aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/linux
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/8250_pci.h2
-rw-r--r--include/linux/a.out.h268
-rw-r--r--include/linux/ac97_codec.h374
-rw-r--r--include/linux/acct.h201
-rw-r--r--include/linux/acpi.h536
-rw-r--r--include/linux/adb.h104
-rw-r--r--include/linux/adfs_fs.h76
-rw-r--r--include/linux/adfs_fs_i.h24
-rw-r--r--include/linux/adfs_fs_sb.h38
-rw-r--r--include/linux/affs_fs.h7
-rw-r--r--include/linux/affs_hardblocks.h66
-rw-r--r--include/linux/agp_backend.h109
-rw-r--r--include/linux/agpgart.h214
-rw-r--r--include/linux/aio.h201
-rw-r--r--include/linux/aio_abi.h92
-rw-r--r--include/linux/amifd.h62
-rw-r--r--include/linux/amifdreg.h81
-rw-r--r--include/linux/amigaffs.h144
-rw-r--r--include/linux/apm_bios.h218
-rw-r--r--include/linux/arcdevice.h350
-rw-r--r--include/linux/ata.h268
-rw-r--r--include/linux/atalk.h245
-rw-r--r--include/linux/atm.h243
-rw-r--r--include/linux/atm_eni.h23
-rw-r--r--include/linux/atm_he.h20
-rw-r--r--include/linux/atm_idt77105.h28
-rw-r--r--include/linux/atm_nicstar.h53
-rw-r--r--include/linux/atm_suni.h12
-rw-r--r--include/linux/atm_tcp.h75
-rw-r--r--include/linux/atm_zatm.h52
-rw-r--r--include/linux/atmapi.h29
-rw-r--r--include/linux/atmarp.h43
-rw-r--r--include/linux/atmbr2684.h101
-rw-r--r--include/linux/atmclip.h21
-rw-r--r--include/linux/atmdev.h489
-rw-r--r--include/linux/atmioc.h41
-rw-r--r--include/linux/atmlec.h88
-rw-r--r--include/linux/atmmpc.h125
-rw-r--r--include/linux/atmppp.h24
-rw-r--r--include/linux/atmsap.h162
-rw-r--r--include/linux/atmsvc.h55
-rw-r--r--include/linux/attribute_container.h73
-rw-r--r--include/linux/audit.h196
-rw-r--r--include/linux/auto_fs.h84
-rw-r--r--include/linux/auto_fs4.h57
-rw-r--r--include/linux/awe_voice.h525
-rw-r--r--include/linux/ax25.h116
-rw-r--r--include/linux/b1lli.h73
-rw-r--r--include/linux/b1pcmcia.h21
-rw-r--r--include/linux/backing-dev.h104
-rw-r--r--include/linux/backlight.h57
-rw-r--r--include/linux/baycom.h39
-rw-r--r--include/linux/bcd.h20
-rw-r--r--include/linux/bfs_fs.h79
-rw-r--r--include/linux/binfmts.h87
-rw-r--r--include/linux/bio.h339
-rw-r--r--include/linux/bitmap.h261
-rw-r--r--include/linux/bitops.h159
-rw-r--r--include/linux/blkdev.h759
-rw-r--r--include/linux/blkpg.h57
-rw-r--r--include/linux/blockgroup_lock.h60
-rw-r--r--include/linux/bootmem.h96
-rw-r--r--include/linux/bpqether.h41
-rw-r--r--include/linux/buffer_head.h296
-rw-r--r--include/linux/byteorder/big_endian.h106
-rw-r--r--include/linux/byteorder/generic.h172
-rw-r--r--include/linux/byteorder/little_endian.h106
-rw-r--r--include/linux/byteorder/pdp_endian.h88
-rw-r--r--include/linux/byteorder/swab.h192
-rw-r--r--include/linux/byteorder/swabb.h137
-rw-r--r--include/linux/cache.h51
-rw-r--r--include/linux/capability.h360
-rw-r--r--include/linux/capi.h133
-rw-r--r--include/linux/cciss_ioctl.h240
-rw-r--r--include/linux/cd1400.h292
-rw-r--r--include/linux/cdev.h27
-rw-r--r--include/linux/cdk.h486
-rw-r--r--include/linux/cdrom.h1192
-rw-r--r--include/linux/circ_buf.h32
-rw-r--r--include/linux/cobalt-nvram.h109
-rw-r--r--include/linux/coda.h788
-rw-r--r--include/linux/coda_cache.h22
-rw-r--r--include/linux/coda_fs_i.h55
-rw-r--r--include/linux/coda_linux.h102
-rw-r--r--include/linux/coda_proc.h76
-rw-r--r--include/linux/coda_psdev.h103
-rw-r--r--include/linux/coff.h351
-rw-r--r--include/linux/com20020.h115
-rw-r--r--include/linux/compat.h162
-rw-r--r--include/linux/compat_ioctl.h771
-rw-r--r--include/linux/compiler-gcc.h17
-rw-r--r--include/linux/compiler-gcc2.h24
-rw-r--r--include/linux/compiler-gcc3.h32
-rw-r--r--include/linux/compiler-gcc4.h16
-rw-r--r--include/linux/compiler-intel.h24
-rw-r--r--include/linux/compiler.h152
-rw-r--r--include/linux/completion.h42
-rw-r--r--include/linux/comstats.h119
-rw-r--r--include/linux/concap.h113
-rw-r--r--include/linux/config.h6
-rw-r--r--include/linux/console.h133
-rw-r--r--include/linux/console_struct.h123
-rw-r--r--include/linux/consolemap.h15
-rw-r--r--include/linux/cpu.h83
-rw-r--r--include/linux/cpufreq.h328
-rw-r--r--include/linux/cpumask.h395
-rw-r--r--include/linux/cpuset.h64
-rw-r--r--include/linux/cramfs_fs.h98
-rw-r--r--include/linux/cramfs_fs_sb.h20
-rw-r--r--include/linux/crc-ccitt.h17
-rw-r--r--include/linux/crc32.h27
-rw-r--r--include/linux/crc32c.h11
-rw-r--r--include/linux/crypto.h398
-rw-r--r--include/linux/cryptohash.h12
-rw-r--r--include/linux/ctype.h54
-rw-r--r--include/linux/cuda.h36
-rw-r--r--include/linux/cyclades.h827
-rw-r--r--include/linux/cyclomx.h80
-rw-r--r--include/linux/cycx_cfm.h101
-rw-r--r--include/linux/cycx_drv.h65
-rw-r--r--include/linux/cycx_x25.h125
-rw-r--r--include/linux/dcache.h338
-rw-r--r--include/linux/dcookies.h69
-rw-r--r--include/linux/debugfs.h92
-rw-r--r--include/linux/delay.h50
-rw-r--r--include/linux/devfs_fs.h41
-rw-r--r--include/linux/devfs_fs_kernel.h58
-rw-r--r--include/linux/device-mapper.h130
-rw-r--r--include/linux/device.h426
-rw-r--r--include/linux/devpts_fs.h34
-rw-r--r--include/linux/dio.h312
-rw-r--r--include/linux/dirent.h32
-rw-r--r--include/linux/divert.h132
-rw-r--r--include/linux/dm-ioctl.h308
-rw-r--r--include/linux/dma-mapping.h56
-rw-r--r--include/linux/dmapool.h27
-rw-r--r--include/linux/dmi.h47
-rw-r--r--include/linux/dn.h147
-rw-r--r--include/linux/dnotify.h63
-rw-r--r--include/linux/dqblk_v1.h18
-rw-r--r--include/linux/dqblk_v2.h20
-rw-r--r--include/linux/dqblk_xfs.h159
-rw-r--r--include/linux/ds1286.h54
-rw-r--r--include/linux/dtlk.h104
-rw-r--r--include/linux/dvb/audio.h124
-rw-r--r--include/linux/dvb/ca.h90
-rw-r--r--include/linux/dvb/dmx.h180
-rw-r--r--include/linux/dvb/frontend.h267
-rw-r--r--include/linux/dvb/net.h53
-rw-r--r--include/linux/dvb/osd.h144
-rw-r--r--include/linux/dvb/version.h29
-rw-r--r--include/linux/dvb/video.h203
-rw-r--r--include/linux/edd.h194
-rw-r--r--include/linux/eeprom.h136
-rw-r--r--include/linux/efi.h398
-rw-r--r--include/linux/efs_dir.h42
-rw-r--r--include/linux/efs_fs.h51
-rw-r--r--include/linux/efs_fs_i.h68
-rw-r--r--include/linux/efs_fs_sb.h62
-rw-r--r--include/linux/efs_vh.h53
-rw-r--r--include/linux/eisa.h107
-rw-r--r--include/linux/elevator.h145
-rw-r--r--include/linux/elf-fdpic.h68
-rw-r--r--include/linux/elf.h449
-rw-r--r--include/linux/elfcore.h129
-rw-r--r--include/linux/err.h31
-rw-r--r--include/linux/errno.h29
-rw-r--r--include/linux/errqueue.h47
-rw-r--r--include/linux/etherdevice.h88
-rw-r--r--include/linux/ethtool.h471
-rw-r--r--include/linux/eventpoll.h99
-rw-r--r--include/linux/ext2_fs.h553
-rw-r--r--include/linux/ext2_fs_sb.h58
-rw-r--r--include/linux/ext3_fs.h830
-rw-r--r--include/linux/ext3_fs_i.h138
-rw-r--r--include/linux/ext3_fs_sb.h83
-rw-r--r--include/linux/ext3_jbd.h265
-rw-r--r--include/linux/fadvise.h11
-rw-r--r--include/linux/fb.h932
-rw-r--r--include/linux/fcdevice.h33
-rw-r--r--include/linux/fcntl.h50
-rw-r--r--include/linux/fd.h374
-rw-r--r--include/linux/fd1772.h80
-rw-r--r--include/linux/fddidevice.h33
-rw-r--r--include/linux/fdreg.h137
-rw-r--r--include/linux/file.h84
-rw-r--r--include/linux/filter.h151
-rw-r--r--include/linux/firmware.h20
-rw-r--r--include/linux/flat.h100
-rw-r--r--include/linux/font.h53
-rw-r--r--include/linux/fs.h1677
-rw-r--r--include/linux/fs_struct.h28
-rw-r--r--include/linux/fsl_devices.h78
-rw-r--r--include/linux/ftape-header-segment.h122
-rw-r--r--include/linux/ftape-vendors.h137
-rw-r--r--include/linux/ftape.h202
-rw-r--r--include/linux/futex.h17
-rw-r--r--include/linux/gameport.h198
-rw-r--r--include/linux/gen_stats.h67
-rw-r--r--include/linux/generic_serial.h96
-rw-r--r--include/linux/genhd.h424
-rw-r--r--include/linux/gfp.h134
-rw-r--r--include/linux/hardirq.h106
-rw-r--r--include/linux/harrier_defs.h212
-rw-r--r--include/linux/hash.h58
-rw-r--r--include/linux/hayesesp.h124
-rw-r--r--include/linux/hdlc.h258
-rw-r--r--include/linux/hdlc/ioctl.h48
-rw-r--r--include/linux/hdlcdrv.h378
-rw-r--r--include/linux/hdpu_features.h26
-rw-r--r--include/linux/hdreg.h703
-rw-r--r--include/linux/hdsmart.h124
-rw-r--r--include/linux/hiddev.h240
-rw-r--r--include/linux/highmem.h104
-rw-r--r--include/linux/highuid.h98
-rw-r--r--include/linux/hippidevice.h35
-rw-r--r--include/linux/hpet.h136
-rw-r--r--include/linux/hpfs_fs.h8
-rw-r--r--include/linux/hugetlb.h142
-rw-r--r--include/linux/hysdn_if.h33
-rw-r--r--include/linux/i2c-algo-bit.h54
-rw-r--r--include/linux/i2c-algo-ite.h69
-rw-r--r--include/linux/i2c-algo-pca.h17
-rw-r--r--include/linux/i2c-algo-pcf.h49
-rw-r--r--include/linux/i2c-algo-sgi.h27
-rw-r--r--include/linux/i2c-algo-sibyte.h33
-rw-r--r--include/linux/i2c-dev.h48
-rw-r--r--include/linux/i2c-id.h319
-rw-r--r--include/linux/i2c-sensor.h263
-rw-r--r--include/linux/i2c-vid.h99
-rw-r--r--include/linux/i2c.h594
-rw-r--r--include/linux/i2o-dev.h402
-rw-r--r--include/linux/i2o.h1003
-rw-r--r--include/linux/i8k.h46
-rw-r--r--include/linux/ibmtr.h373
-rw-r--r--include/linux/icmp.h96
-rw-r--r--include/linux/icmpv6.h171
-rw-r--r--include/linux/ide.h1516
-rw-r--r--include/linux/idr.h78
-rw-r--r--include/linux/if.h193
-rw-r--r--include/linux/if_arcnet.h137
-rw-r--r--include/linux/if_arp.h150
-rw-r--r--include/linux/if_bonding.h117
-rw-r--r--include/linux/if_bridge.h113
-rw-r--r--include/linux/if_cablemodem.h22
-rw-r--r--include/linux/if_ec.h72
-rw-r--r--include/linux/if_eql.h84
-rw-r--r--include/linux/if_ether.h115
-rw-r--r--include/linux/if_fc.h50
-rw-r--r--include/linux/if_fddi.h197
-rw-r--r--include/linux/if_frad.h200
-rw-r--r--include/linux/if_hippi.h157
-rw-r--r--include/linux/if_infiniband.h29
-rw-r--r--include/linux/if_ltalk.h12
-rw-r--r--include/linux/if_packet.h102
-rw-r--r--include/linux/if_plip.h28
-rw-r--r--include/linux/if_ppp.h155
-rw-r--r--include/linux/if_pppox.h175
-rw-r--r--include/linux/if_shaper.h64
-rw-r--r--include/linux/if_slip.h30
-rw-r--r--include/linux/if_strip.h25
-rw-r--r--include/linux/if_tr.h109
-rw-r--r--include/linux/if_tun.h93
-rw-r--r--include/linux/if_tunnel.h29
-rw-r--r--include/linux/if_vlan.h398
-rw-r--r--include/linux/if_wanpipe.h124
-rw-r--r--include/linux/if_wanpipe_common.h60
-rw-r--r--include/linux/igmp.h219
-rw-r--r--include/linux/in.h253
-rw-r--r--include/linux/in6.h201
-rw-r--r--include/linux/in_route.h32
-rw-r--r--include/linux/inet.h50
-rw-r--r--include/linux/inetdevice.h190
-rw-r--r--include/linux/init.h250
-rw-r--r--include/linux/init_task.h125
-rw-r--r--include/linux/initrd.h20
-rw-r--r--include/linux/input.h1016
-rw-r--r--include/linux/interrupt.h289
-rw-r--r--include/linux/ioc4_common.h21
-rw-r--r--include/linux/ioctl.h7
-rw-r--r--include/linux/ioctl32.h37
-rw-r--r--include/linux/ioport.h127
-rw-r--r--include/linux/ip.h221
-rw-r--r--include/linux/ip6_tunnel.h34
-rw-r--r--include/linux/ip_mp_alg.h22
-rw-r--r--include/linux/ipc.h75
-rw-r--r--include/linux/ipmi.h602
-rw-r--r--include/linux/ipmi_msgdefs.h101
-rw-r--r--include/linux/ipmi_smi.h156
-rw-r--r--include/linux/ipsec.h46
-rw-r--r--include/linux/ipv6.h316
-rw-r--r--include/linux/ipv6_route.h49
-rw-r--r--include/linux/ipx.h74
-rw-r--r--include/linux/irda.h222
-rw-r--r--include/linux/irq.h97
-rw-r--r--include/linux/irq_cpustat.h32
-rw-r--r--include/linux/isapnp.h142
-rw-r--r--include/linux/isdn.h638
-rw-r--r--include/linux/isdn/capicmd.h115
-rw-r--r--include/linux/isdn/capilli.h113
-rw-r--r--include/linux/isdn/capiutil.h505
-rw-r--r--include/linux/isdn/tpam.h56
-rw-r--r--include/linux/isdn_divertif.h42
-rw-r--r--include/linux/isdn_ppp.h249
-rw-r--r--include/linux/isdnif.h547
-rw-r--r--include/linux/isicom.h131
-rw-r--r--include/linux/iso_fs.h312
-rw-r--r--include/linux/iso_fs_i.h27
-rw-r--r--include/linux/iso_fs_sb.h34
-rw-r--r--include/linux/istallion.h132
-rw-r--r--include/linux/ite_gpio.h66
-rw-r--r--include/linux/ixjuser.h722
-rw-r--r--include/linux/jbd.h1098
-rw-r--r--include/linux/jffs.h224
-rw-r--r--include/linux/jffs2.h157
-rw-r--r--include/linux/jffs2_fs_i.h47
-rw-r--r--include/linux/jffs2_fs_sb.h118
-rw-r--r--include/linux/jhash.h143
-rw-r--r--include/linux/jiffies.h450
-rw-r--r--include/linux/journal-head.h92
-rw-r--r--include/linux/joystick.h128
-rw-r--r--include/linux/kallsyms.h67
-rw-r--r--include/linux/kbd_diacr.h8
-rw-r--r--include/linux/kbd_kern.h157
-rw-r--r--include/linux/kd.h175
-rw-r--r--include/linux/kdev_t.h101
-rw-r--r--include/linux/kernel.h307
-rw-r--r--include/linux/kernel_stat.h59
-rw-r--r--include/linux/kernelcapi.h161
-rw-r--r--include/linux/key-ui.h97
-rw-r--r--include/linux/key.h291
-rw-r--r--include/linux/keyboard.h431
-rw-r--r--include/linux/keyctl.h39
-rw-r--r--include/linux/kfifo.h157
-rw-r--r--include/linux/kmalloc_sizes.h33
-rw-r--r--include/linux/kmod.h40
-rw-r--r--include/linux/kobj_map.h12
-rw-r--r--include/linux/kobject.h259
-rw-r--r--include/linux/kobject_uevent.h57
-rw-r--r--include/linux/kprobes.h136
-rw-r--r--include/linux/kref.h32
-rw-r--r--include/linux/kthread.h81
-rw-r--r--include/linux/lapb.h56
-rw-r--r--include/linux/lcd.h56
-rw-r--r--include/linux/libata.h599
-rw-r--r--include/linux/libps2.h50
-rw-r--r--include/linux/limits.h22
-rw-r--r--include/linux/linkage.h47
-rw-r--r--include/linux/linux_logo.h37
-rw-r--r--include/linux/list.h707
-rw-r--r--include/linux/llc.h80
-rw-r--r--include/linux/lockd/bind.h36
-rw-r--r--include/linux/lockd/debug.h57
-rw-r--r--include/linux/lockd/lockd.h224
-rw-r--r--include/linux/lockd/nlm.h58
-rw-r--r--include/linux/lockd/share.h30
-rw-r--r--include/linux/lockd/sm_inter.h46
-rw-r--r--include/linux/lockd/xdr.h108
-rw-r--r--include/linux/lockd/xdr4.h46
-rw-r--r--include/linux/loop.h161
-rw-r--r--include/linux/lp.h191
-rw-r--r--include/linux/major.h167
-rw-r--r--include/linux/matroxfb.h43
-rw-r--r--include/linux/mbcache.h52
-rw-r--r--include/linux/mc146818rtc.h92
-rw-r--r--include/linux/mc6821.h51
-rw-r--r--include/linux/mca-legacy.h67
-rw-r--r--include/linux/mca.h146
-rw-r--r--include/linux/mempolicy.h229
-rw-r--r--include/linux/mempool.h37
-rw-r--r--include/linux/meye.h66
-rw-r--r--include/linux/mii.h223
-rw-r--r--include/linux/minix_fs.h85
-rw-r--r--include/linux/miscdevice.h52
-rw-r--r--include/linux/mm.h861
-rw-r--r--include/linux/mm_inline.h40
-rw-r--r--include/linux/mman.h67
-rw-r--r--include/linux/mmc/card.h92
-rw-r--r--include/linux/mmc/host.h108
-rw-r--r--include/linux/mmc/mmc.h101
-rw-r--r--include/linux/mmc/protocol.h213
-rw-r--r--include/linux/mmtimer.h56
-rw-r--r--include/linux/mmzone.h426
-rw-r--r--include/linux/mod_devicetable.h178
-rw-r--r--include/linux/module.h570
-rw-r--r--include/linux/moduleloader.h47
-rw-r--r--include/linux/moduleparam.h182
-rw-r--r--include/linux/mount.h81
-rw-r--r--include/linux/mpage.h31
-rw-r--r--include/linux/mqueue.h55
-rw-r--r--include/linux/mroute.h226
-rw-r--r--include/linux/msdos_fs.h412
-rw-r--r--include/linux/msg.h96
-rw-r--r--include/linux/mtd/blktrans.h72
-rw-r--r--include/linux/mtd/cfi.h394
-rw-r--r--include/linux/mtd/cfi_endian.h57
-rw-r--r--include/linux/mtd/compatmac.h10
-rw-r--r--include/linux/mtd/concat.h23
-rw-r--r--include/linux/mtd/doc2000.h195
-rw-r--r--include/linux/mtd/flashchip.h89
-rw-r--r--include/linux/mtd/ftl.h76
-rw-r--r--include/linux/mtd/gen_probe.h23
-rw-r--r--include/linux/mtd/iflash.h98
-rw-r--r--include/linux/mtd/inftl.h57
-rw-r--r--include/linux/mtd/jedec.h66
-rw-r--r--include/linux/mtd/map.h412
-rw-r--r--include/linux/mtd/mtd.h226
-rw-r--r--include/linux/mtd/nand.h469
-rw-r--r--include/linux/mtd/nand_ecc.h30
-rw-r--r--include/linux/mtd/nftl.h54
-rw-r--r--include/linux/mtd/partitions.h75
-rw-r--r--include/linux/mtd/physmap.h61
-rw-r--r--include/linux/mtd/pmc551.h79
-rw-r--r--include/linux/mtd/xip.h107
-rw-r--r--include/linux/mtio.h351
-rw-r--r--include/linux/mv643xx.h1313
-rw-r--r--include/linux/n_r3964.h226
-rw-r--r--include/linux/namei.h87
-rw-r--r--include/linux/namespace.h42
-rw-r--r--include/linux/nbd.h91
-rw-r--r--include/linux/ncp.h201
-rw-r--r--include/linux/ncp_fs.h300
-rw-r--r--include/linux/ncp_fs_i.h33
-rw-r--r--include/linux/ncp_fs_sb.h157
-rw-r--r--include/linux/ncp_mount.h93
-rw-r--r--include/linux/ncp_no.h19
-rw-r--r--include/linux/net.h287
-rw-r--r--include/linux/netdevice.h933
-rw-r--r--include/linux/netfilter.h199
-rw-r--r--include/linux/netfilter_arp.h20
-rw-r--r--include/linux/netfilter_arp/arp_tables.h340
-rw-r--r--include/linux/netfilter_arp/arpt_mangle.h26
-rw-r--r--include/linux/netfilter_bridge.h113
-rw-r--r--include/linux/netfilter_bridge/ebt_802_3.h69
-rw-r--r--include/linux/netfilter_bridge/ebt_among.h65
-rw-r--r--include/linux/netfilter_bridge/ebt_arp.h32
-rw-r--r--include/linux/netfilter_bridge/ebt_arpreply.h11
-rw-r--r--include/linux/netfilter_bridge/ebt_ip.h43
-rw-r--r--include/linux/netfilter_bridge/ebt_limit.h23
-rw-r--r--include/linux/netfilter_bridge/ebt_log.h17
-rw-r--r--include/linux/netfilter_bridge/ebt_mark_m.h15
-rw-r--r--include/linux/netfilter_bridge/ebt_mark_t.h12
-rw-r--r--include/linux/netfilter_bridge/ebt_nat.h13
-rw-r--r--include/linux/netfilter_bridge/ebt_pkttype.h11
-rw-r--r--include/linux/netfilter_bridge/ebt_redirect.h11
-rw-r--r--include/linux/netfilter_bridge/ebt_stp.h46
-rw-r--r--include/linux/netfilter_bridge/ebt_ulog.h36
-rw-r--r--include/linux/netfilter_bridge/ebt_vlan.h20
-rw-r--r--include/linux/netfilter_bridge/ebtables.h363
-rw-r--r--include/linux/netfilter_decnet.h59
-rw-r--r--include/linux/netfilter_ipv4.h90
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack.h314
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack_amanda.h11
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack_core.h52
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack_ftp.h43
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack_helper.h41
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack_icmp.h11
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack_irc.h32
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack_protocol.h89
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack_sctp.h25
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack_tcp.h51
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack_tftp.h20
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack_tuple.h145
-rw-r--r--include/linux/netfilter_ipv4/ip_logging.h20
-rw-r--r--include/linux/netfilter_ipv4/ip_nat.h87
-rw-r--r--include/linux/netfilter_ipv4/ip_nat_core.h20
-rw-r--r--include/linux/netfilter_ipv4/ip_nat_helper.h33
-rw-r--r--include/linux/netfilter_ipv4/ip_nat_protocol.h70
-rw-r--r--include/linux/netfilter_ipv4/ip_nat_rule.h23
-rw-r--r--include/linux/netfilter_ipv4/ip_queue.h72
-rw-r--r--include/linux/netfilter_ipv4/ip_tables.h490
-rw-r--r--include/linux/netfilter_ipv4/ipt_CLASSIFY.h8
-rw-r--r--include/linux/netfilter_ipv4/ipt_CLUSTERIP.h32
-rw-r--r--include/linux/netfilter_ipv4/ipt_CONNMARK.h25
-rw-r--r--include/linux/netfilter_ipv4/ipt_DSCP.h20
-rw-r--r--include/linux/netfilter_ipv4/ipt_ECN.h31
-rw-r--r--include/linux/netfilter_ipv4/ipt_LOG.h16
-rw-r--r--include/linux/netfilter_ipv4/ipt_MARK.h20
-rw-r--r--include/linux/netfilter_ipv4/ipt_REJECT.h20
-rw-r--r--include/linux/netfilter_ipv4/ipt_SAME.h19
-rw-r--r--include/linux/netfilter_ipv4/ipt_TCPMSS.h10
-rw-r--r--include/linux/netfilter_ipv4/ipt_TOS.h12
-rw-r--r--include/linux/netfilter_ipv4/ipt_ULOG.h49
-rw-r--r--include/linux/netfilter_ipv4/ipt_addrtype.h11
-rw-r--r--include/linux/netfilter_ipv4/ipt_ah.h16
-rw-r--r--include/linux/netfilter_ipv4/ipt_comment.h10
-rw-r--r--include/linux/netfilter_ipv4/ipt_connmark.h18
-rw-r--r--include/linux/netfilter_ipv4/ipt_conntrack.h60
-rw-r--r--include/linux/netfilter_ipv4/ipt_dscp.h23
-rw-r--r--include/linux/netfilter_ipv4/ipt_ecn.h33
-rw-r--r--include/linux/netfilter_ipv4/ipt_esp.h16
-rw-r--r--include/linux/netfilter_ipv4/ipt_hashlimit.h40
-rw-r--r--include/linux/netfilter_ipv4/ipt_helper.h8
-rw-r--r--include/linux/netfilter_ipv4/ipt_iprange.h23
-rw-r--r--include/linux/netfilter_ipv4/ipt_length.h9
-rw-r--r--include/linux/netfilter_ipv4/ipt_limit.h21
-rw-r--r--include/linux/netfilter_ipv4/ipt_mac.h8
-rw-r--r--include/linux/netfilter_ipv4/ipt_mark.h9
-rw-r--r--include/linux/netfilter_ipv4/ipt_multiport.h30
-rw-r--r--include/linux/netfilter_ipv4/ipt_owner.h20
-rw-r--r--include/linux/netfilter_ipv4/ipt_physdev.h24
-rw-r--r--include/linux/netfilter_ipv4/ipt_pkttype.h8
-rw-r--r--include/linux/netfilter_ipv4/ipt_realm.h10
-rw-r--r--include/linux/netfilter_ipv4/ipt_recent.h27
-rw-r--r--include/linux/netfilter_ipv4/ipt_sctp.h107
-rw-r--r--include/linux/netfilter_ipv4/ipt_state.h13
-rw-r--r--include/linux/netfilter_ipv4/ipt_tcpmss.h9
-rw-r--r--include/linux/netfilter_ipv4/ipt_tos.h13
-rw-r--r--include/linux/netfilter_ipv4/ipt_ttl.h21
-rw-r--r--include/linux/netfilter_ipv4/listhelp.h125
-rw-r--r--include/linux/netfilter_ipv4/lockhelp.h129
-rw-r--r--include/linux/netfilter_ipv6.h71
-rw-r--r--include/linux/netfilter_ipv6/ip6_logging.h20
-rw-r--r--include/linux/netfilter_ipv6/ip6_tables.h461
-rw-r--r--include/linux/netfilter_ipv6/ip6t_LOG.h16
-rw-r--r--include/linux/netfilter_ipv6/ip6t_MARK.h8
-rw-r--r--include/linux/netfilter_ipv6/ip6t_ah.h30
-rw-r--r--include/linux/netfilter_ipv6/ip6t_esp.h23
-rw-r--r--include/linux/netfilter_ipv6/ip6t_frag.h33
-rw-r--r--include/linux/netfilter_ipv6/ip6t_hl.h22
-rw-r--r--include/linux/netfilter_ipv6/ip6t_ipv6header.h27
-rw-r--r--include/linux/netfilter_ipv6/ip6t_length.h10
-rw-r--r--include/linux/netfilter_ipv6/ip6t_limit.h21
-rw-r--r--include/linux/netfilter_ipv6/ip6t_mac.h8
-rw-r--r--include/linux/netfilter_ipv6/ip6t_mark.h9
-rw-r--r--include/linux/netfilter_ipv6/ip6t_multiport.h21
-rw-r--r--include/linux/netfilter_ipv6/ip6t_opts.h32
-rw-r--r--include/linux/netfilter_ipv6/ip6t_owner.h18
-rw-r--r--include/linux/netfilter_ipv6/ip6t_physdev.h24
-rw-r--r--include/linux/netfilter_ipv6/ip6t_rt.h42
-rw-r--r--include/linux/netfilter_logging.h33
-rw-r--r--include/linux/netlink.h188
-rw-r--r--include/linux/netpoll.h67
-rw-r--r--include/linux/netrom.h34
-rw-r--r--include/linux/nfs.h171
-rw-r--r--include/linux/nfs2.h74
-rw-r--r--include/linux/nfs3.h105
-rw-r--r--include/linux/nfs4.h394
-rw-r--r--include/linux/nfs4_acl.h59
-rw-r--r--include/linux/nfs4_mount.h70
-rw-r--r--include/linux/nfs_fs.h767
-rw-r--r--include/linux/nfs_fs_i.h25
-rw-r--r--include/linux/nfs_fs_sb.h58
-rw-r--r--include/linux/nfs_idmap.h76
-rw-r--r--include/linux/nfs_mount.h65
-rw-r--r--include/linux/nfs_page.h151
-rw-r--r--include/linux/nfs_xdr.h735
-rw-r--r--include/linux/nfsd/auth.h27
-rw-r--r--include/linux/nfsd/cache.h81
-rw-r--r--include/linux/nfsd/const.h45
-rw-r--r--include/linux/nfsd/debug.h48
-rw-r--r--include/linux/nfsd/export.h137
-rw-r--r--include/linux/nfsd/interface.h13
-rw-r--r--include/linux/nfsd/nfsd.h311
-rw-r--r--include/linux/nfsd/nfsfh.h343
-rw-r--r--include/linux/nfsd/state.h298
-rw-r--r--include/linux/nfsd/stats.h44
-rw-r--r--include/linux/nfsd/syscall.h125
-rw-r--r--include/linux/nfsd/xdr.h172
-rw-r--r--include/linux/nfsd/xdr3.h321
-rw-r--r--include/linux/nfsd/xdr4.h463
-rw-r--r--include/linux/nfsd_idmap.h54
-rw-r--r--include/linux/nls.h64
-rw-r--r--include/linux/nmi.h22
-rw-r--r--include/linux/node.h33
-rw-r--r--include/linux/nodemask.h356
-rw-r--r--include/linux/notifier.h75
-rw-r--r--include/linux/nubus.h334
-rw-r--r--include/linux/numa.h16
-rw-r--r--include/linux/nvram.h27
-rw-r--r--include/linux/openprom_fs.h10
-rw-r--r--include/linux/oprofile.h119
-rw-r--r--include/linux/page-flags.h324
-rw-r--r--include/linux/pagemap.h246
-rw-r--r--include/linux/pagevec.h85
-rw-r--r--include/linux/param.h6
-rw-r--r--include/linux/parport.h552
-rw-r--r--include/linux/parport_pc.h238
-rw-r--r--include/linux/parser.h33
-rw-r--r--include/linux/pci-acpi.h61
-rw-r--r--include/linux/pci-dynids.h18
-rw-r--r--include/linux/pci.h1067
-rw-r--r--include/linux/pci_ids.h2562
-rw-r--r--include/linux/pcieport_if.h74
-rw-r--r--include/linux/percpu.h61
-rw-r--r--include/linux/percpu_counter.h107
-rw-r--r--include/linux/personality.h114
-rw-r--r--include/linux/pfkeyv2.h336
-rw-r--r--include/linux/pg.h63
-rw-r--r--include/linux/phonedev.h26
-rw-r--r--include/linux/pid.h55
-rw-r--r--include/linux/pipe_fs_i.h59
-rw-r--r--include/linux/pkt_cls.h426
-rw-r--r--include/linux/pkt_sched.h454
-rw-r--r--include/linux/pktcdvd.h275
-rw-r--r--include/linux/platform.h43
-rw-r--r--include/linux/pm.h233
-rw-r--r--include/linux/pmu.h240
-rw-r--r--include/linux/pnp.h454
-rw-r--r--include/linux/pnpbios.h157
-rw-r--r--include/linux/poll.h99
-rw-r--r--include/linux/posix-timers.h139
-rw-r--r--include/linux/posix_acl.h86
-rw-r--r--include/linux/posix_acl_xattr.h55
-rw-r--r--include/linux/posix_types.h49
-rw-r--r--include/linux/ppdev.h101
-rw-r--r--include/linux/ppp-comp.h207
-rw-r--r--include/linux/ppp_channel.h81
-rw-r--r--include/linux/ppp_defs.h190
-rw-r--r--include/linux/prctl.h55
-rw-r--r--include/linux/preempt.h62
-rw-r--r--include/linux/prefetch.h69
-rw-r--r--include/linux/prio_tree.h120
-rw-r--r--include/linux/proc_fs.h259
-rw-r--r--include/linux/profile.h104
-rw-r--r--include/linux/ps2esdi.h98
-rw-r--r--include/linux/ptrace.h122
-rw-r--r--include/linux/qic117.h290
-rw-r--r--include/linux/qnx4_fs.h150
-rw-r--r--include/linux/qnxtypes.h29
-rw-r--r--include/linux/quota.h327
-rw-r--r--include/linux/quotaio_v1.h33
-rw-r--r--include/linux/quotaio_v2.h79
-rw-r--r--include/linux/quotaops.h246
-rw-r--r--include/linux/radeonfb.h15
-rw-r--r--include/linux/radix-tree.h71
-rw-r--r--include/linux/raid/linear.h27
-rw-r--r--include/linux/raid/md.h84
-rw-r--r--include/linux/raid/md_k.h369
-rw-r--r--include/linux/raid/md_p.h230
-rw-r--r--include/linux/raid/md_u.h117
-rw-r--r--include/linux/raid/multipath.h42
-rw-r--r--include/linux/raid/raid0.h30
-rw-r--r--include/linux/raid/raid1.h98
-rw-r--r--include/linux/raid/raid10.h103
-rw-r--r--include/linux/raid/raid5.h243
-rw-r--r--include/linux/raid/xor.h23
-rw-r--r--include/linux/ramfs.h11
-rw-r--r--include/linux/random.h72
-rw-r--r--include/linux/raw.h18
-rw-r--r--include/linux/rbtree.h141
-rw-r--r--include/linux/rcupdate.h271
-rw-r--r--include/linux/reboot.h56
-rw-r--r--include/linux/reiserfs_acl.h89
-rw-r--r--include/linux/reiserfs_fs.h2255
-rw-r--r--include/linux/reiserfs_fs_i.h63
-rw-r--r--include/linux/reiserfs_fs_sb.h535
-rw-r--r--include/linux/reiserfs_xattr.h139
-rw-r--r--include/linux/resource.h70
-rw-r--r--include/linux/rmap.h118
-rw-r--r--include/linux/romfs_fs.h61
-rw-r--r--include/linux/root_dev.h21
-rw-r--r--include/linux/rose.h87
-rw-r--r--include/linux/route.h70
-rw-r--r--include/linux/rslib.h105
-rw-r--r--include/linux/rtc.h108
-rw-r--r--include/linux/rtnetlink.h842
-rw-r--r--include/linux/rwsem-spinlock.h65
-rw-r--r--include/linux/rwsem.h115
-rw-r--r--include/linux/sc26198.h533
-rw-r--r--include/linux/scatterlist.h14
-rw-r--r--include/linux/scc.h253
-rw-r--r--include/linux/sched.h1273
-rw-r--r--include/linux/sctp.h594
-rw-r--r--include/linux/scx200.h58
-rw-r--r--include/linux/scx200_gpio.h96
-rw-r--r--include/linux/sdla.h339
-rw-r--r--include/linux/sdla_asy.h226
-rw-r--r--include/linux/sdla_chdlc.h813
-rw-r--r--include/linux/sdla_fr.h638
-rw-r--r--include/linux/sdla_ppp.h575
-rw-r--r--include/linux/sdla_x25.h772
-rw-r--r--include/linux/sdladrv.h70
-rw-r--r--include/linux/sdlapci.h72
-rw-r--r--include/linux/sdlasfm.h104
-rw-r--r--include/linux/seccomp.h34
-rw-r--r--include/linux/securebits.h30
-rw-r--r--include/linux/security.h2858
-rw-r--r--include/linux/selection.h40
-rw-r--r--include/linux/selinux_netlink.h37
-rw-r--r--include/linux/sem.h157
-rw-r--r--include/linux/seq_file.h54
-rw-r--r--include/linux/seqlock.h175
-rw-r--r--include/linux/serial.h188
-rw-r--r--include/linux/serial167.h171
-rw-r--r--include/linux/serialP.h184
-rw-r--r--include/linux/serial_8250.h28
-rw-r--r--include/linux/serial_core.h491
-rw-r--r--include/linux/serial_reg.h325
-rw-r--r--include/linux/serio.h214
-rw-r--r--include/linux/shm.h108
-rw-r--r--include/linux/shmem_fs.h37
-rw-r--r--include/linux/signal.h224
-rw-r--r--include/linux/skbuff.h1253
-rw-r--r--include/linux/slab.h129
-rw-r--r--include/linux/smb.h117
-rw-r--r--include/linux/smb_fs.h204
-rw-r--r--include/linux/smb_fs_i.h39
-rw-r--r--include/linux/smb_fs_sb.h101
-rw-r--r--include/linux/smb_mount.h65
-rw-r--r--include/linux/smbno.h363
-rw-r--r--include/linux/smp.h139
-rw-r--r--include/linux/smp_lock.h54
-rw-r--r--include/linux/snmp.h266
-rw-r--r--include/linux/socket.h295
-rw-r--r--include/linux/sockios.h143
-rw-r--r--include/linux/som.h154
-rw-r--r--include/linux/sonet.h75
-rw-r--r--include/linux/sonypi.h158
-rw-r--r--include/linux/sort.h10
-rw-r--r--include/linux/sound.h42
-rw-r--r--include/linux/soundcard.h1298
-rw-r--r--include/linux/spinlock.h606
-rw-r--r--include/linux/stallion.h154
-rw-r--r--include/linux/stat.h77
-rw-r--r--include/linux/statfs.h22
-rw-r--r--include/linux/stddef.h20
-rw-r--r--include/linux/stop_machine.h52
-rw-r--r--include/linux/string.h96
-rw-r--r--include/linux/stringify.h12
-rw-r--r--include/linux/sunrpc/auth.h149
-rw-r--r--include/linux/sunrpc/auth_gss.h97
-rw-r--r--include/linux/sunrpc/cache.h312
-rw-r--r--include/linux/sunrpc/clnt.h153
-rw-r--r--include/linux/sunrpc/debug.h99
-rw-r--r--include/linux/sunrpc/gss_api.h122
-rw-r--r--include/linux/sunrpc/gss_asn1.h81
-rw-r--r--include/linux/sunrpc/gss_err.h177
-rw-r--r--include/linux/sunrpc/gss_krb5.h148
-rw-r--r--include/linux/sunrpc/gss_spkm3.h61
-rw-r--r--include/linux/sunrpc/msg_prot.h80
-rw-r--r--include/linux/sunrpc/rpc_pipe_fs.h50
-rw-r--r--include/linux/sunrpc/sched.h273
-rw-r--r--include/linux/sunrpc/stats.h78
-rw-r--r--include/linux/sunrpc/svc.h306
-rw-r--r--include/linux/sunrpc/svcauth.h167
-rw-r--r--include/linux/sunrpc/svcauth_gss.h27
-rw-r--r--include/linux/sunrpc/svcsock.h65
-rw-r--r--include/linux/sunrpc/timer.h49
-rw-r--r--include/linux/sunrpc/types.h22
-rw-r--r--include/linux/sunrpc/xdr.h192
-rw-r--r--include/linux/sunrpc/xprt.h232
-rw-r--r--include/linux/superhyway.h79
-rw-r--r--include/linux/suspend.h75
-rw-r--r--include/linux/swap.h293
-rw-r--r--include/linux/swapops.h69
-rw-r--r--include/linux/synclink.h273
-rw-r--r--include/linux/sys.h29
-rw-r--r--include/linux/syscalls.h509
-rw-r--r--include/linux/sysctl.h898
-rw-r--r--include/linux/sysdev.h94
-rw-r--r--include/linux/sysfs.h182
-rw-r--r--include/linux/sysrq.h60
-rw-r--r--include/linux/sysv_fs.h206
-rw-r--r--include/linux/tc_act/tc_gact.h34
-rw-r--r--include/linux/tc_act/tc_ipt.h21
-rw-r--r--include/linux/tc_act/tc_mirred.h28
-rw-r--r--include/linux/tc_act/tc_pedit.h36
-rw-r--r--include/linux/tc_ematch/tc_em_cmp.h26
-rw-r--r--include/linux/tc_ematch/tc_em_meta.h69
-rw-r--r--include/linux/tc_ematch/tc_em_nbyte.h13
-rw-r--r--include/linux/tcp.h448
-rw-r--r--include/linux/tcp_diag.h127
-rw-r--r--include/linux/telephony.h266
-rw-r--r--include/linux/termios.h7
-rw-r--r--include/linux/thread_info.h92
-rw-r--r--include/linux/threads.h36
-rw-r--r--include/linux/ticable.h44
-rw-r--r--include/linux/time.h181
-rw-r--r--include/linux/timer.h102
-rw-r--r--include/linux/times.h13
-rw-r--r--include/linux/timex.h320
-rw-r--r--include/linux/tiocl.h38
-rw-r--r--include/linux/topology.h136
-rw-r--r--include/linux/toshiba.h36
-rw-r--r--include/linux/transport_class.h95
-rw-r--r--include/linux/trdevice.h37
-rw-r--r--include/linux/tty.h412
-rw-r--r--include/linux/tty_driver.h279
-rw-r--r--include/linux/tty_flip.h35
-rw-r--r--include/linux/tty_ldisc.h154
-rw-r--r--include/linux/types.h172
-rw-r--r--include/linux/udf_fs.h59
-rw-r--r--include/linux/udf_fs_i.h78
-rw-r--r--include/linux/udf_fs_sb.h122
-rw-r--r--include/linux/udp.h63
-rw-r--r--include/linux/ufs_fs.h943
-rw-r--r--include/linux/ufs_fs_i.h33
-rw-r--r--include/linux/ufs_fs_sb.h38
-rw-r--r--include/linux/uinput.h167
-rw-r--r--include/linux/uio.h66
-rw-r--r--include/linux/ultrasound.h103
-rw-r--r--include/linux/umem.h138
-rw-r--r--include/linux/un.h11
-rw-r--r--include/linux/unistd.h11
-rw-r--r--include/linux/usb.h1157
-rw-r--r--include/linux/usb_cdc.h192
-rw-r--r--include/linux/usb_ch9.h384
-rw-r--r--include/linux/usb_gadget.h878
-rw-r--r--include/linux/usb_gadgetfs.h75
-rw-r--r--include/linux/usb_otg.h118
-rw-r--r--include/linux/usb_sl811.h26
-rw-r--r--include/linux/usbdevice_fs.h168
-rw-r--r--include/linux/user.h1
-rw-r--r--include/linux/utime.h9
-rw-r--r--include/linux/uts.h19
-rw-r--r--include/linux/utsname.h36
-rw-r--r--include/linux/vermagic.h23
-rw-r--r--include/linux/vfs.h6
-rw-r--r--include/linux/via.h22
-rw-r--r--include/linux/video_decoder.h44
-rw-r--r--include/linux/video_encoder.h21
-rw-r--r--include/linux/videodev.h443
-rw-r--r--include/linux/videodev2.h977
-rw-r--r--include/linux/videotext.h125
-rw-r--r--include/linux/vmalloc.h54
-rw-r--r--include/linux/vt.h54
-rw-r--r--include/linux/vt_buffer.h64
-rw-r--r--include/linux/vt_kern.h86
-rw-r--r--include/linux/wait.h460
-rw-r--r--include/linux/wanpipe.h492
-rw-r--r--include/linux/wanrouter.h541
-rw-r--r--include/linux/watchdog.h50
-rw-r--r--include/linux/wavefront.h675
-rw-r--r--include/linux/wireless.h773
-rw-r--r--include/linux/workqueue.h90
-rw-r--r--include/linux/writeback.h118
-rw-r--r--include/linux/x25.h112
-rw-r--r--include/linux/xattr.h33
-rw-r--r--include/linux/xattr_acl.h50
-rw-r--r--include/linux/xfrm.h258
-rw-r--r--include/linux/yam.h82
-rw-r--r--include/linux/zconf.h45
-rw-r--r--include/linux/zftape.h87
-rw-r--r--include/linux/zlib.h637
-rw-r--r--include/linux/zorro.h329
-rw-r--r--include/linux/zorro_ids.h552
-rw-r--r--include/linux/zutil.h119
838 files changed, 141083 insertions, 0 deletions
diff --git a/include/linux/8250_pci.h b/include/linux/8250_pci.h
new file mode 100644
index 000000000000..5f3ab21b339b
--- /dev/null
+++ b/include/linux/8250_pci.h
@@ -0,0 +1,2 @@
1int pci_siig10x_fn(struct pci_dev *dev, int enable);
2int pci_siig20x_fn(struct pci_dev *dev, int enable);
diff --git a/include/linux/a.out.h b/include/linux/a.out.h
new file mode 100644
index 000000000000..af8a1dfa5c32
--- /dev/null
+++ b/include/linux/a.out.h
@@ -0,0 +1,268 @@
1#ifndef __A_OUT_GNU_H__
2#define __A_OUT_GNU_H__
3
4#define __GNU_EXEC_MACROS__
5
6#ifndef __STRUCT_EXEC_OVERRIDE__
7
8#include <asm/a.out.h>
9
10#endif /* __STRUCT_EXEC_OVERRIDE__ */
11
12/* these go in the N_MACHTYPE field */
13enum machine_type {
14#if defined (M_OLDSUN2)
15 M__OLDSUN2 = M_OLDSUN2,
16#else
17 M_OLDSUN2 = 0,
18#endif
19#if defined (M_68010)
20 M__68010 = M_68010,
21#else
22 M_68010 = 1,
23#endif
24#if defined (M_68020)
25 M__68020 = M_68020,
26#else
27 M_68020 = 2,
28#endif
29#if defined (M_SPARC)
30 M__SPARC = M_SPARC,
31#else
32 M_SPARC = 3,
33#endif
34 /* skip a bunch so we don't run into any of sun's numbers */
35 M_386 = 100,
36 M_MIPS1 = 151, /* MIPS R3000/R3000 binary */
37 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
38};
39
40#if !defined (N_MAGIC)
41#define N_MAGIC(exec) ((exec).a_info & 0xffff)
42#endif
43#define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
44#define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
45#define N_SET_INFO(exec, magic, type, flags) \
46 ((exec).a_info = ((magic) & 0xffff) \
47 | (((int)(type) & 0xff) << 16) \
48 | (((flags) & 0xff) << 24))
49#define N_SET_MAGIC(exec, magic) \
50 ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
51
52#define N_SET_MACHTYPE(exec, machtype) \
53 ((exec).a_info = \
54 ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
55
56#define N_SET_FLAGS(exec, flags) \
57 ((exec).a_info = \
58 ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
59
60/* Code indicating object file or impure executable. */
61#define OMAGIC 0407
62/* Code indicating pure executable. */
63#define NMAGIC 0410
64/* Code indicating demand-paged executable. */
65#define ZMAGIC 0413
66/* This indicates a demand-paged executable with the header in the text.
67 The first page is unmapped to help trap NULL pointer references */
68#define QMAGIC 0314
69
70/* Code indicating core file. */
71#define CMAGIC 0421
72
73#if !defined (N_BADMAG)
74#define N_BADMAG(x) (N_MAGIC(x) != OMAGIC \
75 && N_MAGIC(x) != NMAGIC \
76 && N_MAGIC(x) != ZMAGIC \
77 && N_MAGIC(x) != QMAGIC)
78#endif
79
80#define _N_HDROFF(x) (1024 - sizeof (struct exec))
81
82#if !defined (N_TXTOFF)
83#define N_TXTOFF(x) \
84 (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : \
85 (N_MAGIC(x) == QMAGIC ? 0 : sizeof (struct exec)))
86#endif
87
88#if !defined (N_DATOFF)
89#define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
90#endif
91
92#if !defined (N_TRELOFF)
93#define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
94#endif
95
96#if !defined (N_DRELOFF)
97#define N_DRELOFF(x) (N_TRELOFF(x) + N_TRSIZE(x))
98#endif
99
100#if !defined (N_SYMOFF)
101#define N_SYMOFF(x) (N_DRELOFF(x) + N_DRSIZE(x))
102#endif
103
104#if !defined (N_STROFF)
105#define N_STROFF(x) (N_SYMOFF(x) + N_SYMSIZE(x))
106#endif
107
108/* Address of text segment in memory after it is loaded. */
109#if !defined (N_TXTADDR)
110#define N_TXTADDR(x) (N_MAGIC(x) == QMAGIC ? PAGE_SIZE : 0)
111#endif
112
113/* Address of data segment in memory after it is loaded.
114 Note that it is up to you to define SEGMENT_SIZE
115 on machines not listed here. */
116#if defined(vax) || defined(hp300) || defined(pyr)
117#define SEGMENT_SIZE page_size
118#endif
119#ifdef sony
120#define SEGMENT_SIZE 0x2000
121#endif /* Sony. */
122#ifdef is68k
123#define SEGMENT_SIZE 0x20000
124#endif
125#if defined(m68k) && defined(PORTAR)
126#define PAGE_SIZE 0x400
127#define SEGMENT_SIZE PAGE_SIZE
128#endif
129
130#ifdef linux
131#include <asm/page.h>
132#if defined(__i386__) || defined(__mc68000__)
133#define SEGMENT_SIZE 1024
134#else
135#ifndef SEGMENT_SIZE
136#define SEGMENT_SIZE PAGE_SIZE
137#endif
138#endif
139#endif
140
141#define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))
142
143#define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
144
145#ifndef N_DATADDR
146#define N_DATADDR(x) \
147 (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \
148 : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
149#endif
150
151/* Address of bss segment in memory after it is loaded. */
152#if !defined (N_BSSADDR)
153#define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
154#endif
155
156#if !defined (N_NLIST_DECLARED)
157struct nlist {
158 union {
159 char *n_name;
160 struct nlist *n_next;
161 long n_strx;
162 } n_un;
163 unsigned char n_type;
164 char n_other;
165 short n_desc;
166 unsigned long n_value;
167};
168#endif /* no N_NLIST_DECLARED. */
169
170#if !defined (N_UNDF)
171#define N_UNDF 0
172#endif
173#if !defined (N_ABS)
174#define N_ABS 2
175#endif
176#if !defined (N_TEXT)
177#define N_TEXT 4
178#endif
179#if !defined (N_DATA)
180#define N_DATA 6
181#endif
182#if !defined (N_BSS)
183#define N_BSS 8
184#endif
185#if !defined (N_FN)
186#define N_FN 15
187#endif
188
189#if !defined (N_EXT)
190#define N_EXT 1
191#endif
192#if !defined (N_TYPE)
193#define N_TYPE 036
194#endif
195#if !defined (N_STAB)
196#define N_STAB 0340
197#endif
198
199/* The following type indicates the definition of a symbol as being
200 an indirect reference to another symbol. The other symbol
201 appears as an undefined reference, immediately following this symbol.
202
203 Indirection is asymmetrical. The other symbol's value will be used
204 to satisfy requests for the indirect symbol, but not vice versa.
205 If the other symbol does not have a definition, libraries will
206 be searched to find a definition. */
207#define N_INDR 0xa
208
209/* The following symbols refer to set elements.
210 All the N_SET[ATDB] symbols with the same name form one set.
211 Space is allocated for the set in the text section, and each set
212 element's value is stored into one word of the space.
213 The first word of the space is the length of the set (number of elements).
214
215 The address of the set is made into an N_SETV symbol
216 whose name is the same as the name of the set.
217 This symbol acts like a N_DATA global symbol
218 in that it can satisfy undefined external references. */
219
220/* These appear as input to LD, in a .o file. */
221#define N_SETA 0x14 /* Absolute set element symbol */
222#define N_SETT 0x16 /* Text set element symbol */
223#define N_SETD 0x18 /* Data set element symbol */
224#define N_SETB 0x1A /* Bss set element symbol */
225
226/* This is output from LD. */
227#define N_SETV 0x1C /* Pointer to set vector in data area. */
228
229#if !defined (N_RELOCATION_INFO_DECLARED)
230/* This structure describes a single relocation to be performed.
231 The text-relocation section of the file is a vector of these structures,
232 all of which apply to the text section.
233 Likewise, the data-relocation section applies to the data section. */
234
235struct relocation_info
236{
237 /* Address (within segment) to be relocated. */
238 int r_address;
239 /* The meaning of r_symbolnum depends on r_extern. */
240 unsigned int r_symbolnum:24;
241 /* Nonzero means value is a pc-relative offset
242 and it should be relocated for changes in its own address
243 as well as for changes in the symbol or section specified. */
244 unsigned int r_pcrel:1;
245 /* Length (as exponent of 2) of the field to be relocated.
246 Thus, a value of 2 indicates 1<<2 bytes. */
247 unsigned int r_length:2;
248 /* 1 => relocate with value of symbol.
249 r_symbolnum is the index of the symbol
250 in file's the symbol table.
251 0 => relocate with the address of a segment.
252 r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
253 (the N_EXT bit may be set also, but signifies nothing). */
254 unsigned int r_extern:1;
255 /* Four bits that aren't used, but when writing an object file
256 it is desirable to clear them. */
257#ifdef NS32K
258 unsigned r_bsr:1;
259 unsigned r_disp:1;
260 unsigned r_pad:2;
261#else
262 unsigned int r_pad:4;
263#endif
264};
265#endif /* no N_RELOCATION_INFO_DECLARED. */
266
267
268#endif /* __A_OUT_GNU_H__ */
diff --git a/include/linux/ac97_codec.h b/include/linux/ac97_codec.h
new file mode 100644
index 000000000000..c35833824e11
--- /dev/null
+++ b/include/linux/ac97_codec.h
@@ -0,0 +1,374 @@
1#ifndef _AC97_CODEC_H_
2#define _AC97_CODEC_H_
3
4#include <linux/types.h>
5#include <linux/soundcard.h>
6
7/* AC97 1.0 */
8#define AC97_RESET 0x0000 //
9#define AC97_MASTER_VOL_STEREO 0x0002 // Line Out
10#define AC97_HEADPHONE_VOL 0x0004 //
11#define AC97_MASTER_VOL_MONO 0x0006 // TAD Output
12#define AC97_MASTER_TONE 0x0008 //
13#define AC97_PCBEEP_VOL 0x000a // none
14#define AC97_PHONE_VOL 0x000c // TAD Input (mono)
15#define AC97_MIC_VOL 0x000e // MIC Input (mono)
16#define AC97_LINEIN_VOL 0x0010 // Line Input (stereo)
17#define AC97_CD_VOL 0x0012 // CD Input (stereo)
18#define AC97_VIDEO_VOL 0x0014 // none
19#define AC97_AUX_VOL 0x0016 // Aux Input (stereo)
20#define AC97_PCMOUT_VOL 0x0018 // Wave Output (stereo)
21#define AC97_RECORD_SELECT 0x001a //
22#define AC97_RECORD_GAIN 0x001c
23#define AC97_RECORD_GAIN_MIC 0x001e
24#define AC97_GENERAL_PURPOSE 0x0020
25#define AC97_3D_CONTROL 0x0022
26#define AC97_MODEM_RATE 0x0024
27#define AC97_POWER_CONTROL 0x0026
28
29/* AC'97 2.0 */
30#define AC97_EXTENDED_ID 0x0028 /* Extended Audio ID */
31#define AC97_EXTENDED_STATUS 0x002A /* Extended Audio Status */
32#define AC97_PCM_FRONT_DAC_RATE 0x002C /* PCM Front DAC Rate */
33#define AC97_PCM_SURR_DAC_RATE 0x002E /* PCM Surround DAC Rate */
34#define AC97_PCM_LFE_DAC_RATE 0x0030 /* PCM LFE DAC Rate */
35#define AC97_PCM_LR_ADC_RATE 0x0032 /* PCM LR ADC Rate */
36#define AC97_PCM_MIC_ADC_RATE 0x0034 /* PCM MIC ADC Rate */
37#define AC97_CENTER_LFE_MASTER 0x0036 /* Center + LFE Master Volume */
38#define AC97_SURROUND_MASTER 0x0038 /* Surround (Rear) Master Volume */
39#define AC97_RESERVED_3A 0x003A /* Reserved in AC '97 < 2.2 */
40
41/* AC'97 2.2 */
42#define AC97_SPDIF_CONTROL 0x003A /* S/PDIF Control */
43
44/* range 0x3c-0x58 - MODEM */
45#define AC97_EXTENDED_MODEM_ID 0x003C
46#define AC97_EXTEND_MODEM_STAT 0x003E
47#define AC97_LINE1_RATE 0x0040
48#define AC97_LINE2_RATE 0x0042
49#define AC97_HANDSET_RATE 0x0044
50#define AC97_LINE1_LEVEL 0x0046
51#define AC97_LINE2_LEVEL 0x0048
52#define AC97_HANDSET_LEVEL 0x004A
53#define AC97_GPIO_CONFIG 0x004C
54#define AC97_GPIO_POLARITY 0x004E
55#define AC97_GPIO_STICKY 0x0050
56#define AC97_GPIO_WAKE_UP 0x0052
57#define AC97_GPIO_STATUS 0x0054
58#define AC97_MISC_MODEM_STAT 0x0056
59#define AC97_RESERVED_58 0x0058
60
61/* registers 0x005a - 0x007a are vendor reserved */
62
63#define AC97_VENDOR_ID1 0x007c
64#define AC97_VENDOR_ID2 0x007e
65
66/* volume control bit defines */
67#define AC97_MUTE 0x8000
68#define AC97_MICBOOST 0x0040
69#define AC97_LEFTVOL 0x3f00
70#define AC97_RIGHTVOL 0x003f
71
72/* record mux defines */
73#define AC97_RECMUX_MIC 0x0000
74#define AC97_RECMUX_CD 0x0101
75#define AC97_RECMUX_VIDEO 0x0202
76#define AC97_RECMUX_AUX 0x0303
77#define AC97_RECMUX_LINE 0x0404
78#define AC97_RECMUX_STEREO_MIX 0x0505
79#define AC97_RECMUX_MONO_MIX 0x0606
80#define AC97_RECMUX_PHONE 0x0707
81
82/* general purpose register bit defines */
83#define AC97_GP_LPBK 0x0080 /* Loopback mode */
84#define AC97_GP_MS 0x0100 /* Mic Select 0=Mic1, 1=Mic2 */
85#define AC97_GP_MIX 0x0200 /* Mono output select 0=Mix, 1=Mic */
86#define AC97_GP_RLBK 0x0400 /* Remote Loopback - Modem line codec */
87#define AC97_GP_LLBK 0x0800 /* Local Loopback - Modem Line codec */
88#define AC97_GP_LD 0x1000 /* Loudness 1=on */
89#define AC97_GP_3D 0x2000 /* 3D Enhancement 1=on */
90#define AC97_GP_ST 0x4000 /* Stereo Enhancement 1=on */
91#define AC97_GP_POP 0x8000 /* Pcm Out Path, 0=pre 3D, 1=post 3D */
92
93/* extended audio status and control bit defines */
94#define AC97_EA_VRA 0x0001 /* Variable bit rate enable bit */
95#define AC97_EA_DRA 0x0002 /* Double-rate audio enable bit */
96#define AC97_EA_SPDIF 0x0004 /* S/PDIF Enable bit */
97#define AC97_EA_VRM 0x0008 /* Variable bit rate for MIC enable bit */
98#define AC97_EA_CDAC 0x0040 /* PCM Center DAC is ready (Read only) */
99#define AC97_EA_SDAC 0x0040 /* PCM Surround DACs are ready (Read only) */
100#define AC97_EA_LDAC 0x0080 /* PCM LFE DAC is ready (Read only) */
101#define AC97_EA_MDAC 0x0100 /* MIC ADC is ready (Read only) */
102#define AC97_EA_SPCV 0x0400 /* S/PDIF configuration valid (Read only) */
103#define AC97_EA_PRI 0x0800 /* Turns the PCM Center DAC off */
104#define AC97_EA_PRJ 0x1000 /* Turns the PCM Surround DACs off */
105#define AC97_EA_PRK 0x2000 /* Turns the PCM LFE DAC off */
106#define AC97_EA_PRL 0x4000 /* Turns the MIC ADC off */
107#define AC97_EA_SLOT_MASK 0xffcf /* Mask for slot assignment bits */
108#define AC97_EA_SPSA_3_4 0x0000 /* Slot assigned to 3 & 4 */
109#define AC97_EA_SPSA_7_8 0x0010 /* Slot assigned to 7 & 8 */
110#define AC97_EA_SPSA_6_9 0x0020 /* Slot assigned to 6 & 9 */
111#define AC97_EA_SPSA_10_11 0x0030 /* Slot assigned to 10 & 11 */
112
113/* S/PDIF control bit defines */
114#define AC97_SC_PRO 0x0001 /* Professional status */
115#define AC97_SC_NAUDIO 0x0002 /* Non audio stream */
116#define AC97_SC_COPY 0x0004 /* Copyright status */
117#define AC97_SC_PRE 0x0008 /* Preemphasis status */
118#define AC97_SC_CC_MASK 0x07f0 /* Category Code mask */
119#define AC97_SC_L 0x0800 /* Generation Level status */
120#define AC97_SC_SPSR_MASK 0xcfff /* S/PDIF Sample Rate bits */
121#define AC97_SC_SPSR_44K 0x0000 /* Use 44.1kHz Sample rate */
122#define AC97_SC_SPSR_48K 0x2000 /* Use 48kHz Sample rate */
123#define AC97_SC_SPSR_32K 0x3000 /* Use 32kHz Sample rate */
124#define AC97_SC_DRS 0x4000 /* Double Rate S/PDIF */
125#define AC97_SC_V 0x8000 /* Validity status */
126
127/* powerdown control and status bit defines */
128
129/* status */
130#define AC97_PWR_MDM 0x0010 /* Modem section ready */
131#define AC97_PWR_REF 0x0008 /* Vref nominal */
132#define AC97_PWR_ANL 0x0004 /* Analog section ready */
133#define AC97_PWR_DAC 0x0002 /* DAC section ready */
134#define AC97_PWR_ADC 0x0001 /* ADC section ready */
135
136/* control */
137#define AC97_PWR_PR0 0x0100 /* ADC and Mux powerdown */
138#define AC97_PWR_PR1 0x0200 /* DAC powerdown */
139#define AC97_PWR_PR2 0x0400 /* Output mixer powerdown (Vref on) */
140#define AC97_PWR_PR3 0x0800 /* Output mixer powerdown (Vref off) */
141#define AC97_PWR_PR4 0x1000 /* AC-link powerdown */
142#define AC97_PWR_PR5 0x2000 /* Internal Clk disable */
143#define AC97_PWR_PR6 0x4000 /* HP amp powerdown */
144#define AC97_PWR_PR7 0x8000 /* Modem off - if supported */
145
146/* extended audio ID register bit defines */
147#define AC97_EXTID_VRA 0x0001
148#define AC97_EXTID_DRA 0x0002
149#define AC97_EXTID_SPDIF 0x0004
150#define AC97_EXTID_VRM 0x0008
151#define AC97_EXTID_DSA0 0x0010
152#define AC97_EXTID_DSA1 0x0020
153#define AC97_EXTID_CDAC 0x0040
154#define AC97_EXTID_SDAC 0x0080
155#define AC97_EXTID_LDAC 0x0100
156#define AC97_EXTID_AMAP 0x0200
157#define AC97_EXTID_REV0 0x0400
158#define AC97_EXTID_REV1 0x0800
159#define AC97_EXTID_ID0 0x4000
160#define AC97_EXTID_ID1 0x8000
161
162/* extended status register bit defines */
163#define AC97_EXTSTAT_VRA 0x0001
164#define AC97_EXTSTAT_DRA 0x0002
165#define AC97_EXTSTAT_SPDIF 0x0004
166#define AC97_EXTSTAT_VRM 0x0008
167#define AC97_EXTSTAT_SPSA0 0x0010
168#define AC97_EXTSTAT_SPSA1 0x0020
169#define AC97_EXTSTAT_CDAC 0x0040
170#define AC97_EXTSTAT_SDAC 0x0080
171#define AC97_EXTSTAT_LDAC 0x0100
172#define AC97_EXTSTAT_MADC 0x0200
173#define AC97_EXTSTAT_SPCV 0x0400
174#define AC97_EXTSTAT_PRI 0x0800
175#define AC97_EXTSTAT_PRJ 0x1000
176#define AC97_EXTSTAT_PRK 0x2000
177#define AC97_EXTSTAT_PRL 0x4000
178
179/* extended audio ID register bit defines */
180#define AC97_EXTID_VRA 0x0001
181#define AC97_EXTID_DRA 0x0002
182#define AC97_EXTID_SPDIF 0x0004
183#define AC97_EXTID_VRM 0x0008
184#define AC97_EXTID_DSA0 0x0010
185#define AC97_EXTID_DSA1 0x0020
186#define AC97_EXTID_CDAC 0x0040
187#define AC97_EXTID_SDAC 0x0080
188#define AC97_EXTID_LDAC 0x0100
189#define AC97_EXTID_AMAP 0x0200
190#define AC97_EXTID_REV0 0x0400
191#define AC97_EXTID_REV1 0x0800
192#define AC97_EXTID_ID0 0x4000
193#define AC97_EXTID_ID1 0x8000
194
195/* extended status register bit defines */
196#define AC97_EXTSTAT_VRA 0x0001
197#define AC97_EXTSTAT_DRA 0x0002
198#define AC97_EXTSTAT_SPDIF 0x0004
199#define AC97_EXTSTAT_VRM 0x0008
200#define AC97_EXTSTAT_SPSA0 0x0010
201#define AC97_EXTSTAT_SPSA1 0x0020
202#define AC97_EXTSTAT_CDAC 0x0040
203#define AC97_EXTSTAT_SDAC 0x0080
204#define AC97_EXTSTAT_LDAC 0x0100
205#define AC97_EXTSTAT_MADC 0x0200
206#define AC97_EXTSTAT_SPCV 0x0400
207#define AC97_EXTSTAT_PRI 0x0800
208#define AC97_EXTSTAT_PRJ 0x1000
209#define AC97_EXTSTAT_PRK 0x2000
210#define AC97_EXTSTAT_PRL 0x4000
211
212/* useful power states */
213#define AC97_PWR_D0 0x0000 /* everything on */
214#define AC97_PWR_D1 AC97_PWR_PR0|AC97_PWR_PR1|AC97_PWR_PR4
215#define AC97_PWR_D2 AC97_PWR_PR0|AC97_PWR_PR1|AC97_PWR_PR2|AC97_PWR_PR3|AC97_PWR_PR4
216#define AC97_PWR_D3 AC97_PWR_PR0|AC97_PWR_PR1|AC97_PWR_PR2|AC97_PWR_PR3|AC97_PWR_PR4
217#define AC97_PWR_ANLOFF AC97_PWR_PR2|AC97_PWR_PR3 /* analog section off */
218
219/* Total number of defined registers. */
220#define AC97_REG_CNT 64
221
222
223/* OSS interface to the ac97s.. */
224#define AC97_STEREO_MASK (SOUND_MASK_VOLUME|SOUND_MASK_PCM|\
225 SOUND_MASK_LINE|SOUND_MASK_CD|\
226 SOUND_MASK_ALTPCM|SOUND_MASK_IGAIN|\
227 SOUND_MASK_LINE1|SOUND_MASK_VIDEO)
228
229#define AC97_SUPPORTED_MASK (AC97_STEREO_MASK | \
230 SOUND_MASK_BASS|SOUND_MASK_TREBLE|\
231 SOUND_MASK_SPEAKER|SOUND_MASK_MIC|\
232 SOUND_MASK_PHONEIN|SOUND_MASK_PHONEOUT)
233
234#define AC97_RECORD_MASK (SOUND_MASK_MIC|\
235 SOUND_MASK_CD|SOUND_MASK_IGAIN|SOUND_MASK_VIDEO|\
236 SOUND_MASK_LINE1| SOUND_MASK_LINE|\
237 SOUND_MASK_PHONEIN)
238
239/* original check is not good enough in case FOO is greater than
240 * SOUND_MIXER_NRDEVICES because the supported_mixers has exactly
241 * SOUND_MIXER_NRDEVICES elements.
242 * before matching the given mixer against the bitmask in supported_mixers we
243 * check if mixer number exceeds maximum allowed size which is as mentioned
244 * above SOUND_MIXER_NRDEVICES */
245#define supported_mixer(CODEC,FOO) ((FOO >= 0) && \
246 (FOO < SOUND_MIXER_NRDEVICES) && \
247 (CODEC)->supported_mixers & (1<<FOO) )
248
249struct ac97_codec {
250 /* Linked list of codecs */
251 struct list_head list;
252
253 /* AC97 controller connected with */
254 void *private_data;
255
256 char *name;
257 int id;
258 int dev_mixer;
259 int type;
260 u32 model;
261
262 int modem:1;
263
264 struct ac97_ops *codec_ops;
265
266 /* controller specific lower leverl ac97 accessing routines.
267 must be re-entrant safe */
268 u16 (*codec_read) (struct ac97_codec *codec, u8 reg);
269 void (*codec_write) (struct ac97_codec *codec, u8 reg, u16 val);
270
271 /* Wait for codec-ready. Ok to sleep here. */
272 void (*codec_wait) (struct ac97_codec *codec);
273
274 /* callback used by helper drivers for interesting ac97 setups */
275 void (*codec_unregister) (struct ac97_codec *codec);
276
277 struct ac97_driver *driver;
278 void *driver_private; /* Private data for the driver */
279
280 spinlock_t lock;
281
282 /* OSS mixer masks */
283 int modcnt;
284 int supported_mixers;
285 int stereo_mixers;
286 int record_sources;
287
288 /* Property flags */
289 int flags;
290
291 int bit_resolution;
292
293 /* OSS mixer interface */
294 int (*read_mixer) (struct ac97_codec *codec, int oss_channel);
295 void (*write_mixer)(struct ac97_codec *codec, int oss_channel,
296 unsigned int left, unsigned int right);
297 int (*recmask_io) (struct ac97_codec *codec, int rw, int mask);
298 int (*mixer_ioctl)(struct ac97_codec *codec, unsigned int cmd, unsigned long arg);
299
300 /* saved OSS mixer states */
301 unsigned int mixer_state[SOUND_MIXER_NRDEVICES];
302
303 /* Software Modem interface */
304 int (*modem_ioctl)(struct ac97_codec *codec, unsigned int cmd, unsigned long arg);
305};
306
307/*
308 * Operation structures for each known AC97 chip
309 */
310
311struct ac97_ops
312{
313 /* Initialise */
314 int (*init)(struct ac97_codec *c);
315 /* Amplifier control */
316 int (*amplifier)(struct ac97_codec *codec, int on);
317 /* Digital mode control */
318 int (*digital)(struct ac97_codec *codec, int slots, int rate, int mode);
319#define AUDIO_DIGITAL 0x8000
320#define AUDIO_PRO 0x4000
321#define AUDIO_DRS 0x2000
322#define AUDIO_CCMASK 0x003F
323
324#define AC97_DELUDED_MODEM 1 /* Audio codec reports its a modem */
325#define AC97_NO_PCM_VOLUME 2 /* Volume control is missing */
326#define AC97_DEFAULT_POWER_OFF 4 /* Needs warm reset to power up */
327};
328
329extern int ac97_read_proc (char *page_out, char **start, off_t off,
330 int count, int *eof, void *data);
331extern int ac97_probe_codec(struct ac97_codec *);
332extern unsigned int ac97_set_adc_rate(struct ac97_codec *codec, unsigned int rate);
333extern unsigned int ac97_set_dac_rate(struct ac97_codec *codec, unsigned int rate);
334extern int ac97_save_state(struct ac97_codec *codec);
335extern int ac97_restore_state(struct ac97_codec *codec);
336
337extern struct ac97_codec *ac97_alloc_codec(void);
338extern void ac97_release_codec(struct ac97_codec *codec);
339
340struct ac97_driver {
341 struct list_head list;
342 char *name;
343 u32 codec_id;
344 u32 codec_mask;
345 int (*probe) (struct ac97_codec *codec, struct ac97_driver *driver);
346 void (*remove) (struct ac97_codec *codec, struct ac97_driver *driver);
347};
348
349extern int ac97_register_driver(struct ac97_driver *driver);
350extern void ac97_unregister_driver(struct ac97_driver *driver);
351
352/* quirk types */
353enum {
354 AC97_TUNE_DEFAULT = -1, /* use default from quirk list (not valid in list) */
355 AC97_TUNE_NONE = 0, /* nothing extra to do */
356 AC97_TUNE_HP_ONLY, /* headphone (true line-out) control as master only */
357 AC97_TUNE_SWAP_HP, /* swap headphone and master controls */
358 AC97_TUNE_SWAP_SURROUND, /* swap master and surround controls */
359 AC97_TUNE_AD_SHARING, /* for AD1985, turn on OMS bit and use headphone */
360 AC97_TUNE_ALC_JACK, /* for Realtek, enable JACK detection */
361};
362
363struct ac97_quirk {
364 unsigned short vendor; /* PCI vendor id */
365 unsigned short device; /* PCI device id */
366 unsigned short mask; /* device id bit mask, 0 = accept all */
367 const char *name; /* name shown as info */
368 int type; /* quirk type above */
369};
370
371struct pci_dev;
372extern int ac97_tune_hardware(struct pci_dev *pdev, struct ac97_quirk *quirk, int override);
373
374#endif /* _AC97_CODEC_H_ */
diff --git a/include/linux/acct.h b/include/linux/acct.h
new file mode 100644
index 000000000000..1993a3691768
--- /dev/null
+++ b/include/linux/acct.h
@@ -0,0 +1,201 @@
1/*
2 * BSD Process Accounting for Linux - Definitions
3 *
4 * Author: Marco van Wieringen (mvw@planets.elm.net)
5 *
6 * This header file contains the definitions needed to implement
7 * BSD-style process accounting. The kernel accounting code and all
8 * user-level programs that try to do something useful with the
9 * process accounting log must include this file.
10 *
11 * Copyright (C) 1995 - 1997 Marco van Wieringen - ELM Consultancy B.V.
12 *
13 */
14
15#ifndef _LINUX_ACCT_H
16#define _LINUX_ACCT_H
17
18#include <linux/types.h>
19#include <asm/param.h>
20#include <asm/byteorder.h>
21
22/*
23 * comp_t is a 16-bit "floating" point number with a 3-bit base 8
24 * exponent and a 13-bit fraction.
25 * comp2_t is 24-bit with 5-bit base 2 exponent and 20 bit fraction
26 * (leading 1 not stored).
27 * See linux/kernel/acct.c for the specific encoding systems used.
28 */
29
30typedef __u16 comp_t;
31typedef __u32 comp2_t;
32
33/*
34 * accounting file record
35 *
36 * This structure contains all of the information written out to the
37 * process accounting file whenever a process exits.
38 */
39
40#define ACCT_COMM 16
41
42struct acct
43{
44 char ac_flag; /* Flags */
45 char ac_version; /* Always set to ACCT_VERSION */
46 /* for binary compatibility back until 2.0 */
47 __u16 ac_uid16; /* LSB of Real User ID */
48 __u16 ac_gid16; /* LSB of Real Group ID */
49 __u16 ac_tty; /* Control Terminal */
50 __u32 ac_btime; /* Process Creation Time */
51 comp_t ac_utime; /* User Time */
52 comp_t ac_stime; /* System Time */
53 comp_t ac_etime; /* Elapsed Time */
54 comp_t ac_mem; /* Average Memory Usage */
55 comp_t ac_io; /* Chars Transferred */
56 comp_t ac_rw; /* Blocks Read or Written */
57 comp_t ac_minflt; /* Minor Pagefaults */
58 comp_t ac_majflt; /* Major Pagefaults */
59 comp_t ac_swaps; /* Number of Swaps */
60/* m68k had no padding here. */
61#if !defined(CONFIG_M68K) || !defined(__KERNEL__)
62 __u16 ac_ahz; /* AHZ */
63#endif
64 __u32 ac_exitcode; /* Exitcode */
65 char ac_comm[ACCT_COMM + 1]; /* Command Name */
66 __u8 ac_etime_hi; /* Elapsed Time MSB */
67 __u16 ac_etime_lo; /* Elapsed Time LSB */
68 __u32 ac_uid; /* Real User ID */
69 __u32 ac_gid; /* Real Group ID */
70};
71
72struct acct_v3
73{
74 char ac_flag; /* Flags */
75 char ac_version; /* Always set to ACCT_VERSION */
76 __u16 ac_tty; /* Control Terminal */
77 __u32 ac_exitcode; /* Exitcode */
78 __u32 ac_uid; /* Real User ID */
79 __u32 ac_gid; /* Real Group ID */
80 __u32 ac_pid; /* Process ID */
81 __u32 ac_ppid; /* Parent Process ID */
82 __u32 ac_btime; /* Process Creation Time */
83#ifdef __KERNEL__
84 __u32 ac_etime; /* Elapsed Time */
85#else
86 float ac_etime; /* Elapsed Time */
87#endif
88 comp_t ac_utime; /* User Time */
89 comp_t ac_stime; /* System Time */
90 comp_t ac_mem; /* Average Memory Usage */
91 comp_t ac_io; /* Chars Transferred */
92 comp_t ac_rw; /* Blocks Read or Written */
93 comp_t ac_minflt; /* Minor Pagefaults */
94 comp_t ac_majflt; /* Major Pagefaults */
95 comp_t ac_swaps; /* Number of Swaps */
96 char ac_comm[ACCT_COMM]; /* Command Name */
97};
98
99/*
100 * accounting flags
101 */
102 /* bit set when the process ... */
103#define AFORK 0x01 /* ... executed fork, but did not exec */
104#define ASU 0x02 /* ... used super-user privileges */
105#define ACOMPAT 0x04 /* ... used compatibility mode (VAX only not used) */
106#define ACORE 0x08 /* ... dumped core */
107#define AXSIG 0x10 /* ... was killed by a signal */
108
109#ifdef __BIG_ENDIAN
110#define ACCT_BYTEORDER 0x80 /* accounting file is big endian */
111#else
112#define ACCT_BYTEORDER 0x00 /* accounting file is little endian */
113#endif
114
115#ifdef __KERNEL__
116
117#include <linux/config.h>
118
119#ifdef CONFIG_BSD_PROCESS_ACCT
120struct super_block;
121extern void acct_auto_close(struct super_block *sb);
122extern void acct_process(long exitcode);
123extern void acct_update_integrals(struct task_struct *tsk);
124extern void acct_clear_integrals(struct task_struct *tsk);
125#else
126#define acct_auto_close(x) do { } while (0)
127#define acct_process(x) do { } while (0)
128#define acct_update_integrals(x) do { } while (0)
129#define acct_clear_integrals(task) do { } while (0)
130#endif
131
132/*
133 * ACCT_VERSION numbers as yet defined:
134 * 0: old format (until 2.6.7) with 16 bit uid/gid
135 * 1: extended variant (binary compatible on M68K)
136 * 2: extended variant (binary compatible on everything except M68K)
137 * 3: new binary incompatible format (64 bytes)
138 * 4: new binary incompatible format (128 bytes)
139 * 5: new binary incompatible format (128 bytes, second half)
140 *
141 */
142
143#ifdef CONFIG_BSD_PROCESS_ACCT_V3
144#define ACCT_VERSION 3
145#define AHZ 100
146typedef struct acct_v3 acct_t;
147#else
148#ifdef CONFIG_M68K
149#define ACCT_VERSION 1
150#else
151#define ACCT_VERSION 2
152#endif
153#define AHZ (USER_HZ)
154typedef struct acct acct_t;
155#endif
156
157#else
158#define ACCT_VERSION 2
159#define AHZ (HZ)
160#endif /* __KERNEL */
161
162#ifdef __KERNEL__
163/*
164 * Yet another set of HZ to *HZ helper functions.
165 * See <linux/times.h> for the original.
166 */
167
168static inline u32 jiffies_to_AHZ(unsigned long x)
169{
170#if (TICK_NSEC % (NSEC_PER_SEC / AHZ)) == 0
171 return x / (HZ / USER_HZ);
172#else
173 u64 tmp = (u64)x * TICK_NSEC;
174 do_div(tmp, (NSEC_PER_SEC / AHZ));
175 return (long)tmp;
176#endif
177}
178
179static inline u64 nsec_to_AHZ(u64 x)
180{
181#if (NSEC_PER_SEC % AHZ) == 0
182 do_div(x, (NSEC_PER_SEC / AHZ));
183#elif (AHZ % 512) == 0
184 x *= AHZ/512;
185 do_div(x, (NSEC_PER_SEC / 512));
186#else
187 /*
188 * max relative error 5.7e-8 (1.8s per year) for AHZ <= 1024,
189 * overflow after 64.99 years.
190 * exact for AHZ=60, 72, 90, 120, 144, 180, 300, 600, 900, ...
191 */
192 x *= 9;
193 do_div(x, (unsigned long)((9ull * NSEC_PER_SEC + (AHZ/2))
194 / AHZ));
195#endif
196 return x;
197}
198
199#endif /* __KERNEL */
200
201#endif /* _LINUX_ACCT_H */
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
new file mode 100644
index 000000000000..aefe6d051ace
--- /dev/null
+++ b/include/linux/acpi.h
@@ -0,0 +1,536 @@
1/*
2 * acpi.h - ACPI Interface
3 *
4 * Copyright (C) 2001 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
5 *
6 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 */
24
25#ifndef _LINUX_ACPI_H
26#define _LINUX_ACPI_H
27
28#ifndef _LINUX
29#define _LINUX
30#endif
31
32#include <linux/list.h>
33
34#include <acpi/acpi.h>
35#include <acpi/acpi_bus.h>
36#include <acpi/acpi_drivers.h>
37#include <asm/acpi.h>
38
39
40#ifdef CONFIG_ACPI_BOOT
41
42enum acpi_irq_model_id {
43 ACPI_IRQ_MODEL_PIC = 0,
44 ACPI_IRQ_MODEL_IOAPIC,
45 ACPI_IRQ_MODEL_IOSAPIC,
46 ACPI_IRQ_MODEL_COUNT
47};
48
49extern enum acpi_irq_model_id acpi_irq_model;
50
51
52/* Root System Description Pointer (RSDP) */
53
54struct acpi_table_rsdp {
55 char signature[8];
56 u8 checksum;
57 char oem_id[6];
58 u8 revision;
59 u32 rsdt_address;
60} __attribute__ ((packed));
61
62struct acpi20_table_rsdp {
63 char signature[8];
64 u8 checksum;
65 char oem_id[6];
66 u8 revision;
67 u32 rsdt_address;
68 u32 length;
69 u64 xsdt_address;
70 u8 ext_checksum;
71 u8 reserved[3];
72} __attribute__ ((packed));
73
74typedef struct {
75 u8 type;
76 u8 length;
77} __attribute__ ((packed)) acpi_table_entry_header;
78
79/* Root System Description Table (RSDT) */
80
81struct acpi_table_rsdt {
82 struct acpi_table_header header;
83 u32 entry[8];
84} __attribute__ ((packed));
85
86/* Extended System Description Table (XSDT) */
87
88struct acpi_table_xsdt {
89 struct acpi_table_header header;
90 u64 entry[1];
91} __attribute__ ((packed));
92
93/* Fixed ACPI Description Table (FADT) */
94
95struct acpi_table_fadt {
96 struct acpi_table_header header;
97 u32 facs_addr;
98 u32 dsdt_addr;
99 /* ... */
100} __attribute__ ((packed));
101
102/* Multiple APIC Description Table (MADT) */
103
104struct acpi_table_madt {
105 struct acpi_table_header header;
106 u32 lapic_address;
107 struct {
108 u32 pcat_compat:1;
109 u32 reserved:31;
110 } flags;
111} __attribute__ ((packed));
112
113enum acpi_madt_entry_id {
114 ACPI_MADT_LAPIC = 0,
115 ACPI_MADT_IOAPIC,
116 ACPI_MADT_INT_SRC_OVR,
117 ACPI_MADT_NMI_SRC,
118 ACPI_MADT_LAPIC_NMI,
119 ACPI_MADT_LAPIC_ADDR_OVR,
120 ACPI_MADT_IOSAPIC,
121 ACPI_MADT_LSAPIC,
122 ACPI_MADT_PLAT_INT_SRC,
123 ACPI_MADT_ENTRY_COUNT
124};
125
126typedef struct {
127 u16 polarity:2;
128 u16 trigger:2;
129 u16 reserved:12;
130} __attribute__ ((packed)) acpi_interrupt_flags;
131
132struct acpi_table_lapic {
133 acpi_table_entry_header header;
134 u8 acpi_id;
135 u8 id;
136 struct {
137 u32 enabled:1;
138 u32 reserved:31;
139 } flags;
140} __attribute__ ((packed));
141
142struct acpi_table_ioapic {
143 acpi_table_entry_header header;
144 u8 id;
145 u8 reserved;
146 u32 address;
147 u32 global_irq_base;
148} __attribute__ ((packed));
149
150struct acpi_table_int_src_ovr {
151 acpi_table_entry_header header;
152 u8 bus;
153 u8 bus_irq;
154 u32 global_irq;
155 acpi_interrupt_flags flags;
156} __attribute__ ((packed));
157
158struct acpi_table_nmi_src {
159 acpi_table_entry_header header;
160 acpi_interrupt_flags flags;
161 u32 global_irq;
162} __attribute__ ((packed));
163
164struct acpi_table_lapic_nmi {
165 acpi_table_entry_header header;
166 u8 acpi_id;
167 acpi_interrupt_flags flags;
168 u8 lint;
169} __attribute__ ((packed));
170
171struct acpi_table_lapic_addr_ovr {
172 acpi_table_entry_header header;
173 u8 reserved[2];
174 u64 address;
175} __attribute__ ((packed));
176
177struct acpi_table_iosapic {
178 acpi_table_entry_header header;
179 u8 id;
180 u8 reserved;
181 u32 global_irq_base;
182 u64 address;
183} __attribute__ ((packed));
184
185struct acpi_table_lsapic {
186 acpi_table_entry_header header;
187 u8 acpi_id;
188 u8 id;
189 u8 eid;
190 u8 reserved[3];
191 struct {
192 u32 enabled:1;
193 u32 reserved:31;
194 } flags;
195} __attribute__ ((packed));
196
197struct acpi_table_plat_int_src {
198 acpi_table_entry_header header;
199 acpi_interrupt_flags flags;
200 u8 type; /* See acpi_interrupt_type */
201 u8 id;
202 u8 eid;
203 u8 iosapic_vector;
204 u32 global_irq;
205 u32 reserved;
206} __attribute__ ((packed));
207
208enum acpi_interrupt_id {
209 ACPI_INTERRUPT_PMI = 1,
210 ACPI_INTERRUPT_INIT,
211 ACPI_INTERRUPT_CPEI,
212 ACPI_INTERRUPT_COUNT
213};
214
215#define ACPI_SPACE_MEM 0
216
217struct acpi_gen_regaddr {
218 u8 space_id;
219 u8 bit_width;
220 u8 bit_offset;
221 u8 resv;
222 u32 addrl;
223 u32 addrh;
224} __attribute__ ((packed));
225
226struct acpi_table_hpet {
227 struct acpi_table_header header;
228 u32 id;
229 struct acpi_gen_regaddr addr;
230 u8 number;
231 u16 min_tick;
232 u8 page_protect;
233} __attribute__ ((packed));
234
235/*
236 * Simple Boot Flags
237 * http://www.microsoft.com/whdc/hwdev/resources/specs/simp_bios.mspx
238 */
239struct acpi_table_sbf
240{
241 u8 sbf_signature[4];
242 u32 sbf_len;
243 u8 sbf_revision;
244 u8 sbf_csum;
245 u8 sbf_oemid[6];
246 u8 sbf_oemtable[8];
247 u8 sbf_revdata[4];
248 u8 sbf_creator[4];
249 u8 sbf_crearev[4];
250 u8 sbf_cmos;
251 u8 sbf_spare[3];
252} __attribute__ ((packed));
253
254/*
255 * System Resource Affinity Table (SRAT)
256 * http://www.microsoft.com/whdc/hwdev/platform/proc/SRAT.mspx
257 */
258
259struct acpi_table_srat {
260 struct acpi_table_header header;
261 u32 table_revision;
262 u64 reserved;
263} __attribute__ ((packed));
264
265enum acpi_srat_entry_id {
266 ACPI_SRAT_PROCESSOR_AFFINITY = 0,
267 ACPI_SRAT_MEMORY_AFFINITY,
268 ACPI_SRAT_ENTRY_COUNT
269};
270
271struct acpi_table_processor_affinity {
272 acpi_table_entry_header header;
273 u8 proximity_domain;
274 u8 apic_id;
275 struct {
276 u32 enabled:1;
277 u32 reserved:31;
278 } flags;
279 u8 lsapic_eid;
280 u8 reserved[7];
281} __attribute__ ((packed));
282
283struct acpi_table_memory_affinity {
284 acpi_table_entry_header header;
285 u8 proximity_domain;
286 u8 reserved1[5];
287 u32 base_addr_lo;
288 u32 base_addr_hi;
289 u32 length_lo;
290 u32 length_hi;
291 u32 memory_type; /* See acpi_address_range_id */
292 struct {
293 u32 enabled:1;
294 u32 hot_pluggable:1;
295 u32 reserved:30;
296 } flags;
297 u64 reserved2;
298} __attribute__ ((packed));
299
300enum acpi_address_range_id {
301 ACPI_ADDRESS_RANGE_MEMORY = 1,
302 ACPI_ADDRESS_RANGE_RESERVED = 2,
303 ACPI_ADDRESS_RANGE_ACPI = 3,
304 ACPI_ADDRESS_RANGE_NVS = 4,
305 ACPI_ADDRESS_RANGE_COUNT
306};
307
308/*
309 * System Locality Information Table (SLIT)
310 * see http://devresource.hp.com/devresource/docs/techpapers/ia64/slit.pdf
311 */
312
313struct acpi_table_slit {
314 struct acpi_table_header header;
315 u64 localities;
316 u8 entry[1]; /* real size = localities^2 */
317} __attribute__ ((packed));
318
319/* Smart Battery Description Table (SBST) */
320
321struct acpi_table_sbst {
322 struct acpi_table_header header;
323 u32 warning; /* Warn user */
324 u32 low; /* Critical sleep */
325 u32 critical; /* Critical shutdown */
326} __attribute__ ((packed));
327
328/* Embedded Controller Boot Resources Table (ECDT) */
329
330struct acpi_table_ecdt {
331 struct acpi_table_header header;
332 struct acpi_generic_address ec_control;
333 struct acpi_generic_address ec_data;
334 u32 uid;
335 u8 gpe_bit;
336 char ec_id[0];
337} __attribute__ ((packed));
338
339/* PCI MMCONFIG */
340
341struct acpi_table_mcfg {
342 struct acpi_table_header header;
343 u8 reserved[8];
344 u32 base_address;
345 u32 base_reserved;
346} __attribute__ ((packed));
347
348/* Table Handlers */
349
350enum acpi_table_id {
351 ACPI_TABLE_UNKNOWN = 0,
352 ACPI_APIC,
353 ACPI_BOOT,
354 ACPI_DBGP,
355 ACPI_DSDT,
356 ACPI_ECDT,
357 ACPI_ETDT,
358 ACPI_FADT,
359 ACPI_FACS,
360 ACPI_OEMX,
361 ACPI_PSDT,
362 ACPI_SBST,
363 ACPI_SLIT,
364 ACPI_SPCR,
365 ACPI_SRAT,
366 ACPI_SSDT,
367 ACPI_SPMI,
368 ACPI_HPET,
369 ACPI_MCFG,
370 ACPI_TABLE_COUNT
371};
372
373typedef int (*acpi_table_handler) (unsigned long phys_addr, unsigned long size);
374
375extern acpi_table_handler acpi_table_ops[ACPI_TABLE_COUNT];
376
377typedef int (*acpi_madt_entry_handler) (acpi_table_entry_header *header, const unsigned long end);
378
379char * __acpi_map_table (unsigned long phys_addr, unsigned long size);
380unsigned long acpi_find_rsdp (void);
381int acpi_boot_init (void);
382int acpi_boot_table_init (void);
383int acpi_numa_init (void);
384
385int acpi_table_init (void);
386int acpi_table_parse (enum acpi_table_id id, acpi_table_handler handler);
387int acpi_get_table_header_early (enum acpi_table_id id, struct acpi_table_header **header);
388int acpi_table_parse_madt (enum acpi_madt_entry_id id, acpi_madt_entry_handler handler, unsigned int max_entries);
389int acpi_table_parse_srat (enum acpi_srat_entry_id id, acpi_madt_entry_handler handler, unsigned int max_entries);
390void acpi_table_print (struct acpi_table_header *header, unsigned long phys_addr);
391void acpi_table_print_madt_entry (acpi_table_entry_header *madt);
392void acpi_table_print_srat_entry (acpi_table_entry_header *srat);
393
394/* the following four functions are architecture-dependent */
395void acpi_numa_slit_init (struct acpi_table_slit *slit);
396void acpi_numa_processor_affinity_init (struct acpi_table_processor_affinity *pa);
397void acpi_numa_memory_affinity_init (struct acpi_table_memory_affinity *ma);
398void acpi_numa_arch_fixup(void);
399
400#ifdef CONFIG_ACPI_HOTPLUG_CPU
401/* Arch dependent functions for cpu hotplug support */
402int acpi_map_lsapic(acpi_handle handle, int *pcpu);
403int acpi_unmap_lsapic(int cpu);
404#endif /* CONFIG_ACPI_HOTPLUG_CPU */
405
406extern int acpi_mp_config;
407
408extern u32 pci_mmcfg_base_addr;
409
410extern int sbf_port ;
411
412#else /*!CONFIG_ACPI_BOOT*/
413
414#define acpi_mp_config 0
415
416static inline int acpi_boot_init(void)
417{
418 return 0;
419}
420
421static inline int acpi_boot_table_init(void)
422{
423 return 0;
424}
425
426#endif /*!CONFIG_ACPI_BOOT*/
427
428unsigned int acpi_register_gsi (u32 gsi, int edge_level, int active_high_low);
429int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
430
431/*
432 * This function undoes the effect of one call to acpi_register_gsi().
433 * If this matches the last registration, any IRQ resources for gsi
434 * are freed.
435 */
436#ifdef CONFIG_ACPI_DEALLOCATE_IRQ
437void acpi_unregister_gsi (u32 gsi);
438#endif
439
440#ifdef CONFIG_ACPI_PCI
441
442struct acpi_prt_entry {
443 struct list_head node;
444 struct acpi_pci_id id;
445 u8 pin;
446 struct {
447 acpi_handle handle;
448 u32 index;
449 } link;
450 u32 irq;
451};
452
453struct acpi_prt_list {
454 int count;
455 struct list_head entries;
456};
457
458struct pci_dev;
459
460int acpi_pci_irq_enable (struct pci_dev *dev);
461void acpi_penalize_isa_irq(int irq);
462
463#ifdef CONFIG_ACPI_DEALLOCATE_IRQ
464void acpi_pci_irq_disable (struct pci_dev *dev);
465#endif
466
467struct acpi_pci_driver {
468 struct acpi_pci_driver *next;
469 int (*add)(acpi_handle handle);
470 void (*remove)(acpi_handle handle);
471};
472
473int acpi_pci_register_driver(struct acpi_pci_driver *driver);
474void acpi_pci_unregister_driver(struct acpi_pci_driver *driver);
475
476#endif /*CONFIG_ACPI_PCI*/
477
478#ifdef CONFIG_ACPI_EC
479
480extern int ec_read(u8 addr, u8 *val);
481extern int ec_write(u8 addr, u8 val);
482
483#endif /*CONFIG_ACPI_EC*/
484
485#ifdef CONFIG_ACPI_INTERPRETER
486
487extern int acpi_blacklisted(void);
488extern void acpi_bios_year(char *s);
489
490#else /*!CONFIG_ACPI_INTERPRETER*/
491
492static inline int acpi_blacklisted(void)
493{
494 return 0;
495}
496
497#endif /*!CONFIG_ACPI_INTERPRETER*/
498
499#define ACPI_CSTATE_LIMIT_DEFINED /* for driver builds */
500#ifdef CONFIG_ACPI
501
502/*
503 * Set highest legal C-state
504 * 0: C0 okay, but not C1
505 * 1: C1 okay, but not C2
506 * 2: C2 okay, but not C3 etc.
507 */
508
509extern unsigned int max_cstate;
510
511static inline unsigned int acpi_get_cstate_limit(void)
512{
513 return max_cstate;
514}
515static inline void acpi_set_cstate_limit(unsigned int new_limit)
516{
517 max_cstate = new_limit;
518 return;
519}
520#else
521static inline unsigned int acpi_get_cstate_limit(void) { return 0; }
522static inline void acpi_set_cstate_limit(unsigned int new_limit) { return; }
523#endif
524
525#ifdef CONFIG_ACPI_NUMA
526int acpi_get_pxm(acpi_handle handle);
527#else
528static inline int acpi_get_pxm(acpi_handle handle)
529{
530 return 0;
531}
532#endif
533
534extern int pnpacpi_disabled;
535
536#endif /*_LINUX_ACPI_H*/
diff --git a/include/linux/adb.h b/include/linux/adb.h
new file mode 100644
index 000000000000..e9fdc63483c7
--- /dev/null
+++ b/include/linux/adb.h
@@ -0,0 +1,104 @@
1/*
2 * Definitions for ADB (Apple Desktop Bus) support.
3 */
4#ifndef __ADB_H
5#define __ADB_H
6
7/* ADB commands */
8#define ADB_BUSRESET 0
9#define ADB_FLUSH(id) (0x01 | ((id) << 4))
10#define ADB_WRITEREG(id, reg) (0x08 | (reg) | ((id) << 4))
11#define ADB_READREG(id, reg) (0x0C | (reg) | ((id) << 4))
12
13/* ADB default device IDs (upper 4 bits of ADB command byte) */
14#define ADB_DONGLE 1 /* "software execution control" devices */
15#define ADB_KEYBOARD 2
16#define ADB_MOUSE 3
17#define ADB_TABLET 4
18#define ADB_MODEM 5
19#define ADB_MISC 7 /* maybe a monitor */
20
21#define ADB_RET_OK 0
22#define ADB_RET_TIMEOUT 3
23
24/* The kind of ADB request. The controller may emulate some
25 or all of those CUDA/PMU packet kinds */
26#define ADB_PACKET 0
27#define CUDA_PACKET 1
28#define ERROR_PACKET 2
29#define TIMER_PACKET 3
30#define POWER_PACKET 4
31#define MACIIC_PACKET 5
32#define PMU_PACKET 6
33#define ADB_QUERY 7
34
35/* ADB queries */
36
37/* ADB_QUERY_GETDEVINFO
38 * Query ADB slot for device presence
39 * data[2] = id, rep[0] = orig addr, rep[1] = handler_id
40 */
41#define ADB_QUERY_GETDEVINFO 1
42
43#ifdef __KERNEL__
44
45struct adb_request {
46 unsigned char data[32];
47 int nbytes;
48 unsigned char reply[32];
49 int reply_len;
50 unsigned char reply_expected;
51 unsigned char sent;
52 unsigned char complete;
53 void (*done)(struct adb_request *);
54 void *arg;
55 struct adb_request *next;
56};
57
58struct adb_ids {
59 int nids;
60 unsigned char id[16];
61};
62
63/* Structure which encapsulates a low-level ADB driver */
64
65struct adb_driver {
66 char name[16];
67 int (*probe)(void);
68 int (*init)(void);
69 int (*send_request)(struct adb_request *req, int sync);
70 int (*autopoll)(int devs);
71 void (*poll)(void);
72 int (*reset_bus)(void);
73};
74
75/* Values for adb_request flags */
76#define ADBREQ_REPLY 1 /* expect reply */
77#define ADBREQ_SYNC 2 /* poll until done */
78#define ADBREQ_NOSEND 4 /* build the request, but don't send it */
79
80/* Messages sent thru the client_list notifier. You should NOT stop
81 the operation, at least not with this version */
82enum adb_message {
83 ADB_MSG_POWERDOWN, /* Currently called before sleep only */
84 ADB_MSG_PRE_RESET, /* Called before resetting the bus */
85 ADB_MSG_POST_RESET /* Called after resetting the bus (re-do init & register) */
86};
87extern struct adb_driver *adb_controller;
88extern struct notifier_block *adb_client_list;
89
90int adb_request(struct adb_request *req, void (*done)(struct adb_request *),
91 int flags, int nbytes, ...);
92int adb_register(int default_id,int handler_id,struct adb_ids *ids,
93 void (*handler)(unsigned char *, int, struct pt_regs *, int));
94int adb_unregister(int index);
95void adb_poll(void);
96void adb_input(unsigned char *, int, struct pt_regs *, int);
97int adb_reset_bus(void);
98
99int adb_try_handler_change(int address, int new_id);
100int adb_get_infos(int address, int *original_address, int *handler_id);
101
102#endif /* __KERNEL__ */
103
104#endif /* __ADB_H */
diff --git a/include/linux/adfs_fs.h b/include/linux/adfs_fs.h
new file mode 100644
index 000000000000..4a5d50c2bdbf
--- /dev/null
+++ b/include/linux/adfs_fs.h
@@ -0,0 +1,76 @@
1#ifndef _ADFS_FS_H
2#define _ADFS_FS_H
3
4#include <linux/types.h>
5
6/*
7 * Disc Record at disc address 0xc00
8 */
9struct adfs_discrecord {
10 __u8 log2secsize;
11 __u8 secspertrack;
12 __u8 heads;
13 __u8 density;
14 __u8 idlen;
15 __u8 log2bpmb;
16 __u8 skew;
17 __u8 bootoption;
18 __u8 lowsector;
19 __u8 nzones;
20 __le16 zone_spare;
21 __le32 root;
22 __le32 disc_size;
23 __le16 disc_id;
24 __u8 disc_name[10];
25 __le32 disc_type;
26 __le32 disc_size_high;
27 __u8 log2sharesize:4;
28 __u8 unused40:4;
29 __u8 big_flag:1;
30 __u8 unused41:1;
31 __u8 nzones_high;
32 __le32 format_version;
33 __le32 root_size;
34 __u8 unused52[60 - 52];
35};
36
37#define ADFS_DISCRECORD (0xc00)
38#define ADFS_DR_OFFSET (0x1c0)
39#define ADFS_DR_SIZE 60
40#define ADFS_DR_SIZE_BITS (ADFS_DR_SIZE << 3)
41#define ADFS_SUPER_MAGIC 0xadf5
42
43#ifdef __KERNEL__
44#include <linux/adfs_fs_i.h>
45#include <linux/adfs_fs_sb.h>
46/*
47 * Calculate the boot block checksum on an ADFS drive. Note that this will
48 * appear to be correct if the sector contains all zeros, so also check that
49 * the disk size is non-zero!!!
50 */
51static inline int adfs_checkbblk(unsigned char *ptr)
52{
53 unsigned int result = 0;
54 unsigned char *p = ptr + 511;
55
56 do {
57 result = (result & 0xff) + (result >> 8);
58 result = result + *--p;
59 } while (p != ptr);
60
61 return (result & 0xff) != ptr[511];
62}
63
64static inline struct adfs_sb_info *ADFS_SB(struct super_block *sb)
65{
66 return sb->s_fs_info;
67}
68
69static inline struct adfs_inode_info *ADFS_I(struct inode *inode)
70{
71 return container_of(inode, struct adfs_inode_info, vfs_inode);
72}
73
74#endif
75
76#endif
diff --git a/include/linux/adfs_fs_i.h b/include/linux/adfs_fs_i.h
new file mode 100644
index 000000000000..cb543034e54f
--- /dev/null
+++ b/include/linux/adfs_fs_i.h
@@ -0,0 +1,24 @@
1/*
2 * linux/include/linux/adfs_fs_i.h
3 *
4 * Copyright (C) 1997 Russell King
5 */
6
7#ifndef _ADFS_FS_I
8#define _ADFS_FS_I
9
10/*
11 * adfs file system inode data in memory
12 */
13struct adfs_inode_info {
14 loff_t mmu_private;
15 unsigned long parent_id; /* object id of parent */
16 __u32 loadaddr; /* RISC OS load address */
17 __u32 execaddr; /* RISC OS exec address */
18 unsigned int filetype; /* RISC OS file type */
19 unsigned int attr; /* RISC OS permissions */
20 unsigned int stamped:1; /* RISC OS file has date/time */
21 struct inode vfs_inode;
22};
23
24#endif
diff --git a/include/linux/adfs_fs_sb.h b/include/linux/adfs_fs_sb.h
new file mode 100644
index 000000000000..d9bf05c02ccc
--- /dev/null
+++ b/include/linux/adfs_fs_sb.h
@@ -0,0 +1,38 @@
1/*
2 * linux/include/linux/adfs_fs_sb.h
3 *
4 * Copyright (C) 1997-1999 Russell King
5 */
6
7#ifndef _ADFS_FS_SB
8#define _ADFS_FS_SB
9
10/*
11 * Forward-declare this
12 */
13struct adfs_discmap;
14struct adfs_dir_ops;
15
16/*
17 * ADFS file system superblock data in memory
18 */
19struct adfs_sb_info {
20 struct adfs_discmap *s_map; /* bh list containing map */
21 struct adfs_dir_ops *s_dir; /* directory operations */
22
23 uid_t s_uid; /* owner uid */
24 gid_t s_gid; /* owner gid */
25 umode_t s_owner_mask; /* ADFS owner perm -> unix perm */
26 umode_t s_other_mask; /* ADFS other perm -> unix perm */
27
28 __u32 s_ids_per_zone; /* max. no ids in one zone */
29 __u32 s_idlen; /* length of ID in map */
30 __u32 s_map_size; /* sector size of a map */
31 unsigned long s_size; /* total size (in blocks) of this fs */
32 signed int s_map2blk; /* shift left by this for map->sector */
33 unsigned int s_log2sharesize;/* log2 share size */
34 __le32 s_version; /* disc format version */
35 unsigned int s_namelen; /* maximum number of characters in name */
36};
37
38#endif
diff --git a/include/linux/affs_fs.h b/include/linux/affs_fs.h
new file mode 100644
index 000000000000..c57b5ee87d55
--- /dev/null
+++ b/include/linux/affs_fs.h
@@ -0,0 +1,7 @@
1#ifndef _AFFS_FS_H
2#define _AFFS_FS_H
3/*
4 * The affs filesystem constants/structures
5 */
6#define AFFS_SUPER_MAGIC 0xadff
7#endif
diff --git a/include/linux/affs_hardblocks.h b/include/linux/affs_hardblocks.h
new file mode 100644
index 000000000000..3fb869939d82
--- /dev/null
+++ b/include/linux/affs_hardblocks.h
@@ -0,0 +1,66 @@
1#ifndef AFFS_HARDBLOCKS_H
2#define AFFS_HARDBLOCKS_H
3
4/* Just the needed definitions for the RDB of an Amiga HD. */
5
6struct RigidDiskBlock {
7 u32 rdb_ID;
8 __be32 rdb_SummedLongs;
9 s32 rdb_ChkSum;
10 u32 rdb_HostID;
11 __be32 rdb_BlockBytes;
12 u32 rdb_Flags;
13 u32 rdb_BadBlockList;
14 __be32 rdb_PartitionList;
15 u32 rdb_FileSysHeaderList;
16 u32 rdb_DriveInit;
17 u32 rdb_Reserved1[6];
18 u32 rdb_Cylinders;
19 u32 rdb_Sectors;
20 u32 rdb_Heads;
21 u32 rdb_Interleave;
22 u32 rdb_Park;
23 u32 rdb_Reserved2[3];
24 u32 rdb_WritePreComp;
25 u32 rdb_ReducedWrite;
26 u32 rdb_StepRate;
27 u32 rdb_Reserved3[5];
28 u32 rdb_RDBBlocksLo;
29 u32 rdb_RDBBlocksHi;
30 u32 rdb_LoCylinder;
31 u32 rdb_HiCylinder;
32 u32 rdb_CylBlocks;
33 u32 rdb_AutoParkSeconds;
34 u32 rdb_HighRDSKBlock;
35 u32 rdb_Reserved4;
36 char rdb_DiskVendor[8];
37 char rdb_DiskProduct[16];
38 char rdb_DiskRevision[4];
39 char rdb_ControllerVendor[8];
40 char rdb_ControllerProduct[16];
41 char rdb_ControllerRevision[4];
42 u32 rdb_Reserved5[10];
43};
44
45#define IDNAME_RIGIDDISK 0x5244534B /* "RDSK" */
46
47struct PartitionBlock {
48 __be32 pb_ID;
49 __be32 pb_SummedLongs;
50 s32 pb_ChkSum;
51 u32 pb_HostID;
52 __be32 pb_Next;
53 u32 pb_Flags;
54 u32 pb_Reserved1[2];
55 u32 pb_DevFlags;
56 u8 pb_DriveName[32];
57 u32 pb_Reserved2[15];
58 __be32 pb_Environment[17];
59 u32 pb_EReserved[15];
60};
61
62#define IDNAME_PARTITION 0x50415254 /* "PART" */
63
64#define RDB_ALLOCATION_LIMIT 16
65
66#endif /* AFFS_HARDBLOCKS_H */
diff --git a/include/linux/agp_backend.h b/include/linux/agp_backend.h
new file mode 100644
index 000000000000..a5c8bb5d80ba
--- /dev/null
+++ b/include/linux/agp_backend.h
@@ -0,0 +1,109 @@
1/*
2 * AGPGART backend specific includes. Not for userspace consumption.
3 *
4 * Copyright (C) 2004 Silicon Graphics, Inc.
5 * Copyright (C) 2002-2003 Dave Jones
6 * Copyright (C) 1999 Jeff Hartmann
7 * Copyright (C) 1999 Precision Insight, Inc.
8 * Copyright (C) 1999 Xi Graphics, Inc.
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be included
18 * in all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
24 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
25 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
26 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 *
28 */
29
30#ifndef _AGP_BACKEND_H
31#define _AGP_BACKEND_H 1
32
33#ifdef __KERNEL__
34
35#ifndef TRUE
36#define TRUE 1
37#endif
38
39#ifndef FALSE
40#define FALSE 0
41#endif
42
43enum chipset_type {
44 NOT_SUPPORTED,
45 SUPPORTED,
46};
47
48struct agp_version {
49 u16 major;
50 u16 minor;
51};
52
53struct agp_kern_info {
54 struct agp_version version;
55 struct pci_dev *device;
56 enum chipset_type chipset;
57 unsigned long mode;
58 unsigned long aper_base;
59 size_t aper_size;
60 int max_memory; /* In pages */
61 int current_memory;
62 int cant_use_aperture;
63 unsigned long page_mask;
64 struct vm_operations_struct *vm_ops;
65};
66
67/*
68 * The agp_memory structure has information about the block of agp memory
69 * allocated. A caller may manipulate the next and prev pointers to link
70 * each allocated item into a list. These pointers are ignored by the backend.
71 * Everything else should never be written to, but the caller may read any of
72 * the items to determine the status of this block of agp memory.
73 */
74
75struct agp_bridge_data;
76
77struct agp_memory {
78 struct agp_memory *next;
79 struct agp_memory *prev;
80 struct agp_bridge_data *bridge;
81 unsigned long *memory;
82 size_t page_count;
83 int key;
84 int num_scratch_pages;
85 off_t pg_start;
86 u32 type;
87 u32 physical;
88 u8 is_bound;
89 u8 is_flushed;
90};
91
92#define AGP_NORMAL_MEMORY 0
93
94extern struct agp_bridge_data *agp_bridge;
95extern struct list_head agp_bridges;
96
97extern struct agp_bridge_data *(*agp_find_bridge)(struct pci_dev *);
98
99extern void agp_free_memory(struct agp_memory *);
100extern struct agp_memory *agp_allocate_memory(struct agp_bridge_data *, size_t, u32);
101extern int agp_copy_info(struct agp_bridge_data *, struct agp_kern_info *);
102extern int agp_bind_memory(struct agp_memory *, off_t);
103extern int agp_unbind_memory(struct agp_memory *);
104extern void agp_enable(struct agp_bridge_data *, u32);
105extern struct agp_bridge_data *agp_backend_acquire(struct pci_dev *);
106extern void agp_backend_release(struct agp_bridge_data *);
107
108#endif /* __KERNEL__ */
109#endif /* _AGP_BACKEND_H */
diff --git a/include/linux/agpgart.h b/include/linux/agpgart.h
new file mode 100644
index 000000000000..17a17c55a17f
--- /dev/null
+++ b/include/linux/agpgart.h
@@ -0,0 +1,214 @@
1/*
2 * AGPGART module version 0.99
3 * Copyright (C) 1999 Jeff Hartmann
4 * Copyright (C) 1999 Precision Insight, Inc.
5 * Copyright (C) 1999 Xi Graphics, Inc.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
23 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 *
25 */
26
27#ifndef _AGP_H
28#define _AGP_H 1
29
30#include <linux/agp_backend.h>
31
32#define AGPIOC_BASE 'A'
33#define AGPIOC_INFO _IOR (AGPIOC_BASE, 0, struct agp_info*)
34#define AGPIOC_ACQUIRE _IO (AGPIOC_BASE, 1)
35#define AGPIOC_RELEASE _IO (AGPIOC_BASE, 2)
36#define AGPIOC_SETUP _IOW (AGPIOC_BASE, 3, struct agp_setup*)
37#define AGPIOC_RESERVE _IOW (AGPIOC_BASE, 4, struct agp_region*)
38#define AGPIOC_PROTECT _IOW (AGPIOC_BASE, 5, struct agp_region*)
39#define AGPIOC_ALLOCATE _IOWR(AGPIOC_BASE, 6, struct agp_allocate*)
40#define AGPIOC_DEALLOCATE _IOW (AGPIOC_BASE, 7, int)
41#define AGPIOC_BIND _IOW (AGPIOC_BASE, 8, struct agp_bind*)
42#define AGPIOC_UNBIND _IOW (AGPIOC_BASE, 9, struct agp_unbind*)
43
44#define AGP_DEVICE "/dev/agpgart"
45
46#ifndef TRUE
47#define TRUE 1
48#endif
49
50#ifndef FALSE
51#define FALSE 0
52#endif
53
54#ifndef __KERNEL__
55#include <linux/types.h>
56#include <asm/types.h>
57
58struct agp_version {
59 __u16 major;
60 __u16 minor;
61};
62
63typedef struct _agp_info {
64 struct agp_version version; /* version of the driver */
65 __u32 bridge_id; /* bridge vendor/device */
66 __u32 agp_mode; /* mode info of bridge */
67 unsigned long aper_base;/* base of aperture */
68 size_t aper_size; /* size of aperture */
69 size_t pg_total; /* max pages (swap + system) */
70 size_t pg_system; /* max pages (system) */
71 size_t pg_used; /* current pages used */
72} agp_info;
73
74typedef struct _agp_setup {
75 __u32 agp_mode; /* mode info of bridge */
76} agp_setup;
77
78/*
79 * The "prot" down below needs still a "sleep" flag somehow ...
80 */
81typedef struct _agp_segment {
82 off_t pg_start; /* starting page to populate */
83 size_t pg_count; /* number of pages */
84 int prot; /* prot flags for mmap */
85} agp_segment;
86
87typedef struct _agp_region {
88 pid_t pid; /* pid of process */
89 size_t seg_count; /* number of segments */
90 struct _agp_segment *seg_list;
91} agp_region;
92
93typedef struct _agp_allocate {
94 int key; /* tag of allocation */
95 size_t pg_count; /* number of pages */
96 __u32 type; /* 0 == normal, other devspec */
97 __u32 physical; /* device specific (some devices
98 * need a phys address of the
99 * actual page behind the gatt
100 * table) */
101} agp_allocate;
102
103typedef struct _agp_bind {
104 int key; /* tag of allocation */
105 off_t pg_start; /* starting page to populate */
106} agp_bind;
107
108typedef struct _agp_unbind {
109 int key; /* tag of allocation */
110 __u32 priority; /* priority for paging out */
111} agp_unbind;
112
113#else /* __KERNEL__ */
114
115#define AGPGART_MINOR 175
116
117struct agp_info {
118 struct agp_version version; /* version of the driver */
119 u32 bridge_id; /* bridge vendor/device */
120 u32 agp_mode; /* mode info of bridge */
121 unsigned long aper_base;/* base of aperture */
122 size_t aper_size; /* size of aperture */
123 size_t pg_total; /* max pages (swap + system) */
124 size_t pg_system; /* max pages (system) */
125 size_t pg_used; /* current pages used */
126};
127
128struct agp_setup {
129 u32 agp_mode; /* mode info of bridge */
130};
131
132/*
133 * The "prot" down below needs still a "sleep" flag somehow ...
134 */
135struct agp_segment {
136 off_t pg_start; /* starting page to populate */
137 size_t pg_count; /* number of pages */
138 int prot; /* prot flags for mmap */
139};
140
141struct agp_segment_priv {
142 off_t pg_start;
143 size_t pg_count;
144 pgprot_t prot;
145};
146
147struct agp_region {
148 pid_t pid; /* pid of process */
149 size_t seg_count; /* number of segments */
150 struct agp_segment *seg_list;
151};
152
153struct agp_allocate {
154 int key; /* tag of allocation */
155 size_t pg_count; /* number of pages */
156 u32 type; /* 0 == normal, other devspec */
157 u32 physical; /* device specific (some devices
158 * need a phys address of the
159 * actual page behind the gatt
160 * table) */
161};
162
163struct agp_bind {
164 int key; /* tag of allocation */
165 off_t pg_start; /* starting page to populate */
166};
167
168struct agp_unbind {
169 int key; /* tag of allocation */
170 u32 priority; /* priority for paging out */
171};
172
173struct agp_client {
174 struct agp_client *next;
175 struct agp_client *prev;
176 pid_t pid;
177 int num_segments;
178 struct agp_segment_priv **segments;
179};
180
181struct agp_controller {
182 struct agp_controller *next;
183 struct agp_controller *prev;
184 pid_t pid;
185 int num_clients;
186 struct agp_memory *pool;
187 struct agp_client *clients;
188};
189
190#define AGP_FF_ALLOW_CLIENT 0
191#define AGP_FF_ALLOW_CONTROLLER 1
192#define AGP_FF_IS_CLIENT 2
193#define AGP_FF_IS_CONTROLLER 3
194#define AGP_FF_IS_VALID 4
195
196struct agp_file_private {
197 struct agp_file_private *next;
198 struct agp_file_private *prev;
199 pid_t my_pid;
200 long access_flags; /* long req'd for set_bit --RR */
201};
202
203struct agp_front_data {
204 struct semaphore agp_mutex;
205 struct agp_controller *current_controller;
206 struct agp_controller *controllers;
207 struct agp_file_private *file_priv_list;
208 u8 used_by_controller;
209 u8 backend_acquired;
210};
211
212#endif /* __KERNEL__ */
213
214#endif /* _AGP_H */
diff --git a/include/linux/aio.h b/include/linux/aio.h
new file mode 100644
index 000000000000..a4d5af907f90
--- /dev/null
+++ b/include/linux/aio.h
@@ -0,0 +1,201 @@
1#ifndef __LINUX__AIO_H
2#define __LINUX__AIO_H
3
4#include <linux/list.h>
5#include <linux/workqueue.h>
6#include <linux/aio_abi.h>
7
8#include <asm/atomic.h>
9
10#define AIO_MAXSEGS 4
11#define AIO_KIOGRP_NR_ATOMIC 8
12
13struct kioctx;
14
15/* Notes on cancelling a kiocb:
16 * If a kiocb is cancelled, aio_complete may return 0 to indicate
17 * that cancel has not yet disposed of the kiocb. All cancel
18 * operations *must* call aio_put_req to dispose of the kiocb
19 * to guard against races with the completion code.
20 */
21#define KIOCB_C_CANCELLED 0x01
22#define KIOCB_C_COMPLETE 0x02
23
24#define KIOCB_SYNC_KEY (~0U)
25
26/* ki_flags bits */
27#define KIF_LOCKED 0
28#define KIF_KICKED 1
29#define KIF_CANCELLED 2
30
31#define kiocbTryLock(iocb) test_and_set_bit(KIF_LOCKED, &(iocb)->ki_flags)
32#define kiocbTryKick(iocb) test_and_set_bit(KIF_KICKED, &(iocb)->ki_flags)
33
34#define kiocbSetLocked(iocb) set_bit(KIF_LOCKED, &(iocb)->ki_flags)
35#define kiocbSetKicked(iocb) set_bit(KIF_KICKED, &(iocb)->ki_flags)
36#define kiocbSetCancelled(iocb) set_bit(KIF_CANCELLED, &(iocb)->ki_flags)
37
38#define kiocbClearLocked(iocb) clear_bit(KIF_LOCKED, &(iocb)->ki_flags)
39#define kiocbClearKicked(iocb) clear_bit(KIF_KICKED, &(iocb)->ki_flags)
40#define kiocbClearCancelled(iocb) clear_bit(KIF_CANCELLED, &(iocb)->ki_flags)
41
42#define kiocbIsLocked(iocb) test_bit(KIF_LOCKED, &(iocb)->ki_flags)
43#define kiocbIsKicked(iocb) test_bit(KIF_KICKED, &(iocb)->ki_flags)
44#define kiocbIsCancelled(iocb) test_bit(KIF_CANCELLED, &(iocb)->ki_flags)
45
46struct kiocb {
47 struct list_head ki_run_list;
48 long ki_flags;
49 int ki_users;
50 unsigned ki_key; /* id of this request */
51
52 struct file *ki_filp;
53 struct kioctx *ki_ctx; /* may be NULL for sync ops */
54 int (*ki_cancel)(struct kiocb *, struct io_event *);
55 ssize_t (*ki_retry)(struct kiocb *);
56 void (*ki_dtor)(struct kiocb *);
57
58 struct list_head ki_list; /* the aio core uses this
59 * for cancellation */
60
61 union {
62 void __user *user;
63 struct task_struct *tsk;
64 } ki_obj;
65 __u64 ki_user_data; /* user's data for completion */
66 loff_t ki_pos;
67 /* State that we remember to be able to restart/retry */
68 unsigned short ki_opcode;
69 size_t ki_nbytes; /* copy of iocb->aio_nbytes */
70 char __user *ki_buf; /* remaining iocb->aio_buf */
71 size_t ki_left; /* remaining bytes */
72 wait_queue_t ki_wait;
73 long ki_retried; /* just for testing */
74 long ki_kicked; /* just for testing */
75 long ki_queued; /* just for testing */
76
77 void *private;
78};
79
80#define is_sync_kiocb(iocb) ((iocb)->ki_key == KIOCB_SYNC_KEY)
81#define init_sync_kiocb(x, filp) \
82 do { \
83 struct task_struct *tsk = current; \
84 (x)->ki_flags = 0; \
85 (x)->ki_users = 1; \
86 (x)->ki_key = KIOCB_SYNC_KEY; \
87 (x)->ki_filp = (filp); \
88 (x)->ki_ctx = &tsk->active_mm->default_kioctx; \
89 (x)->ki_cancel = NULL; \
90 (x)->ki_dtor = NULL; \
91 (x)->ki_obj.tsk = tsk; \
92 (x)->ki_user_data = 0; \
93 init_wait((&(x)->ki_wait)); \
94 } while (0)
95
96#define AIO_RING_MAGIC 0xa10a10a1
97#define AIO_RING_COMPAT_FEATURES 1
98#define AIO_RING_INCOMPAT_FEATURES 0
99struct aio_ring {
100 unsigned id; /* kernel internal index number */
101 unsigned nr; /* number of io_events */
102 unsigned head;
103 unsigned tail;
104
105 unsigned magic;
106 unsigned compat_features;
107 unsigned incompat_features;
108 unsigned header_length; /* size of aio_ring */
109
110
111 struct io_event io_events[0];
112}; /* 128 bytes + ring size */
113
114#define aio_ring_avail(info, ring) (((ring)->head + (info)->nr - 1 - (ring)->tail) % (info)->nr)
115
116#define AIO_RING_PAGES 8
117struct aio_ring_info {
118 unsigned long mmap_base;
119 unsigned long mmap_size;
120
121 struct page **ring_pages;
122 spinlock_t ring_lock;
123 long nr_pages;
124
125 unsigned nr, tail;
126
127 struct page *internal_pages[AIO_RING_PAGES];
128};
129
130struct kioctx {
131 atomic_t users;
132 int dead;
133 struct mm_struct *mm;
134
135 /* This needs improving */
136 unsigned long user_id;
137 struct kioctx *next;
138
139 wait_queue_head_t wait;
140
141 spinlock_t ctx_lock;
142
143 int reqs_active;
144 struct list_head active_reqs; /* used for cancellation */
145 struct list_head run_list; /* used for kicked reqs */
146
147 unsigned max_reqs;
148
149 struct aio_ring_info ring_info;
150
151 struct work_struct wq;
152};
153
154/* prototypes */
155extern unsigned aio_max_size;
156
157extern ssize_t FASTCALL(wait_on_sync_kiocb(struct kiocb *iocb));
158extern int FASTCALL(aio_put_req(struct kiocb *iocb));
159extern void FASTCALL(kick_iocb(struct kiocb *iocb));
160extern int FASTCALL(aio_complete(struct kiocb *iocb, long res, long res2));
161extern void FASTCALL(__put_ioctx(struct kioctx *ctx));
162struct mm_struct;
163extern void FASTCALL(exit_aio(struct mm_struct *mm));
164extern struct kioctx *lookup_ioctx(unsigned long ctx_id);
165extern int FASTCALL(io_submit_one(struct kioctx *ctx,
166 struct iocb __user *user_iocb, struct iocb *iocb));
167
168/* semi private, but used by the 32bit emulations: */
169struct kioctx *lookup_ioctx(unsigned long ctx_id);
170int FASTCALL(io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
171 struct iocb *iocb));
172
173#define get_ioctx(kioctx) do { if (unlikely(atomic_read(&(kioctx)->users) <= 0)) BUG(); atomic_inc(&(kioctx)->users); } while (0)
174#define put_ioctx(kioctx) do { if (unlikely(atomic_dec_and_test(&(kioctx)->users))) __put_ioctx(kioctx); else if (unlikely(atomic_read(&(kioctx)->users) < 0)) BUG(); } while (0)
175
176#define in_aio() !is_sync_wait(current->io_wait)
177/* may be used for debugging */
178#define warn_if_async() \
179do { \
180 if (in_aio()) { \
181 printk(KERN_ERR "%s(%s:%d) called in async context!\n", \
182 __FUNCTION__, __FILE__, __LINE__); \
183 dump_stack(); \
184 } \
185} while (0)
186
187#define io_wait_to_kiocb(wait) container_of(wait, struct kiocb, ki_wait)
188#define is_retried_kiocb(iocb) ((iocb)->ki_retried > 1)
189
190#include <linux/aio_abi.h>
191
192static inline struct kiocb *list_kiocb(struct list_head *h)
193{
194 return list_entry(h, struct kiocb, ki_list);
195}
196
197/* for sysctl: */
198extern atomic_t aio_nr;
199extern unsigned aio_max_nr;
200
201#endif /* __LINUX__AIO_H */
diff --git a/include/linux/aio_abi.h b/include/linux/aio_abi.h
new file mode 100644
index 000000000000..30fdcc89d142
--- /dev/null
+++ b/include/linux/aio_abi.h
@@ -0,0 +1,92 @@
1/* linux/aio_abi.h
2 *
3 * Copyright 2000,2001,2002 Red Hat.
4 *
5 * Written by Benjamin LaHaise <bcrl@kvack.org>
6 *
7 * Distribute under the terms of the GPLv2 (see ../../COPYING) or under
8 * the following terms.
9 *
10 * Permission to use, copy, modify, and distribute this software and its
11 * documentation is hereby granted, provided that the above copyright
12 * notice appears in all copies. This software is provided without any
13 * warranty, express or implied. Red Hat makes no representations about
14 * the suitability of this software for any purpose.
15 *
16 * IN NO EVENT SHALL RED HAT BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
17 * SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
18 * THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RED HAT HAS BEEN ADVISED
19 * OF THE POSSIBILITY OF SUCH DAMAGE.
20 *
21 * RED HAT DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND
24 * RED HAT HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
25 * ENHANCEMENTS, OR MODIFICATIONS.
26 */
27#ifndef __LINUX__AIO_ABI_H
28#define __LINUX__AIO_ABI_H
29
30#include <asm/byteorder.h>
31
32typedef unsigned long aio_context_t;
33
34enum {
35 IOCB_CMD_PREAD = 0,
36 IOCB_CMD_PWRITE = 1,
37 IOCB_CMD_FSYNC = 2,
38 IOCB_CMD_FDSYNC = 3,
39 /* These two are experimental.
40 * IOCB_CMD_PREADX = 4,
41 * IOCB_CMD_POLL = 5,
42 */
43 IOCB_CMD_NOOP = 6,
44};
45
46/* read() from /dev/aio returns these structures. */
47struct io_event {
48 __u64 data; /* the data field from the iocb */
49 __u64 obj; /* what iocb this event came from */
50 __s64 res; /* result code for this event */
51 __s64 res2; /* secondary result */
52};
53
54#if defined(__LITTLE_ENDIAN)
55#define PADDED(x,y) x, y
56#elif defined(__BIG_ENDIAN)
57#define PADDED(x,y) y, x
58#else
59#error edit for your odd byteorder.
60#endif
61
62/*
63 * we always use a 64bit off_t when communicating
64 * with userland. its up to libraries to do the
65 * proper padding and aio_error abstraction
66 */
67
68struct iocb {
69 /* these are internal to the kernel/libc. */
70 __u64 aio_data; /* data to be returned in event's data */
71 __u32 PADDED(aio_key, aio_reserved1);
72 /* the kernel sets aio_key to the req # */
73
74 /* common fields */
75 __u16 aio_lio_opcode; /* see IOCB_CMD_ above */
76 __s16 aio_reqprio;
77 __u32 aio_fildes;
78
79 __u64 aio_buf;
80 __u64 aio_nbytes;
81 __s64 aio_offset;
82
83 /* extra parameters */
84 __u64 aio_reserved2; /* TODO: use this for a (struct sigevent *) */
85 __u64 aio_reserved3;
86}; /* 64 bytes */
87
88#undef IFBIG
89#undef IFLITTLE
90
91#endif /* __LINUX__AIO_ABI_H */
92
diff --git a/include/linux/amifd.h b/include/linux/amifd.h
new file mode 100644
index 000000000000..346993268b45
--- /dev/null
+++ b/include/linux/amifd.h
@@ -0,0 +1,62 @@
1#ifndef _AMIFD_H
2#define _AMIFD_H
3
4/* Definitions for the Amiga floppy driver */
5
6#include <linux/fd.h>
7
8#define FD_MAX_UNITS 4 /* Max. Number of drives */
9#define FLOPPY_MAX_SECTORS 22 /* Max. Number of sectors per track */
10
11#ifndef ASSEMBLER
12
13struct fd_data_type {
14 char *name; /* description of data type */
15 int sects; /* sectors per track */
16#ifdef __STDC__
17 int (*read_fkt)(int);
18 void (*write_fkt)(int);
19#else
20 int (*read_fkt)(); /* read whole track */
21 void (*write_fkt)(); /* write whole track */
22#endif
23};
24
25/*
26** Floppy type descriptions
27*/
28
29struct fd_drive_type {
30 unsigned long code; /* code returned from drive */
31 char *name; /* description of drive */
32 unsigned int tracks; /* number of tracks */
33 unsigned int heads; /* number of heads */
34 unsigned int read_size; /* raw read size for one track */
35 unsigned int write_size; /* raw write size for one track */
36 unsigned int sect_mult; /* sectors and gap multiplier (HD = 2) */
37 unsigned int precomp1; /* start track for precomp 1 */
38 unsigned int precomp2; /* start track for precomp 2 */
39 unsigned int step_delay; /* time (in ms) for delay after step */
40 unsigned int settle_time; /* time to settle after dir change */
41 unsigned int side_time; /* time needed to change sides */
42};
43
44struct amiga_floppy_struct {
45 struct fd_drive_type *type; /* type of floppy for this unit */
46 struct fd_data_type *dtype; /* type of floppy for this unit */
47 int track; /* current track (-1 == unknown) */
48 unsigned char *trackbuf; /* current track (kmaloc()'d */
49
50 int blocks; /* total # blocks on disk */
51
52 int changed; /* true when not known */
53 int disk; /* disk in drive (-1 == unknown) */
54 int motor; /* true when motor is at speed */
55 int busy; /* true when drive is active */
56 int dirty; /* true when trackbuf is not on disk */
57 int status; /* current error code for unit */
58 struct gendisk *gendisk;
59};
60#endif
61
62#endif
diff --git a/include/linux/amifdreg.h b/include/linux/amifdreg.h
new file mode 100644
index 000000000000..76188bf48d3b
--- /dev/null
+++ b/include/linux/amifdreg.h
@@ -0,0 +1,81 @@
1#ifndef _LINUX_AMIFDREG_H
2#define _LINUX_AMIFDREG_H
3
4/*
5** CIAAPRA bits (read only)
6*/
7
8#define DSKRDY (0x1<<5) /* disk ready when low */
9#define DSKTRACK0 (0x1<<4) /* head at track zero when low */
10#define DSKPROT (0x1<<3) /* disk protected when low */
11#define DSKCHANGE (0x1<<2) /* low when disk removed */
12
13/*
14** CIAAPRB bits (read/write)
15*/
16
17#define DSKMOTOR (0x1<<7) /* motor on when low */
18#define DSKSEL3 (0x1<<6) /* select drive 3 when low */
19#define DSKSEL2 (0x1<<5) /* select drive 2 when low */
20#define DSKSEL1 (0x1<<4) /* select drive 1 when low */
21#define DSKSEL0 (0x1<<3) /* select drive 0 when low */
22#define DSKSIDE (0x1<<2) /* side selection: 0 = upper, 1 = lower */
23#define DSKDIREC (0x1<<1) /* step direction: 0=in, 1=out (to trk 0) */
24#define DSKSTEP (0x1) /* pulse low to step head 1 track */
25
26/*
27** DSKBYTR bits (read only)
28*/
29
30#define DSKBYT (1<<15) /* register contains valid byte when set */
31#define DMAON (1<<14) /* disk DMA enabled */
32#define DISKWRITE (1<<13) /* disk write bit in DSKLEN enabled */
33#define WORDEQUAL (1<<12) /* DSKSYNC register match when true */
34/* bits 7-0 are data */
35
36/*
37** ADKCON/ADKCONR bits
38*/
39
40#ifndef SETCLR
41#define ADK_SETCLR (1<<15) /* control bit */
42#endif
43#define ADK_PRECOMP1 (1<<14) /* precompensation selection */
44#define ADK_PRECOMP0 (1<<13) /* 00=none, 01=140ns, 10=280ns, 11=500ns */
45#define ADK_MFMPREC (1<<12) /* 0=GCR precomp., 1=MFM precomp. */
46#define ADK_WORDSYNC (1<<10) /* enable DSKSYNC auto DMA */
47#define ADK_MSBSYNC (1<<9) /* when 1, enable sync on MSbit (for GCR) */
48#define ADK_FAST (1<<8) /* bit cell: 0=2us (GCR), 1=1us (MFM) */
49
50/*
51** DSKLEN bits
52*/
53
54#define DSKLEN_DMAEN (1<<15)
55#define DSKLEN_WRITE (1<<14)
56
57/*
58** INTENA/INTREQ bits
59*/
60
61#define DSKINDEX (0x1<<4) /* DSKINDEX bit */
62
63/*
64** Misc
65*/
66
67#define MFM_SYNC 0x4489 /* standard MFM sync value */
68
69/* Values for FD_COMMAND */
70#define FD_RECALIBRATE 0x07 /* move to track 0 */
71#define FD_SEEK 0x0F /* seek track */
72#define FD_READ 0xE6 /* read with MT, MFM, SKip deleted */
73#define FD_WRITE 0xC5 /* write with MT, MFM */
74#define FD_SENSEI 0x08 /* Sense Interrupt Status */
75#define FD_SPECIFY 0x03 /* specify HUT etc */
76#define FD_FORMAT 0x4D /* format one track */
77#define FD_VERSION 0x10 /* get version code */
78#define FD_CONFIGURE 0x13 /* configure FIFO operation */
79#define FD_PERPENDICULAR 0x12 /* perpendicular r/w mode */
80
81#endif /* _LINUX_AMIFDREG_H */
diff --git a/include/linux/amigaffs.h b/include/linux/amigaffs.h
new file mode 100644
index 000000000000..43b41c06aa37
--- /dev/null
+++ b/include/linux/amigaffs.h
@@ -0,0 +1,144 @@
1#ifndef AMIGAFFS_H
2#define AMIGAFFS_H
3
4#include <linux/types.h>
5#include <asm/byteorder.h>
6
7#define FS_OFS 0x444F5300
8#define FS_FFS 0x444F5301
9#define FS_INTLOFS 0x444F5302
10#define FS_INTLFFS 0x444F5303
11#define FS_DCOFS 0x444F5304
12#define FS_DCFFS 0x444F5305
13#define MUFS_FS 0x6d754653 /* 'muFS' */
14#define MUFS_OFS 0x6d754600 /* 'muF\0' */
15#define MUFS_FFS 0x6d754601 /* 'muF\1' */
16#define MUFS_INTLOFS 0x6d754602 /* 'muF\2' */
17#define MUFS_INTLFFS 0x6d754603 /* 'muF\3' */
18#define MUFS_DCOFS 0x6d754604 /* 'muF\4' */
19#define MUFS_DCFFS 0x6d754605 /* 'muF\5' */
20
21#define T_SHORT 2
22#define T_LIST 16
23#define T_DATA 8
24
25#define ST_LINKFILE -4
26#define ST_FILE -3
27#define ST_ROOT 1
28#define ST_USERDIR 2
29#define ST_SOFTLINK 3
30#define ST_LINKDIR 4
31
32#define AFFS_ROOT_BMAPS 25
33
34struct affs_date {
35 __be32 days;
36 __be32 mins;
37 __be32 ticks;
38};
39
40struct affs_short_date {
41 __be16 days;
42 __be16 mins;
43 __be16 ticks;
44};
45
46struct affs_root_head {
47 __be32 ptype;
48 __be32 spare1;
49 __be32 spare2;
50 __be32 hash_size;
51 __be32 spare3;
52 __be32 checksum;
53 __be32 hashtable[1];
54};
55
56struct affs_root_tail {
57 __be32 bm_flag;
58 __be32 bm_blk[AFFS_ROOT_BMAPS];
59 __be32 bm_ext;
60 struct affs_date root_change;
61 u8 disk_name[32];
62 __be32 spare1;
63 __be32 spare2;
64 struct affs_date disk_change;
65 struct affs_date disk_create;
66 __be32 spare3;
67 __be32 spare4;
68 __be32 dcache;
69 __be32 stype;
70};
71
72struct affs_head {
73 __be32 ptype;
74 __be32 key;
75 __be32 block_count;
76 __be32 spare1;
77 __be32 first_data;
78 __be32 checksum;
79 __be32 table[1];
80};
81
82struct affs_tail {
83 __be32 spare1;
84 __be16 uid;
85 __be16 gid;
86 __be32 protect;
87 __be32 size;
88 u8 comment[92];
89 struct affs_date change;
90 u8 name[32];
91 __be32 spare2;
92 __be32 original;
93 __be32 link_chain;
94 __be32 spare[5];
95 __be32 hash_chain;
96 __be32 parent;
97 __be32 extension;
98 __be32 stype;
99};
100
101struct slink_front
102{
103 __be32 ptype;
104 __be32 key;
105 __be32 spare1[3];
106 __be32 checksum;
107 u8 symname[1]; /* depends on block size */
108};
109
110struct affs_data_head
111{
112 __be32 ptype;
113 __be32 key;
114 __be32 sequence;
115 __be32 size;
116 __be32 next;
117 __be32 checksum;
118 u8 data[1]; /* depends on block size */
119};
120
121/* Permission bits */
122
123#define FIBF_OTR_READ 0x8000
124#define FIBF_OTR_WRITE 0x4000
125#define FIBF_OTR_EXECUTE 0x2000
126#define FIBF_OTR_DELETE 0x1000
127#define FIBF_GRP_READ 0x0800
128#define FIBF_GRP_WRITE 0x0400
129#define FIBF_GRP_EXECUTE 0x0200
130#define FIBF_GRP_DELETE 0x0100
131
132#define FIBF_HIDDEN 0x0080
133#define FIBF_SCRIPT 0x0040
134#define FIBF_PURE 0x0020 /* no use under linux */
135#define FIBF_ARCHIVED 0x0010 /* never set, always cleared on write */
136#define FIBF_NOREAD 0x0008 /* 0 means allowed */
137#define FIBF_NOWRITE 0x0004 /* 0 means allowed */
138#define FIBF_NOEXECUTE 0x0002 /* 0 means allowed, ignored under linux */
139#define FIBF_NODELETE 0x0001 /* 0 means allowed */
140
141#define FIBF_OWNER 0x000F /* Bits pertaining to owner */
142#define FIBF_MASK 0xEE0E /* Bits modified by Linux */
143
144#endif
diff --git a/include/linux/apm_bios.h b/include/linux/apm_bios.h
new file mode 100644
index 000000000000..290aef326812
--- /dev/null
+++ b/include/linux/apm_bios.h
@@ -0,0 +1,218 @@
1#ifndef _LINUX_APM_H
2#define _LINUX_APM_H
3
4/*
5 * Include file for the interface to an APM BIOS
6 * Copyright 1994-2001 Stephen Rothwell (sfr@canb.auug.org.au)
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
19typedef unsigned short apm_event_t;
20typedef unsigned short apm_eventinfo_t;
21
22#ifdef __KERNEL__
23
24#define APM_CS (GDT_ENTRY_APMBIOS_BASE * 8)
25#define APM_CS_16 (APM_CS + 8)
26#define APM_DS (APM_CS_16 + 8)
27
28struct apm_bios_info {
29 unsigned short version;
30 unsigned short cseg;
31 unsigned long offset;
32 unsigned short cseg_16;
33 unsigned short dseg;
34 unsigned short flags;
35 unsigned short cseg_len;
36 unsigned short cseg_16_len;
37 unsigned short dseg_len;
38};
39
40/* Results of APM Installation Check */
41#define APM_16_BIT_SUPPORT 0x0001
42#define APM_32_BIT_SUPPORT 0x0002
43#define APM_IDLE_SLOWS_CLOCK 0x0004
44#define APM_BIOS_DISABLED 0x0008
45#define APM_BIOS_DISENGAGED 0x0010
46
47/*
48 * Data for APM that is persistent across module unload/load
49 */
50struct apm_info {
51 struct apm_bios_info bios;
52 unsigned short connection_version;
53 int get_power_status_broken;
54 int get_power_status_swabinminutes;
55 int allow_ints;
56 int forbid_idle;
57 int realmode_power_off;
58 int disabled;
59};
60
61/*
62 * The APM function codes
63 */
64#define APM_FUNC_INST_CHECK 0x5300
65#define APM_FUNC_REAL_CONN 0x5301
66#define APM_FUNC_16BIT_CONN 0x5302
67#define APM_FUNC_32BIT_CONN 0x5303
68#define APM_FUNC_DISCONN 0x5304
69#define APM_FUNC_IDLE 0x5305
70#define APM_FUNC_BUSY 0x5306
71#define APM_FUNC_SET_STATE 0x5307
72#define APM_FUNC_ENABLE_PM 0x5308
73#define APM_FUNC_RESTORE_BIOS 0x5309
74#define APM_FUNC_GET_STATUS 0x530a
75#define APM_FUNC_GET_EVENT 0x530b
76#define APM_FUNC_GET_STATE 0x530c
77#define APM_FUNC_ENABLE_DEV_PM 0x530d
78#define APM_FUNC_VERSION 0x530e
79#define APM_FUNC_ENGAGE_PM 0x530f
80#define APM_FUNC_GET_CAP 0x5310
81#define APM_FUNC_RESUME_TIMER 0x5311
82#define APM_FUNC_RESUME_ON_RING 0x5312
83#define APM_FUNC_TIMER 0x5313
84
85/*
86 * Function code for APM_FUNC_RESUME_TIMER
87 */
88#define APM_FUNC_DISABLE_TIMER 0
89#define APM_FUNC_GET_TIMER 1
90#define APM_FUNC_SET_TIMER 2
91
92/*
93 * Function code for APM_FUNC_RESUME_ON_RING
94 */
95#define APM_FUNC_DISABLE_RING 0
96#define APM_FUNC_ENABLE_RING 1
97#define APM_FUNC_GET_RING 2
98
99/*
100 * Function code for APM_FUNC_TIMER_STATUS
101 */
102#define APM_FUNC_TIMER_DISABLE 0
103#define APM_FUNC_TIMER_ENABLE 1
104#define APM_FUNC_TIMER_GET 2
105
106/*
107 * in arch/i386/kernel/setup.c
108 */
109extern struct apm_info apm_info;
110
111#endif /* __KERNEL__ */
112
113/*
114 * Power states
115 */
116#define APM_STATE_READY 0x0000
117#define APM_STATE_STANDBY 0x0001
118#define APM_STATE_SUSPEND 0x0002
119#define APM_STATE_OFF 0x0003
120#define APM_STATE_BUSY 0x0004
121#define APM_STATE_REJECT 0x0005
122#define APM_STATE_OEM_SYS 0x0020
123#define APM_STATE_OEM_DEV 0x0040
124
125#define APM_STATE_DISABLE 0x0000
126#define APM_STATE_ENABLE 0x0001
127
128#define APM_STATE_DISENGAGE 0x0000
129#define APM_STATE_ENGAGE 0x0001
130
131/*
132 * Events (results of Get PM Event)
133 */
134#define APM_SYS_STANDBY 0x0001
135#define APM_SYS_SUSPEND 0x0002
136#define APM_NORMAL_RESUME 0x0003
137#define APM_CRITICAL_RESUME 0x0004
138#define APM_LOW_BATTERY 0x0005
139#define APM_POWER_STATUS_CHANGE 0x0006
140#define APM_UPDATE_TIME 0x0007
141#define APM_CRITICAL_SUSPEND 0x0008
142#define APM_USER_STANDBY 0x0009
143#define APM_USER_SUSPEND 0x000a
144#define APM_STANDBY_RESUME 0x000b
145#define APM_CAPABILITY_CHANGE 0x000c
146
147/*
148 * Error codes
149 */
150#define APM_SUCCESS 0x00
151#define APM_DISABLED 0x01
152#define APM_CONNECTED 0x02
153#define APM_NOT_CONNECTED 0x03
154#define APM_16_CONNECTED 0x05
155#define APM_16_UNSUPPORTED 0x06
156#define APM_32_CONNECTED 0x07
157#define APM_32_UNSUPPORTED 0x08
158#define APM_BAD_DEVICE 0x09
159#define APM_BAD_PARAM 0x0a
160#define APM_NOT_ENGAGED 0x0b
161#define APM_BAD_FUNCTION 0x0c
162#define APM_RESUME_DISABLED 0x0d
163#define APM_NO_ERROR 0x53
164#define APM_BAD_STATE 0x60
165#define APM_NO_EVENTS 0x80
166#define APM_NOT_PRESENT 0x86
167
168/*
169 * APM Device IDs
170 */
171#define APM_DEVICE_BIOS 0x0000
172#define APM_DEVICE_ALL 0x0001
173#define APM_DEVICE_DISPLAY 0x0100
174#define APM_DEVICE_STORAGE 0x0200
175#define APM_DEVICE_PARALLEL 0x0300
176#define APM_DEVICE_SERIAL 0x0400
177#define APM_DEVICE_NETWORK 0x0500
178#define APM_DEVICE_PCMCIA 0x0600
179#define APM_DEVICE_BATTERY 0x8000
180#define APM_DEVICE_OEM 0xe000
181#define APM_DEVICE_OLD_ALL 0xffff
182#define APM_DEVICE_CLASS 0x00ff
183#define APM_DEVICE_MASK 0xff00
184
185#ifdef __KERNEL__
186/*
187 * This is the "All Devices" ID communicated to the BIOS
188 */
189#define APM_DEVICE_BALL ((apm_info.connection_version > 0x0100) ? \
190 APM_DEVICE_ALL : APM_DEVICE_OLD_ALL)
191#endif
192
193/*
194 * Battery status
195 */
196#define APM_MAX_BATTERIES 2
197
198/*
199 * APM defined capability bit flags
200 */
201#define APM_CAP_GLOBAL_STANDBY 0x0001
202#define APM_CAP_GLOBAL_SUSPEND 0x0002
203#define APM_CAP_RESUME_STANDBY_TIMER 0x0004 /* Timer resume from standby */
204#define APM_CAP_RESUME_SUSPEND_TIMER 0x0008 /* Timer resume from suspend */
205#define APM_CAP_RESUME_STANDBY_RING 0x0010 /* Resume on Ring fr standby */
206#define APM_CAP_RESUME_SUSPEND_RING 0x0020 /* Resume on Ring fr suspend */
207#define APM_CAP_RESUME_STANDBY_PCMCIA 0x0040 /* Resume on PCMCIA Ring */
208#define APM_CAP_RESUME_SUSPEND_PCMCIA 0x0080 /* Resume on PCMCIA Ring */
209
210/*
211 * ioctl operations
212 */
213#include <linux/ioctl.h>
214
215#define APM_IOC_STANDBY _IO('A', 1)
216#define APM_IOC_SUSPEND _IO('A', 2)
217
218#endif /* LINUX_APM_H */
diff --git a/include/linux/arcdevice.h b/include/linux/arcdevice.h
new file mode 100644
index 000000000000..7198f129e135
--- /dev/null
+++ b/include/linux/arcdevice.h
@@ -0,0 +1,350 @@
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. NET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Definitions used by the ARCnet driver.
7 *
8 * Authors: Avery Pennarun and David Woodhouse
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#ifndef _LINUX_ARCDEVICE_H
17#define _LINUX_ARCDEVICE_H
18
19#include <asm/timex.h>
20#include <linux/if_arcnet.h>
21
22#ifdef __KERNEL__
23
24#ifndef bool
25#define bool int
26#endif
27
28/*
29 * RECON_THRESHOLD is the maximum number of RECON messages to receive
30 * within one minute before printing a "cabling problem" warning. The
31 * default value should be fine.
32 *
33 * After that, a "cabling restored" message will be printed on the next IRQ
34 * if no RECON messages have been received for 10 seconds.
35 *
36 * Do not define RECON_THRESHOLD at all if you want to disable this feature.
37 */
38#define RECON_THRESHOLD 30
39
40
41/*
42 * Define this to the minimum "timeout" value. If a transmit takes longer
43 * than TX_TIMEOUT jiffies, Linux will abort the TX and retry. On a large
44 * network, or one with heavy network traffic, this timeout may need to be
45 * increased. The larger it is, though, the longer it will be between
46 * necessary transmits - don't set this too high.
47 */
48#define TX_TIMEOUT (HZ * 200 / 1000)
49
50
51/* Display warnings about the driver being an ALPHA version. */
52#undef ALPHA_WARNING
53
54
55/*
56 * Debugging bitflags: each option can be enabled individually.
57 *
58 * Note: only debug flags included in the ARCNET_DEBUG_MAX define will
59 * actually be available. GCC will (at least, GCC 2.7.0 will) notice
60 * lines using a BUGLVL not in ARCNET_DEBUG_MAX and automatically optimize
61 * them out.
62 */
63#define D_NORMAL 1 /* important operational info */
64#define D_EXTRA 2 /* useful, but non-vital information */
65#define D_INIT 4 /* show init/probe messages */
66#define D_INIT_REASONS 8 /* show reasons for discarding probes */
67#define D_RECON 32 /* print a message whenever token is lost */
68#define D_PROTO 64 /* debug auto-protocol support */
69/* debug levels below give LOTS of output during normal operation! */
70#define D_DURING 128 /* trace operations (including irq's) */
71#define D_TX 256 /* show tx packets */
72#define D_RX 512 /* show rx packets */
73#define D_SKB 1024 /* show skb's */
74#define D_SKB_SIZE 2048 /* show skb sizes */
75#define D_TIMING 4096 /* show time needed to copy buffers to card */
76#define D_DEBUG 8192 /* Very detailed debug line for line */
77
78#ifndef ARCNET_DEBUG_MAX
79#define ARCNET_DEBUG_MAX (127) /* change to ~0 if you want detailed debugging */
80#endif
81
82#ifndef ARCNET_DEBUG
83#define ARCNET_DEBUG (D_NORMAL|D_EXTRA)
84#endif
85extern int arcnet_debug;
86
87/* macros to simplify debug checking */
88#define BUGLVL(x) if ((ARCNET_DEBUG_MAX)&arcnet_debug&(x))
89#define BUGMSG2(x,msg,args...) do { BUGLVL(x) printk(msg, ## args); } while (0)
90#define BUGMSG(x,msg,args...) \
91 BUGMSG2(x, "%s%6s: " msg, \
92 x==D_NORMAL ? KERN_WARNING \
93 : x < D_DURING ? KERN_INFO : KERN_DEBUG, \
94 dev->name , ## args)
95
96/* see how long a function call takes to run, expressed in CPU cycles */
97#define TIME(name, bytes, call) BUGLVL(D_TIMING) { \
98 unsigned long _x, _y; \
99 _x = get_cycles(); \
100 call; \
101 _y = get_cycles(); \
102 BUGMSG(D_TIMING, \
103 "%s: %d bytes in %lu cycles == " \
104 "%lu Kbytes/100Mcycle\n",\
105 name, bytes, _y - _x, \
106 100000000 / 1024 * bytes / (_y - _x + 1));\
107 } \
108 else { \
109 call;\
110 }
111
112
113/*
114 * Time needed to reset the card - in ms (milliseconds). This works on my
115 * SMC PC100. I can't find a reference that tells me just how long I
116 * should wait.
117 */
118#define RESETtime (300)
119
120/*
121 * These are the max/min lengths of packet payload, not including the
122 * arc_hardware header, but definitely including the soft header.
123 *
124 * Note: packet sizes 254, 255, 256 are impossible because of the way
125 * ARCnet registers work That's why RFC1201 defines "exception" packets.
126 * In non-RFC1201 protocols, we have to just tack some extra bytes on the
127 * end.
128 */
129#define MTU 253 /* normal packet max size */
130#define MinTU 257 /* extended packet min size */
131#define XMTU 508 /* extended packet max size */
132
133/* status/interrupt mask bit fields */
134#define TXFREEflag 0x01 /* transmitter available */
135#define TXACKflag 0x02 /* transmitted msg. ackd */
136#define RECONflag 0x04 /* network reconfigured */
137#define TESTflag 0x08 /* test flag */
138#define EXCNAKflag 0x08 /* excesive nak flag */
139#define RESETflag 0x10 /* power-on-reset */
140#define RES1flag 0x20 /* reserved - usually set by jumper */
141#define RES2flag 0x40 /* reserved - usually set by jumper */
142#define NORXflag 0x80 /* receiver inhibited */
143
144/* Flags used for IO-mapped memory operations */
145#define AUTOINCflag 0x40 /* Increase location with each access */
146#define IOMAPflag 0x02 /* (for 90xx) Use IO mapped memory, not mmap */
147#define ENABLE16flag 0x80 /* (for 90xx) Enable 16-bit mode */
148
149/* in the command register, the following bits have these meanings:
150 * 0-2 command
151 * 3-4 page number (for enable rcv/xmt command)
152 * 7 receive broadcasts
153 */
154#define NOTXcmd 0x01 /* disable transmitter */
155#define NORXcmd 0x02 /* disable receiver */
156#define TXcmd 0x03 /* enable transmitter */
157#define RXcmd 0x04 /* enable receiver */
158#define CONFIGcmd 0x05 /* define configuration */
159#define CFLAGScmd 0x06 /* clear flags */
160#define TESTcmd 0x07 /* load test flags */
161
162/* flags for "clear flags" command */
163#define RESETclear 0x08 /* power-on-reset */
164#define CONFIGclear 0x10 /* system reconfigured */
165
166#define EXCNAKclear 0x0E /* Clear and acknowledge the excive nak bit */
167
168/* flags for "load test flags" command */
169#define TESTload 0x08 /* test flag (diagnostic) */
170
171/* byte deposited into first address of buffers on reset */
172#define TESTvalue 0321 /* that's octal for 0xD1 :) */
173
174/* for "enable receiver" command */
175#define RXbcasts 0x80 /* receive broadcasts */
176
177/* flags for "define configuration" command */
178#define NORMALconf 0x00 /* 1-249 byte packets */
179#define EXTconf 0x08 /* 250-504 byte packets */
180
181/* card feature flags, set during auto-detection.
182 * (currently only used by com20020pci)
183 */
184#define ARC_IS_5MBIT 1 /* card default speed is 5MBit */
185#define ARC_CAN_10MBIT 2 /* card uses COM20022, supporting 10MBit,
186 but default is 2.5MBit. */
187
188
189/* information needed to define an encapsulation driver */
190struct ArcProto {
191 char suffix; /* a for RFC1201, e for ether-encap, etc. */
192 int mtu; /* largest possible packet */
193 int is_ip; /* This is a ip plugin - not a raw thing */
194
195 void (*rx) (struct net_device * dev, int bufnum,
196 struct archdr * pkthdr, int length);
197 int (*build_header) (struct sk_buff * skb, struct net_device *dev,
198 unsigned short ethproto, uint8_t daddr);
199
200 /* these functions return '1' if the skb can now be freed */
201 int (*prepare_tx) (struct net_device * dev, struct archdr * pkt, int length,
202 int bufnum);
203 int (*continue_tx) (struct net_device * dev, int bufnum);
204 int (*ack_tx) (struct net_device * dev, int acked);
205};
206
207extern struct ArcProto *arc_proto_map[256], *arc_proto_default,
208 *arc_bcast_proto, *arc_raw_proto;
209extern struct ArcProto arc_proto_null;
210
211
212/*
213 * "Incoming" is information needed for each address that could be sending
214 * to us. Mostly for partially-received split packets.
215 */
216struct Incoming {
217 struct sk_buff *skb; /* packet data buffer */
218 uint16_t sequence; /* sequence number of assembly */
219 uint8_t lastpacket, /* number of last packet (from 1) */
220 numpackets; /* number of packets in split */
221};
222
223
224/* only needed for RFC1201 */
225struct Outgoing {
226 struct ArcProto *proto; /* protocol driver that owns this:
227 * if NULL, no packet is pending.
228 */
229 struct sk_buff *skb; /* buffer from upper levels */
230 struct archdr *pkt; /* a pointer into the skb */
231 uint16_t length, /* bytes total */
232 dataleft, /* bytes left */
233 segnum, /* segment being sent */
234 numsegs; /* number of segments */
235};
236
237
238struct arcnet_local {
239 struct net_device_stats stats;
240
241 uint8_t config, /* current value of CONFIG register */
242 timeout, /* Extended timeout for COM20020 */
243 backplane, /* Backplane flag for COM20020 */
244 clockp, /* COM20020 clock divider */
245 clockm, /* COM20020 clock multiplier flag */
246 setup, /* Contents of setup1 register */
247 setup2, /* Contents of setup2 register */
248 intmask; /* current value of INTMASK register */
249 uint8_t default_proto[256]; /* default encap to use for each host */
250 int cur_tx, /* buffer used by current transmit, or -1 */
251 next_tx, /* buffer where a packet is ready to send */
252 cur_rx; /* current receive buffer */
253 int lastload_dest, /* can last loaded packet be acked? */
254 lasttrans_dest; /* can last TX'd packet be acked? */
255 int timed_out; /* need to process TX timeout and drop packet */
256 unsigned long last_timeout; /* time of last reported timeout */
257 char *card_name; /* card ident string */
258 int card_flags; /* special card features */
259
260
261 /* On preemtive and SMB a lock is needed */
262 spinlock_t lock;
263
264 /*
265 * Buffer management: an ARCnet card has 4 x 512-byte buffers, each of
266 * which can be used for either sending or receiving. The new dynamic
267 * buffer management routines use a simple circular queue of available
268 * buffers, and take them as they're needed. This way, we simplify
269 * situations in which we (for example) want to pre-load a transmit
270 * buffer, or start receiving while we copy a received packet to
271 * memory.
272 *
273 * The rules: only the interrupt handler is allowed to _add_ buffers to
274 * the queue; thus, this doesn't require a lock. Both the interrupt
275 * handler and the transmit function will want to _remove_ buffers, so
276 * we need to handle the situation where they try to do it at the same
277 * time.
278 *
279 * If next_buf == first_free_buf, the queue is empty. Since there are
280 * only four possible buffers, the queue should never be full.
281 */
282 atomic_t buf_lock;
283 int buf_queue[5];
284 int next_buf, first_free_buf;
285
286 /* network "reconfiguration" handling */
287 time_t first_recon, /* time of "first" RECON message to count */
288 last_recon; /* time of most recent RECON */
289 int num_recons; /* number of RECONs between first and last. */
290 bool network_down; /* do we think the network is down? */
291
292 bool excnak_pending; /* We just got an excesive nak interrupt */
293
294 struct {
295 uint16_t sequence; /* sequence number (incs with each packet) */
296 uint16_t aborted_seq;
297
298 struct Incoming incoming[256]; /* one from each address */
299 } rfc1201;
300
301 /* really only used by rfc1201, but we'll pretend it's not */
302 struct Outgoing outgoing; /* packet currently being sent */
303
304 /* hardware-specific functions */
305 struct {
306 struct module *owner;
307 void (*command) (struct net_device * dev, int cmd);
308 int (*status) (struct net_device * dev);
309 void (*intmask) (struct net_device * dev, int mask);
310 bool (*reset) (struct net_device * dev, bool really_reset);
311 void (*open) (struct net_device * dev);
312 void (*close) (struct net_device * dev);
313
314 void (*copy_to_card) (struct net_device * dev, int bufnum, int offset,
315 void *buf, int count);
316 void (*copy_from_card) (struct net_device * dev, int bufnum, int offset,
317 void *buf, int count);
318 } hw;
319
320 void __iomem *mem_start; /* pointer to ioremap'ed MMIO */
321};
322
323
324#define ARCRESET(x) (lp->hw.reset(dev, (x)))
325#define ACOMMAND(x) (lp->hw.command(dev, (x)))
326#define ASTATUS() (lp->hw.status(dev))
327#define AINTMASK(x) (lp->hw.intmask(dev, (x)))
328
329
330
331#if ARCNET_DEBUG_MAX & D_SKB
332void arcnet_dump_skb(struct net_device *dev, struct sk_buff *skb, char *desc);
333#else
334#define arcnet_dump_skb(dev,skb,desc) ;
335#endif
336
337#if (ARCNET_DEBUG_MAX & D_RX) || (ARCNET_DEBUG_MAX & D_TX)
338void arcnet_dump_packet(struct net_device *dev, int bufnum, char *desc,
339 int take_arcnet_lock);
340#else
341#define arcnet_dump_packet(dev, bufnum, desc,take_arcnet_lock) ;
342#endif
343
344void arcnet_unregister_proto(struct ArcProto *proto);
345irqreturn_t arcnet_interrupt(int irq, void *dev_id, struct pt_regs *regs);
346struct net_device *alloc_arcdev(char *name);
347void arcnet_rx(struct net_device *dev, int bufnum);
348
349#endif /* __KERNEL__ */
350#endif /* _LINUX_ARCDEVICE_H */
diff --git a/include/linux/ata.h b/include/linux/ata.h
new file mode 100644
index 000000000000..f178894edd04
--- /dev/null
+++ b/include/linux/ata.h
@@ -0,0 +1,268 @@
1
2/*
3 Copyright 2003-2004 Red Hat, Inc. All rights reserved.
4 Copyright 2003-2004 Jeff Garzik
5
6 The contents of this file are subject to the Open
7 Software License version 1.1 that can be found at
8 http://www.opensource.org/licenses/osl-1.1.txt and is included herein
9 by reference.
10
11 Alternatively, the contents of this file may be used under the terms
12 of the GNU General Public License version 2 (the "GPL") as distributed
13 in the kernel source COPYING file, in which case the provisions of
14 the GPL are applicable instead of the above. If you wish to allow
15 the use of your version of this file only under the terms of the
16 GPL and not to allow others to use your version of this file under
17 the OSL, indicate your decision by deleting the provisions above and
18 replace them with the notice and other provisions required by the GPL.
19 If you do not delete the provisions above, a recipient may use your
20 version of this file under either the OSL or the GPL.
21
22 */
23
24#ifndef __LINUX_ATA_H__
25#define __LINUX_ATA_H__
26
27#include <linux/types.h>
28
29/* defines only for the constants which don't work well as enums */
30#define ATA_DMA_BOUNDARY 0xffffUL
31#define ATA_DMA_MASK 0xffffffffULL
32
33enum {
34 /* various global constants */
35 ATA_MAX_DEVICES = 2, /* per bus/port */
36 ATA_MAX_PRD = 256, /* we could make these 256/256 */
37 ATA_SECT_SIZE = 512,
38
39 ATA_ID_WORDS = 256,
40 ATA_ID_PROD_OFS = 27,
41 ATA_ID_FW_REV_OFS = 23,
42 ATA_ID_SERNO_OFS = 10,
43 ATA_ID_MAJOR_VER = 80,
44 ATA_ID_PIO_MODES = 64,
45 ATA_ID_MWDMA_MODES = 63,
46 ATA_ID_UDMA_MODES = 88,
47 ATA_ID_PIO4 = (1 << 1),
48
49 ATA_PCI_CTL_OFS = 2,
50 ATA_SERNO_LEN = 20,
51 ATA_UDMA0 = (1 << 0),
52 ATA_UDMA1 = ATA_UDMA0 | (1 << 1),
53 ATA_UDMA2 = ATA_UDMA1 | (1 << 2),
54 ATA_UDMA3 = ATA_UDMA2 | (1 << 3),
55 ATA_UDMA4 = ATA_UDMA3 | (1 << 4),
56 ATA_UDMA5 = ATA_UDMA4 | (1 << 5),
57 ATA_UDMA6 = ATA_UDMA5 | (1 << 6),
58 ATA_UDMA7 = ATA_UDMA6 | (1 << 7),
59 /* ATA_UDMA7 is just for completeness... doesn't exist (yet?). */
60
61 ATA_UDMA_MASK_40C = ATA_UDMA2, /* udma0-2 */
62
63 /* DMA-related */
64 ATA_PRD_SZ = 8,
65 ATA_PRD_TBL_SZ = (ATA_MAX_PRD * ATA_PRD_SZ),
66 ATA_PRD_EOT = (1 << 31), /* end-of-table flag */
67
68 ATA_DMA_TABLE_OFS = 4,
69 ATA_DMA_STATUS = 2,
70 ATA_DMA_CMD = 0,
71 ATA_DMA_WR = (1 << 3),
72 ATA_DMA_START = (1 << 0),
73 ATA_DMA_INTR = (1 << 2),
74 ATA_DMA_ERR = (1 << 1),
75 ATA_DMA_ACTIVE = (1 << 0),
76
77 /* bits in ATA command block registers */
78 ATA_HOB = (1 << 7), /* LBA48 selector */
79 ATA_NIEN = (1 << 1), /* disable-irq flag */
80 ATA_LBA = (1 << 6), /* LBA28 selector */
81 ATA_DEV1 = (1 << 4), /* Select Device 1 (slave) */
82 ATA_DEVICE_OBS = (1 << 7) | (1 << 5), /* obs bits in dev reg */
83 ATA_DEVCTL_OBS = (1 << 3), /* obsolete bit in devctl reg */
84 ATA_BUSY = (1 << 7), /* BSY status bit */
85 ATA_DRDY = (1 << 6), /* device ready */
86 ATA_DF = (1 << 5), /* device fault */
87 ATA_DRQ = (1 << 3), /* data request i/o */
88 ATA_ERR = (1 << 0), /* have an error */
89 ATA_SRST = (1 << 2), /* software reset */
90 ATA_ABORTED = (1 << 2), /* command aborted */
91
92 /* ATA command block registers */
93 ATA_REG_DATA = 0x00,
94 ATA_REG_ERR = 0x01,
95 ATA_REG_NSECT = 0x02,
96 ATA_REG_LBAL = 0x03,
97 ATA_REG_LBAM = 0x04,
98 ATA_REG_LBAH = 0x05,
99 ATA_REG_DEVICE = 0x06,
100 ATA_REG_STATUS = 0x07,
101
102 ATA_REG_FEATURE = ATA_REG_ERR, /* and their aliases */
103 ATA_REG_CMD = ATA_REG_STATUS,
104 ATA_REG_BYTEL = ATA_REG_LBAM,
105 ATA_REG_BYTEH = ATA_REG_LBAH,
106 ATA_REG_DEVSEL = ATA_REG_DEVICE,
107 ATA_REG_IRQ = ATA_REG_NSECT,
108
109 /* ATA device commands */
110 ATA_CMD_CHK_POWER = 0xE5, /* check power mode */
111 ATA_CMD_EDD = 0x90, /* execute device diagnostic */
112 ATA_CMD_FLUSH = 0xE7,
113 ATA_CMD_FLUSH_EXT = 0xEA,
114 ATA_CMD_ID_ATA = 0xEC,
115 ATA_CMD_ID_ATAPI = 0xA1,
116 ATA_CMD_READ = 0xC8,
117 ATA_CMD_READ_EXT = 0x25,
118 ATA_CMD_WRITE = 0xCA,
119 ATA_CMD_WRITE_EXT = 0x35,
120 ATA_CMD_PIO_READ = 0x20,
121 ATA_CMD_PIO_READ_EXT = 0x24,
122 ATA_CMD_PIO_WRITE = 0x30,
123 ATA_CMD_PIO_WRITE_EXT = 0x34,
124 ATA_CMD_SET_FEATURES = 0xEF,
125 ATA_CMD_PACKET = 0xA0,
126 ATA_CMD_VERIFY = 0x40,
127 ATA_CMD_VERIFY_EXT = 0x42,
128
129 /* SETFEATURES stuff */
130 SETFEATURES_XFER = 0x03,
131 XFER_UDMA_7 = 0x47,
132 XFER_UDMA_6 = 0x46,
133 XFER_UDMA_5 = 0x45,
134 XFER_UDMA_4 = 0x44,
135 XFER_UDMA_3 = 0x43,
136 XFER_UDMA_2 = 0x42,
137 XFER_UDMA_1 = 0x41,
138 XFER_UDMA_0 = 0x40,
139 XFER_MW_DMA_2 = 0x22,
140 XFER_MW_DMA_1 = 0x21,
141 XFER_MW_DMA_0 = 0x20,
142 XFER_PIO_4 = 0x0C,
143 XFER_PIO_3 = 0x0B,
144 XFER_PIO_2 = 0x0A,
145 XFER_PIO_1 = 0x09,
146 XFER_PIO_0 = 0x08,
147 XFER_SW_DMA_2 = 0x12,
148 XFER_SW_DMA_1 = 0x11,
149 XFER_SW_DMA_0 = 0x10,
150 XFER_PIO_SLOW = 0x00,
151
152 /* ATAPI stuff */
153 ATAPI_PKT_DMA = (1 << 0),
154 ATAPI_DMADIR = (1 << 2), /* ATAPI data dir:
155 0=to device, 1=to host */
156 ATAPI_CDB_LEN = 16,
157
158 /* cable types */
159 ATA_CBL_NONE = 0,
160 ATA_CBL_PATA40 = 1,
161 ATA_CBL_PATA80 = 2,
162 ATA_CBL_PATA_UNK = 3,
163 ATA_CBL_SATA = 4,
164
165 /* SATA Status and Control Registers */
166 SCR_STATUS = 0,
167 SCR_ERROR = 1,
168 SCR_CONTROL = 2,
169 SCR_ACTIVE = 3,
170 SCR_NOTIFICATION = 4,
171
172 /* struct ata_taskfile flags */
173 ATA_TFLAG_LBA48 = (1 << 0), /* enable 48-bit LBA and "HOB" */
174 ATA_TFLAG_ISADDR = (1 << 1), /* enable r/w to nsect/lba regs */
175 ATA_TFLAG_DEVICE = (1 << 2), /* enable r/w to device reg */
176 ATA_TFLAG_WRITE = (1 << 3), /* data dir: host->dev==1 (write) */
177};
178
179enum ata_tf_protocols {
180 /* ATA taskfile protocols */
181 ATA_PROT_UNKNOWN, /* unknown/invalid */
182 ATA_PROT_NODATA, /* no data */
183 ATA_PROT_PIO, /* PIO single sector */
184 ATA_PROT_PIO_MULT, /* PIO multiple sector */
185 ATA_PROT_DMA, /* DMA */
186 ATA_PROT_ATAPI, /* packet command, PIO data xfer*/
187 ATA_PROT_ATAPI_NODATA, /* packet command, no data */
188 ATA_PROT_ATAPI_DMA, /* packet command with special DMA sauce */
189};
190
191enum ata_ioctls {
192 ATA_IOC_GET_IO32 = 0x309,
193 ATA_IOC_SET_IO32 = 0x324,
194};
195
196/* core structures */
197
198struct ata_prd {
199 u32 addr;
200 u32 flags_len;
201};
202
203struct ata_taskfile {
204 unsigned long flags; /* ATA_TFLAG_xxx */
205 u8 protocol; /* ATA_PROT_xxx */
206
207 u8 ctl; /* control reg */
208
209 u8 hob_feature; /* additional data */
210 u8 hob_nsect; /* to support LBA48 */
211 u8 hob_lbal;
212 u8 hob_lbam;
213 u8 hob_lbah;
214
215 u8 feature;
216 u8 nsect;
217 u8 lbal;
218 u8 lbam;
219 u8 lbah;
220
221 u8 device;
222
223 u8 command; /* IO operation */
224};
225
226#define ata_id_is_ata(id) (((id)[0] & (1 << 15)) == 0)
227#define ata_id_rahead_enabled(id) ((id)[85] & (1 << 6))
228#define ata_id_wcache_enabled(id) ((id)[85] & (1 << 5))
229#define ata_id_has_flush(id) ((id)[83] & (1 << 12))
230#define ata_id_has_flush_ext(id) ((id)[83] & (1 << 13))
231#define ata_id_has_lba48(id) ((id)[83] & (1 << 10))
232#define ata_id_has_wcache(id) ((id)[82] & (1 << 5))
233#define ata_id_has_pm(id) ((id)[82] & (1 << 3))
234#define ata_id_has_lba(id) ((id)[49] & (1 << 9))
235#define ata_id_has_dma(id) ((id)[49] & (1 << 8))
236#define ata_id_removeable(id) ((id)[0] & (1 << 7))
237#define ata_id_u32(id,n) \
238 (((u32) (id)[(n) + 1] << 16) | ((u32) (id)[(n)]))
239#define ata_id_u64(id,n) \
240 ( ((u64) (id)[(n) + 3] << 48) | \
241 ((u64) (id)[(n) + 2] << 32) | \
242 ((u64) (id)[(n) + 1] << 16) | \
243 ((u64) (id)[(n) + 0]) )
244
245static inline int atapi_cdb_len(u16 *dev_id)
246{
247 u16 tmp = dev_id[0] & 0x3;
248 switch (tmp) {
249 case 0: return 12;
250 case 1: return 16;
251 default: return -1;
252 }
253}
254
255static inline int is_atapi_taskfile(struct ata_taskfile *tf)
256{
257 return (tf->protocol == ATA_PROT_ATAPI) ||
258 (tf->protocol == ATA_PROT_ATAPI_NODATA) ||
259 (tf->protocol == ATA_PROT_ATAPI_DMA);
260}
261
262static inline int ata_ok(u8 status)
263{
264 return ((status & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ | ATA_ERR))
265 == ATA_DRDY);
266}
267
268#endif /* __LINUX_ATA_H__ */
diff --git a/include/linux/atalk.h b/include/linux/atalk.h
new file mode 100644
index 000000000000..55fcfc11fdc7
--- /dev/null
+++ b/include/linux/atalk.h
@@ -0,0 +1,245 @@
1#ifndef __LINUX_ATALK_H__
2#define __LINUX_ATALK_H__
3
4#include <net/sock.h>
5
6/*
7 * AppleTalk networking structures
8 *
9 * The following are directly referenced from the University Of Michigan
10 * netatalk for compatibility reasons.
11 */
12#define ATPORT_FIRST 1
13#define ATPORT_RESERVED 128
14#define ATPORT_LAST 254 /* 254 is only legal on localtalk */
15#define ATADDR_ANYNET (__u16)0
16#define ATADDR_ANYNODE (__u8)0
17#define ATADDR_ANYPORT (__u8)0
18#define ATADDR_BCAST (__u8)255
19#define DDP_MAXSZ 587
20#define DDP_MAXHOPS 15 /* 4 bits of hop counter */
21
22#define SIOCATALKDIFADDR (SIOCPROTOPRIVATE + 0)
23
24struct atalk_addr {
25 __u16 s_net;
26 __u8 s_node;
27};
28
29struct sockaddr_at {
30 sa_family_t sat_family;
31 __u8 sat_port;
32 struct atalk_addr sat_addr;
33 char sat_zero[8];
34};
35
36struct atalk_netrange {
37 __u8 nr_phase;
38 __u16 nr_firstnet;
39 __u16 nr_lastnet;
40};
41
42struct atalk_route {
43 struct net_device *dev;
44 struct atalk_addr target;
45 struct atalk_addr gateway;
46 int flags;
47 struct atalk_route *next;
48};
49
50/**
51 * struct atalk_iface - AppleTalk Interface
52 * @dev - Network device associated with this interface
53 * @address - Our address
54 * @status - What are we doing?
55 * @nets - Associated direct netrange
56 * @next - next element in the list of interfaces
57 */
58struct atalk_iface {
59 struct net_device *dev;
60 struct atalk_addr address;
61 int status;
62#define ATIF_PROBE 1 /* Probing for an address */
63#define ATIF_PROBE_FAIL 2 /* Probe collided */
64 struct atalk_netrange nets;
65 struct atalk_iface *next;
66};
67
68struct atalk_sock {
69 /* struct sock has to be the first member of atalk_sock */
70 struct sock sk;
71 unsigned short dest_net;
72 unsigned short src_net;
73 unsigned char dest_node;
74 unsigned char src_node;
75 unsigned char dest_port;
76 unsigned char src_port;
77};
78
79static inline struct atalk_sock *at_sk(struct sock *sk)
80{
81 return (struct atalk_sock *)sk;
82}
83
84#ifdef __KERNEL__
85
86#include <asm/byteorder.h>
87
88struct ddpehdr {
89#ifdef __LITTLE_ENDIAN_BITFIELD
90 __u16 deh_len:10,
91 deh_hops:4,
92 deh_pad:2;
93#else
94 __u16 deh_pad:2,
95 deh_hops:4,
96 deh_len:10;
97#endif
98 __u16 deh_sum;
99 __u16 deh_dnet;
100 __u16 deh_snet;
101 __u8 deh_dnode;
102 __u8 deh_snode;
103 __u8 deh_dport;
104 __u8 deh_sport;
105 /* And netatalk apps expect to stick the type in themselves */
106};
107
108static __inline__ struct ddpehdr *ddp_hdr(struct sk_buff *skb)
109{
110 return (struct ddpehdr *)skb->h.raw;
111}
112
113/*
114 * Don't drop the struct into the struct above. You'll get some
115 * surprise padding.
116 */
117struct ddpebits {
118#ifdef __LITTLE_ENDIAN_BITFIELD
119 __u16 deh_len:10,
120 deh_hops:4,
121 deh_pad:2;
122#else
123 __u16 deh_pad:2,
124 deh_hops:4,
125 deh_len:10;
126#endif
127};
128
129/* Short form header */
130struct ddpshdr {
131#ifdef __LITTLE_ENDIAN_BITFIELD
132 __u16 dsh_len:10,
133 dsh_pad:6;
134#else
135 __u16 dsh_pad:6,
136 dsh_len:10;
137#endif
138 __u8 dsh_dport;
139 __u8 dsh_sport;
140 /* And netatalk apps expect to stick the type in themselves */
141};
142
143/* AppleTalk AARP headers */
144struct elapaarp {
145 __u16 hw_type;
146#define AARP_HW_TYPE_ETHERNET 1
147#define AARP_HW_TYPE_TOKENRING 2
148 __u16 pa_type;
149 __u8 hw_len;
150 __u8 pa_len;
151#define AARP_PA_ALEN 4
152 __u16 function;
153#define AARP_REQUEST 1
154#define AARP_REPLY 2
155#define AARP_PROBE 3
156 __u8 hw_src[ETH_ALEN] __attribute__ ((packed));
157 __u8 pa_src_zero __attribute__ ((packed));
158 __u16 pa_src_net __attribute__ ((packed));
159 __u8 pa_src_node __attribute__ ((packed));
160 __u8 hw_dst[ETH_ALEN] __attribute__ ((packed));
161 __u8 pa_dst_zero __attribute__ ((packed));
162 __u16 pa_dst_net __attribute__ ((packed));
163 __u8 pa_dst_node __attribute__ ((packed));
164};
165
166static __inline__ struct elapaarp *aarp_hdr(struct sk_buff *skb)
167{
168 return (struct elapaarp *)skb->h.raw;
169}
170
171/* Not specified - how long till we drop a resolved entry */
172#define AARP_EXPIRY_TIME (5 * 60 * HZ)
173/* Size of hash table */
174#define AARP_HASH_SIZE 16
175/* Fast retransmission timer when resolving */
176#define AARP_TICK_TIME (HZ / 5)
177/* Send 10 requests then give up (2 seconds) */
178#define AARP_RETRANSMIT_LIMIT 10
179/*
180 * Some value bigger than total retransmit time + a bit for last reply to
181 * appear and to stop continual requests
182 */
183#define AARP_RESOLVE_TIME (10 * HZ)
184
185extern struct datalink_proto *ddp_dl, *aarp_dl;
186extern void aarp_proto_init(void);
187
188/* Inter module exports */
189
190/* Give a device find its atif control structure */
191static inline struct atalk_iface *atalk_find_dev(struct net_device *dev)
192{
193 return dev->atalk_ptr;
194}
195
196extern struct atalk_addr *atalk_find_dev_addr(struct net_device *dev);
197extern struct net_device *atrtr_get_dev(struct atalk_addr *sa);
198extern int aarp_send_ddp(struct net_device *dev,
199 struct sk_buff *skb,
200 struct atalk_addr *sa, void *hwaddr);
201extern void aarp_device_down(struct net_device *dev);
202extern void aarp_probe_network(struct atalk_iface *atif);
203extern int aarp_proxy_probe_network(struct atalk_iface *atif,
204 struct atalk_addr *sa);
205extern void aarp_proxy_remove(struct net_device *dev,
206 struct atalk_addr *sa);
207
208extern void aarp_cleanup_module(void);
209
210extern struct hlist_head atalk_sockets;
211extern rwlock_t atalk_sockets_lock;
212
213extern struct atalk_route *atalk_routes;
214extern rwlock_t atalk_routes_lock;
215
216extern struct atalk_iface *atalk_interfaces;
217extern rwlock_t atalk_interfaces_lock;
218
219extern struct atalk_route atrtr_default;
220
221extern struct file_operations atalk_seq_arp_fops;
222
223extern int sysctl_aarp_expiry_time;
224extern int sysctl_aarp_tick_time;
225extern int sysctl_aarp_retransmit_limit;
226extern int sysctl_aarp_resolve_time;
227
228#ifdef CONFIG_SYSCTL
229extern void atalk_register_sysctl(void);
230extern void atalk_unregister_sysctl(void);
231#else
232#define atalk_register_sysctl() do { } while(0)
233#define atalk_unregister_sysctl() do { } while(0)
234#endif
235
236#ifdef CONFIG_PROC_FS
237extern int atalk_proc_init(void);
238extern void atalk_proc_exit(void);
239#else
240#define atalk_proc_init() ({ 0; })
241#define atalk_proc_exit() do { } while(0)
242#endif /* CONFIG_PROC_FS */
243
244#endif /* __KERNEL__ */
245#endif /* __LINUX_ATALK_H__ */
diff --git a/include/linux/atm.h b/include/linux/atm.h
new file mode 100644
index 000000000000..60136684e0af
--- /dev/null
+++ b/include/linux/atm.h
@@ -0,0 +1,243 @@
1/* atm.h - general ATM declarations */
2
3/* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */
4
5
6/*
7 * WARNING: User-space programs should not #include <linux/atm.h> directly.
8 * Instead, #include <atm.h>
9 */
10
11#ifndef _LINUX_ATM_H
12#define _LINUX_ATM_H
13
14/*
15 * BEGIN_xx and END_xx markers are used for automatic generation of
16 * documentation. Do not change them.
17 */
18
19#ifdef __KERNEL__
20#include <linux/socket.h>
21#include <linux/types.h>
22#endif
23#include <linux/compiler.h>
24#include <linux/atmapi.h>
25#include <linux/atmsap.h>
26#include <linux/atmioc.h>
27
28
29/* general ATM constants */
30#define ATM_CELL_SIZE 53 /* ATM cell size incl. header */
31#define ATM_CELL_PAYLOAD 48 /* ATM payload size */
32#define ATM_AAL0_SDU 52 /* AAL0 SDU size */
33#define ATM_MAX_AAL34_PDU 65535 /* maximum AAL3/4 PDU payload */
34#define ATM_AAL5_TRAILER 8 /* AAL5 trailer size */
35#define ATM_MAX_AAL5_PDU 65535 /* maximum AAL5 PDU payload */
36#define ATM_MAX_CDV 9999 /* maximum (default) CDV */
37#define ATM_NOT_RSV_VCI 32 /* first non-reserved VCI value */
38
39#define ATM_MAX_VPI 255 /* maximum VPI at the UNI */
40#define ATM_MAX_VPI_NNI 4096 /* maximum VPI at the NNI */
41#define ATM_MAX_VCI 65535 /* maximum VCI */
42
43
44/* "protcol" values for the socket system call */
45#define ATM_NO_AAL 0 /* AAL not specified */
46#define ATM_AAL0 13 /* "raw" ATM cells */
47#define ATM_AAL1 1 /* AAL1 (CBR) */
48#define ATM_AAL2 2 /* AAL2 (VBR) */
49#define ATM_AAL34 3 /* AAL3/4 (data) */
50#define ATM_AAL5 5 /* AAL5 (data) */
51
52/*
53 * socket option name coding functions
54 *
55 * Note that __SO_ENCODE and __SO_LEVEL are somewhat a hack since the
56 * << 22 only reserves 9 bits for the level. On some architectures
57 * SOL_SOCKET is 0xFFFF, so that's a bit of a problem
58 */
59
60#define __SO_ENCODE(l,n,t) ((((l) & 0x1FF) << 22) | ((n) << 16) | \
61 sizeof(t))
62#define __SO_LEVEL_MATCH(c,m) (((c) >> 22) == ((m) & 0x1FF))
63#define __SO_NUMBER(c) (((c) >> 16) & 0x3f)
64#define __SO_SIZE(c) ((c) & 0x3fff)
65
66/*
67 * ATM layer
68 */
69
70#define SO_SETCLP __SO_ENCODE(SOL_ATM,0,int)
71 /* set CLP bit value - TODO */
72#define SO_CIRANGE __SO_ENCODE(SOL_ATM,1,struct atm_cirange)
73 /* connection identifier range; socket must be
74 bound or connected */
75#define SO_ATMQOS __SO_ENCODE(SOL_ATM,2,struct atm_qos)
76 /* Quality of Service setting */
77#define SO_ATMSAP __SO_ENCODE(SOL_ATM,3,struct atm_sap)
78 /* Service Access Point */
79#define SO_ATMPVC __SO_ENCODE(SOL_ATM,4,struct sockaddr_atmpvc)
80 /* "PVC" address (also for SVCs); get only */
81#define SO_MULTIPOINT __SO_ENCODE(SOL_ATM, 5, int)
82 /* make this vc a p2mp */
83
84
85/*
86 * Note @@@: since the socket layers don't really distinguish the control and
87 * the data plane but generally seems to be data plane-centric, any layer is
88 * about equally wrong for the SAP. If you have a better idea about this,
89 * please speak up ...
90 */
91
92
93/* ATM cell header (for AAL0) */
94
95/* BEGIN_CH */
96#define ATM_HDR_GFC_MASK 0xf0000000
97#define ATM_HDR_GFC_SHIFT 28
98#define ATM_HDR_VPI_MASK 0x0ff00000
99#define ATM_HDR_VPI_SHIFT 20
100#define ATM_HDR_VCI_MASK 0x000ffff0
101#define ATM_HDR_VCI_SHIFT 4
102#define ATM_HDR_PTI_MASK 0x0000000e
103#define ATM_HDR_PTI_SHIFT 1
104#define ATM_HDR_CLP 0x00000001
105/* END_CH */
106
107
108/* PTI codings */
109
110/* BEGIN_PTI */
111#define ATM_PTI_US0 0 /* user data cell, congestion not exp, SDU-type 0 */
112#define ATM_PTI_US1 1 /* user data cell, congestion not exp, SDU-type 1 */
113#define ATM_PTI_UCES0 2 /* user data cell, cong. experienced, SDU-type 0 */
114#define ATM_PTI_UCES1 3 /* user data cell, cong. experienced, SDU-type 1 */
115#define ATM_PTI_SEGF5 4 /* segment OAM F5 flow related cell */
116#define ATM_PTI_E2EF5 5 /* end-to-end OAM F5 flow related cell */
117#define ATM_PTI_RSV_RM 6 /* reserved for traffic control/resource mgmt */
118#define ATM_PTI_RSV 7 /* reserved */
119/* END_PTI */
120
121
122/*
123 * The following items should stay in linux/atm.h, which should be linked to
124 * netatm/atm.h
125 */
126
127/* Traffic description */
128
129#define ATM_NONE 0 /* no traffic */
130#define ATM_UBR 1
131#define ATM_CBR 2
132#define ATM_VBR 3
133#define ATM_ABR 4
134#define ATM_ANYCLASS 5 /* compatible with everything */
135
136#define ATM_MAX_PCR -1 /* maximum available PCR */
137
138struct atm_trafprm {
139 unsigned char traffic_class; /* traffic class (ATM_UBR, ...) */
140 int max_pcr; /* maximum PCR in cells per second */
141 int pcr; /* desired PCR in cells per second */
142 int min_pcr; /* minimum PCR in cells per second */
143 int max_cdv; /* maximum CDV in microseconds */
144 int max_sdu; /* maximum SDU in bytes */
145 /* extra params for ABR */
146 unsigned int icr; /* Initial Cell Rate (24-bit) */
147 unsigned int tbe; /* Transient Buffer Exposure (24-bit) */
148 unsigned int frtt : 24; /* Fixed Round Trip Time (24-bit) */
149 unsigned int rif : 4; /* Rate Increment Factor (4-bit) */
150 unsigned int rdf : 4; /* Rate Decrease Factor (4-bit) */
151 unsigned int nrm_pres :1; /* nrm present bit */
152 unsigned int trm_pres :1; /* rm present bit */
153 unsigned int adtf_pres :1; /* adtf present bit */
154 unsigned int cdf_pres :1; /* cdf present bit*/
155 unsigned int nrm :3; /* Max # of Cells for each forward RM cell (3-bit) */
156 unsigned int trm :3; /* Time between forward RM cells (3-bit) */
157 unsigned int adtf :10; /* ACR Decrease Time Factor (10-bit) */
158 unsigned int cdf :3; /* Cutoff Decrease Factor (3-bit) */
159 unsigned int spare :9; /* spare bits */
160};
161
162struct atm_qos {
163 struct atm_trafprm txtp; /* parameters in TX direction */
164 struct atm_trafprm rxtp __ATM_API_ALIGN;
165 /* parameters in RX direction */
166 unsigned char aal __ATM_API_ALIGN;
167};
168
169/* PVC addressing */
170
171#define ATM_ITF_ANY -1 /* "magic" PVC address values */
172#define ATM_VPI_ANY -1
173#define ATM_VCI_ANY -1
174#define ATM_VPI_UNSPEC -2
175#define ATM_VCI_UNSPEC -2
176
177
178struct sockaddr_atmpvc {
179 unsigned short sap_family; /* address family, AF_ATMPVC */
180 struct { /* PVC address */
181 short itf; /* ATM interface */
182 short vpi; /* VPI (only 8 bits at UNI) */
183 int vci; /* VCI (only 16 bits at UNI) */
184 } sap_addr __ATM_API_ALIGN; /* PVC address */
185};
186
187/* SVC addressing */
188
189#define ATM_ESA_LEN 20 /* ATM End System Address length */
190#define ATM_E164_LEN 12 /* maximum E.164 number length */
191
192#define ATM_AFI_DCC 0x39 /* DCC ATM Format */
193#define ATM_AFI_ICD 0x47 /* ICD ATM Format */
194#define ATM_AFI_E164 0x45 /* E.164 ATM Format */
195#define ATM_AFI_LOCAL 0x49 /* Local ATM Format */
196
197#define ATM_AFI_DCC_GROUP 0xBD /* DCC ATM Group Format */
198#define ATM_AFI_ICD_GROUP 0xC5 /* ICD ATM Group Format */
199#define ATM_AFI_E164_GROUP 0xC3 /* E.164 ATM Group Format */
200#define ATM_AFI_LOCAL_GROUP 0xC7 /* Local ATM Group Format */
201
202#define ATM_LIJ_NONE 0 /* no leaf-initiated join */
203#define ATM_LIJ 1 /* request joining */
204#define ATM_LIJ_RPJ 2 /* set to root-prompted join */
205#define ATM_LIJ_NJ 3 /* set to network join */
206
207
208struct sockaddr_atmsvc {
209 unsigned short sas_family; /* address family, AF_ATMSVC */
210 struct { /* SVC address */
211 unsigned char prv[ATM_ESA_LEN];/* private ATM address */
212 char pub[ATM_E164_LEN+1]; /* public address (E.164) */
213 /* unused addresses must be bzero'ed */
214 char lij_type; /* role in LIJ call; one of ATM_LIJ* */
215 uint32_t lij_id; /* LIJ call identifier */
216 } sas_addr __ATM_API_ALIGN; /* SVC address */
217};
218
219
220static __inline__ int atmsvc_addr_in_use(struct sockaddr_atmsvc addr)
221{
222 return *addr.sas_addr.prv || *addr.sas_addr.pub;
223}
224
225
226static __inline__ int atmpvc_addr_in_use(struct sockaddr_atmpvc addr)
227{
228 return addr.sap_addr.itf || addr.sap_addr.vpi || addr.sap_addr.vci;
229}
230
231
232/*
233 * Some stuff for linux/sockios.h
234 */
235
236struct atmif_sioc {
237 int number;
238 int length;
239 void __user *arg;
240};
241
242typedef unsigned short atm_backend_t;
243#endif
diff --git a/include/linux/atm_eni.h b/include/linux/atm_eni.h
new file mode 100644
index 000000000000..34f317972551
--- /dev/null
+++ b/include/linux/atm_eni.h
@@ -0,0 +1,23 @@
1/* atm_eni.h - Driver-specific declarations of the ENI driver (for use by
2 driver-specific utilities) */
3
4/* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */
5
6
7#ifndef LINUX_ATM_ENI_H
8#define LINUX_ATM_ENI_H
9
10#include <linux/atmioc.h>
11
12
13struct eni_multipliers {
14 int tx,rx; /* values are in percent and must be > 100 */
15};
16
17
18#define ENI_MEMDUMP _IOW('a',ATMIOC_SARPRV,struct atmif_sioc)
19 /* printk memory map */
20#define ENI_SETMULT _IOW('a',ATMIOC_SARPRV+7,struct atmif_sioc)
21 /* set buffer multipliers */
22
23#endif
diff --git a/include/linux/atm_he.h b/include/linux/atm_he.h
new file mode 100644
index 000000000000..2a7713b597cf
--- /dev/null
+++ b/include/linux/atm_he.h
@@ -0,0 +1,20 @@
1/* atm_he.h */
2
3#ifndef LINUX_ATM_HE_H
4#define LINUX_ATM_HE_H
5
6#include <linux/atmioc.h>
7
8#define HE_GET_REG _IOW('a', ATMIOC_SARPRV, struct atmif_sioc)
9
10#define HE_REGTYPE_PCI 1
11#define HE_REGTYPE_RCM 2
12#define HE_REGTYPE_TCM 3
13#define HE_REGTYPE_MBOX 4
14
15struct he_ioctl_reg {
16 unsigned addr, val;
17 char type;
18};
19
20#endif /* LINUX_ATM_HE_H */
diff --git a/include/linux/atm_idt77105.h b/include/linux/atm_idt77105.h
new file mode 100644
index 000000000000..05621cf20709
--- /dev/null
+++ b/include/linux/atm_idt77105.h
@@ -0,0 +1,28 @@
1/* atm_idt77105.h - Driver-specific declarations of the IDT77105 driver (for
2 * use by driver-specific utilities) */
3
4/* Written 1999 by Greg Banks <gnb@linuxfan.com>. Copied from atm_suni.h. */
5
6
7#ifndef LINUX_ATM_IDT77105_H
8#define LINUX_ATM_IDT77105_H
9
10#include <asm/types.h>
11#include <linux/atmioc.h>
12#include <linux/atmdev.h>
13
14/*
15 * Structure for IDT77105_GETSTAT and IDT77105_GETSTATZ ioctls.
16 * Pointed to by `arg' in atmif_sioc.
17 */
18struct idt77105_stats {
19 __u32 symbol_errors; /* wire symbol errors */
20 __u32 tx_cells; /* cells transmitted */
21 __u32 rx_cells; /* cells received */
22 __u32 rx_hec_errors; /* Header Error Check errors on receive */
23};
24
25#define IDT77105_GETSTAT _IOW('a',ATMIOC_PHYPRV+2,struct atmif_sioc) /* get stats */
26#define IDT77105_GETSTATZ _IOW('a',ATMIOC_PHYPRV+3,struct atmif_sioc) /* get stats and zero */
27
28#endif
diff --git a/include/linux/atm_nicstar.h b/include/linux/atm_nicstar.h
new file mode 100644
index 000000000000..577b79f33e8d
--- /dev/null
+++ b/include/linux/atm_nicstar.h
@@ -0,0 +1,53 @@
1/******************************************************************************
2 *
3 * atm_nicstar.h
4 *
5 * Driver-specific declarations for use by NICSTAR driver specific utils.
6 *
7 * Author: Rui Prior
8 *
9 * (C) INESC 1998
10 *
11 ******************************************************************************/
12
13
14#ifndef LINUX_ATM_NICSTAR_H
15#define LINUX_ATM_NICSTAR_H
16
17/* Note: non-kernel programs including this file must also include
18 * sys/types.h for struct timeval
19 */
20
21#include <linux/atmapi.h>
22#include <linux/atmioc.h>
23
24#define NS_GETPSTAT _IOWR('a',ATMIOC_SARPRV+1,struct atmif_sioc)
25 /* get pool statistics */
26#define NS_SETBUFLEV _IOW('a',ATMIOC_SARPRV+2,struct atmif_sioc)
27 /* set buffer level markers */
28#define NS_ADJBUFLEV _IO('a',ATMIOC_SARPRV+3)
29 /* adjust buffer level */
30
31typedef struct buf_nr
32{
33 unsigned min;
34 unsigned init;
35 unsigned max;
36}buf_nr;
37
38
39typedef struct pool_levels
40{
41 int buftype;
42 int count; /* (At least for now) only used in NS_GETPSTAT */
43 buf_nr level;
44} pool_levels;
45
46/* type must be one of the following: */
47#define NS_BUFTYPE_SMALL 1
48#define NS_BUFTYPE_LARGE 2
49#define NS_BUFTYPE_HUGE 3
50#define NS_BUFTYPE_IOVEC 4
51
52
53#endif /* LINUX_ATM_NICSTAR_H */
diff --git a/include/linux/atm_suni.h b/include/linux/atm_suni.h
new file mode 100644
index 000000000000..84f3aab54468
--- /dev/null
+++ b/include/linux/atm_suni.h
@@ -0,0 +1,12 @@
1/* atm_suni.h - Driver-specific declarations of the SUNI driver (for use by
2 driver-specific utilities) */
3
4/* Written 1998,2000 by Werner Almesberger, EPFL ICA */
5
6
7#ifndef LINUX_ATM_SUNI_H
8#define LINUX_ATM_SUNI_H
9
10/* everything obsoleted */
11
12#endif
diff --git a/include/linux/atm_tcp.h b/include/linux/atm_tcp.h
new file mode 100644
index 000000000000..18787f9b2f19
--- /dev/null
+++ b/include/linux/atm_tcp.h
@@ -0,0 +1,75 @@
1/* atm_tcp.h - Driver-specific declarations of the ATMTCP driver (for use by
2 driver-specific utilities) */
3
4/* Written 1997-2000 by Werner Almesberger, EPFL LRC/ICA */
5
6
7#ifndef LINUX_ATM_TCP_H
8#define LINUX_ATM_TCP_H
9
10#include <linux/atmapi.h>
11
12#ifdef __KERNEL__
13#include <linux/types.h>
14#endif
15#include <linux/atmioc.h>
16
17
18/*
19 * All values in struct atmtcp_hdr are in network byte order
20 */
21
22struct atmtcp_hdr {
23 uint16_t vpi;
24 uint16_t vci;
25 uint32_t length; /* ... of data part */
26};
27
28/*
29 * All values in struct atmtcp_command are in host byte order
30 */
31
32#define ATMTCP_HDR_MAGIC (~0) /* this length indicates a command */
33#define ATMTCP_CTRL_OPEN 1 /* request/reply */
34#define ATMTCP_CTRL_CLOSE 2 /* request/reply */
35
36struct atmtcp_control {
37 struct atmtcp_hdr hdr; /* must be first */
38 int type; /* message type; both directions */
39 atm_kptr_t vcc; /* both directions */
40 struct sockaddr_atmpvc addr; /* suggested value from kernel */
41 struct atm_qos qos; /* both directions */
42 int result; /* to kernel only */
43} __ATM_API_ALIGN;
44
45/*
46 * Field usage:
47 * Messge type dir. hdr.v?i type addr qos vcc result
48 * ----------- ---- ------- ---- ---- --- --- ------
49 * OPEN K->D Y Y Y Y Y 0
50 * OPEN D->K - Y Y Y Y Y
51 * CLOSE K->D - - Y - Y 0
52 * CLOSE D->K - - - - Y Y
53 */
54
55#define SIOCSIFATMTCP _IO('a',ATMIOC_ITF) /* set ATMTCP mode */
56#define ATMTCP_CREATE _IO('a',ATMIOC_ITF+14) /* create persistent ATMTCP
57 interface */
58#define ATMTCP_REMOVE _IO('a',ATMIOC_ITF+15) /* destroy persistent ATMTCP
59 interface */
60
61
62#ifdef __KERNEL__
63
64struct atm_tcp_ops {
65 int (*attach)(struct atm_vcc *vcc,int itf);
66 int (*create_persistent)(int itf);
67 int (*remove_persistent)(int itf);
68 struct module *owner;
69};
70
71extern struct atm_tcp_ops atm_tcp_ops;
72
73#endif
74
75#endif
diff --git a/include/linux/atm_zatm.h b/include/linux/atm_zatm.h
new file mode 100644
index 000000000000..10f0fa29454f
--- /dev/null
+++ b/include/linux/atm_zatm.h
@@ -0,0 +1,52 @@
1/* atm_zatm.h - Driver-specific declarations of the ZATM driver (for use by
2 driver-specific utilities) */
3
4/* Written 1995-1999 by Werner Almesberger, EPFL LRC/ICA */
5
6
7#ifndef LINUX_ATM_ZATM_H
8#define LINUX_ATM_ZATM_H
9
10/*
11 * Note: non-kernel programs including this file must also include
12 * sys/types.h for struct timeval
13 */
14
15#include <linux/atmapi.h>
16#include <linux/atmioc.h>
17
18#define ZATM_GETPOOL _IOW('a',ATMIOC_SARPRV+1,struct atmif_sioc)
19 /* get pool statistics */
20#define ZATM_GETPOOLZ _IOW('a',ATMIOC_SARPRV+2,struct atmif_sioc)
21 /* get statistics and zero */
22#define ZATM_SETPOOL _IOW('a',ATMIOC_SARPRV+3,struct atmif_sioc)
23 /* set pool parameters */
24
25struct zatm_pool_info {
26 int ref_count; /* free buffer pool usage counters */
27 int low_water,high_water; /* refill parameters */
28 int rqa_count,rqu_count; /* queue condition counters */
29 int offset,next_off; /* alignment optimizations: offset */
30 int next_cnt,next_thres; /* repetition counter and threshold */
31};
32
33struct zatm_pool_req {
34 int pool_num; /* pool number */
35 struct zatm_pool_info info; /* actual information */
36};
37
38struct zatm_t_hist {
39 struct timeval real; /* real (wall-clock) time */
40 struct timeval expected; /* expected real time */
41};
42
43
44#define ZATM_OAM_POOL 0 /* free buffer pool for OAM cells */
45#define ZATM_AAL0_POOL 1 /* free buffer pool for AAL0 cells */
46#define ZATM_AAL5_POOL_BASE 2 /* first AAL5 free buffer pool */
47#define ZATM_LAST_POOL ZATM_AAL5_POOL_BASE+10 /* max. 64 kB */
48
49#define ZATM_TIMER_HISTORY_SIZE 16 /* number of timer adjustments to
50 record; must be 2^n */
51
52#endif
diff --git a/include/linux/atmapi.h b/include/linux/atmapi.h
new file mode 100644
index 000000000000..8fe54d90d95b
--- /dev/null
+++ b/include/linux/atmapi.h
@@ -0,0 +1,29 @@
1/* atmapi.h - ATM API user space/kernel compatibility */
2
3/* Written 1999,2000 by Werner Almesberger, EPFL ICA */
4
5
6#ifndef _LINUX_ATMAPI_H
7#define _LINUX_ATMAPI_H
8
9#if defined(__sparc__) || defined(__ia64__)
10/* such alignment is not required on 32 bit sparcs, but we can't
11 figure that we are on a sparc64 while compiling user-space programs. */
12#define __ATM_API_ALIGN __attribute__((aligned(8)))
13#else
14#define __ATM_API_ALIGN
15#endif
16
17
18/*
19 * Opaque type for kernel pointers. Note that _ is never accessed. We need
20 * the struct in order hide the array, so that we can make simple assignments
21 * instead of being forced to use memcpy. It also improves error reporting for
22 * code that still assumes that we're passing unsigned longs.
23 *
24 * Convention: NULL pointers are passed as a field of all zeroes.
25 */
26
27typedef struct { unsigned char _[8]; } __ATM_API_ALIGN atm_kptr_t;
28
29#endif
diff --git a/include/linux/atmarp.h b/include/linux/atmarp.h
new file mode 100644
index 000000000000..24f82338f59a
--- /dev/null
+++ b/include/linux/atmarp.h
@@ -0,0 +1,43 @@
1/* atmarp.h - ATM ARP protocol and kernel-demon interface definitions */
2
3/* Written 1995-1999 by Werner Almesberger, EPFL LRC/ICA */
4
5
6#ifndef _LINUX_ATMARP_H
7#define _LINUX_ATMARP_H
8
9#ifdef __KERNEL__
10#include <linux/types.h>
11#endif
12#include <linux/atmapi.h>
13#include <linux/atmioc.h>
14
15
16#define ATMARP_RETRY_DELAY 30 /* request next resolution or forget
17 NAK after 30 sec - should go into
18 atmclip.h */
19#define ATMARP_MAX_UNRES_PACKETS 5 /* queue that many packets while
20 waiting for the resolver */
21
22
23#define ATMARPD_CTRL _IO('a',ATMIOC_CLIP+1) /* become atmarpd ctrl sock */
24#define ATMARP_MKIP _IO('a',ATMIOC_CLIP+2) /* attach socket to IP */
25#define ATMARP_SETENTRY _IO('a',ATMIOC_CLIP+3) /* fill or hide ARP entry */
26#define ATMARP_ENCAP _IO('a',ATMIOC_CLIP+5) /* change encapsulation */
27
28
29enum atmarp_ctrl_type {
30 act_invalid, /* catch uninitialized structures */
31 act_need, /* need address resolution */
32 act_up, /* interface is coming up */
33 act_down, /* interface is going down */
34 act_change /* interface configuration has changed */
35};
36
37struct atmarp_ctrl {
38 enum atmarp_ctrl_type type; /* message type */
39 int itf_num;/* interface number (if present) */
40 uint32_t ip; /* IP address (act_need only) */
41};
42
43#endif
diff --git a/include/linux/atmbr2684.h b/include/linux/atmbr2684.h
new file mode 100644
index 000000000000..7981b733f1ef
--- /dev/null
+++ b/include/linux/atmbr2684.h
@@ -0,0 +1,101 @@
1#ifndef _LINUX_ATMBR2684_H
2#define _LINUX_ATMBR2684_H
3
4#include <linux/atm.h>
5#include <linux/if.h> /* For IFNAMSIZ */
6
7/*
8 * Type of media we're bridging (ethernet, token ring, etc) Currently only
9 * ethernet is supported
10 */
11#define BR2684_MEDIA_ETHERNET (0) /* 802.3 */
12#define BR2684_MEDIA_802_4 (1) /* 802.4 */
13#define BR2684_MEDIA_TR (2) /* 802.5 - token ring */
14#define BR2684_MEDIA_FDDI (3)
15#define BR2684_MEDIA_802_6 (4) /* 802.6 */
16
17/*
18 * Is there FCS inbound on this VC? This currently isn't supported.
19 */
20#define BR2684_FCSIN_NO (0)
21#define BR2684_FCSIN_IGNORE (1)
22#define BR2684_FCSIN_VERIFY (2)
23
24/*
25 * Is there FCS outbound on this VC? This currently isn't supported.
26 */
27#define BR2684_FCSOUT_NO (0)
28#define BR2684_FCSOUT_SENDZERO (1)
29#define BR2684_FCSOUT_GENERATE (2)
30
31/*
32 * Does this VC include LLC encapsulation?
33 */
34#define BR2684_ENCAPS_VC (0) /* VC-mux */
35#define BR2684_ENCAPS_LLC (1)
36#define BR2684_ENCAPS_AUTODETECT (2) /* Unsuported */
37
38/*
39 * This is for the ATM_NEWBACKENDIF call - these are like socket families:
40 * the first element of the structure is the backend number and the rest
41 * is per-backend specific
42 */
43struct atm_newif_br2684 {
44 atm_backend_t backend_num; /* ATM_BACKEND_BR2684 */
45 int media; /* BR2684_MEDIA_* */
46 char ifname[IFNAMSIZ];
47 int mtu;
48};
49
50/*
51 * This structure is used to specify a br2684 interface - either by a
52 * positive integer (returned by ATM_NEWBACKENDIF) or the interfaces name
53 */
54#define BR2684_FIND_BYNOTHING (0)
55#define BR2684_FIND_BYNUM (1)
56#define BR2684_FIND_BYIFNAME (2)
57struct br2684_if_spec {
58 int method; /* BR2684_FIND_* */
59 union {
60 char ifname[IFNAMSIZ];
61 int devnum;
62 } spec;
63};
64
65/*
66 * This is for the ATM_SETBACKEND call - these are like socket families:
67 * the first element of the structure is the backend number and the rest
68 * is per-backend specific
69 */
70struct atm_backend_br2684 {
71 atm_backend_t backend_num; /* ATM_BACKEND_BR2684 */
72 struct br2684_if_spec ifspec;
73 int fcs_in; /* BR2684_FCSIN_* */
74 int fcs_out; /* BR2684_FCSOUT_* */
75 int fcs_auto; /* 1: fcs_{in,out} disabled if no FCS rx'ed */
76 int encaps; /* BR2684_ENCAPS_* */
77 int has_vpiid; /* 1: use vpn_id - Unsupported */
78 __u8 vpn_id[7];
79 int send_padding; /* unsupported */
80 int min_size; /* we will pad smaller packets than this */
81};
82
83/*
84 * The BR2684_SETFILT ioctl is an experimental mechanism for folks
85 * terminating a large number of IP-only vcc's. When netfilter allows
86 * efficient per-if in/out filters, this support will be removed
87 */
88struct br2684_filter {
89 __u32 prefix; /* network byte order */
90 __u32 netmask; /* 0 = disable filter */
91};
92
93struct br2684_filter_set {
94 struct br2684_if_spec ifspec;
95 struct br2684_filter filter;
96};
97
98#define BR2684_SETFILT _IOW( 'a', ATMIOC_BACKEND + 0, \
99 struct br2684_filter_set)
100
101#endif /* _LINUX_ATMBR2684_H */
diff --git a/include/linux/atmclip.h b/include/linux/atmclip.h
new file mode 100644
index 000000000000..02c94c448dd6
--- /dev/null
+++ b/include/linux/atmclip.h
@@ -0,0 +1,21 @@
1/* atmclip.h - Classical IP over ATM */
2
3/* Written 1995-1998 by Werner Almesberger, EPFL LRC/ICA */
4
5
6#ifndef LINUX_ATMCLIP_H
7#define LINUX_ATMCLIP_H
8
9#include <linux/sockios.h>
10#include <linux/atmioc.h>
11
12
13#define RFC1483LLC_LEN 8 /* LLC+OUI+PID = 8 */
14#define RFC1626_MTU 9180 /* RFC1626 default MTU */
15
16#define CLIP_DEFAULT_IDLETIMER 1200 /* 20 minutes, see RFC1755 */
17#define CLIP_CHECK_INTERVAL 10 /* check every ten seconds */
18
19#define SIOCMKCLIP _IO('a',ATMIOC_CLIP) /* create IP interface */
20
21#endif
diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
new file mode 100644
index 000000000000..9f374cfa1b05
--- /dev/null
+++ b/include/linux/atmdev.h
@@ -0,0 +1,489 @@
1/* atmdev.h - ATM device driver declarations and various related items */
2
3/* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */
4
5
6#ifndef LINUX_ATMDEV_H
7#define LINUX_ATMDEV_H
8
9
10#include <linux/config.h>
11#include <linux/atmapi.h>
12#include <linux/atm.h>
13#include <linux/atmioc.h>
14
15
16#define ESI_LEN 6
17
18#define ATM_OC3_PCR (155520000/270*260/8/53)
19 /* OC3 link rate: 155520000 bps
20 SONET overhead: /270*260 (9 section, 1 path)
21 bits per cell: /8/53
22 max cell rate: 353207.547 cells/sec */
23#define ATM_25_PCR ((25600000/8-8000)/54)
24 /* 25 Mbps ATM cell rate (59111) */
25#define ATM_OC12_PCR (622080000/1080*1040/8/53)
26 /* OC12 link rate: 622080000 bps
27 SONET overhead: /1080*1040
28 bits per cell: /8/53
29 max cell rate: 1412830.188 cells/sec */
30#define ATM_DS3_PCR (8000*12)
31 /* DS3: 12 cells in a 125 usec time slot */
32
33
34#define __AAL_STAT_ITEMS \
35 __HANDLE_ITEM(tx); /* TX okay */ \
36 __HANDLE_ITEM(tx_err); /* TX errors */ \
37 __HANDLE_ITEM(rx); /* RX okay */ \
38 __HANDLE_ITEM(rx_err); /* RX errors */ \
39 __HANDLE_ITEM(rx_drop); /* RX out of memory */
40
41struct atm_aal_stats {
42#define __HANDLE_ITEM(i) int i
43 __AAL_STAT_ITEMS
44#undef __HANDLE_ITEM
45};
46
47
48struct atm_dev_stats {
49 struct atm_aal_stats aal0;
50 struct atm_aal_stats aal34;
51 struct atm_aal_stats aal5;
52} __ATM_API_ALIGN;
53
54
55#define ATM_GETLINKRATE _IOW('a',ATMIOC_ITF+1,struct atmif_sioc)
56 /* get link rate */
57#define ATM_GETNAMES _IOW('a',ATMIOC_ITF+3,struct atm_iobuf)
58 /* get interface names (numbers) */
59#define ATM_GETTYPE _IOW('a',ATMIOC_ITF+4,struct atmif_sioc)
60 /* get interface type name */
61#define ATM_GETESI _IOW('a',ATMIOC_ITF+5,struct atmif_sioc)
62 /* get interface ESI */
63#define ATM_GETADDR _IOW('a',ATMIOC_ITF+6,struct atmif_sioc)
64 /* get itf's local ATM addr. list */
65#define ATM_RSTADDR _IOW('a',ATMIOC_ITF+7,struct atmif_sioc)
66 /* reset itf's ATM address list */
67#define ATM_ADDADDR _IOW('a',ATMIOC_ITF+8,struct atmif_sioc)
68 /* add a local ATM address */
69#define ATM_DELADDR _IOW('a',ATMIOC_ITF+9,struct atmif_sioc)
70 /* remove a local ATM address */
71#define ATM_GETCIRANGE _IOW('a',ATMIOC_ITF+10,struct atmif_sioc)
72 /* get connection identifier range */
73#define ATM_SETCIRANGE _IOW('a',ATMIOC_ITF+11,struct atmif_sioc)
74 /* set connection identifier range */
75#define ATM_SETESI _IOW('a',ATMIOC_ITF+12,struct atmif_sioc)
76 /* set interface ESI */
77#define ATM_SETESIF _IOW('a',ATMIOC_ITF+13,struct atmif_sioc)
78 /* force interface ESI */
79#define ATM_GETSTAT _IOW('a',ATMIOC_SARCOM+0,struct atmif_sioc)
80 /* get AAL layer statistics */
81#define ATM_GETSTATZ _IOW('a',ATMIOC_SARCOM+1,struct atmif_sioc)
82 /* get AAL layer statistics and zero */
83#define ATM_GETLOOP _IOW('a',ATMIOC_SARCOM+2,struct atmif_sioc)
84 /* get loopback mode */
85#define ATM_SETLOOP _IOW('a',ATMIOC_SARCOM+3,struct atmif_sioc)
86 /* set loopback mode */
87#define ATM_QUERYLOOP _IOW('a',ATMIOC_SARCOM+4,struct atmif_sioc)
88 /* query supported loopback modes */
89#define ATM_SETSC _IOW('a',ATMIOC_SPECIAL+1,int)
90 /* enable or disable single-copy */
91#define ATM_SETBACKEND _IOW('a',ATMIOC_SPECIAL+2,atm_backend_t)
92 /* set backend handler */
93#define ATM_NEWBACKENDIF _IOW('a',ATMIOC_SPECIAL+3,atm_backend_t)
94 /* use backend to make new if */
95#define ATM_ADDPARTY _IOW('a', ATMIOC_SPECIAL+4,struct atm_iobuf)
96 /* add party to p2mp call */
97#define ATM_DROPPARTY _IOW('a', ATMIOC_SPECIAL+5,int)
98 /* drop party from p2mp call */
99
100/*
101 * These are backend handkers that can be set via the ATM_SETBACKEND call
102 * above. In the future we may support dynamic loading of these - for now,
103 * they're just being used to share the ATMIOC_BACKEND ioctls
104 */
105#define ATM_BACKEND_RAW 0
106#define ATM_BACKEND_PPP 1 /* PPPoATM - RFC2364 */
107#define ATM_BACKEND_BR2684 2 /* Bridged RFC1483/2684 */
108
109/* for ATM_GETTYPE */
110#define ATM_ITFTYP_LEN 8 /* maximum length of interface type name */
111
112/*
113 * Loopback modes for ATM_{PHY,SAR}_{GET,SET}LOOP
114 */
115
116/* Point of loopback CPU-->SAR-->PHY-->line--> ... */
117#define __ATM_LM_NONE 0 /* no loop back ^ ^ ^ ^ */
118#define __ATM_LM_AAL 1 /* loop back PDUs --' | | | */
119#define __ATM_LM_ATM 2 /* loop back ATM cells ---' | | */
120/* RESERVED 4 loop back on PHY side ---' */
121#define __ATM_LM_PHY 8 /* loop back bits (digital) ----' | */
122#define __ATM_LM_ANALOG 16 /* loop back the analog signal --------' */
123
124/* Direction of loopback */
125#define __ATM_LM_MKLOC(n) ((n)) /* Local (i.e. loop TX to RX) */
126#define __ATM_LM_MKRMT(n) ((n) << 8) /* Remote (i.e. loop RX to TX) */
127
128#define __ATM_LM_XTLOC(n) ((n) & 0xff)
129#define __ATM_LM_XTRMT(n) (((n) >> 8) & 0xff)
130
131#define ATM_LM_NONE 0 /* no loopback */
132
133#define ATM_LM_LOC_AAL __ATM_LM_MKLOC(__ATM_LM_AAL)
134#define ATM_LM_LOC_ATM __ATM_LM_MKLOC(__ATM_LM_ATM)
135#define ATM_LM_LOC_PHY __ATM_LM_MKLOC(__ATM_LM_PHY)
136#define ATM_LM_LOC_ANALOG __ATM_LM_MKLOC(__ATM_LM_ANALOG)
137
138#define ATM_LM_RMT_AAL __ATM_LM_MKRMT(__ATM_LM_AAL)
139#define ATM_LM_RMT_ATM __ATM_LM_MKRMT(__ATM_LM_ATM)
140#define ATM_LM_RMT_PHY __ATM_LM_MKRMT(__ATM_LM_PHY)
141#define ATM_LM_RMT_ANALOG __ATM_LM_MKRMT(__ATM_LM_ANALOG)
142
143/*
144 * Note: ATM_LM_LOC_* and ATM_LM_RMT_* can be combined, provided that
145 * __ATM_LM_XTLOC(x) <= __ATM_LM_XTRMT(x)
146 */
147
148
149struct atm_iobuf {
150 int length;
151 void __user *buffer;
152};
153
154/* for ATM_GETCIRANGE / ATM_SETCIRANGE */
155
156#define ATM_CI_MAX -1 /* use maximum range of VPI/VCI */
157
158struct atm_cirange {
159 signed char vpi_bits; /* 1..8, ATM_CI_MAX (-1) for maximum */
160 signed char vci_bits; /* 1..16, ATM_CI_MAX (-1) for maximum */
161};
162
163/* for ATM_SETSC; actually taken from the ATM_VF number space */
164
165#define ATM_SC_RX 1024 /* enable RX single-copy */
166#define ATM_SC_TX 2048 /* enable TX single-copy */
167
168#define ATM_BACKLOG_DEFAULT 32 /* if we get more, we're likely to time out
169 anyway */
170
171/* MF: change_qos (Modify) flags */
172
173#define ATM_MF_IMMED 1 /* Block until change is effective */
174#define ATM_MF_INC_RSV 2 /* Change reservation on increase */
175#define ATM_MF_INC_SHP 4 /* Change shaping on increase */
176#define ATM_MF_DEC_RSV 8 /* Change reservation on decrease */
177#define ATM_MF_DEC_SHP 16 /* Change shaping on decrease */
178#define ATM_MF_BWD 32 /* Set the backward direction parameters */
179
180#define ATM_MF_SET (ATM_MF_INC_RSV | ATM_MF_INC_SHP | ATM_MF_DEC_RSV | \
181 ATM_MF_DEC_SHP | ATM_MF_BWD)
182
183/*
184 * ATM_VS_* are used to express VC state in a human-friendly way.
185 */
186
187#define ATM_VS_IDLE 0 /* VC is not used */
188#define ATM_VS_CONNECTED 1 /* VC is connected */
189#define ATM_VS_CLOSING 2 /* VC is closing */
190#define ATM_VS_LISTEN 3 /* VC is listening for incoming setups */
191#define ATM_VS_INUSE 4 /* VC is in use (registered with atmsigd) */
192#define ATM_VS_BOUND 5 /* VC is bound */
193
194#define ATM_VS2TXT_MAP \
195 "IDLE", "CONNECTED", "CLOSING", "LISTEN", "INUSE", "BOUND"
196
197#define ATM_VF2TXT_MAP \
198 "ADDR", "READY", "PARTIAL", "REGIS", \
199 "RELEASED", "HASQOS", "LISTEN", "META", \
200 "256", "512", "1024", "2048", \
201 "SESSION", "HASSAP", "BOUND", "CLOSE"
202
203
204#ifdef __KERNEL__
205
206#include <linux/wait.h> /* wait_queue_head_t */
207#include <linux/time.h> /* struct timeval */
208#include <linux/net.h>
209#include <linux/skbuff.h> /* struct sk_buff */
210#include <linux/uio.h>
211#include <net/sock.h>
212#include <asm/atomic.h>
213
214#ifdef CONFIG_PROC_FS
215#include <linux/proc_fs.h>
216
217extern struct proc_dir_entry *atm_proc_root;
218#endif
219
220
221struct k_atm_aal_stats {
222#define __HANDLE_ITEM(i) atomic_t i
223 __AAL_STAT_ITEMS
224#undef __HANDLE_ITEM
225};
226
227
228struct k_atm_dev_stats {
229 struct k_atm_aal_stats aal0;
230 struct k_atm_aal_stats aal34;
231 struct k_atm_aal_stats aal5;
232};
233
234
235enum {
236 ATM_VF_ADDR, /* Address is in use. Set by anybody, cleared
237 by device driver. */
238 ATM_VF_READY, /* VC is ready to transfer data. Set by device
239 driver, cleared by anybody. */
240 ATM_VF_PARTIAL, /* resources are bound to PVC (partial PVC
241 setup), controlled by socket layer */
242 ATM_VF_REGIS, /* registered with demon, controlled by SVC
243 socket layer */
244 ATM_VF_BOUND, /* local SAP is set, controlled by SVC socket
245 layer */
246 ATM_VF_RELEASED, /* demon has indicated/requested release,
247 controlled by SVC socket layer */
248 ATM_VF_HASQOS, /* QOS parameters have been set */
249 ATM_VF_LISTEN, /* socket is used for listening */
250 ATM_VF_META, /* SVC socket isn't used for normal data
251 traffic and doesn't depend on signaling
252 to be available */
253 ATM_VF_SESSION, /* VCC is p2mp session control descriptor */
254 ATM_VF_HASSAP, /* SAP has been set */
255 ATM_VF_CLOSE, /* asynchronous close - treat like VF_RELEASED*/
256 ATM_VF_WAITING, /* waiting for reply from sigd */
257 ATM_VF_IS_CLIP, /* in use by CLIP protocol */
258};
259
260
261#define ATM_VF2VS(flags) \
262 (test_bit(ATM_VF_READY,&(flags)) ? ATM_VS_CONNECTED : \
263 test_bit(ATM_VF_RELEASED,&(flags)) ? ATM_VS_CLOSING : \
264 test_bit(ATM_VF_LISTEN,&(flags)) ? ATM_VS_LISTEN : \
265 test_bit(ATM_VF_REGIS,&(flags)) ? ATM_VS_INUSE : \
266 test_bit(ATM_VF_BOUND,&(flags)) ? ATM_VS_BOUND : ATM_VS_IDLE)
267
268
269enum {
270 ATM_DF_CLOSE, /* close device when last VCC is closed */
271};
272
273
274#define ATM_PHY_SIG_LOST 0 /* no carrier/light */
275#define ATM_PHY_SIG_UNKNOWN 1 /* carrier/light status is unknown */
276#define ATM_PHY_SIG_FOUND 2 /* carrier/light okay */
277
278#define ATM_ATMOPT_CLP 1 /* set CLP bit */
279
280struct atm_vcc {
281 /* struct sock has to be the first member of atm_vcc */
282 struct sock sk;
283 unsigned long flags; /* VCC flags (ATM_VF_*) */
284 short vpi; /* VPI and VCI (types must be equal */
285 /* with sockaddr) */
286 int vci;
287 unsigned long aal_options; /* AAL layer options */
288 unsigned long atm_options; /* ATM layer options */
289 struct atm_dev *dev; /* device back pointer */
290 struct atm_qos qos; /* QOS */
291 struct atm_sap sap; /* SAP */
292 void (*push)(struct atm_vcc *vcc,struct sk_buff *skb);
293 void (*pop)(struct atm_vcc *vcc,struct sk_buff *skb); /* optional */
294 int (*push_oam)(struct atm_vcc *vcc,void *cell);
295 int (*send)(struct atm_vcc *vcc,struct sk_buff *skb);
296 void *dev_data; /* per-device data */
297 void *proto_data; /* per-protocol data */
298 struct k_atm_aal_stats *stats; /* pointer to AAL stats group */
299 /* SVC part --- may move later ------------------------------------- */
300 short itf; /* interface number */
301 struct sockaddr_atmsvc local;
302 struct sockaddr_atmsvc remote;
303 /* Multipoint part ------------------------------------------------- */
304 struct atm_vcc *session; /* session VCC descriptor */
305 /* Other stuff ----------------------------------------------------- */
306 void *user_back; /* user backlink - not touched by */
307 /* native ATM stack. Currently used */
308 /* by CLIP and sch_atm. */
309};
310
311static inline struct atm_vcc *atm_sk(struct sock *sk)
312{
313 return (struct atm_vcc *)sk;
314}
315
316static inline struct atm_vcc *ATM_SD(struct socket *sock)
317{
318 return atm_sk(sock->sk);
319}
320
321static inline struct sock *sk_atm(struct atm_vcc *vcc)
322{
323 return (struct sock *)vcc;
324}
325
326struct atm_dev_addr {
327 struct sockaddr_atmsvc addr; /* ATM address */
328 struct list_head entry; /* next address */
329};
330
331struct atm_dev {
332 const struct atmdev_ops *ops; /* device operations; NULL if unused */
333 const struct atmphy_ops *phy; /* PHY operations, may be undefined */
334 /* (NULL) */
335 const char *type; /* device type name */
336 int number; /* device index */
337 void *dev_data; /* per-device data */
338 void *phy_data; /* private PHY date */
339 unsigned long flags; /* device flags (ATM_DF_*) */
340 struct list_head local; /* local ATM addresses */
341 unsigned char esi[ESI_LEN]; /* ESI ("MAC" addr) */
342 struct atm_cirange ci_range; /* VPI/VCI range */
343 struct k_atm_dev_stats stats; /* statistics */
344 char signal; /* signal status (ATM_PHY_SIG_*) */
345 int link_rate; /* link rate (default: OC3) */
346 atomic_t refcnt; /* reference count */
347 spinlock_t lock; /* protect internal members */
348#ifdef CONFIG_PROC_FS
349 struct proc_dir_entry *proc_entry; /* proc entry */
350 char *proc_name; /* proc entry name */
351#endif
352 struct list_head dev_list; /* linkage */
353};
354
355
356/* OF: send_Oam Flags */
357
358#define ATM_OF_IMMED 1 /* Attempt immediate delivery */
359#define ATM_OF_INRATE 2 /* Attempt in-rate delivery */
360
361
362/*
363 * ioctl, getsockopt, and setsockopt are optional and can be set to NULL.
364 */
365
366struct atmdev_ops { /* only send is required */
367 void (*dev_close)(struct atm_dev *dev);
368 int (*open)(struct atm_vcc *vcc);
369 void (*close)(struct atm_vcc *vcc);
370 int (*ioctl)(struct atm_dev *dev,unsigned int cmd,void __user *arg);
371 int (*getsockopt)(struct atm_vcc *vcc,int level,int optname,
372 void __user *optval,int optlen);
373 int (*setsockopt)(struct atm_vcc *vcc,int level,int optname,
374 void __user *optval,int optlen);
375 int (*send)(struct atm_vcc *vcc,struct sk_buff *skb);
376 int (*send_oam)(struct atm_vcc *vcc,void *cell,int flags);
377 void (*phy_put)(struct atm_dev *dev,unsigned char value,
378 unsigned long addr);
379 unsigned char (*phy_get)(struct atm_dev *dev,unsigned long addr);
380 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
381 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
382 struct module *owner;
383};
384
385struct atmphy_ops {
386 int (*start)(struct atm_dev *dev);
387 int (*ioctl)(struct atm_dev *dev,unsigned int cmd,void __user *arg);
388 void (*interrupt)(struct atm_dev *dev);
389 int (*stop)(struct atm_dev *dev);
390};
391
392struct atm_skb_data {
393 struct atm_vcc *vcc; /* ATM VCC */
394 unsigned long atm_options; /* ATM layer options */
395};
396
397#define VCC_HTABLE_SIZE 32
398
399extern struct hlist_head vcc_hash[VCC_HTABLE_SIZE];
400extern rwlock_t vcc_sklist_lock;
401
402#define ATM_SKB(skb) (((struct atm_skb_data *) (skb)->cb))
403
404struct atm_dev *atm_dev_register(const char *type,const struct atmdev_ops *ops,
405 int number,unsigned long *flags); /* number == -1: pick first available */
406struct atm_dev *atm_dev_lookup(int number);
407void atm_dev_deregister(struct atm_dev *dev);
408void shutdown_atm_dev(struct atm_dev *dev);
409void vcc_insert_socket(struct sock *sk);
410
411
412/*
413 * This is approximately the algorithm used by alloc_skb.
414 *
415 */
416
417static inline int atm_guess_pdu2truesize(int size)
418{
419 return (SKB_DATA_ALIGN(size) + sizeof(struct skb_shared_info));
420}
421
422
423static inline void atm_force_charge(struct atm_vcc *vcc,int truesize)
424{
425 atomic_add(truesize, &sk_atm(vcc)->sk_rmem_alloc);
426}
427
428
429static inline void atm_return(struct atm_vcc *vcc,int truesize)
430{
431 atomic_sub(truesize, &sk_atm(vcc)->sk_rmem_alloc);
432}
433
434
435static inline int atm_may_send(struct atm_vcc *vcc,unsigned int size)
436{
437 return (size + atomic_read(&sk_atm(vcc)->sk_wmem_alloc)) <
438 sk_atm(vcc)->sk_sndbuf;
439}
440
441
442static inline void atm_dev_hold(struct atm_dev *dev)
443{
444 atomic_inc(&dev->refcnt);
445}
446
447
448static inline void atm_dev_put(struct atm_dev *dev)
449{
450 atomic_dec(&dev->refcnt);
451
452 if ((atomic_read(&dev->refcnt) == 1) &&
453 test_bit(ATM_DF_CLOSE,&dev->flags))
454 shutdown_atm_dev(dev);
455}
456
457
458int atm_charge(struct atm_vcc *vcc,int truesize);
459struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc,int pdu_size,
460 int gfp_flags);
461int atm_pcr_goal(struct atm_trafprm *tp);
462
463void vcc_release_async(struct atm_vcc *vcc, int reply);
464
465struct atm_ioctl {
466 struct module *owner;
467 /* A module reference is kept if appropriate over this call.
468 * Return -ENOIOCTLCMD if you don't handle it. */
469 int (*ioctl)(struct socket *, unsigned int cmd, unsigned long arg);
470 struct list_head list;
471};
472
473/**
474 * register_atm_ioctl - register handler for ioctl operations
475 *
476 * Special (non-device) handlers of ioctl's should
477 * register here. If you're a normal device, you should
478 * set .ioctl in your atmdev_ops instead.
479 */
480void register_atm_ioctl(struct atm_ioctl *);
481
482/**
483 * deregister_atm_ioctl - remove the ioctl handler
484 */
485void deregister_atm_ioctl(struct atm_ioctl *);
486
487#endif /* __KERNEL__ */
488
489#endif
diff --git a/include/linux/atmioc.h b/include/linux/atmioc.h
new file mode 100644
index 000000000000..37f67aa8f1c1
--- /dev/null
+++ b/include/linux/atmioc.h
@@ -0,0 +1,41 @@
1/* atmioc.h - ranges for ATM-related ioctl numbers */
2
3/* Written 1995-1999 by Werner Almesberger, EPFL LRC/ICA */
4
5
6/*
7 * See http://icawww1.epfl.ch/linux-atm/magic.html for the complete list of
8 * "magic" ioctl numbers.
9 */
10
11
12#ifndef _LINUX_ATMIOC_H
13#define _LINUX_ATMIOC_H
14
15#include <asm/ioctl.h>
16 /* everybody including atmioc.h will also need _IO{,R,W,WR} */
17
18#define ATMIOC_PHYCOM 0x00 /* PHY device common ioctls, globally unique */
19#define ATMIOC_PHYCOM_END 0x0f
20#define ATMIOC_PHYTYP 0x10 /* PHY dev type ioctls, unique per PHY type */
21#define ATMIOC_PHYTYP_END 0x2f
22#define ATMIOC_PHYPRV 0x30 /* PHY dev private ioctls, unique per driver */
23#define ATMIOC_PHYPRV_END 0x4f
24#define ATMIOC_SARCOM 0x50 /* SAR device common ioctls, globally unique */
25#define ATMIOC_SARCOM_END 0x50
26#define ATMIOC_SARPRV 0x60 /* SAR dev private ioctls, unique per driver */
27#define ATMIOC_SARPRV_END 0x7f
28#define ATMIOC_ITF 0x80 /* Interface ioctls, globally unique */
29#define ATMIOC_ITF_END 0x8f
30#define ATMIOC_BACKEND 0x90 /* ATM generic backend ioctls, u. per backend */
31#define ATMIOC_BACKEND_END 0xaf
32/* 0xb0-0xbf: Reserved for future use */
33#define ATMIOC_AREQUIPA 0xc0 /* Application requested IP over ATM, glob. u. */
34#define ATMIOC_LANE 0xd0 /* LAN Emulation, globally unique */
35#define ATMIOC_MPOA 0xd8 /* MPOA, globally unique */
36#define ATMIOC_CLIP 0xe0 /* Classical IP over ATM control, globally u. */
37#define ATMIOC_CLIP_END 0xef
38#define ATMIOC_SPECIAL 0xf0 /* Special-purpose controls, globally unique */
39#define ATMIOC_SPECIAL_END 0xff
40
41#endif
diff --git a/include/linux/atmlec.h b/include/linux/atmlec.h
new file mode 100644
index 000000000000..f267f2442766
--- /dev/null
+++ b/include/linux/atmlec.h
@@ -0,0 +1,88 @@
1/*
2 *
3 * ATM Lan Emulation Daemon vs. driver interface
4 *
5 * mkiiskila@yahoo.com
6 *
7 */
8
9#ifndef _ATMLEC_H_
10#define _ATMLEC_H_
11
12#include <linux/atmapi.h>
13#include <linux/atmioc.h>
14#include <linux/atm.h>
15#include <linux/if_ether.h>
16/* ATM lec daemon control socket */
17#define ATMLEC_CTRL _IO('a',ATMIOC_LANE)
18#define ATMLEC_DATA _IO('a',ATMIOC_LANE+1)
19#define ATMLEC_MCAST _IO('a',ATMIOC_LANE+2)
20
21/* Maximum number of LEC interfaces (tweakable) */
22#define MAX_LEC_ITF 48
23
24/* From the total of MAX_LEC_ITF, last NUM_TR_DEVS are reserved for Token Ring.
25 * E.g. if MAX_LEC_ITF = 48 and NUM_TR_DEVS = 8, then lec0-lec39 are for
26 * Ethernet ELANs and lec40-lec47 are for Token Ring ELANS.
27 */
28#define NUM_TR_DEVS 8
29
30typedef enum {
31 l_set_mac_addr, l_del_mac_addr,
32 l_svc_setup,
33 l_addr_delete, l_topology_change,
34 l_flush_complete, l_arp_update,
35 l_narp_req, /* LANE2 mandates the use of this */
36 l_config, l_flush_tran_id,
37 l_set_lecid, l_arp_xmt,
38 l_rdesc_arp_xmt,
39 l_associate_req,
40 l_should_bridge /* should we bridge this MAC? */
41} atmlec_msg_type;
42
43#define ATMLEC_MSG_TYPE_MAX l_should_bridge
44
45struct atmlec_config_msg {
46 unsigned int maximum_unknown_frame_count;
47 unsigned int max_unknown_frame_time;
48 unsigned short max_retry_count;
49 unsigned int aging_time;
50 unsigned int forward_delay_time;
51 unsigned int arp_response_time;
52 unsigned int flush_timeout;
53 unsigned int path_switching_delay;
54 unsigned int lane_version; /* LANE2: 1 for LANEv1, 2 for LANEv2 */
55 int mtu;
56 int is_proxy;
57};
58
59struct atmlec_msg {
60 atmlec_msg_type type;
61 int sizeoftlvs; /* LANE2: if != 0, tlvs follow */
62 union {
63 struct {
64 unsigned char mac_addr[ETH_ALEN];
65 unsigned char atm_addr[ATM_ESA_LEN];
66 unsigned int flag;/* Topology_change flag,
67 remoteflag, permanent flag,
68 lecid, transaction id */
69 unsigned int targetless_le_arp; /* LANE2 */
70 unsigned int no_source_le_narp; /* LANE2 */
71 } normal;
72 struct atmlec_config_msg config;
73 struct {
74 uint16_t lec_id; /* requestor lec_id */
75 uint32_t tran_id; /* transaction id */
76 unsigned char mac_addr[ETH_ALEN]; /* dst mac addr */
77 unsigned char atm_addr[ATM_ESA_LEN]; /* reqestor ATM addr */
78 } proxy;
79 /* For mapping LE_ARP requests to responses. Filled by */
80 } content; /* zeppelin, returned by kernel. Used only when proxying */
81} __ATM_API_ALIGN;
82
83struct atmlec_ioc {
84 int dev_num;
85 unsigned char atm_addr[ATM_ESA_LEN];
86 unsigned char receive; /* 1= receive vcc, 0 = send vcc */
87};
88#endif /* _ATMLEC_H_ */
diff --git a/include/linux/atmmpc.h b/include/linux/atmmpc.h
new file mode 100644
index 000000000000..5fbfa68136d3
--- /dev/null
+++ b/include/linux/atmmpc.h
@@ -0,0 +1,125 @@
1#ifndef _ATMMPC_H_
2#define _ATMMPC_H_
3
4#include <linux/atmapi.h>
5#include <linux/atmioc.h>
6#include <linux/atm.h>
7
8#define ATMMPC_CTRL _IO('a', ATMIOC_MPOA)
9#define ATMMPC_DATA _IO('a', ATMIOC_MPOA+1)
10
11#define MPC_SOCKET_INGRESS 1
12#define MPC_SOCKET_EGRESS 2
13
14struct atmmpc_ioc {
15 int dev_num;
16 uint32_t ipaddr; /* the IP address of the shortcut */
17 int type; /* ingress or egress */
18};
19
20typedef struct in_ctrl_info {
21 uint8_t Last_NHRP_CIE_code;
22 uint8_t Last_Q2931_cause_value;
23 uint8_t eg_MPC_ATM_addr[ATM_ESA_LEN];
24 uint32_t tag;
25 uint32_t in_dst_ip; /* IP address this ingress MPC sends packets to */
26 uint16_t holding_time;
27 uint32_t request_id;
28} in_ctrl_info;
29
30typedef struct eg_ctrl_info {
31 uint8_t DLL_header[256];
32 uint8_t DH_length;
33 uint32_t cache_id;
34 uint32_t tag;
35 uint32_t mps_ip;
36 uint32_t eg_dst_ip; /* IP address to which ingress MPC sends packets */
37 uint8_t in_MPC_data_ATM_addr[ATM_ESA_LEN];
38 uint16_t holding_time;
39} eg_ctrl_info;
40
41struct mpc_parameters {
42 uint16_t mpc_p1; /* Shortcut-Setup Frame Count */
43 uint16_t mpc_p2; /* Shortcut-Setup Frame Time */
44 uint8_t mpc_p3[8]; /* Flow-detection Protocols */
45 uint16_t mpc_p4; /* MPC Initial Retry Time */
46 uint16_t mpc_p5; /* MPC Retry Time Maximum */
47 uint16_t mpc_p6; /* Hold Down Time */
48} ;
49
50struct k_message {
51 uint16_t type;
52 uint32_t ip_mask;
53 uint8_t MPS_ctrl[ATM_ESA_LEN];
54 union {
55 in_ctrl_info in_info;
56 eg_ctrl_info eg_info;
57 struct mpc_parameters params;
58 } content;
59 struct atm_qos qos;
60} __ATM_API_ALIGN;
61
62struct llc_snap_hdr {
63 /* RFC 1483 LLC/SNAP encapsulation for routed IP PDUs */
64 uint8_t dsap; /* Destination Service Access Point (0xAA) */
65 uint8_t ssap; /* Source Service Access Point (0xAA) */
66 uint8_t ui; /* Unnumbered Information (0x03) */
67 uint8_t org[3]; /* Organizational identification (0x000000) */
68 uint8_t type[2]; /* Ether type (for IP) (0x0800) */
69};
70
71/* TLVs this MPC recognizes */
72#define TLV_MPOA_DEVICE_TYPE 0x00a03e2a
73
74/* MPOA device types in MPOA Device Type TLV */
75#define NON_MPOA 0
76#define MPS 1
77#define MPC 2
78#define MPS_AND_MPC 3
79
80
81/* MPC parameter defaults */
82
83#define MPC_P1 10 /* Shortcut-Setup Frame Count */
84#define MPC_P2 1 /* Shortcut-Setup Frame Time */
85#define MPC_P3 0 /* Flow-detection Protocols */
86#define MPC_P4 5 /* MPC Initial Retry Time */
87#define MPC_P5 40 /* MPC Retry Time Maximum */
88#define MPC_P6 160 /* Hold Down Time */
89#define HOLDING_TIME_DEFAULT 1200 /* same as MPS-p7 */
90
91/* MPC constants */
92
93#define MPC_C1 2 /* Retry Time Multiplier */
94#define MPC_C2 60 /* Initial Keep-Alive Lifetime */
95
96/* Message types - to MPOA daemon */
97
98#define SND_MPOA_RES_RQST 201
99#define SET_MPS_CTRL_ADDR 202
100#define SND_MPOA_RES_RTRY 203 /* Different type in a retry due to req id */
101#define STOP_KEEP_ALIVE_SM 204
102#define EGRESS_ENTRY_REMOVED 205
103#define SND_EGRESS_PURGE 206
104#define DIE 207 /* tell the daemon to exit() */
105#define DATA_PLANE_PURGE 208 /* Data plane purge because of egress cache hit miss or dead MPS */
106#define OPEN_INGRESS_SVC 209
107
108/* Message types - from MPOA daemon */
109
110#define MPOA_TRIGGER_RCVD 101
111#define MPOA_RES_REPLY_RCVD 102
112#define INGRESS_PURGE_RCVD 103
113#define EGRESS_PURGE_RCVD 104
114#define MPS_DEATH 105
115#define CACHE_IMPOS_RCVD 106
116#define SET_MPC_CTRL_ADDR 107 /* Our MPC's control ATM address */
117#define SET_MPS_MAC_ADDR 108
118#define CLEAN_UP_AND_EXIT 109
119#define SET_MPC_PARAMS 110 /* MPC configuration parameters */
120
121/* Message types - bidirectional */
122
123#define RELOAD 301 /* kill -HUP the daemon for reload */
124
125#endif /* _ATMMPC_H_ */
diff --git a/include/linux/atmppp.h b/include/linux/atmppp.h
new file mode 100644
index 000000000000..300dcce0c83f
--- /dev/null
+++ b/include/linux/atmppp.h
@@ -0,0 +1,24 @@
1/* atmppp.h - RFC2364 PPPoATM */
2
3/* Written 2000 by Mitchell Blank Jr */
4
5#ifndef _LINUX_ATMPPP_H
6#define _LINUX_ATMPPP_H
7
8#include <linux/atm.h>
9
10#define PPPOATM_ENCAPS_AUTODETECT (0)
11#define PPPOATM_ENCAPS_VC (1)
12#define PPPOATM_ENCAPS_LLC (2)
13
14/*
15 * This is for the ATM_SETBACKEND call - these are like socket families:
16 * the first element of the structure is the backend number and the rest
17 * is per-backend specific
18 */
19struct atm_backend_ppp {
20 atm_backend_t backend_num; /* ATM_BACKEND_PPP */
21 int encaps; /* PPPOATM_ENCAPS_* */
22};
23
24#endif /* _LINUX_ATMPPP_H */
diff --git a/include/linux/atmsap.h b/include/linux/atmsap.h
new file mode 100644
index 000000000000..799b104515d7
--- /dev/null
+++ b/include/linux/atmsap.h
@@ -0,0 +1,162 @@
1/* atmsap.h - ATM Service Access Point addressing definitions */
2
3/* Written 1995-1999 by Werner Almesberger, EPFL LRC/ICA */
4
5
6#ifndef _LINUX_ATMSAP_H
7#define _LINUX_ATMSAP_H
8
9#include <linux/atmapi.h>
10
11/*
12 * BEGIN_xx and END_xx markers are used for automatic generation of
13 * documentation. Do not change them.
14 */
15
16
17/*
18 * Layer 2 protocol identifiers
19 */
20
21/* BEGIN_L2 */
22#define ATM_L2_NONE 0 /* L2 not specified */
23#define ATM_L2_ISO1745 0x01 /* Basic mode ISO 1745 */
24#define ATM_L2_Q291 0x02 /* ITU-T Q.291 (Rec. I.441) */
25#define ATM_L2_X25_LL 0x06 /* ITU-T X.25, link layer */
26#define ATM_L2_X25_ML 0x07 /* ITU-T X.25, multilink */
27#define ATM_L2_LAPB 0x08 /* Extended LAPB, half-duplex (Rec. T.71) */
28#define ATM_L2_HDLC_ARM 0x09 /* HDLC ARM (ISO/IEC 4335) */
29#define ATM_L2_HDLC_NRM 0x0a /* HDLC NRM (ISO/IEC 4335) */
30#define ATM_L2_HDLC_ABM 0x0b /* HDLC ABM (ISO/IEC 4335) */
31#define ATM_L2_ISO8802 0x0c /* LAN LLC (ISO/IEC 8802/2) */
32#define ATM_L2_X75 0x0d /* ITU-T X.75, SLP */
33#define ATM_L2_Q922 0x0e /* ITU-T Q.922 */
34#define ATM_L2_USER 0x10 /* user-specified */
35#define ATM_L2_ISO7776 0x11 /* ISO 7776 DTE-DTE */
36/* END_L2 */
37
38
39/*
40 * Layer 3 protocol identifiers
41 */
42
43/* BEGIN_L3 */
44#define ATM_L3_NONE 0 /* L3 not specified */
45#define ATM_L3_X25 0x06 /* ITU-T X.25, packet layer */
46#define ATM_L3_ISO8208 0x07 /* ISO/IEC 8208 */
47#define ATM_L3_X223 0x08 /* ITU-T X.223 | ISO/IEC 8878 */
48#define ATM_L3_ISO8473 0x09 /* ITU-T X.233 | ISO/IEC 8473 */
49#define ATM_L3_T70 0x0a /* ITU-T T.70 minimum network layer */
50#define ATM_L3_TR9577 0x0b /* ISO/IEC TR 9577 */
51#define ATM_L3_H310 0x0c /* ITU-T Recommendation H.310 */
52#define ATM_L3_H321 0x0d /* ITU-T Recommendation H.321 */
53#define ATM_L3_USER 0x10 /* user-specified */
54/* END_L3 */
55
56
57/*
58 * High layer identifiers
59 */
60
61/* BEGIN_HL */
62#define ATM_HL_NONE 0 /* HL not specified */
63#define ATM_HL_ISO 0x01 /* ISO */
64#define ATM_HL_USER 0x02 /* user-specific */
65#define ATM_HL_HLP 0x03 /* high layer profile - UNI 3.0 only */
66#define ATM_HL_VENDOR 0x04 /* vendor-specific application identifier */
67/* END_HL */
68
69
70/*
71 * ITU-T coded mode of operation
72 */
73
74/* BEGIN_IMD */
75#define ATM_IMD_NONE 0 /* mode not specified */
76#define ATM_IMD_NORMAL 1 /* normal mode of operation */
77#define ATM_IMD_EXTENDED 2 /* extended mode of operation */
78/* END_IMD */
79
80/*
81 * H.310 code points
82 */
83
84#define ATM_TT_NONE 0 /* terminal type not specified */
85#define ATM_TT_RX 1 /* receive only */
86#define ATM_TT_TX 2 /* send only */
87#define ATM_TT_RXTX 3 /* receive and send */
88
89#define ATM_MC_NONE 0 /* no multiplexing */
90#define ATM_MC_TS 1 /* transport stream (TS) */
91#define ATM_MC_TS_FEC 2 /* transport stream with forward error corr. */
92#define ATM_MC_PS 3 /* program stream (PS) */
93#define ATM_MC_PS_FEC 4 /* program stream with forward error corr. */
94#define ATM_MC_H221 5 /* ITU-T Rec. H.221 */
95
96/*
97 * SAP structures
98 */
99
100#define ATM_MAX_HLI 8 /* maximum high-layer information length */
101
102
103struct atm_blli {
104 unsigned char l2_proto; /* layer 2 protocol */
105 union {
106 struct {
107 unsigned char mode; /* mode of operation (ATM_IMD_xxx), 0 if */
108 /* absent */
109 unsigned char window; /* window size (k), 1-127 (0 to omit) */
110 } itu; /* ITU-T encoding */
111 unsigned char user; /* user-specified l2 information */
112 } l2;
113 unsigned char l3_proto; /* layer 3 protocol */
114 union {
115 struct {
116 unsigned char mode; /* mode of operation (ATM_IMD_xxx), 0 if */
117 /* absent */
118 unsigned char def_size; /* default packet size (log2), 4-12 (0 to */
119 /* omit) */
120 unsigned char window;/* packet window size, 1-127 (0 to omit) */
121 } itu; /* ITU-T encoding */
122 unsigned char user; /* user specified l3 information */
123 struct { /* if l3_proto = ATM_L3_H310 */
124 unsigned char term_type; /* terminal type */
125 unsigned char fw_mpx_cap; /* forward multiplexing capability */
126 /* only if term_type != ATM_TT_NONE */
127 unsigned char bw_mpx_cap; /* backward multiplexing capability */
128 /* only if term_type != ATM_TT_NONE */
129 } h310;
130 struct { /* if l3_proto = ATM_L3_TR9577 */
131 unsigned char ipi; /* initial protocol id */
132 unsigned char snap[5];/* IEEE 802.1 SNAP identifier */
133 /* (only if ipi == NLPID_IEEE802_1_SNAP) */
134 } tr9577;
135 } l3;
136} __ATM_API_ALIGN;
137
138
139struct atm_bhli {
140 unsigned char hl_type; /* high layer information type */
141 unsigned char hl_length; /* length (only if hl_type == ATM_HL_USER || */
142 /* hl_type == ATM_HL_ISO) */
143 unsigned char hl_info[ATM_MAX_HLI];/* high layer information */
144};
145
146
147#define ATM_MAX_BLLI 3 /* maximum number of BLLI elements */
148
149
150struct atm_sap {
151 struct atm_bhli bhli; /* local SAP, high-layer information */
152 struct atm_blli blli[ATM_MAX_BLLI] __ATM_API_ALIGN;
153 /* local SAP, low-layer info */
154};
155
156
157static __inline__ int blli_in_use(struct atm_blli blli)
158{
159 return blli.l2_proto || blli.l3_proto;
160}
161
162#endif
diff --git a/include/linux/atmsvc.h b/include/linux/atmsvc.h
new file mode 100644
index 000000000000..aa71583b8da7
--- /dev/null
+++ b/include/linux/atmsvc.h
@@ -0,0 +1,55 @@
1/* atmsvc.h - ATM signaling kernel-demon interface definitions */
2
3/* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */
4
5
6#ifndef _LINUX_ATMSVC_H
7#define _LINUX_ATMSVC_H
8
9#include <linux/atmapi.h>
10#include <linux/atm.h>
11#include <linux/atmioc.h>
12
13
14#define ATMSIGD_CTRL _IO('a',ATMIOC_SPECIAL)
15 /* become ATM signaling demon control socket */
16
17enum atmsvc_msg_type { as_catch_null, as_bind, as_connect, as_accept, as_reject,
18 as_listen, as_okay, as_error, as_indicate, as_close,
19 as_itf_notify, as_modify, as_identify, as_terminate,
20 as_addparty, as_dropparty };
21
22struct atmsvc_msg {
23 enum atmsvc_msg_type type;
24 atm_kptr_t vcc;
25 atm_kptr_t listen_vcc; /* indicate */
26 int reply; /* for okay and close: */
27 /* < 0: error before active */
28 /* (sigd has discarded ctx) */
29 /* ==0: success */
30 /* > 0: error when active (still */
31 /* need to close) */
32 struct sockaddr_atmpvc pvc; /* indicate, okay (connect) */
33 struct sockaddr_atmsvc local; /* local SVC address */
34 struct atm_qos qos; /* QOS parameters */
35 struct atm_sap sap; /* SAP */
36 unsigned int session; /* for p2pm */
37 struct sockaddr_atmsvc svc; /* SVC address */
38} __ATM_API_ALIGN;
39
40/*
41 * Message contents: see ftp://icaftp.epfl.ch/pub/linux/atm/docs/isp-*.tar.gz
42 */
43
44/*
45 * Some policy stuff for atmsigd and for net/atm/svc.c. Both have to agree on
46 * what PCR is used to request bandwidth from the device driver. net/atm/svc.c
47 * tries to do better than that, but only if there's no routing decision (i.e.
48 * if signaling only uses one ATM interface).
49 */
50
51#define SELECT_TOP_PCR(tp) ((tp).pcr ? (tp).pcr : \
52 (tp).max_pcr && (tp).max_pcr != ATM_MAX_PCR ? (tp).max_pcr : \
53 (tp).min_pcr ? (tp).min_pcr : ATM_MAX_PCR)
54
55#endif
diff --git a/include/linux/attribute_container.h b/include/linux/attribute_container.h
new file mode 100644
index 000000000000..af1010b6dab7
--- /dev/null
+++ b/include/linux/attribute_container.h
@@ -0,0 +1,73 @@
1/*
2 * class_container.h - a generic container for all classes
3 *
4 * Copyright (c) 2005 - James Bottomley <James.Bottomley@steeleye.com>
5 *
6 * This file is licensed under GPLv2
7 */
8
9#ifndef _ATTRIBUTE_CONTAINER_H_
10#define _ATTRIBUTE_CONTAINER_H_
11
12#include <linux/device.h>
13#include <linux/list.h>
14
15struct attribute_container {
16 struct list_head node;
17 struct list_head containers;
18 struct class *class;
19 struct class_device_attribute **attrs;
20 int (*match)(struct attribute_container *, struct device *);
21#define ATTRIBUTE_CONTAINER_NO_CLASSDEVS 0x01
22 unsigned long flags;
23};
24
25static inline int
26attribute_container_no_classdevs(struct attribute_container *atc)
27{
28 return atc->flags & ATTRIBUTE_CONTAINER_NO_CLASSDEVS;
29}
30
31static inline void
32attribute_container_set_no_classdevs(struct attribute_container *atc)
33{
34 atc->flags |= ATTRIBUTE_CONTAINER_NO_CLASSDEVS;
35}
36
37int attribute_container_register(struct attribute_container *cont);
38int attribute_container_unregister(struct attribute_container *cont);
39void attribute_container_create_device(struct device *dev,
40 int (*fn)(struct attribute_container *,
41 struct device *,
42 struct class_device *));
43void attribute_container_add_device(struct device *dev,
44 int (*fn)(struct attribute_container *,
45 struct device *,
46 struct class_device *));
47void attribute_container_remove_device(struct device *dev,
48 void (*fn)(struct attribute_container *,
49 struct device *,
50 struct class_device *));
51void attribute_container_device_trigger(struct device *dev,
52 int (*fn)(struct attribute_container *,
53 struct device *,
54 struct class_device *));
55void attribute_container_trigger(struct device *dev,
56 int (*fn)(struct attribute_container *,
57 struct device *));
58int attribute_container_add_attrs(struct class_device *classdev);
59int attribute_container_add_class_device(struct class_device *classdev);
60int attribute_container_add_class_device_adapter(struct attribute_container *cont,
61 struct device *dev,
62 struct class_device *classdev);
63void attribute_container_remove_attrs(struct class_device *classdev);
64void attribute_container_class_device_del(struct class_device *classdev);
65
66
67
68
69
70
71struct class_device_attribute **attribute_container_classdev_to_attrs(const struct class_device *classdev);
72
73#endif
diff --git a/include/linux/audit.h b/include/linux/audit.h
new file mode 100644
index 000000000000..3628f7cfb178
--- /dev/null
+++ b/include/linux/audit.h
@@ -0,0 +1,196 @@
1/* audit.h -- Auditing support -*- linux-c -*-
2 *
3 * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina.
4 * All Rights Reserved.
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 * Written by Rickard E. (Rik) Faith <faith@redhat.com>
21 *
22 */
23
24#ifndef _LINUX_AUDIT_H_
25#define _LINUX_AUDIT_H_
26
27/* Request and reply types */
28#define AUDIT_GET 1000 /* Get status */
29#define AUDIT_SET 1001 /* Set status (enable/disable/auditd) */
30#define AUDIT_LIST 1002 /* List filtering rules */
31#define AUDIT_ADD 1003 /* Add filtering rule */
32#define AUDIT_DEL 1004 /* Delete filtering rule */
33#define AUDIT_USER 1005 /* Send a message from user-space */
34#define AUDIT_LOGIN 1006 /* Define the login id and informaiton */
35#define AUDIT_KERNEL 2000 /* Asynchronous audit record. NOT A REQUEST. */
36
37/* Rule flags */
38#define AUDIT_PER_TASK 0x01 /* Apply rule at task creation (not syscall) */
39#define AUDIT_AT_ENTRY 0x02 /* Apply rule at syscall entry */
40#define AUDIT_AT_EXIT 0x04 /* Apply rule at syscall exit */
41#define AUDIT_PREPEND 0x10 /* Prepend to front of list */
42
43/* Rule actions */
44#define AUDIT_NEVER 0 /* Do not build context if rule matches */
45#define AUDIT_POSSIBLE 1 /* Build context if rule matches */
46#define AUDIT_ALWAYS 2 /* Generate audit record if rule matches */
47
48/* Rule structure sizes -- if these change, different AUDIT_ADD and
49 * AUDIT_LIST commands must be implemented. */
50#define AUDIT_MAX_FIELDS 64
51#define AUDIT_BITMASK_SIZE 64
52#define AUDIT_WORD(nr) ((__u32)((nr)/32))
53#define AUDIT_BIT(nr) (1 << ((nr) - AUDIT_WORD(nr)*32))
54
55/* Rule fields */
56 /* These are useful when checking the
57 * task structure at task creation time
58 * (AUDIT_PER_TASK). */
59#define AUDIT_PID 0
60#define AUDIT_UID 1
61#define AUDIT_EUID 2
62#define AUDIT_SUID 3
63#define AUDIT_FSUID 4
64#define AUDIT_GID 5
65#define AUDIT_EGID 6
66#define AUDIT_SGID 7
67#define AUDIT_FSGID 8
68#define AUDIT_LOGINUID 9
69#define AUDIT_PERS 10
70
71 /* These are ONLY useful when checking
72 * at syscall exit time (AUDIT_AT_EXIT). */
73#define AUDIT_DEVMAJOR 100
74#define AUDIT_DEVMINOR 101
75#define AUDIT_INODE 102
76#define AUDIT_EXIT 103
77#define AUDIT_SUCCESS 104 /* exit >= 0; value ignored */
78
79#define AUDIT_ARG0 200
80#define AUDIT_ARG1 (AUDIT_ARG0+1)
81#define AUDIT_ARG2 (AUDIT_ARG0+2)
82#define AUDIT_ARG3 (AUDIT_ARG0+3)
83
84#define AUDIT_NEGATE 0x80000000
85
86
87/* Status symbols */
88 /* Mask values */
89#define AUDIT_STATUS_ENABLED 0x0001
90#define AUDIT_STATUS_FAILURE 0x0002
91#define AUDIT_STATUS_PID 0x0004
92#define AUDIT_STATUS_RATE_LIMIT 0x0008
93#define AUDIT_STATUS_BACKLOG_LIMIT 0x0010
94 /* Failure-to-log actions */
95#define AUDIT_FAIL_SILENT 0
96#define AUDIT_FAIL_PRINTK 1
97#define AUDIT_FAIL_PANIC 2
98
99#ifndef __KERNEL__
100struct audit_message {
101 struct nlmsghdr nlh;
102 char data[1200];
103};
104#endif
105
106struct audit_status {
107 __u32 mask; /* Bit mask for valid entries */
108 __u32 enabled; /* 1 = enabled, 0 = disbaled */
109 __u32 failure; /* Failure-to-log action */
110 __u32 pid; /* pid of auditd process */
111 __u32 rate_limit; /* messages rate limit (per second) */
112 __u32 backlog_limit; /* waiting messages limit */
113 __u32 lost; /* messages lost */
114 __u32 backlog; /* messages waiting in queue */
115};
116
117struct audit_rule { /* for AUDIT_LIST, AUDIT_ADD, and AUDIT_DEL */
118 __u32 flags; /* AUDIT_PER_{TASK,CALL}, AUDIT_PREPEND */
119 __u32 action; /* AUDIT_NEVER, AUDIT_POSSIBLE, AUDIT_ALWAYS */
120 __u32 field_count;
121 __u32 mask[AUDIT_BITMASK_SIZE];
122 __u32 fields[AUDIT_MAX_FIELDS];
123 __u32 values[AUDIT_MAX_FIELDS];
124};
125
126#ifdef __KERNEL__
127
128struct audit_buffer;
129struct audit_context;
130struct inode;
131
132#ifdef CONFIG_AUDITSYSCALL
133/* These are defined in auditsc.c */
134 /* Public API */
135extern int audit_alloc(struct task_struct *task);
136extern void audit_free(struct task_struct *task);
137extern void audit_syscall_entry(struct task_struct *task,
138 int major, unsigned long a0, unsigned long a1,
139 unsigned long a2, unsigned long a3);
140extern void audit_syscall_exit(struct task_struct *task, int return_code);
141extern void audit_getname(const char *name);
142extern void audit_putname(const char *name);
143extern void audit_inode(const char *name, const struct inode *inode);
144
145 /* Private API (for audit.c only) */
146extern int audit_receive_filter(int type, int pid, int uid, int seq,
147 void *data);
148extern void audit_get_stamp(struct audit_context *ctx,
149 struct timespec *t, int *serial);
150extern int audit_set_loginuid(struct audit_context *ctx, uid_t loginuid);
151extern uid_t audit_get_loginuid(struct audit_context *ctx);
152extern int audit_ipc_perms(unsigned long qbytes, uid_t uid, gid_t gid, mode_t mode);
153#else
154#define audit_alloc(t) ({ 0; })
155#define audit_free(t) do { ; } while (0)
156#define audit_syscall_entry(t,a,b,c,d,e) do { ; } while (0)
157#define audit_syscall_exit(t,r) do { ; } while (0)
158#define audit_getname(n) do { ; } while (0)
159#define audit_putname(n) do { ; } while (0)
160#define audit_inode(n,i) do { ; } while (0)
161#define audit_get_loginuid(c) ({ -1; })
162#define audit_ipc_perms(q,u,g,m) ({ 0; })
163#endif
164
165#ifdef CONFIG_AUDIT
166/* These are defined in audit.c */
167 /* Public API */
168extern void audit_log(struct audit_context *ctx,
169 const char *fmt, ...)
170 __attribute__((format(printf,2,3)));
171
172extern struct audit_buffer *audit_log_start(struct audit_context *ctx);
173extern void audit_log_format(struct audit_buffer *ab,
174 const char *fmt, ...)
175 __attribute__((format(printf,2,3)));
176extern void audit_log_end(struct audit_buffer *ab);
177extern void audit_log_d_path(struct audit_buffer *ab,
178 const char *prefix,
179 struct dentry *dentry,
180 struct vfsmount *vfsmnt);
181
182 /* Private API (for auditsc.c only) */
183extern void audit_send_reply(int pid, int seq, int type,
184 int done, int multi,
185 void *payload, int size);
186extern void audit_log_lost(const char *message);
187#else
188#define audit_log(t,f,...) do { ; } while (0)
189#define audit_log_start(t) ({ NULL; })
190#define audit_log_vformat(b,f,a) do { ; } while (0)
191#define audit_log_format(b,f,...) do { ; } while (0)
192#define audit_log_end(b) do { ; } while (0)
193#define audit_log_d_path(b,p,d,v) do { ; } while (0)
194#endif
195#endif
196#endif
diff --git a/include/linux/auto_fs.h b/include/linux/auto_fs.h
new file mode 100644
index 000000000000..c21e5972a3e8
--- /dev/null
+++ b/include/linux/auto_fs.h
@@ -0,0 +1,84 @@
1/* -*- linux-c -*- ------------------------------------------------------- *
2 *
3 * linux/include/linux/auto_fs.h
4 *
5 * Copyright 1997 Transmeta Corporation - All Rights Reserved
6 *
7 * This file is part of the Linux kernel and is made available under
8 * the terms of the GNU General Public License, version 2, or at your
9 * option, any later version, incorporated herein by reference.
10 *
11 * ----------------------------------------------------------------------- */
12
13
14#ifndef _LINUX_AUTO_FS_H
15#define _LINUX_AUTO_FS_H
16
17#ifdef __KERNEL__
18#include <linux/fs.h>
19#include <linux/limits.h>
20#include <asm/types.h>
21#endif /* __KERNEL__ */
22
23#include <linux/ioctl.h>
24
25/* This file describes autofs v3 */
26#define AUTOFS_PROTO_VERSION 3
27
28/* Range of protocol versions defined */
29#define AUTOFS_MAX_PROTO_VERSION AUTOFS_PROTO_VERSION
30#define AUTOFS_MIN_PROTO_VERSION AUTOFS_PROTO_VERSION
31
32/*
33 * Architectures where both 32- and 64-bit binaries can be executed
34 * on 64-bit kernels need this. This keeps the structure format
35 * uniform, and makes sure the wait_queue_token isn't too big to be
36 * passed back down to the kernel.
37 *
38 * This assumes that on these architectures:
39 * mode 32 bit 64 bit
40 * -------------------------
41 * int 32 bit 32 bit
42 * long 32 bit 64 bit
43 *
44 * If so, 32-bit user-space code should be backwards compatible.
45 */
46
47#if defined(__sparc__) || defined(__mips__) || defined(__x86_64__) \
48 || defined(__powerpc__) || defined(__s390__)
49typedef unsigned int autofs_wqt_t;
50#else
51typedef unsigned long autofs_wqt_t;
52#endif
53
54/* Packet types */
55#define autofs_ptype_missing 0 /* Missing entry (mount request) */
56#define autofs_ptype_expire 1 /* Expire entry (umount request) */
57
58struct autofs_packet_hdr {
59 int proto_version; /* Protocol version */
60 int type; /* Type of packet */
61};
62
63struct autofs_packet_missing {
64 struct autofs_packet_hdr hdr;
65 autofs_wqt_t wait_queue_token;
66 int len;
67 char name[NAME_MAX+1];
68};
69
70/* v3 expire (via ioctl) */
71struct autofs_packet_expire {
72 struct autofs_packet_hdr hdr;
73 int len;
74 char name[NAME_MAX+1];
75};
76
77#define AUTOFS_IOC_READY _IO(0x93,0x60)
78#define AUTOFS_IOC_FAIL _IO(0x93,0x61)
79#define AUTOFS_IOC_CATATONIC _IO(0x93,0x62)
80#define AUTOFS_IOC_PROTOVER _IOR(0x93,0x63,int)
81#define AUTOFS_IOC_SETTIMEOUT _IOWR(0x93,0x64,unsigned long)
82#define AUTOFS_IOC_EXPIRE _IOR(0x93,0x65,struct autofs_packet_expire)
83
84#endif /* _LINUX_AUTO_FS_H */
diff --git a/include/linux/auto_fs4.h b/include/linux/auto_fs4.h
new file mode 100644
index 000000000000..d1c7b0ec7c22
--- /dev/null
+++ b/include/linux/auto_fs4.h
@@ -0,0 +1,57 @@
1/* -*- c -*-
2 * linux/include/linux/auto_fs4.h
3 *
4 * Copyright 1999-2000 Jeremy Fitzhardinge <jeremy@goop.org>
5 *
6 * This file is part of the Linux kernel and is made available under
7 * the terms of the GNU General Public License, version 2, or at your
8 * option, any later version, incorporated herein by reference.
9 */
10
11#ifndef _LINUX_AUTO_FS4_H
12#define _LINUX_AUTO_FS4_H
13
14/* Include common v3 definitions */
15#include <linux/auto_fs.h>
16
17/* autofs v4 definitions */
18#undef AUTOFS_PROTO_VERSION
19#undef AUTOFS_MIN_PROTO_VERSION
20#undef AUTOFS_MAX_PROTO_VERSION
21
22#define AUTOFS_PROTO_VERSION 4
23#define AUTOFS_MIN_PROTO_VERSION 3
24#define AUTOFS_MAX_PROTO_VERSION 4
25
26#define AUTOFS_PROTO_SUBVERSION 5
27
28/* Mask for expire behaviour */
29#define AUTOFS_EXP_IMMEDIATE 1
30#define AUTOFS_EXP_LEAVES 2
31
32/* New message type */
33#define autofs_ptype_expire_multi 2 /* Expire entry (umount request) */
34
35/* v4 multi expire (via pipe) */
36struct autofs_packet_expire_multi {
37 struct autofs_packet_hdr hdr;
38 autofs_wqt_t wait_queue_token;
39 int len;
40 char name[NAME_MAX+1];
41};
42
43union autofs_packet_union {
44 struct autofs_packet_hdr hdr;
45 struct autofs_packet_missing missing;
46 struct autofs_packet_expire expire;
47 struct autofs_packet_expire_multi expire_multi;
48};
49
50#define AUTOFS_IOC_EXPIRE_MULTI _IOW(0x93,0x66,int)
51#define AUTOFS_IOC_PROTOSUBVER _IOR(0x93,0x67,int)
52#define AUTOFS_IOC_ASKREGHOST _IOR(0x93,0x68,int)
53#define AUTOFS_IOC_TOGGLEREGHOST _IOR(0x93,0x69,int)
54#define AUTOFS_IOC_ASKUMOUNT _IOR(0x93,0x70,int)
55
56
57#endif /* _LINUX_AUTO_FS4_H */
diff --git a/include/linux/awe_voice.h b/include/linux/awe_voice.h
new file mode 100644
index 000000000000..da0e27de752c
--- /dev/null
+++ b/include/linux/awe_voice.h
@@ -0,0 +1,525 @@
1/*
2 * sound/awe_voice.h
3 *
4 * Voice information definitions for the low level driver for the
5 * AWE32/SB32/AWE64 wave table synth.
6 * version 0.4.4; Jan. 4, 2000
7 *
8 * Copyright (C) 1996-2000 Takashi Iwai
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., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */
24
25#ifndef AWE_VOICE_H
26#define AWE_VOICE_H
27
28#ifndef SAMPLE_TYPE_AWE32
29#define SAMPLE_TYPE_AWE32 0x20
30#endif
31
32#ifndef _PATCHKEY
33#define _PATCHKEY(id) ((id<<8)|0xfd)
34#endif
35
36/*----------------------------------------------------------------
37 * patch information record
38 *----------------------------------------------------------------*/
39
40/* patch interface header: 16 bytes */
41typedef struct awe_patch_info {
42 short key; /* use AWE_PATCH here */
43#define AWE_PATCH _PATCHKEY(0x07)
44
45 short device_no; /* synthesizer number */
46 unsigned short sf_id; /* file id (should be zero) */
47 short optarg; /* optional argument */
48 int len; /* data length (without this header) */
49
50 short type; /* patch operation type */
51#define AWE_LOAD_INFO 0 /* awe_voice_rec */
52#define AWE_LOAD_DATA 1 /* awe_sample_info */
53#define AWE_OPEN_PATCH 2 /* awe_open_parm */
54#define AWE_CLOSE_PATCH 3 /* none */
55#define AWE_UNLOAD_PATCH 4 /* none */
56#define AWE_REPLACE_DATA 5 /* awe_sample_info (optarg=#channels)*/
57#define AWE_MAP_PRESET 6 /* awe_voice_map */
58/*#define AWE_PROBE_INFO 7*/ /* awe_voice_map (pat only) */
59#define AWE_PROBE_DATA 8 /* optarg=sample */
60#define AWE_REMOVE_INFO 9 /* optarg=(bank<<8)|instr */
61#define AWE_LOAD_CHORUS_FX 0x10 /* awe_chorus_fx_rec (optarg=mode) */
62#define AWE_LOAD_REVERB_FX 0x11 /* awe_reverb_fx_rec (optarg=mode) */
63
64 short reserved; /* word alignment data */
65
66 /* the actual patch data begins after this */
67#if defined(AWE_COMPAT_030) && AWE_COMPAT_030
68 char data[0];
69#endif
70} awe_patch_info;
71
72/*#define AWE_PATCH_INFO_SIZE 16*/
73#define AWE_PATCH_INFO_SIZE sizeof(awe_patch_info)
74
75
76/*----------------------------------------------------------------
77 * open patch
78 *----------------------------------------------------------------*/
79
80#define AWE_PATCH_NAME_LEN 32
81
82typedef struct _awe_open_parm {
83 unsigned short type; /* sample type */
84#define AWE_PAT_TYPE_MISC 0
85#define AWE_PAT_TYPE_GM 1
86#define AWE_PAT_TYPE_GS 2
87#define AWE_PAT_TYPE_MT32 3
88#define AWE_PAT_TYPE_XG 4
89#define AWE_PAT_TYPE_SFX 5
90#define AWE_PAT_TYPE_GUS 6
91#define AWE_PAT_TYPE_MAP 7
92
93#define AWE_PAT_LOCKED 0x100 /* lock the samples */
94#define AWE_PAT_SHARED 0x200 /* sample is shared */
95
96 short reserved;
97 char name[AWE_PATCH_NAME_LEN];
98} awe_open_parm;
99
100/*#define AWE_OPEN_PARM_SIZE 28*/
101#define AWE_OPEN_PARM_SIZE sizeof(awe_open_parm)
102
103
104/*----------------------------------------------------------------
105 * raw voice information record
106 *----------------------------------------------------------------*/
107
108/* wave table envelope & effect parameters to control EMU8000 */
109typedef struct _awe_voice_parm {
110 unsigned short moddelay; /* modulation delay (0x8000) */
111 unsigned short modatkhld; /* modulation attack & hold time (0x7f7f) */
112 unsigned short moddcysus; /* modulation decay & sustain (0x7f7f) */
113 unsigned short modrelease; /* modulation release time (0x807f) */
114 short modkeyhold, modkeydecay; /* envelope change per key (not used) */
115 unsigned short voldelay; /* volume delay (0x8000) */
116 unsigned short volatkhld; /* volume attack & hold time (0x7f7f) */
117 unsigned short voldcysus; /* volume decay & sustain (0x7f7f) */
118 unsigned short volrelease; /* volume release time (0x807f) */
119 short volkeyhold, volkeydecay; /* envelope change per key (not used) */
120 unsigned short lfo1delay; /* LFO1 delay (0x8000) */
121 unsigned short lfo2delay; /* LFO2 delay (0x8000) */
122 unsigned short pefe; /* modulation pitch & cutoff (0x0000) */
123 unsigned short fmmod; /* LFO1 pitch & cutoff (0x0000) */
124 unsigned short tremfrq; /* LFO1 volume & freq (0x0000) */
125 unsigned short fm2frq2; /* LFO2 pitch & freq (0x0000) */
126 unsigned char cutoff; /* initial cutoff (0xff) */
127 unsigned char filterQ; /* initial filter Q [0-15] (0x0) */
128 unsigned char chorus; /* chorus send (0x00) */
129 unsigned char reverb; /* reverb send (0x00) */
130 unsigned short reserved[4]; /* not used */
131} awe_voice_parm;
132
133typedef struct _awe_voice_parm_block {
134 unsigned short moddelay; /* modulation delay (0x8000) */
135 unsigned char modatk, modhld;
136 unsigned char moddcy, modsus;
137 unsigned char modrel, moddummy;
138 short modkeyhold, modkeydecay; /* envelope change per key (not used) */
139 unsigned short voldelay; /* volume delay (0x8000) */
140 unsigned char volatk, volhld;
141 unsigned char voldcy, volsus;
142 unsigned char volrel, voldummy;
143 short volkeyhold, volkeydecay; /* envelope change per key (not used) */
144 unsigned short lfo1delay; /* LFO1 delay (0x8000) */
145 unsigned short lfo2delay; /* LFO2 delay (0x8000) */
146 unsigned char env1fc, env1pit;
147 unsigned char lfo1fc, lfo1pit;
148 unsigned char lfo1freq, lfo1vol;
149 unsigned char lfo2freq, lfo2pit;
150 unsigned char cutoff; /* initial cutoff (0xff) */
151 unsigned char filterQ; /* initial filter Q [0-15] (0x0) */
152 unsigned char chorus; /* chorus send (0x00) */
153 unsigned char reverb; /* reverb send (0x00) */
154 unsigned short reserved[4]; /* not used */
155} awe_voice_parm_block;
156
157#define AWE_VOICE_PARM_SIZE 48
158
159
160/* wave table parameters: 92 bytes */
161typedef struct _awe_voice_info {
162 unsigned short sf_id; /* file id (should be zero) */
163 unsigned short sample; /* sample id */
164 int start, end; /* sample offset correction */
165 int loopstart, loopend; /* loop offset correction */
166 short rate_offset; /* sample rate pitch offset */
167 unsigned short mode; /* sample mode */
168#define AWE_MODE_ROMSOUND 0x8000
169#define AWE_MODE_STEREO 1
170#define AWE_MODE_LOOPING 2
171#define AWE_MODE_NORELEASE 4 /* obsolete */
172#define AWE_MODE_INIT_PARM 8
173
174 short root; /* midi root key */
175 short tune; /* pitch tuning (in cents) */
176 signed char low, high; /* key note range */
177 signed char vellow, velhigh; /* velocity range */
178 signed char fixkey, fixvel; /* fixed key, velocity */
179 signed char pan, fixpan; /* panning, fixed panning */
180 short exclusiveClass; /* exclusive class (0 = none) */
181 unsigned char amplitude; /* sample volume (127 max) */
182 unsigned char attenuation; /* attenuation (0.375dB) */
183 short scaleTuning; /* pitch scale tuning(%), normally 100 */
184 awe_voice_parm parm; /* voice envelope parameters */
185 short index; /* internal index (set by driver) */
186} awe_voice_info;
187
188/*#define AWE_VOICE_INFO_SIZE 92*/
189#define AWE_VOICE_INFO_SIZE sizeof(awe_voice_info)
190
191/*----------------------------------------------------------------*/
192
193/* The info entry of awe_voice_rec is changed from 0 to 1
194 * for some compilers refusing zero size array.
195 * Due to this change, sizeof(awe_voice_rec) becomes different
196 * from older versions.
197 * Use AWE_VOICE_REC_SIZE instead.
198 */
199
200/* instrument info header: 4 bytes */
201typedef struct _awe_voice_rec_hdr {
202 unsigned char bank; /* midi bank number */
203 unsigned char instr; /* midi preset number */
204 char nvoices; /* number of voices */
205 char write_mode; /* write mode; normally 0 */
206#define AWE_WR_APPEND 0 /* append anyway */
207#define AWE_WR_EXCLUSIVE 1 /* skip if already exists */
208#define AWE_WR_REPLACE 2 /* replace if already exists */
209} awe_voice_rec_hdr;
210
211/*#define AWE_VOICE_REC_SIZE 4*/
212#define AWE_VOICE_REC_SIZE sizeof(awe_voice_rec_hdr)
213
214/* the standard patch structure for one sample */
215typedef struct _awe_voice_rec_patch {
216 awe_patch_info patch;
217 awe_voice_rec_hdr hdr;
218 awe_voice_info info;
219} awe_voice_rec_patch;
220
221
222/* obsolete data type */
223#if defined(AWE_COMPAT_030) && AWE_COMPAT_030
224#define AWE_INFOARRAY_SIZE 0
225#else
226#define AWE_INFOARRAY_SIZE 1
227#endif
228
229typedef struct _awe_voice_rec {
230 unsigned char bank; /* midi bank number */
231 unsigned char instr; /* midi preset number */
232 short nvoices; /* number of voices */
233 /* voice information follows here */
234 awe_voice_info info[AWE_INFOARRAY_SIZE];
235} awe_voice_rec;
236
237
238/*----------------------------------------------------------------
239 * sample wave information
240 *----------------------------------------------------------------*/
241
242/* wave table sample header: 32 bytes */
243typedef struct awe_sample_info {
244 unsigned short sf_id; /* file id (should be zero) */
245 unsigned short sample; /* sample id */
246 int start, end; /* start & end offset */
247 int loopstart, loopend; /* loop start & end offset */
248 int size; /* size (0 = ROM) */
249 short checksum_flag; /* use check sum = 1 */
250 unsigned short mode_flags; /* mode flags */
251#define AWE_SAMPLE_8BITS 1 /* wave data is 8bits */
252#define AWE_SAMPLE_UNSIGNED 2 /* wave data is unsigned */
253#define AWE_SAMPLE_NO_BLANK 4 /* no blank loop is attached */
254#define AWE_SAMPLE_SINGLESHOT 8 /* single-shot w/o loop */
255#define AWE_SAMPLE_BIDIR_LOOP 16 /* bidirectional looping */
256#define AWE_SAMPLE_STEREO_LEFT 32 /* stereo left sound */
257#define AWE_SAMPLE_STEREO_RIGHT 64 /* stereo right sound */
258#define AWE_SAMPLE_REVERSE_LOOP 128 /* reverse looping */
259 unsigned int checksum; /* check sum */
260#if defined(AWE_COMPAT_030) && AWE_COMPAT_030
261 unsigned short data[0]; /* sample data follows here */
262#endif
263} awe_sample_info;
264
265/*#define AWE_SAMPLE_INFO_SIZE 32*/
266#define AWE_SAMPLE_INFO_SIZE sizeof(awe_sample_info)
267
268
269/*----------------------------------------------------------------
270 * voice preset mapping
271 *----------------------------------------------------------------*/
272
273typedef struct awe_voice_map {
274 int map_bank, map_instr, map_key; /* key = -1 means all keys */
275 int src_bank, src_instr, src_key;
276} awe_voice_map;
277
278#define AWE_VOICE_MAP_SIZE sizeof(awe_voice_map)
279
280
281/*----------------------------------------------------------------
282 * awe hardware controls
283 *----------------------------------------------------------------*/
284
285#define _AWE_DEBUG_MODE 0x00
286#define _AWE_REVERB_MODE 0x01
287#define _AWE_CHORUS_MODE 0x02
288#define _AWE_REMOVE_LAST_SAMPLES 0x03
289#define _AWE_INITIALIZE_CHIP 0x04
290#define _AWE_SEND_EFFECT 0x05
291#define _AWE_TERMINATE_CHANNEL 0x06
292#define _AWE_TERMINATE_ALL 0x07
293#define _AWE_INITIAL_VOLUME 0x08
294#define _AWE_INITIAL_ATTEN _AWE_INITIAL_VOLUME
295#define _AWE_RESET_CHANNEL 0x09
296#define _AWE_CHANNEL_MODE 0x0a
297#define _AWE_DRUM_CHANNELS 0x0b
298#define _AWE_MISC_MODE 0x0c
299#define _AWE_RELEASE_ALL 0x0d
300#define _AWE_NOTEOFF_ALL 0x0e
301#define _AWE_CHN_PRESSURE 0x0f
302/*#define _AWE_GET_CURRENT_MODE 0x10*/
303#define _AWE_EQUALIZER 0x11
304/*#define _AWE_GET_MISC_MODE 0x12*/
305/*#define _AWE_GET_FONTINFO 0x13*/
306
307#define _AWE_MODE_FLAG 0x80
308#define _AWE_COOKED_FLAG 0x40 /* not supported */
309#define _AWE_MODE_VALUE_MASK 0x3F
310
311/*----------------------------------------------------------------*/
312
313#define _AWE_SET_CMD(p,dev,voice,cmd,p1,p2) \
314{((char*)(p))[0] = SEQ_PRIVATE;\
315 ((char*)(p))[1] = dev;\
316 ((char*)(p))[2] = _AWE_MODE_FLAG|(cmd);\
317 ((char*)(p))[3] = voice;\
318 ((unsigned short*)(p))[2] = p1;\
319 ((unsigned short*)(p))[3] = p2;}
320
321/* buffered access */
322#define _AWE_CMD(dev, voice, cmd, p1, p2) \
323{_SEQ_NEEDBUF(8);\
324 _AWE_SET_CMD(_seqbuf + _seqbufptr, dev, voice, cmd, p1, p2);\
325 _SEQ_ADVBUF(8);}
326
327/* direct access */
328#define _AWE_CMD_NOW(seqfd,dev,voice,cmd,p1,p2) \
329{struct seq_event_rec tmp;\
330 _AWE_SET_CMD(&tmp, dev, voice, cmd, p1, p2);\
331 ioctl(seqfd, SNDCTL_SEQ_OUTOFBAND, &tmp);}
332
333/*----------------------------------------------------------------*/
334
335/* set debugging mode */
336#define AWE_DEBUG_MODE(dev,p1) _AWE_CMD(dev, 0, _AWE_DEBUG_MODE, p1, 0)
337/* set reverb mode; from 0 to 7 */
338#define AWE_REVERB_MODE(dev,p1) _AWE_CMD(dev, 0, _AWE_REVERB_MODE, p1, 0)
339/* set chorus mode; from 0 to 7 */
340#define AWE_CHORUS_MODE(dev,p1) _AWE_CMD(dev, 0, _AWE_CHORUS_MODE, p1, 0)
341
342/* reset channel */
343#define AWE_RESET_CHANNEL(dev,ch) _AWE_CMD(dev, ch, _AWE_RESET_CHANNEL, 0, 0)
344#define AWE_RESET_CONTROL(dev,ch) _AWE_CMD(dev, ch, _AWE_RESET_CHANNEL, 1, 0)
345
346/* send an effect to all layers */
347#define AWE_SEND_EFFECT(dev,voice,type,value) _AWE_CMD(dev,voice,_AWE_SEND_EFFECT,type,value)
348#define AWE_ADD_EFFECT(dev,voice,type,value) _AWE_CMD(dev,voice,_AWE_SEND_EFFECT,((type)|0x80),value)
349#define AWE_UNSET_EFFECT(dev,voice,type) _AWE_CMD(dev,voice,_AWE_SEND_EFFECT,((type)|0x40),0)
350/* send an effect to a layer */
351#define AWE_SEND_LAYER_EFFECT(dev,voice,layer,type,value) _AWE_CMD(dev,voice,_AWE_SEND_EFFECT,((layer+1)<<8|(type)),value)
352#define AWE_ADD_LAYER_EFFECT(dev,voice,layer,type,value) _AWE_CMD(dev,voice,_AWE_SEND_EFFECT,((layer+1)<<8|(type)|0x80),value)
353#define AWE_UNSET_LAYER_EFFECT(dev,voice,layer,type) _AWE_CMD(dev,voice,_AWE_SEND_EFFECT,((layer+1)<<8|(type)|0x40),0)
354
355/* terminate sound on the channel/voice */
356#define AWE_TERMINATE_CHANNEL(dev,voice) _AWE_CMD(dev,voice,_AWE_TERMINATE_CHANNEL,0,0)
357/* terminate all sounds */
358#define AWE_TERMINATE_ALL(dev) _AWE_CMD(dev, 0, _AWE_TERMINATE_ALL, 0, 0)
359/* release all sounds (w/o sustain effect) */
360#define AWE_RELEASE_ALL(dev) _AWE_CMD(dev, 0, _AWE_RELEASE_ALL, 0, 0)
361/* note off all sounds (w sustain effect) */
362#define AWE_NOTEOFF_ALL(dev) _AWE_CMD(dev, 0, _AWE_NOTEOFF_ALL, 0, 0)
363
364/* set initial attenuation */
365#define AWE_INITIAL_VOLUME(dev,atten) _AWE_CMD(dev, 0, _AWE_INITIAL_VOLUME, atten, 0)
366#define AWE_INITIAL_ATTEN AWE_INITIAL_VOLUME
367/* relative attenuation */
368#define AWE_SET_ATTEN(dev,atten) _AWE_CMD(dev, 0, _AWE_INITIAL_VOLUME, atten, 1)
369
370/* set channel playing mode; mode=0/1/2 */
371#define AWE_SET_CHANNEL_MODE(dev,mode) _AWE_CMD(dev, 0, _AWE_CHANNEL_MODE, mode, 0)
372#define AWE_PLAY_INDIRECT 0 /* indirect voice mode (default) */
373#define AWE_PLAY_MULTI 1 /* multi note voice mode */
374#define AWE_PLAY_DIRECT 2 /* direct single voice mode */
375#define AWE_PLAY_MULTI2 3 /* sequencer2 mode; used internally */
376
377/* set drum channel mask; channels is 32bit long value */
378#define AWE_DRUM_CHANNELS(dev,channels) _AWE_CMD(dev, 0, _AWE_DRUM_CHANNELS, ((channels) & 0xffff), ((channels) >> 16))
379
380/* set bass and treble control; values are from 0 to 11 */
381#define AWE_EQUALIZER(dev,bass,treble) _AWE_CMD(dev, 0, _AWE_EQUALIZER, bass, treble)
382
383/* remove last loaded samples */
384#define AWE_REMOVE_LAST_SAMPLES(seqfd,dev) _AWE_CMD_NOW(seqfd, dev, 0, _AWE_REMOVE_LAST_SAMPLES, 0, 0)
385/* initialize emu8000 chip */
386#define AWE_INITIALIZE_CHIP(seqfd,dev) _AWE_CMD_NOW(seqfd, dev, 0, _AWE_INITIALIZE_CHIP, 0, 0)
387
388/* set miscellaneous modes; meta command */
389#define AWE_MISC_MODE(dev,mode,value) _AWE_CMD(dev, 0, _AWE_MISC_MODE, mode, value)
390/* exclusive sound off; 1=off */
391#define AWE_EXCLUSIVE_SOUND(dev,mode) AWE_MISC_MODE(dev,AWE_MD_EXCLUSIVE_SOUND,mode)
392/* default GUS bank number */
393#define AWE_SET_GUS_BANK(dev,bank) AWE_MISC_MODE(dev,AWE_MD_GUS_BANK,bank)
394/* change panning position in realtime; 0=don't 1=do */
395#define AWE_REALTIME_PAN(dev,mode) AWE_MISC_MODE(dev,AWE_MD_REALTIME_PAN,mode)
396
397/* extended pressure controls; not portable with other sound drivers */
398#define AWE_KEY_PRESSURE(dev,ch,note,vel) SEQ_START_NOTE(dev,ch,(note)+128,vel)
399#define AWE_CHN_PRESSURE(dev,ch,vel) _AWE_CMD(dev,ch,_AWE_CHN_PRESSURE,vel,0)
400
401/*----------------------------------------------------------------*/
402
403/* reverb mode parameters */
404#define AWE_REVERB_ROOM1 0
405#define AWE_REVERB_ROOM2 1
406#define AWE_REVERB_ROOM3 2
407#define AWE_REVERB_HALL1 3
408#define AWE_REVERB_HALL2 4
409#define AWE_REVERB_PLATE 5
410#define AWE_REVERB_DELAY 6
411#define AWE_REVERB_PANNINGDELAY 7
412#define AWE_REVERB_PREDEFINED 8
413/* user can define reverb modes up to 32 */
414#define AWE_REVERB_NUMBERS 32
415
416typedef struct awe_reverb_fx_rec {
417 unsigned short parms[28];
418} awe_reverb_fx_rec;
419
420/*----------------------------------------------------------------*/
421
422/* chorus mode parameters */
423#define AWE_CHORUS_1 0
424#define AWE_CHORUS_2 1
425#define AWE_CHORUS_3 2
426#define AWE_CHORUS_4 3
427#define AWE_CHORUS_FEEDBACK 4
428#define AWE_CHORUS_FLANGER 5
429#define AWE_CHORUS_SHORTDELAY 6
430#define AWE_CHORUS_SHORTDELAY2 7
431#define AWE_CHORUS_PREDEFINED 8
432/* user can define chorus modes up to 32 */
433#define AWE_CHORUS_NUMBERS 32
434
435typedef struct awe_chorus_fx_rec {
436 unsigned short feedback; /* feedback level (0xE600-0xE6FF) */
437 unsigned short delay_offset; /* delay (0-0x0DA3) [1/44100 sec] */
438 unsigned short lfo_depth; /* LFO depth (0xBC00-0xBCFF) */
439 unsigned int delay; /* right delay (0-0xFFFFFFFF) [1/256/44100 sec] */
440 unsigned int lfo_freq; /* LFO freq LFO freq (0-0xFFFFFFFF) */
441} awe_chorus_fx_rec;
442
443/*----------------------------------------------------------------*/
444
445/* misc mode types */
446enum {
447/* 0*/ AWE_MD_EXCLUSIVE_OFF, /* obsolete */
448/* 1*/ AWE_MD_EXCLUSIVE_ON, /* obsolete */
449/* 2*/ AWE_MD_VERSION, /* read only */
450/* 3*/ AWE_MD_EXCLUSIVE_SOUND, /* 0/1: exclusive note on (default=1) */
451/* 4*/ AWE_MD_REALTIME_PAN, /* 0/1: do realtime pan change (default=1) */
452/* 5*/ AWE_MD_GUS_BANK, /* bank number for GUS patches (default=0) */
453/* 6*/ AWE_MD_KEEP_EFFECT, /* 0/1: keep effect values, (default=0) */
454/* 7*/ AWE_MD_ZERO_ATTEN, /* attenuation of max volume (default=32) */
455/* 8*/ AWE_MD_CHN_PRIOR, /* 0/1: set MIDI channel priority mode (default=1) */
456/* 9*/ AWE_MD_MOD_SENSE, /* integer: modwheel sensitivity (def=18) */
457/*10*/ AWE_MD_DEF_PRESET, /* integer: default preset number (def=0) */
458/*11*/ AWE_MD_DEF_BANK, /* integer: default bank number (def=0) */
459/*12*/ AWE_MD_DEF_DRUM, /* integer: default drumset number (def=0) */
460/*13*/ AWE_MD_TOGGLE_DRUM_BANK, /* 0/1: toggle drum flag with bank# (def=0) */
461/*14*/ AWE_MD_NEW_VOLUME_CALC, /* 0/1: volume calculation mode (def=1) */
462/*15*/ AWE_MD_CHORUS_MODE, /* integer: chorus mode (def=2) */
463/*16*/ AWE_MD_REVERB_MODE, /* integer: chorus mode (def=4) */
464/*17*/ AWE_MD_BASS_LEVEL, /* integer: bass level (def=5) */
465/*18*/ AWE_MD_TREBLE_LEVEL, /* integer: treble level (def=9) */
466/*19*/ AWE_MD_DEBUG_MODE, /* integer: debug level (def=0) */
467/*20*/ AWE_MD_PAN_EXCHANGE, /* 0/1: exchange panning direction (def=0) */
468 AWE_MD_END,
469};
470
471/*----------------------------------------------------------------*/
472
473/* effect parameters */
474enum {
475
476/* modulation envelope parameters */
477/* 0*/ AWE_FX_ENV1_DELAY, /* WORD: ENVVAL */
478/* 1*/ AWE_FX_ENV1_ATTACK, /* BYTE: up ATKHLD */
479/* 2*/ AWE_FX_ENV1_HOLD, /* BYTE: lw ATKHLD */
480/* 3*/ AWE_FX_ENV1_DECAY, /* BYTE: lw DCYSUS */
481/* 4*/ AWE_FX_ENV1_RELEASE, /* BYTE: lw DCYSUS */
482/* 5*/ AWE_FX_ENV1_SUSTAIN, /* BYTE: up DCYSUS */
483/* 6*/ AWE_FX_ENV1_PITCH, /* BYTE: up PEFE */
484/* 7*/ AWE_FX_ENV1_CUTOFF, /* BYTE: lw PEFE */
485
486/* volume envelope parameters */
487/* 8*/ AWE_FX_ENV2_DELAY, /* WORD: ENVVOL */
488/* 9*/ AWE_FX_ENV2_ATTACK, /* BYTE: up ATKHLDV */
489/*10*/ AWE_FX_ENV2_HOLD, /* BYTE: lw ATKHLDV */
490/*11*/ AWE_FX_ENV2_DECAY, /* BYTE: lw DCYSUSV */
491/*12*/ AWE_FX_ENV2_RELEASE, /* BYTE: lw DCYSUSV */
492/*13*/ AWE_FX_ENV2_SUSTAIN, /* BYTE: up DCYSUSV */
493
494/* LFO1 (tremolo & vibrato) parameters */
495/*14*/ AWE_FX_LFO1_DELAY, /* WORD: LFO1VAL */
496/*15*/ AWE_FX_LFO1_FREQ, /* BYTE: lo TREMFRQ */
497/*16*/ AWE_FX_LFO1_VOLUME, /* BYTE: up TREMFRQ */
498/*17*/ AWE_FX_LFO1_PITCH, /* BYTE: up FMMOD */
499/*18*/ AWE_FX_LFO1_CUTOFF, /* BYTE: lo FMMOD */
500
501/* LFO2 (vibrato) parameters */
502/*19*/ AWE_FX_LFO2_DELAY, /* WORD: LFO2VAL */
503/*20*/ AWE_FX_LFO2_FREQ, /* BYTE: lo FM2FRQ2 */
504/*21*/ AWE_FX_LFO2_PITCH, /* BYTE: up FM2FRQ2 */
505
506/* Other overall effect parameters */
507/*22*/ AWE_FX_INIT_PITCH, /* SHORT: pitch offset */
508/*23*/ AWE_FX_CHORUS, /* BYTE: chorus effects send (0-255) */
509/*24*/ AWE_FX_REVERB, /* BYTE: reverb effects send (0-255) */
510/*25*/ AWE_FX_CUTOFF, /* BYTE: up IFATN */
511/*26*/ AWE_FX_FILTERQ, /* BYTE: up CCCA */
512
513/* Sample / loop offset changes */
514/*27*/ AWE_FX_SAMPLE_START, /* SHORT: offset */
515/*28*/ AWE_FX_LOOP_START, /* SHORT: offset */
516/*29*/ AWE_FX_LOOP_END, /* SHORT: offset */
517/*30*/ AWE_FX_COARSE_SAMPLE_START, /* SHORT: upper word offset */
518/*31*/ AWE_FX_COARSE_LOOP_START, /* SHORT: upper word offset */
519/*32*/ AWE_FX_COARSE_LOOP_END, /* SHORT: upper word offset */
520/*33*/ AWE_FX_ATTEN, /* BYTE: lo IFATN */
521
522 AWE_FX_END,
523};
524
525#endif /* AWE_VOICE_H */
diff --git a/include/linux/ax25.h b/include/linux/ax25.h
new file mode 100644
index 000000000000..56c11f0dbd80
--- /dev/null
+++ b/include/linux/ax25.h
@@ -0,0 +1,116 @@
1/*
2 * These are the public elements of the Linux kernel AX.25 code. A similar
3 * file netrom.h exists for the NET/ROM protocol.
4 */
5
6#ifndef AX25_KERNEL_H
7#define AX25_KERNEL_H
8
9#include <linux/socket.h>
10
11#define AX25_MTU 256
12#define AX25_MAX_DIGIS 8
13
14#define AX25_WINDOW 1
15#define AX25_T1 2
16#define AX25_N2 3
17#define AX25_T3 4
18#define AX25_T2 5
19#define AX25_BACKOFF 6
20#define AX25_EXTSEQ 7
21#define AX25_PIDINCL 8
22#define AX25_IDLE 9
23#define AX25_PACLEN 10
24#define AX25_IAMDIGI 12
25
26#define AX25_KILL 99
27
28#define SIOCAX25GETUID (SIOCPROTOPRIVATE+0)
29#define SIOCAX25ADDUID (SIOCPROTOPRIVATE+1)
30#define SIOCAX25DELUID (SIOCPROTOPRIVATE+2)
31#define SIOCAX25NOUID (SIOCPROTOPRIVATE+3)
32#define SIOCAX25OPTRT (SIOCPROTOPRIVATE+7)
33#define SIOCAX25CTLCON (SIOCPROTOPRIVATE+8)
34#define SIOCAX25GETINFOOLD (SIOCPROTOPRIVATE+9)
35#define SIOCAX25ADDFWD (SIOCPROTOPRIVATE+10)
36#define SIOCAX25DELFWD (SIOCPROTOPRIVATE+11)
37#define SIOCAX25DEVCTL (SIOCPROTOPRIVATE+12)
38#define SIOCAX25GETINFO (SIOCPROTOPRIVATE+13)
39
40#define AX25_SET_RT_IPMODE 2
41
42#define AX25_NOUID_DEFAULT 0
43#define AX25_NOUID_BLOCK 1
44
45typedef struct {
46 char ax25_call[7]; /* 6 call + SSID (shifted ascii!) */
47} ax25_address;
48
49struct sockaddr_ax25 {
50 sa_family_t sax25_family;
51 ax25_address sax25_call;
52 int sax25_ndigis;
53 /* Digipeater ax25_address sets follow */
54};
55
56#define sax25_uid sax25_ndigis
57
58struct full_sockaddr_ax25 {
59 struct sockaddr_ax25 fsa_ax25;
60 ax25_address fsa_digipeater[AX25_MAX_DIGIS];
61};
62
63struct ax25_routes_struct {
64 ax25_address port_addr;
65 ax25_address dest_addr;
66 unsigned char digi_count;
67 ax25_address digi_addr[AX25_MAX_DIGIS];
68};
69
70struct ax25_route_opt_struct {
71 ax25_address port_addr;
72 ax25_address dest_addr;
73 int cmd;
74 int arg;
75};
76
77struct ax25_ctl_struct {
78 ax25_address port_addr;
79 ax25_address source_addr;
80 ax25_address dest_addr;
81 unsigned int cmd;
82 unsigned long arg;
83 unsigned char digi_count;
84 ax25_address digi_addr[AX25_MAX_DIGIS];
85};
86
87/* this will go away. Please do not export to user land */
88struct ax25_info_struct_deprecated {
89 unsigned int n2, n2count;
90 unsigned int t1, t1timer;
91 unsigned int t2, t2timer;
92 unsigned int t3, t3timer;
93 unsigned int idle, idletimer;
94 unsigned int state;
95 unsigned int rcv_q, snd_q;
96};
97
98struct ax25_info_struct {
99 unsigned int n2, n2count;
100 unsigned int t1, t1timer;
101 unsigned int t2, t2timer;
102 unsigned int t3, t3timer;
103 unsigned int idle, idletimer;
104 unsigned int state;
105 unsigned int rcv_q, snd_q;
106 unsigned int vs, vr, va, vs_max;
107 unsigned int paclen;
108 unsigned int window;
109};
110
111struct ax25_fwd_struct {
112 ax25_address port_from;
113 ax25_address port_to;
114};
115
116#endif
diff --git a/include/linux/b1lli.h b/include/linux/b1lli.h
new file mode 100644
index 000000000000..713f712685d3
--- /dev/null
+++ b/include/linux/b1lli.h
@@ -0,0 +1,73 @@
1/* $Id: b1lli.h,v 1.8.8.3 2001/09/23 22:25:05 kai Exp $
2 *
3 * ISDN lowlevel-module for AVM B1-card.
4 *
5 * Copyright 1996 by Carsten Paeth (calle@calle.in-berlin.de)
6 *
7 * This software may be used and distributed according to the terms
8 * of the GNU General Public License, incorporated herein by reference.
9 *
10 */
11
12#ifndef _B1LLI_H_
13#define _B1LLI_H_
14/*
15 * struct for loading t4 file
16 */
17typedef struct avmb1_t4file {
18 int len;
19 unsigned char *data;
20} avmb1_t4file;
21
22typedef struct avmb1_loaddef {
23 int contr;
24 avmb1_t4file t4file;
25} avmb1_loaddef;
26
27typedef struct avmb1_loadandconfigdef {
28 int contr;
29 avmb1_t4file t4file;
30 avmb1_t4file t4config;
31} avmb1_loadandconfigdef;
32
33typedef struct avmb1_resetdef {
34 int contr;
35} avmb1_resetdef;
36
37typedef struct avmb1_getdef {
38 int contr;
39 int cardtype;
40 int cardstate;
41} avmb1_getdef;
42
43/*
44 * struct for adding new cards
45 */
46typedef struct avmb1_carddef {
47 int port;
48 int irq;
49} avmb1_carddef;
50
51#define AVM_CARDTYPE_B1 0
52#define AVM_CARDTYPE_T1 1
53#define AVM_CARDTYPE_M1 2
54#define AVM_CARDTYPE_M2 3
55
56typedef struct avmb1_extcarddef {
57 int port;
58 int irq;
59 int cardtype;
60 int cardnr; /* for HEMA/T1 */
61} avmb1_extcarddef;
62
63#define AVMB1_LOAD 0 /* load image to card */
64#define AVMB1_ADDCARD 1 /* add a new card - OBSOLETE */
65#define AVMB1_RESETCARD 2 /* reset a card */
66#define AVMB1_LOAD_AND_CONFIG 3 /* load image and config to card */
67#define AVMB1_ADDCARD_WITH_TYPE 4 /* add a new card, with cardtype */
68#define AVMB1_GET_CARDINFO 5 /* get cardtype */
69#define AVMB1_REMOVECARD 6 /* remove a card - OBSOLETE */
70
71#define AVMB1_REGISTERCARD_IS_OBSOLETE
72
73#endif /* _B1LLI_H_ */
diff --git a/include/linux/b1pcmcia.h b/include/linux/b1pcmcia.h
new file mode 100644
index 000000000000..12a867c6061e
--- /dev/null
+++ b/include/linux/b1pcmcia.h
@@ -0,0 +1,21 @@
1/* $Id: b1pcmcia.h,v 1.1.8.2 2001/09/23 22:25:05 kai Exp $
2 *
3 * Exported functions of module b1pcmcia to be called by
4 * avm_cs card services module.
5 *
6 * Copyright 1999 by Carsten Paeth (calle@calle.in-berlin.de)
7 *
8 * This software may be used and distributed according to the terms
9 * of the GNU General Public License, incorporated herein by reference.
10 *
11 */
12
13#ifndef _B1PCMCIA_H_
14#define _B1PCMCIA_H_
15
16int b1pcmcia_addcard_b1(unsigned int port, unsigned irq);
17int b1pcmcia_addcard_m1(unsigned int port, unsigned irq);
18int b1pcmcia_addcard_m2(unsigned int port, unsigned irq);
19int b1pcmcia_delcard(unsigned int port, unsigned irq);
20
21#endif /* _B1PCMCIA_H_ */
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
new file mode 100644
index 000000000000..f7a1390d67f5
--- /dev/null
+++ b/include/linux/backing-dev.h
@@ -0,0 +1,104 @@
1/*
2 * include/linux/backing-dev.h
3 *
4 * low-level device information and state which is propagated up through
5 * to high-level code.
6 */
7
8#ifndef _LINUX_BACKING_DEV_H
9#define _LINUX_BACKING_DEV_H
10
11#include <asm/atomic.h>
12
13/*
14 * Bits in backing_dev_info.state
15 */
16enum bdi_state {
17 BDI_pdflush, /* A pdflush thread is working this device */
18 BDI_write_congested, /* The write queue is getting full */
19 BDI_read_congested, /* The read queue is getting full */
20 BDI_unused, /* Available bits start here */
21};
22
23typedef int (congested_fn)(void *, int);
24
25struct backing_dev_info {
26 unsigned long ra_pages; /* max readahead in PAGE_CACHE_SIZE units */
27 unsigned long state; /* Always use atomic bitops on this */
28 unsigned int capabilities; /* Device capabilities */
29 congested_fn *congested_fn; /* Function pointer if device is md/dm */
30 void *congested_data; /* Pointer to aux data for congested func */
31 void (*unplug_io_fn)(struct backing_dev_info *, struct page *);
32 void *unplug_io_data;
33};
34
35
36/*
37 * Flags in backing_dev_info::capability
38 * - The first two flags control whether dirty pages will contribute to the
39 * VM's accounting and whether writepages() should be called for dirty pages
40 * (something that would not, for example, be appropriate for ramfs)
41 * - These flags let !MMU mmap() govern direct device mapping vs immediate
42 * copying more easily for MAP_PRIVATE, especially for ROM filesystems
43 */
44#define BDI_CAP_NO_ACCT_DIRTY 0x00000001 /* Dirty pages shouldn't contribute to accounting */
45#define BDI_CAP_NO_WRITEBACK 0x00000002 /* Don't write pages back */
46#define BDI_CAP_MAP_COPY 0x00000004 /* Copy can be mapped (MAP_PRIVATE) */
47#define BDI_CAP_MAP_DIRECT 0x00000008 /* Can be mapped directly (MAP_SHARED) */
48#define BDI_CAP_READ_MAP 0x00000010 /* Can be mapped for reading */
49#define BDI_CAP_WRITE_MAP 0x00000020 /* Can be mapped for writing */
50#define BDI_CAP_EXEC_MAP 0x00000040 /* Can be mapped for execution */
51#define BDI_CAP_VMFLAGS \
52 (BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP | BDI_CAP_EXEC_MAP)
53
54#if defined(VM_MAYREAD) && \
55 (BDI_CAP_READ_MAP != VM_MAYREAD || \
56 BDI_CAP_WRITE_MAP != VM_MAYWRITE || \
57 BDI_CAP_EXEC_MAP != VM_MAYEXEC)
58#error please change backing_dev_info::capabilities flags
59#endif
60
61extern struct backing_dev_info default_backing_dev_info;
62void default_unplug_io_fn(struct backing_dev_info *bdi, struct page *page);
63
64int writeback_acquire(struct backing_dev_info *bdi);
65int writeback_in_progress(struct backing_dev_info *bdi);
66void writeback_release(struct backing_dev_info *bdi);
67
68static inline int bdi_congested(struct backing_dev_info *bdi, int bdi_bits)
69{
70 if (bdi->congested_fn)
71 return bdi->congested_fn(bdi->congested_data, bdi_bits);
72 return (bdi->state & bdi_bits);
73}
74
75static inline int bdi_read_congested(struct backing_dev_info *bdi)
76{
77 return bdi_congested(bdi, 1 << BDI_read_congested);
78}
79
80static inline int bdi_write_congested(struct backing_dev_info *bdi)
81{
82 return bdi_congested(bdi, 1 << BDI_write_congested);
83}
84
85static inline int bdi_rw_congested(struct backing_dev_info *bdi)
86{
87 return bdi_congested(bdi, (1 << BDI_read_congested)|
88 (1 << BDI_write_congested));
89}
90
91#define bdi_cap_writeback_dirty(bdi) \
92 (!((bdi)->capabilities & BDI_CAP_NO_WRITEBACK))
93
94#define bdi_cap_account_dirty(bdi) \
95 (!((bdi)->capabilities & BDI_CAP_NO_ACCT_DIRTY))
96
97#define mapping_cap_writeback_dirty(mapping) \
98 bdi_cap_writeback_dirty((mapping)->backing_dev_info)
99
100#define mapping_cap_account_dirty(mapping) \
101 bdi_cap_account_dirty((mapping)->backing_dev_info)
102
103
104#endif /* _LINUX_BACKING_DEV_H */
diff --git a/include/linux/backlight.h b/include/linux/backlight.h
new file mode 100644
index 000000000000..bb9e54322322
--- /dev/null
+++ b/include/linux/backlight.h
@@ -0,0 +1,57 @@
1/*
2 * Backlight Lowlevel Control Abstraction
3 *
4 * Copyright (C) 2003,2004 Hewlett-Packard Company
5 *
6 */
7
8#ifndef _LINUX_BACKLIGHT_H
9#define _LINUX_BACKLIGHT_H
10
11#include <linux/device.h>
12#include <linux/notifier.h>
13
14struct backlight_device;
15struct fb_info;
16
17/* This structure defines all the properties of a backlight
18 (usually attached to a LCD). */
19struct backlight_properties {
20 /* Owner module */
21 struct module *owner;
22 /* Get the backlight power status (0: full on, 1..3: power saving
23 modes; 4: full off), see FB_BLANK_XXX */
24 int (*get_power)(struct backlight_device *);
25 /* Enable or disable power to the LCD (0: on; 4: off, see FB_BLANK_XXX) */
26 int (*set_power)(struct backlight_device *, int power);
27 /* Maximal value for brightness (read-only) */
28 int max_brightness;
29 /* Get current backlight brightness */
30 int (*get_brightness)(struct backlight_device *);
31 /* Set backlight brightness (0..max_brightness) */
32 int (*set_brightness)(struct backlight_device *, int brightness);
33 /* Check if given framebuffer device is the one bound to this backlight;
34 return 0 if not, !=0 if it is. If NULL, backlight always matches the fb. */
35 int (*check_fb)(struct fb_info *);
36};
37
38struct backlight_device {
39 /* This protects the 'props' field. If 'props' is NULL, the driver that
40 registered this device has been unloaded, and if class_get_devdata()
41 points to something in the body of that driver, it is also invalid. */
42 struct semaphore sem;
43 /* If this is NULL, the backing module is unloaded */
44 struct backlight_properties *props;
45 /* The framebuffer notifier block */
46 struct notifier_block fb_notif;
47 /* The class device structure */
48 struct class_device class_dev;
49};
50
51extern struct backlight_device *backlight_device_register(const char *name,
52 void *devdata, struct backlight_properties *bp);
53extern void backlight_device_unregister(struct backlight_device *bd);
54
55#define to_backlight_device(obj) container_of(obj, struct backlight_device, class_dev)
56
57#endif
diff --git a/include/linux/baycom.h b/include/linux/baycom.h
new file mode 100644
index 000000000000..81249e029dad
--- /dev/null
+++ b/include/linux/baycom.h
@@ -0,0 +1,39 @@
1/*
2 * The Linux BAYCOM driver for the Baycom serial 1200 baud modem
3 * and the parallel 9600 baud modem
4 * (C) 1997-1998 by Thomas Sailer, HB9JNX/AE4WA
5 */
6
7#ifndef _BAYCOM_H
8#define _BAYCOM_H
9
10/* -------------------------------------------------------------------- */
11/*
12 * structs for the IOCTL commands
13 */
14
15struct baycom_debug_data {
16 unsigned long debug1;
17 unsigned long debug2;
18 long debug3;
19};
20
21struct baycom_ioctl {
22 int cmd;
23 union {
24 struct baycom_debug_data dbg;
25 } data;
26};
27
28/* -------------------------------------------------------------------- */
29
30/*
31 * ioctl values change for baycom
32 */
33#define BAYCOMCTL_GETDEBUG 0x92
34
35/* -------------------------------------------------------------------- */
36
37#endif /* _BAYCOM_H */
38
39/* --------------------------------------------------------------------- */
diff --git a/include/linux/bcd.h b/include/linux/bcd.h
new file mode 100644
index 000000000000..c545308125b0
--- /dev/null
+++ b/include/linux/bcd.h
@@ -0,0 +1,20 @@
1/* Permission is hereby granted to copy, modify and redistribute this code
2 * in terms of the GNU Library General Public License, Version 2 or later,
3 * at your option.
4 */
5
6/* macros to translate to/from binary and binary-coded decimal (frequently
7 * found in RTC chips).
8 */
9
10#ifndef _BCD_H
11#define _BCD_H
12
13#define BCD2BIN(val) (((val) & 0x0f) + ((val)>>4)*10)
14#define BIN2BCD(val) ((((val)/10)<<4) + (val)%10)
15
16/* backwards compat */
17#define BCD_TO_BIN(val) ((val)=BCD2BIN(val))
18#define BIN_TO_BCD(val) ((val)=BIN2BCD(val))
19
20#endif /* _BCD_H */
diff --git a/include/linux/bfs_fs.h b/include/linux/bfs_fs.h
new file mode 100644
index 000000000000..f7f0913cd110
--- /dev/null
+++ b/include/linux/bfs_fs.h
@@ -0,0 +1,79 @@
1/*
2 * include/linux/bfs_fs.h - BFS data structures on disk.
3 * Copyright (C) 1999 Tigran Aivazian <tigran@veritas.com>
4 */
5
6#ifndef _LINUX_BFS_FS_H
7#define _LINUX_BFS_FS_H
8
9#define BFS_BSIZE_BITS 9
10#define BFS_BSIZE (1<<BFS_BSIZE_BITS)
11
12#define BFS_MAGIC 0x1BADFACE
13#define BFS_ROOT_INO 2
14#define BFS_INODES_PER_BLOCK 8
15
16/* SVR4 vnode type values (bfs_inode->i_vtype) */
17#define BFS_VDIR 2
18#define BFS_VREG 1
19
20/* BFS inode layout on disk */
21struct bfs_inode {
22 __u16 i_ino;
23 __u16 i_unused;
24 __u32 i_sblock;
25 __u32 i_eblock;
26 __u32 i_eoffset;
27 __u32 i_vtype;
28 __u32 i_mode;
29 __s32 i_uid;
30 __s32 i_gid;
31 __u32 i_nlink;
32 __u32 i_atime;
33 __u32 i_mtime;
34 __u32 i_ctime;
35 __u32 i_padding[4];
36};
37
38#define BFS_NAMELEN 14
39#define BFS_DIRENT_SIZE 16
40#define BFS_DIRS_PER_BLOCK 32
41
42struct bfs_dirent {
43 __u16 ino;
44 char name[BFS_NAMELEN];
45};
46
47/* BFS superblock layout on disk */
48struct bfs_super_block {
49 __u32 s_magic;
50 __u32 s_start;
51 __u32 s_end;
52 __s32 s_from;
53 __s32 s_to;
54 __s32 s_bfrom;
55 __s32 s_bto;
56 char s_fsname[6];
57 char s_volume[6];
58 __u32 s_padding[118];
59};
60
61#define BFS_NZFILESIZE(ip) \
62 (((ip)->i_eoffset + 1) - (ip)->i_sblock * BFS_BSIZE)
63
64#define BFS_FILESIZE(ip) \
65 ((ip)->i_sblock == 0 ? 0 : BFS_NZFILESIZE(ip))
66
67#define BFS_FILEBLOCKS(ip) \
68 ((ip)->i_sblock == 0 ? 0 : ((ip)->i_eblock + 1) - (ip)->i_sblock)
69
70#define BFS_OFF2INO(offset) \
71 ((((offset) - BFS_BSIZE) / sizeof(struct bfs_inode)) + BFS_ROOT_INO)
72
73#define BFS_INO2OFF(ino) \
74 ((__u32)(((ino) - BFS_ROOT_INO) * sizeof(struct bfs_inode)) + BFS_BSIZE)
75
76#define BFS_UNCLEAN(bfs_sb, sb) \
77 ((bfs_sb->s_from != -1) && (bfs_sb->s_to != -1) && !(sb->s_flags & MS_RDONLY))
78
79#endif /* _LINUX_BFS_FS_H */
diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
new file mode 100644
index 000000000000..54f820832c73
--- /dev/null
+++ b/include/linux/binfmts.h
@@ -0,0 +1,87 @@
1#ifndef _LINUX_BINFMTS_H
2#define _LINUX_BINFMTS_H
3
4#include <linux/capability.h>
5
6struct pt_regs;
7
8/*
9 * MAX_ARG_PAGES defines the number of pages allocated for arguments
10 * and envelope for the new program. 32 should suffice, this gives
11 * a maximum env+arg of 128kB w/4KB pages!
12 */
13#define MAX_ARG_PAGES 32
14
15/* sizeof(linux_binprm->buf) */
16#define BINPRM_BUF_SIZE 128
17
18#ifdef __KERNEL__
19
20/*
21 * This structure is used to hold the arguments that are used when loading binaries.
22 */
23struct linux_binprm{
24 char buf[BINPRM_BUF_SIZE];
25 struct page *page[MAX_ARG_PAGES];
26 struct mm_struct *mm;
27 unsigned long p; /* current top of mem */
28 int sh_bang;
29 struct file * file;
30 int e_uid, e_gid;
31 kernel_cap_t cap_inheritable, cap_permitted, cap_effective;
32 void *security;
33 int argc, envc;
34 char * filename; /* Name of binary as seen by procps */
35 char * interp; /* Name of the binary really executed. Most
36 of the time same as filename, but could be
37 different for binfmt_{misc,script} */
38 unsigned interp_flags;
39 unsigned interp_data;
40 unsigned long loader, exec;
41};
42
43#define BINPRM_FLAGS_ENFORCE_NONDUMP_BIT 0
44#define BINPRM_FLAGS_ENFORCE_NONDUMP (1 << BINPRM_FLAGS_ENFORCE_NONDUMP_BIT)
45
46/* fd of the binary should be passed to the interpreter */
47#define BINPRM_FLAGS_EXECFD_BIT 1
48#define BINPRM_FLAGS_EXECFD (1 << BINPRM_FLAGS_EXECFD_BIT)
49
50
51/*
52 * This structure defines the functions that are used to load the binary formats that
53 * linux accepts.
54 */
55struct linux_binfmt {
56 struct linux_binfmt * next;
57 struct module *module;
58 int (*load_binary)(struct linux_binprm *, struct pt_regs * regs);
59 int (*load_shlib)(struct file *);
60 int (*core_dump)(long signr, struct pt_regs * regs, struct file * file);
61 unsigned long min_coredump; /* minimal dump size */
62};
63
64extern int register_binfmt(struct linux_binfmt *);
65extern int unregister_binfmt(struct linux_binfmt *);
66
67extern int prepare_binprm(struct linux_binprm *);
68extern void remove_arg_zero(struct linux_binprm *);
69extern int search_binary_handler(struct linux_binprm *,struct pt_regs *);
70extern int flush_old_exec(struct linux_binprm * bprm);
71
72/* Stack area protections */
73#define EXSTACK_DEFAULT 0 /* Whatever the arch defaults to */
74#define EXSTACK_DISABLE_X 1 /* Disable executable stacks */
75#define EXSTACK_ENABLE_X 2 /* Enable executable stacks */
76
77extern int setup_arg_pages(struct linux_binprm * bprm,
78 unsigned long stack_top,
79 int executable_stack);
80extern int copy_strings(int argc,char __user * __user * argv,struct linux_binprm *bprm);
81extern int copy_strings_kernel(int argc,char ** argv,struct linux_binprm *bprm);
82extern void compute_creds(struct linux_binprm *binprm);
83extern int do_coredump(long signr, int exit_code, struct pt_regs * regs);
84extern int set_binfmt(struct linux_binfmt *new);
85
86#endif /* __KERNEL__ */
87#endif /* _LINUX_BINFMTS_H */
diff --git a/include/linux/bio.h b/include/linux/bio.h
new file mode 100644
index 000000000000..038022763f09
--- /dev/null
+++ b/include/linux/bio.h
@@ -0,0 +1,339 @@
1/*
2 * 2.5 block I/O model
3 *
4 * Copyright (C) 2001 Jens Axboe <axboe@suse.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 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
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 Licens
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-
19 */
20#ifndef __LINUX_BIO_H
21#define __LINUX_BIO_H
22
23#include <linux/highmem.h>
24#include <linux/mempool.h>
25
26/* Platforms may set this to teach the BIO layer about IOMMU hardware. */
27#include <asm/io.h>
28
29#if defined(BIO_VMERGE_MAX_SIZE) && defined(BIO_VMERGE_BOUNDARY)
30#define BIOVEC_VIRT_START_SIZE(x) (bvec_to_phys(x) & (BIO_VMERGE_BOUNDARY - 1))
31#define BIOVEC_VIRT_OVERSIZE(x) ((x) > BIO_VMERGE_MAX_SIZE)
32#else
33#define BIOVEC_VIRT_START_SIZE(x) 0
34#define BIOVEC_VIRT_OVERSIZE(x) 0
35#endif
36
37#ifndef BIO_VMERGE_BOUNDARY
38#define BIO_VMERGE_BOUNDARY 0
39#endif
40
41#define BIO_DEBUG
42
43#ifdef BIO_DEBUG
44#define BIO_BUG_ON BUG_ON
45#else
46#define BIO_BUG_ON
47#endif
48
49#define BIO_MAX_PAGES (256)
50#define BIO_MAX_SIZE (BIO_MAX_PAGES << PAGE_CACHE_SHIFT)
51#define BIO_MAX_SECTORS (BIO_MAX_SIZE >> 9)
52
53/*
54 * was unsigned short, but we might as well be ready for > 64kB I/O pages
55 */
56struct bio_vec {
57 struct page *bv_page;
58 unsigned int bv_len;
59 unsigned int bv_offset;
60};
61
62struct bio_set;
63struct bio;
64typedef int (bio_end_io_t) (struct bio *, unsigned int, int);
65typedef void (bio_destructor_t) (struct bio *);
66
67/*
68 * main unit of I/O for the block layer and lower layers (ie drivers and
69 * stacking drivers)
70 */
71struct bio {
72 sector_t bi_sector;
73 struct bio *bi_next; /* request queue link */
74 struct block_device *bi_bdev;
75 unsigned long bi_flags; /* status, command, etc */
76 unsigned long bi_rw; /* bottom bits READ/WRITE,
77 * top bits priority
78 */
79
80 unsigned short bi_vcnt; /* how many bio_vec's */
81 unsigned short bi_idx; /* current index into bvl_vec */
82
83 /* Number of segments in this BIO after
84 * physical address coalescing is performed.
85 */
86 unsigned short bi_phys_segments;
87
88 /* Number of segments after physical and DMA remapping
89 * hardware coalescing is performed.
90 */
91 unsigned short bi_hw_segments;
92
93 unsigned int bi_size; /* residual I/O count */
94
95 /*
96 * To keep track of the max hw size, we account for the
97 * sizes of the first and last virtually mergeable segments
98 * in this bio
99 */
100 unsigned int bi_hw_front_size;
101 unsigned int bi_hw_back_size;
102
103 unsigned int bi_max_vecs; /* max bvl_vecs we can hold */
104
105 struct bio_vec *bi_io_vec; /* the actual vec list */
106
107 bio_end_io_t *bi_end_io;
108 atomic_t bi_cnt; /* pin count */
109
110 void *bi_private;
111
112 bio_destructor_t *bi_destructor; /* destructor */
113 struct bio_set *bi_set; /* memory pools set */
114};
115
116/*
117 * bio flags
118 */
119#define BIO_UPTODATE 0 /* ok after I/O completion */
120#define BIO_RW_BLOCK 1 /* RW_AHEAD set, and read/write would block */
121#define BIO_EOF 2 /* out-out-bounds error */
122#define BIO_SEG_VALID 3 /* nr_hw_seg valid */
123#define BIO_CLONED 4 /* doesn't own data */
124#define BIO_BOUNCED 5 /* bio is a bounce bio */
125#define BIO_USER_MAPPED 6 /* contains user pages */
126#define BIO_EOPNOTSUPP 7 /* not supported */
127#define bio_flagged(bio, flag) ((bio)->bi_flags & (1 << (flag)))
128
129/*
130 * top 4 bits of bio flags indicate the pool this bio came from
131 */
132#define BIO_POOL_BITS (4)
133#define BIO_POOL_OFFSET (BITS_PER_LONG - BIO_POOL_BITS)
134#define BIO_POOL_MASK (1UL << BIO_POOL_OFFSET)
135#define BIO_POOL_IDX(bio) ((bio)->bi_flags >> BIO_POOL_OFFSET)
136
137/*
138 * bio bi_rw flags
139 *
140 * bit 0 -- read (not set) or write (set)
141 * bit 1 -- rw-ahead when set
142 * bit 2 -- barrier
143 * bit 3 -- fail fast, don't want low level driver retries
144 * bit 4 -- synchronous I/O hint: the block layer will unplug immediately
145 */
146#define BIO_RW 0
147#define BIO_RW_AHEAD 1
148#define BIO_RW_BARRIER 2
149#define BIO_RW_FAILFAST 3
150#define BIO_RW_SYNC 4
151
152/*
153 * various member access, note that bio_data should of course not be used
154 * on highmem page vectors
155 */
156#define bio_iovec_idx(bio, idx) (&((bio)->bi_io_vec[(idx)]))
157#define bio_iovec(bio) bio_iovec_idx((bio), (bio)->bi_idx)
158#define bio_page(bio) bio_iovec((bio))->bv_page
159#define bio_offset(bio) bio_iovec((bio))->bv_offset
160#define bio_segments(bio) ((bio)->bi_vcnt - (bio)->bi_idx)
161#define bio_sectors(bio) ((bio)->bi_size >> 9)
162#define bio_cur_sectors(bio) (bio_iovec(bio)->bv_len >> 9)
163#define bio_data(bio) (page_address(bio_page((bio))) + bio_offset((bio)))
164#define bio_barrier(bio) ((bio)->bi_rw & (1 << BIO_RW_BARRIER))
165#define bio_sync(bio) ((bio)->bi_rw & (1 << BIO_RW_SYNC))
166#define bio_failfast(bio) ((bio)->bi_rw & (1 << BIO_RW_FAILFAST))
167#define bio_rw_ahead(bio) ((bio)->bi_rw & (1 << BIO_RW_AHEAD))
168
169/*
170 * will die
171 */
172#define bio_to_phys(bio) (page_to_phys(bio_page((bio))) + (unsigned long) bio_offset((bio)))
173#define bvec_to_phys(bv) (page_to_phys((bv)->bv_page) + (unsigned long) (bv)->bv_offset)
174
175/*
176 * queues that have highmem support enabled may still need to revert to
177 * PIO transfers occasionally and thus map high pages temporarily. For
178 * permanent PIO fall back, user is probably better off disabling highmem
179 * I/O completely on that queue (see ide-dma for example)
180 */
181#define __bio_kmap_atomic(bio, idx, kmtype) \
182 (kmap_atomic(bio_iovec_idx((bio), (idx))->bv_page, kmtype) + \
183 bio_iovec_idx((bio), (idx))->bv_offset)
184
185#define __bio_kunmap_atomic(addr, kmtype) kunmap_atomic(addr, kmtype)
186
187/*
188 * merge helpers etc
189 */
190
191#define __BVEC_END(bio) bio_iovec_idx((bio), (bio)->bi_vcnt - 1)
192#define __BVEC_START(bio) bio_iovec_idx((bio), (bio)->bi_idx)
193
194/*
195 * allow arch override, for eg virtualized architectures (put in asm/io.h)
196 */
197#ifndef BIOVEC_PHYS_MERGEABLE
198#define BIOVEC_PHYS_MERGEABLE(vec1, vec2) \
199 ((bvec_to_phys((vec1)) + (vec1)->bv_len) == bvec_to_phys((vec2)))
200#endif
201
202#define BIOVEC_VIRT_MERGEABLE(vec1, vec2) \
203 ((((bvec_to_phys((vec1)) + (vec1)->bv_len) | bvec_to_phys((vec2))) & (BIO_VMERGE_BOUNDARY - 1)) == 0)
204#define __BIO_SEG_BOUNDARY(addr1, addr2, mask) \
205 (((addr1) | (mask)) == (((addr2) - 1) | (mask)))
206#define BIOVEC_SEG_BOUNDARY(q, b1, b2) \
207 __BIO_SEG_BOUNDARY(bvec_to_phys((b1)), bvec_to_phys((b2)) + (b2)->bv_len, (q)->seg_boundary_mask)
208#define BIO_SEG_BOUNDARY(q, b1, b2) \
209 BIOVEC_SEG_BOUNDARY((q), __BVEC_END((b1)), __BVEC_START((b2)))
210
211#define bio_io_error(bio, bytes) bio_endio((bio), (bytes), -EIO)
212
213/*
214 * drivers should not use the __ version unless they _really_ want to
215 * run through the entire bio and not just pending pieces
216 */
217#define __bio_for_each_segment(bvl, bio, i, start_idx) \
218 for (bvl = bio_iovec_idx((bio), (start_idx)), i = (start_idx); \
219 i < (bio)->bi_vcnt; \
220 bvl++, i++)
221
222#define bio_for_each_segment(bvl, bio, i) \
223 __bio_for_each_segment(bvl, bio, i, (bio)->bi_idx)
224
225/*
226 * get a reference to a bio, so it won't disappear. the intended use is
227 * something like:
228 *
229 * bio_get(bio);
230 * submit_bio(rw, bio);
231 * if (bio->bi_flags ...)
232 * do_something
233 * bio_put(bio);
234 *
235 * without the bio_get(), it could potentially complete I/O before submit_bio
236 * returns. and then bio would be freed memory when if (bio->bi_flags ...)
237 * runs
238 */
239#define bio_get(bio) atomic_inc(&(bio)->bi_cnt)
240
241
242/*
243 * A bio_pair is used when we need to split a bio.
244 * This can only happen for a bio that refers to just one
245 * page of data, and in the unusual situation when the
246 * page crosses a chunk/device boundary
247 *
248 * The address of the master bio is stored in bio1.bi_private
249 * The address of the pool the pair was allocated from is stored
250 * in bio2.bi_private
251 */
252struct bio_pair {
253 struct bio bio1, bio2;
254 struct bio_vec bv1, bv2;
255 atomic_t cnt;
256 int error;
257};
258extern struct bio_pair *bio_split(struct bio *bi, mempool_t *pool,
259 int first_sectors);
260extern mempool_t *bio_split_pool;
261extern void bio_pair_release(struct bio_pair *dbio);
262
263extern struct bio_set *bioset_create(int, int, int);
264extern void bioset_free(struct bio_set *);
265
266extern struct bio *bio_alloc(unsigned int __nocast, int);
267extern struct bio *bio_alloc_bioset(unsigned int __nocast, int, struct bio_set *);
268extern void bio_put(struct bio *);
269
270extern void bio_endio(struct bio *, unsigned int, int);
271struct request_queue;
272extern int bio_phys_segments(struct request_queue *, struct bio *);
273extern int bio_hw_segments(struct request_queue *, struct bio *);
274
275extern void __bio_clone(struct bio *, struct bio *);
276extern struct bio *bio_clone(struct bio *, unsigned int __nocast);
277
278extern void bio_init(struct bio *);
279
280extern int bio_add_page(struct bio *, struct page *, unsigned int,unsigned int);
281extern int bio_get_nr_vecs(struct block_device *);
282extern struct bio *bio_map_user(struct request_queue *, struct block_device *,
283 unsigned long, unsigned int, int);
284extern void bio_unmap_user(struct bio *);
285extern void bio_set_pages_dirty(struct bio *bio);
286extern void bio_check_pages_dirty(struct bio *bio);
287extern struct bio *bio_copy_user(struct request_queue *, unsigned long, unsigned int, int);
288extern int bio_uncopy_user(struct bio *);
289void zero_fill_bio(struct bio *bio);
290
291#ifdef CONFIG_HIGHMEM
292/*
293 * remember to add offset! and never ever reenable interrupts between a
294 * bvec_kmap_irq and bvec_kunmap_irq!!
295 *
296 * This function MUST be inlined - it plays with the CPU interrupt flags.
297 * Hence the `extern inline'.
298 */
299extern inline char *bvec_kmap_irq(struct bio_vec *bvec, unsigned long *flags)
300{
301 unsigned long addr;
302
303 /*
304 * might not be a highmem page, but the preempt/irq count
305 * balancing is a lot nicer this way
306 */
307 local_irq_save(*flags);
308 addr = (unsigned long) kmap_atomic(bvec->bv_page, KM_BIO_SRC_IRQ);
309
310 BUG_ON(addr & ~PAGE_MASK);
311
312 return (char *) addr + bvec->bv_offset;
313}
314
315extern inline void bvec_kunmap_irq(char *buffer, unsigned long *flags)
316{
317 unsigned long ptr = (unsigned long) buffer & PAGE_MASK;
318
319 kunmap_atomic((void *) ptr, KM_BIO_SRC_IRQ);
320 local_irq_restore(*flags);
321}
322
323#else
324#define bvec_kmap_irq(bvec, flags) (page_address((bvec)->bv_page) + (bvec)->bv_offset)
325#define bvec_kunmap_irq(buf, flags) do { *(flags) = 0; } while (0)
326#endif
327
328extern inline char *__bio_kmap_irq(struct bio *bio, unsigned short idx,
329 unsigned long *flags)
330{
331 return bvec_kmap_irq(bio_iovec_idx(bio, idx), flags);
332}
333#define __bio_kunmap_irq(buf, flags) bvec_kunmap_irq(buf, flags)
334
335#define bio_kmap_irq(bio, flags) \
336 __bio_kmap_irq((bio), (bio)->bi_idx, (flags))
337#define bio_kunmap_irq(buf,flags) __bio_kunmap_irq(buf, flags)
338
339#endif /* __LINUX_BIO_H */
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
new file mode 100644
index 000000000000..86dd5502b05c
--- /dev/null
+++ b/include/linux/bitmap.h
@@ -0,0 +1,261 @@
1#ifndef __LINUX_BITMAP_H
2#define __LINUX_BITMAP_H
3
4#ifndef __ASSEMBLY__
5
6#include <linux/types.h>
7#include <linux/bitops.h>
8#include <linux/string.h>
9
10/*
11 * bitmaps provide bit arrays that consume one or more unsigned
12 * longs. The bitmap interface and available operations are listed
13 * here, in bitmap.h
14 *
15 * Function implementations generic to all architectures are in
16 * lib/bitmap.c. Functions implementations that are architecture
17 * specific are in various include/asm-<arch>/bitops.h headers
18 * and other arch/<arch> specific files.
19 *
20 * See lib/bitmap.c for more details.
21 */
22
23/*
24 * The available bitmap operations and their rough meaning in the
25 * case that the bitmap is a single unsigned long are thus:
26 *
27 * bitmap_zero(dst, nbits) *dst = 0UL
28 * bitmap_fill(dst, nbits) *dst = ~0UL
29 * bitmap_copy(dst, src, nbits) *dst = *src
30 * bitmap_and(dst, src1, src2, nbits) *dst = *src1 & *src2
31 * bitmap_or(dst, src1, src2, nbits) *dst = *src1 | *src2
32 * bitmap_xor(dst, src1, src2, nbits) *dst = *src1 ^ *src2
33 * bitmap_andnot(dst, src1, src2, nbits) *dst = *src1 & ~(*src2)
34 * bitmap_complement(dst, src, nbits) *dst = ~(*src)
35 * bitmap_equal(src1, src2, nbits) Are *src1 and *src2 equal?
36 * bitmap_intersects(src1, src2, nbits) Do *src1 and *src2 overlap?
37 * bitmap_subset(src1, src2, nbits) Is *src1 a subset of *src2?
38 * bitmap_empty(src, nbits) Are all bits zero in *src?
39 * bitmap_full(src, nbits) Are all bits set in *src?
40 * bitmap_weight(src, nbits) Hamming Weight: number set bits
41 * bitmap_shift_right(dst, src, n, nbits) *dst = *src >> n
42 * bitmap_shift_left(dst, src, n, nbits) *dst = *src << n
43 * bitmap_scnprintf(buf, len, src, nbits) Print bitmap src to buf
44 * bitmap_parse(ubuf, ulen, dst, nbits) Parse bitmap dst from user buf
45 * bitmap_scnlistprintf(buf, len, src, nbits) Print bitmap src as list to buf
46 * bitmap_parselist(buf, dst, nbits) Parse bitmap dst from list
47 */
48
49/*
50 * Also the following operations in asm/bitops.h apply to bitmaps.
51 *
52 * set_bit(bit, addr) *addr |= bit
53 * clear_bit(bit, addr) *addr &= ~bit
54 * change_bit(bit, addr) *addr ^= bit
55 * test_bit(bit, addr) Is bit set in *addr?
56 * test_and_set_bit(bit, addr) Set bit and return old value
57 * test_and_clear_bit(bit, addr) Clear bit and return old value
58 * test_and_change_bit(bit, addr) Change bit and return old value
59 * find_first_zero_bit(addr, nbits) Position first zero bit in *addr
60 * find_first_bit(addr, nbits) Position first set bit in *addr
61 * find_next_zero_bit(addr, nbits, bit) Position next zero bit in *addr >= bit
62 * find_next_bit(addr, nbits, bit) Position next set bit in *addr >= bit
63 */
64
65/*
66 * The DECLARE_BITMAP(name,bits) macro, in linux/types.h, can be used
67 * to declare an array named 'name' of just enough unsigned longs to
68 * contain all bit positions from 0 to 'bits' - 1.
69 */
70
71/*
72 * lib/bitmap.c provides these functions:
73 */
74
75extern int __bitmap_empty(const unsigned long *bitmap, int bits);
76extern int __bitmap_full(const unsigned long *bitmap, int bits);
77extern int __bitmap_equal(const unsigned long *bitmap1,
78 const unsigned long *bitmap2, int bits);
79extern void __bitmap_complement(unsigned long *dst, const unsigned long *src,
80 int bits);
81extern void __bitmap_shift_right(unsigned long *dst,
82 const unsigned long *src, int shift, int bits);
83extern void __bitmap_shift_left(unsigned long *dst,
84 const unsigned long *src, int shift, int bits);
85extern void __bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
86 const unsigned long *bitmap2, int bits);
87extern void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
88 const unsigned long *bitmap2, int bits);
89extern void __bitmap_xor(unsigned long *dst, const unsigned long *bitmap1,
90 const unsigned long *bitmap2, int bits);
91extern void __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1,
92 const unsigned long *bitmap2, int bits);
93extern int __bitmap_intersects(const unsigned long *bitmap1,
94 const unsigned long *bitmap2, int bits);
95extern int __bitmap_subset(const unsigned long *bitmap1,
96 const unsigned long *bitmap2, int bits);
97extern int __bitmap_weight(const unsigned long *bitmap, int bits);
98
99extern int bitmap_scnprintf(char *buf, unsigned int len,
100 const unsigned long *src, int nbits);
101extern int bitmap_parse(const char __user *ubuf, unsigned int ulen,
102 unsigned long *dst, int nbits);
103extern int bitmap_scnlistprintf(char *buf, unsigned int len,
104 const unsigned long *src, int nbits);
105extern int bitmap_parselist(const char *buf, unsigned long *maskp,
106 int nmaskbits);
107extern int bitmap_find_free_region(unsigned long *bitmap, int bits, int order);
108extern void bitmap_release_region(unsigned long *bitmap, int pos, int order);
109extern int bitmap_allocate_region(unsigned long *bitmap, int pos, int order);
110
111#define BITMAP_LAST_WORD_MASK(nbits) \
112( \
113 ((nbits) % BITS_PER_LONG) ? \
114 (1UL<<((nbits) % BITS_PER_LONG))-1 : ~0UL \
115)
116
117static inline void bitmap_zero(unsigned long *dst, int nbits)
118{
119 if (nbits <= BITS_PER_LONG)
120 *dst = 0UL;
121 else {
122 int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
123 memset(dst, 0, len);
124 }
125}
126
127static inline void bitmap_fill(unsigned long *dst, int nbits)
128{
129 size_t nlongs = BITS_TO_LONGS(nbits);
130 if (nlongs > 1) {
131 int len = (nlongs - 1) * sizeof(unsigned long);
132 memset(dst, 0xff, len);
133 }
134 dst[nlongs - 1] = BITMAP_LAST_WORD_MASK(nbits);
135}
136
137static inline void bitmap_copy(unsigned long *dst, const unsigned long *src,
138 int nbits)
139{
140 if (nbits <= BITS_PER_LONG)
141 *dst = *src;
142 else {
143 int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
144 memcpy(dst, src, len);
145 }
146}
147
148static inline void bitmap_and(unsigned long *dst, const unsigned long *src1,
149 const unsigned long *src2, int nbits)
150{
151 if (nbits <= BITS_PER_LONG)
152 *dst = *src1 & *src2;
153 else
154 __bitmap_and(dst, src1, src2, nbits);
155}
156
157static inline void bitmap_or(unsigned long *dst, const unsigned long *src1,
158 const unsigned long *src2, int nbits)
159{
160 if (nbits <= BITS_PER_LONG)
161 *dst = *src1 | *src2;
162 else
163 __bitmap_or(dst, src1, src2, nbits);
164}
165
166static inline void bitmap_xor(unsigned long *dst, const unsigned long *src1,
167 const unsigned long *src2, int nbits)
168{
169 if (nbits <= BITS_PER_LONG)
170 *dst = *src1 ^ *src2;
171 else
172 __bitmap_xor(dst, src1, src2, nbits);
173}
174
175static inline void bitmap_andnot(unsigned long *dst, const unsigned long *src1,
176 const unsigned long *src2, int nbits)
177{
178 if (nbits <= BITS_PER_LONG)
179 *dst = *src1 & ~(*src2);
180 else
181 __bitmap_andnot(dst, src1, src2, nbits);
182}
183
184static inline void bitmap_complement(unsigned long *dst, const unsigned long *src,
185 int nbits)
186{
187 if (nbits <= BITS_PER_LONG)
188 *dst = ~(*src) & BITMAP_LAST_WORD_MASK(nbits);
189 else
190 __bitmap_complement(dst, src, nbits);
191}
192
193static inline int bitmap_equal(const unsigned long *src1,
194 const unsigned long *src2, int nbits)
195{
196 if (nbits <= BITS_PER_LONG)
197 return ! ((*src1 ^ *src2) & BITMAP_LAST_WORD_MASK(nbits));
198 else
199 return __bitmap_equal(src1, src2, nbits);
200}
201
202static inline int bitmap_intersects(const unsigned long *src1,
203 const unsigned long *src2, int nbits)
204{
205 if (nbits <= BITS_PER_LONG)
206 return ((*src1 & *src2) & BITMAP_LAST_WORD_MASK(nbits)) != 0;
207 else
208 return __bitmap_intersects(src1, src2, nbits);
209}
210
211static inline int bitmap_subset(const unsigned long *src1,
212 const unsigned long *src2, int nbits)
213{
214 if (nbits <= BITS_PER_LONG)
215 return ! ((*src1 & ~(*src2)) & BITMAP_LAST_WORD_MASK(nbits));
216 else
217 return __bitmap_subset(src1, src2, nbits);
218}
219
220static inline int bitmap_empty(const unsigned long *src, int nbits)
221{
222 if (nbits <= BITS_PER_LONG)
223 return ! (*src & BITMAP_LAST_WORD_MASK(nbits));
224 else
225 return __bitmap_empty(src, nbits);
226}
227
228static inline int bitmap_full(const unsigned long *src, int nbits)
229{
230 if (nbits <= BITS_PER_LONG)
231 return ! (~(*src) & BITMAP_LAST_WORD_MASK(nbits));
232 else
233 return __bitmap_full(src, nbits);
234}
235
236static inline int bitmap_weight(const unsigned long *src, int nbits)
237{
238 return __bitmap_weight(src, nbits);
239}
240
241static inline void bitmap_shift_right(unsigned long *dst,
242 const unsigned long *src, int n, int nbits)
243{
244 if (nbits <= BITS_PER_LONG)
245 *dst = *src >> n;
246 else
247 __bitmap_shift_right(dst, src, n, nbits);
248}
249
250static inline void bitmap_shift_left(unsigned long *dst,
251 const unsigned long *src, int n, int nbits)
252{
253 if (nbits <= BITS_PER_LONG)
254 *dst = (*src << n) & BITMAP_LAST_WORD_MASK(nbits);
255 else
256 __bitmap_shift_left(dst, src, n, nbits);
257}
258
259#endif /* __ASSEMBLY__ */
260
261#endif /* __LINUX_BITMAP_H */
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
new file mode 100644
index 000000000000..cb3c3ef50f50
--- /dev/null
+++ b/include/linux/bitops.h
@@ -0,0 +1,159 @@
1#ifndef _LINUX_BITOPS_H
2#define _LINUX_BITOPS_H
3#include <asm/types.h>
4
5/*
6 * ffs: find first bit set. This is defined the same way as
7 * the libc and compiler builtin ffs routines, therefore
8 * differs in spirit from the above ffz (man ffs).
9 */
10
11static inline int generic_ffs(int x)
12{
13 int r = 1;
14
15 if (!x)
16 return 0;
17 if (!(x & 0xffff)) {
18 x >>= 16;
19 r += 16;
20 }
21 if (!(x & 0xff)) {
22 x >>= 8;
23 r += 8;
24 }
25 if (!(x & 0xf)) {
26 x >>= 4;
27 r += 4;
28 }
29 if (!(x & 3)) {
30 x >>= 2;
31 r += 2;
32 }
33 if (!(x & 1)) {
34 x >>= 1;
35 r += 1;
36 }
37 return r;
38}
39
40/*
41 * fls: find last bit set.
42 */
43
44static __inline__ int generic_fls(int x)
45{
46 int r = 32;
47
48 if (!x)
49 return 0;
50 if (!(x & 0xffff0000u)) {
51 x <<= 16;
52 r -= 16;
53 }
54 if (!(x & 0xff000000u)) {
55 x <<= 8;
56 r -= 8;
57 }
58 if (!(x & 0xf0000000u)) {
59 x <<= 4;
60 r -= 4;
61 }
62 if (!(x & 0xc0000000u)) {
63 x <<= 2;
64 r -= 2;
65 }
66 if (!(x & 0x80000000u)) {
67 x <<= 1;
68 r -= 1;
69 }
70 return r;
71}
72
73/*
74 * Include this here because some architectures need generic_ffs/fls in
75 * scope
76 */
77#include <asm/bitops.h>
78
79static __inline__ int get_bitmask_order(unsigned int count)
80{
81 int order;
82
83 order = fls(count);
84 return order; /* We could be slightly more clever with -1 here... */
85}
86
87/*
88 * hweightN: returns the hamming weight (i.e. the number
89 * of bits set) of a N-bit word
90 */
91
92static inline unsigned int generic_hweight32(unsigned int w)
93{
94 unsigned int res = (w & 0x55555555) + ((w >> 1) & 0x55555555);
95 res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
96 res = (res & 0x0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F);
97 res = (res & 0x00FF00FF) + ((res >> 8) & 0x00FF00FF);
98 return (res & 0x0000FFFF) + ((res >> 16) & 0x0000FFFF);
99}
100
101static inline unsigned int generic_hweight16(unsigned int w)
102{
103 unsigned int res = (w & 0x5555) + ((w >> 1) & 0x5555);
104 res = (res & 0x3333) + ((res >> 2) & 0x3333);
105 res = (res & 0x0F0F) + ((res >> 4) & 0x0F0F);
106 return (res & 0x00FF) + ((res >> 8) & 0x00FF);
107}
108
109static inline unsigned int generic_hweight8(unsigned int w)
110{
111 unsigned int res = (w & 0x55) + ((w >> 1) & 0x55);
112 res = (res & 0x33) + ((res >> 2) & 0x33);
113 return (res & 0x0F) + ((res >> 4) & 0x0F);
114}
115
116static inline unsigned long generic_hweight64(__u64 w)
117{
118#if BITS_PER_LONG < 64
119 return generic_hweight32((unsigned int)(w >> 32)) +
120 generic_hweight32((unsigned int)w);
121#else
122 u64 res;
123 res = (w & 0x5555555555555555ul) + ((w >> 1) & 0x5555555555555555ul);
124 res = (res & 0x3333333333333333ul) + ((res >> 2) & 0x3333333333333333ul);
125 res = (res & 0x0F0F0F0F0F0F0F0Ful) + ((res >> 4) & 0x0F0F0F0F0F0F0F0Ful);
126 res = (res & 0x00FF00FF00FF00FFul) + ((res >> 8) & 0x00FF00FF00FF00FFul);
127 res = (res & 0x0000FFFF0000FFFFul) + ((res >> 16) & 0x0000FFFF0000FFFFul);
128 return (res & 0x00000000FFFFFFFFul) + ((res >> 32) & 0x00000000FFFFFFFFul);
129#endif
130}
131
132static inline unsigned long hweight_long(unsigned long w)
133{
134 return sizeof(w) == 4 ? generic_hweight32(w) : generic_hweight64(w);
135}
136
137/*
138 * rol32 - rotate a 32-bit value left
139 *
140 * @word: value to rotate
141 * @shift: bits to roll
142 */
143static inline __u32 rol32(__u32 word, unsigned int shift)
144{
145 return (word << shift) | (word >> (32 - shift));
146}
147
148/*
149 * ror32 - rotate a 32-bit value right
150 *
151 * @word: value to rotate
152 * @shift: bits to roll
153 */
154static inline __u32 ror32(__u32 word, unsigned int shift)
155{
156 return (word >> shift) | (word << (32 - shift));
157}
158
159#endif
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
new file mode 100644
index 000000000000..70ac2860a605
--- /dev/null
+++ b/include/linux/blkdev.h
@@ -0,0 +1,759 @@
1#ifndef _LINUX_BLKDEV_H
2#define _LINUX_BLKDEV_H
3
4#include <linux/config.h>
5#include <linux/major.h>
6#include <linux/genhd.h>
7#include <linux/list.h>
8#include <linux/timer.h>
9#include <linux/workqueue.h>
10#include <linux/pagemap.h>
11#include <linux/backing-dev.h>
12#include <linux/wait.h>
13#include <linux/mempool.h>
14#include <linux/bio.h>
15#include <linux/module.h>
16#include <linux/stringify.h>
17
18#include <asm/scatterlist.h>
19
20struct request_queue;
21typedef struct request_queue request_queue_t;
22struct elevator_queue;
23typedef struct elevator_queue elevator_t;
24struct request_pm_state;
25
26#define BLKDEV_MIN_RQ 4
27#define BLKDEV_MAX_RQ 128 /* Default maximum */
28
29/*
30 * This is the per-process anticipatory I/O scheduler state.
31 */
32struct as_io_context {
33 spinlock_t lock;
34
35 void (*dtor)(struct as_io_context *aic); /* destructor */
36 void (*exit)(struct as_io_context *aic); /* called on task exit */
37
38 unsigned long state;
39 atomic_t nr_queued; /* queued reads & sync writes */
40 atomic_t nr_dispatched; /* number of requests gone to the drivers */
41
42 /* IO History tracking */
43 /* Thinktime */
44 unsigned long last_end_request;
45 unsigned long ttime_total;
46 unsigned long ttime_samples;
47 unsigned long ttime_mean;
48 /* Layout pattern */
49 unsigned int seek_samples;
50 sector_t last_request_pos;
51 u64 seek_total;
52 sector_t seek_mean;
53};
54
55struct cfq_queue;
56struct cfq_io_context {
57 void (*dtor)(struct cfq_io_context *);
58 void (*exit)(struct cfq_io_context *);
59
60 struct io_context *ioc;
61
62 /*
63 * circular list of cfq_io_contexts belonging to a process io context
64 */
65 struct list_head list;
66 struct cfq_queue *cfqq;
67};
68
69/*
70 * This is the per-process I/O subsystem state. It is refcounted and
71 * kmalloc'ed. Currently all fields are modified in process io context
72 * (apart from the atomic refcount), so require no locking.
73 */
74struct io_context {
75 atomic_t refcount;
76 pid_t pid;
77
78 /*
79 * For request batching
80 */
81 unsigned long last_waited; /* Time last woken after wait for request */
82 int nr_batch_requests; /* Number of requests left in the batch */
83
84 spinlock_t lock;
85
86 struct as_io_context *aic;
87 struct cfq_io_context *cic;
88};
89
90void put_io_context(struct io_context *ioc);
91void exit_io_context(void);
92struct io_context *get_io_context(int gfp_flags);
93void copy_io_context(struct io_context **pdst, struct io_context **psrc);
94void swap_io_context(struct io_context **ioc1, struct io_context **ioc2);
95
96struct request;
97typedef void (rq_end_io_fn)(struct request *);
98
99struct request_list {
100 int count[2];
101 int starved[2];
102 mempool_t *rq_pool;
103 wait_queue_head_t wait[2];
104 wait_queue_head_t drain;
105};
106
107#define BLK_MAX_CDB 16
108
109/*
110 * try to put the fields that are referenced together in the same cacheline
111 */
112struct request {
113 struct list_head queuelist; /* looking for ->queue? you must _not_
114 * access it directly, use
115 * blkdev_dequeue_request! */
116 unsigned long flags; /* see REQ_ bits below */
117
118 /* Maintain bio traversal state for part by part I/O submission.
119 * hard_* are block layer internals, no driver should touch them!
120 */
121
122 sector_t sector; /* next sector to submit */
123 unsigned long nr_sectors; /* no. of sectors left to submit */
124 /* no. of sectors left to submit in the current segment */
125 unsigned int current_nr_sectors;
126
127 sector_t hard_sector; /* next sector to complete */
128 unsigned long hard_nr_sectors; /* no. of sectors left to complete */
129 /* no. of sectors left to complete in the current segment */
130 unsigned int hard_cur_sectors;
131
132 struct bio *bio;
133 struct bio *biotail;
134
135 void *elevator_private;
136
137 int rq_status; /* should split this into a few status bits */
138 struct gendisk *rq_disk;
139 int errors;
140 unsigned long start_time;
141
142 /* Number of scatter-gather DMA addr+len pairs after
143 * physical address coalescing is performed.
144 */
145 unsigned short nr_phys_segments;
146
147 /* Number of scatter-gather addr+len pairs after
148 * physical and DMA remapping hardware coalescing is performed.
149 * This is the number of scatter-gather entries the driver
150 * will actually have to deal with after DMA mapping is done.
151 */
152 unsigned short nr_hw_segments;
153
154 int tag;
155 char *buffer;
156
157 int ref_count;
158 request_queue_t *q;
159 struct request_list *rl;
160
161 struct completion *waiting;
162 void *special;
163
164 /*
165 * when request is used as a packet command carrier
166 */
167 unsigned int cmd_len;
168 unsigned char cmd[BLK_MAX_CDB];
169
170 unsigned int data_len;
171 void *data;
172
173 unsigned int sense_len;
174 void *sense;
175
176 unsigned int timeout;
177
178 /*
179 * For Power Management requests
180 */
181 struct request_pm_state *pm;
182
183 /*
184 * completion callback. end_io_data should be folded in with waiting
185 */
186 rq_end_io_fn *end_io;
187 void *end_io_data;
188};
189
190/*
191 * first three bits match BIO_RW* bits, important
192 */
193enum rq_flag_bits {
194 __REQ_RW, /* not set, read. set, write */
195 __REQ_FAILFAST, /* no low level driver retries */
196 __REQ_SOFTBARRIER, /* may not be passed by ioscheduler */
197 __REQ_HARDBARRIER, /* may not be passed by drive either */
198 __REQ_CMD, /* is a regular fs rw request */
199 __REQ_NOMERGE, /* don't touch this for merging */
200 __REQ_STARTED, /* drive already may have started this one */
201 __REQ_DONTPREP, /* don't call prep for this one */
202 __REQ_QUEUED, /* uses queueing */
203 /*
204 * for ATA/ATAPI devices
205 */
206 __REQ_PC, /* packet command (special) */
207 __REQ_BLOCK_PC, /* queued down pc from block layer */
208 __REQ_SENSE, /* sense retrival */
209
210 __REQ_FAILED, /* set if the request failed */
211 __REQ_QUIET, /* don't worry about errors */
212 __REQ_SPECIAL, /* driver suplied command */
213 __REQ_DRIVE_CMD,
214 __REQ_DRIVE_TASK,
215 __REQ_DRIVE_TASKFILE,
216 __REQ_PREEMPT, /* set for "ide_preempt" requests */
217 __REQ_PM_SUSPEND, /* suspend request */
218 __REQ_PM_RESUME, /* resume request */
219 __REQ_PM_SHUTDOWN, /* shutdown request */
220 __REQ_BAR_PREFLUSH, /* barrier pre-flush done */
221 __REQ_BAR_POSTFLUSH, /* barrier post-flush */
222 __REQ_BAR_FLUSH, /* rq is the flush request */
223 __REQ_NR_BITS, /* stops here */
224};
225
226#define REQ_RW (1 << __REQ_RW)
227#define REQ_FAILFAST (1 << __REQ_FAILFAST)
228#define REQ_SOFTBARRIER (1 << __REQ_SOFTBARRIER)
229#define REQ_HARDBARRIER (1 << __REQ_HARDBARRIER)
230#define REQ_CMD (1 << __REQ_CMD)
231#define REQ_NOMERGE (1 << __REQ_NOMERGE)
232#define REQ_STARTED (1 << __REQ_STARTED)
233#define REQ_DONTPREP (1 << __REQ_DONTPREP)
234#define REQ_QUEUED (1 << __REQ_QUEUED)
235#define REQ_PC (1 << __REQ_PC)
236#define REQ_BLOCK_PC (1 << __REQ_BLOCK_PC)
237#define REQ_SENSE (1 << __REQ_SENSE)
238#define REQ_FAILED (1 << __REQ_FAILED)
239#define REQ_QUIET (1 << __REQ_QUIET)
240#define REQ_SPECIAL (1 << __REQ_SPECIAL)
241#define REQ_DRIVE_CMD (1 << __REQ_DRIVE_CMD)
242#define REQ_DRIVE_TASK (1 << __REQ_DRIVE_TASK)
243#define REQ_DRIVE_TASKFILE (1 << __REQ_DRIVE_TASKFILE)
244#define REQ_PREEMPT (1 << __REQ_PREEMPT)
245#define REQ_PM_SUSPEND (1 << __REQ_PM_SUSPEND)
246#define REQ_PM_RESUME (1 << __REQ_PM_RESUME)
247#define REQ_PM_SHUTDOWN (1 << __REQ_PM_SHUTDOWN)
248#define REQ_BAR_PREFLUSH (1 << __REQ_BAR_PREFLUSH)
249#define REQ_BAR_POSTFLUSH (1 << __REQ_BAR_POSTFLUSH)
250#define REQ_BAR_FLUSH (1 << __REQ_BAR_FLUSH)
251
252/*
253 * State information carried for REQ_PM_SUSPEND and REQ_PM_RESUME
254 * requests. Some step values could eventually be made generic.
255 */
256struct request_pm_state
257{
258 /* PM state machine step value, currently driver specific */
259 int pm_step;
260 /* requested PM state value (S1, S2, S3, S4, ...) */
261 u32 pm_state;
262 void* data; /* for driver use */
263};
264
265#include <linux/elevator.h>
266
267typedef int (merge_request_fn) (request_queue_t *, struct request *,
268 struct bio *);
269typedef int (merge_requests_fn) (request_queue_t *, struct request *,
270 struct request *);
271typedef void (request_fn_proc) (request_queue_t *q);
272typedef int (make_request_fn) (request_queue_t *q, struct bio *bio);
273typedef int (prep_rq_fn) (request_queue_t *, struct request *);
274typedef void (unplug_fn) (request_queue_t *);
275
276struct bio_vec;
277typedef int (merge_bvec_fn) (request_queue_t *, struct bio *, struct bio_vec *);
278typedef void (activity_fn) (void *data, int rw);
279typedef int (issue_flush_fn) (request_queue_t *, struct gendisk *, sector_t *);
280typedef int (prepare_flush_fn) (request_queue_t *, struct request *);
281typedef void (end_flush_fn) (request_queue_t *, struct request *);
282
283enum blk_queue_state {
284 Queue_down,
285 Queue_up,
286};
287
288#define BLK_TAGS_PER_LONG (sizeof(unsigned long) * 8)
289#define BLK_TAGS_MASK (BLK_TAGS_PER_LONG - 1)
290
291struct blk_queue_tag {
292 struct request **tag_index; /* map of busy tags */
293 unsigned long *tag_map; /* bit map of free/busy tags */
294 struct list_head busy_list; /* fifo list of busy tags */
295 int busy; /* current depth */
296 int max_depth; /* what we will send to device */
297 int real_max_depth; /* what the array can hold */
298 atomic_t refcnt; /* map can be shared */
299};
300
301struct request_queue
302{
303 /*
304 * Together with queue_head for cacheline sharing
305 */
306 struct list_head queue_head;
307 struct request *last_merge;
308 elevator_t *elevator;
309
310 /*
311 * the queue request freelist, one for reads and one for writes
312 */
313 struct request_list rq;
314
315 request_fn_proc *request_fn;
316 merge_request_fn *back_merge_fn;
317 merge_request_fn *front_merge_fn;
318 merge_requests_fn *merge_requests_fn;
319 make_request_fn *make_request_fn;
320 prep_rq_fn *prep_rq_fn;
321 unplug_fn *unplug_fn;
322 merge_bvec_fn *merge_bvec_fn;
323 activity_fn *activity_fn;
324 issue_flush_fn *issue_flush_fn;
325 prepare_flush_fn *prepare_flush_fn;
326 end_flush_fn *end_flush_fn;
327
328 /*
329 * Auto-unplugging state
330 */
331 struct timer_list unplug_timer;
332 int unplug_thresh; /* After this many requests */
333 unsigned long unplug_delay; /* After this many jiffies */
334 struct work_struct unplug_work;
335
336 struct backing_dev_info backing_dev_info;
337
338 /*
339 * The queue owner gets to use this for whatever they like.
340 * ll_rw_blk doesn't touch it.
341 */
342 void *queuedata;
343
344 void *activity_data;
345
346 /*
347 * queue needs bounce pages for pages above this limit
348 */
349 unsigned long bounce_pfn;
350 unsigned int bounce_gfp;
351
352 /*
353 * various queue flags, see QUEUE_* below
354 */
355 unsigned long queue_flags;
356
357 /*
358 * protects queue structures from reentrancy
359 */
360 spinlock_t *queue_lock;
361
362 /*
363 * queue kobject
364 */
365 struct kobject kobj;
366
367 /*
368 * queue settings
369 */
370 unsigned long nr_requests; /* Max # of requests */
371 unsigned int nr_congestion_on;
372 unsigned int nr_congestion_off;
373 unsigned int nr_batching;
374
375 unsigned short max_sectors;
376 unsigned short max_hw_sectors;
377 unsigned short max_phys_segments;
378 unsigned short max_hw_segments;
379 unsigned short hardsect_size;
380 unsigned int max_segment_size;
381
382 unsigned long seg_boundary_mask;
383 unsigned int dma_alignment;
384
385 struct blk_queue_tag *queue_tags;
386
387 atomic_t refcnt;
388
389 unsigned int in_flight;
390
391 /*
392 * sg stuff
393 */
394 unsigned int sg_timeout;
395 unsigned int sg_reserved_size;
396
397 struct list_head drain_list;
398
399 /*
400 * reserved for flush operations
401 */
402 struct request *flush_rq;
403 unsigned char ordered;
404};
405
406enum {
407 QUEUE_ORDERED_NONE,
408 QUEUE_ORDERED_TAG,
409 QUEUE_ORDERED_FLUSH,
410};
411
412#define RQ_INACTIVE (-1)
413#define RQ_ACTIVE 1
414#define RQ_SCSI_BUSY 0xffff
415#define RQ_SCSI_DONE 0xfffe
416#define RQ_SCSI_DISCONNECTING 0xffe0
417
418#define QUEUE_FLAG_CLUSTER 0 /* cluster several segments into 1 */
419#define QUEUE_FLAG_QUEUED 1 /* uses generic tag queueing */
420#define QUEUE_FLAG_STOPPED 2 /* queue is stopped */
421#define QUEUE_FLAG_READFULL 3 /* write queue has been filled */
422#define QUEUE_FLAG_WRITEFULL 4 /* read queue has been filled */
423#define QUEUE_FLAG_DEAD 5 /* queue being torn down */
424#define QUEUE_FLAG_REENTER 6 /* Re-entrancy avoidance */
425#define QUEUE_FLAG_PLUGGED 7 /* queue is plugged */
426#define QUEUE_FLAG_DRAIN 8 /* draining queue for sched switch */
427#define QUEUE_FLAG_FLUSH 9 /* doing barrier flush sequence */
428
429#define blk_queue_plugged(q) test_bit(QUEUE_FLAG_PLUGGED, &(q)->queue_flags)
430#define blk_queue_tagged(q) test_bit(QUEUE_FLAG_QUEUED, &(q)->queue_flags)
431#define blk_queue_stopped(q) test_bit(QUEUE_FLAG_STOPPED, &(q)->queue_flags)
432#define blk_queue_flushing(q) test_bit(QUEUE_FLAG_FLUSH, &(q)->queue_flags)
433
434#define blk_fs_request(rq) ((rq)->flags & REQ_CMD)
435#define blk_pc_request(rq) ((rq)->flags & REQ_BLOCK_PC)
436#define blk_noretry_request(rq) ((rq)->flags & REQ_FAILFAST)
437#define blk_rq_started(rq) ((rq)->flags & REQ_STARTED)
438
439#define blk_account_rq(rq) (blk_rq_started(rq) && blk_fs_request(rq))
440
441#define blk_pm_suspend_request(rq) ((rq)->flags & REQ_PM_SUSPEND)
442#define blk_pm_resume_request(rq) ((rq)->flags & REQ_PM_RESUME)
443#define blk_pm_request(rq) \
444 ((rq)->flags & (REQ_PM_SUSPEND | REQ_PM_RESUME))
445
446#define blk_barrier_rq(rq) ((rq)->flags & REQ_HARDBARRIER)
447#define blk_barrier_preflush(rq) ((rq)->flags & REQ_BAR_PREFLUSH)
448#define blk_barrier_postflush(rq) ((rq)->flags & REQ_BAR_POSTFLUSH)
449
450#define list_entry_rq(ptr) list_entry((ptr), struct request, queuelist)
451
452#define rq_data_dir(rq) ((rq)->flags & 1)
453
454static inline int blk_queue_full(struct request_queue *q, int rw)
455{
456 if (rw == READ)
457 return test_bit(QUEUE_FLAG_READFULL, &q->queue_flags);
458 return test_bit(QUEUE_FLAG_WRITEFULL, &q->queue_flags);
459}
460
461static inline void blk_set_queue_full(struct request_queue *q, int rw)
462{
463 if (rw == READ)
464 set_bit(QUEUE_FLAG_READFULL, &q->queue_flags);
465 else
466 set_bit(QUEUE_FLAG_WRITEFULL, &q->queue_flags);
467}
468
469static inline void blk_clear_queue_full(struct request_queue *q, int rw)
470{
471 if (rw == READ)
472 clear_bit(QUEUE_FLAG_READFULL, &q->queue_flags);
473 else
474 clear_bit(QUEUE_FLAG_WRITEFULL, &q->queue_flags);
475}
476
477
478/*
479 * mergeable request must not have _NOMERGE or _BARRIER bit set, nor may
480 * it already be started by driver.
481 */
482#define RQ_NOMERGE_FLAGS \
483 (REQ_NOMERGE | REQ_STARTED | REQ_HARDBARRIER | REQ_SOFTBARRIER)
484#define rq_mergeable(rq) \
485 (!((rq)->flags & RQ_NOMERGE_FLAGS) && blk_fs_request((rq)))
486
487/*
488 * noop, requests are automagically marked as active/inactive by I/O
489 * scheduler -- see elv_next_request
490 */
491#define blk_queue_headactive(q, head_active)
492
493/*
494 * q->prep_rq_fn return values
495 */
496#define BLKPREP_OK 0 /* serve it */
497#define BLKPREP_KILL 1 /* fatal error, kill */
498#define BLKPREP_DEFER 2 /* leave on queue */
499
500extern unsigned long blk_max_low_pfn, blk_max_pfn;
501
502/*
503 * standard bounce addresses:
504 *
505 * BLK_BOUNCE_HIGH : bounce all highmem pages
506 * BLK_BOUNCE_ANY : don't bounce anything
507 * BLK_BOUNCE_ISA : bounce pages above ISA DMA boundary
508 */
509#define BLK_BOUNCE_HIGH ((u64)blk_max_low_pfn << PAGE_SHIFT)
510#define BLK_BOUNCE_ANY ((u64)blk_max_pfn << PAGE_SHIFT)
511#define BLK_BOUNCE_ISA (ISA_DMA_THRESHOLD)
512
513#ifdef CONFIG_MMU
514extern int init_emergency_isa_pool(void);
515extern void blk_queue_bounce(request_queue_t *q, struct bio **bio);
516#else
517static inline int init_emergency_isa_pool(void)
518{
519 return 0;
520}
521static inline void blk_queue_bounce(request_queue_t *q, struct bio **bio)
522{
523}
524#endif /* CONFIG_MMU */
525
526#define rq_for_each_bio(_bio, rq) \
527 if ((rq->bio)) \
528 for (_bio = (rq)->bio; _bio; _bio = _bio->bi_next)
529
530struct sec_size {
531 unsigned block_size;
532 unsigned block_size_bits;
533};
534
535extern int blk_register_queue(struct gendisk *disk);
536extern void blk_unregister_queue(struct gendisk *disk);
537extern void register_disk(struct gendisk *dev);
538extern void generic_make_request(struct bio *bio);
539extern void blk_put_request(struct request *);
540extern void blk_end_sync_rq(struct request *rq);
541extern void blk_attempt_remerge(request_queue_t *, struct request *);
542extern void __blk_attempt_remerge(request_queue_t *, struct request *);
543extern struct request *blk_get_request(request_queue_t *, int, int);
544extern void blk_insert_request(request_queue_t *, struct request *, int, void *, int);
545extern void blk_requeue_request(request_queue_t *, struct request *);
546extern void blk_plug_device(request_queue_t *);
547extern int blk_remove_plug(request_queue_t *);
548extern void blk_recount_segments(request_queue_t *, struct bio *);
549extern int blk_phys_contig_segment(request_queue_t *q, struct bio *, struct bio *);
550extern int blk_hw_contig_segment(request_queue_t *q, struct bio *, struct bio *);
551extern int scsi_cmd_ioctl(struct file *, struct gendisk *, unsigned int, void __user *);
552extern void blk_start_queue(request_queue_t *q);
553extern void blk_stop_queue(request_queue_t *q);
554extern void blk_sync_queue(struct request_queue *q);
555extern void __blk_stop_queue(request_queue_t *q);
556extern void blk_run_queue(request_queue_t *);
557extern void blk_queue_activity_fn(request_queue_t *, activity_fn *, void *);
558extern struct request *blk_rq_map_user(request_queue_t *, int, void __user *, unsigned int);
559extern int blk_rq_unmap_user(struct request *, struct bio *, unsigned int);
560extern int blk_execute_rq(request_queue_t *, struct gendisk *, struct request *);
561
562static inline request_queue_t *bdev_get_queue(struct block_device *bdev)
563{
564 return bdev->bd_disk->queue;
565}
566
567static inline void blk_run_backing_dev(struct backing_dev_info *bdi,
568 struct page *page)
569{
570 if (bdi && bdi->unplug_io_fn)
571 bdi->unplug_io_fn(bdi, page);
572}
573
574static inline void blk_run_address_space(struct address_space *mapping)
575{
576 if (mapping)
577 blk_run_backing_dev(mapping->backing_dev_info, NULL);
578}
579
580/*
581 * end_request() and friends. Must be called with the request queue spinlock
582 * acquired. All functions called within end_request() _must_be_ atomic.
583 *
584 * Several drivers define their own end_request and call
585 * end_that_request_first() and end_that_request_last()
586 * for parts of the original function. This prevents
587 * code duplication in drivers.
588 */
589extern int end_that_request_first(struct request *, int, int);
590extern int end_that_request_chunk(struct request *, int, int);
591extern void end_that_request_last(struct request *);
592extern void end_request(struct request *req, int uptodate);
593
594/*
595 * end_that_request_first/chunk() takes an uptodate argument. we account
596 * any value <= as an io error. 0 means -EIO for compatability reasons,
597 * any other < 0 value is the direct error type. An uptodate value of
598 * 1 indicates successful io completion
599 */
600#define end_io_error(uptodate) (unlikely((uptodate) <= 0))
601
602static inline void blkdev_dequeue_request(struct request *req)
603{
604 BUG_ON(list_empty(&req->queuelist));
605
606 list_del_init(&req->queuelist);
607
608 if (req->rl)
609 elv_remove_request(req->q, req);
610}
611
612/*
613 * Access functions for manipulating queue properties
614 */
615extern request_queue_t *blk_init_queue(request_fn_proc *, spinlock_t *);
616extern void blk_cleanup_queue(request_queue_t *);
617extern void blk_queue_make_request(request_queue_t *, make_request_fn *);
618extern void blk_queue_bounce_limit(request_queue_t *, u64);
619extern void blk_queue_max_sectors(request_queue_t *, unsigned short);
620extern void blk_queue_max_phys_segments(request_queue_t *, unsigned short);
621extern void blk_queue_max_hw_segments(request_queue_t *, unsigned short);
622extern void blk_queue_max_segment_size(request_queue_t *, unsigned int);
623extern void blk_queue_hardsect_size(request_queue_t *, unsigned short);
624extern void blk_queue_stack_limits(request_queue_t *t, request_queue_t *b);
625extern void blk_queue_segment_boundary(request_queue_t *, unsigned long);
626extern void blk_queue_prep_rq(request_queue_t *, prep_rq_fn *pfn);
627extern void blk_queue_merge_bvec(request_queue_t *, merge_bvec_fn *);
628extern void blk_queue_dma_alignment(request_queue_t *, int);
629extern struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev);
630extern void blk_queue_ordered(request_queue_t *, int);
631extern void blk_queue_issue_flush_fn(request_queue_t *, issue_flush_fn *);
632extern int blkdev_scsi_issue_flush_fn(request_queue_t *, struct gendisk *, sector_t *);
633extern struct request *blk_start_pre_flush(request_queue_t *,struct request *);
634extern int blk_complete_barrier_rq(request_queue_t *, struct request *, int);
635extern int blk_complete_barrier_rq_locked(request_queue_t *, struct request *, int);
636
637extern int blk_rq_map_sg(request_queue_t *, struct request *, struct scatterlist *);
638extern void blk_dump_rq_flags(struct request *, char *);
639extern void generic_unplug_device(request_queue_t *);
640extern void __generic_unplug_device(request_queue_t *);
641extern long nr_blockdev_pages(void);
642extern void blk_wait_queue_drained(request_queue_t *, int);
643extern void blk_finish_queue_drain(request_queue_t *);
644
645int blk_get_queue(request_queue_t *);
646request_queue_t *blk_alloc_queue(int);
647#define blk_put_queue(q) blk_cleanup_queue((q))
648
649/*
650 * tag stuff
651 */
652#define blk_queue_tag_depth(q) ((q)->queue_tags->busy)
653#define blk_queue_tag_queue(q) ((q)->queue_tags->busy < (q)->queue_tags->max_depth)
654#define blk_rq_tagged(rq) ((rq)->flags & REQ_QUEUED)
655extern int blk_queue_start_tag(request_queue_t *, struct request *);
656extern struct request *blk_queue_find_tag(request_queue_t *, int);
657extern void blk_queue_end_tag(request_queue_t *, struct request *);
658extern int blk_queue_init_tags(request_queue_t *, int, struct blk_queue_tag *);
659extern void blk_queue_free_tags(request_queue_t *);
660extern int blk_queue_resize_tags(request_queue_t *, int);
661extern void blk_queue_invalidate_tags(request_queue_t *);
662extern long blk_congestion_wait(int rw, long timeout);
663
664extern void blk_rq_bio_prep(request_queue_t *, struct request *, struct bio *);
665extern int blkdev_issue_flush(struct block_device *, sector_t *);
666
667#define MAX_PHYS_SEGMENTS 128
668#define MAX_HW_SEGMENTS 128
669#define MAX_SECTORS 255
670
671#define MAX_SEGMENT_SIZE 65536
672
673#define blkdev_entry_to_request(entry) list_entry((entry), struct request, queuelist)
674
675extern void drive_stat_acct(struct request *, int, int);
676
677static inline int queue_hardsect_size(request_queue_t *q)
678{
679 int retval = 512;
680
681 if (q && q->hardsect_size)
682 retval = q->hardsect_size;
683
684 return retval;
685}
686
687static inline int bdev_hardsect_size(struct block_device *bdev)
688{
689 return queue_hardsect_size(bdev_get_queue(bdev));
690}
691
692static inline int queue_dma_alignment(request_queue_t *q)
693{
694 int retval = 511;
695
696 if (q && q->dma_alignment)
697 retval = q->dma_alignment;
698
699 return retval;
700}
701
702static inline int bdev_dma_aligment(struct block_device *bdev)
703{
704 return queue_dma_alignment(bdev_get_queue(bdev));
705}
706
707#define blk_finished_io(nsects) do { } while (0)
708#define blk_started_io(nsects) do { } while (0)
709
710/* assumes size > 256 */
711static inline unsigned int blksize_bits(unsigned int size)
712{
713 unsigned int bits = 8;
714 do {
715 bits++;
716 size >>= 1;
717 } while (size > 256);
718 return bits;
719}
720
721extern inline unsigned int block_size(struct block_device *bdev)
722{
723 return bdev->bd_block_size;
724}
725
726typedef struct {struct page *v;} Sector;
727
728unsigned char *read_dev_sector(struct block_device *, sector_t, Sector *);
729
730static inline void put_dev_sector(Sector p)
731{
732 page_cache_release(p.v);
733}
734
735struct work_struct;
736int kblockd_schedule_work(struct work_struct *work);
737void kblockd_flush(void);
738
739#ifdef CONFIG_LBD
740# include <asm/div64.h>
741# define sector_div(a, b) do_div(a, b)
742#else
743# define sector_div(n, b)( \
744{ \
745 int _res; \
746 _res = (n) % (b); \
747 (n) /= (b); \
748 _res; \
749} \
750)
751#endif
752
753#define MODULE_ALIAS_BLOCKDEV(major,minor) \
754 MODULE_ALIAS("block-major-" __stringify(major) "-" __stringify(minor))
755#define MODULE_ALIAS_BLOCKDEV_MAJOR(major) \
756 MODULE_ALIAS("block-major-" __stringify(major) "-*")
757
758
759#endif
diff --git a/include/linux/blkpg.h b/include/linux/blkpg.h
new file mode 100644
index 000000000000..be5d0f4ad24c
--- /dev/null
+++ b/include/linux/blkpg.h
@@ -0,0 +1,57 @@
1#ifndef _LINUX_BLKPG_H
2#define _LINUX_BLKPG_H
3
4/*
5 * Partition table and disk geometry handling
6 *
7 * A single ioctl with lots of subfunctions:
8 *
9 * Device number stuff:
10 * get_whole_disk() (given the device number of a partition,
11 * find the device number of the encompassing disk)
12 * get_all_partitions() (given the device number of a disk, return the
13 * device numbers of all its known partitions)
14 *
15 * Partition stuff:
16 * add_partition()
17 * delete_partition()
18 * test_partition_in_use() (also for test_disk_in_use)
19 *
20 * Geometry stuff:
21 * get_geometry()
22 * set_geometry()
23 * get_bios_drivedata()
24 *
25 * For today, only the partition stuff - aeb, 990515
26 */
27#include <linux/ioctl.h>
28
29#define BLKPG _IO(0x12,105)
30
31/* The argument structure */
32struct blkpg_ioctl_arg {
33 int op;
34 int flags;
35 int datalen;
36 void __user *data;
37};
38
39/* The subfunctions (for the op field) */
40#define BLKPG_ADD_PARTITION 1
41#define BLKPG_DEL_PARTITION 2
42
43/* Sizes of name fields. Unused at present. */
44#define BLKPG_DEVNAMELTH 64
45#define BLKPG_VOLNAMELTH 64
46
47/* The data structure for ADD_PARTITION and DEL_PARTITION */
48struct blkpg_partition {
49 long long start; /* starting offset in bytes */
50 long long length; /* length in bytes */
51 int pno; /* partition number */
52 char devname[BLKPG_DEVNAMELTH]; /* partition name, like sda5 or c0d1p2,
53 to be used in kernel messages */
54 char volname[BLKPG_VOLNAMELTH]; /* volume label */
55};
56
57#endif /* _LINUX_BLKPG_H */
diff --git a/include/linux/blockgroup_lock.h b/include/linux/blockgroup_lock.h
new file mode 100644
index 000000000000..0137ee5dd43c
--- /dev/null
+++ b/include/linux/blockgroup_lock.h
@@ -0,0 +1,60 @@
1#ifndef _LINUX_BLOCKGROUP_LOCK_H
2#define _LINUX_BLOCKGROUP_LOCK_H
3/*
4 * Per-blockgroup locking for ext2 and ext3.
5 *
6 * Simple hashed spinlocking.
7 */
8
9#include <linux/config.h>
10#include <linux/spinlock.h>
11#include <linux/cache.h>
12
13#ifdef CONFIG_SMP
14
15/*
16 * We want a power-of-two. Is there a better way than this?
17 */
18
19#if NR_CPUS >= 32
20#define NR_BG_LOCKS 128
21#elif NR_CPUS >= 16
22#define NR_BG_LOCKS 64
23#elif NR_CPUS >= 8
24#define NR_BG_LOCKS 32
25#elif NR_CPUS >= 4
26#define NR_BG_LOCKS 16
27#elif NR_CPUS >= 2
28#define NR_BG_LOCKS 8
29#else
30#define NR_BG_LOCKS 4
31#endif
32
33#else /* CONFIG_SMP */
34#define NR_BG_LOCKS 1
35#endif /* CONFIG_SMP */
36
37struct bgl_lock {
38 spinlock_t lock;
39} ____cacheline_aligned_in_smp;
40
41struct blockgroup_lock {
42 struct bgl_lock locks[NR_BG_LOCKS];
43};
44
45static inline void bgl_lock_init(struct blockgroup_lock *bgl)
46{
47 int i;
48
49 for (i = 0; i < NR_BG_LOCKS; i++)
50 spin_lock_init(&bgl->locks[i].lock);
51}
52
53/*
54 * The accessor is a macro so we can embed a blockgroup_lock into different
55 * superblock types
56 */
57#define sb_bgl_lock(sb, block_group) \
58 (&(sb)->s_blockgroup_lock.locks[(block_group) & (NR_BG_LOCKS-1)].lock)
59
60#endif
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
new file mode 100644
index 000000000000..0dd8ca1a3d5a
--- /dev/null
+++ b/include/linux/bootmem.h
@@ -0,0 +1,96 @@
1/*
2 * Discontiguous memory support, Kanoj Sarcar, SGI, Nov 1999
3 */
4#ifndef _LINUX_BOOTMEM_H
5#define _LINUX_BOOTMEM_H
6
7#include <asm/pgtable.h>
8#include <asm/dma.h>
9#include <linux/cache.h>
10#include <linux/init.h>
11#include <linux/mmzone.h>
12
13/*
14 * simple boot-time physical memory area allocator.
15 */
16
17extern unsigned long max_low_pfn;
18extern unsigned long min_low_pfn;
19
20/*
21 * highest page
22 */
23extern unsigned long max_pfn;
24
25/*
26 * node_bootmem_map is a map pointer - the bits represent all physical
27 * memory pages (including holes) on the node.
28 */
29typedef struct bootmem_data {
30 unsigned long node_boot_start;
31 unsigned long node_low_pfn;
32 void *node_bootmem_map;
33 unsigned long last_offset;
34 unsigned long last_pos;
35 unsigned long last_success; /* Previous allocation point. To speed
36 * up searching */
37} bootmem_data_t;
38
39extern unsigned long __init bootmem_bootmap_pages (unsigned long);
40extern unsigned long __init init_bootmem (unsigned long addr, unsigned long memend);
41extern void __init free_bootmem (unsigned long addr, unsigned long size);
42extern void * __init __alloc_bootmem (unsigned long size, unsigned long align, unsigned long goal);
43#ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE
44extern void __init reserve_bootmem (unsigned long addr, unsigned long size);
45#define alloc_bootmem(x) \
46 __alloc_bootmem((x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
47#define alloc_bootmem_low(x) \
48 __alloc_bootmem((x), SMP_CACHE_BYTES, 0)
49#define alloc_bootmem_pages(x) \
50 __alloc_bootmem((x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
51#define alloc_bootmem_low_pages(x) \
52 __alloc_bootmem((x), PAGE_SIZE, 0)
53#endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */
54extern unsigned long __init free_all_bootmem (void);
55
56extern unsigned long __init init_bootmem_node (pg_data_t *pgdat, unsigned long freepfn, unsigned long startpfn, unsigned long endpfn);
57extern void __init reserve_bootmem_node (pg_data_t *pgdat, unsigned long physaddr, unsigned long size);
58extern void __init free_bootmem_node (pg_data_t *pgdat, unsigned long addr, unsigned long size);
59extern unsigned long __init free_all_bootmem_node (pg_data_t *pgdat);
60extern void * __init __alloc_bootmem_node (pg_data_t *pgdat, unsigned long size, unsigned long align, unsigned long goal);
61#ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE
62#define alloc_bootmem_node(pgdat, x) \
63 __alloc_bootmem_node((pgdat), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
64#define alloc_bootmem_pages_node(pgdat, x) \
65 __alloc_bootmem_node((pgdat), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
66#define alloc_bootmem_low_pages_node(pgdat, x) \
67 __alloc_bootmem_node((pgdat), (x), PAGE_SIZE, 0)
68#endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */
69
70extern unsigned long __initdata nr_kernel_pages;
71extern unsigned long __initdata nr_all_pages;
72
73extern void *__init alloc_large_system_hash(const char *tablename,
74 unsigned long bucketsize,
75 unsigned long numentries,
76 int scale,
77 int flags,
78 unsigned int *_hash_shift,
79 unsigned int *_hash_mask,
80 unsigned long limit);
81
82#define HASH_HIGHMEM 0x00000001 /* Consider highmem? */
83#define HASH_EARLY 0x00000002 /* Allocating during early boot? */
84
85/* Only NUMA needs hash distribution.
86 * IA64 is known to have sufficient vmalloc space.
87 */
88#if defined(CONFIG_NUMA) && defined(CONFIG_IA64)
89#define HASHDIST_DEFAULT 1
90#else
91#define HASHDIST_DEFAULT 0
92#endif
93extern int __initdata hashdist; /* Distribute hashes across NUMA nodes? */
94
95
96#endif /* _LINUX_BOOTMEM_H */
diff --git a/include/linux/bpqether.h b/include/linux/bpqether.h
new file mode 100644
index 000000000000..a6c35e1a89ad
--- /dev/null
+++ b/include/linux/bpqether.h
@@ -0,0 +1,41 @@
1#ifndef __BPQETHER_H
2#define __BPQETHER_H
3
4/*
5 * Defines for the BPQETHER pseudo device driver
6 */
7
8#ifndef __LINUX_IF_ETHER_H
9#include <linux/if_ether.h>
10#endif
11
12#define SIOCSBPQETHOPT (SIOCDEVPRIVATE+0) /* reserved */
13#define SIOCSBPQETHADDR (SIOCDEVPRIVATE+1)
14
15struct bpq_ethaddr {
16 unsigned char destination[ETH_ALEN];
17 unsigned char accept[ETH_ALEN];
18};
19
20/*
21 * For SIOCSBPQETHOPT - this is compatible with PI2/PacketTwin card drivers,
22 * currently not implemented, though. If someone wants to hook a radio
23 * to his Ethernet card he may find this useful. ;-)
24 */
25
26#define SIOCGBPQETHPARAM 0x5000 /* get Level 1 parameters */
27#define SIOCSBPQETHPARAM 0x5001 /* set */
28
29struct bpq_req {
30 int cmd;
31 int speed; /* unused */
32 int clockmode; /* unused */
33 int txdelay;
34 unsigned char persist; /* unused */
35 int slotime; /* unused */
36 int squeldelay;
37 int dmachan; /* unused */
38 int irq; /* unused */
39};
40
41#endif
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
new file mode 100644
index 000000000000..802c91e9b3da
--- /dev/null
+++ b/include/linux/buffer_head.h
@@ -0,0 +1,296 @@
1/*
2 * include/linux/buffer_head.h
3 *
4 * Everything to do with buffer_heads.
5 */
6
7#ifndef _LINUX_BUFFER_HEAD_H
8#define _LINUX_BUFFER_HEAD_H
9
10#include <linux/types.h>
11#include <linux/fs.h>
12#include <linux/linkage.h>
13#include <linux/pagemap.h>
14#include <linux/wait.h>
15#include <asm/atomic.h>
16
17enum bh_state_bits {
18 BH_Uptodate, /* Contains valid data */
19 BH_Dirty, /* Is dirty */
20 BH_Lock, /* Is locked */
21 BH_Req, /* Has been submitted for I/O */
22
23 BH_Mapped, /* Has a disk mapping */
24 BH_New, /* Disk mapping was newly created by get_block */
25 BH_Async_Read, /* Is under end_buffer_async_read I/O */
26 BH_Async_Write, /* Is under end_buffer_async_write I/O */
27 BH_Delay, /* Buffer is not yet allocated on disk */
28 BH_Boundary, /* Block is followed by a discontiguity */
29 BH_Write_EIO, /* I/O error on write */
30 BH_Ordered, /* ordered write */
31 BH_Eopnotsupp, /* operation not supported (barrier) */
32
33 BH_PrivateStart,/* not a state bit, but the first bit available
34 * for private allocation by other entities
35 */
36};
37
38#define MAX_BUF_PER_PAGE (PAGE_CACHE_SIZE / 512)
39
40struct page;
41struct buffer_head;
42struct address_space;
43typedef void (bh_end_io_t)(struct buffer_head *bh, int uptodate);
44
45/*
46 * Keep related fields in common cachelines. The most commonly accessed
47 * field (b_state) goes at the start so the compiler does not generate
48 * indexed addressing for it.
49 */
50struct buffer_head {
51 /* First cache line: */
52 unsigned long b_state; /* buffer state bitmap (see above) */
53 struct buffer_head *b_this_page;/* circular list of page's buffers */
54 struct page *b_page; /* the page this bh is mapped to */
55 atomic_t b_count; /* users using this block */
56 u32 b_size; /* block size */
57
58 sector_t b_blocknr; /* block number */
59 char *b_data; /* pointer to data block */
60
61 struct block_device *b_bdev;
62 bh_end_io_t *b_end_io; /* I/O completion */
63 void *b_private; /* reserved for b_end_io */
64 struct list_head b_assoc_buffers; /* associated with another mapping */
65};
66
67/*
68 * macro tricks to expand the set_buffer_foo(), clear_buffer_foo()
69 * and buffer_foo() functions.
70 */
71#define BUFFER_FNS(bit, name) \
72static inline void set_buffer_##name(struct buffer_head *bh) \
73{ \
74 set_bit(BH_##bit, &(bh)->b_state); \
75} \
76static inline void clear_buffer_##name(struct buffer_head *bh) \
77{ \
78 clear_bit(BH_##bit, &(bh)->b_state); \
79} \
80static inline int buffer_##name(const struct buffer_head *bh) \
81{ \
82 return test_bit(BH_##bit, &(bh)->b_state); \
83}
84
85/*
86 * test_set_buffer_foo() and test_clear_buffer_foo()
87 */
88#define TAS_BUFFER_FNS(bit, name) \
89static inline int test_set_buffer_##name(struct buffer_head *bh) \
90{ \
91 return test_and_set_bit(BH_##bit, &(bh)->b_state); \
92} \
93static inline int test_clear_buffer_##name(struct buffer_head *bh) \
94{ \
95 return test_and_clear_bit(BH_##bit, &(bh)->b_state); \
96} \
97
98/*
99 * Emit the buffer bitops functions. Note that there are also functions
100 * of the form "mark_buffer_foo()". These are higher-level functions which
101 * do something in addition to setting a b_state bit.
102 */
103BUFFER_FNS(Uptodate, uptodate)
104BUFFER_FNS(Dirty, dirty)
105TAS_BUFFER_FNS(Dirty, dirty)
106BUFFER_FNS(Lock, locked)
107TAS_BUFFER_FNS(Lock, locked)
108BUFFER_FNS(Req, req)
109TAS_BUFFER_FNS(Req, req)
110BUFFER_FNS(Mapped, mapped)
111BUFFER_FNS(New, new)
112BUFFER_FNS(Async_Read, async_read)
113BUFFER_FNS(Async_Write, async_write)
114BUFFER_FNS(Delay, delay)
115BUFFER_FNS(Boundary, boundary)
116BUFFER_FNS(Write_EIO, write_io_error)
117BUFFER_FNS(Ordered, ordered)
118BUFFER_FNS(Eopnotsupp, eopnotsupp)
119
120#define bh_offset(bh) ((unsigned long)(bh)->b_data & ~PAGE_MASK)
121#define touch_buffer(bh) mark_page_accessed(bh->b_page)
122
123/* If we *know* page->private refers to buffer_heads */
124#define page_buffers(page) \
125 ({ \
126 BUG_ON(!PagePrivate(page)); \
127 ((struct buffer_head *)(page)->private); \
128 })
129#define page_has_buffers(page) PagePrivate(page)
130
131/*
132 * Declarations
133 */
134
135void FASTCALL(mark_buffer_dirty(struct buffer_head *bh));
136void init_buffer(struct buffer_head *, bh_end_io_t *, void *);
137void set_bh_page(struct buffer_head *bh,
138 struct page *page, unsigned long offset);
139int try_to_free_buffers(struct page *);
140struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size,
141 int retry);
142void create_empty_buffers(struct page *, unsigned long,
143 unsigned long b_state);
144void end_buffer_read_sync(struct buffer_head *bh, int uptodate);
145void end_buffer_write_sync(struct buffer_head *bh, int uptodate);
146void end_buffer_async_write(struct buffer_head *bh, int uptodate);
147
148/* Things to do with buffers at mapping->private_list */
149void mark_buffer_dirty_inode(struct buffer_head *bh, struct inode *inode);
150int inode_has_buffers(struct inode *);
151void invalidate_inode_buffers(struct inode *);
152int remove_inode_buffers(struct inode *inode);
153int sync_mapping_buffers(struct address_space *mapping);
154void unmap_underlying_metadata(struct block_device *bdev, sector_t block);
155
156void mark_buffer_async_write(struct buffer_head *bh);
157void invalidate_bdev(struct block_device *, int);
158int sync_blockdev(struct block_device *bdev);
159void __wait_on_buffer(struct buffer_head *);
160wait_queue_head_t *bh_waitq_head(struct buffer_head *bh);
161int fsync_bdev(struct block_device *);
162struct super_block *freeze_bdev(struct block_device *);
163void thaw_bdev(struct block_device *, struct super_block *);
164int fsync_super(struct super_block *);
165int fsync_no_super(struct block_device *);
166struct buffer_head *__find_get_block(struct block_device *, sector_t, int);
167struct buffer_head * __getblk(struct block_device *, sector_t, int);
168void __brelse(struct buffer_head *);
169void __bforget(struct buffer_head *);
170void __breadahead(struct block_device *, sector_t block, int size);
171struct buffer_head *__bread(struct block_device *, sector_t block, int size);
172struct buffer_head *alloc_buffer_head(unsigned int __nocast gfp_flags);
173void free_buffer_head(struct buffer_head * bh);
174void FASTCALL(unlock_buffer(struct buffer_head *bh));
175void FASTCALL(__lock_buffer(struct buffer_head *bh));
176void ll_rw_block(int, int, struct buffer_head * bh[]);
177int sync_dirty_buffer(struct buffer_head *bh);
178int submit_bh(int, struct buffer_head *);
179void write_boundary_block(struct block_device *bdev,
180 sector_t bblock, unsigned blocksize);
181
182extern int buffer_heads_over_limit;
183
184/*
185 * Generic address_space_operations implementations for buffer_head-backed
186 * address_spaces.
187 */
188int try_to_release_page(struct page * page, int gfp_mask);
189int block_invalidatepage(struct page *page, unsigned long offset);
190int block_write_full_page(struct page *page, get_block_t *get_block,
191 struct writeback_control *wbc);
192int block_read_full_page(struct page*, get_block_t*);
193int block_prepare_write(struct page*, unsigned, unsigned, get_block_t*);
194int cont_prepare_write(struct page*, unsigned, unsigned, get_block_t*,
195 loff_t *);
196int generic_cont_expand(struct inode *inode, loff_t size) ;
197int block_commit_write(struct page *page, unsigned from, unsigned to);
198int block_sync_page(struct page *);
199sector_t generic_block_bmap(struct address_space *, sector_t, get_block_t *);
200int generic_commit_write(struct file *, struct page *, unsigned, unsigned);
201int block_truncate_page(struct address_space *, loff_t, get_block_t *);
202int file_fsync(struct file *, struct dentry *, int);
203int nobh_prepare_write(struct page*, unsigned, unsigned, get_block_t*);
204int nobh_commit_write(struct file *, struct page *, unsigned, unsigned);
205int nobh_truncate_page(struct address_space *, loff_t);
206int nobh_writepage(struct page *page, get_block_t *get_block,
207 struct writeback_control *wbc);
208
209
210/*
211 * inline definitions
212 */
213
214static inline void attach_page_buffers(struct page *page,
215 struct buffer_head *head)
216{
217 page_cache_get(page);
218 SetPagePrivate(page);
219 page->private = (unsigned long)head;
220}
221
222static inline void get_bh(struct buffer_head *bh)
223{
224 atomic_inc(&bh->b_count);
225}
226
227static inline void put_bh(struct buffer_head *bh)
228{
229 smp_mb__before_atomic_dec();
230 atomic_dec(&bh->b_count);
231}
232
233static inline void brelse(struct buffer_head *bh)
234{
235 if (bh)
236 __brelse(bh);
237}
238
239static inline void bforget(struct buffer_head *bh)
240{
241 if (bh)
242 __bforget(bh);
243}
244
245static inline struct buffer_head *
246sb_bread(struct super_block *sb, sector_t block)
247{
248 return __bread(sb->s_bdev, block, sb->s_blocksize);
249}
250
251static inline void
252sb_breadahead(struct super_block *sb, sector_t block)
253{
254 __breadahead(sb->s_bdev, block, sb->s_blocksize);
255}
256
257static inline struct buffer_head *
258sb_getblk(struct super_block *sb, sector_t block)
259{
260 return __getblk(sb->s_bdev, block, sb->s_blocksize);
261}
262
263static inline struct buffer_head *
264sb_find_get_block(struct super_block *sb, sector_t block)
265{
266 return __find_get_block(sb->s_bdev, block, sb->s_blocksize);
267}
268
269static inline void
270map_bh(struct buffer_head *bh, struct super_block *sb, sector_t block)
271{
272 set_buffer_mapped(bh);
273 bh->b_bdev = sb->s_bdev;
274 bh->b_blocknr = block;
275}
276
277/*
278 * Calling wait_on_buffer() for a zero-ref buffer is illegal, so we call into
279 * __wait_on_buffer() just to trip a debug check. Because debug code in inline
280 * functions is bloaty.
281 */
282static inline void wait_on_buffer(struct buffer_head *bh)
283{
284 might_sleep();
285 if (buffer_locked(bh) || atomic_read(&bh->b_count) == 0)
286 __wait_on_buffer(bh);
287}
288
289static inline void lock_buffer(struct buffer_head *bh)
290{
291 might_sleep();
292 if (test_set_buffer_locked(bh))
293 __lock_buffer(bh);
294}
295
296#endif /* _LINUX_BUFFER_HEAD_H */
diff --git a/include/linux/byteorder/big_endian.h b/include/linux/byteorder/big_endian.h
new file mode 100644
index 000000000000..bef87891cb24
--- /dev/null
+++ b/include/linux/byteorder/big_endian.h
@@ -0,0 +1,106 @@
1#ifndef _LINUX_BYTEORDER_BIG_ENDIAN_H
2#define _LINUX_BYTEORDER_BIG_ENDIAN_H
3
4#ifndef __BIG_ENDIAN
5#define __BIG_ENDIAN 4321
6#endif
7#ifndef __BIG_ENDIAN_BITFIELD
8#define __BIG_ENDIAN_BITFIELD
9#endif
10
11#include <linux/types.h>
12#include <linux/byteorder/swab.h>
13
14#define __constant_htonl(x) ((__force __be32)(__u32)(x))
15#define __constant_ntohl(x) ((__force __u32)(__be32)(x))
16#define __constant_htons(x) ((__force __be16)(__u16)(x))
17#define __constant_ntohs(x) ((__force __u16)(__be16)(x))
18#define __constant_cpu_to_le64(x) ((__force __le64)___constant_swab64((x)))
19#define __constant_le64_to_cpu(x) ___constant_swab64((__force __u64)(__le64)(x))
20#define __constant_cpu_to_le32(x) ((__force __le32)___constant_swab32((x)))
21#define __constant_le32_to_cpu(x) ___constant_swab32((__force __u32)(__le32)(x))
22#define __constant_cpu_to_le16(x) ((__force __le16)___constant_swab16((x)))
23#define __constant_le16_to_cpu(x) ___constant_swab16((__force __u16)(__le16)(x))
24#define __constant_cpu_to_be64(x) ((__force __be64)(__u64)(x))
25#define __constant_be64_to_cpu(x) ((__force __u64)(__be64)(x))
26#define __constant_cpu_to_be32(x) ((__force __be32)(__u32)(x))
27#define __constant_be32_to_cpu(x) ((__force __u32)(__be32)(x))
28#define __constant_cpu_to_be16(x) ((__force __be16)(__u16)(x))
29#define __constant_be16_to_cpu(x) ((__force __u16)(__be16)(x))
30#define __cpu_to_le64(x) ((__force __le64)__swab64((x)))
31#define __le64_to_cpu(x) __swab64((__force __u64)(__le64)(x))
32#define __cpu_to_le32(x) ((__force __le32)__swab32((x)))
33#define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
34#define __cpu_to_le16(x) ((__force __le16)__swab16((x)))
35#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
36#define __cpu_to_be64(x) ((__force __be64)(__u64)(x))
37#define __be64_to_cpu(x) ((__force __u64)(__be64)(x))
38#define __cpu_to_be32(x) ((__force __be32)(__u32)(x))
39#define __be32_to_cpu(x) ((__force __u32)(__be32)(x))
40#define __cpu_to_be16(x) ((__force __be16)(__u16)(x))
41#define __be16_to_cpu(x) ((__force __u16)(__be16)(x))
42
43static inline __le64 __cpu_to_le64p(const __u64 *p)
44{
45 return (__force __le64)__swab64p(p);
46}
47static inline __u64 __le64_to_cpup(const __le64 *p)
48{
49 return __swab64p((__u64 *)p);
50}
51static inline __le32 __cpu_to_le32p(const __u32 *p)
52{
53 return (__force __le32)__swab32p(p);
54}
55static inline __u32 __le32_to_cpup(const __le32 *p)
56{
57 return __swab32p((__u32 *)p);
58}
59static inline __le16 __cpu_to_le16p(const __u16 *p)
60{
61 return (__force __le16)__swab16p(p);
62}
63static inline __u16 __le16_to_cpup(const __le16 *p)
64{
65 return __swab16p((__u16 *)p);
66}
67static inline __be64 __cpu_to_be64p(const __u64 *p)
68{
69 return (__force __be64)*p;
70}
71static inline __u64 __be64_to_cpup(const __be64 *p)
72{
73 return (__force __u64)*p;
74}
75static inline __be32 __cpu_to_be32p(const __u32 *p)
76{
77 return (__force __be32)*p;
78}
79static inline __u32 __be32_to_cpup(const __be32 *p)
80{
81 return (__force __u32)*p;
82}
83static inline __be16 __cpu_to_be16p(const __u16 *p)
84{
85 return (__force __be16)*p;
86}
87static inline __u16 __be16_to_cpup(const __be16 *p)
88{
89 return (__force __u16)*p;
90}
91#define __cpu_to_le64s(x) __swab64s((x))
92#define __le64_to_cpus(x) __swab64s((x))
93#define __cpu_to_le32s(x) __swab32s((x))
94#define __le32_to_cpus(x) __swab32s((x))
95#define __cpu_to_le16s(x) __swab16s((x))
96#define __le16_to_cpus(x) __swab16s((x))
97#define __cpu_to_be64s(x) do {} while (0)
98#define __be64_to_cpus(x) do {} while (0)
99#define __cpu_to_be32s(x) do {} while (0)
100#define __be32_to_cpus(x) do {} while (0)
101#define __cpu_to_be16s(x) do {} while (0)
102#define __be16_to_cpus(x) do {} while (0)
103
104#include <linux/byteorder/generic.h>
105
106#endif /* _LINUX_BYTEORDER_BIG_ENDIAN_H */
diff --git a/include/linux/byteorder/generic.h b/include/linux/byteorder/generic.h
new file mode 100644
index 000000000000..5fde6f4d6c1e
--- /dev/null
+++ b/include/linux/byteorder/generic.h
@@ -0,0 +1,172 @@
1#ifndef _LINUX_BYTEORDER_GENERIC_H
2#define _LINUX_BYTEORDER_GENERIC_H
3
4/*
5 * linux/byteorder_generic.h
6 * Generic Byte-reordering support
7 *
8 * Francois-Rene Rideau <fare@tunes.org> 19970707
9 * gathered all the good ideas from all asm-foo/byteorder.h into one file,
10 * cleaned them up.
11 * I hope it is compliant with non-GCC compilers.
12 * I decided to put __BYTEORDER_HAS_U64__ in byteorder.h,
13 * because I wasn't sure it would be ok to put it in types.h
14 * Upgraded it to 2.1.43
15 * Francois-Rene Rideau <fare@tunes.org> 19971012
16 * Upgraded it to 2.1.57
17 * to please Linus T., replaced huge #ifdef's between little/big endian
18 * by nestedly #include'd files.
19 * Francois-Rene Rideau <fare@tunes.org> 19971205
20 * Made it to 2.1.71; now a facelift:
21 * Put files under include/linux/byteorder/
22 * Split swab from generic support.
23 *
24 * TODO:
25 * = Regular kernel maintainers could also replace all these manual
26 * byteswap macros that remain, disseminated among drivers,
27 * after some grep or the sources...
28 * = Linus might want to rename all these macros and files to fit his taste,
29 * to fit his personal naming scheme.
30 * = it seems that a few drivers would also appreciate
31 * nybble swapping support...
32 * = every architecture could add their byteswap macro in asm/byteorder.h
33 * see how some architectures already do (i386, alpha, ppc, etc)
34 * = cpu_to_beXX and beXX_to_cpu might some day need to be well
35 * distinguished throughout the kernel. This is not the case currently,
36 * since little endian, big endian, and pdp endian machines needn't it.
37 * But this might be the case for, say, a port of Linux to 20/21 bit
38 * architectures (and F21 Linux addict around?).
39 */
40
41/*
42 * The following macros are to be defined by <asm/byteorder.h>:
43 *
44 * Conversion of long and short int between network and host format
45 * ntohl(__u32 x)
46 * ntohs(__u16 x)
47 * htonl(__u32 x)
48 * htons(__u16 x)
49 * It seems that some programs (which? where? or perhaps a standard? POSIX?)
50 * might like the above to be functions, not macros (why?).
51 * if that's true, then detect them, and take measures.
52 * Anyway, the measure is: define only ___ntohl as a macro instead,
53 * and in a separate file, have
54 * unsigned long inline ntohl(x){return ___ntohl(x);}
55 *
56 * The same for constant arguments
57 * __constant_ntohl(__u32 x)
58 * __constant_ntohs(__u16 x)
59 * __constant_htonl(__u32 x)
60 * __constant_htons(__u16 x)
61 *
62 * Conversion of XX-bit integers (16- 32- or 64-)
63 * between native CPU format and little/big endian format
64 * 64-bit stuff only defined for proper architectures
65 * cpu_to_[bl]eXX(__uXX x)
66 * [bl]eXX_to_cpu(__uXX x)
67 *
68 * The same, but takes a pointer to the value to convert
69 * cpu_to_[bl]eXXp(__uXX x)
70 * [bl]eXX_to_cpup(__uXX x)
71 *
72 * The same, but change in situ
73 * cpu_to_[bl]eXXs(__uXX x)
74 * [bl]eXX_to_cpus(__uXX x)
75 *
76 * See asm-foo/byteorder.h for examples of how to provide
77 * architecture-optimized versions
78 *
79 */
80
81
82#if defined(__KERNEL__)
83/*
84 * inside the kernel, we can use nicknames;
85 * outside of it, we must avoid POSIX namespace pollution...
86 */
87#define cpu_to_le64 __cpu_to_le64
88#define le64_to_cpu __le64_to_cpu
89#define cpu_to_le32 __cpu_to_le32
90#define le32_to_cpu __le32_to_cpu
91#define cpu_to_le16 __cpu_to_le16
92#define le16_to_cpu __le16_to_cpu
93#define cpu_to_be64 __cpu_to_be64
94#define be64_to_cpu __be64_to_cpu
95#define cpu_to_be32 __cpu_to_be32
96#define be32_to_cpu __be32_to_cpu
97#define cpu_to_be16 __cpu_to_be16
98#define be16_to_cpu __be16_to_cpu
99#define cpu_to_le64p __cpu_to_le64p
100#define le64_to_cpup __le64_to_cpup
101#define cpu_to_le32p __cpu_to_le32p
102#define le32_to_cpup __le32_to_cpup
103#define cpu_to_le16p __cpu_to_le16p
104#define le16_to_cpup __le16_to_cpup
105#define cpu_to_be64p __cpu_to_be64p
106#define be64_to_cpup __be64_to_cpup
107#define cpu_to_be32p __cpu_to_be32p
108#define be32_to_cpup __be32_to_cpup
109#define cpu_to_be16p __cpu_to_be16p
110#define be16_to_cpup __be16_to_cpup
111#define cpu_to_le64s __cpu_to_le64s
112#define le64_to_cpus __le64_to_cpus
113#define cpu_to_le32s __cpu_to_le32s
114#define le32_to_cpus __le32_to_cpus
115#define cpu_to_le16s __cpu_to_le16s
116#define le16_to_cpus __le16_to_cpus
117#define cpu_to_be64s __cpu_to_be64s
118#define be64_to_cpus __be64_to_cpus
119#define cpu_to_be32s __cpu_to_be32s
120#define be32_to_cpus __be32_to_cpus
121#define cpu_to_be16s __cpu_to_be16s
122#define be16_to_cpus __be16_to_cpus
123#endif
124
125
126#if defined(__KERNEL__)
127/*
128 * Handle ntohl and suches. These have various compatibility
129 * issues - like we want to give the prototype even though we
130 * also have a macro for them in case some strange program
131 * wants to take the address of the thing or something..
132 *
133 * Note that these used to return a "long" in libc5, even though
134 * long is often 64-bit these days.. Thus the casts.
135 *
136 * They have to be macros in order to do the constant folding
137 * correctly - if the argument passed into a inline function
138 * it is no longer constant according to gcc..
139 */
140
141#undef ntohl
142#undef ntohs
143#undef htonl
144#undef htons
145
146/*
147 * Do the prototypes. Somebody might want to take the
148 * address or some such sick thing..
149 */
150extern __u32 ntohl(__be32);
151extern __be32 htonl(__u32);
152extern __u16 ntohs(__be16);
153extern __be16 htons(__u16);
154
155#if defined(__GNUC__) && (__GNUC__ >= 2) && defined(__OPTIMIZE__)
156
157#define ___htonl(x) __cpu_to_be32(x)
158#define ___htons(x) __cpu_to_be16(x)
159#define ___ntohl(x) __be32_to_cpu(x)
160#define ___ntohs(x) __be16_to_cpu(x)
161
162#define htonl(x) ___htonl(x)
163#define ntohl(x) ___ntohl(x)
164#define htons(x) ___htons(x)
165#define ntohs(x) ___ntohs(x)
166
167#endif /* OPTIMIZE */
168
169#endif /* KERNEL */
170
171
172#endif /* _LINUX_BYTEORDER_GENERIC_H */
diff --git a/include/linux/byteorder/little_endian.h b/include/linux/byteorder/little_endian.h
new file mode 100644
index 000000000000..86e62b750176
--- /dev/null
+++ b/include/linux/byteorder/little_endian.h
@@ -0,0 +1,106 @@
1#ifndef _LINUX_BYTEORDER_LITTLE_ENDIAN_H
2#define _LINUX_BYTEORDER_LITTLE_ENDIAN_H
3
4#ifndef __LITTLE_ENDIAN
5#define __LITTLE_ENDIAN 1234
6#endif
7#ifndef __LITTLE_ENDIAN_BITFIELD
8#define __LITTLE_ENDIAN_BITFIELD
9#endif
10
11#include <linux/types.h>
12#include <linux/byteorder/swab.h>
13
14#define __constant_htonl(x) ((__force __be32)___constant_swab32((x)))
15#define __constant_ntohl(x) ___constant_swab32((__force __be32)(x))
16#define __constant_htons(x) ((__force __be16)___constant_swab16((x)))
17#define __constant_ntohs(x) ___constant_swab16((__force __be16)(x))
18#define __constant_cpu_to_le64(x) ((__force __le64)(__u64)(x))
19#define __constant_le64_to_cpu(x) ((__force __u64)(__le64)(x))
20#define __constant_cpu_to_le32(x) ((__force __le32)(__u32)(x))
21#define __constant_le32_to_cpu(x) ((__force __u32)(__le32)(x))
22#define __constant_cpu_to_le16(x) ((__force __le16)(__u16)(x))
23#define __constant_le16_to_cpu(x) ((__force __u16)(__le16)(x))
24#define __constant_cpu_to_be64(x) ((__force __be64)___constant_swab64((x)))
25#define __constant_be64_to_cpu(x) ___constant_swab64((__force __u64)(__be64)(x))
26#define __constant_cpu_to_be32(x) ((__force __be32)___constant_swab32((x)))
27#define __constant_be32_to_cpu(x) ___constant_swab32((__force __u32)(__be32)(x))
28#define __constant_cpu_to_be16(x) ((__force __be16)___constant_swab16((x)))
29#define __constant_be16_to_cpu(x) ___constant_swab16((__force __u16)(__be16)(x))
30#define __cpu_to_le64(x) ((__force __le64)(__u64)(x))
31#define __le64_to_cpu(x) ((__force __u64)(__le64)(x))
32#define __cpu_to_le32(x) ((__force __le32)(__u32)(x))
33#define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
34#define __cpu_to_le16(x) ((__force __le16)(__u16)(x))
35#define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
36#define __cpu_to_be64(x) ((__force __be64)__swab64((x)))
37#define __be64_to_cpu(x) __swab64((__force __u64)(__be64)(x))
38#define __cpu_to_be32(x) ((__force __be32)__swab32((x)))
39#define __be32_to_cpu(x) __swab32((__force __u32)(__be32)(x))
40#define __cpu_to_be16(x) ((__force __be16)__swab16((x)))
41#define __be16_to_cpu(x) __swab16((__force __u16)(__be16)(x))
42
43static inline __le64 __cpu_to_le64p(const __u64 *p)
44{
45 return (__force __le64)*p;
46}
47static inline __u64 __le64_to_cpup(const __le64 *p)
48{
49 return (__force __u64)*p;
50}
51static inline __le32 __cpu_to_le32p(const __u32 *p)
52{
53 return (__force __le32)*p;
54}
55static inline __u32 __le32_to_cpup(const __le32 *p)
56{
57 return (__force __u32)*p;
58}
59static inline __le16 __cpu_to_le16p(const __u16 *p)
60{
61 return (__force __le16)*p;
62}
63static inline __u16 __le16_to_cpup(const __le16 *p)
64{
65 return (__force __u16)*p;
66}
67static inline __be64 __cpu_to_be64p(const __u64 *p)
68{
69 return (__force __be64)__swab64p(p);
70}
71static inline __u64 __be64_to_cpup(const __be64 *p)
72{
73 return __swab64p((__u64 *)p);
74}
75static inline __be32 __cpu_to_be32p(const __u32 *p)
76{
77 return (__force __be32)__swab32p(p);
78}
79static inline __u32 __be32_to_cpup(const __be32 *p)
80{
81 return __swab32p((__u32 *)p);
82}
83static inline __be16 __cpu_to_be16p(const __u16 *p)
84{
85 return (__force __be16)__swab16p(p);
86}
87static inline __u16 __be16_to_cpup(const __be16 *p)
88{
89 return __swab16p((__u16 *)p);
90}
91#define __cpu_to_le64s(x) do {} while (0)
92#define __le64_to_cpus(x) do {} while (0)
93#define __cpu_to_le32s(x) do {} while (0)
94#define __le32_to_cpus(x) do {} while (0)
95#define __cpu_to_le16s(x) do {} while (0)
96#define __le16_to_cpus(x) do {} while (0)
97#define __cpu_to_be64s(x) __swab64s((x))
98#define __be64_to_cpus(x) __swab64s((x))
99#define __cpu_to_be32s(x) __swab32s((x))
100#define __be32_to_cpus(x) __swab32s((x))
101#define __cpu_to_be16s(x) __swab16s((x))
102#define __be16_to_cpus(x) __swab16s((x))
103
104#include <linux/byteorder/generic.h>
105
106#endif /* _LINUX_BYTEORDER_LITTLE_ENDIAN_H */
diff --git a/include/linux/byteorder/pdp_endian.h b/include/linux/byteorder/pdp_endian.h
new file mode 100644
index 000000000000..618631cbc6e3
--- /dev/null
+++ b/include/linux/byteorder/pdp_endian.h
@@ -0,0 +1,88 @@
1#ifndef _LINUX_BYTEORDER_PDP_ENDIAN_H
2#define _LINUX_BYTEORDER_PDP_ENDIAN_H
3
4/*
5 * Could have been named NUXI-endian, but we use the same name as in glibc.
6 * hopefully only the PDP and its evolutions (old VAXen in compatibility mode)
7 * should ever use this braindead byteorder.
8 * This file *should* work, but has not been tested.
9 *
10 * little-endian is 1234; big-endian is 4321; nuxi/pdp-endian is 3412
11 *
12 * I thought vaxen were NUXI-endian, but was told they were correct-endian
13 * (little-endian), though indeed there existed NUXI-endian machines
14 * (DEC PDP-11 and old VAXen in compatibility mode).
15 * This makes this file a bit useless, but as a proof-of-concept.
16 *
17 * But what does a __u64 look like: is it 34127856 or 78563412 ???
18 * I don't dare imagine! Hence, no 64-bit byteorder support yet.
19 * Hopefully, there 64-bit pdp-endian support shouldn't ever be required.
20 *
21 */
22
23#ifndef __PDP_ENDIAN
24#define __PDP_ENDIAN 3412
25#endif
26#ifndef __PDP_ENDIAN_BITFIELD
27#define __PDP_ENDIAN_BITFIELD
28#endif
29
30#include <linux/byteorder/swab.h>
31#include <linux/byteorder/swabb.h>
32
33#define __constant_htonl(x) ___constant_swahb32((x))
34#define __constant_ntohl(x) ___constant_swahb32((x))
35#define __constant_htons(x) ___constant_swab16((x))
36#define __constant_ntohs(x) ___constant_swab16((x))
37#define __constant_cpu_to_le64(x) I DON'T KNOW
38#define __constant_le64_to_cpu(x) I DON'T KNOW
39#define __constant_cpu_to_le32(x) ___constant_swahw32((x))
40#define __constant_le32_to_cpu(x) ___constant_swahw32((x))
41#define __constant_cpu_to_le16(x) ((__u16)(x)
42#define __constant_le16_to_cpu(x) ((__u16)(x)
43#define __constant_cpu_to_be64(x) I DON'T KNOW
44#define __constant_be64_to_cpu(x) I DON'T KNOW
45#define __constant_cpu_to_be32(x) ___constant_swahb32((x))
46#define __constant_be32_to_cpu(x) ___constant_swahb32((x))
47#define __constant_cpu_to_be16(x) ___constant_swab16((x))
48#define __constant_be16_to_cpu(x) ___constant_swab16((x))
49#define __cpu_to_le64(x) I DON'T KNOW
50#define __le64_to_cpu(x) I DON'T KNOW
51#define __cpu_to_le32(x) ___swahw32((x))
52#define __le32_to_cpu(x) ___swahw32((x))
53#define __cpu_to_le16(x) ((__u16)(x)
54#define __le16_to_cpu(x) ((__u16)(x)
55#define __cpu_to_be64(x) I DON'T KNOW
56#define __be64_to_cpu(x) I DON'T KNOW
57#define __cpu_to_be32(x) __swahb32((x))
58#define __be32_to_cpu(x) __swahb32((x))
59#define __cpu_to_be16(x) __swab16((x))
60#define __be16_to_cpu(x) __swab16((x))
61#define __cpu_to_le64p(x) I DON'T KNOW
62#define __le64_to_cpup(x) I DON'T KNOW
63#define __cpu_to_le32p(x) ___swahw32p((x))
64#define __le32_to_cpup(x) ___swahw32p((x))
65#define __cpu_to_le16p(x) (*(__u16*)(x))
66#define __le16_to_cpup(x) (*(__u16*)(x))
67#define __cpu_to_be64p(x) I DON'T KNOW
68#define __be64_to_cpup(x) I DON'T KNOW
69#define __cpu_to_be32p(x) __swahb32p((x))
70#define __be32_to_cpup(x) __swahb32p((x))
71#define __cpu_to_be16p(x) __swab16p((x))
72#define __be16_to_cpup(x) __swab16p((x))
73#define __cpu_to_le64s(x) I DON'T KNOW
74#define __le64_to_cpus(x) I DON'T KNOW
75#define __cpu_to_le32s(x) ___swahw32s((x))
76#define __le32_to_cpus(x) ___swahw32s((x))
77#define __cpu_to_le16s(x) do {} while (0)
78#define __le16_to_cpus(x) do {} while (0)
79#define __cpu_to_be64s(x) I DON'T KNOW
80#define __be64_to_cpus(x) I DON'T KNOW
81#define __cpu_to_be32s(x) __swahb32s((x))
82#define __be32_to_cpus(x) __swahb32s((x))
83#define __cpu_to_be16s(x) __swab16s((x))
84#define __be16_to_cpus(x) __swab16s((x))
85
86#include <linux/byteorder/generic.h>
87
88#endif /* _LINUX_BYTEORDER_PDP_ENDIAN_H */
diff --git a/include/linux/byteorder/swab.h b/include/linux/byteorder/swab.h
new file mode 100644
index 000000000000..2f1cb775125a
--- /dev/null
+++ b/include/linux/byteorder/swab.h
@@ -0,0 +1,192 @@
1#ifndef _LINUX_BYTEORDER_SWAB_H
2#define _LINUX_BYTEORDER_SWAB_H
3
4/*
5 * linux/byteorder/swab.h
6 * Byte-swapping, independently from CPU endianness
7 * swabXX[ps]?(foo)
8 *
9 * Francois-Rene Rideau <fare@tunes.org> 19971205
10 * separated swab functions from cpu_to_XX,
11 * to clean up support for bizarre-endian architectures.
12 *
13 * See asm-i386/byteorder.h and suches for examples of how to provide
14 * architecture-dependent optimized versions
15 *
16 */
17
18#include <linux/compiler.h>
19
20/* casts are necessary for constants, because we never know how for sure
21 * how U/UL/ULL map to __u16, __u32, __u64. At least not in a portable way.
22 */
23#define ___swab16(x) \
24({ \
25 __u16 __x = (x); \
26 ((__u16)( \
27 (((__u16)(__x) & (__u16)0x00ffU) << 8) | \
28 (((__u16)(__x) & (__u16)0xff00U) >> 8) )); \
29})
30
31#define ___swab32(x) \
32({ \
33 __u32 __x = (x); \
34 ((__u32)( \
35 (((__u32)(__x) & (__u32)0x000000ffUL) << 24) | \
36 (((__u32)(__x) & (__u32)0x0000ff00UL) << 8) | \
37 (((__u32)(__x) & (__u32)0x00ff0000UL) >> 8) | \
38 (((__u32)(__x) & (__u32)0xff000000UL) >> 24) )); \
39})
40
41#define ___swab64(x) \
42({ \
43 __u64 __x = (x); \
44 ((__u64)( \
45 (__u64)(((__u64)(__x) & (__u64)0x00000000000000ffULL) << 56) | \
46 (__u64)(((__u64)(__x) & (__u64)0x000000000000ff00ULL) << 40) | \
47 (__u64)(((__u64)(__x) & (__u64)0x0000000000ff0000ULL) << 24) | \
48 (__u64)(((__u64)(__x) & (__u64)0x00000000ff000000ULL) << 8) | \
49 (__u64)(((__u64)(__x) & (__u64)0x000000ff00000000ULL) >> 8) | \
50 (__u64)(((__u64)(__x) & (__u64)0x0000ff0000000000ULL) >> 24) | \
51 (__u64)(((__u64)(__x) & (__u64)0x00ff000000000000ULL) >> 40) | \
52 (__u64)(((__u64)(__x) & (__u64)0xff00000000000000ULL) >> 56) )); \
53})
54
55#define ___constant_swab16(x) \
56 ((__u16)( \
57 (((__u16)(x) & (__u16)0x00ffU) << 8) | \
58 (((__u16)(x) & (__u16)0xff00U) >> 8) ))
59#define ___constant_swab32(x) \
60 ((__u32)( \
61 (((__u32)(x) & (__u32)0x000000ffUL) << 24) | \
62 (((__u32)(x) & (__u32)0x0000ff00UL) << 8) | \
63 (((__u32)(x) & (__u32)0x00ff0000UL) >> 8) | \
64 (((__u32)(x) & (__u32)0xff000000UL) >> 24) ))
65#define ___constant_swab64(x) \
66 ((__u64)( \
67 (__u64)(((__u64)(x) & (__u64)0x00000000000000ffULL) << 56) | \
68 (__u64)(((__u64)(x) & (__u64)0x000000000000ff00ULL) << 40) | \
69 (__u64)(((__u64)(x) & (__u64)0x0000000000ff0000ULL) << 24) | \
70 (__u64)(((__u64)(x) & (__u64)0x00000000ff000000ULL) << 8) | \
71 (__u64)(((__u64)(x) & (__u64)0x000000ff00000000ULL) >> 8) | \
72 (__u64)(((__u64)(x) & (__u64)0x0000ff0000000000ULL) >> 24) | \
73 (__u64)(((__u64)(x) & (__u64)0x00ff000000000000ULL) >> 40) | \
74 (__u64)(((__u64)(x) & (__u64)0xff00000000000000ULL) >> 56) ))
75
76/*
77 * provide defaults when no architecture-specific optimization is detected
78 */
79#ifndef __arch__swab16
80# define __arch__swab16(x) ({ __u16 __tmp = (x) ; ___swab16(__tmp); })
81#endif
82#ifndef __arch__swab32
83# define __arch__swab32(x) ({ __u32 __tmp = (x) ; ___swab32(__tmp); })
84#endif
85#ifndef __arch__swab64
86# define __arch__swab64(x) ({ __u64 __tmp = (x) ; ___swab64(__tmp); })
87#endif
88
89#ifndef __arch__swab16p
90# define __arch__swab16p(x) __arch__swab16(*(x))
91#endif
92#ifndef __arch__swab32p
93# define __arch__swab32p(x) __arch__swab32(*(x))
94#endif
95#ifndef __arch__swab64p
96# define __arch__swab64p(x) __arch__swab64(*(x))
97#endif
98
99#ifndef __arch__swab16s
100# define __arch__swab16s(x) do { *(x) = __arch__swab16p((x)); } while (0)
101#endif
102#ifndef __arch__swab32s
103# define __arch__swab32s(x) do { *(x) = __arch__swab32p((x)); } while (0)
104#endif
105#ifndef __arch__swab64s
106# define __arch__swab64s(x) do { *(x) = __arch__swab64p((x)); } while (0)
107#endif
108
109
110/*
111 * Allow constant folding
112 */
113#if defined(__GNUC__) && (__GNUC__ >= 2) && defined(__OPTIMIZE__)
114# define __swab16(x) \
115(__builtin_constant_p((__u16)(x)) ? \
116 ___swab16((x)) : \
117 __fswab16((x)))
118# define __swab32(x) \
119(__builtin_constant_p((__u32)(x)) ? \
120 ___swab32((x)) : \
121 __fswab32((x)))
122# define __swab64(x) \
123(__builtin_constant_p((__u64)(x)) ? \
124 ___swab64((x)) : \
125 __fswab64((x)))
126#else
127# define __swab16(x) __fswab16(x)
128# define __swab32(x) __fswab32(x)
129# define __swab64(x) __fswab64(x)
130#endif /* OPTIMIZE */
131
132
133static __inline__ __attribute_const__ __u16 __fswab16(__u16 x)
134{
135 return __arch__swab16(x);
136}
137static __inline__ __u16 __swab16p(const __u16 *x)
138{
139 return __arch__swab16p(x);
140}
141static __inline__ void __swab16s(__u16 *addr)
142{
143 __arch__swab16s(addr);
144}
145
146static __inline__ __attribute_const__ __u32 __fswab32(__u32 x)
147{
148 return __arch__swab32(x);
149}
150static __inline__ __u32 __swab32p(const __u32 *x)
151{
152 return __arch__swab32p(x);
153}
154static __inline__ void __swab32s(__u32 *addr)
155{
156 __arch__swab32s(addr);
157}
158
159#ifdef __BYTEORDER_HAS_U64__
160static __inline__ __attribute_const__ __u64 __fswab64(__u64 x)
161{
162# ifdef __SWAB_64_THRU_32__
163 __u32 h = x >> 32;
164 __u32 l = x & ((1ULL<<32)-1);
165 return (((__u64)__swab32(l)) << 32) | ((__u64)(__swab32(h)));
166# else
167 return __arch__swab64(x);
168# endif
169}
170static __inline__ __u64 __swab64p(const __u64 *x)
171{
172 return __arch__swab64p(x);
173}
174static __inline__ void __swab64s(__u64 *addr)
175{
176 __arch__swab64s(addr);
177}
178#endif /* __BYTEORDER_HAS_U64__ */
179
180#if defined(__KERNEL__)
181#define swab16 __swab16
182#define swab32 __swab32
183#define swab64 __swab64
184#define swab16p __swab16p
185#define swab32p __swab32p
186#define swab64p __swab64p
187#define swab16s __swab16s
188#define swab32s __swab32s
189#define swab64s __swab64s
190#endif
191
192#endif /* _LINUX_BYTEORDER_SWAB_H */
diff --git a/include/linux/byteorder/swabb.h b/include/linux/byteorder/swabb.h
new file mode 100644
index 000000000000..d28d9a804d3b
--- /dev/null
+++ b/include/linux/byteorder/swabb.h
@@ -0,0 +1,137 @@
1#ifndef _LINUX_BYTEORDER_SWABB_H
2#define _LINUX_BYTEORDER_SWABB_H
3
4/*
5 * linux/byteorder/swabb.h
6 * SWAp Bytes Bizarrely
7 * swaHHXX[ps]?(foo)
8 *
9 * Support for obNUXIous pdp-endian and other bizarre architectures.
10 * Will Linux ever run on such ancient beasts? if not, this file
11 * will be but a programming pearl. Still, it's a reminder that we
12 * shouldn't be making too many assumptions when trying to be portable.
13 *
14 */
15
16/*
17 * Meaning of the names I chose (vaxlinux people feel free to correct them):
18 * swahw32 swap 16-bit half-words in a 32-bit word
19 * swahb32 swap 8-bit halves of each 16-bit half-word in a 32-bit word
20 *
21 * No 64-bit support yet. I don't know NUXI conventions for long longs.
22 * I guarantee it will be a mess when it's there, though :->
23 * It will be even worse if there are conflicting 64-bit conventions.
24 * Hopefully, no one ever used 64-bit objects on NUXI machines.
25 *
26 */
27
28#define ___swahw32(x) \
29({ \
30 __u32 __x = (x); \
31 ((__u32)( \
32 (((__u32)(__x) & (__u32)0x0000ffffUL) << 16) | \
33 (((__u32)(__x) & (__u32)0xffff0000UL) >> 16) )); \
34})
35#define ___swahb32(x) \
36({ \
37 __u32 __x = (x); \
38 ((__u32)( \
39 (((__u32)(__x) & (__u32)0x00ff00ffUL) << 8) | \
40 (((__u32)(__x) & (__u32)0xff00ff00UL) >> 8) )); \
41})
42
43#define ___constant_swahw32(x) \
44 ((__u32)( \
45 (((__u32)(x) & (__u32)0x0000ffffUL) << 16) | \
46 (((__u32)(x) & (__u32)0xffff0000UL) >> 16) ))
47#define ___constant_swahb32(x) \
48 ((__u32)( \
49 (((__u32)(x) & (__u32)0x00ff00ffUL) << 8) | \
50 (((__u32)(x) & (__u32)0xff00ff00UL) >> 8) ))
51
52/*
53 * provide defaults when no architecture-specific optimization is detected
54 */
55#ifndef __arch__swahw32
56# define __arch__swahw32(x) ___swahw32(x)
57#endif
58#ifndef __arch__swahb32
59# define __arch__swahb32(x) ___swahb32(x)
60#endif
61
62#ifndef __arch__swahw32p
63# define __arch__swahw32p(x) __swahw32(*(x))
64#endif
65#ifndef __arch__swahb32p
66# define __arch__swahb32p(x) __swahb32(*(x))
67#endif
68
69#ifndef __arch__swahw32s
70# define __arch__swahw32s(x) do { *(x) = __swahw32p((x)); } while (0)
71#endif
72#ifndef __arch__swahb32s
73# define __arch__swahb32s(x) do { *(x) = __swahb32p((x)); } while (0)
74#endif
75
76
77/*
78 * Allow constant folding
79 */
80#if defined(__GNUC__) && (__GNUC__ >= 2) && defined(__OPTIMIZE__)
81# define __swahw32(x) \
82(__builtin_constant_p((__u32)(x)) ? \
83 ___swahw32((x)) : \
84 __fswahw32((x)))
85# define __swahb32(x) \
86(__builtin_constant_p((__u32)(x)) ? \
87 ___swahb32((x)) : \
88 __fswahb32((x)))
89#else
90# define __swahw32(x) __fswahw32(x)
91# define __swahb32(x) __fswahb32(x)
92#endif /* OPTIMIZE */
93
94
95static __inline__ __const__ __u32 __fswahw32(__u32 x)
96{
97 return __arch__swahw32(x);
98}
99static __inline__ __u32 __swahw32p(__u32 *x)
100{
101 return __arch__swahw32p(x);
102}
103static __inline__ void __swahw32s(__u32 *addr)
104{
105 __arch__swahw32s(addr);
106}
107
108
109static __inline__ __const__ __u32 __fswahb32(__u32 x)
110{
111 return __arch__swahb32(x);
112}
113static __inline__ __u32 __swahb32p(__u32 *x)
114{
115 return __arch__swahb32p(x);
116}
117static __inline__ void __swahb32s(__u32 *addr)
118{
119 __arch__swahb32s(addr);
120}
121
122#ifdef __BYTEORDER_HAS_U64__
123/*
124 * Not supported yet
125 */
126#endif /* __BYTEORDER_HAS_U64__ */
127
128#if defined(__KERNEL__)
129#define swahw32 __swahw32
130#define swahb32 __swahb32
131#define swahw32p __swahw32p
132#define swahb32p __swahb32p
133#define swahw32s __swahw32s
134#define swahb32s __swahb32s
135#endif
136
137#endif /* _LINUX_BYTEORDER_SWABB_H */
diff --git a/include/linux/cache.h b/include/linux/cache.h
new file mode 100644
index 000000000000..4d767b93738a
--- /dev/null
+++ b/include/linux/cache.h
@@ -0,0 +1,51 @@
1#ifndef __LINUX_CACHE_H
2#define __LINUX_CACHE_H
3
4#include <linux/kernel.h>
5#include <linux/config.h>
6#include <asm/cache.h>
7
8#ifndef L1_CACHE_ALIGN
9#define L1_CACHE_ALIGN(x) ALIGN(x, L1_CACHE_BYTES)
10#endif
11
12#ifndef SMP_CACHE_BYTES
13#define SMP_CACHE_BYTES L1_CACHE_BYTES
14#endif
15
16#ifndef ____cacheline_aligned
17#define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
18#endif
19
20#ifndef ____cacheline_aligned_in_smp
21#ifdef CONFIG_SMP
22#define ____cacheline_aligned_in_smp ____cacheline_aligned
23#else
24#define ____cacheline_aligned_in_smp
25#endif /* CONFIG_SMP */
26#endif
27
28#ifndef __cacheline_aligned
29#define __cacheline_aligned \
30 __attribute__((__aligned__(SMP_CACHE_BYTES), \
31 __section__(".data.cacheline_aligned")))
32#endif /* __cacheline_aligned */
33
34#ifndef __cacheline_aligned_in_smp
35#ifdef CONFIG_SMP
36#define __cacheline_aligned_in_smp __cacheline_aligned
37#else
38#define __cacheline_aligned_in_smp
39#endif /* CONFIG_SMP */
40#endif
41
42#if !defined(____cacheline_maxaligned_in_smp)
43#if defined(CONFIG_SMP)
44#define ____cacheline_maxaligned_in_smp \
45 __attribute__((__aligned__(1 << (L1_CACHE_SHIFT_MAX))))
46#else
47#define ____cacheline_maxaligned_in_smp
48#endif
49#endif
50
51#endif /* __LINUX_CACHE_H */
diff --git a/include/linux/capability.h b/include/linux/capability.h
new file mode 100644
index 000000000000..8d139f4acf23
--- /dev/null
+++ b/include/linux/capability.h
@@ -0,0 +1,360 @@
1/*
2 * This is <linux/capability.h>
3 *
4 * Andrew G. Morgan <morgan@transmeta.com>
5 * Alexander Kjeldaas <astor@guardian.no>
6 * with help from Aleph1, Roland Buresund and Andrew Main.
7 *
8 * See here for the libcap library ("POSIX draft" compliance):
9 *
10 * ftp://linux.kernel.org/pub/linux/libs/security/linux-privs/kernel-2.2/
11 */
12
13#ifndef _LINUX_CAPABILITY_H
14#define _LINUX_CAPABILITY_H
15
16#include <linux/types.h>
17#include <linux/compiler.h>
18
19/* User-level do most of the mapping between kernel and user
20 capabilities based on the version tag given by the kernel. The
21 kernel might be somewhat backwards compatible, but don't bet on
22 it. */
23
24/* XXX - Note, cap_t, is defined by POSIX to be an "opaque" pointer to
25 a set of three capability sets. The transposition of 3*the
26 following structure to such a composite is better handled in a user
27 library since the draft standard requires the use of malloc/free
28 etc.. */
29
30#define _LINUX_CAPABILITY_VERSION 0x19980330
31
32typedef struct __user_cap_header_struct {
33 __u32 version;
34 int pid;
35} __user *cap_user_header_t;
36
37typedef struct __user_cap_data_struct {
38 __u32 effective;
39 __u32 permitted;
40 __u32 inheritable;
41} __user *cap_user_data_t;
42
43#ifdef __KERNEL__
44
45#include <linux/spinlock.h>
46
47/* #define STRICT_CAP_T_TYPECHECKS */
48
49#ifdef STRICT_CAP_T_TYPECHECKS
50
51typedef struct kernel_cap_struct {
52 __u32 cap;
53} kernel_cap_t;
54
55#else
56
57typedef __u32 kernel_cap_t;
58
59#endif
60
61#define _USER_CAP_HEADER_SIZE (2*sizeof(__u32))
62#define _KERNEL_CAP_T_SIZE (sizeof(kernel_cap_t))
63
64#endif
65
66
67/**
68 ** POSIX-draft defined capabilities.
69 **/
70
71/* In a system with the [_POSIX_CHOWN_RESTRICTED] option defined, this
72 overrides the restriction of changing file ownership and group
73 ownership. */
74
75#define CAP_CHOWN 0
76
77/* Override all DAC access, including ACL execute access if
78 [_POSIX_ACL] is defined. Excluding DAC access covered by
79 CAP_LINUX_IMMUTABLE. */
80
81#define CAP_DAC_OVERRIDE 1
82
83/* Overrides all DAC restrictions regarding read and search on files
84 and directories, including ACL restrictions if [_POSIX_ACL] is
85 defined. Excluding DAC access covered by CAP_LINUX_IMMUTABLE. */
86
87#define CAP_DAC_READ_SEARCH 2
88
89/* Overrides all restrictions about allowed operations on files, where
90 file owner ID must be equal to the user ID, except where CAP_FSETID
91 is applicable. It doesn't override MAC and DAC restrictions. */
92
93#define CAP_FOWNER 3
94
95/* Overrides the following restrictions that the effective user ID
96 shall match the file owner ID when setting the S_ISUID and S_ISGID
97 bits on that file; that the effective group ID (or one of the
98 supplementary group IDs) shall match the file owner ID when setting
99 the S_ISGID bit on that file; that the S_ISUID and S_ISGID bits are
100 cleared on successful return from chown(2) (not implemented). */
101
102#define CAP_FSETID 4
103
104/* Used to decide between falling back on the old suser() or fsuser(). */
105
106#define CAP_FS_MASK 0x1f
107
108/* Overrides the restriction that the real or effective user ID of a
109 process sending a signal must match the real or effective user ID
110 of the process receiving the signal. */
111
112#define CAP_KILL 5
113
114/* Allows setgid(2) manipulation */
115/* Allows setgroups(2) */
116/* Allows forged gids on socket credentials passing. */
117
118#define CAP_SETGID 6
119
120/* Allows set*uid(2) manipulation (including fsuid). */
121/* Allows forged pids on socket credentials passing. */
122
123#define CAP_SETUID 7
124
125
126/**
127 ** Linux-specific capabilities
128 **/
129
130/* Transfer any capability in your permitted set to any pid,
131 remove any capability in your permitted set from any pid */
132
133#define CAP_SETPCAP 8
134
135/* Allow modification of S_IMMUTABLE and S_APPEND file attributes */
136
137#define CAP_LINUX_IMMUTABLE 9
138
139/* Allows binding to TCP/UDP sockets below 1024 */
140/* Allows binding to ATM VCIs below 32 */
141
142#define CAP_NET_BIND_SERVICE 10
143
144/* Allow broadcasting, listen to multicast */
145
146#define CAP_NET_BROADCAST 11
147
148/* Allow interface configuration */
149/* Allow administration of IP firewall, masquerading and accounting */
150/* Allow setting debug option on sockets */
151/* Allow modification of routing tables */
152/* Allow setting arbitrary process / process group ownership on
153 sockets */
154/* Allow binding to any address for transparent proxying */
155/* Allow setting TOS (type of service) */
156/* Allow setting promiscuous mode */
157/* Allow clearing driver statistics */
158/* Allow multicasting */
159/* Allow read/write of device-specific registers */
160/* Allow activation of ATM control sockets */
161
162#define CAP_NET_ADMIN 12
163
164/* Allow use of RAW sockets */
165/* Allow use of PACKET sockets */
166
167#define CAP_NET_RAW 13
168
169/* Allow locking of shared memory segments */
170/* Allow mlock and mlockall (which doesn't really have anything to do
171 with IPC) */
172
173#define CAP_IPC_LOCK 14
174
175/* Override IPC ownership checks */
176
177#define CAP_IPC_OWNER 15
178
179/* Insert and remove kernel modules - modify kernel without limit */
180/* Modify cap_bset */
181#define CAP_SYS_MODULE 16
182
183/* Allow ioperm/iopl access */
184/* Allow sending USB messages to any device via /proc/bus/usb */
185
186#define CAP_SYS_RAWIO 17
187
188/* Allow use of chroot() */
189
190#define CAP_SYS_CHROOT 18
191
192/* Allow ptrace() of any process */
193
194#define CAP_SYS_PTRACE 19
195
196/* Allow configuration of process accounting */
197
198#define CAP_SYS_PACCT 20
199
200/* Allow configuration of the secure attention key */
201/* Allow administration of the random device */
202/* Allow examination and configuration of disk quotas */
203/* Allow configuring the kernel's syslog (printk behaviour) */
204/* Allow setting the domainname */
205/* Allow setting the hostname */
206/* Allow calling bdflush() */
207/* Allow mount() and umount(), setting up new smb connection */
208/* Allow some autofs root ioctls */
209/* Allow nfsservctl */
210/* Allow VM86_REQUEST_IRQ */
211/* Allow to read/write pci config on alpha */
212/* Allow irix_prctl on mips (setstacksize) */
213/* Allow flushing all cache on m68k (sys_cacheflush) */
214/* Allow removing semaphores */
215/* Used instead of CAP_CHOWN to "chown" IPC message queues, semaphores
216 and shared memory */
217/* Allow locking/unlocking of shared memory segment */
218/* Allow turning swap on/off */
219/* Allow forged pids on socket credentials passing */
220/* Allow setting readahead and flushing buffers on block devices */
221/* Allow setting geometry in floppy driver */
222/* Allow turning DMA on/off in xd driver */
223/* Allow administration of md devices (mostly the above, but some
224 extra ioctls) */
225/* Allow tuning the ide driver */
226/* Allow access to the nvram device */
227/* Allow administration of apm_bios, serial and bttv (TV) device */
228/* Allow manufacturer commands in isdn CAPI support driver */
229/* Allow reading non-standardized portions of pci configuration space */
230/* Allow DDI debug ioctl on sbpcd driver */
231/* Allow setting up serial ports */
232/* Allow sending raw qic-117 commands */
233/* Allow enabling/disabling tagged queuing on SCSI controllers and sending
234 arbitrary SCSI commands */
235/* Allow setting encryption key on loopback filesystem */
236
237#define CAP_SYS_ADMIN 21
238
239/* Allow use of reboot() */
240
241#define CAP_SYS_BOOT 22
242
243/* Allow raising priority and setting priority on other (different
244 UID) processes */
245/* Allow use of FIFO and round-robin (realtime) scheduling on own
246 processes and setting the scheduling algorithm used by another
247 process. */
248/* Allow setting cpu affinity on other processes */
249
250#define CAP_SYS_NICE 23
251
252/* Override resource limits. Set resource limits. */
253/* Override quota limits. */
254/* Override reserved space on ext2 filesystem */
255/* Modify data journaling mode on ext3 filesystem (uses journaling
256 resources) */
257/* NOTE: ext2 honors fsuid when checking for resource overrides, so
258 you can override using fsuid too */
259/* Override size restrictions on IPC message queues */
260/* Allow more than 64hz interrupts from the real-time clock */
261/* Override max number of consoles on console allocation */
262/* Override max number of keymaps */
263
264#define CAP_SYS_RESOURCE 24
265
266/* Allow manipulation of system clock */
267/* Allow irix_stime on mips */
268/* Allow setting the real-time clock */
269
270#define CAP_SYS_TIME 25
271
272/* Allow configuration of tty devices */
273/* Allow vhangup() of tty */
274
275#define CAP_SYS_TTY_CONFIG 26
276
277/* Allow the privileged aspects of mknod() */
278
279#define CAP_MKNOD 27
280
281/* Allow taking of leases on files */
282
283#define CAP_LEASE 28
284
285#define CAP_AUDIT_WRITE 29
286
287#define CAP_AUDIT_CONTROL 30
288
289#ifdef __KERNEL__
290/*
291 * Bounding set
292 */
293extern kernel_cap_t cap_bset;
294
295/*
296 * Internal kernel functions only
297 */
298
299#ifdef STRICT_CAP_T_TYPECHECKS
300
301#define to_cap_t(x) { x }
302#define cap_t(x) (x).cap
303
304#else
305
306#define to_cap_t(x) (x)
307#define cap_t(x) (x)
308
309#endif
310
311#define CAP_EMPTY_SET to_cap_t(0)
312#define CAP_FULL_SET to_cap_t(~0)
313#define CAP_INIT_EFF_SET to_cap_t(~0 & ~CAP_TO_MASK(CAP_SETPCAP))
314#define CAP_INIT_INH_SET to_cap_t(0)
315
316#define CAP_TO_MASK(x) (1 << (x))
317#define cap_raise(c, flag) (cap_t(c) |= CAP_TO_MASK(flag))
318#define cap_lower(c, flag) (cap_t(c) &= ~CAP_TO_MASK(flag))
319#define cap_raised(c, flag) (cap_t(c) & CAP_TO_MASK(flag))
320
321static inline kernel_cap_t cap_combine(kernel_cap_t a, kernel_cap_t b)
322{
323 kernel_cap_t dest;
324 cap_t(dest) = cap_t(a) | cap_t(b);
325 return dest;
326}
327
328static inline kernel_cap_t cap_intersect(kernel_cap_t a, kernel_cap_t b)
329{
330 kernel_cap_t dest;
331 cap_t(dest) = cap_t(a) & cap_t(b);
332 return dest;
333}
334
335static inline kernel_cap_t cap_drop(kernel_cap_t a, kernel_cap_t drop)
336{
337 kernel_cap_t dest;
338 cap_t(dest) = cap_t(a) & ~cap_t(drop);
339 return dest;
340}
341
342static inline kernel_cap_t cap_invert(kernel_cap_t c)
343{
344 kernel_cap_t dest;
345 cap_t(dest) = ~cap_t(c);
346 return dest;
347}
348
349#define cap_isclear(c) (!cap_t(c))
350#define cap_issubset(a,set) (!(cap_t(a) & ~cap_t(set)))
351
352#define cap_clear(c) do { cap_t(c) = 0; } while(0)
353#define cap_set_full(c) do { cap_t(c) = ~0; } while(0)
354#define cap_mask(c,mask) do { cap_t(c) &= cap_t(mask); } while(0)
355
356#define cap_is_fs_cap(c) (CAP_TO_MASK(c) & CAP_FS_MASK)
357
358#endif /* __KERNEL__ */
359
360#endif /* !_LINUX_CAPABILITY_H */
diff --git a/include/linux/capi.h b/include/linux/capi.h
new file mode 100644
index 000000000000..fdebaaa9f66e
--- /dev/null
+++ b/include/linux/capi.h
@@ -0,0 +1,133 @@
1/* $Id: capi.h,v 1.4.6.1 2001/09/23 22:25:05 kai Exp $
2 *
3 * CAPI 2.0 Interface for Linux
4 *
5 * Copyright 1997 by Carsten Paeth (calle@calle.in-berlin.de)
6 *
7 * This software may be used and distributed according to the terms
8 * of the GNU General Public License, incorporated herein by reference.
9 *
10 */
11
12#ifndef __LINUX_CAPI_H__
13#define __LINUX_CAPI_H__
14
15#include <asm/types.h>
16#include <linux/ioctl.h>
17#ifndef __KERNEL__
18#include <linux/kernelcapi.h>
19#endif
20
21/*
22 * CAPI_REGISTER
23 */
24
25typedef struct capi_register_params { /* CAPI_REGISTER */
26 __u32 level3cnt; /* No. of simulatneous user data connections */
27 __u32 datablkcnt; /* No. of buffered data messages */
28 __u32 datablklen; /* Size of buffered data messages */
29} capi_register_params;
30
31#define CAPI_REGISTER _IOW('C',0x01,struct capi_register_params)
32
33/*
34 * CAPI_GET_MANUFACTURER
35 */
36
37#define CAPI_MANUFACTURER_LEN 64
38
39#define CAPI_GET_MANUFACTURER _IOWR('C',0x06,int) /* broken: wanted size 64 (CAPI_MANUFACTURER_LEN) */
40
41/*
42 * CAPI_GET_VERSION
43 */
44
45typedef struct capi_version {
46 __u32 majorversion;
47 __u32 minorversion;
48 __u32 majormanuversion;
49 __u32 minormanuversion;
50} capi_version;
51
52#define CAPI_GET_VERSION _IOWR('C',0x07,struct capi_version)
53
54/*
55 * CAPI_GET_SERIAL
56 */
57
58#define CAPI_SERIAL_LEN 8
59#define CAPI_GET_SERIAL _IOWR('C',0x08,int) /* broken: wanted size 8 (CAPI_SERIAL_LEN) */
60
61/*
62 * CAPI_GET_PROFILE
63 */
64
65typedef struct capi_profile {
66 __u16 ncontroller; /* number of installed controller */
67 __u16 nbchannel; /* number of B-Channels */
68 __u32 goptions; /* global options */
69 __u32 support1; /* B1 protocols support */
70 __u32 support2; /* B2 protocols support */
71 __u32 support3; /* B3 protocols support */
72 __u32 reserved[6]; /* reserved */
73 __u32 manu[5]; /* manufacturer specific information */
74} capi_profile;
75
76#define CAPI_GET_PROFILE _IOWR('C',0x09,struct capi_profile)
77
78typedef struct capi_manufacturer_cmd {
79 unsigned long cmd;
80 void __user *data;
81} capi_manufacturer_cmd;
82
83/*
84 * CAPI_MANUFACTURER_CMD
85 */
86
87#define CAPI_MANUFACTURER_CMD _IOWR('C',0x20, struct capi_manufacturer_cmd)
88
89/*
90 * CAPI_GET_ERRCODE
91 * capi errcode is set, * if read, write, or ioctl returns EIO,
92 * ioctl returns errcode directly, and in arg, if != 0
93 */
94
95#define CAPI_GET_ERRCODE _IOR('C',0x21, __u16)
96
97/*
98 * CAPI_INSTALLED
99 */
100#define CAPI_INSTALLED _IOR('C',0x22, __u16)
101
102
103/*
104 * member contr is input for
105 * CAPI_GET_MANUFACTURER, CAPI_VERSION, CAPI_GET_SERIAL
106 * and CAPI_GET_PROFILE
107 */
108typedef union capi_ioctl_struct {
109 __u32 contr;
110 capi_register_params rparams;
111 __u8 manufacturer[CAPI_MANUFACTURER_LEN];
112 capi_version version;
113 __u8 serial[CAPI_SERIAL_LEN];
114 capi_profile profile;
115 capi_manufacturer_cmd cmd;
116 __u16 errcode;
117} capi_ioctl_struct;
118
119/*
120 * Middleware extension
121 */
122
123#define CAPIFLAG_HIGHJACKING 0x0001
124
125#define CAPI_GET_FLAGS _IOR('C',0x23, unsigned)
126#define CAPI_SET_FLAGS _IOR('C',0x24, unsigned)
127#define CAPI_CLR_FLAGS _IOR('C',0x25, unsigned)
128
129#define CAPI_NCCI_OPENCOUNT _IOR('C',0x26, unsigned)
130
131#define CAPI_NCCI_GETUNIT _IOR('C',0x27, unsigned)
132
133#endif /* __LINUX_CAPI_H__ */
diff --git a/include/linux/cciss_ioctl.h b/include/linux/cciss_ioctl.h
new file mode 100644
index 000000000000..ee0c6e8995da
--- /dev/null
+++ b/include/linux/cciss_ioctl.h
@@ -0,0 +1,240 @@
1#ifndef CCISS_IOCTLH
2#define CCISS_IOCTLH
3
4#include <linux/types.h>
5#include <linux/ioctl.h>
6
7#define CCISS_IOC_MAGIC 'B'
8
9
10typedef struct _cciss_pci_info_struct
11{
12 unsigned char bus;
13 unsigned char dev_fn;
14 __u32 board_id;
15} cciss_pci_info_struct;
16
17typedef struct _cciss_coalint_struct
18{
19 __u32 delay;
20 __u32 count;
21} cciss_coalint_struct;
22
23typedef char NodeName_type[16];
24
25typedef __u32 Heartbeat_type;
26
27#define CISS_PARSCSIU2 0x0001
28#define CISS_PARCSCIU3 0x0002
29#define CISS_FIBRE1G 0x0100
30#define CISS_FIBRE2G 0x0200
31typedef __u32 BusTypes_type;
32
33typedef char FirmwareVer_type[4];
34typedef __u32 DriverVer_type;
35
36#define MAX_KMALLOC_SIZE 128000
37
38#ifndef CCISS_CMD_H
39// This defines are duplicated in cciss_cmd.h in the driver directory
40
41//general boundary defintions
42#define SENSEINFOBYTES 32//note that this value may vary between host implementations
43
44//Command Status value
45#define CMD_SUCCESS 0x0000
46#define CMD_TARGET_STATUS 0x0001
47#define CMD_DATA_UNDERRUN 0x0002
48#define CMD_DATA_OVERRUN 0x0003
49#define CMD_INVALID 0x0004
50#define CMD_PROTOCOL_ERR 0x0005
51#define CMD_HARDWARE_ERR 0x0006
52#define CMD_CONNECTION_LOST 0x0007
53#define CMD_ABORTED 0x0008
54#define CMD_ABORT_FAILED 0x0009
55#define CMD_UNSOLICITED_ABORT 0x000A
56#define CMD_TIMEOUT 0x000B
57#define CMD_UNABORTABLE 0x000C
58
59//transfer direction
60#define XFER_NONE 0x00
61#define XFER_WRITE 0x01
62#define XFER_READ 0x02
63#define XFER_RSVD 0x03
64
65//task attribute
66#define ATTR_UNTAGGED 0x00
67#define ATTR_SIMPLE 0x04
68#define ATTR_HEADOFQUEUE 0x05
69#define ATTR_ORDERED 0x06
70#define ATTR_ACA 0x07
71
72//cdb type
73#define TYPE_CMD 0x00
74#define TYPE_MSG 0x01
75
76// Type defs used in the following structs
77#define BYTE __u8
78#define WORD __u16
79#define HWORD __u16
80#define DWORD __u32
81
82#define CISS_MAX_LUN 16
83
84#define LEVEL2LUN 1 // index into Target(x) structure, due to byte swapping
85#define LEVEL3LUN 0
86
87#pragma pack(1)
88
89//Command List Structure
90typedef union _SCSI3Addr_struct {
91 struct {
92 BYTE Dev;
93 BYTE Bus:6;
94 BYTE Mode:2; // b00
95 } PeripDev;
96 struct {
97 BYTE DevLSB;
98 BYTE DevMSB:6;
99 BYTE Mode:2; // b01
100 } LogDev;
101 struct {
102 BYTE Dev:5;
103 BYTE Bus:3;
104 BYTE Targ:6;
105 BYTE Mode:2; // b10
106 } LogUnit;
107} SCSI3Addr_struct;
108
109typedef struct _PhysDevAddr_struct {
110 DWORD TargetId:24;
111 DWORD Bus:6;
112 DWORD Mode:2;
113 SCSI3Addr_struct Target[2]; //2 level target device addr
114} PhysDevAddr_struct;
115
116typedef struct _LogDevAddr_struct {
117 DWORD VolId:30;
118 DWORD Mode:2;
119 BYTE reserved[4];
120} LogDevAddr_struct;
121
122typedef union _LUNAddr_struct {
123 BYTE LunAddrBytes[8];
124 SCSI3Addr_struct SCSI3Lun[4];
125 PhysDevAddr_struct PhysDev;
126 LogDevAddr_struct LogDev;
127} LUNAddr_struct;
128
129typedef struct _RequestBlock_struct {
130 BYTE CDBLen;
131 struct {
132 BYTE Type:3;
133 BYTE Attribute:3;
134 BYTE Direction:2;
135 } Type;
136 HWORD Timeout;
137 BYTE CDB[16];
138} RequestBlock_struct;
139
140typedef union _MoreErrInfo_struct{
141 struct {
142 BYTE Reserved[3];
143 BYTE Type;
144 DWORD ErrorInfo;
145 }Common_Info;
146 struct{
147 BYTE Reserved[2];
148 BYTE offense_size;//size of offending entry
149 BYTE offense_num; //byte # of offense 0-base
150 DWORD offense_value;
151 }Invalid_Cmd;
152}MoreErrInfo_struct;
153typedef struct _ErrorInfo_struct {
154 BYTE ScsiStatus;
155 BYTE SenseLen;
156 HWORD CommandStatus;
157 DWORD ResidualCnt;
158 MoreErrInfo_struct MoreErrInfo;
159 BYTE SenseInfo[SENSEINFOBYTES];
160} ErrorInfo_struct;
161
162#pragma pack()
163#endif /* CCISS_CMD_H */
164
165typedef struct _IOCTL_Command_struct {
166 LUNAddr_struct LUN_info;
167 RequestBlock_struct Request;
168 ErrorInfo_struct error_info;
169 WORD buf_size; /* size in bytes of the buf */
170 BYTE __user *buf;
171} IOCTL_Command_struct;
172
173typedef struct _BIG_IOCTL_Command_struct {
174 LUNAddr_struct LUN_info;
175 RequestBlock_struct Request;
176 ErrorInfo_struct error_info;
177 DWORD malloc_size; /* < MAX_KMALLOC_SIZE in cciss.c */
178 DWORD buf_size; /* size in bytes of the buf */
179 /* < malloc_size * MAXSGENTRIES */
180 BYTE __user *buf;
181} BIG_IOCTL_Command_struct;
182
183typedef struct _LogvolInfo_struct{
184 __u32 LunID;
185 int num_opens; /* number of opens on the logical volume */
186 int num_parts; /* number of partitions configured on logvol */
187} LogvolInfo_struct;
188
189#define CCISS_GETPCIINFO _IOR(CCISS_IOC_MAGIC, 1, cciss_pci_info_struct)
190
191#define CCISS_GETINTINFO _IOR(CCISS_IOC_MAGIC, 2, cciss_coalint_struct)
192#define CCISS_SETINTINFO _IOW(CCISS_IOC_MAGIC, 3, cciss_coalint_struct)
193
194#define CCISS_GETNODENAME _IOR(CCISS_IOC_MAGIC, 4, NodeName_type)
195#define CCISS_SETNODENAME _IOW(CCISS_IOC_MAGIC, 5, NodeName_type)
196
197#define CCISS_GETHEARTBEAT _IOR(CCISS_IOC_MAGIC, 6, Heartbeat_type)
198#define CCISS_GETBUSTYPES _IOR(CCISS_IOC_MAGIC, 7, BusTypes_type)
199#define CCISS_GETFIRMVER _IOR(CCISS_IOC_MAGIC, 8, FirmwareVer_type)
200#define CCISS_GETDRIVVER _IOR(CCISS_IOC_MAGIC, 9, DriverVer_type)
201#define CCISS_REVALIDVOLS _IO(CCISS_IOC_MAGIC, 10)
202#define CCISS_PASSTHRU _IOWR(CCISS_IOC_MAGIC, 11, IOCTL_Command_struct)
203#define CCISS_DEREGDISK _IO(CCISS_IOC_MAGIC, 12)
204
205/* no longer used... use REGNEWD instead */
206#define CCISS_REGNEWDISK _IOW(CCISS_IOC_MAGIC, 13, int)
207
208#define CCISS_REGNEWD _IO(CCISS_IOC_MAGIC, 14)
209#define CCISS_RESCANDISK _IO(CCISS_IOC_MAGIC, 16)
210#define CCISS_GETLUNINFO _IOR(CCISS_IOC_MAGIC, 17, LogvolInfo_struct)
211#define CCISS_BIG_PASSTHRU _IOWR(CCISS_IOC_MAGIC, 18, BIG_IOCTL_Command_struct)
212
213#ifdef __KERNEL__
214#ifdef CONFIG_COMPAT
215
216/* 32 bit compatible ioctl structs */
217typedef struct _IOCTL32_Command_struct {
218 LUNAddr_struct LUN_info;
219 RequestBlock_struct Request;
220 ErrorInfo_struct error_info;
221 WORD buf_size; /* size in bytes of the buf */
222 __u32 buf; /* 32 bit pointer to data buffer */
223} IOCTL32_Command_struct;
224
225typedef struct _BIG_IOCTL32_Command_struct {
226 LUNAddr_struct LUN_info;
227 RequestBlock_struct Request;
228 ErrorInfo_struct error_info;
229 DWORD malloc_size; /* < MAX_KMALLOC_SIZE in cciss.c */
230 DWORD buf_size; /* size in bytes of the buf */
231 /* < malloc_size * MAXSGENTRIES */
232 __u32 buf; /* 32 bit pointer to data buffer */
233} BIG_IOCTL32_Command_struct;
234
235#define CCISS_PASSTHRU32 _IOWR(CCISS_IOC_MAGIC, 11, IOCTL32_Command_struct)
236#define CCISS_BIG_PASSTHRU32 _IOWR(CCISS_IOC_MAGIC, 18, BIG_IOCTL32_Command_struct)
237
238#endif /* CONFIG_COMPAT */
239#endif /* __KERNEL__ */
240#endif
diff --git a/include/linux/cd1400.h b/include/linux/cd1400.h
new file mode 100644
index 000000000000..1dc3ab0523fd
--- /dev/null
+++ b/include/linux/cd1400.h
@@ -0,0 +1,292 @@
1/*****************************************************************************/
2
3/*
4 * cd1400.h -- cd1400 UART hardware info.
5 *
6 * Copyright (C) 1996-1998 Stallion Technologies
7 * Copyright (C) 1994-1996 Greg Ungerer.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24/*****************************************************************************/
25#ifndef _CD1400_H
26#define _CD1400_H
27/*****************************************************************************/
28
29/*
30 * Define the number of async ports per cd1400 uart chip.
31 */
32#define CD1400_PORTS 4
33
34/*
35 * Define the cd1400 uarts internal FIFO sizes.
36 */
37#define CD1400_TXFIFOSIZE 12
38#define CD1400_RXFIFOSIZE 12
39
40/*
41 * Local RX FIFO thresh hold level. Also define the RTS thresh hold
42 * based on the RX thresh hold.
43 */
44#define FIFO_RXTHRESHOLD 6
45#define FIFO_RTSTHRESHOLD 7
46
47/*****************************************************************************/
48
49/*
50 * Define the cd1400 register addresses. These are all the valid
51 * registers with the cd1400. Some are global, some virtual, some
52 * per port.
53 */
54#define GFRCR 0x40
55#define CAR 0x68
56#define GCR 0x4b
57#define SVRR 0x67
58#define RICR 0x44
59#define TICR 0x45
60#define MICR 0x46
61#define RIR 0x6b
62#define TIR 0x6a
63#define MIR 0x69
64#define PPR 0x7e
65
66#define RIVR 0x43
67#define TIVR 0x42
68#define MIVR 0x41
69#define TDR 0x63
70#define RDSR 0x62
71#define MISR 0x4c
72#define EOSRR 0x60
73
74#define LIVR 0x18
75#define CCR 0x05
76#define SRER 0x06
77#define COR1 0x08
78#define COR2 0x09
79#define COR3 0x0a
80#define COR4 0x1e
81#define COR5 0x1f
82#define CCSR 0x0b
83#define RDCR 0x0e
84#define SCHR1 0x1a
85#define SCHR2 0x1b
86#define SCHR3 0x1c
87#define SCHR4 0x1d
88#define SCRL 0x22
89#define SCRH 0x23
90#define LNC 0x24
91#define MCOR1 0x15
92#define MCOR2 0x16
93#define RTPR 0x21
94#define MSVR1 0x6c
95#define MSVR2 0x6d
96#define PSVR 0x6f
97#define RBPR 0x78
98#define RCOR 0x7c
99#define TBPR 0x72
100#define TCOR 0x76
101
102/*****************************************************************************/
103
104/*
105 * Define the set of baud rate clock divisors.
106 */
107#define CD1400_CLK0 8
108#define CD1400_CLK1 32
109#define CD1400_CLK2 128
110#define CD1400_CLK3 512
111#define CD1400_CLK4 2048
112
113#define CD1400_NUMCLKS 5
114
115/*****************************************************************************/
116
117/*
118 * Define the clock pre-scalar value to be a 5 ms clock. This should be
119 * OK for now. It would probably be better to make it 10 ms, but we
120 * can't fit that divisor into 8 bits!
121 */
122#define PPR_SCALAR 244
123
124/*****************************************************************************/
125
126/*
127 * Define values used to set character size options.
128 */
129#define COR1_CHL5 0x00
130#define COR1_CHL6 0x01
131#define COR1_CHL7 0x02
132#define COR1_CHL8 0x03
133
134/*
135 * Define values used to set the number of stop bits.
136 */
137#define COR1_STOP1 0x00
138#define COR1_STOP15 0x04
139#define COR1_STOP2 0x08
140
141/*
142 * Define values used to set the parity scheme in use.
143 */
144#define COR1_PARNONE 0x00
145#define COR1_PARFORCE 0x20
146#define COR1_PARENB 0x40
147#define COR1_PARIGNORE 0x10
148
149#define COR1_PARODD 0x80
150#define COR1_PAREVEN 0x00
151
152#define COR2_IXM 0x80
153#define COR2_TXIBE 0x40
154#define COR2_ETC 0x20
155#define COR2_LLM 0x10
156#define COR2_RLM 0x08
157#define COR2_RTSAO 0x04
158#define COR2_CTSAE 0x02
159
160#define COR3_SCDRNG 0x80
161#define COR3_SCD34 0x40
162#define COR3_FCT 0x20
163#define COR3_SCD12 0x10
164
165/*
166 * Define values used by COR4.
167 */
168#define COR4_BRKINT 0x08
169#define COR4_IGNBRK 0x18
170
171/*****************************************************************************/
172
173/*
174 * Define the modem control register values.
175 * Note that the actual hardware is a little different to the conventional
176 * pin names on the cd1400.
177 */
178#define MSVR1_DTR 0x01
179#define MSVR1_DSR 0x10
180#define MSVR1_RI 0x20
181#define MSVR1_CTS 0x40
182#define MSVR1_DCD 0x80
183
184#define MSVR2_RTS 0x02
185#define MSVR2_DSR 0x10
186#define MSVR2_RI 0x20
187#define MSVR2_CTS 0x40
188#define MSVR2_DCD 0x80
189
190#define MCOR1_DCD 0x80
191#define MCOR1_CTS 0x40
192#define MCOR1_RI 0x20
193#define MCOR1_DSR 0x10
194
195#define MCOR2_DCD 0x80
196#define MCOR2_CTS 0x40
197#define MCOR2_RI 0x20
198#define MCOR2_DSR 0x10
199
200/*****************************************************************************/
201
202/*
203 * Define the bits used with the service (interrupt) enable register.
204 */
205#define SRER_NNDT 0x01
206#define SRER_TXEMPTY 0x02
207#define SRER_TXDATA 0x04
208#define SRER_RXDATA 0x10
209#define SRER_MODEM 0x80
210
211/*****************************************************************************/
212
213/*
214 * Define operational commands for the command register.
215 */
216#define CCR_RESET 0x80
217#define CCR_CORCHANGE 0x4e
218#define CCR_SENDCH 0x20
219#define CCR_CHANCTRL 0x10
220
221#define CCR_TXENABLE (CCR_CHANCTRL | 0x08)
222#define CCR_TXDISABLE (CCR_CHANCTRL | 0x04)
223#define CCR_RXENABLE (CCR_CHANCTRL | 0x02)
224#define CCR_RXDISABLE (CCR_CHANCTRL | 0x01)
225
226#define CCR_SENDSCHR1 (CCR_SENDCH | 0x01)
227#define CCR_SENDSCHR2 (CCR_SENDCH | 0x02)
228#define CCR_SENDSCHR3 (CCR_SENDCH | 0x03)
229#define CCR_SENDSCHR4 (CCR_SENDCH | 0x04)
230
231#define CCR_RESETCHAN (CCR_RESET | 0x00)
232#define CCR_RESETFULL (CCR_RESET | 0x01)
233#define CCR_TXFLUSHFIFO (CCR_RESET | 0x02)
234
235#define CCR_MAXWAIT 10000
236
237/*****************************************************************************/
238
239/*
240 * Define the valid acknowledgement types (for hw ack cycle).
241 */
242#define ACK_TYPMASK 0x07
243#define ACK_TYPTX 0x02
244#define ACK_TYPMDM 0x01
245#define ACK_TYPRXGOOD 0x03
246#define ACK_TYPRXBAD 0x07
247
248#define SVRR_RX 0x01
249#define SVRR_TX 0x02
250#define SVRR_MDM 0x04
251
252#define ST_OVERRUN 0x01
253#define ST_FRAMING 0x02
254#define ST_PARITY 0x04
255#define ST_BREAK 0x08
256#define ST_SCHAR1 0x10
257#define ST_SCHAR2 0x20
258#define ST_SCHAR3 0x30
259#define ST_SCHAR4 0x40
260#define ST_RANGE 0x70
261#define ST_SCHARMASK 0x70
262#define ST_TIMEOUT 0x80
263
264#define MISR_DCD 0x80
265#define MISR_CTS 0x40
266#define MISR_RI 0x20
267#define MISR_DSR 0x10
268
269/*****************************************************************************/
270
271/*
272 * Defines for the CCSR status register.
273 */
274#define CCSR_RXENABLED 0x80
275#define CCSR_RXFLOWON 0x40
276#define CCSR_RXFLOWOFF 0x20
277#define CCSR_TXENABLED 0x08
278#define CCSR_TXFLOWON 0x04
279#define CCSR_TXFLOWOFF 0x02
280
281/*****************************************************************************/
282
283/*
284 * Define the embedded commands.
285 */
286#define ETC_CMD 0x00
287#define ETC_STARTBREAK 0x81
288#define ETC_DELAY 0x82
289#define ETC_STOPBREAK 0x83
290
291/*****************************************************************************/
292#endif
diff --git a/include/linux/cdev.h b/include/linux/cdev.h
new file mode 100644
index 000000000000..8da37e29cb87
--- /dev/null
+++ b/include/linux/cdev.h
@@ -0,0 +1,27 @@
1#ifndef _LINUX_CDEV_H
2#define _LINUX_CDEV_H
3#ifdef __KERNEL__
4
5struct cdev {
6 struct kobject kobj;
7 struct module *owner;
8 struct file_operations *ops;
9 struct list_head list;
10 dev_t dev;
11 unsigned int count;
12};
13
14void cdev_init(struct cdev *, struct file_operations *);
15
16struct cdev *cdev_alloc(void);
17
18void cdev_put(struct cdev *p);
19
20int cdev_add(struct cdev *, dev_t, unsigned);
21
22void cdev_del(struct cdev *);
23
24void cd_forget(struct inode *);
25
26#endif
27#endif
diff --git a/include/linux/cdk.h b/include/linux/cdk.h
new file mode 100644
index 000000000000..0908daf7bf56
--- /dev/null
+++ b/include/linux/cdk.h
@@ -0,0 +1,486 @@
1/*****************************************************************************/
2
3/*
4 * cdk.h -- CDK interface definitions.
5 *
6 * Copyright (C) 1996-1998 Stallion Technologies
7 * Copyright (C) 1994-1996 Greg Ungerer.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24/*****************************************************************************/
25#ifndef _CDK_H
26#define _CDK_H
27/*****************************************************************************/
28
29#pragma pack(2)
30
31/*
32 * The following set of definitions is used to communicate with the
33 * shared memory interface of the Stallion intelligent multiport serial
34 * boards. The definitions in this file are taken directly from the
35 * document titled "Generic Stackable Interface, Downloader and
36 * Communications Development Kit".
37 */
38
39/*
40 * Define the set of important shared memory addresses. These are
41 * required to initialize the board and get things started. All of these
42 * addresses are relative to the start of the shared memory.
43 */
44#define CDK_SIGADDR 0x200
45#define CDK_FEATADDR 0x280
46#define CDK_CDKADDR 0x300
47#define CDK_RDYADDR 0x262
48
49#define CDK_ALIVEMARKER 13
50
51/*
52 * On hardware power up the ROMs located on the EasyConnection 8/64 will
53 * fill out the following signature information into shared memory. This
54 * way the host system can quickly determine that the board is present
55 * and is operational.
56 */
57typedef struct cdkecpsig {
58 unsigned long magic;
59 unsigned short romver;
60 unsigned short cputype;
61 unsigned char panelid[8];
62} cdkecpsig_t;
63
64#define ECP_MAGIC 0x21504345
65
66/*
67 * On hardware power up the ROMs located on the ONboard, Stallion and
68 * Brumbys will fill out the following signature information into shared
69 * memory. This way the host system can quickly determine that the board
70 * is present and is operational.
71 */
72typedef struct cdkonbsig {
73 unsigned short magic0;
74 unsigned short magic1;
75 unsigned short magic2;
76 unsigned short magic3;
77 unsigned short romver;
78 unsigned short memoff;
79 unsigned short memseg;
80 unsigned short amask0;
81 unsigned short pic;
82 unsigned short status;
83 unsigned short btype;
84 unsigned short clkticks;
85 unsigned short clkspeed;
86 unsigned short amask1;
87 unsigned short amask2;
88} cdkonbsig_t;
89
90#define ONB_MAGIC0 0xf2a7
91#define ONB_MAGIC1 0xa149
92#define ONB_MAGIC2 0x6352
93#define ONB_MAGIC3 0xf121
94
95/*
96 * Define the feature area structure. The feature area is the set of
97 * startup parameters used by the slave image when it starts executing.
98 * They allow for the specification of buffer sizes, debug trace, etc.
99 */
100typedef struct cdkfeature {
101 unsigned long debug;
102 unsigned long banner;
103 unsigned long etype;
104 unsigned long nrdevs;
105 unsigned long brdspec;
106 unsigned long txrqsize;
107 unsigned long rxrqsize;
108 unsigned long flags;
109} cdkfeature_t;
110
111#define ETYP_DDK 0
112#define ETYP_CDK 1
113
114/*
115 * Define the CDK header structure. This is the info that the slave
116 * environment sets up after it has been downloaded and started. It
117 * essentially provides a memory map for the shared memory interface.
118 */
119typedef struct cdkhdr {
120 unsigned short command;
121 unsigned short status;
122 unsigned short port;
123 unsigned short mode;
124 unsigned long cmd_buf[14];
125 unsigned short alive_cnt;
126 unsigned short intrpt_mode;
127 unsigned char intrpt_id[8];
128 unsigned char ver_release;
129 unsigned char ver_modification;
130 unsigned char ver_fix;
131 unsigned char deadman_restart;
132 unsigned short deadman;
133 unsigned short nrdevs;
134 unsigned long memp;
135 unsigned long hostp;
136 unsigned long slavep;
137 unsigned char hostreq;
138 unsigned char slavereq;
139 unsigned char cmd_reserved[30];
140} cdkhdr_t;
141
142#define MODE_DDK 0
143#define MODE_CDK 1
144
145#define IMD_INTR 0x0
146#define IMD_PPINTR 0x1
147#define IMD_POLL 0xff
148
149/*
150 * Define the memory mapping structure. This structure is pointed to by
151 * the memp field in the stlcdkhdr struct. As many as these structures
152 * as required are layed out in shared memory to define how the rest of
153 * shared memory is divided up. There will be one for each port.
154 */
155typedef struct cdkmem {
156 unsigned short dtype;
157 unsigned long offset;
158} cdkmem_t;
159
160#define TYP_UNDEFINED 0x0
161#define TYP_ASYNCTRL 0x1
162#define TYP_ASYNC 0x20
163#define TYP_PARALLEL 0x40
164#define TYP_SYNCX21 0x60
165
166/*****************************************************************************/
167
168/*
169 * Following is a set of defines and structures used to actually deal
170 * with the serial ports on the board. Firstly is the set of commands
171 * that can be applied to ports.
172 */
173#define ASYCMD (((unsigned long) 'a') << 8)
174
175#define A_NULL (ASYCMD | 0)
176#define A_FLUSH (ASYCMD | 1)
177#define A_BREAK (ASYCMD | 2)
178#define A_GETPORT (ASYCMD | 3)
179#define A_SETPORT (ASYCMD | 4)
180#define A_SETPORTF (ASYCMD | 5)
181#define A_SETPORTFTX (ASYCMD | 6)
182#define A_SETPORTFRX (ASYCMD | 7)
183#define A_GETSIGNALS (ASYCMD | 8)
184#define A_SETSIGNALS (ASYCMD | 9)
185#define A_SETSIGNALSF (ASYCMD | 10)
186#define A_SETSIGNALSFTX (ASYCMD | 11)
187#define A_SETSIGNALSFRX (ASYCMD | 12)
188#define A_GETNOTIFY (ASYCMD | 13)
189#define A_SETNOTIFY (ASYCMD | 14)
190#define A_NOTIFY (ASYCMD | 15)
191#define A_PORTCTRL (ASYCMD | 16)
192#define A_GETSTATS (ASYCMD | 17)
193#define A_RQSTATE (ASYCMD | 18)
194#define A_FLOWSTATE (ASYCMD | 19)
195#define A_CLEARSTATS (ASYCMD | 20)
196
197/*
198 * Define those arguments used for simple commands.
199 */
200#define FLUSHRX 0x1
201#define FLUSHTX 0x2
202
203#define BREAKON -1
204#define BREAKOFF -2
205
206/*
207 * Define the port setting structure, and all those defines that go along
208 * with it. Basically this structure defines the characteristics of this
209 * port: baud rate, chars, parity, input/output char cooking etc.
210 */
211typedef struct asyport {
212 unsigned long baudout;
213 unsigned long baudin;
214 unsigned long iflag;
215 unsigned long oflag;
216 unsigned long lflag;
217 unsigned long pflag;
218 unsigned long flow;
219 unsigned long spare1;
220 unsigned short vtime;
221 unsigned short vmin;
222 unsigned short txlo;
223 unsigned short txhi;
224 unsigned short rxlo;
225 unsigned short rxhi;
226 unsigned short rxhog;
227 unsigned short spare2;
228 unsigned char csize;
229 unsigned char stopbs;
230 unsigned char parity;
231 unsigned char stopin;
232 unsigned char startin;
233 unsigned char stopout;
234 unsigned char startout;
235 unsigned char parmark;
236 unsigned char brkmark;
237 unsigned char cc[11];
238} asyport_t;
239
240#define PT_STOP1 0x0
241#define PT_STOP15 0x1
242#define PT_STOP2 0x2
243
244#define PT_NOPARITY 0x0
245#define PT_ODDPARITY 0x1
246#define PT_EVENPARITY 0x2
247#define PT_MARKPARITY 0x3
248#define PT_SPACEPARITY 0x4
249
250#define F_NONE 0x0
251#define F_IXON 0x1
252#define F_IXOFF 0x2
253#define F_IXANY 0x4
254#define F_IOXANY 0x8
255#define F_RTSFLOW 0x10
256#define F_CTSFLOW 0x20
257#define F_DTRFLOW 0x40
258#define F_DCDFLOW 0x80
259#define F_DSROFLOW 0x100
260#define F_DSRIFLOW 0x200
261
262#define FI_NORX 0x1
263#define FI_RAW 0x2
264#define FI_ISTRIP 0x4
265#define FI_UCLC 0x8
266#define FI_INLCR 0x10
267#define FI_ICRNL 0x20
268#define FI_IGNCR 0x40
269#define FI_IGNBREAK 0x80
270#define FI_DSCRDBREAK 0x100
271#define FI_1MARKBREAK 0x200
272#define FI_2MARKBREAK 0x400
273#define FI_XCHNGBREAK 0x800
274#define FI_IGNRXERRS 0x1000
275#define FI_DSCDRXERRS 0x2000
276#define FI_1MARKRXERRS 0x4000
277#define FI_2MARKRXERRS 0x8000
278#define FI_XCHNGRXERRS 0x10000
279#define FI_DSCRDNULL 0x20000
280
281#define FO_OLCUC 0x1
282#define FO_ONLCR 0x2
283#define FO_OOCRNL 0x4
284#define FO_ONOCR 0x8
285#define FO_ONLRET 0x10
286#define FO_ONL 0x20
287#define FO_OBS 0x40
288#define FO_OVT 0x80
289#define FO_OFF 0x100
290#define FO_OTAB1 0x200
291#define FO_OTAB2 0x400
292#define FO_OTAB3 0x800
293#define FO_OCR1 0x1000
294#define FO_OCR2 0x2000
295#define FO_OCR3 0x4000
296#define FO_OFILL 0x8000
297#define FO_ODELL 0x10000
298
299#define P_RTSLOCK 0x1
300#define P_CTSLOCK 0x2
301#define P_MAPRTS 0x4
302#define P_MAPCTS 0x8
303#define P_LOOPBACK 0x10
304#define P_DTRFOLLOW 0x20
305#define P_FAKEDCD 0x40
306
307#define P_RXIMIN 0x10000
308#define P_RXITIME 0x20000
309#define P_RXTHOLD 0x40000
310
311/*
312 * Define a structure to communicate serial port signal and data state
313 * information.
314 */
315typedef struct asysigs {
316 unsigned long data;
317 unsigned long signal;
318 unsigned long sigvalue;
319} asysigs_t;
320
321#define DT_TXBUSY 0x1
322#define DT_TXEMPTY 0x2
323#define DT_TXLOW 0x4
324#define DT_TXHIGH 0x8
325#define DT_TXFULL 0x10
326#define DT_TXHOG 0x20
327#define DT_TXFLOWED 0x40
328#define DT_TXBREAK 0x80
329
330#define DT_RXBUSY 0x100
331#define DT_RXEMPTY 0x200
332#define DT_RXLOW 0x400
333#define DT_RXHIGH 0x800
334#define DT_RXFULL 0x1000
335#define DT_RXHOG 0x2000
336#define DT_RXFLOWED 0x4000
337#define DT_RXBREAK 0x8000
338
339#define SG_DTR 0x1
340#define SG_DCD 0x2
341#define SG_RTS 0x4
342#define SG_CTS 0x8
343#define SG_DSR 0x10
344#define SG_RI 0x20
345
346/*
347 * Define the notification setting structure. This is used to tell the
348 * port what events we want to be informed about. Fields here use the
349 * same defines as for the asysigs structure above.
350 */
351typedef struct asynotify {
352 unsigned long ctrl;
353 unsigned long data;
354 unsigned long signal;
355 unsigned long sigvalue;
356} asynotify_t;
357
358/*
359 * Define the port control structure. It is used to do fine grain
360 * control operations on the port.
361 */
362typedef struct {
363 unsigned long rxctrl;
364 unsigned long txctrl;
365 char rximdch;
366 char tximdch;
367 char spare1;
368 char spare2;
369} asyctrl_t;
370
371#define CT_ENABLE 0x1
372#define CT_DISABLE 0x2
373#define CT_STOP 0x4
374#define CT_START 0x8
375#define CT_STARTFLOW 0x10
376#define CT_STOPFLOW 0x20
377#define CT_SENDCHR 0x40
378
379/*
380 * Define the stats structure kept for each port. This is a useful set
381 * of data collected for each port on the slave. The A_GETSTATS command
382 * is used to retrieve this data from the slave.
383 */
384typedef struct asystats {
385 unsigned long opens;
386 unsigned long txchars;
387 unsigned long rxchars;
388 unsigned long txringq;
389 unsigned long rxringq;
390 unsigned long txmsgs;
391 unsigned long rxmsgs;
392 unsigned long txflushes;
393 unsigned long rxflushes;
394 unsigned long overruns;
395 unsigned long framing;
396 unsigned long parity;
397 unsigned long ringover;
398 unsigned long lost;
399 unsigned long rxstart;
400 unsigned long rxstop;
401 unsigned long txstart;
402 unsigned long txstop;
403 unsigned long dcdcnt;
404 unsigned long dtrcnt;
405 unsigned long ctscnt;
406 unsigned long rtscnt;
407 unsigned long dsrcnt;
408 unsigned long ricnt;
409 unsigned long txbreaks;
410 unsigned long rxbreaks;
411 unsigned long signals;
412 unsigned long state;
413 unsigned long hwid;
414} asystats_t;
415
416/*****************************************************************************/
417
418/*
419 * All command and control communication with a device on the slave is
420 * via a control block in shared memory. Each device has its own control
421 * block, defined by the following structure. The control block allows
422 * the host to open, close and control the device on the slave.
423 */
424typedef struct cdkctrl {
425 unsigned char open;
426 unsigned char close;
427 unsigned long openarg;
428 unsigned long closearg;
429 unsigned long cmd;
430 unsigned long status;
431 unsigned long args[32];
432} cdkctrl_t;
433
434/*
435 * Each device on the slave passes data to and from the host via a ring
436 * queue in shared memory. Define a ring queue structure to hold the
437 * vital information about each ring queue. Two ring queues will be
438 * allocated for each port, one for receive data and one for transmit
439 * data.
440 */
441typedef struct cdkasyrq {
442 unsigned long offset;
443 unsigned short size;
444 unsigned short head;
445 unsigned short tail;
446} cdkasyrq_t;
447
448/*
449 * Each asynchronous port is defined in shared memory by the following
450 * structure. It contains a control block to command a device, and also
451 * the necessary data channel information as well.
452 */
453typedef struct cdkasy {
454 cdkctrl_t ctrl;
455 unsigned short notify;
456 asynotify_t changed;
457 unsigned short receive;
458 cdkasyrq_t rxq;
459 unsigned short transmit;
460 cdkasyrq_t txq;
461} cdkasy_t;
462
463#pragma pack()
464
465/*****************************************************************************/
466
467/*
468 * Define the set of ioctls used by the driver to do special things
469 * to the board. These include interrupting it, and initializing
470 * the driver after board startup and shutdown.
471 */
472#include <linux/ioctl.h>
473
474#define STL_BINTR _IO('s',20)
475#define STL_BSTART _IO('s',21)
476#define STL_BSTOP _IO('s',22)
477#define STL_BRESET _IO('s',23)
478
479/*
480 * Define a set of ioctl extensions, used to get at special stuff.
481 */
482#define STL_GETPFLAG _IO('s',80)
483#define STL_SETPFLAG _IO('s',81)
484
485/*****************************************************************************/
486#endif
diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
new file mode 100644
index 000000000000..b68fdf1f3156
--- /dev/null
+++ b/include/linux/cdrom.h
@@ -0,0 +1,1192 @@
1/*
2 * -- <linux/cdrom.h>
3 * General header file for linux CD-ROM drivers
4 * Copyright (C) 1992 David Giller, rafetmad@oxy.edu
5 * 1994, 1995 Eberhard Moenkeberg, emoenke@gwdg.de
6 * 1996 David van Leeuwen, david@tm.tno.nl
7 * 1997, 1998 Erik Andersen, andersee@debian.org
8 * 1998-2002 Jens Axboe, axboe@suse.de
9 */
10
11#ifndef _LINUX_CDROM_H
12#define _LINUX_CDROM_H
13
14#include <asm/byteorder.h>
15
16/*******************************************************
17 * As of Linux 2.1.x, all Linux CD-ROM application programs will use this
18 * (and only this) include file. It is my hope to provide Linux with
19 * a uniform interface between software accessing CD-ROMs and the various
20 * device drivers that actually talk to the drives. There may still be
21 * 23 different kinds of strange CD-ROM drives, but at least there will
22 * now be one, and only one, Linux CD-ROM interface.
23 *
24 * Additionally, as of Linux 2.1.x, all Linux application programs
25 * should use the O_NONBLOCK option when opening a CD-ROM device
26 * for subsequent ioctl commands. This allows for neat system errors
27 * like "No medium found" or "Wrong medium type" upon attempting to
28 * mount or play an empty slot, mount an audio disc, or play a data disc.
29 * Generally, changing an application program to support O_NONBLOCK
30 * is as easy as the following:
31 * - drive = open("/dev/cdrom", O_RDONLY);
32 * + drive = open("/dev/cdrom", O_RDONLY | O_NONBLOCK);
33 * It is worth the small change.
34 *
35 * Patches for many common CD programs (provided by David A. van Leeuwen)
36 * can be found at: ftp://ftp.gwdg.de/pub/linux/cdrom/drivers/cm206/
37 *
38 *******************************************************/
39
40/* When a driver supports a certain function, but the cdrom drive we are
41 * using doesn't, we will return the error EDRIVE_CANT_DO_THIS. We will
42 * borrow the "Operation not supported" error from the network folks to
43 * accomplish this. Maybe someday we will get a more targeted error code,
44 * but this will do for now... */
45#define EDRIVE_CANT_DO_THIS EOPNOTSUPP
46
47/*******************************************************
48 * The CD-ROM IOCTL commands -- these should be supported by
49 * all the various cdrom drivers. For the CD-ROM ioctls, we
50 * will commandeer byte 0x53, or 'S'.
51 *******************************************************/
52#define CDROMPAUSE 0x5301 /* Pause Audio Operation */
53#define CDROMRESUME 0x5302 /* Resume paused Audio Operation */
54#define CDROMPLAYMSF 0x5303 /* Play Audio MSF (struct cdrom_msf) */
55#define CDROMPLAYTRKIND 0x5304 /* Play Audio Track/index
56 (struct cdrom_ti) */
57#define CDROMREADTOCHDR 0x5305 /* Read TOC header
58 (struct cdrom_tochdr) */
59#define CDROMREADTOCENTRY 0x5306 /* Read TOC entry
60 (struct cdrom_tocentry) */
61#define CDROMSTOP 0x5307 /* Stop the cdrom drive */
62#define CDROMSTART 0x5308 /* Start the cdrom drive */
63#define CDROMEJECT 0x5309 /* Ejects the cdrom media */
64#define CDROMVOLCTRL 0x530a /* Control output volume
65 (struct cdrom_volctrl) */
66#define CDROMSUBCHNL 0x530b /* Read subchannel data
67 (struct cdrom_subchnl) */
68#define CDROMREADMODE2 0x530c /* Read CDROM mode 2 data (2336 Bytes)
69 (struct cdrom_read) */
70#define CDROMREADMODE1 0x530d /* Read CDROM mode 1 data (2048 Bytes)
71 (struct cdrom_read) */
72#define CDROMREADAUDIO 0x530e /* (struct cdrom_read_audio) */
73#define CDROMEJECT_SW 0x530f /* enable(1)/disable(0) auto-ejecting */
74#define CDROMMULTISESSION 0x5310 /* Obtain the start-of-last-session
75 address of multi session disks
76 (struct cdrom_multisession) */
77#define CDROM_GET_MCN 0x5311 /* Obtain the "Universal Product Code"
78 if available (struct cdrom_mcn) */
79#define CDROM_GET_UPC CDROM_GET_MCN /* This one is depricated,
80 but here anyway for compatibility */
81#define CDROMRESET 0x5312 /* hard-reset the drive */
82#define CDROMVOLREAD 0x5313 /* Get the drive's volume setting
83 (struct cdrom_volctrl) */
84#define CDROMREADRAW 0x5314 /* read data in raw mode (2352 Bytes)
85 (struct cdrom_read) */
86/*
87 * These ioctls are used only used in aztcd.c and optcd.c
88 */
89#define CDROMREADCOOKED 0x5315 /* read data in cooked mode */
90#define CDROMSEEK 0x5316 /* seek msf address */
91
92/*
93 * This ioctl is only used by the scsi-cd driver.
94 It is for playing audio in logical block addressing mode.
95 */
96#define CDROMPLAYBLK 0x5317 /* (struct cdrom_blk) */
97
98/*
99 * These ioctls are only used in optcd.c
100 */
101#define CDROMREADALL 0x5318 /* read all 2646 bytes */
102
103/*
104 * These ioctls are (now) only in ide-cd.c for controlling
105 * drive spindown time. They should be implemented in the
106 * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10,
107 * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE...
108 * -Erik
109 */
110#define CDROMGETSPINDOWN 0x531d
111#define CDROMSETSPINDOWN 0x531e
112
113/*
114 * These ioctls are implemented through the uniform CD-ROM driver
115 * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM
116 * drivers are eventually ported to the uniform CD-ROM driver interface.
117 */
118#define CDROMCLOSETRAY 0x5319 /* pendant of CDROMEJECT */
119#define CDROM_SET_OPTIONS 0x5320 /* Set behavior options */
120#define CDROM_CLEAR_OPTIONS 0x5321 /* Clear behavior options */
121#define CDROM_SELECT_SPEED 0x5322 /* Set the CD-ROM speed */
122#define CDROM_SELECT_DISC 0x5323 /* Select disc (for juke-boxes) */
123#define CDROM_MEDIA_CHANGED 0x5325 /* Check is media changed */
124#define CDROM_DRIVE_STATUS 0x5326 /* Get tray position, etc. */
125#define CDROM_DISC_STATUS 0x5327 /* Get disc type, etc. */
126#define CDROM_CHANGER_NSLOTS 0x5328 /* Get number of slots */
127#define CDROM_LOCKDOOR 0x5329 /* lock or unlock door */
128#define CDROM_DEBUG 0x5330 /* Turn debug messages on/off */
129#define CDROM_GET_CAPABILITY 0x5331 /* get capabilities */
130
131/* Note that scsi/scsi_ioctl.h also uses 0x5382 - 0x5386.
132 * Future CDROM ioctls should be kept below 0x537F
133 */
134
135/* This ioctl is only used by sbpcd at the moment */
136#define CDROMAUDIOBUFSIZ 0x5382 /* set the audio buffer size */
137 /* conflict with SCSI_IOCTL_GET_IDLUN */
138
139/* DVD-ROM Specific ioctls */
140#define DVD_READ_STRUCT 0x5390 /* Read structure */
141#define DVD_WRITE_STRUCT 0x5391 /* Write structure */
142#define DVD_AUTH 0x5392 /* Authentication */
143
144#define CDROM_SEND_PACKET 0x5393 /* send a packet to the drive */
145#define CDROM_NEXT_WRITABLE 0x5394 /* get next writable block */
146#define CDROM_LAST_WRITTEN 0x5395 /* get last block written on disc */
147
148/*******************************************************
149 * CDROM IOCTL structures
150 *******************************************************/
151
152/* Address in MSF format */
153struct cdrom_msf0
154{
155 __u8 minute;
156 __u8 second;
157 __u8 frame;
158};
159
160/* Address in either MSF or logical format */
161union cdrom_addr
162{
163 struct cdrom_msf0 msf;
164 int lba;
165};
166
167/* This struct is used by the CDROMPLAYMSF ioctl */
168struct cdrom_msf
169{
170 __u8 cdmsf_min0; /* start minute */
171 __u8 cdmsf_sec0; /* start second */
172 __u8 cdmsf_frame0; /* start frame */
173 __u8 cdmsf_min1; /* end minute */
174 __u8 cdmsf_sec1; /* end second */
175 __u8 cdmsf_frame1; /* end frame */
176};
177
178/* This struct is used by the CDROMPLAYTRKIND ioctl */
179struct cdrom_ti
180{
181 __u8 cdti_trk0; /* start track */
182 __u8 cdti_ind0; /* start index */
183 __u8 cdti_trk1; /* end track */
184 __u8 cdti_ind1; /* end index */
185};
186
187/* This struct is used by the CDROMREADTOCHDR ioctl */
188struct cdrom_tochdr
189{
190 __u8 cdth_trk0; /* start track */
191 __u8 cdth_trk1; /* end track */
192};
193
194/* This struct is used by the CDROMVOLCTRL and CDROMVOLREAD ioctls */
195struct cdrom_volctrl
196{
197 __u8 channel0;
198 __u8 channel1;
199 __u8 channel2;
200 __u8 channel3;
201};
202
203/* This struct is used by the CDROMSUBCHNL ioctl */
204struct cdrom_subchnl
205{
206 __u8 cdsc_format;
207 __u8 cdsc_audiostatus;
208 __u8 cdsc_adr: 4;
209 __u8 cdsc_ctrl: 4;
210 __u8 cdsc_trk;
211 __u8 cdsc_ind;
212 union cdrom_addr cdsc_absaddr;
213 union cdrom_addr cdsc_reladdr;
214};
215
216
217/* This struct is used by the CDROMREADTOCENTRY ioctl */
218struct cdrom_tocentry
219{
220 __u8 cdte_track;
221 __u8 cdte_adr :4;
222 __u8 cdte_ctrl :4;
223 __u8 cdte_format;
224 union cdrom_addr cdte_addr;
225 __u8 cdte_datamode;
226};
227
228/* This struct is used by the CDROMREADMODE1, and CDROMREADMODE2 ioctls */
229struct cdrom_read
230{
231 int cdread_lba;
232 char *cdread_bufaddr;
233 int cdread_buflen;
234};
235
236/* This struct is used by the CDROMREADAUDIO ioctl */
237struct cdrom_read_audio
238{
239 union cdrom_addr addr; /* frame address */
240 __u8 addr_format; /* CDROM_LBA or CDROM_MSF */
241 int nframes; /* number of 2352-byte-frames to read at once */
242 __u8 __user *buf; /* frame buffer (size: nframes*2352 bytes) */
243};
244
245/* This struct is used with the CDROMMULTISESSION ioctl */
246struct cdrom_multisession
247{
248 union cdrom_addr addr; /* frame address: start-of-last-session
249 (not the new "frame 16"!). Only valid
250 if the "xa_flag" is true. */
251 __u8 xa_flag; /* 1: "is XA disk" */
252 __u8 addr_format; /* CDROM_LBA or CDROM_MSF */
253};
254
255/* This struct is used with the CDROM_GET_MCN ioctl.
256 * Very few audio discs actually have Universal Product Code information,
257 * which should just be the Medium Catalog Number on the box. Also note
258 * that the way the codeis written on CD is _not_ uniform across all discs!
259 */
260struct cdrom_mcn
261{
262 __u8 medium_catalog_number[14]; /* 13 ASCII digits, null-terminated */
263};
264
265/* This is used by the CDROMPLAYBLK ioctl */
266struct cdrom_blk
267{
268 unsigned from;
269 unsigned short len;
270};
271
272#define CDROM_PACKET_SIZE 12
273
274#define CGC_DATA_UNKNOWN 0
275#define CGC_DATA_WRITE 1
276#define CGC_DATA_READ 2
277#define CGC_DATA_NONE 3
278
279/* for CDROM_PACKET_COMMAND ioctl */
280struct cdrom_generic_command
281{
282 unsigned char cmd[CDROM_PACKET_SIZE];
283 unsigned char __user *buffer;
284 unsigned int buflen;
285 int stat;
286 struct request_sense __user *sense;
287 unsigned char data_direction;
288 int quiet;
289 int timeout;
290 void __user *reserved[1]; /* unused, actually */
291};
292
293/*
294 * A CD-ROM physical sector size is 2048, 2052, 2056, 2324, 2332, 2336,
295 * 2340, or 2352 bytes long.
296
297* Sector types of the standard CD-ROM data formats:
298 *
299 * format sector type user data size (bytes)
300 * -----------------------------------------------------------------------------
301 * 1 (Red Book) CD-DA 2352 (CD_FRAMESIZE_RAW)
302 * 2 (Yellow Book) Mode1 Form1 2048 (CD_FRAMESIZE)
303 * 3 (Yellow Book) Mode1 Form2 2336 (CD_FRAMESIZE_RAW0)
304 * 4 (Green Book) Mode2 Form1 2048 (CD_FRAMESIZE)
305 * 5 (Green Book) Mode2 Form2 2328 (2324+4 spare bytes)
306 *
307 *
308 * The layout of the standard CD-ROM data formats:
309 * -----------------------------------------------------------------------------
310 * - audio (red): | audio_sample_bytes |
311 * | 2352 |
312 *
313 * - data (yellow, mode1): | sync - head - data - EDC - zero - ECC |
314 * | 12 - 4 - 2048 - 4 - 8 - 276 |
315 *
316 * - data (yellow, mode2): | sync - head - data |
317 * | 12 - 4 - 2336 |
318 *
319 * - XA data (green, mode2 form1): | sync - head - sub - data - EDC - ECC |
320 * | 12 - 4 - 8 - 2048 - 4 - 276 |
321 *
322 * - XA data (green, mode2 form2): | sync - head - sub - data - Spare |
323 * | 12 - 4 - 8 - 2324 - 4 |
324 *
325 */
326
327/* Some generally useful CD-ROM information -- mostly based on the above */
328#define CD_MINS 74 /* max. minutes per CD, not really a limit */
329#define CD_SECS 60 /* seconds per minute */
330#define CD_FRAMES 75 /* frames per second */
331#define CD_SYNC_SIZE 12 /* 12 sync bytes per raw data frame */
332#define CD_MSF_OFFSET 150 /* MSF numbering offset of first frame */
333#define CD_CHUNK_SIZE 24 /* lowest-level "data bytes piece" */
334#define CD_NUM_OF_CHUNKS 98 /* chunks per frame */
335#define CD_FRAMESIZE_SUB 96 /* subchannel data "frame" size */
336#define CD_HEAD_SIZE 4 /* header (address) bytes per raw data frame */
337#define CD_SUBHEAD_SIZE 8 /* subheader bytes per raw XA data frame */
338#define CD_EDC_SIZE 4 /* bytes EDC per most raw data frame types */
339#define CD_ZERO_SIZE 8 /* bytes zero per yellow book mode 1 frame */
340#define CD_ECC_SIZE 276 /* bytes ECC per most raw data frame types */
341#define CD_FRAMESIZE 2048 /* bytes per frame, "cooked" mode */
342#define CD_FRAMESIZE_RAW 2352 /* bytes per frame, "raw" mode */
343#define CD_FRAMESIZE_RAWER 2646 /* The maximum possible returned bytes */
344/* most drives don't deliver everything: */
345#define CD_FRAMESIZE_RAW1 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE) /*2340*/
346#define CD_FRAMESIZE_RAW0 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE-CD_HEAD_SIZE) /*2336*/
347
348#define CD_XA_HEAD (CD_HEAD_SIZE+CD_SUBHEAD_SIZE) /* "before data" part of raw XA frame */
349#define CD_XA_TAIL (CD_EDC_SIZE+CD_ECC_SIZE) /* "after data" part of raw XA frame */
350#define CD_XA_SYNC_HEAD (CD_SYNC_SIZE+CD_XA_HEAD) /* sync bytes + header of XA frame */
351
352/* CD-ROM address types (cdrom_tocentry.cdte_format) */
353#define CDROM_LBA 0x01 /* "logical block": first frame is #0 */
354#define CDROM_MSF 0x02 /* "minute-second-frame": binary, not bcd here! */
355
356/* bit to tell whether track is data or audio (cdrom_tocentry.cdte_ctrl) */
357#define CDROM_DATA_TRACK 0x04
358
359/* The leadout track is always 0xAA, regardless of # of tracks on disc */
360#define CDROM_LEADOUT 0xAA
361
362/* audio states (from SCSI-2, but seen with other drives, too) */
363#define CDROM_AUDIO_INVALID 0x00 /* audio status not supported */
364#define CDROM_AUDIO_PLAY 0x11 /* audio play operation in progress */
365#define CDROM_AUDIO_PAUSED 0x12 /* audio play operation paused */
366#define CDROM_AUDIO_COMPLETED 0x13 /* audio play successfully completed */
367#define CDROM_AUDIO_ERROR 0x14 /* audio play stopped due to error */
368#define CDROM_AUDIO_NO_STATUS 0x15 /* no current audio status to return */
369
370/* capability flags used with the uniform CD-ROM driver */
371#define CDC_CLOSE_TRAY 0x1 /* caddy systems _can't_ close */
372#define CDC_OPEN_TRAY 0x2 /* but _can_ eject. */
373#define CDC_LOCK 0x4 /* disable manual eject */
374#define CDC_SELECT_SPEED 0x8 /* programmable speed */
375#define CDC_SELECT_DISC 0x10 /* select disc from juke-box */
376#define CDC_MULTI_SESSION 0x20 /* read sessions>1 */
377#define CDC_MCN 0x40 /* Medium Catalog Number */
378#define CDC_MEDIA_CHANGED 0x80 /* media changed */
379#define CDC_PLAY_AUDIO 0x100 /* audio functions */
380#define CDC_RESET 0x200 /* hard reset device */
381#define CDC_IOCTLS 0x400 /* driver has non-standard ioctls */
382#define CDC_DRIVE_STATUS 0x800 /* driver implements drive status */
383#define CDC_GENERIC_PACKET 0x1000 /* driver implements generic packets */
384#define CDC_CD_R 0x2000 /* drive is a CD-R */
385#define CDC_CD_RW 0x4000 /* drive is a CD-RW */
386#define CDC_DVD 0x8000 /* drive is a DVD */
387#define CDC_DVD_R 0x10000 /* drive can write DVD-R */
388#define CDC_DVD_RAM 0x20000 /* drive can write DVD-RAM */
389#define CDC_MO_DRIVE 0x40000 /* drive is an MO device */
390#define CDC_MRW 0x80000 /* drive can read MRW */
391#define CDC_MRW_W 0x100000 /* drive can write MRW */
392#define CDC_RAM 0x200000 /* ok to open for WRITE */
393
394/* drive status possibilities returned by CDROM_DRIVE_STATUS ioctl */
395#define CDS_NO_INFO 0 /* if not implemented */
396#define CDS_NO_DISC 1
397#define CDS_TRAY_OPEN 2
398#define CDS_DRIVE_NOT_READY 3
399#define CDS_DISC_OK 4
400
401/* return values for the CDROM_DISC_STATUS ioctl */
402/* can also return CDS_NO_[INFO|DISC], from above */
403#define CDS_AUDIO 100
404#define CDS_DATA_1 101
405#define CDS_DATA_2 102
406#define CDS_XA_2_1 103
407#define CDS_XA_2_2 104
408#define CDS_MIXED 105
409
410/* User-configurable behavior options for the uniform CD-ROM driver */
411#define CDO_AUTO_CLOSE 0x1 /* close tray on first open() */
412#define CDO_AUTO_EJECT 0x2 /* open tray on last release() */
413#define CDO_USE_FFLAGS 0x4 /* use O_NONBLOCK information on open */
414#define CDO_LOCK 0x8 /* lock tray on open files */
415#define CDO_CHECK_TYPE 0x10 /* check type on open for data */
416
417/* Special codes used when specifying changer slots. */
418#define CDSL_NONE ((int) (~0U>>1)-1)
419#define CDSL_CURRENT ((int) (~0U>>1))
420
421/* For partition based multisession access. IDE can handle 64 partitions
422 * per drive - SCSI CD-ROM's use minors to differentiate between the
423 * various drives, so we can't do multisessions the same way there.
424 * Use the -o session=x option to mount on them.
425 */
426#define CD_PART_MAX 64
427#define CD_PART_MASK (CD_PART_MAX - 1)
428
429/*********************************************************************
430 * Generic Packet commands, MMC commands, and such
431 *********************************************************************/
432
433 /* The generic packet command opcodes for CD/DVD Logical Units,
434 * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */
435#define GPCMD_BLANK 0xa1
436#define GPCMD_CLOSE_TRACK 0x5b
437#define GPCMD_FLUSH_CACHE 0x35
438#define GPCMD_FORMAT_UNIT 0x04
439#define GPCMD_GET_CONFIGURATION 0x46
440#define GPCMD_GET_EVENT_STATUS_NOTIFICATION 0x4a
441#define GPCMD_GET_PERFORMANCE 0xac
442#define GPCMD_INQUIRY 0x12
443#define GPCMD_LOAD_UNLOAD 0xa6
444#define GPCMD_MECHANISM_STATUS 0xbd
445#define GPCMD_MODE_SELECT_10 0x55
446#define GPCMD_MODE_SENSE_10 0x5a
447#define GPCMD_PAUSE_RESUME 0x4b
448#define GPCMD_PLAY_AUDIO_10 0x45
449#define GPCMD_PLAY_AUDIO_MSF 0x47
450#define GPCMD_PLAY_AUDIO_TI 0x48
451#define GPCMD_PLAY_CD 0xbc
452#define GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1e
453#define GPCMD_READ_10 0x28
454#define GPCMD_READ_12 0xa8
455#define GPCMD_READ_BUFFER_CAPACITY 0x5c
456#define GPCMD_READ_CDVD_CAPACITY 0x25
457#define GPCMD_READ_CD 0xbe
458#define GPCMD_READ_CD_MSF 0xb9
459#define GPCMD_READ_DISC_INFO 0x51
460#define GPCMD_READ_DVD_STRUCTURE 0xad
461#define GPCMD_READ_FORMAT_CAPACITIES 0x23
462#define GPCMD_READ_HEADER 0x44
463#define GPCMD_READ_TRACK_RZONE_INFO 0x52
464#define GPCMD_READ_SUBCHANNEL 0x42
465#define GPCMD_READ_TOC_PMA_ATIP 0x43
466#define GPCMD_REPAIR_RZONE_TRACK 0x58
467#define GPCMD_REPORT_KEY 0xa4
468#define GPCMD_REQUEST_SENSE 0x03
469#define GPCMD_RESERVE_RZONE_TRACK 0x53
470#define GPCMD_SEND_CUE_SHEET 0x5d
471#define GPCMD_SCAN 0xba
472#define GPCMD_SEEK 0x2b
473#define GPCMD_SEND_DVD_STRUCTURE 0xbf
474#define GPCMD_SEND_EVENT 0xa2
475#define GPCMD_SEND_KEY 0xa3
476#define GPCMD_SEND_OPC 0x54
477#define GPCMD_SET_READ_AHEAD 0xa7
478#define GPCMD_SET_STREAMING 0xb6
479#define GPCMD_START_STOP_UNIT 0x1b
480#define GPCMD_STOP_PLAY_SCAN 0x4e
481#define GPCMD_TEST_UNIT_READY 0x00
482#define GPCMD_VERIFY_10 0x2f
483#define GPCMD_WRITE_10 0x2a
484#define GPCMD_WRITE_AND_VERIFY_10 0x2e
485/* This is listed as optional in ATAPI 2.6, but is (curiously)
486 * missing from Mt. Fuji, Table 57. It _is_ mentioned in Mt. Fuji
487 * Table 377 as an MMC command for SCSi devices though... Most ATAPI
488 * drives support it. */
489#define GPCMD_SET_SPEED 0xbb
490/* This seems to be a SCSI specific CD-ROM opcode
491 * to play data at track/index */
492#define GPCMD_PLAYAUDIO_TI 0x48
493/*
494 * From MS Media Status Notification Support Specification. For
495 * older drives only.
496 */
497#define GPCMD_GET_MEDIA_STATUS 0xda
498
499/* Mode page codes for mode sense/set */
500#define GPMODE_VENDOR_PAGE 0x00
501#define GPMODE_R_W_ERROR_PAGE 0x01
502#define GPMODE_WRITE_PARMS_PAGE 0x05
503#define GPMODE_WCACHING_PAGE 0x08
504#define GPMODE_AUDIO_CTL_PAGE 0x0e
505#define GPMODE_POWER_PAGE 0x1a
506#define GPMODE_FAULT_FAIL_PAGE 0x1c
507#define GPMODE_TO_PROTECT_PAGE 0x1d
508#define GPMODE_CAPABILITIES_PAGE 0x2a
509#define GPMODE_ALL_PAGES 0x3f
510/* Not in Mt. Fuji, but in ATAPI 2.6 -- depricated now in favor
511 * of MODE_SENSE_POWER_PAGE */
512#define GPMODE_CDROM_PAGE 0x0d
513
514
515
516/* DVD struct types */
517#define DVD_STRUCT_PHYSICAL 0x00
518#define DVD_STRUCT_COPYRIGHT 0x01
519#define DVD_STRUCT_DISCKEY 0x02
520#define DVD_STRUCT_BCA 0x03
521#define DVD_STRUCT_MANUFACT 0x04
522
523struct dvd_layer {
524 __u8 book_version : 4;
525 __u8 book_type : 4;
526 __u8 min_rate : 4;
527 __u8 disc_size : 4;
528 __u8 layer_type : 4;
529 __u8 track_path : 1;
530 __u8 nlayers : 2;
531 __u8 track_density : 4;
532 __u8 linear_density : 4;
533 __u8 bca : 1;
534 __u32 start_sector;
535 __u32 end_sector;
536 __u32 end_sector_l0;
537};
538
539#define DVD_LAYERS 4
540
541struct dvd_physical {
542 __u8 type;
543 __u8 layer_num;
544 struct dvd_layer layer[DVD_LAYERS];
545};
546
547struct dvd_copyright {
548 __u8 type;
549
550 __u8 layer_num;
551 __u8 cpst;
552 __u8 rmi;
553};
554
555struct dvd_disckey {
556 __u8 type;
557
558 unsigned agid : 2;
559 __u8 value[2048];
560};
561
562struct dvd_bca {
563 __u8 type;
564
565 int len;
566 __u8 value[188];
567};
568
569struct dvd_manufact {
570 __u8 type;
571
572 __u8 layer_num;
573 int len;
574 __u8 value[2048];
575};
576
577typedef union {
578 __u8 type;
579
580 struct dvd_physical physical;
581 struct dvd_copyright copyright;
582 struct dvd_disckey disckey;
583 struct dvd_bca bca;
584 struct dvd_manufact manufact;
585} dvd_struct;
586
587/*
588 * DVD authentication ioctl
589 */
590
591/* Authentication states */
592#define DVD_LU_SEND_AGID 0
593#define DVD_HOST_SEND_CHALLENGE 1
594#define DVD_LU_SEND_KEY1 2
595#define DVD_LU_SEND_CHALLENGE 3
596#define DVD_HOST_SEND_KEY2 4
597
598/* Termination states */
599#define DVD_AUTH_ESTABLISHED 5
600#define DVD_AUTH_FAILURE 6
601
602/* Other functions */
603#define DVD_LU_SEND_TITLE_KEY 7
604#define DVD_LU_SEND_ASF 8
605#define DVD_INVALIDATE_AGID 9
606#define DVD_LU_SEND_RPC_STATE 10
607#define DVD_HOST_SEND_RPC_STATE 11
608
609/* State data */
610typedef __u8 dvd_key[5]; /* 40-bit value, MSB is first elem. */
611typedef __u8 dvd_challenge[10]; /* 80-bit value, MSB is first elem. */
612
613struct dvd_lu_send_agid {
614 __u8 type;
615 unsigned agid : 2;
616};
617
618struct dvd_host_send_challenge {
619 __u8 type;
620 unsigned agid : 2;
621
622 dvd_challenge chal;
623};
624
625struct dvd_send_key {
626 __u8 type;
627 unsigned agid : 2;
628
629 dvd_key key;
630};
631
632struct dvd_lu_send_challenge {
633 __u8 type;
634 unsigned agid : 2;
635
636 dvd_challenge chal;
637};
638
639#define DVD_CPM_NO_COPYRIGHT 0
640#define DVD_CPM_COPYRIGHTED 1
641
642#define DVD_CP_SEC_NONE 0
643#define DVD_CP_SEC_EXIST 1
644
645#define DVD_CGMS_UNRESTRICTED 0
646#define DVD_CGMS_SINGLE 2
647#define DVD_CGMS_RESTRICTED 3
648
649struct dvd_lu_send_title_key {
650 __u8 type;
651 unsigned agid : 2;
652
653 dvd_key title_key;
654 int lba;
655 unsigned cpm : 1;
656 unsigned cp_sec : 1;
657 unsigned cgms : 2;
658};
659
660struct dvd_lu_send_asf {
661 __u8 type;
662 unsigned agid : 2;
663
664 unsigned asf : 1;
665};
666
667struct dvd_host_send_rpcstate {
668 __u8 type;
669 __u8 pdrc;
670};
671
672struct dvd_lu_send_rpcstate {
673 __u8 type : 2;
674 __u8 vra : 3;
675 __u8 ucca : 3;
676 __u8 region_mask;
677 __u8 rpc_scheme;
678};
679
680typedef union {
681 __u8 type;
682
683 struct dvd_lu_send_agid lsa;
684 struct dvd_host_send_challenge hsc;
685 struct dvd_send_key lsk;
686 struct dvd_lu_send_challenge lsc;
687 struct dvd_send_key hsk;
688 struct dvd_lu_send_title_key lstk;
689 struct dvd_lu_send_asf lsasf;
690 struct dvd_host_send_rpcstate hrpcs;
691 struct dvd_lu_send_rpcstate lrpcs;
692} dvd_authinfo;
693
694struct request_sense {
695#if defined(__BIG_ENDIAN_BITFIELD)
696 __u8 valid : 1;
697 __u8 error_code : 7;
698#elif defined(__LITTLE_ENDIAN_BITFIELD)
699 __u8 error_code : 7;
700 __u8 valid : 1;
701#endif
702 __u8 segment_number;
703#if defined(__BIG_ENDIAN_BITFIELD)
704 __u8 reserved1 : 2;
705 __u8 ili : 1;
706 __u8 reserved2 : 1;
707 __u8 sense_key : 4;
708#elif defined(__LITTLE_ENDIAN_BITFIELD)
709 __u8 sense_key : 4;
710 __u8 reserved2 : 1;
711 __u8 ili : 1;
712 __u8 reserved1 : 2;
713#endif
714 __u8 information[4];
715 __u8 add_sense_len;
716 __u8 command_info[4];
717 __u8 asc;
718 __u8 ascq;
719 __u8 fruc;
720 __u8 sks[3];
721 __u8 asb[46];
722};
723
724/*
725 * feature profile
726 */
727#define CDF_RWRT 0x0020 /* "Random Writable" */
728#define CDF_HWDM 0x0024 /* "Hardware Defect Management" */
729#define CDF_MRW 0x0028
730
731/*
732 * media status bits
733 */
734#define CDM_MRW_NOTMRW 0
735#define CDM_MRW_BGFORMAT_INACTIVE 1
736#define CDM_MRW_BGFORMAT_ACTIVE 2
737#define CDM_MRW_BGFORMAT_COMPLETE 3
738
739/*
740 * mrw address spaces
741 */
742#define MRW_LBA_DMA 0
743#define MRW_LBA_GAA 1
744
745/*
746 * mrw mode pages (first is deprecated) -- probed at init time and
747 * cdi->mrw_mode_page is set
748 */
749#define MRW_MODE_PC_PRE1 0x2c
750#define MRW_MODE_PC 0x03
751
752struct mrw_feature_desc {
753 __u16 feature_code;
754#if defined(__BIG_ENDIAN_BITFIELD)
755 __u8 reserved1 : 2;
756 __u8 feature_version : 4;
757 __u8 persistent : 1;
758 __u8 curr : 1;
759#elif defined(__LITTLE_ENDIAN_BITFIELD)
760 __u8 curr : 1;
761 __u8 persistent : 1;
762 __u8 feature_version : 4;
763 __u8 reserved1 : 2;
764#endif
765 __u8 add_len;
766#if defined(__BIG_ENDIAN_BITFIELD)
767 __u8 reserved2 : 7;
768 __u8 write : 1;
769#elif defined(__LITTLE_ENDIAN_BITFIELD)
770 __u8 write : 1;
771 __u8 reserved2 : 7;
772#endif
773 __u8 reserved3;
774 __u8 reserved4;
775 __u8 reserved5;
776};
777
778/* cf. mmc4r02g.pdf 5.3.10 Random Writable Feature (0020h) pg 197 of 635 */
779struct rwrt_feature_desc {
780 __u16 feature_code;
781#if defined(__BIG_ENDIAN_BITFIELD)
782 __u8 reserved1 : 2;
783 __u8 feature_version : 4;
784 __u8 persistent : 1;
785 __u8 curr : 1;
786#elif defined(__LITTLE_ENDIAN_BITFIELD)
787 __u8 curr : 1;
788 __u8 persistent : 1;
789 __u8 feature_version : 4;
790 __u8 reserved1 : 2;
791#endif
792 __u8 add_len;
793 __u32 last_lba;
794 __u32 block_size;
795 __u16 blocking;
796#if defined(__BIG_ENDIAN_BITFIELD)
797 __u8 reserved2 : 7;
798 __u8 page_present : 1;
799#elif defined(__LITTLE_ENDIAN_BITFIELD)
800 __u8 page_present : 1;
801 __u8 reserved2 : 7;
802#endif
803 __u8 reserved3;
804};
805
806typedef struct {
807 __u16 disc_information_length;
808#if defined(__BIG_ENDIAN_BITFIELD)
809 __u8 reserved1 : 3;
810 __u8 erasable : 1;
811 __u8 border_status : 2;
812 __u8 disc_status : 2;
813#elif defined(__LITTLE_ENDIAN_BITFIELD)
814 __u8 disc_status : 2;
815 __u8 border_status : 2;
816 __u8 erasable : 1;
817 __u8 reserved1 : 3;
818#else
819#error "Please fix <asm/byteorder.h>"
820#endif
821 __u8 n_first_track;
822 __u8 n_sessions_lsb;
823 __u8 first_track_lsb;
824 __u8 last_track_lsb;
825#if defined(__BIG_ENDIAN_BITFIELD)
826 __u8 did_v : 1;
827 __u8 dbc_v : 1;
828 __u8 uru : 1;
829 __u8 reserved2 : 2;
830 __u8 dbit : 1;
831 __u8 mrw_status : 2;
832#elif defined(__LITTLE_ENDIAN_BITFIELD)
833 __u8 mrw_status : 2;
834 __u8 dbit : 1;
835 __u8 reserved2 : 2;
836 __u8 uru : 1;
837 __u8 dbc_v : 1;
838 __u8 did_v : 1;
839#endif
840 __u8 disc_type;
841 __u8 n_sessions_msb;
842 __u8 first_track_msb;
843 __u8 last_track_msb;
844 __u32 disc_id;
845 __u32 lead_in;
846 __u32 lead_out;
847 __u8 disc_bar_code[8];
848 __u8 reserved3;
849 __u8 n_opc;
850} disc_information;
851
852typedef struct {
853 __u16 track_information_length;
854 __u8 track_lsb;
855 __u8 session_lsb;
856 __u8 reserved1;
857#if defined(__BIG_ENDIAN_BITFIELD)
858 __u8 reserved2 : 2;
859 __u8 damage : 1;
860 __u8 copy : 1;
861 __u8 track_mode : 4;
862 __u8 rt : 1;
863 __u8 blank : 1;
864 __u8 packet : 1;
865 __u8 fp : 1;
866 __u8 data_mode : 4;
867 __u8 reserved3 : 6;
868 __u8 lra_v : 1;
869 __u8 nwa_v : 1;
870#elif defined(__LITTLE_ENDIAN_BITFIELD)
871 __u8 track_mode : 4;
872 __u8 copy : 1;
873 __u8 damage : 1;
874 __u8 reserved2 : 2;
875 __u8 data_mode : 4;
876 __u8 fp : 1;
877 __u8 packet : 1;
878 __u8 blank : 1;
879 __u8 rt : 1;
880 __u8 nwa_v : 1;
881 __u8 lra_v : 1;
882 __u8 reserved3 : 6;
883#endif
884 __u32 track_start;
885 __u32 next_writable;
886 __u32 free_blocks;
887 __u32 fixed_packet_size;
888 __u32 track_size;
889 __u32 last_rec_address;
890} track_information;
891
892struct feature_header {
893 __u32 data_len;
894 __u8 reserved1;
895 __u8 reserved2;
896 __u16 curr_profile;
897};
898
899struct mode_page_header {
900 __u16 mode_data_length;
901 __u8 medium_type;
902 __u8 reserved1;
903 __u8 reserved2;
904 __u8 reserved3;
905 __u16 desc_length;
906};
907
908#ifdef __KERNEL__
909#include <linux/fs.h> /* not really needed, later.. */
910#include <linux/device.h>
911
912struct packet_command
913{
914 unsigned char cmd[CDROM_PACKET_SIZE];
915 unsigned char *buffer;
916 unsigned int buflen;
917 int stat;
918 struct request_sense *sense;
919 unsigned char data_direction;
920 int quiet;
921 int timeout;
922 void *reserved[1];
923};
924
925/*
926 * _OLD will use PIO transfer on atapi devices, _BPC_* will use DMA
927 */
928#define CDDA_OLD 0 /* old style */
929#define CDDA_BPC_SINGLE 1 /* single frame block pc */
930#define CDDA_BPC_FULL 2 /* multi frame block pc */
931
932/* Uniform cdrom data structures for cdrom.c */
933struct cdrom_device_info {
934 struct cdrom_device_ops *ops; /* link to device_ops */
935 struct cdrom_device_info *next; /* next device_info for this major */
936 struct gendisk *disk; /* matching block layer disk */
937 void *handle; /* driver-dependent data */
938/* specifications */
939 int mask; /* mask of capability: disables them */
940 int speed; /* maximum speed for reading data */
941 int capacity; /* number of discs in jukebox */
942/* device-related storage */
943 int options : 30; /* options flags */
944 unsigned mc_flags : 2; /* media change buffer flags */
945 int use_count; /* number of times device opened */
946 char name[20]; /* name of the device type */
947/* per-device flags */
948 __u8 sanyo_slot : 2; /* Sanyo 3 CD changer support */
949 __u8 reserved : 6; /* not used yet */
950 int cdda_method; /* see flags */
951 __u8 last_sense;
952 __u8 media_written; /* dirty flag, DVD+RW bookkeeping */
953 unsigned short mmc3_profile; /* current MMC3 profile */
954 int for_data;
955 int (*exit)(struct cdrom_device_info *);
956 int mrw_mode_page;
957};
958
959struct cdrom_device_ops {
960/* routines */
961 int (*open) (struct cdrom_device_info *, int);
962 void (*release) (struct cdrom_device_info *);
963 int (*drive_status) (struct cdrom_device_info *, int);
964 int (*media_changed) (struct cdrom_device_info *, int);
965 int (*tray_move) (struct cdrom_device_info *, int);
966 int (*lock_door) (struct cdrom_device_info *, int);
967 int (*select_speed) (struct cdrom_device_info *, int);
968 int (*select_disc) (struct cdrom_device_info *, int);
969 int (*get_last_session) (struct cdrom_device_info *,
970 struct cdrom_multisession *);
971 int (*get_mcn) (struct cdrom_device_info *,
972 struct cdrom_mcn *);
973 /* hard reset device */
974 int (*reset) (struct cdrom_device_info *);
975 /* play stuff */
976 int (*audio_ioctl) (struct cdrom_device_info *,unsigned int, void *);
977 /* dev-specific */
978 int (*dev_ioctl) (struct cdrom_device_info *,
979 unsigned int, unsigned long);
980/* driver specifications */
981 const int capability; /* capability flags */
982 int n_minors; /* number of active minor devices */
983 /* handle uniform packets for scsi type devices (scsi,atapi) */
984 int (*generic_packet) (struct cdrom_device_info *,
985 struct packet_command *);
986};
987
988/* the general block_device operations structure: */
989extern int cdrom_open(struct cdrom_device_info *cdi, struct inode *ip,
990 struct file *fp);
991extern int cdrom_release(struct cdrom_device_info *cdi, struct file *fp);
992extern int cdrom_ioctl(struct file *file, struct cdrom_device_info *cdi,
993 struct inode *ip, unsigned int cmd, unsigned long arg);
994extern int cdrom_media_changed(struct cdrom_device_info *);
995
996extern int register_cdrom(struct cdrom_device_info *cdi);
997extern int unregister_cdrom(struct cdrom_device_info *cdi);
998
999typedef struct {
1000 int data;
1001 int audio;
1002 int cdi;
1003 int xa;
1004 long error;
1005} tracktype;
1006
1007extern int cdrom_get_last_written(struct cdrom_device_info *cdi, long *last_written);
1008extern int cdrom_number_of_slots(struct cdrom_device_info *cdi);
1009extern int cdrom_mode_select(struct cdrom_device_info *cdi,
1010 struct packet_command *cgc);
1011extern int cdrom_mode_sense(struct cdrom_device_info *cdi,
1012 struct packet_command *cgc,
1013 int page_code, int page_control);
1014extern void init_cdrom_command(struct packet_command *cgc,
1015 void *buffer, int len, int type);
1016
1017/* The SCSI spec says there could be 256 slots. */
1018#define CDROM_MAX_SLOTS 256
1019
1020struct cdrom_mechstat_header {
1021#if defined(__BIG_ENDIAN_BITFIELD)
1022 __u8 fault : 1;
1023 __u8 changer_state : 2;
1024 __u8 curslot : 5;
1025 __u8 mech_state : 3;
1026 __u8 door_open : 1;
1027 __u8 reserved1 : 4;
1028#elif defined(__LITTLE_ENDIAN_BITFIELD)
1029 __u8 curslot : 5;
1030 __u8 changer_state : 2;
1031 __u8 fault : 1;
1032 __u8 reserved1 : 4;
1033 __u8 door_open : 1;
1034 __u8 mech_state : 3;
1035#endif
1036 __u8 curlba[3];
1037 __u8 nslots;
1038 __u16 slot_tablelen;
1039};
1040
1041struct cdrom_slot {
1042#if defined(__BIG_ENDIAN_BITFIELD)
1043 __u8 disc_present : 1;
1044 __u8 reserved1 : 6;
1045 __u8 change : 1;
1046#elif defined(__LITTLE_ENDIAN_BITFIELD)
1047 __u8 change : 1;
1048 __u8 reserved1 : 6;
1049 __u8 disc_present : 1;
1050#endif
1051 __u8 reserved2[3];
1052};
1053
1054struct cdrom_changer_info {
1055 struct cdrom_mechstat_header hdr;
1056 struct cdrom_slot slots[CDROM_MAX_SLOTS];
1057};
1058
1059typedef enum {
1060 mechtype_caddy = 0,
1061 mechtype_tray = 1,
1062 mechtype_popup = 2,
1063 mechtype_individual_changer = 4,
1064 mechtype_cartridge_changer = 5
1065} mechtype_t;
1066
1067typedef struct {
1068#if defined(__BIG_ENDIAN_BITFIELD)
1069 __u8 ps : 1;
1070 __u8 reserved1 : 1;
1071 __u8 page_code : 6;
1072 __u8 page_length;
1073 __u8 reserved2 : 1;
1074 __u8 bufe : 1;
1075 __u8 ls_v : 1;
1076 __u8 test_write : 1;
1077 __u8 write_type : 4;
1078 __u8 multi_session : 2; /* or border, DVD */
1079 __u8 fp : 1;
1080 __u8 copy : 1;
1081 __u8 track_mode : 4;
1082 __u8 reserved3 : 4;
1083 __u8 data_block_type : 4;
1084#elif defined(__LITTLE_ENDIAN_BITFIELD)
1085 __u8 page_code : 6;
1086 __u8 reserved1 : 1;
1087 __u8 ps : 1;
1088 __u8 page_length;
1089 __u8 write_type : 4;
1090 __u8 test_write : 1;
1091 __u8 ls_v : 1;
1092 __u8 bufe : 1;
1093 __u8 reserved2 : 1;
1094 __u8 track_mode : 4;
1095 __u8 copy : 1;
1096 __u8 fp : 1;
1097 __u8 multi_session : 2; /* or border, DVD */
1098 __u8 data_block_type : 4;
1099 __u8 reserved3 : 4;
1100#endif
1101 __u8 link_size;
1102 __u8 reserved4;
1103#if defined(__BIG_ENDIAN_BITFIELD)
1104 __u8 reserved5 : 2;
1105 __u8 app_code : 6;
1106#elif defined(__LITTLE_ENDIAN_BITFIELD)
1107 __u8 app_code : 6;
1108 __u8 reserved5 : 2;
1109#endif
1110 __u8 session_format;
1111 __u8 reserved6;
1112 __u32 packet_size;
1113 __u16 audio_pause;
1114 __u8 mcn[16];
1115 __u8 isrc[16];
1116 __u8 subhdr0;
1117 __u8 subhdr1;
1118 __u8 subhdr2;
1119 __u8 subhdr3;
1120} __attribute__((packed)) write_param_page;
1121
1122struct modesel_head
1123{
1124 __u8 reserved1;
1125 __u8 medium;
1126 __u8 reserved2;
1127 __u8 block_desc_length;
1128 __u8 density;
1129 __u8 number_of_blocks_hi;
1130 __u8 number_of_blocks_med;
1131 __u8 number_of_blocks_lo;
1132 __u8 reserved3;
1133 __u8 block_length_hi;
1134 __u8 block_length_med;
1135 __u8 block_length_lo;
1136};
1137
1138typedef struct {
1139 __u16 report_key_length;
1140 __u8 reserved1;
1141 __u8 reserved2;
1142#if defined(__BIG_ENDIAN_BITFIELD)
1143 __u8 type_code : 2;
1144 __u8 vra : 3;
1145 __u8 ucca : 3;
1146#elif defined(__LITTLE_ENDIAN_BITFIELD)
1147 __u8 ucca : 3;
1148 __u8 vra : 3;
1149 __u8 type_code : 2;
1150#endif
1151 __u8 region_mask;
1152 __u8 rpc_scheme;
1153 __u8 reserved3;
1154} rpc_state_t;
1155
1156struct event_header {
1157 __u16 data_len;
1158#if defined(__BIG_ENDIAN_BITFIELD)
1159 __u8 nea : 1;
1160 __u8 reserved1 : 4;
1161 __u8 notification_class : 3;
1162#elif defined(__LITTLE_ENDIAN_BITFIELD)
1163 __u8 notification_class : 3;
1164 __u8 reserved1 : 4;
1165 __u8 nea : 1;
1166#endif
1167 __u8 supp_event_class;
1168};
1169
1170struct media_event_desc {
1171#if defined(__BIG_ENDIAN_BITFIELD)
1172 __u8 reserved1 : 4;
1173 __u8 media_event_code : 4;
1174 __u8 reserved2 : 6;
1175 __u8 media_present : 1;
1176 __u8 door_open : 1;
1177#elif defined(__LITTLE_ENDIAN_BITFIELD)
1178 __u8 media_event_code : 4;
1179 __u8 reserved1 : 4;
1180 __u8 door_open : 1;
1181 __u8 media_present : 1;
1182 __u8 reserved2 : 6;
1183#endif
1184 __u8 start_slot;
1185 __u8 end_slot;
1186};
1187
1188extern int cdrom_get_media_event(struct cdrom_device_info *cdi, struct media_event_desc *med);
1189
1190#endif /* End of kernel only stuff */
1191
1192#endif /* _LINUX_CDROM_H */
diff --git a/include/linux/circ_buf.h b/include/linux/circ_buf.h
new file mode 100644
index 000000000000..a2ed0591fb19
--- /dev/null
+++ b/include/linux/circ_buf.h
@@ -0,0 +1,32 @@
1#ifndef _LINUX_CIRC_BUF_H
2#define _LINUX_CIRC_BUF_H 1
3
4struct circ_buf {
5 char *buf;
6 int head;
7 int tail;
8};
9
10/* Return count in buffer. */
11#define CIRC_CNT(head,tail,size) (((head) - (tail)) & ((size)-1))
12
13/* Return space available, 0..size-1. We always leave one free char
14 as a completely full buffer has head == tail, which is the same as
15 empty. */
16#define CIRC_SPACE(head,tail,size) CIRC_CNT((tail),((head)+1),(size))
17
18/* Return count up to the end of the buffer. Carefully avoid
19 accessing head and tail more than once, so they can change
20 underneath us without returning inconsistent results. */
21#define CIRC_CNT_TO_END(head,tail,size) \
22 ({int end = (size) - (tail); \
23 int n = ((head) + end) & ((size)-1); \
24 n < end ? n : end;})
25
26/* Return space available up to the end of the buffer. */
27#define CIRC_SPACE_TO_END(head,tail,size) \
28 ({int end = (size) - 1 - (head); \
29 int n = (end + (tail)) & ((size)-1); \
30 n <= end ? n : end+1;})
31
32#endif /* _LINUX_CIRC_BUF_H */
diff --git a/include/linux/cobalt-nvram.h b/include/linux/cobalt-nvram.h
new file mode 100644
index 000000000000..ea429562ff36
--- /dev/null
+++ b/include/linux/cobalt-nvram.h
@@ -0,0 +1,109 @@
1/*
2 * $Id: cobalt-nvram.h,v 1.20 2001/10/17 23:16:55 thockin Exp $
3 * cobalt-nvram.h : defines for the various fields in the cobalt NVRAM
4 *
5 * Copyright 2001,2002 Sun Microsystems, Inc.
6 */
7
8#ifndef COBALT_NVRAM_H
9#define COBALT_NVRAM_H
10
11#include <linux/nvram.h>
12
13#define COBT_CMOS_INFO_MAX 0x7f /* top address allowed */
14#define COBT_CMOS_BIOS_DRIVE_INFO 0x12 /* drive info would go here */
15
16#define COBT_CMOS_CKS_START NVRAM_OFFSET(0x0e)
17#define COBT_CMOS_CKS_END NVRAM_OFFSET(0x7f)
18
19/* flag bytes - 16 flags for now, leave room for more */
20#define COBT_CMOS_FLAG_BYTE_0 NVRAM_OFFSET(0x10)
21#define COBT_CMOS_FLAG_BYTE_1 NVRAM_OFFSET(0x11)
22
23/* flags in flag bytes - up to 16 */
24#define COBT_CMOS_FLAG_MIN 0x0001
25#define COBT_CMOS_CONSOLE_FLAG 0x0001 /* console on/off */
26#define COBT_CMOS_DEBUG_FLAG 0x0002 /* ROM debug messages */
27#define COBT_CMOS_AUTO_PROMPT_FLAG 0x0004 /* boot to ROM prompt? */
28#define COBT_CMOS_CLEAN_BOOT_FLAG 0x0008 /* set by a clean shutdown */
29#define COBT_CMOS_HW_NOPROBE_FLAG 0x0010 /* go easy on the probing */
30#define COBT_CMOS_SYSFAULT_FLAG 0x0020 /* system fault detected */
31#define COBT_CMOS_OOPSPANIC_FLAG 0x0040 /* panic on oops */
32#define COBT_CMOS_DELAY_CACHE_FLAG 0x0080 /* delay cache initialization */
33#define COBT_CMOS_NOLOGO_FLAG 0x0100 /* hide "C" logo @ boot */
34#define COBT_CMOS_VERSION_FLAG 0x0200 /* the version field is valid */
35#define COBT_CMOS_FLAG_MAX 0x0200
36
37/* leave byte 0x12 blank - Linux looks for drive info here */
38
39/* CMOS structure version, valid if COBT_CMOS_VERSION_FLAG is true */
40#define COBT_CMOS_VERSION NVRAM_OFFSET(0x13)
41#define COBT_CMOS_VER_BTOCODE 1 /* min. version needed for btocode */
42
43/* index of default boot method */
44#define COBT_CMOS_BOOT_METHOD NVRAM_OFFSET(0x20)
45#define COBT_CMOS_BOOT_METHOD_DISK 0
46#define COBT_CMOS_BOOT_METHOD_ROM 1
47#define COBT_CMOS_BOOT_METHOD_NET 2
48
49#define COBT_CMOS_BOOT_DEV_MIN NVRAM_OFFSET(0x21)
50/* major #, minor # of first through fourth boot device */
51#define COBT_CMOS_BOOT_DEV0_MAJ NVRAM_OFFSET(0x21)
52#define COBT_CMOS_BOOT_DEV0_MIN NVRAM_OFFSET(0x22)
53#define COBT_CMOS_BOOT_DEV1_MAJ NVRAM_OFFSET(0x23)
54#define COBT_CMOS_BOOT_DEV1_MIN NVRAM_OFFSET(0x24)
55#define COBT_CMOS_BOOT_DEV2_MAJ NVRAM_OFFSET(0x25)
56#define COBT_CMOS_BOOT_DEV2_MIN NVRAM_OFFSET(0x26)
57#define COBT_CMOS_BOOT_DEV3_MAJ NVRAM_OFFSET(0x27)
58#define COBT_CMOS_BOOT_DEV3_MIN NVRAM_OFFSET(0x28)
59#define COBT_CMOS_BOOT_DEV_MAX NVRAM_OFFSET(0x28)
60
61/* checksum of bytes 0xe-0x7f */
62#define COBT_CMOS_CHECKSUM NVRAM_OFFSET(0x2e)
63
64/* running uptime counter, units of 5 minutes (32 bits =~ 41000 years) */
65#define COBT_CMOS_UPTIME_0 NVRAM_OFFSET(0x30)
66#define COBT_CMOS_UPTIME_1 NVRAM_OFFSET(0x31)
67#define COBT_CMOS_UPTIME_2 NVRAM_OFFSET(0x32)
68#define COBT_CMOS_UPTIME_3 NVRAM_OFFSET(0x33)
69
70/* count of successful boots (32 bits) */
71#define COBT_CMOS_BOOTCOUNT_0 NVRAM_OFFSET(0x38)
72#define COBT_CMOS_BOOTCOUNT_1 NVRAM_OFFSET(0x39)
73#define COBT_CMOS_BOOTCOUNT_2 NVRAM_OFFSET(0x3a)
74#define COBT_CMOS_BOOTCOUNT_3 NVRAM_OFFSET(0x3b)
75
76/* 13 bytes: system serial number, same as on the back of the system */
77#define COBT_CMOS_SYS_SERNUM_LEN 13
78#define COBT_CMOS_SYS_SERNUM_0 NVRAM_OFFSET(0x40)
79#define COBT_CMOS_SYS_SERNUM_1 NVRAM_OFFSET(0x41)
80#define COBT_CMOS_SYS_SERNUM_2 NVRAM_OFFSET(0x42)
81#define COBT_CMOS_SYS_SERNUM_3 NVRAM_OFFSET(0x43)
82#define COBT_CMOS_SYS_SERNUM_4 NVRAM_OFFSET(0x44)
83#define COBT_CMOS_SYS_SERNUM_5 NVRAM_OFFSET(0x45)
84#define COBT_CMOS_SYS_SERNUM_6 NVRAM_OFFSET(0x46)
85#define COBT_CMOS_SYS_SERNUM_7 NVRAM_OFFSET(0x47)
86#define COBT_CMOS_SYS_SERNUM_8 NVRAM_OFFSET(0x48)
87#define COBT_CMOS_SYS_SERNUM_9 NVRAM_OFFSET(0x49)
88#define COBT_CMOS_SYS_SERNUM_10 NVRAM_OFFSET(0x4a)
89#define COBT_CMOS_SYS_SERNUM_11 NVRAM_OFFSET(0x4b)
90#define COBT_CMOS_SYS_SERNUM_12 NVRAM_OFFSET(0x4c)
91/* checksum for serial num - 1 byte */
92#define COBT_CMOS_SYS_SERNUM_CSUM NVRAM_OFFSET(0x4f)
93
94#define COBT_CMOS_ROM_REV_MAJ NVRAM_OFFSET(0x50)
95#define COBT_CMOS_ROM_REV_MIN NVRAM_OFFSET(0x51)
96#define COBT_CMOS_ROM_REV_REV NVRAM_OFFSET(0x52)
97
98#define COBT_CMOS_BTO_CODE_0 NVRAM_OFFSET(0x53)
99#define COBT_CMOS_BTO_CODE_1 NVRAM_OFFSET(0x54)
100#define COBT_CMOS_BTO_CODE_2 NVRAM_OFFSET(0x55)
101#define COBT_CMOS_BTO_CODE_3 NVRAM_OFFSET(0x56)
102
103#define COBT_CMOS_BTO_IP_CSUM NVRAM_OFFSET(0x57)
104#define COBT_CMOS_BTO_IP_0 NVRAM_OFFSET(0x58)
105#define COBT_CMOS_BTO_IP_1 NVRAM_OFFSET(0x59)
106#define COBT_CMOS_BTO_IP_2 NVRAM_OFFSET(0x5a)
107#define COBT_CMOS_BTO_IP_3 NVRAM_OFFSET(0x5b)
108
109#endif /* COBALT_NVRAM_H */
diff --git a/include/linux/coda.h b/include/linux/coda.h
new file mode 100644
index 000000000000..bbc5afcd7db6
--- /dev/null
+++ b/include/linux/coda.h
@@ -0,0 +1,788 @@
1/*
2 You may distribute this file under either of the two licenses that
3 follow at your discretion.
4*/
5
6/* BLURB lgpl
7
8 Coda File System
9 Release 5
10
11 Copyright (c) 1987-1999 Carnegie Mellon University
12 Additional copyrights listed below
13
14This code is distributed "AS IS" without warranty of any kind under
15the terms of the GNU Library General Public Licence Version 2, as
16shown in the file LICENSE, or under the license shown below. The
17technical and financial contributors to Coda are listed in the file
18CREDITS.
19
20 Additional copyrights
21*/
22
23/*
24
25 Coda: an Experimental Distributed File System
26 Release 4.0
27
28 Copyright (c) 1987-1999 Carnegie Mellon University
29 All Rights Reserved
30
31Permission to use, copy, modify and distribute this software and its
32documentation is hereby granted, provided that both the copyright
33notice and this permission notice appear in all copies of the
34software, derivative works or modified versions, and any portions
35thereof, and that both notices appear in supporting documentation, and
36that credit is given to Carnegie Mellon University in all documents
37and publicity pertaining to direct or indirect use of this code or its
38derivatives.
39
40CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS,
41SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. CARNEGIE MELLON ALLOWS
42FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION. CARNEGIE MELLON
43DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER
44RESULTING DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF
45ANY DERIVATIVE WORK.
46
47Carnegie Mellon encourages users of this software to return any
48improvements or extensions that they make, and to grant Carnegie
49Mellon the rights to redistribute these changes without encumbrance.
50*/
51
52/*
53 *
54 * Based on cfs.h from Mach, but revamped for increased simplicity.
55 * Linux modifications by
56 * Peter Braam, Aug 1996
57 */
58
59#ifndef _CODA_HEADER_
60#define _CODA_HEADER_
61
62#include <linux/config.h>
63
64/* Catch new _KERNEL defn for NetBSD and DJGPP/__CYGWIN32__ */
65#if defined(__NetBSD__) || \
66 ((defined(DJGPP) || defined(__CYGWIN32__)) && !defined(KERNEL))
67#include <sys/types.h>
68#endif
69
70#ifndef CODA_MAXSYMLINKS
71#define CODA_MAXSYMLINKS 10
72#endif
73
74#if defined(DJGPP) || defined(__CYGWIN32__)
75#ifdef KERNEL
76typedef unsigned long u_long;
77typedef unsigned int u_int;
78typedef unsigned short u_short;
79typedef u_long ino_t;
80typedef u_long dev_t;
81typedef void * caddr_t;
82#ifdef DOS
83typedef unsigned __int64 u_quad_t;
84#else
85typedef unsigned long long u_quad_t;
86#endif
87
88#define inline
89
90struct timespec {
91 long ts_sec;
92 long ts_nsec;
93};
94#else /* DJGPP but not KERNEL */
95#include <sys/time.h>
96typedef unsigned long long u_quad_t;
97#endif /* !KERNEL */
98#endif /* !DJGPP */
99
100
101#if defined(__linux__)
102#include <linux/time.h>
103#define cdev_t u_quad_t
104#ifndef __KERNEL__
105#if !defined(_UQUAD_T_) && (!defined(__GLIBC__) || __GLIBC__ < 2)
106#define _UQUAD_T_ 1
107typedef unsigned long long u_quad_t;
108#endif
109#else /*__KERNEL__ */
110typedef unsigned long long u_quad_t;
111#endif /* __KERNEL__ */
112#else
113#define cdev_t dev_t
114#endif
115
116#ifdef __CYGWIN32__
117struct timespec {
118 time_t tv_sec; /* seconds */
119 long tv_nsec; /* nanoseconds */
120};
121#endif
122
123#ifndef __BIT_TYPES_DEFINED__
124#define __BIT_TYPES_DEFINED__
125typedef signed char int8_t;
126typedef unsigned char u_int8_t;
127typedef short int16_t;
128typedef unsigned short u_int16_t;
129typedef int int32_t;
130typedef unsigned int u_int32_t;
131#endif
132
133
134/*
135 * Cfs constants
136 */
137#define CODA_MAXNAMLEN 255
138#define CODA_MAXPATHLEN 1024
139#define CODA_MAXSYMLINK 10
140
141/* these are Coda's version of O_RDONLY etc combinations
142 * to deal with VFS open modes
143 */
144#define C_O_READ 0x001
145#define C_O_WRITE 0x002
146#define C_O_TRUNC 0x010
147#define C_O_EXCL 0x100
148#define C_O_CREAT 0x200
149
150/* these are to find mode bits in Venus */
151#define C_M_READ 00400
152#define C_M_WRITE 00200
153
154/* for access Venus will use */
155#define C_A_C_OK 8 /* Test for writing upon create. */
156#define C_A_R_OK 4 /* Test for read permission. */
157#define C_A_W_OK 2 /* Test for write permission. */
158#define C_A_X_OK 1 /* Test for execute permission. */
159#define C_A_F_OK 0 /* Test for existence. */
160
161
162
163#ifndef _VENUS_DIRENT_T_
164#define _VENUS_DIRENT_T_ 1
165struct venus_dirent {
166 u_int32_t d_fileno; /* file number of entry */
167 u_int16_t d_reclen; /* length of this record */
168 u_int8_t d_type; /* file type, see below */
169 u_int8_t d_namlen; /* length of string in d_name */
170 char d_name[CODA_MAXNAMLEN + 1];/* name must be no longer than this */
171};
172#undef DIRSIZ
173#define DIRSIZ(dp) ((sizeof (struct venus_dirent) - (CODA_MAXNAMLEN+1)) + \
174 (((dp)->d_namlen+1 + 3) &~ 3))
175
176/*
177 * File types
178 */
179#define CDT_UNKNOWN 0
180#define CDT_FIFO 1
181#define CDT_CHR 2
182#define CDT_DIR 4
183#define CDT_BLK 6
184#define CDT_REG 8
185#define CDT_LNK 10
186#define CDT_SOCK 12
187#define CDT_WHT 14
188
189/*
190 * Convert between stat structure types and directory types.
191 */
192#define IFTOCDT(mode) (((mode) & 0170000) >> 12)
193#define CDTTOIF(dirtype) ((dirtype) << 12)
194
195#endif
196
197#ifndef _VUID_T_
198#define _VUID_T_
199typedef u_int32_t vuid_t;
200typedef u_int32_t vgid_t;
201#endif /*_VUID_T_ */
202
203#ifdef CONFIG_CODA_FS_OLD_API
204struct CodaFid {
205 u_int32_t opaque[3];
206};
207
208static __inline__ ino_t coda_f2i(struct CodaFid *fid)
209{
210 if ( ! fid )
211 return 0;
212 if (fid->opaque[1] == 0xfffffffe || fid->opaque[1] == 0xffffffff)
213 return ((fid->opaque[0] << 20) | (fid->opaque[2] & 0xfffff));
214 else
215 return (fid->opaque[2] + (fid->opaque[1]<<10) + (fid->opaque[0]<<20));
216}
217
218struct coda_cred {
219 vuid_t cr_uid, cr_euid, cr_suid, cr_fsuid; /* Real, efftve, set, fs uid*/
220 vgid_t cr_groupid, cr_egid, cr_sgid, cr_fsgid; /* same for groups */
221};
222
223#else /* not defined(CONFIG_CODA_FS_OLD_API) */
224
225struct CodaFid {
226 u_int32_t opaque[4];
227};
228
229#define coda_f2i(fid)\
230 (fid ? (fid->opaque[3] ^ (fid->opaque[2]<<10) ^ (fid->opaque[1]<<20) ^ fid->opaque[0]) : 0)
231
232#endif
233
234#ifndef _VENUS_VATTR_T_
235#define _VENUS_VATTR_T_
236/*
237 * Vnode types. VNON means no type.
238 */
239enum coda_vtype { C_VNON, C_VREG, C_VDIR, C_VBLK, C_VCHR, C_VLNK, C_VSOCK, C_VFIFO, C_VBAD };
240
241struct coda_vattr {
242 long va_type; /* vnode type (for create) */
243 u_short va_mode; /* files access mode and type */
244 short va_nlink; /* number of references to file */
245 vuid_t va_uid; /* owner user id */
246 vgid_t va_gid; /* owner group id */
247 long va_fileid; /* file id */
248 u_quad_t va_size; /* file size in bytes */
249 long va_blocksize; /* blocksize preferred for i/o */
250 struct timespec va_atime; /* time of last access */
251 struct timespec va_mtime; /* time of last modification */
252 struct timespec va_ctime; /* time file changed */
253 u_long va_gen; /* generation number of file */
254 u_long va_flags; /* flags defined for file */
255 cdev_t va_rdev; /* device special file represents */
256 u_quad_t va_bytes; /* bytes of disk space held by file */
257 u_quad_t va_filerev; /* file modification number */
258};
259
260#endif
261
262/* structure used by CODA_STATFS for getting cache information from venus */
263struct coda_statfs {
264 int32_t f_blocks;
265 int32_t f_bfree;
266 int32_t f_bavail;
267 int32_t f_files;
268 int32_t f_ffree;
269};
270
271/*
272 * Kernel <--> Venus communications.
273 */
274
275#define CODA_ROOT 2
276#define CODA_OPEN_BY_FD 3
277#define CODA_OPEN 4
278#define CODA_CLOSE 5
279#define CODA_IOCTL 6
280#define CODA_GETATTR 7
281#define CODA_SETATTR 8
282#define CODA_ACCESS 9
283#define CODA_LOOKUP 10
284#define CODA_CREATE 11
285#define CODA_REMOVE 12
286#define CODA_LINK 13
287#define CODA_RENAME 14
288#define CODA_MKDIR 15
289#define CODA_RMDIR 16
290#define CODA_SYMLINK 18
291#define CODA_READLINK 19
292#define CODA_FSYNC 20
293#define CODA_VGET 22
294#define CODA_SIGNAL 23
295#define CODA_REPLACE 24 /* DOWNCALL */
296#define CODA_FLUSH 25 /* DOWNCALL */
297#define CODA_PURGEUSER 26 /* DOWNCALL */
298#define CODA_ZAPFILE 27 /* DOWNCALL */
299#define CODA_ZAPDIR 28 /* DOWNCALL */
300#define CODA_PURGEFID 30 /* DOWNCALL */
301#define CODA_OPEN_BY_PATH 31
302#define CODA_RESOLVE 32
303#define CODA_REINTEGRATE 33
304#define CODA_STATFS 34
305#define CODA_STORE 35
306#define CODA_RELEASE 36
307#define CODA_NCALLS 37
308
309#define DOWNCALL(opcode) (opcode >= CODA_REPLACE && opcode <= CODA_PURGEFID)
310
311#define VC_MAXDATASIZE 8192
312#define VC_MAXMSGSIZE sizeof(union inputArgs)+sizeof(union outputArgs) +\
313 VC_MAXDATASIZE
314
315#define CIOC_KERNEL_VERSION _IOWR('c', 10, size_t)
316
317#if 0
318#define CODA_KERNEL_VERSION 0 /* don't care about kernel version number */
319#define CODA_KERNEL_VERSION 1 /* The old venus 4.6 compatible interface */
320#endif
321#ifdef CONFIG_CODA_FS_OLD_API
322#define CODA_KERNEL_VERSION 2 /* venus_lookup got an extra parameter */
323#else
324#define CODA_KERNEL_VERSION 3 /* 128-bit file identifiers */
325#endif
326
327/*
328 * Venus <-> Coda RPC arguments
329 */
330struct coda_in_hdr {
331 u_int32_t opcode;
332 u_int32_t unique; /* Keep multiple outstanding msgs distinct */
333#ifdef CONFIG_CODA_FS_OLD_API
334 u_int16_t pid; /* Common to all */
335 u_int16_t pgid; /* Common to all */
336 u_int16_t sid; /* Common to all */
337 struct coda_cred cred; /* Common to all */
338#else
339 pid_t pid;
340 pid_t pgid;
341 vuid_t uid;
342#endif
343};
344
345/* Really important that opcode and unique are 1st two fields! */
346struct coda_out_hdr {
347 u_int32_t opcode;
348 u_int32_t unique;
349 u_int32_t result;
350};
351
352/* coda_root: NO_IN */
353struct coda_root_out {
354 struct coda_out_hdr oh;
355 struct CodaFid VFid;
356};
357
358struct coda_root_in {
359 struct coda_in_hdr in;
360};
361
362/* coda_open: */
363struct coda_open_in {
364 struct coda_in_hdr ih;
365 struct CodaFid VFid;
366 int flags;
367};
368
369struct coda_open_out {
370 struct coda_out_hdr oh;
371 cdev_t dev;
372 ino_t inode;
373};
374
375
376/* coda_store: */
377struct coda_store_in {
378 struct coda_in_hdr ih;
379 struct CodaFid VFid;
380 int flags;
381};
382
383struct coda_store_out {
384 struct coda_out_hdr out;
385};
386
387/* coda_release: */
388struct coda_release_in {
389 struct coda_in_hdr ih;
390 struct CodaFid VFid;
391 int flags;
392};
393
394struct coda_release_out {
395 struct coda_out_hdr out;
396};
397
398/* coda_close: */
399struct coda_close_in {
400 struct coda_in_hdr ih;
401 struct CodaFid VFid;
402 int flags;
403};
404
405struct coda_close_out {
406 struct coda_out_hdr out;
407};
408
409/* coda_ioctl: */
410struct coda_ioctl_in {
411 struct coda_in_hdr ih;
412 struct CodaFid VFid;
413 int cmd;
414 int len;
415 int rwflag;
416 char *data; /* Place holder for data. */
417};
418
419struct coda_ioctl_out {
420 struct coda_out_hdr oh;
421 int len;
422 caddr_t data; /* Place holder for data. */
423};
424
425
426/* coda_getattr: */
427struct coda_getattr_in {
428 struct coda_in_hdr ih;
429 struct CodaFid VFid;
430};
431
432struct coda_getattr_out {
433 struct coda_out_hdr oh;
434 struct coda_vattr attr;
435};
436
437
438/* coda_setattr: NO_OUT */
439struct coda_setattr_in {
440 struct coda_in_hdr ih;
441 struct CodaFid VFid;
442 struct coda_vattr attr;
443};
444
445struct coda_setattr_out {
446 struct coda_out_hdr out;
447};
448
449/* coda_access: NO_OUT */
450struct coda_access_in {
451 struct coda_in_hdr ih;
452 struct CodaFid VFid;
453 int flags;
454};
455
456struct coda_access_out {
457 struct coda_out_hdr out;
458};
459
460
461/* lookup flags */
462#define CLU_CASE_SENSITIVE 0x01
463#define CLU_CASE_INSENSITIVE 0x02
464
465/* coda_lookup: */
466struct coda_lookup_in {
467 struct coda_in_hdr ih;
468 struct CodaFid VFid;
469 int name; /* Place holder for data. */
470 int flags;
471};
472
473struct coda_lookup_out {
474 struct coda_out_hdr oh;
475 struct CodaFid VFid;
476 int vtype;
477};
478
479
480/* coda_create: */
481struct coda_create_in {
482 struct coda_in_hdr ih;
483 struct CodaFid VFid;
484 struct coda_vattr attr;
485 int excl;
486 int mode;
487 int name; /* Place holder for data. */
488};
489
490struct coda_create_out {
491 struct coda_out_hdr oh;
492 struct CodaFid VFid;
493 struct coda_vattr attr;
494};
495
496
497/* coda_remove: NO_OUT */
498struct coda_remove_in {
499 struct coda_in_hdr ih;
500 struct CodaFid VFid;
501 int name; /* Place holder for data. */
502};
503
504struct coda_remove_out {
505 struct coda_out_hdr out;
506};
507
508/* coda_link: NO_OUT */
509struct coda_link_in {
510 struct coda_in_hdr ih;
511 struct CodaFid sourceFid; /* cnode to link *to* */
512 struct CodaFid destFid; /* Directory in which to place link */
513 int tname; /* Place holder for data. */
514};
515
516struct coda_link_out {
517 struct coda_out_hdr out;
518};
519
520
521/* coda_rename: NO_OUT */
522struct coda_rename_in {
523 struct coda_in_hdr ih;
524 struct CodaFid sourceFid;
525 int srcname;
526 struct CodaFid destFid;
527 int destname;
528};
529
530struct coda_rename_out {
531 struct coda_out_hdr out;
532};
533
534/* coda_mkdir: */
535struct coda_mkdir_in {
536 struct coda_in_hdr ih;
537 struct CodaFid VFid;
538 struct coda_vattr attr;
539 int name; /* Place holder for data. */
540};
541
542struct coda_mkdir_out {
543 struct coda_out_hdr oh;
544 struct CodaFid VFid;
545 struct coda_vattr attr;
546};
547
548
549/* coda_rmdir: NO_OUT */
550struct coda_rmdir_in {
551 struct coda_in_hdr ih;
552 struct CodaFid VFid;
553 int name; /* Place holder for data. */
554};
555
556struct coda_rmdir_out {
557 struct coda_out_hdr out;
558};
559
560/* coda_symlink: NO_OUT */
561struct coda_symlink_in {
562 struct coda_in_hdr ih;
563 struct CodaFid VFid; /* Directory to put symlink in */
564 int srcname;
565 struct coda_vattr attr;
566 int tname;
567};
568
569struct coda_symlink_out {
570 struct coda_out_hdr out;
571};
572
573/* coda_readlink: */
574struct coda_readlink_in {
575 struct coda_in_hdr ih;
576 struct CodaFid VFid;
577};
578
579struct coda_readlink_out {
580 struct coda_out_hdr oh;
581 int count;
582 caddr_t data; /* Place holder for data. */
583};
584
585
586/* coda_fsync: NO_OUT */
587struct coda_fsync_in {
588 struct coda_in_hdr ih;
589 struct CodaFid VFid;
590};
591
592struct coda_fsync_out {
593 struct coda_out_hdr out;
594};
595
596/* coda_vget: */
597struct coda_vget_in {
598 struct coda_in_hdr ih;
599 struct CodaFid VFid;
600};
601
602struct coda_vget_out {
603 struct coda_out_hdr oh;
604 struct CodaFid VFid;
605 int vtype;
606};
607
608
609/* CODA_SIGNAL is out-of-band, doesn't need data. */
610/* CODA_INVALIDATE is a venus->kernel call */
611/* CODA_FLUSH is a venus->kernel call */
612
613/* coda_purgeuser: */
614/* CODA_PURGEUSER is a venus->kernel call */
615struct coda_purgeuser_out {
616 struct coda_out_hdr oh;
617#ifdef CONFIG_CODA_FS_OLD_API
618 struct coda_cred cred;
619#else
620 vuid_t uid;
621#endif
622};
623
624/* coda_zapfile: */
625/* CODA_ZAPFILE is a venus->kernel call */
626struct coda_zapfile_out {
627 struct coda_out_hdr oh;
628 struct CodaFid CodaFid;
629};
630
631/* coda_zapdir: */
632/* CODA_ZAPDIR is a venus->kernel call */
633struct coda_zapdir_out {
634 struct coda_out_hdr oh;
635 struct CodaFid CodaFid;
636};
637
638/* coda_purgefid: */
639/* CODA_PURGEFID is a venus->kernel call */
640struct coda_purgefid_out {
641 struct coda_out_hdr oh;
642 struct CodaFid CodaFid;
643};
644
645/* coda_replace: */
646/* CODA_REPLACE is a venus->kernel call */
647struct coda_replace_out { /* coda_replace is a venus->kernel call */
648 struct coda_out_hdr oh;
649 struct CodaFid NewFid;
650 struct CodaFid OldFid;
651};
652
653/* coda_open_by_fd: */
654struct coda_open_by_fd_in {
655 struct coda_in_hdr ih;
656 struct CodaFid VFid;
657 int flags;
658};
659
660struct coda_open_by_fd_out {
661 struct coda_out_hdr oh;
662 int fd;
663
664#ifdef __KERNEL__
665 struct file *fh; /* not passed from userspace but used in-kernel only */
666#endif
667};
668
669/* coda_open_by_path: */
670struct coda_open_by_path_in {
671 struct coda_in_hdr ih;
672 struct CodaFid VFid;
673 int flags;
674};
675
676struct coda_open_by_path_out {
677 struct coda_out_hdr oh;
678 int path;
679};
680
681/* coda_statfs: NO_IN */
682struct coda_statfs_in {
683 struct coda_in_hdr in;
684};
685
686struct coda_statfs_out {
687 struct coda_out_hdr oh;
688 struct coda_statfs stat;
689};
690
691/*
692 * Occasionally, we don't cache the fid returned by CODA_LOOKUP.
693 * For instance, if the fid is inconsistent.
694 * This case is handled by setting the top bit of the type result parameter.
695 */
696#define CODA_NOCACHE 0x80000000
697
698union inputArgs {
699 struct coda_in_hdr ih; /* NB: every struct below begins with an ih */
700 struct coda_open_in coda_open;
701 struct coda_store_in coda_store;
702 struct coda_release_in coda_release;
703 struct coda_close_in coda_close;
704 struct coda_ioctl_in coda_ioctl;
705 struct coda_getattr_in coda_getattr;
706 struct coda_setattr_in coda_setattr;
707 struct coda_access_in coda_access;
708 struct coda_lookup_in coda_lookup;
709 struct coda_create_in coda_create;
710 struct coda_remove_in coda_remove;
711 struct coda_link_in coda_link;
712 struct coda_rename_in coda_rename;
713 struct coda_mkdir_in coda_mkdir;
714 struct coda_rmdir_in coda_rmdir;
715 struct coda_symlink_in coda_symlink;
716 struct coda_readlink_in coda_readlink;
717 struct coda_fsync_in coda_fsync;
718 struct coda_vget_in coda_vget;
719 struct coda_open_by_fd_in coda_open_by_fd;
720 struct coda_open_by_path_in coda_open_by_path;
721 struct coda_statfs_in coda_statfs;
722};
723
724union outputArgs {
725 struct coda_out_hdr oh; /* NB: every struct below begins with an oh */
726 struct coda_root_out coda_root;
727 struct coda_open_out coda_open;
728 struct coda_ioctl_out coda_ioctl;
729 struct coda_getattr_out coda_getattr;
730 struct coda_lookup_out coda_lookup;
731 struct coda_create_out coda_create;
732 struct coda_mkdir_out coda_mkdir;
733 struct coda_readlink_out coda_readlink;
734 struct coda_vget_out coda_vget;
735 struct coda_purgeuser_out coda_purgeuser;
736 struct coda_zapfile_out coda_zapfile;
737 struct coda_zapdir_out coda_zapdir;
738 struct coda_purgefid_out coda_purgefid;
739 struct coda_replace_out coda_replace;
740 struct coda_open_by_fd_out coda_open_by_fd;
741 struct coda_open_by_path_out coda_open_by_path;
742 struct coda_statfs_out coda_statfs;
743};
744
745union coda_downcalls {
746 /* CODA_INVALIDATE is a venus->kernel call */
747 /* CODA_FLUSH is a venus->kernel call */
748 struct coda_purgeuser_out purgeuser;
749 struct coda_zapfile_out zapfile;
750 struct coda_zapdir_out zapdir;
751 struct coda_purgefid_out purgefid;
752 struct coda_replace_out replace;
753};
754
755
756/*
757 * Used for identifying usage of "Control" and pioctls
758 */
759
760#define PIOCPARM_MASK 0x0000ffff
761struct ViceIoctl {
762 void __user *in; /* Data to be transferred in */
763 void __user *out; /* Data to be transferred out */
764 u_short in_size; /* Size of input buffer <= 2K */
765 u_short out_size; /* Maximum size of output buffer, <= 2K */
766};
767
768struct PioctlData {
769 const char __user *path;
770 int follow;
771 struct ViceIoctl vi;
772};
773
774#define CODA_CONTROL ".CONTROL"
775#define CODA_CONTROLLEN 8
776#define CTL_INO -1
777
778/* Data passed to mount */
779
780#define CODA_MOUNT_VERSION 1
781
782struct coda_mount_data {
783 int version;
784 int fd; /* Opened device */
785};
786
787#endif
788
diff --git a/include/linux/coda_cache.h b/include/linux/coda_cache.h
new file mode 100644
index 000000000000..c910b5eb1ceb
--- /dev/null
+++ b/include/linux/coda_cache.h
@@ -0,0 +1,22 @@
1/* Coda filesystem -- Linux Minicache
2 *
3 * Copyright (C) 1989 - 1997 Carnegie Mellon University
4 *
5 * Carnegie Mellon University encourages users of this software to
6 * contribute improvements to the Coda project. Contact Peter Braam
7 * <coda@cs.cmu.edu>
8 */
9
10#ifndef _CFSNC_HEADER_
11#define _CFSNC_HEADER_
12
13/* credential cache */
14void coda_cache_enter(struct inode *inode, int mask);
15void coda_cache_clear_inode(struct inode *);
16void coda_cache_clear_all(struct super_block *sb);
17int coda_cache_check(struct inode *inode, int mask);
18
19/* for downcalls and attributes and lookups */
20void coda_flag_inode_children(struct inode *inode, int flag);
21
22#endif /* _CFSNC_HEADER_ */
diff --git a/include/linux/coda_fs_i.h b/include/linux/coda_fs_i.h
new file mode 100644
index 000000000000..424fe9cf02c4
--- /dev/null
+++ b/include/linux/coda_fs_i.h
@@ -0,0 +1,55 @@
1/*
2 * coda_fs_i.h
3 *
4 * Copyright (C) 1998 Carnegie Mellon University
5 *
6 */
7
8#ifndef _LINUX_CODA_FS_I
9#define _LINUX_CODA_FS_I
10
11#ifdef __KERNEL__
12#include <linux/types.h>
13#include <linux/list.h>
14#include <linux/coda.h>
15
16/*
17 * coda fs inode data
18 */
19struct coda_inode_info {
20 struct CodaFid c_fid; /* Coda identifier */
21 u_short c_flags; /* flags (see below) */
22 struct list_head c_cilist; /* list of all coda inodes */
23 unsigned int c_mapcount; /* nr of times this inode is mapped */
24 unsigned int c_cached_epoch; /* epoch for cached permissions */
25 vuid_t c_uid; /* fsuid for cached permissions */
26 unsigned int c_cached_perm; /* cached access permissions */
27 struct inode vfs_inode;
28};
29
30/*
31 * coda fs file private data
32 */
33#define CODA_MAGIC 0xC0DAC0DA
34struct coda_file_info {
35 int cfi_magic; /* magic number */
36 struct file *cfi_container; /* container file for this cnode */
37 unsigned int cfi_mapcount; /* nr of times this file is mapped */
38};
39
40#define CODA_FTOC(file) ((struct coda_file_info *)((file)->private_data))
41
42/* flags */
43#define C_VATTR 0x1 /* Validity of vattr in inode */
44#define C_FLUSH 0x2 /* used after a flush */
45#define C_DYING 0x4 /* from venus (which died) */
46#define C_PURGE 0x8
47
48int coda_cnode_make(struct inode **, struct CodaFid *, struct super_block *);
49struct inode *coda_iget(struct super_block *sb, struct CodaFid *fid, struct coda_vattr *attr);
50int coda_cnode_makectl(struct inode **inode, struct super_block *sb);
51struct inode *coda_fid_to_inode(struct CodaFid *fid, struct super_block *sb);
52void coda_replace_fid(struct inode *, struct CodaFid *, struct CodaFid *);
53
54#endif
55#endif
diff --git a/include/linux/coda_linux.h b/include/linux/coda_linux.h
new file mode 100644
index 000000000000..cc621ec409d8
--- /dev/null
+++ b/include/linux/coda_linux.h
@@ -0,0 +1,102 @@
1/*
2 * Coda File System, Linux Kernel module
3 *
4 * Original version, adapted from cfs_mach.c, (C) Carnegie Mellon University
5 * Linux modifications (C) 1996, Peter J. Braam
6 * Rewritten for Linux 2.1 (C) 1997 Carnegie Mellon University
7 *
8 * Carnegie Mellon University encourages users of this software to
9 * contribute improvements to the Coda project.
10 */
11
12#ifndef _LINUX_CODA_FS
13#define _LINUX_CODA_FS
14
15#include <linux/kernel.h>
16#include <linux/param.h>
17#include <linux/mm.h>
18#include <linux/vmalloc.h>
19#include <linux/slab.h>
20#include <linux/wait.h>
21#include <linux/types.h>
22#include <linux/fs.h>
23#include <linux/coda_fs_i.h>
24
25/* operations */
26extern struct inode_operations coda_dir_inode_operations;
27extern struct inode_operations coda_file_inode_operations;
28extern struct inode_operations coda_ioctl_inode_operations;
29
30extern struct address_space_operations coda_file_aops;
31extern struct address_space_operations coda_symlink_aops;
32
33extern struct file_operations coda_dir_operations;
34extern struct file_operations coda_file_operations;
35extern struct file_operations coda_ioctl_operations;
36
37/* operations shared over more than one file */
38int coda_open(struct inode *i, struct file *f);
39int coda_flush(struct file *f);
40int coda_release(struct inode *i, struct file *f);
41int coda_permission(struct inode *inode, int mask, struct nameidata *nd);
42int coda_revalidate_inode(struct dentry *);
43int coda_getattr(struct vfsmount *, struct dentry *, struct kstat *);
44int coda_setattr(struct dentry *, struct iattr *);
45
46/* global variables */
47extern int coda_fake_statfs;
48
49/* this file: heloers */
50static __inline__ struct CodaFid *coda_i2f(struct inode *);
51static __inline__ char *coda_i2s(struct inode *);
52static __inline__ void coda_flag_inode(struct inode *, int flag);
53char *coda_f2s(struct CodaFid *f);
54int coda_isroot(struct inode *i);
55int coda_iscontrol(const char *name, size_t length);
56
57void coda_vattr_to_iattr(struct inode *, struct coda_vattr *);
58void coda_iattr_to_vattr(struct iattr *, struct coda_vattr *);
59unsigned short coda_flags_to_cflags(unsigned short);
60
61/* sysctl.h */
62void coda_sysctl_init(void);
63void coda_sysctl_clean(void);
64
65#define CODA_ALLOC(ptr, cast, size) do { \
66 if (size < PAGE_SIZE) \
67 ptr = (cast)kmalloc((unsigned long) size, GFP_KERNEL); \
68 else \
69 ptr = (cast)vmalloc((unsigned long) size); \
70 if (!ptr) \
71 printk("kernel malloc returns 0 at %s:%d\n", __FILE__, __LINE__); \
72 else memset( ptr, 0, size ); \
73} while (0)
74
75
76#define CODA_FREE(ptr,size) \
77 do { if (size < PAGE_SIZE) kfree((ptr)); else vfree((ptr)); } while (0)
78
79/* inode to cnode access functions */
80
81static inline struct coda_inode_info *ITOC(struct inode *inode)
82{
83 return list_entry(inode, struct coda_inode_info, vfs_inode);
84}
85
86static __inline__ struct CodaFid *coda_i2f(struct inode *inode)
87{
88 return &(ITOC(inode)->c_fid);
89}
90
91static __inline__ char *coda_i2s(struct inode *inode)
92{
93 return coda_f2s(&(ITOC(inode)->c_fid));
94}
95
96/* this will not zap the inode away */
97static __inline__ void coda_flag_inode(struct inode *inode, int flag)
98{
99 ITOC(inode)->c_flags |= flag;
100}
101
102#endif
diff --git a/include/linux/coda_proc.h b/include/linux/coda_proc.h
new file mode 100644
index 000000000000..0dc1b0458e75
--- /dev/null
+++ b/include/linux/coda_proc.h
@@ -0,0 +1,76 @@
1/*
2 * coda_statis.h
3 *
4 * CODA operation statistics
5 *
6 * (c) March, 1998
7 * by Michihiro Kuramochi, Zhenyu Xia and Zhanyong Wan
8 * zhanyong.wan@yale.edu
9 *
10 */
11
12#ifndef _CODA_PROC_H
13#define _CODA_PROC_H
14
15void coda_sysctl_init(void);
16void coda_sysctl_clean(void);
17
18#include <linux/sysctl.h>
19#include <linux/coda_fs_i.h>
20#include <linux/coda.h>
21
22/* these four files are presented to show the result of the statistics:
23 *
24 * /proc/fs/coda/vfs_stats
25 * cache_inv_stats
26 *
27 * these four files are presented to reset the statistics to 0:
28 *
29 * /proc/sys/coda/vfs_stats
30 * cache_inv_stats
31 */
32
33/* VFS operation statistics */
34struct coda_vfs_stats
35{
36 /* file operations */
37 int open;
38 int flush;
39 int release;
40 int fsync;
41
42 /* dir operations */
43 int readdir;
44
45 /* inode operations */
46 int create;
47 int lookup;
48 int link;
49 int unlink;
50 int symlink;
51 int mkdir;
52 int rmdir;
53 int rename;
54 int permission;
55
56 /* symlink operatoins*/
57 int follow_link;
58 int readlink;
59};
60
61/* cache invalidation statistics */
62struct coda_cache_inv_stats
63{
64 int flush;
65 int purge_user;
66 int zap_dir;
67 int zap_file;
68 int zap_vnode;
69 int purge_fid;
70 int replace;
71};
72
73/* these global variables hold the actual statistics data */
74extern struct coda_vfs_stats coda_vfs_stat;
75
76#endif /* _CODA_PROC_H */
diff --git a/include/linux/coda_psdev.h b/include/linux/coda_psdev.h
new file mode 100644
index 000000000000..d539262a8f89
--- /dev/null
+++ b/include/linux/coda_psdev.h
@@ -0,0 +1,103 @@
1#ifndef __CODA_PSDEV_H
2#define __CODA_PSDEV_H
3
4#define CODA_PSDEV_MAJOR 67
5#define MAX_CODADEVS 5 /* how many do we allow */
6
7#define CODA_SUPER_MAGIC 0x73757245
8
9struct kstatfs;
10
11struct coda_sb_info
12{
13 struct venus_comm *sbi_vcomm;
14};
15
16/* communication pending/processing queues */
17struct venus_comm {
18 u_long vc_seq;
19 wait_queue_head_t vc_waitq; /* Venus wait queue */
20 struct list_head vc_pending;
21 struct list_head vc_processing;
22 int vc_inuse;
23 struct super_block *vc_sb;
24};
25
26
27static inline struct coda_sb_info *coda_sbp(struct super_block *sb)
28{
29 return ((struct coda_sb_info *)((sb)->s_fs_info));
30}
31
32
33/* upcalls */
34int venus_rootfid(struct super_block *sb, struct CodaFid *fidp);
35int venus_getattr(struct super_block *sb, struct CodaFid *fid,
36 struct coda_vattr *attr);
37int venus_setattr(struct super_block *, struct CodaFid *, struct coda_vattr *);
38int venus_lookup(struct super_block *sb, struct CodaFid *fid,
39 const char *name, int length, int *type,
40 struct CodaFid *resfid);
41int venus_store(struct super_block *sb, struct CodaFid *fid, int flags,
42 vuid_t uid);
43int venus_release(struct super_block *sb, struct CodaFid *fid, int flags);
44int venus_close(struct super_block *sb, struct CodaFid *fid, int flags,
45 vuid_t uid);
46int venus_open(struct super_block *sb, struct CodaFid *fid, int flags,
47 struct file **f);
48int venus_mkdir(struct super_block *sb, struct CodaFid *dirfid,
49 const char *name, int length,
50 struct CodaFid *newfid, struct coda_vattr *attrs);
51int venus_create(struct super_block *sb, struct CodaFid *dirfid,
52 const char *name, int length, int excl, int mode,
53 struct CodaFid *newfid, struct coda_vattr *attrs) ;
54int venus_rmdir(struct super_block *sb, struct CodaFid *dirfid,
55 const char *name, int length);
56int venus_remove(struct super_block *sb, struct CodaFid *dirfid,
57 const char *name, int length);
58int venus_readlink(struct super_block *sb, struct CodaFid *fid,
59 char *buffer, int *length);
60int venus_rename(struct super_block *, struct CodaFid *new_fid,
61 struct CodaFid *old_fid, size_t old_length,
62 size_t new_length, const char *old_name,
63 const char *new_name);
64int venus_link(struct super_block *sb, struct CodaFid *fid,
65 struct CodaFid *dirfid, const char *name, int len );
66int venus_symlink(struct super_block *sb, struct CodaFid *fid,
67 const char *name, int len, const char *symname, int symlen);
68int venus_access(struct super_block *sb, struct CodaFid *fid, int mask);
69int venus_pioctl(struct super_block *sb, struct CodaFid *fid,
70 unsigned int cmd, struct PioctlData *data);
71int coda_downcall(int opcode, union outputArgs *out, struct super_block *sb);
72int venus_fsync(struct super_block *sb, struct CodaFid *fid);
73int venus_statfs(struct super_block *sb, struct kstatfs *sfs);
74
75
76/* messages between coda filesystem in kernel and Venus */
77extern int coda_hard;
78extern unsigned long coda_timeout;
79struct upc_req {
80 struct list_head uc_chain;
81 caddr_t uc_data;
82 u_short uc_flags;
83 u_short uc_inSize; /* Size is at most 5000 bytes */
84 u_short uc_outSize;
85 u_short uc_opcode; /* copied from data to save lookup */
86 int uc_unique;
87 wait_queue_head_t uc_sleep; /* process' wait queue */
88 unsigned long uc_posttime;
89};
90
91#define REQ_ASYNC 0x1
92#define REQ_READ 0x2
93#define REQ_WRITE 0x4
94#define REQ_ABORT 0x8
95
96
97/*
98 * Statistics
99 */
100
101extern struct venus_comm coda_comms[];
102
103#endif
diff --git a/include/linux/coff.h b/include/linux/coff.h
new file mode 100644
index 000000000000..6354a7fe22b2
--- /dev/null
+++ b/include/linux/coff.h
@@ -0,0 +1,351 @@
1/* This file is derived from the GAS 2.1.4 assembler control file.
2 The GAS product is under the GNU General Public License, version 2 or later.
3 As such, this file is also under that license.
4
5 If the file format changes in the COFF object, this file should be
6 subsequently updated to reflect the changes.
7
8 The actual loader module only uses a few of these structures. The full
9 set is documented here because I received the full set. If you wish
10 more information about COFF, then O'Reilly has a very excellent book.
11*/
12
13#define E_SYMNMLEN 8 /* Number of characters in a symbol name */
14#define E_FILNMLEN 14 /* Number of characters in a file name */
15#define E_DIMNUM 4 /* Number of array dimensions in auxiliary entry */
16
17/*
18 * These defines are byte order independent. There is no alignment of fields
19 * permitted in the structures. Therefore they are declared as characters
20 * and the values loaded from the character positions. It also makes it
21 * nice to have it "endian" independent.
22 */
23
24/* Load a short int from the following tables with little-endian formats */
25#define COFF_SHORT_L(ps) ((short)(((unsigned short)((unsigned char)ps[1])<<8)|\
26 ((unsigned short)((unsigned char)ps[0]))))
27
28/* Load a long int from the following tables with little-endian formats */
29#define COFF_LONG_L(ps) (((long)(((unsigned long)((unsigned char)ps[3])<<24) |\
30 ((unsigned long)((unsigned char)ps[2])<<16) |\
31 ((unsigned long)((unsigned char)ps[1])<<8) |\
32 ((unsigned long)((unsigned char)ps[0])))))
33
34/* Load a short int from the following tables with big-endian formats */
35#define COFF_SHORT_H(ps) ((short)(((unsigned short)((unsigned char)ps[0])<<8)|\
36 ((unsigned short)((unsigned char)ps[1]))))
37
38/* Load a long int from the following tables with big-endian formats */
39#define COFF_LONG_H(ps) (((long)(((unsigned long)((unsigned char)ps[0])<<24) |\
40 ((unsigned long)((unsigned char)ps[1])<<16) |\
41 ((unsigned long)((unsigned char)ps[2])<<8) |\
42 ((unsigned long)((unsigned char)ps[3])))))
43
44/* These may be overridden later by brain dead implementations which generate
45 a big-endian header with little-endian data. In that case, generate a
46 replacement macro which tests a flag and uses either of the two above
47 as appropriate. */
48
49#define COFF_LONG(v) COFF_LONG_L(v)
50#define COFF_SHORT(v) COFF_SHORT_L(v)
51
52/*** coff information for Intel 386/486. */
53
54/********************** FILE HEADER **********************/
55
56struct COFF_filehdr {
57 char f_magic[2]; /* magic number */
58 char f_nscns[2]; /* number of sections */
59 char f_timdat[4]; /* time & date stamp */
60 char f_symptr[4]; /* file pointer to symtab */
61 char f_nsyms[4]; /* number of symtab entries */
62 char f_opthdr[2]; /* sizeof(optional hdr) */
63 char f_flags[2]; /* flags */
64};
65
66/*
67 * Bits for f_flags:
68 *
69 * F_RELFLG relocation info stripped from file
70 * F_EXEC file is executable (i.e. no unresolved external
71 * references)
72 * F_LNNO line numbers stripped from file
73 * F_LSYMS local symbols stripped from file
74 * F_MINMAL this is a minimal object file (".m") output of fextract
75 * F_UPDATE this is a fully bound update file, output of ogen
76 * F_SWABD this file has had its bytes swabbed (in names)
77 * F_AR16WR this file has the byte ordering of an AR16WR
78 * (e.g. 11/70) machine
79 * F_AR32WR this file has the byte ordering of an AR32WR machine
80 * (e.g. vax and iNTEL 386)
81 * F_AR32W this file has the byte ordering of an AR32W machine
82 * (e.g. 3b,maxi)
83 * F_PATCH file contains "patch" list in optional header
84 * F_NODF (minimal file only) no decision functions for
85 * replaced functions
86 */
87
88#define COFF_F_RELFLG 0000001
89#define COFF_F_EXEC 0000002
90#define COFF_F_LNNO 0000004
91#define COFF_F_LSYMS 0000010
92#define COFF_F_MINMAL 0000020
93#define COFF_F_UPDATE 0000040
94#define COFF_F_SWABD 0000100
95#define COFF_F_AR16WR 0000200
96#define COFF_F_AR32WR 0000400
97#define COFF_F_AR32W 0001000
98#define COFF_F_PATCH 0002000
99#define COFF_F_NODF 0002000
100
101#define COFF_I386MAGIC 0x14c /* Linux's system */
102
103#if 0 /* Perhaps, someday, these formats may be used. */
104#define COFF_I386PTXMAGIC 0x154
105#define COFF_I386AIXMAGIC 0x175 /* IBM's AIX system */
106#define COFF_I386BADMAG(x) ((COFF_SHORT((x).f_magic) != COFF_I386MAGIC) \
107 && COFF_SHORT((x).f_magic) != COFF_I386PTXMAGIC \
108 && COFF_SHORT((x).f_magic) != COFF_I386AIXMAGIC)
109#else
110#define COFF_I386BADMAG(x) (COFF_SHORT((x).f_magic) != COFF_I386MAGIC)
111#endif
112
113#define COFF_FILHDR struct COFF_filehdr
114#define COFF_FILHSZ sizeof(COFF_FILHDR)
115
116/********************** AOUT "OPTIONAL HEADER" **********************/
117
118/* Linux COFF must have this "optional" header. Standard COFF has no entry
119 location for the "entry" point. They normally would start with the first
120 location of the .text section. This is not a good idea for linux. So,
121 the use of this "optional" header is not optional. It is required.
122
123 Do not be tempted to assume that the size of the optional header is
124 a constant and simply index the next byte by the size of this structure.
125 Use the 'f_opthdr' field in the main coff header for the size of the
126 structure actually written to the file!!
127*/
128
129typedef struct
130{
131 char magic[2]; /* type of file */
132 char vstamp[2]; /* version stamp */
133 char tsize[4]; /* text size in bytes, padded to FW bdry */
134 char dsize[4]; /* initialized data " " */
135 char bsize[4]; /* uninitialized data " " */
136 char entry[4]; /* entry pt. */
137 char text_start[4]; /* base of text used for this file */
138 char data_start[4]; /* base of data used for this file */
139}
140COFF_AOUTHDR;
141
142#define COFF_AOUTSZ (sizeof(COFF_AOUTHDR))
143
144#define COFF_STMAGIC 0401
145#define COFF_OMAGIC 0404
146#define COFF_JMAGIC 0407 /* dirty text and data image, can't share */
147#define COFF_DMAGIC 0410 /* dirty text segment, data aligned */
148#define COFF_ZMAGIC 0413 /* The proper magic number for executables */
149#define COFF_SHMAGIC 0443 /* shared library header */
150
151/********************** SECTION HEADER **********************/
152
153struct COFF_scnhdr {
154 char s_name[8]; /* section name */
155 char s_paddr[4]; /* physical address, aliased s_nlib */
156 char s_vaddr[4]; /* virtual address */
157 char s_size[4]; /* section size */
158 char s_scnptr[4]; /* file ptr to raw data for section */
159 char s_relptr[4]; /* file ptr to relocation */
160 char s_lnnoptr[4]; /* file ptr to line numbers */
161 char s_nreloc[2]; /* number of relocation entries */
162 char s_nlnno[2]; /* number of line number entries */
163 char s_flags[4]; /* flags */
164};
165
166#define COFF_SCNHDR struct COFF_scnhdr
167#define COFF_SCNHSZ sizeof(COFF_SCNHDR)
168
169/*
170 * names of "special" sections
171 */
172
173#define COFF_TEXT ".text"
174#define COFF_DATA ".data"
175#define COFF_BSS ".bss"
176#define COFF_COMMENT ".comment"
177#define COFF_LIB ".lib"
178
179#define COFF_SECT_TEXT 0 /* Section for instruction code */
180#define COFF_SECT_DATA 1 /* Section for initialized globals */
181#define COFF_SECT_BSS 2 /* Section for un-initialized globals */
182#define COFF_SECT_REQD 3 /* Minimum number of sections for good file */
183
184#define COFF_STYP_REG 0x00 /* regular segment */
185#define COFF_STYP_DSECT 0x01 /* dummy segment */
186#define COFF_STYP_NOLOAD 0x02 /* no-load segment */
187#define COFF_STYP_GROUP 0x04 /* group segment */
188#define COFF_STYP_PAD 0x08 /* .pad segment */
189#define COFF_STYP_COPY 0x10 /* copy section */
190#define COFF_STYP_TEXT 0x20 /* .text segment */
191#define COFF_STYP_DATA 0x40 /* .data segment */
192#define COFF_STYP_BSS 0x80 /* .bss segment */
193#define COFF_STYP_INFO 0x200 /* .comment section */
194#define COFF_STYP_OVER 0x400 /* overlay section */
195#define COFF_STYP_LIB 0x800 /* library section */
196
197/*
198 * Shared libraries have the following section header in the data field for
199 * each library.
200 */
201
202struct COFF_slib {
203 char sl_entsz[4]; /* Size of this entry */
204 char sl_pathndx[4]; /* size of the header field */
205};
206
207#define COFF_SLIBHD struct COFF_slib
208#define COFF_SLIBSZ sizeof(COFF_SLIBHD)
209
210/********************** LINE NUMBERS **********************/
211
212/* 1 line number entry for every "breakpointable" source line in a section.
213 * Line numbers are grouped on a per function basis; first entry in a function
214 * grouping will have l_lnno = 0 and in place of physical address will be the
215 * symbol table index of the function name.
216 */
217
218struct COFF_lineno {
219 union {
220 char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
221 char l_paddr[4]; /* (physical) address of line number */
222 } l_addr;
223 char l_lnno[2]; /* line number */
224};
225
226#define COFF_LINENO struct COFF_lineno
227#define COFF_LINESZ 6
228
229/********************** SYMBOLS **********************/
230
231#define COFF_E_SYMNMLEN 8 /* # characters in a short symbol name */
232#define COFF_E_FILNMLEN 14 /* # characters in a file name */
233#define COFF_E_DIMNUM 4 /* # array dimensions in auxiliary entry */
234
235/*
236 * All symbols and sections have the following definition
237 */
238
239struct COFF_syment
240{
241 union {
242 char e_name[E_SYMNMLEN]; /* Symbol name (first 8 characters) */
243 struct {
244 char e_zeroes[4]; /* Leading zeros */
245 char e_offset[4]; /* Offset if this is a header section */
246 } e;
247 } e;
248
249 char e_value[4]; /* Value (address) of the segment */
250 char e_scnum[2]; /* Section number */
251 char e_type[2]; /* Type of section */
252 char e_sclass[1]; /* Loader class */
253 char e_numaux[1]; /* Number of auxiliary entries which follow */
254};
255
256#define COFF_N_BTMASK (0xf) /* Mask for important class bits */
257#define COFF_N_TMASK (0x30) /* Mask for important type bits */
258#define COFF_N_BTSHFT (4) /* # bits to shift class field */
259#define COFF_N_TSHIFT (2) /* # bits to shift type field */
260
261/*
262 * Auxiliary entries because the main table is too limiting.
263 */
264
265union COFF_auxent {
266
267/*
268 * Debugger information
269 */
270
271 struct {
272 char x_tagndx[4]; /* str, un, or enum tag indx */
273 union {
274 struct {
275 char x_lnno[2]; /* declaration line number */
276 char x_size[2]; /* str/union/array size */
277 } x_lnsz;
278 char x_fsize[4]; /* size of function */
279 } x_misc;
280
281 union {
282 struct { /* if ISFCN, tag, or .bb */
283 char x_lnnoptr[4]; /* ptr to fcn line # */
284 char x_endndx[4]; /* entry ndx past block end */
285 } x_fcn;
286
287 struct { /* if ISARY, up to 4 dimen. */
288 char x_dimen[E_DIMNUM][2];
289 } x_ary;
290 } x_fcnary;
291
292 char x_tvndx[2]; /* tv index */
293 } x_sym;
294
295/*
296 * Source file names (debugger information)
297 */
298
299 union {
300 char x_fname[E_FILNMLEN];
301 struct {
302 char x_zeroes[4];
303 char x_offset[4];
304 } x_n;
305 } x_file;
306
307/*
308 * Section information
309 */
310
311 struct {
312 char x_scnlen[4]; /* section length */
313 char x_nreloc[2]; /* # relocation entries */
314 char x_nlinno[2]; /* # line numbers */
315 } x_scn;
316
317/*
318 * Transfer vector (branch table)
319 */
320
321 struct {
322 char x_tvfill[4]; /* tv fill value */
323 char x_tvlen[2]; /* length of .tv */
324 char x_tvran[2][2]; /* tv range */
325 } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
326};
327
328#define COFF_SYMENT struct COFF_syment
329#define COFF_SYMESZ 18
330#define COFF_AUXENT union COFF_auxent
331#define COFF_AUXESZ 18
332
333#define COFF_ETEXT "etext"
334
335/********************** RELOCATION DIRECTIVES **********************/
336
337struct COFF_reloc {
338 char r_vaddr[4]; /* Virtual address of item */
339 char r_symndx[4]; /* Symbol index in the symtab */
340 char r_type[2]; /* Relocation type */
341};
342
343#define COFF_RELOC struct COFF_reloc
344#define COFF_RELSZ 10
345
346#define COFF_DEF_DATA_SECTION_ALIGNMENT 4
347#define COFF_DEF_BSS_SECTION_ALIGNMENT 4
348#define COFF_DEF_TEXT_SECTION_ALIGNMENT 4
349
350/* For new sections we haven't heard of before */
351#define COFF_DEF_SECTION_ALIGNMENT 4
diff --git a/include/linux/com20020.h b/include/linux/com20020.h
new file mode 100644
index 000000000000..ac6d9a43e085
--- /dev/null
+++ b/include/linux/com20020.h
@@ -0,0 +1,115 @@
1/*
2 * Linux ARCnet driver - COM20020 chipset support - function declarations
3 *
4 * Written 1997 by David Woodhouse.
5 * Written 1994-1999 by Avery Pennarun.
6 * Derived from skeleton.c by Donald Becker.
7 *
8 * Special thanks to Contemporary Controls, Inc. (www.ccontrols.com)
9 * for sponsoring the further development of this driver.
10 *
11 * **********************
12 *
13 * The original copyright of skeleton.c was as follows:
14 *
15 * skeleton.c Written 1993 by Donald Becker.
16 * Copyright 1993 United States Government as represented by the
17 * Director, National Security Agency. This software may only be used
18 * and distributed according to the terms of the GNU General Public License as
19 * modified by SRC, incorporated herein by reference.
20 *
21 * **********************
22 *
23 * For more details, see drivers/net/arcnet.c
24 *
25 * **********************
26 */
27#ifndef __COM20020_H
28#define __COM20020_H
29
30int com20020_check(struct net_device *dev);
31int com20020_found(struct net_device *dev, int shared);
32
33/* The number of low I/O ports used by the card. */
34#define ARCNET_TOTAL_SIZE 8
35
36/* various register addresses */
37#ifdef CONFIG_SA1100_CT6001
38#define BUS_ALIGN 2 /* 8 bit device on a 16 bit bus - needs padding */
39#else
40#define BUS_ALIGN 1
41#endif
42
43
44#define _INTMASK (ioaddr+BUS_ALIGN*0) /* writable */
45#define _STATUS (ioaddr+BUS_ALIGN*0) /* readable */
46#define _COMMAND (ioaddr+BUS_ALIGN*1) /* standard arcnet commands */
47#define _DIAGSTAT (ioaddr+BUS_ALIGN*1) /* diagnostic status register */
48#define _ADDR_HI (ioaddr+BUS_ALIGN*2) /* control registers for IO-mapped memory */
49#define _ADDR_LO (ioaddr+BUS_ALIGN*3)
50#define _MEMDATA (ioaddr+BUS_ALIGN*4) /* data port for IO-mapped memory */
51#define _SUBADR (ioaddr+BUS_ALIGN*5) /* the extended port _XREG refers to */
52#define _CONFIG (ioaddr+BUS_ALIGN*6) /* configuration register */
53#define _XREG (ioaddr+BUS_ALIGN*7) /* extra registers (indexed by _CONFIG
54 or _SUBADR) */
55
56/* in the ADDR_HI register */
57#define RDDATAflag 0x80 /* next access is a read (not a write) */
58
59/* in the DIAGSTAT register */
60#define NEWNXTIDflag 0x02 /* ID to which token is passed has changed */
61
62/* in the CONFIG register */
63#define RESETcfg 0x80 /* put card in reset state */
64#define TXENcfg 0x20 /* enable TX */
65
66/* in SETUP register */
67#define PROMISCset 0x10 /* enable RCV_ALL */
68#define P1MODE 0x80 /* enable P1-MODE for Backplane */
69#define SLOWARB 0x01 /* enable Slow Arbitration for >=5Mbps */
70
71/* COM2002x */
72#define SUB_TENTATIVE 0 /* tentative node ID */
73#define SUB_NODE 1 /* node ID */
74#define SUB_SETUP1 2 /* various options */
75#define SUB_TEST 3 /* test/diag register */
76
77/* COM20022 only */
78#define SUB_SETUP2 4 /* sundry options */
79#define SUB_BUSCTL 5 /* bus control options */
80#define SUB_DMACOUNT 6 /* DMA count options */
81
82#define SET_SUBADR(x) do { \
83 if ((x) < 4) \
84 { \
85 lp->config = (lp->config & ~0x03) | (x); \
86 SETCONF; \
87 } \
88 else \
89 { \
90 outb(x, _SUBADR); \
91 } \
92} while (0)
93
94#undef ARCRESET
95#undef ASTATUS
96#undef ACOMMAND
97#undef AINTMASK
98
99#define ARCRESET { outb(lp->config | 0x80, _CONFIG); \
100 udelay(5); \
101 outb(lp->config , _CONFIG); \
102 }
103#define ARCRESET0 { outb(0x18 | 0x80, _CONFIG); \
104 udelay(5); \
105 outb(0x18 , _CONFIG); \
106 }
107
108#define ASTATUS() inb(_STATUS)
109#define ADIAGSTATUS() inb(_DIAGSTAT)
110#define ACOMMAND(cmd) outb((cmd),_COMMAND)
111#define AINTMASK(msk) outb((msk),_INTMASK)
112
113#define SETCONF outb(lp->config, _CONFIG)
114
115#endif /* __COM20020_H */
diff --git a/include/linux/compat.h b/include/linux/compat.h
new file mode 100644
index 000000000000..b58b7d6f2fdb
--- /dev/null
+++ b/include/linux/compat.h
@@ -0,0 +1,162 @@
1#ifndef _LINUX_COMPAT_H
2#define _LINUX_COMPAT_H
3/*
4 * These are the type definitions for the architecture specific
5 * syscall compatibility layer.
6 */
7#include <linux/config.h>
8
9#ifdef CONFIG_COMPAT
10
11#include <linux/stat.h>
12#include <linux/param.h> /* for HZ */
13#include <linux/sem.h>
14
15#include <asm/compat.h>
16#include <asm/siginfo.h>
17
18#define compat_jiffies_to_clock_t(x) \
19 (((unsigned long)(x) * COMPAT_USER_HZ) / HZ)
20
21struct rusage;
22
23struct compat_itimerspec {
24 struct compat_timespec it_interval;
25 struct compat_timespec it_value;
26};
27
28struct compat_utimbuf {
29 compat_time_t actime;
30 compat_time_t modtime;
31};
32
33struct compat_itimerval {
34 struct compat_timeval it_interval;
35 struct compat_timeval it_value;
36};
37
38struct compat_tms {
39 compat_clock_t tms_utime;
40 compat_clock_t tms_stime;
41 compat_clock_t tms_cutime;
42 compat_clock_t tms_cstime;
43};
44
45#define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW)
46
47typedef struct {
48 compat_sigset_word sig[_COMPAT_NSIG_WORDS];
49} compat_sigset_t;
50
51extern int cp_compat_stat(struct kstat *, struct compat_stat __user *);
52extern int get_compat_timespec(struct timespec *, const struct compat_timespec __user *);
53extern int put_compat_timespec(const struct timespec *, struct compat_timespec __user *);
54
55struct compat_iovec {
56 compat_uptr_t iov_base;
57 compat_size_t iov_len;
58};
59
60struct compat_rlimit {
61 compat_ulong_t rlim_cur;
62 compat_ulong_t rlim_max;
63};
64
65struct compat_rusage {
66 struct compat_timeval ru_utime;
67 struct compat_timeval ru_stime;
68 compat_long_t ru_maxrss;
69 compat_long_t ru_ixrss;
70 compat_long_t ru_idrss;
71 compat_long_t ru_isrss;
72 compat_long_t ru_minflt;
73 compat_long_t ru_majflt;
74 compat_long_t ru_nswap;
75 compat_long_t ru_inblock;
76 compat_long_t ru_oublock;
77 compat_long_t ru_msgsnd;
78 compat_long_t ru_msgrcv;
79 compat_long_t ru_nsignals;
80 compat_long_t ru_nvcsw;
81 compat_long_t ru_nivcsw;
82};
83
84extern int put_compat_rusage(const struct rusage *, struct compat_rusage __user *);
85
86struct compat_siginfo;
87
88extern asmlinkage long compat_sys_waitid(int, compat_pid_t,
89 struct compat_siginfo __user *, int,
90 struct compat_rusage __user *);
91
92struct compat_dirent {
93 u32 d_ino;
94 compat_off_t d_off;
95 u16 d_reclen;
96 char d_name[256];
97};
98
99typedef union compat_sigval {
100 compat_int_t sival_int;
101 compat_uptr_t sival_ptr;
102} compat_sigval_t;
103
104#define COMPAT_SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 3)
105
106typedef struct compat_sigevent {
107 compat_sigval_t sigev_value;
108 compat_int_t sigev_signo;
109 compat_int_t sigev_notify;
110 union {
111 compat_int_t _pad[COMPAT_SIGEV_PAD_SIZE];
112 compat_int_t _tid;
113
114 struct {
115 compat_uptr_t _function;
116 compat_uptr_t _attribute;
117 } _sigev_thread;
118 } _sigev_un;
119} compat_sigevent_t;
120
121
122long compat_sys_semctl(int first, int second, int third, void __user *uptr);
123long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
124long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
125 int version, void __user *uptr);
126long compat_sys_msgctl(int first, int second, void __user *uptr);
127long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
128 void __user *uptr);
129long compat_sys_shmctl(int first, int second, void __user *uptr);
130long compat_sys_semtimedop(int semid, struct sembuf __user *tsems,
131 unsigned nsems, const struct compat_timespec __user *timeout);
132asmlinkage long compat_sys_keyctl(u32 option,
133 u32 arg2, u32 arg3, u32 arg4, u32 arg5);
134
135asmlinkage ssize_t compat_sys_readv(unsigned long fd,
136 const struct compat_iovec __user *vec, unsigned long vlen);
137asmlinkage ssize_t compat_sys_writev(unsigned long fd,
138 const struct compat_iovec __user *vec, unsigned long vlen);
139
140int compat_do_execve(char * filename, compat_uptr_t __user *argv,
141 compat_uptr_t __user *envp, struct pt_regs * regs);
142
143asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp,
144 compat_ulong_t __user *outp, compat_ulong_t __user *exp,
145 struct compat_timeval __user *tvp);
146
147#define BITS_PER_COMPAT_LONG (8*sizeof(compat_long_t))
148
149#define BITS_TO_COMPAT_LONGS(bits) \
150 (((bits)+BITS_PER_COMPAT_LONG-1)/BITS_PER_COMPAT_LONG)
151
152long compat_get_bitmap(unsigned long *mask, compat_ulong_t __user *umask,
153 unsigned long bitmap_size);
154long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask,
155 unsigned long bitmap_size);
156int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from);
157int copy_siginfo_to_user32(struct compat_siginfo __user *to, siginfo_t *from);
158int get_compat_sigevent(struct sigevent *event,
159 const struct compat_sigevent __user *u_event);
160
161#endif /* CONFIG_COMPAT */
162#endif /* _LINUX_COMPAT_H */
diff --git a/include/linux/compat_ioctl.h b/include/linux/compat_ioctl.h
new file mode 100644
index 000000000000..70a4ebb5d964
--- /dev/null
+++ b/include/linux/compat_ioctl.h
@@ -0,0 +1,771 @@
1/* List here explicitly which ioctl's are known to have
2 * compatible types passed or none at all... Please include
3 * only stuff that is compatible on *all architectures*.
4 */
5#ifndef COMPATIBLE_IOCTL /* pointer to compatible structure or no argument */
6#define COMPATIBLE_IOCTL(cmd) HANDLE_IOCTL((cmd),(ioctl_trans_handler_t)sys_ioctl)
7#endif
8
9#ifndef ULONG_IOCTL /* argument is an unsigned long integer, not a pointer */
10#define ULONG_IOCTL(cmd) HANDLE_IOCTL((cmd),(ioctl_trans_handler_t)sys_ioctl)
11#endif
12
13/* Big T */
14COMPATIBLE_IOCTL(TCGETA)
15COMPATIBLE_IOCTL(TCSETA)
16COMPATIBLE_IOCTL(TCSETAW)
17COMPATIBLE_IOCTL(TCSETAF)
18COMPATIBLE_IOCTL(TCSBRK)
19ULONG_IOCTL(TCSBRKP)
20COMPATIBLE_IOCTL(TCXONC)
21COMPATIBLE_IOCTL(TCFLSH)
22COMPATIBLE_IOCTL(TCGETS)
23COMPATIBLE_IOCTL(TCSETS)
24COMPATIBLE_IOCTL(TCSETSW)
25COMPATIBLE_IOCTL(TCSETSF)
26COMPATIBLE_IOCTL(TIOCLINUX)
27COMPATIBLE_IOCTL(TIOCSBRK)
28COMPATIBLE_IOCTL(TIOCCBRK)
29ULONG_IOCTL(TIOCMIWAIT)
30COMPATIBLE_IOCTL(TIOCGICOUNT)
31/* Little t */
32COMPATIBLE_IOCTL(TIOCGETD)
33COMPATIBLE_IOCTL(TIOCSETD)
34COMPATIBLE_IOCTL(TIOCEXCL)
35COMPATIBLE_IOCTL(TIOCNXCL)
36COMPATIBLE_IOCTL(TIOCCONS)
37COMPATIBLE_IOCTL(TIOCGSOFTCAR)
38COMPATIBLE_IOCTL(TIOCSSOFTCAR)
39COMPATIBLE_IOCTL(TIOCSWINSZ)
40COMPATIBLE_IOCTL(TIOCGWINSZ)
41COMPATIBLE_IOCTL(TIOCMGET)
42COMPATIBLE_IOCTL(TIOCMBIC)
43COMPATIBLE_IOCTL(TIOCMBIS)
44COMPATIBLE_IOCTL(TIOCMSET)
45COMPATIBLE_IOCTL(TIOCPKT)
46COMPATIBLE_IOCTL(TIOCNOTTY)
47COMPATIBLE_IOCTL(TIOCSTI)
48COMPATIBLE_IOCTL(TIOCOUTQ)
49COMPATIBLE_IOCTL(TIOCSPGRP)
50COMPATIBLE_IOCTL(TIOCGPGRP)
51ULONG_IOCTL(TIOCSCTTY)
52COMPATIBLE_IOCTL(TIOCGPTN)
53COMPATIBLE_IOCTL(TIOCSPTLCK)
54COMPATIBLE_IOCTL(TIOCSERGETLSR)
55/* Big F */
56COMPATIBLE_IOCTL(FBIOBLANK)
57COMPATIBLE_IOCTL(FBIOGET_VSCREENINFO)
58COMPATIBLE_IOCTL(FBIOPUT_VSCREENINFO)
59COMPATIBLE_IOCTL(FBIOPAN_DISPLAY)
60COMPATIBLE_IOCTL(FBIOGET_CON2FBMAP)
61COMPATIBLE_IOCTL(FBIOPUT_CON2FBMAP)
62/* Little f */
63COMPATIBLE_IOCTL(FIOCLEX)
64COMPATIBLE_IOCTL(FIONCLEX)
65COMPATIBLE_IOCTL(FIOASYNC)
66COMPATIBLE_IOCTL(FIONBIO)
67COMPATIBLE_IOCTL(FIONREAD) /* This is also TIOCINQ */
68/* 0x00 */
69COMPATIBLE_IOCTL(FIBMAP)
70COMPATIBLE_IOCTL(FIGETBSZ)
71/* 0x03 -- HD/IDE ioctl's used by hdparm and friends.
72 * Some need translations, these do not.
73 */
74COMPATIBLE_IOCTL(HDIO_GET_IDENTITY)
75COMPATIBLE_IOCTL(HDIO_SET_DMA)
76COMPATIBLE_IOCTL(HDIO_SET_UNMASKINTR)
77COMPATIBLE_IOCTL(HDIO_SET_NOWERR)
78COMPATIBLE_IOCTL(HDIO_SET_32BIT)
79COMPATIBLE_IOCTL(HDIO_SET_MULTCOUNT)
80COMPATIBLE_IOCTL(HDIO_DRIVE_CMD)
81COMPATIBLE_IOCTL(HDIO_DRIVE_TASK)
82COMPATIBLE_IOCTL(HDIO_SET_PIO_MODE)
83COMPATIBLE_IOCTL(HDIO_SET_NICE)
84/* 0x02 -- Floppy ioctls */
85COMPATIBLE_IOCTL(FDMSGON)
86COMPATIBLE_IOCTL(FDMSGOFF)
87COMPATIBLE_IOCTL(FDSETEMSGTRESH)
88COMPATIBLE_IOCTL(FDFLUSH)
89COMPATIBLE_IOCTL(FDWERRORCLR)
90COMPATIBLE_IOCTL(FDSETMAXERRS)
91COMPATIBLE_IOCTL(FDGETMAXERRS)
92COMPATIBLE_IOCTL(FDGETDRVTYP)
93COMPATIBLE_IOCTL(FDEJECT)
94COMPATIBLE_IOCTL(FDCLRPRM)
95COMPATIBLE_IOCTL(FDFMTBEG)
96COMPATIBLE_IOCTL(FDFMTEND)
97COMPATIBLE_IOCTL(FDRESET)
98COMPATIBLE_IOCTL(FDTWADDLE)
99COMPATIBLE_IOCTL(FDFMTTRK)
100COMPATIBLE_IOCTL(FDRAWCMD)
101/* 0x12 */
102COMPATIBLE_IOCTL(BLKROSET)
103COMPATIBLE_IOCTL(BLKROGET)
104COMPATIBLE_IOCTL(BLKRRPART)
105COMPATIBLE_IOCTL(BLKFLSBUF)
106COMPATIBLE_IOCTL(BLKSECTSET)
107COMPATIBLE_IOCTL(BLKSSZGET)
108ULONG_IOCTL(BLKRASET)
109ULONG_IOCTL(BLKFRASET)
110/* RAID */
111COMPATIBLE_IOCTL(RAID_VERSION)
112COMPATIBLE_IOCTL(GET_ARRAY_INFO)
113COMPATIBLE_IOCTL(GET_DISK_INFO)
114COMPATIBLE_IOCTL(PRINT_RAID_DEBUG)
115COMPATIBLE_IOCTL(RAID_AUTORUN)
116COMPATIBLE_IOCTL(CLEAR_ARRAY)
117COMPATIBLE_IOCTL(ADD_NEW_DISK)
118ULONG_IOCTL(HOT_REMOVE_DISK)
119COMPATIBLE_IOCTL(SET_ARRAY_INFO)
120COMPATIBLE_IOCTL(SET_DISK_INFO)
121COMPATIBLE_IOCTL(WRITE_RAID_INFO)
122COMPATIBLE_IOCTL(UNPROTECT_ARRAY)
123COMPATIBLE_IOCTL(PROTECT_ARRAY)
124ULONG_IOCTL(HOT_ADD_DISK)
125ULONG_IOCTL(SET_DISK_FAULTY)
126COMPATIBLE_IOCTL(RUN_ARRAY)
127ULONG_IOCTL(START_ARRAY)
128COMPATIBLE_IOCTL(STOP_ARRAY)
129COMPATIBLE_IOCTL(STOP_ARRAY_RO)
130COMPATIBLE_IOCTL(RESTART_ARRAY_RW)
131/* DM */
132COMPATIBLE_IOCTL(DM_VERSION_32)
133COMPATIBLE_IOCTL(DM_REMOVE_ALL_32)
134COMPATIBLE_IOCTL(DM_LIST_DEVICES_32)
135COMPATIBLE_IOCTL(DM_DEV_CREATE_32)
136COMPATIBLE_IOCTL(DM_DEV_REMOVE_32)
137COMPATIBLE_IOCTL(DM_DEV_RENAME_32)
138COMPATIBLE_IOCTL(DM_DEV_SUSPEND_32)
139COMPATIBLE_IOCTL(DM_DEV_STATUS_32)
140COMPATIBLE_IOCTL(DM_DEV_WAIT_32)
141COMPATIBLE_IOCTL(DM_TABLE_LOAD_32)
142COMPATIBLE_IOCTL(DM_TABLE_CLEAR_32)
143COMPATIBLE_IOCTL(DM_TABLE_DEPS_32)
144COMPATIBLE_IOCTL(DM_TABLE_STATUS_32)
145COMPATIBLE_IOCTL(DM_LIST_VERSIONS_32)
146COMPATIBLE_IOCTL(DM_TARGET_MSG_32)
147COMPATIBLE_IOCTL(DM_VERSION)
148COMPATIBLE_IOCTL(DM_REMOVE_ALL)
149COMPATIBLE_IOCTL(DM_LIST_DEVICES)
150COMPATIBLE_IOCTL(DM_DEV_CREATE)
151COMPATIBLE_IOCTL(DM_DEV_REMOVE)
152COMPATIBLE_IOCTL(DM_DEV_RENAME)
153COMPATIBLE_IOCTL(DM_DEV_SUSPEND)
154COMPATIBLE_IOCTL(DM_DEV_STATUS)
155COMPATIBLE_IOCTL(DM_DEV_WAIT)
156COMPATIBLE_IOCTL(DM_TABLE_LOAD)
157COMPATIBLE_IOCTL(DM_TABLE_CLEAR)
158COMPATIBLE_IOCTL(DM_TABLE_DEPS)
159COMPATIBLE_IOCTL(DM_TABLE_STATUS)
160COMPATIBLE_IOCTL(DM_LIST_VERSIONS)
161COMPATIBLE_IOCTL(DM_TARGET_MSG)
162/* Big K */
163COMPATIBLE_IOCTL(PIO_FONT)
164COMPATIBLE_IOCTL(GIO_FONT)
165ULONG_IOCTL(KDSIGACCEPT)
166COMPATIBLE_IOCTL(KDGETKEYCODE)
167COMPATIBLE_IOCTL(KDSETKEYCODE)
168ULONG_IOCTL(KIOCSOUND)
169ULONG_IOCTL(KDMKTONE)
170COMPATIBLE_IOCTL(KDGKBTYPE)
171ULONG_IOCTL(KDSETMODE)
172COMPATIBLE_IOCTL(KDGETMODE)
173ULONG_IOCTL(KDSKBMODE)
174COMPATIBLE_IOCTL(KDGKBMODE)
175ULONG_IOCTL(KDSKBMETA)
176COMPATIBLE_IOCTL(KDGKBMETA)
177COMPATIBLE_IOCTL(KDGKBENT)
178COMPATIBLE_IOCTL(KDSKBENT)
179COMPATIBLE_IOCTL(KDGKBSENT)
180COMPATIBLE_IOCTL(KDSKBSENT)
181COMPATIBLE_IOCTL(KDGKBDIACR)
182COMPATIBLE_IOCTL(KDSKBDIACR)
183COMPATIBLE_IOCTL(KDKBDREP)
184COMPATIBLE_IOCTL(KDGKBLED)
185ULONG_IOCTL(KDSKBLED)
186COMPATIBLE_IOCTL(KDGETLED)
187ULONG_IOCTL(KDSETLED)
188COMPATIBLE_IOCTL(GIO_SCRNMAP)
189COMPATIBLE_IOCTL(PIO_SCRNMAP)
190COMPATIBLE_IOCTL(GIO_UNISCRNMAP)
191COMPATIBLE_IOCTL(PIO_UNISCRNMAP)
192COMPATIBLE_IOCTL(PIO_FONTRESET)
193COMPATIBLE_IOCTL(PIO_UNIMAPCLR)
194/* Big S */
195COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN)
196COMPATIBLE_IOCTL(SCSI_IOCTL_DOORLOCK)
197COMPATIBLE_IOCTL(SCSI_IOCTL_DOORUNLOCK)
198COMPATIBLE_IOCTL(SCSI_IOCTL_TEST_UNIT_READY)
199COMPATIBLE_IOCTL(SCSI_IOCTL_GET_BUS_NUMBER)
200COMPATIBLE_IOCTL(SCSI_IOCTL_SEND_COMMAND)
201COMPATIBLE_IOCTL(SCSI_IOCTL_PROBE_HOST)
202COMPATIBLE_IOCTL(SCSI_IOCTL_GET_PCI)
203/* Big T */
204COMPATIBLE_IOCTL(TUNSETNOCSUM)
205COMPATIBLE_IOCTL(TUNSETDEBUG)
206COMPATIBLE_IOCTL(TUNSETPERSIST)
207COMPATIBLE_IOCTL(TUNSETOWNER)
208/* Big V */
209COMPATIBLE_IOCTL(VT_SETMODE)
210COMPATIBLE_IOCTL(VT_GETMODE)
211COMPATIBLE_IOCTL(VT_GETSTATE)
212COMPATIBLE_IOCTL(VT_OPENQRY)
213ULONG_IOCTL(VT_ACTIVATE)
214ULONG_IOCTL(VT_WAITACTIVE)
215ULONG_IOCTL(VT_RELDISP)
216ULONG_IOCTL(VT_DISALLOCATE)
217COMPATIBLE_IOCTL(VT_RESIZE)
218COMPATIBLE_IOCTL(VT_RESIZEX)
219COMPATIBLE_IOCTL(VT_LOCKSWITCH)
220COMPATIBLE_IOCTL(VT_UNLOCKSWITCH)
221/* Little v */
222/* Little v, the video4linux ioctls (conflict?) */
223COMPATIBLE_IOCTL(VIDIOCGCAP)
224COMPATIBLE_IOCTL(VIDIOCGCHAN)
225COMPATIBLE_IOCTL(VIDIOCSCHAN)
226COMPATIBLE_IOCTL(VIDIOCGPICT)
227COMPATIBLE_IOCTL(VIDIOCSPICT)
228COMPATIBLE_IOCTL(VIDIOCCAPTURE)
229COMPATIBLE_IOCTL(VIDIOCKEY)
230COMPATIBLE_IOCTL(VIDIOCGAUDIO)
231COMPATIBLE_IOCTL(VIDIOCSAUDIO)
232COMPATIBLE_IOCTL(VIDIOCSYNC)
233COMPATIBLE_IOCTL(VIDIOCMCAPTURE)
234COMPATIBLE_IOCTL(VIDIOCGMBUF)
235COMPATIBLE_IOCTL(VIDIOCGUNIT)
236COMPATIBLE_IOCTL(VIDIOCGCAPTURE)
237COMPATIBLE_IOCTL(VIDIOCSCAPTURE)
238/* BTTV specific... */
239COMPATIBLE_IOCTL(_IOW('v', BASE_VIDIOCPRIVATE+0, char [256]))
240COMPATIBLE_IOCTL(_IOR('v', BASE_VIDIOCPRIVATE+1, char [256]))
241COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+2, unsigned int))
242COMPATIBLE_IOCTL(_IOW('v' , BASE_VIDIOCPRIVATE+3, char [16])) /* struct bttv_pll_info */
243COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+4, int))
244COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+5, int))
245COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+6, int))
246COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+7, int))
247/* Little p (/dev/rtc, /dev/envctrl, etc.) */
248COMPATIBLE_IOCTL(RTC_AIE_ON)
249COMPATIBLE_IOCTL(RTC_AIE_OFF)
250COMPATIBLE_IOCTL(RTC_UIE_ON)
251COMPATIBLE_IOCTL(RTC_UIE_OFF)
252COMPATIBLE_IOCTL(RTC_PIE_ON)
253COMPATIBLE_IOCTL(RTC_PIE_OFF)
254COMPATIBLE_IOCTL(RTC_WIE_ON)
255COMPATIBLE_IOCTL(RTC_WIE_OFF)
256COMPATIBLE_IOCTL(RTC_ALM_SET)
257COMPATIBLE_IOCTL(RTC_ALM_READ)
258COMPATIBLE_IOCTL(RTC_RD_TIME)
259COMPATIBLE_IOCTL(RTC_SET_TIME)
260COMPATIBLE_IOCTL(RTC_WKALM_SET)
261COMPATIBLE_IOCTL(RTC_WKALM_RD)
262/* Little m */
263COMPATIBLE_IOCTL(MTIOCTOP)
264/* Socket level stuff */
265COMPATIBLE_IOCTL(FIOSETOWN)
266COMPATIBLE_IOCTL(SIOCSPGRP)
267COMPATIBLE_IOCTL(FIOGETOWN)
268COMPATIBLE_IOCTL(SIOCGPGRP)
269COMPATIBLE_IOCTL(SIOCATMARK)
270COMPATIBLE_IOCTL(SIOCSIFLINK)
271COMPATIBLE_IOCTL(SIOCSIFENCAP)
272COMPATIBLE_IOCTL(SIOCGIFENCAP)
273COMPATIBLE_IOCTL(SIOCSIFNAME)
274COMPATIBLE_IOCTL(SIOCSARP)
275COMPATIBLE_IOCTL(SIOCGARP)
276COMPATIBLE_IOCTL(SIOCDARP)
277COMPATIBLE_IOCTL(SIOCSRARP)
278COMPATIBLE_IOCTL(SIOCGRARP)
279COMPATIBLE_IOCTL(SIOCDRARP)
280COMPATIBLE_IOCTL(SIOCADDDLCI)
281COMPATIBLE_IOCTL(SIOCDELDLCI)
282COMPATIBLE_IOCTL(SIOCGMIIPHY)
283COMPATIBLE_IOCTL(SIOCGMIIREG)
284COMPATIBLE_IOCTL(SIOCSMIIREG)
285COMPATIBLE_IOCTL(SIOCGIFVLAN)
286COMPATIBLE_IOCTL(SIOCSIFVLAN)
287COMPATIBLE_IOCTL(SIOCBRADDBR)
288COMPATIBLE_IOCTL(SIOCBRDELBR)
289/* SG stuff */
290COMPATIBLE_IOCTL(SG_SET_TIMEOUT)
291COMPATIBLE_IOCTL(SG_GET_TIMEOUT)
292COMPATIBLE_IOCTL(SG_EMULATED_HOST)
293ULONG_IOCTL(SG_SET_TRANSFORM)
294COMPATIBLE_IOCTL(SG_GET_TRANSFORM)
295COMPATIBLE_IOCTL(SG_SET_RESERVED_SIZE)
296COMPATIBLE_IOCTL(SG_GET_RESERVED_SIZE)
297COMPATIBLE_IOCTL(SG_GET_SCSI_ID)
298COMPATIBLE_IOCTL(SG_SET_FORCE_LOW_DMA)
299COMPATIBLE_IOCTL(SG_GET_LOW_DMA)
300COMPATIBLE_IOCTL(SG_SET_FORCE_PACK_ID)
301COMPATIBLE_IOCTL(SG_GET_PACK_ID)
302COMPATIBLE_IOCTL(SG_GET_NUM_WAITING)
303COMPATIBLE_IOCTL(SG_SET_DEBUG)
304COMPATIBLE_IOCTL(SG_GET_SG_TABLESIZE)
305COMPATIBLE_IOCTL(SG_GET_COMMAND_Q)
306COMPATIBLE_IOCTL(SG_SET_COMMAND_Q)
307COMPATIBLE_IOCTL(SG_GET_VERSION_NUM)
308COMPATIBLE_IOCTL(SG_NEXT_CMD_LEN)
309COMPATIBLE_IOCTL(SG_SCSI_RESET)
310COMPATIBLE_IOCTL(SG_GET_REQUEST_TABLE)
311COMPATIBLE_IOCTL(SG_SET_KEEP_ORPHAN)
312COMPATIBLE_IOCTL(SG_GET_KEEP_ORPHAN)
313/* PPP stuff */
314COMPATIBLE_IOCTL(PPPIOCGFLAGS)
315COMPATIBLE_IOCTL(PPPIOCSFLAGS)
316COMPATIBLE_IOCTL(PPPIOCGASYNCMAP)
317COMPATIBLE_IOCTL(PPPIOCSASYNCMAP)
318COMPATIBLE_IOCTL(PPPIOCGUNIT)
319COMPATIBLE_IOCTL(PPPIOCGRASYNCMAP)
320COMPATIBLE_IOCTL(PPPIOCSRASYNCMAP)
321COMPATIBLE_IOCTL(PPPIOCGMRU)
322COMPATIBLE_IOCTL(PPPIOCSMRU)
323COMPATIBLE_IOCTL(PPPIOCSMAXCID)
324COMPATIBLE_IOCTL(PPPIOCGXASYNCMAP)
325COMPATIBLE_IOCTL(PPPIOCSXASYNCMAP)
326COMPATIBLE_IOCTL(PPPIOCXFERUNIT)
327/* PPPIOCSCOMPRESS is translated */
328COMPATIBLE_IOCTL(PPPIOCGNPMODE)
329COMPATIBLE_IOCTL(PPPIOCSNPMODE)
330COMPATIBLE_IOCTL(PPPIOCGDEBUG)
331COMPATIBLE_IOCTL(PPPIOCSDEBUG)
332/* PPPIOCSPASS is translated */
333/* PPPIOCSACTIVE is translated */
334/* PPPIOCGIDLE is translated */
335COMPATIBLE_IOCTL(PPPIOCNEWUNIT)
336COMPATIBLE_IOCTL(PPPIOCATTACH)
337COMPATIBLE_IOCTL(PPPIOCDETACH)
338COMPATIBLE_IOCTL(PPPIOCSMRRU)
339COMPATIBLE_IOCTL(PPPIOCCONNECT)
340COMPATIBLE_IOCTL(PPPIOCDISCONN)
341COMPATIBLE_IOCTL(PPPIOCATTCHAN)
342COMPATIBLE_IOCTL(PPPIOCGCHAN)
343/* PPPOX */
344COMPATIBLE_IOCTL(PPPOEIOCSFWD)
345COMPATIBLE_IOCTL(PPPOEIOCDFWD)
346/* LP */
347COMPATIBLE_IOCTL(LPGETSTATUS)
348/* ppdev */
349COMPATIBLE_IOCTL(PPCLAIM)
350COMPATIBLE_IOCTL(PPRELEASE)
351COMPATIBLE_IOCTL(PPEXCL)
352COMPATIBLE_IOCTL(PPYIELD)
353/* CDROM stuff */
354COMPATIBLE_IOCTL(CDROMPAUSE)
355COMPATIBLE_IOCTL(CDROMRESUME)
356COMPATIBLE_IOCTL(CDROMPLAYMSF)
357COMPATIBLE_IOCTL(CDROMPLAYTRKIND)
358COMPATIBLE_IOCTL(CDROMREADTOCHDR)
359COMPATIBLE_IOCTL(CDROMREADTOCENTRY)
360COMPATIBLE_IOCTL(CDROMSTOP)
361COMPATIBLE_IOCTL(CDROMSTART)
362COMPATIBLE_IOCTL(CDROMEJECT)
363COMPATIBLE_IOCTL(CDROMVOLCTRL)
364COMPATIBLE_IOCTL(CDROMSUBCHNL)
365ULONG_IOCTL(CDROMEJECT_SW)
366COMPATIBLE_IOCTL(CDROMMULTISESSION)
367COMPATIBLE_IOCTL(CDROM_GET_MCN)
368COMPATIBLE_IOCTL(CDROMRESET)
369COMPATIBLE_IOCTL(CDROMVOLREAD)
370COMPATIBLE_IOCTL(CDROMSEEK)
371COMPATIBLE_IOCTL(CDROMPLAYBLK)
372COMPATIBLE_IOCTL(CDROMCLOSETRAY)
373ULONG_IOCTL(CDROM_SET_OPTIONS)
374ULONG_IOCTL(CDROM_CLEAR_OPTIONS)
375ULONG_IOCTL(CDROM_SELECT_SPEED)
376ULONG_IOCTL(CDROM_SELECT_DISC)
377ULONG_IOCTL(CDROM_MEDIA_CHANGED)
378ULONG_IOCTL(CDROM_DRIVE_STATUS)
379COMPATIBLE_IOCTL(CDROM_DISC_STATUS)
380COMPATIBLE_IOCTL(CDROM_CHANGER_NSLOTS)
381ULONG_IOCTL(CDROM_LOCKDOOR)
382ULONG_IOCTL(CDROM_DEBUG)
383COMPATIBLE_IOCTL(CDROM_GET_CAPABILITY)
384/* Ignore cdrom.h about these next 5 ioctls, they absolutely do
385 * not take a struct cdrom_read, instead they take a struct cdrom_msf
386 * which is compatible.
387 */
388COMPATIBLE_IOCTL(CDROMREADMODE2)
389COMPATIBLE_IOCTL(CDROMREADMODE1)
390COMPATIBLE_IOCTL(CDROMREADRAW)
391COMPATIBLE_IOCTL(CDROMREADCOOKED)
392COMPATIBLE_IOCTL(CDROMREADALL)
393/* DVD ioctls */
394COMPATIBLE_IOCTL(DVD_READ_STRUCT)
395COMPATIBLE_IOCTL(DVD_WRITE_STRUCT)
396COMPATIBLE_IOCTL(DVD_AUTH)
397/* pktcdvd */
398COMPATIBLE_IOCTL(PACKET_CTRL_CMD)
399/* Big L */
400ULONG_IOCTL(LOOP_SET_FD)
401ULONG_IOCTL(LOOP_CHANGE_FD)
402COMPATIBLE_IOCTL(LOOP_CLR_FD)
403COMPATIBLE_IOCTL(LOOP_GET_STATUS64)
404COMPATIBLE_IOCTL(LOOP_SET_STATUS64)
405/* Big A */
406/* sparc only */
407/* Big Q for sound/OSS */
408COMPATIBLE_IOCTL(SNDCTL_SEQ_RESET)
409COMPATIBLE_IOCTL(SNDCTL_SEQ_SYNC)
410COMPATIBLE_IOCTL(SNDCTL_SYNTH_INFO)
411COMPATIBLE_IOCTL(SNDCTL_SEQ_CTRLRATE)
412COMPATIBLE_IOCTL(SNDCTL_SEQ_GETOUTCOUNT)
413COMPATIBLE_IOCTL(SNDCTL_SEQ_GETINCOUNT)
414COMPATIBLE_IOCTL(SNDCTL_SEQ_PERCMODE)
415COMPATIBLE_IOCTL(SNDCTL_FM_LOAD_INSTR)
416COMPATIBLE_IOCTL(SNDCTL_SEQ_TESTMIDI)
417COMPATIBLE_IOCTL(SNDCTL_SEQ_RESETSAMPLES)
418COMPATIBLE_IOCTL(SNDCTL_SEQ_NRSYNTHS)
419COMPATIBLE_IOCTL(SNDCTL_SEQ_NRMIDIS)
420COMPATIBLE_IOCTL(SNDCTL_MIDI_INFO)
421COMPATIBLE_IOCTL(SNDCTL_SEQ_THRESHOLD)
422COMPATIBLE_IOCTL(SNDCTL_SYNTH_MEMAVL)
423COMPATIBLE_IOCTL(SNDCTL_FM_4OP_ENABLE)
424COMPATIBLE_IOCTL(SNDCTL_SEQ_PANIC)
425COMPATIBLE_IOCTL(SNDCTL_SEQ_OUTOFBAND)
426COMPATIBLE_IOCTL(SNDCTL_SEQ_GETTIME)
427COMPATIBLE_IOCTL(SNDCTL_SYNTH_ID)
428COMPATIBLE_IOCTL(SNDCTL_SYNTH_CONTROL)
429COMPATIBLE_IOCTL(SNDCTL_SYNTH_REMOVESAMPLE)
430/* Big T for sound/OSS */
431COMPATIBLE_IOCTL(SNDCTL_TMR_TIMEBASE)
432COMPATIBLE_IOCTL(SNDCTL_TMR_START)
433COMPATIBLE_IOCTL(SNDCTL_TMR_STOP)
434COMPATIBLE_IOCTL(SNDCTL_TMR_CONTINUE)
435COMPATIBLE_IOCTL(SNDCTL_TMR_TEMPO)
436COMPATIBLE_IOCTL(SNDCTL_TMR_SOURCE)
437COMPATIBLE_IOCTL(SNDCTL_TMR_METRONOME)
438COMPATIBLE_IOCTL(SNDCTL_TMR_SELECT)
439/* Little m for sound/OSS */
440COMPATIBLE_IOCTL(SNDCTL_MIDI_PRETIME)
441COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUMODE)
442COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUCMD)
443/* Big P for sound/OSS */
444COMPATIBLE_IOCTL(SNDCTL_DSP_RESET)
445COMPATIBLE_IOCTL(SNDCTL_DSP_SYNC)
446COMPATIBLE_IOCTL(SNDCTL_DSP_SPEED)
447COMPATIBLE_IOCTL(SNDCTL_DSP_STEREO)
448COMPATIBLE_IOCTL(SNDCTL_DSP_GETBLKSIZE)
449COMPATIBLE_IOCTL(SNDCTL_DSP_CHANNELS)
450COMPATIBLE_IOCTL(SOUND_PCM_WRITE_FILTER)
451COMPATIBLE_IOCTL(SNDCTL_DSP_POST)
452COMPATIBLE_IOCTL(SNDCTL_DSP_SUBDIVIDE)
453COMPATIBLE_IOCTL(SNDCTL_DSP_SETFRAGMENT)
454COMPATIBLE_IOCTL(SNDCTL_DSP_GETFMTS)
455COMPATIBLE_IOCTL(SNDCTL_DSP_SETFMT)
456COMPATIBLE_IOCTL(SNDCTL_DSP_GETOSPACE)
457COMPATIBLE_IOCTL(SNDCTL_DSP_GETISPACE)
458COMPATIBLE_IOCTL(SNDCTL_DSP_NONBLOCK)
459COMPATIBLE_IOCTL(SNDCTL_DSP_GETCAPS)
460COMPATIBLE_IOCTL(SNDCTL_DSP_GETTRIGGER)
461COMPATIBLE_IOCTL(SNDCTL_DSP_SETTRIGGER)
462COMPATIBLE_IOCTL(SNDCTL_DSP_GETIPTR)
463COMPATIBLE_IOCTL(SNDCTL_DSP_GETOPTR)
464/* SNDCTL_DSP_MAPINBUF, XXX needs translation */
465/* SNDCTL_DSP_MAPOUTBUF, XXX needs translation */
466COMPATIBLE_IOCTL(SNDCTL_DSP_SETSYNCRO)
467COMPATIBLE_IOCTL(SNDCTL_DSP_SETDUPLEX)
468COMPATIBLE_IOCTL(SNDCTL_DSP_GETODELAY)
469COMPATIBLE_IOCTL(SNDCTL_DSP_PROFILE)
470COMPATIBLE_IOCTL(SOUND_PCM_READ_RATE)
471COMPATIBLE_IOCTL(SOUND_PCM_READ_CHANNELS)
472COMPATIBLE_IOCTL(SOUND_PCM_READ_BITS)
473COMPATIBLE_IOCTL(SOUND_PCM_READ_FILTER)
474/* Big C for sound/OSS */
475COMPATIBLE_IOCTL(SNDCTL_COPR_RESET)
476COMPATIBLE_IOCTL(SNDCTL_COPR_LOAD)
477COMPATIBLE_IOCTL(SNDCTL_COPR_RDATA)
478COMPATIBLE_IOCTL(SNDCTL_COPR_RCODE)
479COMPATIBLE_IOCTL(SNDCTL_COPR_WDATA)
480COMPATIBLE_IOCTL(SNDCTL_COPR_WCODE)
481COMPATIBLE_IOCTL(SNDCTL_COPR_RUN)
482COMPATIBLE_IOCTL(SNDCTL_COPR_HALT)
483COMPATIBLE_IOCTL(SNDCTL_COPR_SENDMSG)
484COMPATIBLE_IOCTL(SNDCTL_COPR_RCVMSG)
485/* Big M for sound/OSS */
486COMPATIBLE_IOCTL(SOUND_MIXER_READ_VOLUME)
487COMPATIBLE_IOCTL(SOUND_MIXER_READ_BASS)
488COMPATIBLE_IOCTL(SOUND_MIXER_READ_TREBLE)
489COMPATIBLE_IOCTL(SOUND_MIXER_READ_SYNTH)
490COMPATIBLE_IOCTL(SOUND_MIXER_READ_PCM)
491COMPATIBLE_IOCTL(SOUND_MIXER_READ_SPEAKER)
492COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE)
493COMPATIBLE_IOCTL(SOUND_MIXER_READ_MIC)
494COMPATIBLE_IOCTL(SOUND_MIXER_READ_CD)
495COMPATIBLE_IOCTL(SOUND_MIXER_READ_IMIX)
496COMPATIBLE_IOCTL(SOUND_MIXER_READ_ALTPCM)
497COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECLEV)
498COMPATIBLE_IOCTL(SOUND_MIXER_READ_IGAIN)
499COMPATIBLE_IOCTL(SOUND_MIXER_READ_OGAIN)
500COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE1)
501COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE2)
502COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE3)
503COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL1))
504COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL2))
505COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL3))
506COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEIN))
507COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEOUT))
508COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_VIDEO))
509COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_RADIO))
510COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_MONITOR))
511COMPATIBLE_IOCTL(SOUND_MIXER_READ_MUTE)
512/* SOUND_MIXER_READ_ENHANCE, same value as READ_MUTE */
513/* SOUND_MIXER_READ_LOUD, same value as READ_MUTE */
514COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECSRC)
515COMPATIBLE_IOCTL(SOUND_MIXER_READ_DEVMASK)
516COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECMASK)
517COMPATIBLE_IOCTL(SOUND_MIXER_READ_STEREODEVS)
518COMPATIBLE_IOCTL(SOUND_MIXER_READ_CAPS)
519COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_VOLUME)
520COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_BASS)
521COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_TREBLE)
522COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SYNTH)
523COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_PCM)
524COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SPEAKER)
525COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE)
526COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MIC)
527COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_CD)
528COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IMIX)
529COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_ALTPCM)
530COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECLEV)
531COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IGAIN)
532COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_OGAIN)
533COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE1)
534COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE2)
535COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE3)
536COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL1))
537COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL2))
538COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL3))
539COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEIN))
540COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEOUT))
541COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_VIDEO))
542COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_RADIO))
543COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_MONITOR))
544COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MUTE)
545/* SOUND_MIXER_WRITE_ENHANCE, same value as WRITE_MUTE */
546/* SOUND_MIXER_WRITE_LOUD, same value as WRITE_MUTE */
547COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECSRC)
548COMPATIBLE_IOCTL(SOUND_MIXER_INFO)
549COMPATIBLE_IOCTL(SOUND_OLD_MIXER_INFO)
550COMPATIBLE_IOCTL(SOUND_MIXER_ACCESS)
551COMPATIBLE_IOCTL(SOUND_MIXER_AGC)
552COMPATIBLE_IOCTL(SOUND_MIXER_3DSE)
553COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE1)
554COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE2)
555COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE3)
556COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE4)
557COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE5)
558COMPATIBLE_IOCTL(SOUND_MIXER_GETLEVELS)
559COMPATIBLE_IOCTL(SOUND_MIXER_SETLEVELS)
560COMPATIBLE_IOCTL(OSS_GETVERSION)
561/* AUTOFS */
562ULONG_IOCTL(AUTOFS_IOC_READY)
563ULONG_IOCTL(AUTOFS_IOC_FAIL)
564COMPATIBLE_IOCTL(AUTOFS_IOC_CATATONIC)
565COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOVER)
566COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE)
567COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE_MULTI)
568COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOSUBVER)
569COMPATIBLE_IOCTL(AUTOFS_IOC_ASKREGHOST)
570COMPATIBLE_IOCTL(AUTOFS_IOC_TOGGLEREGHOST)
571COMPATIBLE_IOCTL(AUTOFS_IOC_ASKUMOUNT)
572/* DEVFS */
573COMPATIBLE_IOCTL(DEVFSDIOC_GET_PROTO_REV)
574COMPATIBLE_IOCTL(DEVFSDIOC_SET_EVENT_MASK)
575COMPATIBLE_IOCTL(DEVFSDIOC_RELEASE_EVENT_QUEUE)
576COMPATIBLE_IOCTL(DEVFSDIOC_SET_DEBUG_MASK)
577/* Raw devices */
578COMPATIBLE_IOCTL(RAW_SETBIND)
579COMPATIBLE_IOCTL(RAW_GETBIND)
580/* SMB ioctls which do not need any translations */
581COMPATIBLE_IOCTL(SMB_IOC_NEWCONN)
582/* NCP ioctls which do not need any translations */
583COMPATIBLE_IOCTL(NCP_IOC_CONN_LOGGED_IN)
584COMPATIBLE_IOCTL(NCP_IOC_SIGN_INIT)
585COMPATIBLE_IOCTL(NCP_IOC_SIGN_WANTED)
586COMPATIBLE_IOCTL(NCP_IOC_SET_SIGN_WANTED)
587COMPATIBLE_IOCTL(NCP_IOC_LOCKUNLOCK)
588COMPATIBLE_IOCTL(NCP_IOC_GETROOT)
589COMPATIBLE_IOCTL(NCP_IOC_SETROOT)
590COMPATIBLE_IOCTL(NCP_IOC_GETCHARSETS)
591COMPATIBLE_IOCTL(NCP_IOC_SETCHARSETS)
592COMPATIBLE_IOCTL(NCP_IOC_GETDENTRYTTL)
593COMPATIBLE_IOCTL(NCP_IOC_SETDENTRYTTL)
594/* Little a */
595COMPATIBLE_IOCTL(ATMSIGD_CTRL)
596COMPATIBLE_IOCTL(ATMARPD_CTRL)
597COMPATIBLE_IOCTL(ATMLEC_CTRL)
598COMPATIBLE_IOCTL(ATMLEC_MCAST)
599COMPATIBLE_IOCTL(ATMLEC_DATA)
600COMPATIBLE_IOCTL(ATM_SETSC)
601COMPATIBLE_IOCTL(SIOCSIFATMTCP)
602COMPATIBLE_IOCTL(SIOCMKCLIP)
603COMPATIBLE_IOCTL(ATMARP_MKIP)
604COMPATIBLE_IOCTL(ATMARP_SETENTRY)
605COMPATIBLE_IOCTL(ATMARP_ENCAP)
606COMPATIBLE_IOCTL(ATMTCP_CREATE)
607COMPATIBLE_IOCTL(ATMTCP_REMOVE)
608COMPATIBLE_IOCTL(ATMMPC_CTRL)
609COMPATIBLE_IOCTL(ATMMPC_DATA)
610/* Watchdog */
611COMPATIBLE_IOCTL(WDIOC_GETSUPPORT)
612COMPATIBLE_IOCTL(WDIOC_GETSTATUS)
613COMPATIBLE_IOCTL(WDIOC_GETBOOTSTATUS)
614COMPATIBLE_IOCTL(WDIOC_GETTEMP)
615COMPATIBLE_IOCTL(WDIOC_SETOPTIONS)
616COMPATIBLE_IOCTL(WDIOC_KEEPALIVE)
617COMPATIBLE_IOCTL(WDIOC_SETTIMEOUT)
618COMPATIBLE_IOCTL(WDIOC_GETTIMEOUT)
619/* Big R */
620COMPATIBLE_IOCTL(RNDGETENTCNT)
621COMPATIBLE_IOCTL(RNDADDTOENTCNT)
622COMPATIBLE_IOCTL(RNDGETPOOL)
623COMPATIBLE_IOCTL(RNDADDENTROPY)
624COMPATIBLE_IOCTL(RNDZAPENTCNT)
625COMPATIBLE_IOCTL(RNDCLEARPOOL)
626/* Bluetooth */
627COMPATIBLE_IOCTL(HCIDEVUP)
628COMPATIBLE_IOCTL(HCIDEVDOWN)
629COMPATIBLE_IOCTL(HCIDEVRESET)
630COMPATIBLE_IOCTL(HCIDEVRESTAT)
631COMPATIBLE_IOCTL(HCIGETDEVLIST)
632COMPATIBLE_IOCTL(HCIGETDEVINFO)
633COMPATIBLE_IOCTL(HCIGETCONNLIST)
634COMPATIBLE_IOCTL(HCIGETCONNINFO)
635COMPATIBLE_IOCTL(HCISETRAW)
636COMPATIBLE_IOCTL(HCISETSCAN)
637COMPATIBLE_IOCTL(HCISETAUTH)
638COMPATIBLE_IOCTL(HCISETENCRYPT)
639COMPATIBLE_IOCTL(HCISETPTYPE)
640COMPATIBLE_IOCTL(HCISETLINKPOL)
641COMPATIBLE_IOCTL(HCISETLINKMODE)
642COMPATIBLE_IOCTL(HCISETACLMTU)
643COMPATIBLE_IOCTL(HCISETSCOMTU)
644COMPATIBLE_IOCTL(HCIINQUIRY)
645COMPATIBLE_IOCTL(HCIUARTSETPROTO)
646COMPATIBLE_IOCTL(HCIUARTGETPROTO)
647COMPATIBLE_IOCTL(RFCOMMCREATEDEV)
648COMPATIBLE_IOCTL(RFCOMMRELEASEDEV)
649COMPATIBLE_IOCTL(RFCOMMGETDEVLIST)
650COMPATIBLE_IOCTL(RFCOMMGETDEVINFO)
651COMPATIBLE_IOCTL(RFCOMMSTEALDLC)
652COMPATIBLE_IOCTL(BNEPCONNADD)
653COMPATIBLE_IOCTL(BNEPCONNDEL)
654COMPATIBLE_IOCTL(BNEPGETCONNLIST)
655COMPATIBLE_IOCTL(BNEPGETCONNINFO)
656COMPATIBLE_IOCTL(CMTPCONNADD)
657COMPATIBLE_IOCTL(CMTPCONNDEL)
658COMPATIBLE_IOCTL(CMTPGETCONNLIST)
659COMPATIBLE_IOCTL(CMTPGETCONNINFO)
660COMPATIBLE_IOCTL(HIDPCONNADD)
661COMPATIBLE_IOCTL(HIDPCONNDEL)
662COMPATIBLE_IOCTL(HIDPGETCONNLIST)
663COMPATIBLE_IOCTL(HIDPGETCONNINFO)
664/* CAPI */
665COMPATIBLE_IOCTL(CAPI_REGISTER)
666COMPATIBLE_IOCTL(CAPI_GET_MANUFACTURER)
667COMPATIBLE_IOCTL(CAPI_GET_VERSION)
668COMPATIBLE_IOCTL(CAPI_GET_SERIAL)
669COMPATIBLE_IOCTL(CAPI_GET_PROFILE)
670COMPATIBLE_IOCTL(CAPI_MANUFACTURER_CMD)
671COMPATIBLE_IOCTL(CAPI_GET_ERRCODE)
672COMPATIBLE_IOCTL(CAPI_INSTALLED)
673COMPATIBLE_IOCTL(CAPI_GET_FLAGS)
674COMPATIBLE_IOCTL(CAPI_SET_FLAGS)
675COMPATIBLE_IOCTL(CAPI_CLR_FLAGS)
676COMPATIBLE_IOCTL(CAPI_NCCI_OPENCOUNT)
677COMPATIBLE_IOCTL(CAPI_NCCI_GETUNIT)
678/* Misc. */
679COMPATIBLE_IOCTL(0x41545900) /* ATYIO_CLKR */
680COMPATIBLE_IOCTL(0x41545901) /* ATYIO_CLKW */
681COMPATIBLE_IOCTL(PCIIOC_CONTROLLER)
682COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_IO)
683COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_MEM)
684COMPATIBLE_IOCTL(PCIIOC_WRITE_COMBINE)
685/* USB */
686COMPATIBLE_IOCTL(USBDEVFS_RESETEP)
687COMPATIBLE_IOCTL(USBDEVFS_SETINTERFACE)
688COMPATIBLE_IOCTL(USBDEVFS_SETCONFIGURATION)
689COMPATIBLE_IOCTL(USBDEVFS_GETDRIVER)
690COMPATIBLE_IOCTL(USBDEVFS_DISCARDURB)
691COMPATIBLE_IOCTL(USBDEVFS_CLAIMINTERFACE)
692COMPATIBLE_IOCTL(USBDEVFS_RELEASEINTERFACE)
693COMPATIBLE_IOCTL(USBDEVFS_CONNECTINFO)
694COMPATIBLE_IOCTL(USBDEVFS_HUB_PORTINFO)
695COMPATIBLE_IOCTL(USBDEVFS_RESET)
696COMPATIBLE_IOCTL(USBDEVFS_SUBMITURB32)
697COMPATIBLE_IOCTL(USBDEVFS_REAPURB32)
698COMPATIBLE_IOCTL(USBDEVFS_REAPURBNDELAY32)
699COMPATIBLE_IOCTL(USBDEVFS_CLEAR_HALT)
700/* MTD */
701COMPATIBLE_IOCTL(MEMGETINFO)
702COMPATIBLE_IOCTL(MEMERASE)
703COMPATIBLE_IOCTL(MEMLOCK)
704COMPATIBLE_IOCTL(MEMUNLOCK)
705COMPATIBLE_IOCTL(MEMGETREGIONCOUNT)
706COMPATIBLE_IOCTL(MEMGETREGIONINFO)
707/* NBD */
708ULONG_IOCTL(NBD_SET_SOCK)
709ULONG_IOCTL(NBD_SET_BLKSIZE)
710ULONG_IOCTL(NBD_SET_SIZE)
711COMPATIBLE_IOCTL(NBD_DO_IT)
712COMPATIBLE_IOCTL(NBD_CLEAR_SOCK)
713COMPATIBLE_IOCTL(NBD_CLEAR_QUE)
714COMPATIBLE_IOCTL(NBD_PRINT_DEBUG)
715ULONG_IOCTL(NBD_SET_SIZE_BLOCKS)
716COMPATIBLE_IOCTL(NBD_DISCONNECT)
717/* i2c */
718COMPATIBLE_IOCTL(I2C_SLAVE)
719COMPATIBLE_IOCTL(I2C_SLAVE_FORCE)
720COMPATIBLE_IOCTL(I2C_TENBIT)
721COMPATIBLE_IOCTL(I2C_PEC)
722COMPATIBLE_IOCTL(I2C_RETRIES)
723COMPATIBLE_IOCTL(I2C_TIMEOUT)
724/* wireless */
725COMPATIBLE_IOCTL(SIOCSIWCOMMIT)
726COMPATIBLE_IOCTL(SIOCGIWNAME)
727COMPATIBLE_IOCTL(SIOCSIWNWID)
728COMPATIBLE_IOCTL(SIOCGIWNWID)
729COMPATIBLE_IOCTL(SIOCSIWFREQ)
730COMPATIBLE_IOCTL(SIOCGIWFREQ)
731COMPATIBLE_IOCTL(SIOCSIWMODE)
732COMPATIBLE_IOCTL(SIOCGIWMODE)
733COMPATIBLE_IOCTL(SIOCSIWSENS)
734COMPATIBLE_IOCTL(SIOCGIWSENS)
735COMPATIBLE_IOCTL(SIOCSIWRANGE)
736COMPATIBLE_IOCTL(SIOCSIWPRIV)
737COMPATIBLE_IOCTL(SIOCGIWPRIV)
738COMPATIBLE_IOCTL(SIOCSIWSTATS)
739COMPATIBLE_IOCTL(SIOCGIWSTATS)
740COMPATIBLE_IOCTL(SIOCSIWAP)
741COMPATIBLE_IOCTL(SIOCGIWAP)
742COMPATIBLE_IOCTL(SIOCSIWSCAN)
743COMPATIBLE_IOCTL(SIOCSIWRATE)
744COMPATIBLE_IOCTL(SIOCGIWRATE)
745COMPATIBLE_IOCTL(SIOCSIWRTS)
746COMPATIBLE_IOCTL(SIOCGIWRTS)
747COMPATIBLE_IOCTL(SIOCSIWFRAG)
748COMPATIBLE_IOCTL(SIOCGIWFRAG)
749COMPATIBLE_IOCTL(SIOCSIWTXPOW)
750COMPATIBLE_IOCTL(SIOCGIWTXPOW)
751COMPATIBLE_IOCTL(SIOCSIWRETRY)
752COMPATIBLE_IOCTL(SIOCGIWRETRY)
753COMPATIBLE_IOCTL(SIOCSIWPOWER)
754COMPATIBLE_IOCTL(SIOCGIWPOWER)
755/* hiddev */
756COMPATIBLE_IOCTL(HIDIOCGVERSION)
757COMPATIBLE_IOCTL(HIDIOCAPPLICATION)
758COMPATIBLE_IOCTL(HIDIOCGDEVINFO)
759COMPATIBLE_IOCTL(HIDIOCGSTRING)
760COMPATIBLE_IOCTL(HIDIOCINITREPORT)
761COMPATIBLE_IOCTL(HIDIOCGREPORT)
762COMPATIBLE_IOCTL(HIDIOCSREPORT)
763COMPATIBLE_IOCTL(HIDIOCGREPORTINFO)
764COMPATIBLE_IOCTL(HIDIOCGFIELDINFO)
765COMPATIBLE_IOCTL(HIDIOCGUSAGE)
766COMPATIBLE_IOCTL(HIDIOCSUSAGE)
767COMPATIBLE_IOCTL(HIDIOCGUCODE)
768COMPATIBLE_IOCTL(HIDIOCGFLAG)
769COMPATIBLE_IOCTL(HIDIOCSFLAG)
770COMPATIBLE_IOCTL(HIDIOCGCOLLECTIONINDEX)
771COMPATIBLE_IOCTL(HIDIOCGCOLLECTIONINFO)
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
new file mode 100644
index 000000000000..152734055403
--- /dev/null
+++ b/include/linux/compiler-gcc.h
@@ -0,0 +1,17 @@
1/* Never include this file directly. Include <linux/compiler.h> instead. */
2
3/*
4 * Common definitions for all gcc versions go here.
5 */
6
7
8/* Optimization barrier */
9/* The "volatile" is due to gcc bugs */
10#define barrier() __asm__ __volatile__("": : :"memory")
11
12/* This macro obfuscates arithmetic on a variable address so that gcc
13 shouldn't recognize the original var, and make assumptions about it */
14#define RELOC_HIDE(ptr, off) \
15 ({ unsigned long __ptr; \
16 __asm__ ("" : "=g"(__ptr) : "0"(ptr)); \
17 (typeof(ptr)) (__ptr + (off)); })
diff --git a/include/linux/compiler-gcc2.h b/include/linux/compiler-gcc2.h
new file mode 100644
index 000000000000..5a359153ffd9
--- /dev/null
+++ b/include/linux/compiler-gcc2.h
@@ -0,0 +1,24 @@
1/* Never include this file directly. Include <linux/compiler.h> instead. */
2
3/* These definitions are for GCC v2.x. */
4
5/* Somewhere in the middle of the GCC 2.96 development cycle, we implemented
6 a mechanism by which the user can annotate likely branch directions and
7 expect the blocks to be reordered appropriately. Define __builtin_expect
8 to nothing for earlier compilers. */
9#include <linux/compiler-gcc.h>
10
11#if __GNUC_MINOR__ < 96
12# define __builtin_expect(x, expected_value) (x)
13#endif
14
15#define __attribute_used__ __attribute__((__unused__))
16
17/*
18 * The attribute `pure' is not implemented in GCC versions earlier
19 * than 2.96.
20 */
21#if __GNUC_MINOR__ >= 96
22# define __attribute_pure__ __attribute__((pure))
23# define __attribute_const__ __attribute__((__const__))
24#endif
diff --git a/include/linux/compiler-gcc3.h b/include/linux/compiler-gcc3.h
new file mode 100644
index 000000000000..a6fa615afab5
--- /dev/null
+++ b/include/linux/compiler-gcc3.h
@@ -0,0 +1,32 @@
1/* Never include this file directly. Include <linux/compiler.h> instead. */
2
3/* These definitions are for GCC v3.x. */
4#include <linux/compiler-gcc.h>
5
6#if __GNUC_MINOR__ >= 1
7# define inline inline __attribute__((always_inline))
8# define __inline__ __inline__ __attribute__((always_inline))
9# define __inline __inline __attribute__((always_inline))
10#endif
11
12#if __GNUC_MINOR__ > 0
13# define __deprecated __attribute__((deprecated))
14#endif
15
16#if __GNUC_MINOR__ >= 3
17# define __attribute_used__ __attribute__((__used__))
18#else
19# define __attribute_used__ __attribute__((__unused__))
20#endif
21
22#define __attribute_pure__ __attribute__((pure))
23#define __attribute_const__ __attribute__((__const__))
24
25#if __GNUC_MINOR__ >= 1
26#define noinline __attribute__((noinline))
27#endif
28
29#if __GNUC_MINOR__ >= 4
30#define __must_check __attribute__((warn_unused_result))
31#endif
32
diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
new file mode 100644
index 000000000000..53686c037a06
--- /dev/null
+++ b/include/linux/compiler-gcc4.h
@@ -0,0 +1,16 @@
1/* Never include this file directly. Include <linux/compiler.h> instead. */
2
3/* These definitions are for GCC v4.x. */
4#include <linux/compiler-gcc.h>
5
6#define inline inline __attribute__((always_inline))
7#define __inline__ __inline__ __attribute__((always_inline))
8#define __inline __inline __attribute__((always_inline))
9#define __deprecated __attribute__((deprecated))
10#define __attribute_used__ __attribute__((__used__))
11#define __attribute_pure__ __attribute__((pure))
12#define __attribute_const__ __attribute__((__const__))
13#define noinline __attribute__((noinline))
14#define __must_check __attribute__((warn_unused_result))
15#define __compiler_offsetof(a,b) __builtin_offsetof(a,b)
16
diff --git a/include/linux/compiler-intel.h b/include/linux/compiler-intel.h
new file mode 100644
index 000000000000..1d1c3ceaff4e
--- /dev/null
+++ b/include/linux/compiler-intel.h
@@ -0,0 +1,24 @@
1/* Never include this file directly. Include <linux/compiler.h> instead. */
2
3#ifdef __ECC
4
5/* Some compiler specific definitions are overwritten here
6 * for Intel ECC compiler
7 */
8
9#include <asm/intrinsics.h>
10
11/* Intel ECC compiler doesn't support gcc specific asm stmts.
12 * It uses intrinsics to do the equivalent things.
13 */
14#undef barrier
15#undef RELOC_HIDE
16
17#define barrier() __memory_barrier()
18
19#define RELOC_HIDE(ptr, off) \
20 ({ unsigned long __ptr; \
21 __ptr = (unsigned long) (ptr); \
22 (typeof(ptr)) (__ptr + (off)); })
23
24#endif
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
new file mode 100644
index 000000000000..487725cf0d0d
--- /dev/null
+++ b/include/linux/compiler.h
@@ -0,0 +1,152 @@
1#ifndef __LINUX_COMPILER_H
2#define __LINUX_COMPILER_H
3
4#ifndef __ASSEMBLY__
5
6#ifdef __CHECKER__
7# define __user __attribute__((noderef, address_space(1)))
8# define __kernel /* default address space */
9# define __safe __attribute__((safe))
10# define __force __attribute__((force))
11# define __nocast __attribute__((nocast))
12# define __iomem __attribute__((noderef, address_space(2)))
13# define __acquires(x) __attribute__((context(0,1)))
14# define __releases(x) __attribute__((context(1,0)))
15# define __acquire(x) __context__(1)
16# define __release(x) __context__(-1)
17# define __cond_lock(x) ((x) ? ({ __context__(1); 1; }) : 0)
18extern void __chk_user_ptr(void __user *);
19extern void __chk_io_ptr(void __iomem *);
20#else
21# define __user
22# define __kernel
23# define __safe
24# define __force
25# define __nocast
26# define __iomem
27# define __chk_user_ptr(x) (void)0
28# define __chk_io_ptr(x) (void)0
29# define __builtin_warning(x, y...) (1)
30# define __acquires(x)
31# define __releases(x)
32# define __acquire(x) (void)0
33# define __release(x) (void)0
34# define __cond_lock(x) (x)
35#endif
36
37#ifdef __KERNEL__
38
39#if __GNUC__ > 4
40#error no compiler-gcc.h file for this gcc version
41#elif __GNUC__ == 4
42# include <linux/compiler-gcc4.h>
43#elif __GNUC__ == 3
44# include <linux/compiler-gcc3.h>
45#elif __GNUC__ == 2
46# include <linux/compiler-gcc2.h>
47#else
48# error Sorry, your compiler is too old/not recognized.
49#endif
50
51/* Intel compiler defines __GNUC__. So we will overwrite implementations
52 * coming from above header files here
53 */
54#ifdef __INTEL_COMPILER
55# include <linux/compiler-intel.h>
56#endif
57
58/*
59 * Generic compiler-dependent macros required for kernel
60 * build go below this comment. Actual compiler/compiler version
61 * specific implementations come from the above header files
62 */
63
64#define likely(x) __builtin_expect(!!(x), 1)
65#define unlikely(x) __builtin_expect(!!(x), 0)
66
67/* Optimization barrier */
68#ifndef barrier
69# define barrier() __memory_barrier()
70#endif
71
72#ifndef RELOC_HIDE
73# define RELOC_HIDE(ptr, off) \
74 ({ unsigned long __ptr; \
75 __ptr = (unsigned long) (ptr); \
76 (typeof(ptr)) (__ptr + (off)); })
77#endif
78
79#endif /* __KERNEL__ */
80
81#endif /* __ASSEMBLY__ */
82
83/*
84 * Allow us to mark functions as 'deprecated' and have gcc emit a nice
85 * warning for each use, in hopes of speeding the functions removal.
86 * Usage is:
87 * int __deprecated foo(void)
88 */
89#ifndef __deprecated
90# define __deprecated /* unimplemented */
91#endif
92
93#ifndef __must_check
94#define __must_check
95#endif
96
97/*
98 * Allow us to avoid 'defined but not used' warnings on functions and data,
99 * as well as force them to be emitted to the assembly file.
100 *
101 * As of gcc 3.3, static functions that are not marked with attribute((used))
102 * may be elided from the assembly file. As of gcc 3.3, static data not so
103 * marked will not be elided, but this may change in a future gcc version.
104 *
105 * In prior versions of gcc, such functions and data would be emitted, but
106 * would be warned about except with attribute((unused)).
107 */
108#ifndef __attribute_used__
109# define __attribute_used__ /* unimplemented */
110#endif
111
112/*
113 * From the GCC manual:
114 *
115 * Many functions have no effects except the return value and their
116 * return value depends only on the parameters and/or global
117 * variables. Such a function can be subject to common subexpression
118 * elimination and loop optimization just as an arithmetic operator
119 * would be.
120 * [...]
121 */
122#ifndef __attribute_pure__
123# define __attribute_pure__ /* unimplemented */
124#endif
125
126/*
127 * From the GCC manual:
128 *
129 * Many functions do not examine any values except their arguments,
130 * and have no effects except the return value. Basically this is
131 * just slightly more strict class than the `pure' attribute above,
132 * since function is not allowed to read global memory.
133 *
134 * Note that a function that has pointer arguments and examines the
135 * data pointed to must _not_ be declared `const'. Likewise, a
136 * function that calls a non-`const' function usually must not be
137 * `const'. It does not make sense for a `const' function to return
138 * `void'.
139 */
140#ifndef __attribute_const__
141# define __attribute_const__ /* unimplemented */
142#endif
143
144#ifndef noinline
145#define noinline
146#endif
147
148#ifndef __always_inline
149#define __always_inline inline
150#endif
151
152#endif /* __LINUX_COMPILER_H */
diff --git a/include/linux/completion.h b/include/linux/completion.h
new file mode 100644
index 000000000000..90663ad217f9
--- /dev/null
+++ b/include/linux/completion.h
@@ -0,0 +1,42 @@
1#ifndef __LINUX_COMPLETION_H
2#define __LINUX_COMPLETION_H
3
4/*
5 * (C) Copyright 2001 Linus Torvalds
6 *
7 * Atomic wait-for-completion handler data structures.
8 * See kernel/sched.c for details.
9 */
10
11#include <linux/wait.h>
12
13struct completion {
14 unsigned int done;
15 wait_queue_head_t wait;
16};
17
18#define COMPLETION_INITIALIZER(work) \
19 { 0, __WAIT_QUEUE_HEAD_INITIALIZER((work).wait) }
20
21#define DECLARE_COMPLETION(work) \
22 struct completion work = COMPLETION_INITIALIZER(work)
23
24static inline void init_completion(struct completion *x)
25{
26 x->done = 0;
27 init_waitqueue_head(&x->wait);
28}
29
30extern void FASTCALL(wait_for_completion(struct completion *));
31extern int FASTCALL(wait_for_completion_interruptible(struct completion *x));
32extern unsigned long FASTCALL(wait_for_completion_timeout(struct completion *x,
33 unsigned long timeout));
34extern unsigned long FASTCALL(wait_for_completion_interruptible_timeout(
35 struct completion *x, unsigned long timeout));
36
37extern void FASTCALL(complete(struct completion *));
38extern void FASTCALL(complete_all(struct completion *));
39
40#define INIT_COMPLETION(x) ((x).done = 0)
41
42#endif
diff --git a/include/linux/comstats.h b/include/linux/comstats.h
new file mode 100644
index 000000000000..3f5ea8e8026d
--- /dev/null
+++ b/include/linux/comstats.h
@@ -0,0 +1,119 @@
1/*****************************************************************************/
2
3/*
4 * comstats.h -- Serial Port Stats.
5 *
6 * Copyright (C) 1996-1998 Stallion Technologies
7 * Copyright (C) 1994-1996 Greg Ungerer.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24/*****************************************************************************/
25#ifndef _COMSTATS_H
26#define _COMSTATS_H
27/*****************************************************************************/
28
29/*
30 * Serial port stats structure. The structure itself is UART
31 * independent, but some fields may be UART/driver specific (for
32 * example state).
33 */
34
35typedef struct {
36 unsigned long brd;
37 unsigned long panel;
38 unsigned long port;
39 unsigned long hwid;
40 unsigned long type;
41 unsigned long txtotal;
42 unsigned long rxtotal;
43 unsigned long txbuffered;
44 unsigned long rxbuffered;
45 unsigned long rxoverrun;
46 unsigned long rxparity;
47 unsigned long rxframing;
48 unsigned long rxlost;
49 unsigned long txbreaks;
50 unsigned long rxbreaks;
51 unsigned long txxon;
52 unsigned long txxoff;
53 unsigned long rxxon;
54 unsigned long rxxoff;
55 unsigned long txctson;
56 unsigned long txctsoff;
57 unsigned long rxrtson;
58 unsigned long rxrtsoff;
59 unsigned long modem;
60 unsigned long state;
61 unsigned long flags;
62 unsigned long ttystate;
63 unsigned long cflags;
64 unsigned long iflags;
65 unsigned long oflags;
66 unsigned long lflags;
67 unsigned long signals;
68} comstats_t;
69
70
71/*
72 * Board stats structure. Returns useful info about the board.
73 */
74
75#define COM_MAXPANELS 8
76
77typedef struct {
78 unsigned long panel;
79 unsigned long type;
80 unsigned long hwid;
81 unsigned long nrports;
82} companel_t;
83
84typedef struct {
85 unsigned long brd;
86 unsigned long type;
87 unsigned long hwid;
88 unsigned long state;
89 unsigned long ioaddr;
90 unsigned long ioaddr2;
91 unsigned long memaddr;
92 unsigned long irq;
93 unsigned long nrpanels;
94 unsigned long nrports;
95 companel_t panels[COM_MAXPANELS];
96} combrd_t;
97
98
99/*
100 * Define the ioctl operations for stats stuff.
101 */
102#include <linux/ioctl.h>
103
104#define COM_GETPORTSTATS _IO('c',30)
105#define COM_CLRPORTSTATS _IO('c',31)
106#define COM_GETBRDSTATS _IO('c',32)
107
108
109/*
110 * Define the set of ioctls that give user level access to the
111 * private port, panel and board structures. The argument required
112 * will be driver dependent!
113 */
114#define COM_READPORT _IO('c',40)
115#define COM_READBOARD _IO('c',41)
116#define COM_READPANEL _IO('c',42)
117
118/*****************************************************************************/
119#endif
diff --git a/include/linux/concap.h b/include/linux/concap.h
new file mode 100644
index 000000000000..27304651d700
--- /dev/null
+++ b/include/linux/concap.h
@@ -0,0 +1,113 @@
1/* $Id: concap.h,v 1.3.2.2 2004/01/12 23:08:35 keil Exp $
2 *
3 * Copyright 1997 by Henner Eisen <eis@baty.hanse.de>
4 *
5 * This software may be used and distributed according to the terms
6 * of the GNU General Public License, incorporated herein by reference.
7 */
8
9#ifndef _LINUX_CONCAP_H
10#define _LINUX_CONCAP_H
11#ifdef __KERNEL__
12#include <linux/skbuff.h>
13#include <linux/netdevice.h>
14
15/* Stuff to support encapsulation protocols genericly. The encapsulation
16 protocol is processed at the uppermost layer of the network interface.
17
18 Based on a ideas developed in a 'synchronous device' thread in the
19 linux-x25 mailing list contributed by Alan Cox, Thomasz Motylewski
20 and Jonathan Naylor.
21
22 For more documetation on this refer to Documentation/isdn/README.concap
23*/
24
25struct concap_proto_ops;
26struct concap_device_ops;
27
28/* this manages all data needed by the encapsulation protocol
29 */
30struct concap_proto{
31 struct net_device *net_dev; /* net device using our service */
32 struct concap_device_ops *dops; /* callbacks provided by device */
33 struct concap_proto_ops *pops; /* callbacks provided by us */
34 spinlock_t lock;
35 int flags;
36 void *proto_data; /* protocol specific private data, to
37 be accessed via *pops methods only*/
38 /*
39 :
40 whatever
41 :
42 */
43};
44
45/* Operations to be supported by the net device. Called by the encapsulation
46 * protocol entity. No receive method is offered because the encapsulation
47 * protocol directly calls netif_rx().
48 */
49struct concap_device_ops{
50
51 /* to request data is submitted by device*/
52 int (*data_req)(struct concap_proto *, struct sk_buff *);
53
54 /* Control methods must be set to NULL by devices which do not
55 support connection control.*/
56 /* to request a connection is set up */
57 int (*connect_req)(struct concap_proto *);
58
59 /* to request a connection is released */
60 int (*disconn_req)(struct concap_proto *);
61};
62
63/* Operations to be supported by the encapsulation protocol. Called by
64 * device driver.
65 */
66struct concap_proto_ops{
67
68 /* create a new encapsulation protocol instance of same type */
69 struct concap_proto * (*proto_new) (void);
70
71 /* delete encapsulation protocol instance and free all its resources.
72 cprot may no loger be referenced after calling this */
73 void (*proto_del)(struct concap_proto *cprot);
74
75 /* initialize the protocol's data. To be called at interface startup
76 or when the device driver resets the interface. All services of the
77 encapsulation protocol may be used after this*/
78 int (*restart)(struct concap_proto *cprot,
79 struct net_device *ndev,
80 struct concap_device_ops *dops);
81
82 /* inactivate an encapsulation protocol instance. The encapsulation
83 protocol may not call any *dops methods after this. */
84 int (*close)(struct concap_proto *cprot);
85
86 /* process a frame handed down to us by upper layer */
87 int (*encap_and_xmit)(struct concap_proto *cprot, struct sk_buff *skb);
88
89 /* to be called for each data entity received from lower layer*/
90 int (*data_ind)(struct concap_proto *cprot, struct sk_buff *skb);
91
92 /* to be called when a connection was set up/down.
93 Protocols that don't process these primitives might fill in
94 dummy methods here */
95 int (*connect_ind)(struct concap_proto *cprot);
96 int (*disconn_ind)(struct concap_proto *cprot);
97 /*
98 Some network device support functions, like net_header(), rebuild_header(),
99 and others, that depend solely on the encapsulation protocol, might
100 be provided here, too. The net device would just fill them in its
101 corresponding fields when it is opened.
102 */
103};
104
105/* dummy restart/close/connect/reset/disconn methods
106 */
107extern int concap_nop(struct concap_proto *cprot);
108
109/* dummy submit method
110 */
111extern int concap_drop_skb(struct concap_proto *cprot, struct sk_buff *skb);
112#endif
113#endif
diff --git a/include/linux/config.h b/include/linux/config.h
new file mode 100644
index 000000000000..9d1c14f7ad6d
--- /dev/null
+++ b/include/linux/config.h
@@ -0,0 +1,6 @@
1#ifndef _LINUX_CONFIG_H
2#define _LINUX_CONFIG_H
3
4#include <linux/autoconf.h>
5
6#endif
diff --git a/include/linux/console.h b/include/linux/console.h
new file mode 100644
index 000000000000..721371382ae5
--- /dev/null
+++ b/include/linux/console.h
@@ -0,0 +1,133 @@
1/*
2 * linux/include/linux/console.h
3 *
4 * Copyright (C) 1993 Hamish Macdonald
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 * Changed:
11 * 10-Mar-94: Arno Griffioen: Conversion for vt100 emulator port from PC LINUX
12 */
13
14#ifndef _LINUX_CONSOLE_H_
15#define _LINUX_CONSOLE_H_ 1
16
17#include <linux/types.h>
18#include <linux/spinlock.h>
19
20struct vc_data;
21struct console_font_op;
22struct console_font;
23struct module;
24
25/*
26 * this is what the terminal answers to a ESC-Z or csi0c query.
27 */
28#define VT100ID "\033[?1;2c"
29#define VT102ID "\033[?6c"
30
31struct consw {
32 struct module *owner;
33 const char *(*con_startup)(void);
34 void (*con_init)(struct vc_data *, int);
35 void (*con_deinit)(struct vc_data *);
36 void (*con_clear)(struct vc_data *, int, int, int, int);
37 void (*con_putc)(struct vc_data *, int, int, int);
38 void (*con_putcs)(struct vc_data *, const unsigned short *, int, int, int);
39 void (*con_cursor)(struct vc_data *, int);
40 int (*con_scroll)(struct vc_data *, int, int, int, int);
41 void (*con_bmove)(struct vc_data *, int, int, int, int, int, int);
42 int (*con_switch)(struct vc_data *);
43 int (*con_blank)(struct vc_data *, int, int);
44 int (*con_font_set)(struct vc_data *, struct console_font *, unsigned);
45 int (*con_font_get)(struct vc_data *, struct console_font *);
46 int (*con_font_default)(struct vc_data *, struct console_font *, char *);
47 int (*con_font_copy)(struct vc_data *, int);
48 int (*con_resize)(struct vc_data *, unsigned int, unsigned int);
49 int (*con_set_palette)(struct vc_data *, unsigned char *);
50 int (*con_scrolldelta)(struct vc_data *, int);
51 int (*con_set_origin)(struct vc_data *);
52 void (*con_save_screen)(struct vc_data *);
53 u8 (*con_build_attr)(struct vc_data *, u8, u8, u8, u8, u8);
54 void (*con_invert_region)(struct vc_data *, u16 *, int);
55 u16 *(*con_screen_pos)(struct vc_data *, int);
56 unsigned long (*con_getxy)(struct vc_data *, unsigned long, int *, int *);
57};
58
59extern const struct consw *conswitchp;
60
61extern const struct consw dummy_con; /* dummy console buffer */
62extern const struct consw vga_con; /* VGA text console */
63extern const struct consw newport_con; /* SGI Newport console */
64extern const struct consw prom_con; /* SPARC PROM console */
65
66int take_over_console(const struct consw *sw, int first, int last, int deflt);
67void give_up_console(const struct consw *sw);
68
69/* scroll */
70#define SM_UP (1)
71#define SM_DOWN (2)
72
73/* cursor */
74#define CM_DRAW (1)
75#define CM_ERASE (2)
76#define CM_MOVE (3)
77
78/*
79 * The interface for a console, or any other device that wants to capture
80 * console messages (printer driver?)
81 *
82 * If a console driver is marked CON_BOOT then it will be auto-unregistered
83 * when the first real console is registered. This is for early-printk drivers.
84 */
85
86#define CON_PRINTBUFFER (1)
87#define CON_CONSDEV (2) /* Last on the command line */
88#define CON_ENABLED (4)
89#define CON_BOOT (8)
90
91struct console
92{
93 char name[8];
94 void (*write)(struct console *, const char *, unsigned);
95 int (*read)(struct console *, char *, unsigned);
96 struct tty_driver *(*device)(struct console *, int *);
97 void (*unblank)(void);
98 int (*setup)(struct console *, char *);
99 short flags;
100 short index;
101 int cflag;
102 void *data;
103 struct console *next;
104};
105
106extern int add_preferred_console(char *name, int idx, char *options);
107extern void register_console(struct console *);
108extern int unregister_console(struct console *);
109extern struct console *console_drivers;
110extern void acquire_console_sem(void);
111extern int try_acquire_console_sem(void);
112extern void release_console_sem(void);
113extern void console_conditional_schedule(void);
114extern void console_unblank(void);
115extern struct tty_driver *console_device(int *);
116extern void console_stop(struct console *);
117extern void console_start(struct console *);
118extern int is_console_locked(void);
119
120/* Some debug stub to catch some of the obvious races in the VT code */
121#if 1
122#define WARN_CONSOLE_UNLOCKED() WARN_ON(!is_console_locked() && !oops_in_progress)
123#else
124#define WARN_CONSOLE_UNLOCKED()
125#endif
126
127/* VESA Blanking Levels */
128#define VESA_NO_BLANKING 0
129#define VESA_VSYNC_SUSPEND 1
130#define VESA_HSYNC_SUSPEND 2
131#define VESA_POWERDOWN 3
132
133#endif /* _LINUX_CONSOLE_H */
diff --git a/include/linux/console_struct.h b/include/linux/console_struct.h
new file mode 100644
index 000000000000..725be90ef55e
--- /dev/null
+++ b/include/linux/console_struct.h
@@ -0,0 +1,123 @@
1/*
2 * console_struct.h
3 *
4 * Data structure describing single virtual console except for data
5 * used by vt.c.
6 *
7 * Fields marked with [#] must be set by the low-level driver.
8 * Fields marked with [!] can be changed by the low-level driver
9 * to achieve effects such as fast scrolling by changing the origin.
10 */
11
12struct vt_struct;
13
14#define NPAR 16
15
16struct vc_data {
17 unsigned short vc_num; /* Console number */
18 unsigned int vc_cols; /* [#] Console size */
19 unsigned int vc_rows;
20 unsigned int vc_size_row; /* Bytes per row */
21 unsigned int vc_scan_lines; /* # of scan lines */
22 unsigned long vc_origin; /* [!] Start of real screen */
23 unsigned long vc_scr_end; /* [!] End of real screen */
24 unsigned long vc_visible_origin; /* [!] Top of visible window */
25 unsigned int vc_top, vc_bottom; /* Scrolling region */
26 const struct consw *vc_sw;
27 unsigned short *vc_screenbuf; /* In-memory character/attribute buffer */
28 unsigned int vc_screenbuf_size;
29 unsigned char vc_mode; /* KD_TEXT, ... */
30 /* attributes for all characters on screen */
31 unsigned char vc_attr; /* Current attributes */
32 unsigned char vc_def_color; /* Default colors */
33 unsigned char vc_color; /* Foreground & background */
34 unsigned char vc_s_color; /* Saved foreground & background */
35 unsigned char vc_ulcolor; /* Color for underline mode */
36 unsigned char vc_halfcolor; /* Color for half intensity mode */
37 /* cursor */
38 unsigned int vc_cursor_type;
39 unsigned short vc_complement_mask; /* [#] Xor mask for mouse pointer */
40 unsigned short vc_s_complement_mask; /* Saved mouse pointer mask */
41 unsigned int vc_x, vc_y; /* Cursor position */
42 unsigned int vc_saved_x, vc_saved_y;
43 unsigned long vc_pos; /* Cursor address */
44 /* fonts */
45 unsigned short vc_hi_font_mask; /* [#] Attribute set for upper 256 chars of font or 0 if not supported */
46 struct console_font vc_font; /* Current VC font set */
47 unsigned short vc_video_erase_char; /* Background erase character */
48 /* VT terminal data */
49 unsigned int vc_state; /* Escape sequence parser state */
50 unsigned int vc_npar,vc_par[NPAR]; /* Parameters of current escape sequence */
51 struct tty_struct *vc_tty; /* TTY we are attached to */
52 /* data for manual vt switching */
53 struct vt_mode vt_mode;
54 int vt_pid;
55 int vt_newvt;
56 wait_queue_head_t paste_wait;
57 /* mode flags */
58 unsigned int vc_charset : 1; /* Character set G0 / G1 */
59 unsigned int vc_s_charset : 1; /* Saved character set */
60 unsigned int vc_disp_ctrl : 1; /* Display chars < 32? */
61 unsigned int vc_toggle_meta : 1; /* Toggle high bit? */
62 unsigned int vc_decscnm : 1; /* Screen Mode */
63 unsigned int vc_decom : 1; /* Origin Mode */
64 unsigned int vc_decawm : 1; /* Autowrap Mode */
65 unsigned int vc_deccm : 1; /* Cursor Visible */
66 unsigned int vc_decim : 1; /* Insert Mode */
67 unsigned int vc_deccolm : 1; /* 80/132 Column Mode */
68 /* attribute flags */
69 unsigned int vc_intensity : 2; /* 0=half-bright, 1=normal, 2=bold */
70 unsigned int vc_underline : 1;
71 unsigned int vc_blink : 1;
72 unsigned int vc_reverse : 1;
73 unsigned int vc_s_intensity : 2; /* saved rendition */
74 unsigned int vc_s_underline : 1;
75 unsigned int vc_s_blink : 1;
76 unsigned int vc_s_reverse : 1;
77 /* misc */
78 unsigned int vc_ques : 1;
79 unsigned int vc_need_wrap : 1;
80 unsigned int vc_can_do_color : 1;
81 unsigned int vc_report_mouse : 2;
82 unsigned int vc_kmalloced : 1;
83 unsigned char vc_utf : 1; /* Unicode UTF-8 encoding */
84 unsigned char vc_utf_count;
85 int vc_utf_char;
86 unsigned int vc_tab_stop[8]; /* Tab stops. 256 columns. */
87 unsigned char vc_palette[16*3]; /* Colour palette for VGA+ */
88 unsigned short * vc_translate;
89 unsigned char vc_G0_charset;
90 unsigned char vc_G1_charset;
91 unsigned char vc_saved_G0;
92 unsigned char vc_saved_G1;
93 unsigned int vc_bell_pitch; /* Console bell pitch */
94 unsigned int vc_bell_duration; /* Console bell duration */
95 struct vc_data **vc_display_fg; /* [!] Ptr to var holding fg console for this display */
96 unsigned long vc_uni_pagedir;
97 unsigned long *vc_uni_pagedir_loc; /* [!] Location of uni_pagedir variable for this console */
98 /* additional information is in vt_kern.h */
99};
100
101struct vc {
102 struct vc_data *d;
103
104 /* might add scrmem, vt_struct, kbd at some time,
105 to have everything in one place - the disadvantage
106 would be that vc_cons etc can no longer be static */
107};
108
109extern struct vc vc_cons [MAX_NR_CONSOLES];
110
111#define CUR_DEF 0
112#define CUR_NONE 1
113#define CUR_UNDERLINE 2
114#define CUR_LOWER_THIRD 3
115#define CUR_LOWER_HALF 4
116#define CUR_TWO_THIRDS 5
117#define CUR_BLOCK 6
118#define CUR_HWMASK 0x0f
119#define CUR_SWMASK 0xfff0
120
121#define CUR_DEFAULT CUR_UNDERLINE
122
123#define CON_IS_VISIBLE(conp) (*conp->vc_display_fg == conp)
diff --git a/include/linux/consolemap.h b/include/linux/consolemap.h
new file mode 100644
index 000000000000..65842efc1b70
--- /dev/null
+++ b/include/linux/consolemap.h
@@ -0,0 +1,15 @@
1/*
2 * consolemap.h
3 *
4 * Interface between console.c, selection.c and consolemap.c
5 */
6#define LAT1_MAP 0
7#define GRAF_MAP 1
8#define IBMPC_MAP 2
9#define USER_MAP 3
10
11struct vc_data;
12
13extern unsigned char inverse_translate(struct vc_data *conp, int glyph);
14extern unsigned short *set_translate(int m, struct vc_data *vc);
15extern int conv_uni_to_pc(struct vc_data *conp, long ucs);
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
new file mode 100644
index 000000000000..fe0298e5dae1
--- /dev/null
+++ b/include/linux/cpu.h
@@ -0,0 +1,83 @@
1/*
2 * include/linux/cpu.h - generic cpu definition
3 *
4 * This is mainly for topological representation. We define the
5 * basic 'struct cpu' here, which can be embedded in per-arch
6 * definitions of processors.
7 *
8 * Basic handling of the devices is done in drivers/base/cpu.c
9 * and system devices are handled in drivers/base/sys.c.
10 *
11 * CPUs are exported via driverfs in the class/cpu/devices/
12 * directory.
13 *
14 * Per-cpu interfaces can be implemented using a struct device_interface.
15 * See the following for how to do this:
16 * - drivers/base/intf.c
17 * - Documentation/driver-model/interface.txt
18 */
19#ifndef _LINUX_CPU_H_
20#define _LINUX_CPU_H_
21
22#include <linux/sysdev.h>
23#include <linux/node.h>
24#include <linux/compiler.h>
25#include <linux/cpumask.h>
26#include <asm/semaphore.h>
27
28struct cpu {
29 int node_id; /* The node which contains the CPU */
30 int no_control; /* Should the sysfs control file be created? */
31 struct sys_device sysdev;
32};
33
34extern int register_cpu(struct cpu *, int, struct node *);
35#ifdef CONFIG_HOTPLUG_CPU
36extern void unregister_cpu(struct cpu *, struct node *);
37#endif
38struct notifier_block;
39
40#ifdef CONFIG_SMP
41/* Need to know about CPUs going up/down? */
42extern int register_cpu_notifier(struct notifier_block *nb);
43extern void unregister_cpu_notifier(struct notifier_block *nb);
44
45int cpu_up(unsigned int cpu);
46
47#else
48
49static inline int register_cpu_notifier(struct notifier_block *nb)
50{
51 return 0;
52}
53static inline void unregister_cpu_notifier(struct notifier_block *nb)
54{
55}
56
57#endif /* CONFIG_SMP */
58extern struct sysdev_class cpu_sysdev_class;
59
60#ifdef CONFIG_HOTPLUG_CPU
61/* Stop CPUs going up and down. */
62extern struct semaphore cpucontrol;
63#define lock_cpu_hotplug() down(&cpucontrol)
64#define unlock_cpu_hotplug() up(&cpucontrol)
65#define lock_cpu_hotplug_interruptible() down_interruptible(&cpucontrol)
66#define hotcpu_notifier(fn, pri) { \
67 static struct notifier_block fn##_nb = \
68 { .notifier_call = fn, .priority = pri }; \
69 register_cpu_notifier(&fn##_nb); \
70}
71int cpu_down(unsigned int cpu);
72#define cpu_is_offline(cpu) unlikely(!cpu_online(cpu))
73#else
74#define lock_cpu_hotplug() do { } while (0)
75#define unlock_cpu_hotplug() do { } while (0)
76#define lock_cpu_hotplug_interruptible() 0
77#define hotcpu_notifier(fn, pri)
78
79/* CPUs don't go offline once they're online w/o CONFIG_HOTPLUG_CPU */
80static inline int cpu_is_offline(int cpu) { return 0; }
81#endif
82
83#endif /* _LINUX_CPU_H_ */
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
new file mode 100644
index 000000000000..910eca35583d
--- /dev/null
+++ b/include/linux/cpufreq.h
@@ -0,0 +1,328 @@
1/*
2 * linux/include/linux/cpufreq.h
3 *
4 * Copyright (C) 2001 Russell King
5 * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de>
6 *
7 *
8 * $Id: cpufreq.h,v 1.36 2003/01/20 17:31:48 db Exp $
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 version 2 as
12 * published by the Free Software Foundation.
13 */
14#ifndef _LINUX_CPUFREQ_H
15#define _LINUX_CPUFREQ_H
16
17#include <linux/config.h>
18#include <linux/notifier.h>
19#include <linux/threads.h>
20#include <linux/device.h>
21#include <linux/kobject.h>
22#include <linux/sysfs.h>
23#include <linux/completion.h>
24#include <linux/workqueue.h>
25#include <linux/cpumask.h>
26
27#define CPUFREQ_NAME_LEN 16
28
29
30/*********************************************************************
31 * CPUFREQ NOTIFIER INTERFACE *
32 *********************************************************************/
33
34int cpufreq_register_notifier(struct notifier_block *nb, unsigned int list);
35int cpufreq_unregister_notifier(struct notifier_block *nb, unsigned int list);
36
37#define CPUFREQ_TRANSITION_NOTIFIER (0)
38#define CPUFREQ_POLICY_NOTIFIER (1)
39
40
41/* if (cpufreq_driver->target) exists, the ->governor decides what frequency
42 * within the limits is used. If (cpufreq_driver->setpolicy> exists, these
43 * two generic policies are available:
44 */
45
46#define CPUFREQ_POLICY_POWERSAVE (1)
47#define CPUFREQ_POLICY_PERFORMANCE (2)
48
49/* Frequency values here are CPU kHz so that hardware which doesn't run
50 * with some frequencies can complain without having to guess what per
51 * cent / per mille means.
52 * Maximum transition latency is in microseconds - if it's unknown,
53 * CPUFREQ_ETERNAL shall be used.
54 */
55
56struct cpufreq_governor;
57
58#define CPUFREQ_ETERNAL (-1)
59struct cpufreq_cpuinfo {
60 unsigned int max_freq;
61 unsigned int min_freq;
62 unsigned int transition_latency; /* in 10^(-9) s = nanoseconds */
63};
64
65struct cpufreq_real_policy {
66 unsigned int min; /* in kHz */
67 unsigned int max; /* in kHz */
68 unsigned int policy; /* see above */
69 struct cpufreq_governor *governor; /* see below */
70};
71
72struct cpufreq_policy {
73 cpumask_t cpus; /* affected CPUs */
74 unsigned int cpu; /* cpu nr of registered CPU */
75 struct cpufreq_cpuinfo cpuinfo;/* see above */
76
77 unsigned int min; /* in kHz */
78 unsigned int max; /* in kHz */
79 unsigned int cur; /* in kHz, only needed if cpufreq
80 * governors are used */
81 unsigned int policy; /* see above */
82 struct cpufreq_governor *governor; /* see below */
83
84 struct semaphore lock; /* CPU ->setpolicy or ->target may
85 only be called once a time */
86
87 struct work_struct update; /* if update_policy() needs to be
88 * called, but you're in IRQ context */
89
90 struct cpufreq_real_policy user_policy;
91
92 struct kobject kobj;
93 struct completion kobj_unregister;
94};
95
96#define CPUFREQ_ADJUST (0)
97#define CPUFREQ_INCOMPATIBLE (1)
98#define CPUFREQ_NOTIFY (2)
99
100
101/******************** cpufreq transition notifiers *******************/
102
103#define CPUFREQ_PRECHANGE (0)
104#define CPUFREQ_POSTCHANGE (1)
105#define CPUFREQ_RESUMECHANGE (8)
106
107struct cpufreq_freqs {
108 unsigned int cpu; /* cpu nr */
109 unsigned int old;
110 unsigned int new;
111 u8 flags; /* flags of cpufreq_driver, see below. */
112};
113
114
115/**
116 * cpufreq_scale - "old * mult / div" calculation for large values (32-bit-arch safe)
117 * @old: old value
118 * @div: divisor
119 * @mult: multiplier
120 *
121 *
122 * new = old * mult / div
123 */
124static inline unsigned long cpufreq_scale(unsigned long old, u_int div, u_int mult)
125{
126#if BITS_PER_LONG == 32
127
128 u64 result = ((u64) old) * ((u64) mult);
129 do_div(result, div);
130 return (unsigned long) result;
131
132#elif BITS_PER_LONG == 64
133
134 unsigned long result = old * ((u64) mult);
135 result /= div;
136 return result;
137
138#endif
139};
140
141/*********************************************************************
142 * CPUFREQ GOVERNORS *
143 *********************************************************************/
144
145#define CPUFREQ_GOV_START 1
146#define CPUFREQ_GOV_STOP 2
147#define CPUFREQ_GOV_LIMITS 3
148
149struct cpufreq_governor {
150 char name[CPUFREQ_NAME_LEN];
151 int (*governor) (struct cpufreq_policy *policy,
152 unsigned int event);
153 struct list_head governor_list;
154 struct module *owner;
155};
156
157/* pass a target to the cpufreq driver
158 */
159extern int cpufreq_driver_target(struct cpufreq_policy *policy,
160 unsigned int target_freq,
161 unsigned int relation);
162extern int __cpufreq_driver_target(struct cpufreq_policy *policy,
163 unsigned int target_freq,
164 unsigned int relation);
165
166
167/* pass an event to the cpufreq governor */
168int cpufreq_governor(unsigned int cpu, unsigned int event);
169
170int cpufreq_register_governor(struct cpufreq_governor *governor);
171void cpufreq_unregister_governor(struct cpufreq_governor *governor);
172
173
174/*********************************************************************
175 * CPUFREQ DRIVER INTERFACE *
176 *********************************************************************/
177
178#define CPUFREQ_RELATION_L 0 /* lowest frequency at or above target */
179#define CPUFREQ_RELATION_H 1 /* highest frequency below or at target */
180
181struct freq_attr;
182
183struct cpufreq_driver {
184 struct module *owner;
185 char name[CPUFREQ_NAME_LEN];
186 u8 flags;
187
188 /* needed by all drivers */
189 int (*init) (struct cpufreq_policy *policy);
190 int (*verify) (struct cpufreq_policy *policy);
191
192 /* define one out of two */
193 int (*setpolicy) (struct cpufreq_policy *policy);
194 int (*target) (struct cpufreq_policy *policy,
195 unsigned int target_freq,
196 unsigned int relation);
197
198 /* should be defined, if possible */
199 unsigned int (*get) (unsigned int cpu);
200
201 /* optional */
202 int (*exit) (struct cpufreq_policy *policy);
203 int (*resume) (struct cpufreq_policy *policy);
204 struct freq_attr **attr;
205};
206
207/* flags */
208
209#define CPUFREQ_STICKY 0x01 /* the driver isn't removed even if
210 * all ->init() calls failed */
211#define CPUFREQ_CONST_LOOPS 0x02 /* loops_per_jiffy or other kernel
212 * "constants" aren't affected by
213 * frequency transitions */
214
215
216int cpufreq_register_driver(struct cpufreq_driver *driver_data);
217int cpufreq_unregister_driver(struct cpufreq_driver *driver_data);
218
219
220void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state);
221
222
223static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy, unsigned int min, unsigned int max)
224{
225 if (policy->min < min)
226 policy->min = min;
227 if (policy->max < min)
228 policy->max = min;
229 if (policy->min > max)
230 policy->min = max;
231 if (policy->max > max)
232 policy->max = max;
233 if (policy->min > policy->max)
234 policy->min = policy->max;
235 return;
236}
237
238struct freq_attr {
239 struct attribute attr;
240 ssize_t (*show)(struct cpufreq_policy *, char *);
241 ssize_t (*store)(struct cpufreq_policy *, const char *, size_t count);
242};
243
244
245/*********************************************************************
246 * CPUFREQ 2.6. INTERFACE *
247 *********************************************************************/
248int cpufreq_set_policy(struct cpufreq_policy *policy);
249int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu);
250int cpufreq_update_policy(unsigned int cpu);
251
252/* query the current CPU frequency (in kHz). If zero, cpufreq couldn't detect it */
253unsigned int cpufreq_get(unsigned int cpu);
254
255
256/*********************************************************************
257 * CPUFREQ DEFAULT GOVERNOR *
258 *********************************************************************/
259
260
261#ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE
262extern struct cpufreq_governor cpufreq_gov_performance;
263#define CPUFREQ_DEFAULT_GOVERNOR &cpufreq_gov_performance
264#elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE)
265extern struct cpufreq_governor cpufreq_gov_userspace;
266#define CPUFREQ_DEFAULT_GOVERNOR &cpufreq_gov_userspace
267#endif
268
269
270/*********************************************************************
271 * FREQUENCY TABLE HELPERS *
272 *********************************************************************/
273
274#define CPUFREQ_ENTRY_INVALID ~0
275#define CPUFREQ_TABLE_END ~1
276
277struct cpufreq_frequency_table {
278 unsigned int index; /* any */
279 unsigned int frequency; /* kHz - doesn't need to be in ascending
280 * order */
281};
282
283int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
284 struct cpufreq_frequency_table *table);
285
286int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,
287 struct cpufreq_frequency_table *table);
288
289int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
290 struct cpufreq_frequency_table *table,
291 unsigned int target_freq,
292 unsigned int relation,
293 unsigned int *index);
294
295/* the following 3 funtions are for cpufreq core use only */
296struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu);
297struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu);
298void cpufreq_cpu_put (struct cpufreq_policy *data);
299
300/* the following are really really optional */
301extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs;
302
303void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table,
304 unsigned int cpu);
305
306void cpufreq_frequency_table_put_attr(unsigned int cpu);
307
308
309/*********************************************************************
310 * UNIFIED DEBUG HELPERS *
311 *********************************************************************/
312
313#define CPUFREQ_DEBUG_CORE 1
314#define CPUFREQ_DEBUG_DRIVER 2
315#define CPUFREQ_DEBUG_GOVERNOR 4
316
317#ifdef CONFIG_CPU_FREQ_DEBUG
318
319extern void cpufreq_debug_printk(unsigned int type, const char *prefix,
320 const char *fmt, ...);
321
322#else
323
324#define cpufreq_debug_printk(msg...) do { } while(0)
325
326#endif /* CONFIG_CPU_FREQ_DEBUG */
327
328#endif /* _LINUX_CPUFREQ_H */
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
new file mode 100644
index 000000000000..b15826f6e3a2
--- /dev/null
+++ b/include/linux/cpumask.h
@@ -0,0 +1,395 @@
1#ifndef __LINUX_CPUMASK_H
2#define __LINUX_CPUMASK_H
3
4/*
5 * Cpumasks provide a bitmap suitable for representing the
6 * set of CPU's in a system, one bit position per CPU number.
7 *
8 * See detailed comments in the file linux/bitmap.h describing the
9 * data type on which these cpumasks are based.
10 *
11 * For details of cpumask_scnprintf() and cpumask_parse(),
12 * see bitmap_scnprintf() and bitmap_parse() in lib/bitmap.c.
13 * For details of cpulist_scnprintf() and cpulist_parse(), see
14 * bitmap_scnlistprintf() and bitmap_parselist(), also in bitmap.c.
15 *
16 * The available cpumask operations are:
17 *
18 * void cpu_set(cpu, mask) turn on bit 'cpu' in mask
19 * void cpu_clear(cpu, mask) turn off bit 'cpu' in mask
20 * void cpus_setall(mask) set all bits
21 * void cpus_clear(mask) clear all bits
22 * int cpu_isset(cpu, mask) true iff bit 'cpu' set in mask
23 * int cpu_test_and_set(cpu, mask) test and set bit 'cpu' in mask
24 *
25 * void cpus_and(dst, src1, src2) dst = src1 & src2 [intersection]
26 * void cpus_or(dst, src1, src2) dst = src1 | src2 [union]
27 * void cpus_xor(dst, src1, src2) dst = src1 ^ src2
28 * void cpus_andnot(dst, src1, src2) dst = src1 & ~src2
29 * void cpus_complement(dst, src) dst = ~src
30 *
31 * int cpus_equal(mask1, mask2) Does mask1 == mask2?
32 * int cpus_intersects(mask1, mask2) Do mask1 and mask2 intersect?
33 * int cpus_subset(mask1, mask2) Is mask1 a subset of mask2?
34 * int cpus_empty(mask) Is mask empty (no bits sets)?
35 * int cpus_full(mask) Is mask full (all bits sets)?
36 * int cpus_weight(mask) Hamming weigh - number of set bits
37 *
38 * void cpus_shift_right(dst, src, n) Shift right
39 * void cpus_shift_left(dst, src, n) Shift left
40 *
41 * int first_cpu(mask) Number lowest set bit, or NR_CPUS
42 * int next_cpu(cpu, mask) Next cpu past 'cpu', or NR_CPUS
43 *
44 * cpumask_t cpumask_of_cpu(cpu) Return cpumask with bit 'cpu' set
45 * CPU_MASK_ALL Initializer - all bits set
46 * CPU_MASK_NONE Initializer - no bits set
47 * unsigned long *cpus_addr(mask) Array of unsigned long's in mask
48 *
49 * int cpumask_scnprintf(buf, len, mask) Format cpumask for printing
50 * int cpumask_parse(ubuf, ulen, mask) Parse ascii string as cpumask
51 * int cpulist_scnprintf(buf, len, mask) Format cpumask as list for printing
52 * int cpulist_parse(buf, map) Parse ascii string as cpulist
53 *
54 * for_each_cpu_mask(cpu, mask) for-loop cpu over mask
55 *
56 * int num_online_cpus() Number of online CPUs
57 * int num_possible_cpus() Number of all possible CPUs
58 * int num_present_cpus() Number of present CPUs
59 *
60 * int cpu_online(cpu) Is some cpu online?
61 * int cpu_possible(cpu) Is some cpu possible?
62 * int cpu_present(cpu) Is some cpu present (can schedule)?
63 *
64 * int any_online_cpu(mask) First online cpu in mask
65 *
66 * for_each_cpu(cpu) for-loop cpu over cpu_possible_map
67 * for_each_online_cpu(cpu) for-loop cpu over cpu_online_map
68 * for_each_present_cpu(cpu) for-loop cpu over cpu_present_map
69 *
70 * Subtlety:
71 * 1) The 'type-checked' form of cpu_isset() causes gcc (3.3.2, anyway)
72 * to generate slightly worse code. Note for example the additional
73 * 40 lines of assembly code compiling the "for each possible cpu"
74 * loops buried in the disk_stat_read() macros calls when compiling
75 * drivers/block/genhd.c (arch i386, CONFIG_SMP=y). So use a simple
76 * one-line #define for cpu_isset(), instead of wrapping an inline
77 * inside a macro, the way we do the other calls.
78 */
79
80#include <linux/kernel.h>
81#include <linux/threads.h>
82#include <linux/bitmap.h>
83#include <asm/bug.h>
84
85typedef struct { DECLARE_BITMAP(bits, NR_CPUS); } cpumask_t;
86extern cpumask_t _unused_cpumask_arg_;
87
88#define cpu_set(cpu, dst) __cpu_set((cpu), &(dst))
89static inline void __cpu_set(int cpu, volatile cpumask_t *dstp)
90{
91 set_bit(cpu, dstp->bits);
92}
93
94#define cpu_clear(cpu, dst) __cpu_clear((cpu), &(dst))
95static inline void __cpu_clear(int cpu, volatile cpumask_t *dstp)
96{
97 clear_bit(cpu, dstp->bits);
98}
99
100#define cpus_setall(dst) __cpus_setall(&(dst), NR_CPUS)
101static inline void __cpus_setall(cpumask_t *dstp, int nbits)
102{
103 bitmap_fill(dstp->bits, nbits);
104}
105
106#define cpus_clear(dst) __cpus_clear(&(dst), NR_CPUS)
107static inline void __cpus_clear(cpumask_t *dstp, int nbits)
108{
109 bitmap_zero(dstp->bits, nbits);
110}
111
112/* No static inline type checking - see Subtlety (1) above. */
113#define cpu_isset(cpu, cpumask) test_bit((cpu), (cpumask).bits)
114
115#define cpu_test_and_set(cpu, cpumask) __cpu_test_and_set((cpu), &(cpumask))
116static inline int __cpu_test_and_set(int cpu, cpumask_t *addr)
117{
118 return test_and_set_bit(cpu, addr->bits);
119}
120
121#define cpus_and(dst, src1, src2) __cpus_and(&(dst), &(src1), &(src2), NR_CPUS)
122static inline void __cpus_and(cpumask_t *dstp, const cpumask_t *src1p,
123 const cpumask_t *src2p, int nbits)
124{
125 bitmap_and(dstp->bits, src1p->bits, src2p->bits, nbits);
126}
127
128#define cpus_or(dst, src1, src2) __cpus_or(&(dst), &(src1), &(src2), NR_CPUS)
129static inline void __cpus_or(cpumask_t *dstp, const cpumask_t *src1p,
130 const cpumask_t *src2p, int nbits)
131{
132 bitmap_or(dstp->bits, src1p->bits, src2p->bits, nbits);
133}
134
135#define cpus_xor(dst, src1, src2) __cpus_xor(&(dst), &(src1), &(src2), NR_CPUS)
136static inline void __cpus_xor(cpumask_t *dstp, const cpumask_t *src1p,
137 const cpumask_t *src2p, int nbits)
138{
139 bitmap_xor(dstp->bits, src1p->bits, src2p->bits, nbits);
140}
141
142#define cpus_andnot(dst, src1, src2) \
143 __cpus_andnot(&(dst), &(src1), &(src2), NR_CPUS)
144static inline void __cpus_andnot(cpumask_t *dstp, const cpumask_t *src1p,
145 const cpumask_t *src2p, int nbits)
146{
147 bitmap_andnot(dstp->bits, src1p->bits, src2p->bits, nbits);
148}
149
150#define cpus_complement(dst, src) __cpus_complement(&(dst), &(src), NR_CPUS)
151static inline void __cpus_complement(cpumask_t *dstp,
152 const cpumask_t *srcp, int nbits)
153{
154 bitmap_complement(dstp->bits, srcp->bits, nbits);
155}
156
157#define cpus_equal(src1, src2) __cpus_equal(&(src1), &(src2), NR_CPUS)
158static inline int __cpus_equal(const cpumask_t *src1p,
159 const cpumask_t *src2p, int nbits)
160{
161 return bitmap_equal(src1p->bits, src2p->bits, nbits);
162}
163
164#define cpus_intersects(src1, src2) __cpus_intersects(&(src1), &(src2), NR_CPUS)
165static inline int __cpus_intersects(const cpumask_t *src1p,
166 const cpumask_t *src2p, int nbits)
167{
168 return bitmap_intersects(src1p->bits, src2p->bits, nbits);
169}
170
171#define cpus_subset(src1, src2) __cpus_subset(&(src1), &(src2), NR_CPUS)
172static inline int __cpus_subset(const cpumask_t *src1p,
173 const cpumask_t *src2p, int nbits)
174{
175 return bitmap_subset(src1p->bits, src2p->bits, nbits);
176}
177
178#define cpus_empty(src) __cpus_empty(&(src), NR_CPUS)
179static inline int __cpus_empty(const cpumask_t *srcp, int nbits)
180{
181 return bitmap_empty(srcp->bits, nbits);
182}
183
184#define cpus_full(cpumask) __cpus_full(&(cpumask), NR_CPUS)
185static inline int __cpus_full(const cpumask_t *srcp, int nbits)
186{
187 return bitmap_full(srcp->bits, nbits);
188}
189
190#define cpus_weight(cpumask) __cpus_weight(&(cpumask), NR_CPUS)
191static inline int __cpus_weight(const cpumask_t *srcp, int nbits)
192{
193 return bitmap_weight(srcp->bits, nbits);
194}
195
196#define cpus_shift_right(dst, src, n) \
197 __cpus_shift_right(&(dst), &(src), (n), NR_CPUS)
198static inline void __cpus_shift_right(cpumask_t *dstp,
199 const cpumask_t *srcp, int n, int nbits)
200{
201 bitmap_shift_right(dstp->bits, srcp->bits, n, nbits);
202}
203
204#define cpus_shift_left(dst, src, n) \
205 __cpus_shift_left(&(dst), &(src), (n), NR_CPUS)
206static inline void __cpus_shift_left(cpumask_t *dstp,
207 const cpumask_t *srcp, int n, int nbits)
208{
209 bitmap_shift_left(dstp->bits, srcp->bits, n, nbits);
210}
211
212#define first_cpu(src) __first_cpu(&(src), NR_CPUS)
213static inline int __first_cpu(const cpumask_t *srcp, int nbits)
214{
215 return min_t(int, nbits, find_first_bit(srcp->bits, nbits));
216}
217
218#define next_cpu(n, src) __next_cpu((n), &(src), NR_CPUS)
219static inline int __next_cpu(int n, const cpumask_t *srcp, int nbits)
220{
221 return min_t(int, nbits, find_next_bit(srcp->bits, nbits, n+1));
222}
223
224#define cpumask_of_cpu(cpu) \
225({ \
226 typeof(_unused_cpumask_arg_) m; \
227 if (sizeof(m) == sizeof(unsigned long)) { \
228 m.bits[0] = 1UL<<(cpu); \
229 } else { \
230 cpus_clear(m); \
231 cpu_set((cpu), m); \
232 } \
233 m; \
234})
235
236#define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(NR_CPUS)
237
238#if NR_CPUS <= BITS_PER_LONG
239
240#define CPU_MASK_ALL \
241(cpumask_t) { { \
242 [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \
243} }
244
245#else
246
247#define CPU_MASK_ALL \
248(cpumask_t) { { \
249 [0 ... BITS_TO_LONGS(NR_CPUS)-2] = ~0UL, \
250 [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \
251} }
252
253#endif
254
255#define CPU_MASK_NONE \
256(cpumask_t) { { \
257 [0 ... BITS_TO_LONGS(NR_CPUS)-1] = 0UL \
258} }
259
260#define CPU_MASK_CPU0 \
261(cpumask_t) { { \
262 [0] = 1UL \
263} }
264
265#define cpus_addr(src) ((src).bits)
266
267#define cpumask_scnprintf(buf, len, src) \
268 __cpumask_scnprintf((buf), (len), &(src), NR_CPUS)
269static inline int __cpumask_scnprintf(char *buf, int len,
270 const cpumask_t *srcp, int nbits)
271{
272 return bitmap_scnprintf(buf, len, srcp->bits, nbits);
273}
274
275#define cpumask_parse(ubuf, ulen, dst) \
276 __cpumask_parse((ubuf), (ulen), &(dst), NR_CPUS)
277static inline int __cpumask_parse(const char __user *buf, int len,
278 cpumask_t *dstp, int nbits)
279{
280 return bitmap_parse(buf, len, dstp->bits, nbits);
281}
282
283#define cpulist_scnprintf(buf, len, src) \
284 __cpulist_scnprintf((buf), (len), &(src), NR_CPUS)
285static inline int __cpulist_scnprintf(char *buf, int len,
286 const cpumask_t *srcp, int nbits)
287{
288 return bitmap_scnlistprintf(buf, len, srcp->bits, nbits);
289}
290
291#define cpulist_parse(buf, dst) __cpulist_parse((buf), &(dst), NR_CPUS)
292static inline int __cpulist_parse(const char *buf, cpumask_t *dstp, int nbits)
293{
294 return bitmap_parselist(buf, dstp->bits, nbits);
295}
296
297#if NR_CPUS > 1
298#define for_each_cpu_mask(cpu, mask) \
299 for ((cpu) = first_cpu(mask); \
300 (cpu) < NR_CPUS; \
301 (cpu) = next_cpu((cpu), (mask)))
302#else /* NR_CPUS == 1 */
303#define for_each_cpu_mask(cpu, mask) for ((cpu) = 0; (cpu) < 1; (cpu)++)
304#endif /* NR_CPUS */
305
306/*
307 * The following particular system cpumasks and operations manage
308 * possible, present and online cpus. Each of them is a fixed size
309 * bitmap of size NR_CPUS.
310 *
311 * #ifdef CONFIG_HOTPLUG_CPU
312 * cpu_possible_map - all NR_CPUS bits set
313 * cpu_present_map - has bit 'cpu' set iff cpu is populated
314 * cpu_online_map - has bit 'cpu' set iff cpu available to scheduler
315 * #else
316 * cpu_possible_map - has bit 'cpu' set iff cpu is populated
317 * cpu_present_map - copy of cpu_possible_map
318 * cpu_online_map - has bit 'cpu' set iff cpu available to scheduler
319 * #endif
320 *
321 * In either case, NR_CPUS is fixed at compile time, as the static
322 * size of these bitmaps. The cpu_possible_map is fixed at boot
323 * time, as the set of CPU id's that it is possible might ever
324 * be plugged in at anytime during the life of that system boot.
325 * The cpu_present_map is dynamic(*), representing which CPUs
326 * are currently plugged in. And cpu_online_map is the dynamic
327 * subset of cpu_present_map, indicating those CPUs available
328 * for scheduling.
329 *
330 * If HOTPLUG is enabled, then cpu_possible_map is forced to have
331 * all NR_CPUS bits set, otherwise it is just the set of CPUs that
332 * ACPI reports present at boot.
333 *
334 * If HOTPLUG is enabled, then cpu_present_map varies dynamically,
335 * depending on what ACPI reports as currently plugged in, otherwise
336 * cpu_present_map is just a copy of cpu_possible_map.
337 *
338 * (*) Well, cpu_present_map is dynamic in the hotplug case. If not
339 * hotplug, it's a copy of cpu_possible_map, hence fixed at boot.
340 *
341 * Subtleties:
342 * 1) UP arch's (NR_CPUS == 1, CONFIG_SMP not defined) hardcode
343 * assumption that their single CPU is online. The UP
344 * cpu_{online,possible,present}_maps are placebos. Changing them
345 * will have no useful affect on the following num_*_cpus()
346 * and cpu_*() macros in the UP case. This ugliness is a UP
347 * optimization - don't waste any instructions or memory references
348 * asking if you're online or how many CPUs there are if there is
349 * only one CPU.
350 * 2) Most SMP arch's #define some of these maps to be some
351 * other map specific to that arch. Therefore, the following
352 * must be #define macros, not inlines. To see why, examine
353 * the assembly code produced by the following. Note that
354 * set1() writes phys_x_map, but set2() writes x_map:
355 * int x_map, phys_x_map;
356 * #define set1(a) x_map = a
357 * inline void set2(int a) { x_map = a; }
358 * #define x_map phys_x_map
359 * main(){ set1(3); set2(5); }
360 */
361
362extern cpumask_t cpu_possible_map;
363extern cpumask_t cpu_online_map;
364extern cpumask_t cpu_present_map;
365
366#if NR_CPUS > 1
367#define num_online_cpus() cpus_weight(cpu_online_map)
368#define num_possible_cpus() cpus_weight(cpu_possible_map)
369#define num_present_cpus() cpus_weight(cpu_present_map)
370#define cpu_online(cpu) cpu_isset((cpu), cpu_online_map)
371#define cpu_possible(cpu) cpu_isset((cpu), cpu_possible_map)
372#define cpu_present(cpu) cpu_isset((cpu), cpu_present_map)
373#else
374#define num_online_cpus() 1
375#define num_possible_cpus() 1
376#define num_present_cpus() 1
377#define cpu_online(cpu) ((cpu) == 0)
378#define cpu_possible(cpu) ((cpu) == 0)
379#define cpu_present(cpu) ((cpu) == 0)
380#endif
381
382#define any_online_cpu(mask) \
383({ \
384 int cpu; \
385 for_each_cpu_mask(cpu, (mask)) \
386 if (cpu_online(cpu)) \
387 break; \
388 cpu; \
389})
390
391#define for_each_cpu(cpu) for_each_cpu_mask((cpu), cpu_possible_map)
392#define for_each_online_cpu(cpu) for_each_cpu_mask((cpu), cpu_online_map)
393#define for_each_present_cpu(cpu) for_each_cpu_mask((cpu), cpu_present_map)
394
395#endif /* __LINUX_CPUMASK_H */
diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
new file mode 100644
index 000000000000..2d9a500d994d
--- /dev/null
+++ b/include/linux/cpuset.h
@@ -0,0 +1,64 @@
1#ifndef _LINUX_CPUSET_H
2#define _LINUX_CPUSET_H
3/*
4 * cpuset interface
5 *
6 * Copyright (C) 2003 BULL SA
7 * Copyright (C) 2004 Silicon Graphics, Inc.
8 *
9 */
10
11#include <linux/sched.h>
12#include <linux/cpumask.h>
13#include <linux/nodemask.h>
14
15#ifdef CONFIG_CPUSETS
16
17extern int cpuset_init(void);
18extern void cpuset_init_smp(void);
19extern void cpuset_fork(struct task_struct *p);
20extern void cpuset_exit(struct task_struct *p);
21extern const cpumask_t cpuset_cpus_allowed(const struct task_struct *p);
22void cpuset_init_current_mems_allowed(void);
23void cpuset_update_current_mems_allowed(void);
24void cpuset_restrict_to_mems_allowed(unsigned long *nodes);
25int cpuset_zonelist_valid_mems_allowed(struct zonelist *zl);
26int cpuset_zone_allowed(struct zone *z);
27extern struct file_operations proc_cpuset_operations;
28extern char *cpuset_task_status_allowed(struct task_struct *task, char *buffer);
29
30#else /* !CONFIG_CPUSETS */
31
32static inline int cpuset_init(void) { return 0; }
33static inline void cpuset_init_smp(void) {}
34static inline void cpuset_fork(struct task_struct *p) {}
35static inline void cpuset_exit(struct task_struct *p) {}
36
37static inline cpumask_t cpuset_cpus_allowed(struct task_struct *p)
38{
39 return cpu_possible_map;
40}
41
42static inline void cpuset_init_current_mems_allowed(void) {}
43static inline void cpuset_update_current_mems_allowed(void) {}
44static inline void cpuset_restrict_to_mems_allowed(unsigned long *nodes) {}
45
46static inline int cpuset_zonelist_valid_mems_allowed(struct zonelist *zl)
47{
48 return 1;
49}
50
51static inline int cpuset_zone_allowed(struct zone *z)
52{
53 return 1;
54}
55
56static inline char *cpuset_task_status_allowed(struct task_struct *task,
57 char *buffer)
58{
59 return buffer;
60}
61
62#endif /* !CONFIG_CPUSETS */
63
64#endif /* _LINUX_CPUSET_H */
diff --git a/include/linux/cramfs_fs.h b/include/linux/cramfs_fs.h
new file mode 100644
index 000000000000..a8948f34b776
--- /dev/null
+++ b/include/linux/cramfs_fs.h
@@ -0,0 +1,98 @@
1#ifndef __CRAMFS_H
2#define __CRAMFS_H
3
4#ifndef __KERNEL__
5
6typedef unsigned char u8;
7typedef unsigned short u16;
8typedef unsigned int u32;
9
10#endif
11
12#define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
13#define CRAMFS_SIGNATURE "Compressed ROMFS"
14
15/*
16 * Width of various bitfields in struct cramfs_inode.
17 * Primarily used to generate warnings in mkcramfs.
18 */
19#define CRAMFS_MODE_WIDTH 16
20#define CRAMFS_UID_WIDTH 16
21#define CRAMFS_SIZE_WIDTH 24
22#define CRAMFS_GID_WIDTH 8
23#define CRAMFS_NAMELEN_WIDTH 6
24#define CRAMFS_OFFSET_WIDTH 26
25
26/*
27 * Since inode.namelen is a unsigned 6-bit number, the maximum cramfs
28 * path length is 63 << 2 = 252.
29 */
30#define CRAMFS_MAXPATHLEN (((1 << CRAMFS_NAMELEN_WIDTH) - 1) << 2)
31
32/*
33 * Reasonably terse representation of the inode data.
34 */
35struct cramfs_inode {
36 u32 mode:CRAMFS_MODE_WIDTH, uid:CRAMFS_UID_WIDTH;
37 /* SIZE for device files is i_rdev */
38 u32 size:CRAMFS_SIZE_WIDTH, gid:CRAMFS_GID_WIDTH;
39 /* NAMELEN is the length of the file name, divided by 4 and
40 rounded up. (cramfs doesn't support hard links.) */
41 /* OFFSET: For symlinks and non-empty regular files, this
42 contains the offset (divided by 4) of the file data in
43 compressed form (starting with an array of block pointers;
44 see README). For non-empty directories it is the offset
45 (divided by 4) of the inode of the first file in that
46 directory. For anything else, offset is zero. */
47 u32 namelen:CRAMFS_NAMELEN_WIDTH, offset:CRAMFS_OFFSET_WIDTH;
48};
49
50struct cramfs_info {
51 u32 crc;
52 u32 edition;
53 u32 blocks;
54 u32 files;
55};
56
57/*
58 * Superblock information at the beginning of the FS.
59 */
60struct cramfs_super {
61 u32 magic; /* 0x28cd3d45 - random number */
62 u32 size; /* length in bytes */
63 u32 flags; /* feature flags */
64 u32 future; /* reserved for future use */
65 u8 signature[16]; /* "Compressed ROMFS" */
66 struct cramfs_info fsid; /* unique filesystem info */
67 u8 name[16]; /* user-defined name */
68 struct cramfs_inode root; /* root inode data */
69};
70
71/*
72 * Feature flags
73 *
74 * 0x00000000 - 0x000000ff: features that work for all past kernels
75 * 0x00000100 - 0xffffffff: features that don't work for past kernels
76 */
77#define CRAMFS_FLAG_FSID_VERSION_2 0x00000001 /* fsid version #2 */
78#define CRAMFS_FLAG_SORTED_DIRS 0x00000002 /* sorted dirs */
79#define CRAMFS_FLAG_HOLES 0x00000100 /* support for holes */
80#define CRAMFS_FLAG_WRONG_SIGNATURE 0x00000200 /* reserved */
81#define CRAMFS_FLAG_SHIFTED_ROOT_OFFSET 0x00000400 /* shifted root fs */
82
83/*
84 * Valid values in super.flags. Currently we refuse to mount
85 * if (flags & ~CRAMFS_SUPPORTED_FLAGS). Maybe that should be
86 * changed to test super.future instead.
87 */
88#define CRAMFS_SUPPORTED_FLAGS ( 0x000000ff \
89 | CRAMFS_FLAG_HOLES \
90 | CRAMFS_FLAG_WRONG_SIGNATURE \
91 | CRAMFS_FLAG_SHIFTED_ROOT_OFFSET )
92
93/* Uncompression interfaces to the underlying zlib */
94int cramfs_uncompress_block(void *dst, int dstlen, void *src, int srclen);
95int cramfs_uncompress_init(void);
96int cramfs_uncompress_exit(void);
97
98#endif
diff --git a/include/linux/cramfs_fs_sb.h b/include/linux/cramfs_fs_sb.h
new file mode 100644
index 000000000000..8390693568fd
--- /dev/null
+++ b/include/linux/cramfs_fs_sb.h
@@ -0,0 +1,20 @@
1#ifndef _CRAMFS_FS_SB
2#define _CRAMFS_FS_SB
3
4/*
5 * cramfs super-block data in memory
6 */
7struct cramfs_sb_info {
8 unsigned long magic;
9 unsigned long size;
10 unsigned long blocks;
11 unsigned long files;
12 unsigned long flags;
13};
14
15static inline struct cramfs_sb_info *CRAMFS_SB(struct super_block *sb)
16{
17 return sb->s_fs_info;
18}
19
20#endif
diff --git a/include/linux/crc-ccitt.h b/include/linux/crc-ccitt.h
new file mode 100644
index 000000000000..90037617da8f
--- /dev/null
+++ b/include/linux/crc-ccitt.h
@@ -0,0 +1,17 @@
1#ifndef _LINUX_CRC_CCITT_H
2#define _LINUX_CRC_CCITT_H
3#ifdef __KERNEL__
4
5#include <linux/types.h>
6
7extern u16 const crc_ccitt_table[256];
8
9extern u16 crc_ccitt(u16 crc, const u8 *buffer, size_t len);
10
11static inline u16 crc_ccitt_byte(u16 crc, const u8 c)
12{
13 return (crc >> 8) ^ crc_ccitt_table[(crc ^ c) & 0xff];
14}
15
16#endif /* __KERNEL__ */
17#endif /* _LINUX_CRC_CCITT_H */
diff --git a/include/linux/crc32.h b/include/linux/crc32.h
new file mode 100644
index 000000000000..56c0645789a9
--- /dev/null
+++ b/include/linux/crc32.h
@@ -0,0 +1,27 @@
1/*
2 * crc32.h
3 * See linux/lib/crc32.c for license and changes
4 */
5#ifndef _LINUX_CRC32_H
6#define _LINUX_CRC32_H
7
8#include <linux/types.h>
9
10extern u32 crc32_le(u32 crc, unsigned char const *p, size_t len);
11extern u32 crc32_be(u32 crc, unsigned char const *p, size_t len);
12extern u32 bitreverse(u32 in);
13
14#define crc32(seed, data, length) crc32_le(seed, (unsigned char const *)data, length)
15
16/*
17 * Helpers for hash table generation of ethernet nics:
18 *
19 * Ethernet sends the least significant bit of a byte first, thus crc32_le
20 * is used. The output of crc32_le is bit reversed [most significant bit
21 * is in bit nr 0], thus it must be reversed before use. Except for
22 * nics that bit swap the result internally...
23 */
24#define ether_crc(length, data) bitreverse(crc32_le(~0, data, length))
25#define ether_crc_le(length, data) crc32_le(~0, data, length)
26
27#endif /* _LINUX_CRC32_H */
diff --git a/include/linux/crc32c.h b/include/linux/crc32c.h
new file mode 100644
index 000000000000..508f512e5a2f
--- /dev/null
+++ b/include/linux/crc32c.h
@@ -0,0 +1,11 @@
1#ifndef _LINUX_CRC32C_H
2#define _LINUX_CRC32C_H
3
4#include <linux/types.h>
5
6extern u32 crc32c_le(u32 crc, unsigned char const *address, size_t length);
7extern u32 crc32c_be(u32 crc, unsigned char const *address, size_t length);
8
9#define crc32c(seed, data, length) crc32c_le(seed, (unsigned char const *)data, length)
10
11#endif /* _LINUX_CRC32C_H */
diff --git a/include/linux/crypto.h b/include/linux/crypto.h
new file mode 100644
index 000000000000..387da6a3e58c
--- /dev/null
+++ b/include/linux/crypto.h
@@ -0,0 +1,398 @@
1/*
2 * Scatterlist Cryptographic API.
3 *
4 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
5 * Copyright (c) 2002 David S. Miller (davem@redhat.com)
6 *
7 * Portions derived from Cryptoapi, by Alexander Kjeldaas <astor@fast.no>
8 * and Nettle, by Niels Möller.
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the Free
12 * Software Foundation; either version 2 of the License, or (at your option)
13 * any later version.
14 *
15 */
16#ifndef _LINUX_CRYPTO_H
17#define _LINUX_CRYPTO_H
18
19#include <linux/config.h>
20#include <linux/module.h>
21#include <linux/kernel.h>
22#include <linux/types.h>
23#include <linux/list.h>
24#include <linux/string.h>
25#include <asm/page.h>
26
27/*
28 * Algorithm masks and types.
29 */
30#define CRYPTO_ALG_TYPE_MASK 0x000000ff
31#define CRYPTO_ALG_TYPE_CIPHER 0x00000001
32#define CRYPTO_ALG_TYPE_DIGEST 0x00000002
33#define CRYPTO_ALG_TYPE_COMPRESS 0x00000004
34
35/*
36 * Transform masks and values (for crt_flags).
37 */
38#define CRYPTO_TFM_MODE_MASK 0x000000ff
39#define CRYPTO_TFM_REQ_MASK 0x000fff00
40#define CRYPTO_TFM_RES_MASK 0xfff00000
41
42#define CRYPTO_TFM_MODE_ECB 0x00000001
43#define CRYPTO_TFM_MODE_CBC 0x00000002
44#define CRYPTO_TFM_MODE_CFB 0x00000004
45#define CRYPTO_TFM_MODE_CTR 0x00000008
46
47#define CRYPTO_TFM_REQ_WEAK_KEY 0x00000100
48#define CRYPTO_TFM_RES_WEAK_KEY 0x00100000
49#define CRYPTO_TFM_RES_BAD_KEY_LEN 0x00200000
50#define CRYPTO_TFM_RES_BAD_KEY_SCHED 0x00400000
51#define CRYPTO_TFM_RES_BAD_BLOCK_LEN 0x00800000
52#define CRYPTO_TFM_RES_BAD_FLAGS 0x01000000
53
54/*
55 * Miscellaneous stuff.
56 */
57#define CRYPTO_UNSPEC 0
58#define CRYPTO_MAX_ALG_NAME 64
59
60#define CRYPTO_DIR_ENCRYPT 1
61#define CRYPTO_DIR_DECRYPT 0
62
63struct scatterlist;
64
65/*
66 * Algorithms: modular crypto algorithm implementations, managed
67 * via crypto_register_alg() and crypto_unregister_alg().
68 */
69struct cipher_alg {
70 unsigned int cia_min_keysize;
71 unsigned int cia_max_keysize;
72 int (*cia_setkey)(void *ctx, const u8 *key,
73 unsigned int keylen, u32 *flags);
74 void (*cia_encrypt)(void *ctx, u8 *dst, const u8 *src);
75 void (*cia_decrypt)(void *ctx, u8 *dst, const u8 *src);
76};
77
78struct digest_alg {
79 unsigned int dia_digestsize;
80 void (*dia_init)(void *ctx);
81 void (*dia_update)(void *ctx, const u8 *data, unsigned int len);
82 void (*dia_final)(void *ctx, u8 *out);
83 int (*dia_setkey)(void *ctx, const u8 *key,
84 unsigned int keylen, u32 *flags);
85};
86
87struct compress_alg {
88 int (*coa_init)(void *ctx);
89 void (*coa_exit)(void *ctx);
90 int (*coa_compress)(void *ctx, const u8 *src, unsigned int slen,
91 u8 *dst, unsigned int *dlen);
92 int (*coa_decompress)(void *ctx, const u8 *src, unsigned int slen,
93 u8 *dst, unsigned int *dlen);
94};
95
96#define cra_cipher cra_u.cipher
97#define cra_digest cra_u.digest
98#define cra_compress cra_u.compress
99
100struct crypto_alg {
101 struct list_head cra_list;
102 u32 cra_flags;
103 unsigned int cra_blocksize;
104 unsigned int cra_ctxsize;
105 const char cra_name[CRYPTO_MAX_ALG_NAME];
106
107 union {
108 struct cipher_alg cipher;
109 struct digest_alg digest;
110 struct compress_alg compress;
111 } cra_u;
112
113 struct module *cra_module;
114};
115
116/*
117 * Algorithm registration interface.
118 */
119int crypto_register_alg(struct crypto_alg *alg);
120int crypto_unregister_alg(struct crypto_alg *alg);
121
122/*
123 * Algorithm query interface.
124 */
125#ifdef CONFIG_CRYPTO
126int crypto_alg_available(const char *name, u32 flags);
127#else
128static inline int crypto_alg_available(const char *name, u32 flags)
129{
130 return 0;
131}
132#endif
133
134/*
135 * Transforms: user-instantiated objects which encapsulate algorithms
136 * and core processing logic. Managed via crypto_alloc_tfm() and
137 * crypto_free_tfm(), as well as the various helpers below.
138 */
139struct crypto_tfm;
140
141struct cipher_tfm {
142 void *cit_iv;
143 unsigned int cit_ivsize;
144 u32 cit_mode;
145 int (*cit_setkey)(struct crypto_tfm *tfm,
146 const u8 *key, unsigned int keylen);
147 int (*cit_encrypt)(struct crypto_tfm *tfm,
148 struct scatterlist *dst,
149 struct scatterlist *src,
150 unsigned int nbytes);
151 int (*cit_encrypt_iv)(struct crypto_tfm *tfm,
152 struct scatterlist *dst,
153 struct scatterlist *src,
154 unsigned int nbytes, u8 *iv);
155 int (*cit_decrypt)(struct crypto_tfm *tfm,
156 struct scatterlist *dst,
157 struct scatterlist *src,
158 unsigned int nbytes);
159 int (*cit_decrypt_iv)(struct crypto_tfm *tfm,
160 struct scatterlist *dst,
161 struct scatterlist *src,
162 unsigned int nbytes, u8 *iv);
163 void (*cit_xor_block)(u8 *dst, const u8 *src);
164};
165
166struct digest_tfm {
167 void (*dit_init)(struct crypto_tfm *tfm);
168 void (*dit_update)(struct crypto_tfm *tfm,
169 struct scatterlist *sg, unsigned int nsg);
170 void (*dit_final)(struct crypto_tfm *tfm, u8 *out);
171 void (*dit_digest)(struct crypto_tfm *tfm, struct scatterlist *sg,
172 unsigned int nsg, u8 *out);
173 int (*dit_setkey)(struct crypto_tfm *tfm,
174 const u8 *key, unsigned int keylen);
175#ifdef CONFIG_CRYPTO_HMAC
176 void *dit_hmac_block;
177#endif
178};
179
180struct compress_tfm {
181 int (*cot_compress)(struct crypto_tfm *tfm,
182 const u8 *src, unsigned int slen,
183 u8 *dst, unsigned int *dlen);
184 int (*cot_decompress)(struct crypto_tfm *tfm,
185 const u8 *src, unsigned int slen,
186 u8 *dst, unsigned int *dlen);
187};
188
189#define crt_cipher crt_u.cipher
190#define crt_digest crt_u.digest
191#define crt_compress crt_u.compress
192
193struct crypto_tfm {
194
195 u32 crt_flags;
196
197 union {
198 struct cipher_tfm cipher;
199 struct digest_tfm digest;
200 struct compress_tfm compress;
201 } crt_u;
202
203 struct crypto_alg *__crt_alg;
204};
205
206/*
207 * Transform user interface.
208 */
209
210/*
211 * crypto_alloc_tfm() will first attempt to locate an already loaded algorithm.
212 * If that fails and the kernel supports dynamically loadable modules, it
213 * will then attempt to load a module of the same name or alias. A refcount
214 * is grabbed on the algorithm which is then associated with the new transform.
215 *
216 * crypto_free_tfm() frees up the transform and any associated resources,
217 * then drops the refcount on the associated algorithm.
218 */
219struct crypto_tfm *crypto_alloc_tfm(const char *alg_name, u32 tfm_flags);
220void crypto_free_tfm(struct crypto_tfm *tfm);
221
222/*
223 * Transform helpers which query the underlying algorithm.
224 */
225static inline const char *crypto_tfm_alg_name(struct crypto_tfm *tfm)
226{
227 return tfm->__crt_alg->cra_name;
228}
229
230static inline const char *crypto_tfm_alg_modname(struct crypto_tfm *tfm)
231{
232 return module_name(tfm->__crt_alg->cra_module);
233}
234
235static inline u32 crypto_tfm_alg_type(struct crypto_tfm *tfm)
236{
237 return tfm->__crt_alg->cra_flags & CRYPTO_ALG_TYPE_MASK;
238}
239
240static inline unsigned int crypto_tfm_alg_min_keysize(struct crypto_tfm *tfm)
241{
242 BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
243 return tfm->__crt_alg->cra_cipher.cia_min_keysize;
244}
245
246static inline unsigned int crypto_tfm_alg_max_keysize(struct crypto_tfm *tfm)
247{
248 BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
249 return tfm->__crt_alg->cra_cipher.cia_max_keysize;
250}
251
252static inline unsigned int crypto_tfm_alg_ivsize(struct crypto_tfm *tfm)
253{
254 BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
255 return tfm->crt_cipher.cit_ivsize;
256}
257
258static inline unsigned int crypto_tfm_alg_blocksize(struct crypto_tfm *tfm)
259{
260 return tfm->__crt_alg->cra_blocksize;
261}
262
263static inline unsigned int crypto_tfm_alg_digestsize(struct crypto_tfm *tfm)
264{
265 BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST);
266 return tfm->__crt_alg->cra_digest.dia_digestsize;
267}
268
269/*
270 * API wrappers.
271 */
272static inline void crypto_digest_init(struct crypto_tfm *tfm)
273{
274 BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST);
275 tfm->crt_digest.dit_init(tfm);
276}
277
278static inline void crypto_digest_update(struct crypto_tfm *tfm,
279 struct scatterlist *sg,
280 unsigned int nsg)
281{
282 BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST);
283 tfm->crt_digest.dit_update(tfm, sg, nsg);
284}
285
286static inline void crypto_digest_final(struct crypto_tfm *tfm, u8 *out)
287{
288 BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST);
289 tfm->crt_digest.dit_final(tfm, out);
290}
291
292static inline void crypto_digest_digest(struct crypto_tfm *tfm,
293 struct scatterlist *sg,
294 unsigned int nsg, u8 *out)
295{
296 BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST);
297 tfm->crt_digest.dit_digest(tfm, sg, nsg, out);
298}
299
300static inline int crypto_digest_setkey(struct crypto_tfm *tfm,
301 const u8 *key, unsigned int keylen)
302{
303 BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST);
304 if (tfm->crt_digest.dit_setkey == NULL)
305 return -ENOSYS;
306 return tfm->crt_digest.dit_setkey(tfm, key, keylen);
307}
308
309static inline int crypto_cipher_setkey(struct crypto_tfm *tfm,
310 const u8 *key, unsigned int keylen)
311{
312 BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
313 return tfm->crt_cipher.cit_setkey(tfm, key, keylen);
314}
315
316static inline int crypto_cipher_encrypt(struct crypto_tfm *tfm,
317 struct scatterlist *dst,
318 struct scatterlist *src,
319 unsigned int nbytes)
320{
321 BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
322 return tfm->crt_cipher.cit_encrypt(tfm, dst, src, nbytes);
323}
324
325static inline int crypto_cipher_encrypt_iv(struct crypto_tfm *tfm,
326 struct scatterlist *dst,
327 struct scatterlist *src,
328 unsigned int nbytes, u8 *iv)
329{
330 BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
331 BUG_ON(tfm->crt_cipher.cit_mode == CRYPTO_TFM_MODE_ECB);
332 return tfm->crt_cipher.cit_encrypt_iv(tfm, dst, src, nbytes, iv);
333}
334
335static inline int crypto_cipher_decrypt(struct crypto_tfm *tfm,
336 struct scatterlist *dst,
337 struct scatterlist *src,
338 unsigned int nbytes)
339{
340 BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
341 return tfm->crt_cipher.cit_decrypt(tfm, dst, src, nbytes);
342}
343
344static inline int crypto_cipher_decrypt_iv(struct crypto_tfm *tfm,
345 struct scatterlist *dst,
346 struct scatterlist *src,
347 unsigned int nbytes, u8 *iv)
348{
349 BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
350 BUG_ON(tfm->crt_cipher.cit_mode == CRYPTO_TFM_MODE_ECB);
351 return tfm->crt_cipher.cit_decrypt_iv(tfm, dst, src, nbytes, iv);
352}
353
354static inline void crypto_cipher_set_iv(struct crypto_tfm *tfm,
355 const u8 *src, unsigned int len)
356{
357 BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
358 memcpy(tfm->crt_cipher.cit_iv, src, len);
359}
360
361static inline void crypto_cipher_get_iv(struct crypto_tfm *tfm,
362 u8 *dst, unsigned int len)
363{
364 BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
365 memcpy(dst, tfm->crt_cipher.cit_iv, len);
366}
367
368static inline int crypto_comp_compress(struct crypto_tfm *tfm,
369 const u8 *src, unsigned int slen,
370 u8 *dst, unsigned int *dlen)
371{
372 BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_COMPRESS);
373 return tfm->crt_compress.cot_compress(tfm, src, slen, dst, dlen);
374}
375
376static inline int crypto_comp_decompress(struct crypto_tfm *tfm,
377 const u8 *src, unsigned int slen,
378 u8 *dst, unsigned int *dlen)
379{
380 BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_COMPRESS);
381 return tfm->crt_compress.cot_decompress(tfm, src, slen, dst, dlen);
382}
383
384/*
385 * HMAC support.
386 */
387#ifdef CONFIG_CRYPTO_HMAC
388void crypto_hmac_init(struct crypto_tfm *tfm, u8 *key, unsigned int *keylen);
389void crypto_hmac_update(struct crypto_tfm *tfm,
390 struct scatterlist *sg, unsigned int nsg);
391void crypto_hmac_final(struct crypto_tfm *tfm, u8 *key,
392 unsigned int *keylen, u8 *out);
393void crypto_hmac(struct crypto_tfm *tfm, u8 *key, unsigned int *keylen,
394 struct scatterlist *sg, unsigned int nsg, u8 *out);
395#endif /* CONFIG_CRYPTO_HMAC */
396
397#endif /* _LINUX_CRYPTO_H */
398
diff --git a/include/linux/cryptohash.h b/include/linux/cryptohash.h
new file mode 100644
index 000000000000..c118b2ad9807
--- /dev/null
+++ b/include/linux/cryptohash.h
@@ -0,0 +1,12 @@
1#ifndef __CRYPTOHASH_H
2#define __CRYPTOHASH_H
3
4#define SHA_DIGEST_WORDS 5
5#define SHA_WORKSPACE_WORDS 80
6
7void sha_init(__u32 *buf);
8void sha_transform(__u32 *digest, const char *data, __u32 *W);
9
10__u32 half_md4_transform(__u32 buf[4], __u32 const in[8]);
11
12#endif
diff --git a/include/linux/ctype.h b/include/linux/ctype.h
new file mode 100644
index 000000000000..afa36392297a
--- /dev/null
+++ b/include/linux/ctype.h
@@ -0,0 +1,54 @@
1#ifndef _LINUX_CTYPE_H
2#define _LINUX_CTYPE_H
3
4/*
5 * NOTE! This ctype does not handle EOF like the standard C
6 * library is required to.
7 */
8
9#define _U 0x01 /* upper */
10#define _L 0x02 /* lower */
11#define _D 0x04 /* digit */
12#define _C 0x08 /* cntrl */
13#define _P 0x10 /* punct */
14#define _S 0x20 /* white space (space/lf/tab) */
15#define _X 0x40 /* hex digit */
16#define _SP 0x80 /* hard space (0x20) */
17
18extern unsigned char _ctype[];
19
20#define __ismask(x) (_ctype[(int)(unsigned char)(x)])
21
22#define isalnum(c) ((__ismask(c)&(_U|_L|_D)) != 0)
23#define isalpha(c) ((__ismask(c)&(_U|_L)) != 0)
24#define iscntrl(c) ((__ismask(c)&(_C)) != 0)
25#define isdigit(c) ((__ismask(c)&(_D)) != 0)
26#define isgraph(c) ((__ismask(c)&(_P|_U|_L|_D)) != 0)
27#define islower(c) ((__ismask(c)&(_L)) != 0)
28#define isprint(c) ((__ismask(c)&(_P|_U|_L|_D|_SP)) != 0)
29#define ispunct(c) ((__ismask(c)&(_P)) != 0)
30#define isspace(c) ((__ismask(c)&(_S)) != 0)
31#define isupper(c) ((__ismask(c)&(_U)) != 0)
32#define isxdigit(c) ((__ismask(c)&(_D|_X)) != 0)
33
34#define isascii(c) (((unsigned char)(c))<=0x7f)
35#define toascii(c) (((unsigned char)(c))&0x7f)
36
37static inline unsigned char __tolower(unsigned char c)
38{
39 if (isupper(c))
40 c -= 'A'-'a';
41 return c;
42}
43
44static inline unsigned char __toupper(unsigned char c)
45{
46 if (islower(c))
47 c -= 'a'-'A';
48 return c;
49}
50
51#define tolower(c) __tolower(c)
52#define toupper(c) __toupper(c)
53
54#endif
diff --git a/include/linux/cuda.h b/include/linux/cuda.h
new file mode 100644
index 000000000000..6a3e6385d3f3
--- /dev/null
+++ b/include/linux/cuda.h
@@ -0,0 +1,36 @@
1/*
2 * Definitions for talking to the CUDA. The CUDA is a microcontroller
3 * which controls the ADB, system power, RTC, and various other things.
4 *
5 * Copyright (C) 1996 Paul Mackerras.
6 */
7
8/* CUDA commands (2nd byte) */
9#define CUDA_WARM_START 0
10#define CUDA_AUTOPOLL 1
11#define CUDA_GET_6805_ADDR 2
12#define CUDA_GET_TIME 3
13#define CUDA_GET_PRAM 7
14#define CUDA_SET_6805_ADDR 8
15#define CUDA_SET_TIME 9
16#define CUDA_POWERDOWN 0xa
17#define CUDA_POWERUP_TIME 0xb
18#define CUDA_SET_PRAM 0xc
19#define CUDA_MS_RESET 0xd
20#define CUDA_SEND_DFAC 0xe
21#define CUDA_RESET_SYSTEM 0x11
22#define CUDA_SET_IPL 0x12
23#define CUDA_SET_AUTO_RATE 0x14
24#define CUDA_GET_AUTO_RATE 0x16
25#define CUDA_SET_DEVICE_LIST 0x19
26#define CUDA_GET_DEVICE_LIST 0x1a
27#define CUDA_GET_SET_IIC 0x22
28
29#ifdef __KERNEL__
30
31extern int find_via_cuda(void);
32extern int cuda_request(struct adb_request *req,
33 void (*done)(struct adb_request *), int nbytes, ...);
34extern void cuda_poll(void);
35
36#endif /* __KERNEL */
diff --git a/include/linux/cyclades.h b/include/linux/cyclades.h
new file mode 100644
index 000000000000..46d8254c1a79
--- /dev/null
+++ b/include/linux/cyclades.h
@@ -0,0 +1,827 @@
1/* $Revision: 3.0 $$Date: 1998/11/02 14:20:59 $
2 * linux/include/linux/cyclades.h
3 *
4 * This file was initially written by
5 * Randolph Bentson <bentson@grieg.seaslug.org> and is maintained by
6 * Ivan Passos <ivan@cyclades.com>.
7 *
8 * This file contains the general definitions for the cyclades.c driver
9 *$Log: cyclades.h,v $
10 *Revision 3.1 2002/01/29 11:36:16 henrique
11 *added throttle field on struct cyclades_port to indicate whether the
12 *port is throttled or not
13 *
14 *Revision 3.1 2000/04/19 18:52:52 ivan
15 *converted address fields to unsigned long and added fields for physical
16 *addresses on cyclades_card structure;
17 *
18 *Revision 3.0 1998/11/02 14:20:59 ivan
19 *added nports field on cyclades_card structure;
20 *
21 *Revision 2.5 1998/08/03 16:57:01 ivan
22 *added cyclades_idle_stats structure;
23 *
24 *Revision 2.4 1998/06/01 12:09:53 ivan
25 *removed closing_wait2 from cyclades_port structure;
26 *
27 *Revision 2.3 1998/03/16 18:01:12 ivan
28 *changes in the cyclades_port structure to get it closer to the
29 *standard serial port structure;
30 *added constants for new ioctls;
31 *
32 *Revision 2.2 1998/02/17 16:50:00 ivan
33 *changes in the cyclades_port structure (addition of shutdown_wait and
34 *chip_rev variables);
35 *added constants for new ioctls and for CD1400 rev. numbers.
36 *
37 *Revision 2.1 1997/10/24 16:03:00 ivan
38 *added rflow (which allows enabling the CD1400 special flow control
39 *feature) and rtsdtr_inv (which allows DTR/RTS pin inversion) to
40 *cyclades_port structure;
41 *added Alpha support
42 *
43 *Revision 2.0 1997/06/30 10:30:00 ivan
44 *added some new doorbell command constants related to IOCTLW and
45 *UART error signaling
46 *
47 *Revision 1.8 1997/06/03 15:30:00 ivan
48 *added constant ZFIRM_HLT
49 *added constant CyPCI_Ze_win ( = 2 * Cy_PCI_Zwin)
50 *
51 *Revision 1.7 1997/03/26 10:30:00 daniel
52 *new entries at the end of cyclades_port struct to reallocate
53 *variables illegally allocated within card memory.
54 *
55 *Revision 1.6 1996/09/09 18:35:30 bentson
56 *fold in changes for Cyclom-Z -- including structures for
57 *communicating with board as well modest changes to original
58 *structures to support new features.
59 *
60 *Revision 1.5 1995/11/13 21:13:31 bentson
61 *changes suggested by Michael Chastain <mec@duracef.shout.net>
62 *to support use of this file in non-kernel applications
63 *
64 *
65 */
66
67#ifndef _LINUX_CYCLADES_H
68#define _LINUX_CYCLADES_H
69
70struct cyclades_monitor {
71 unsigned long int_count;
72 unsigned long char_count;
73 unsigned long char_max;
74 unsigned long char_last;
75};
76
77/*
78 * These stats all reflect activity since the device was last initialized.
79 * (i.e., since the port was opened with no other processes already having it
80 * open)
81 */
82struct cyclades_idle_stats {
83 time_t in_use; /* Time device has been in use (secs) */
84 time_t recv_idle; /* Time since last char received (secs) */
85 time_t xmit_idle; /* Time since last char transmitted (secs) */
86 unsigned long recv_bytes; /* Bytes received */
87 unsigned long xmit_bytes; /* Bytes transmitted */
88 unsigned long overruns; /* Input overruns */
89 unsigned long frame_errs; /* Input framing errors */
90 unsigned long parity_errs; /* Input parity errors */
91};
92
93#define CYCLADES_MAGIC 0x4359
94
95#define CYGETMON 0x435901
96#define CYGETTHRESH 0x435902
97#define CYSETTHRESH 0x435903
98#define CYGETDEFTHRESH 0x435904
99#define CYSETDEFTHRESH 0x435905
100#define CYGETTIMEOUT 0x435906
101#define CYSETTIMEOUT 0x435907
102#define CYGETDEFTIMEOUT 0x435908
103#define CYSETDEFTIMEOUT 0x435909
104#define CYSETRFLOW 0x43590a
105#define CYGETRFLOW 0x43590b
106#define CYSETRTSDTR_INV 0x43590c
107#define CYGETRTSDTR_INV 0x43590d
108#define CYZSETPOLLCYCLE 0x43590e
109#define CYZGETPOLLCYCLE 0x43590f
110#define CYGETCD1400VER 0x435910
111#define CYGETCARDINFO 0x435911
112#define CYSETWAIT 0x435912
113#define CYGETWAIT 0x435913
114
115/*************** CYCLOM-Z ADDITIONS ***************/
116
117#define CZIOC ('M' << 8)
118#define CZ_NBOARDS (CZIOC|0xfa)
119#define CZ_BOOT_START (CZIOC|0xfb)
120#define CZ_BOOT_DATA (CZIOC|0xfc)
121#define CZ_BOOT_END (CZIOC|0xfd)
122#define CZ_TEST (CZIOC|0xfe)
123
124#define CZ_DEF_POLL (HZ/25)
125
126#define MAX_BOARD 4 /* Max number of boards */
127#define MAX_DEV 256 /* Max number of ports total */
128#define CYZ_MAX_SPEED 921600
129
130#define CYZ_FIFO_SIZE 16
131
132#define CYZ_BOOT_NWORDS 0x100
133struct CYZ_BOOT_CTRL {
134 unsigned short nboard;
135 int status[MAX_BOARD];
136 int nchannel[MAX_BOARD];
137 int fw_rev[MAX_BOARD];
138 unsigned long offset;
139 unsigned long data[CYZ_BOOT_NWORDS];
140};
141
142
143#ifndef DP_WINDOW_SIZE
144/* #include "cyclomz.h" */
145/****************** ****************** *******************/
146/*
147 * The data types defined below are used in all ZFIRM interface
148 * data structures. They accomodate differences between HW
149 * architectures and compilers.
150 */
151
152#if defined(__alpha__)
153typedef unsigned long ucdouble; /* 64 bits, unsigned */
154typedef unsigned int uclong; /* 32 bits, unsigned */
155#else
156typedef unsigned long uclong; /* 32 bits, unsigned */
157#endif
158typedef unsigned short ucshort; /* 16 bits, unsigned */
159typedef unsigned char ucchar; /* 8 bits, unsigned */
160
161/*
162 * Memory Window Sizes
163 */
164
165#define DP_WINDOW_SIZE (0x00080000) /* window size 512 Kb */
166#define ZE_DP_WINDOW_SIZE (0x00100000) /* window size 1 Mb (Ze and
167 8Zo V.2 */
168#define CTRL_WINDOW_SIZE (0x00000080) /* runtime regs 128 bytes */
169
170/*
171 * CUSTOM_REG - Cyclom-Z/PCI Custom Registers Set. The driver
172 * normally will access only interested on the fpga_id, fpga_version,
173 * start_cpu and stop_cpu.
174 */
175
176struct CUSTOM_REG {
177 uclong fpga_id; /* FPGA Identification Register */
178 uclong fpga_version; /* FPGA Version Number Register */
179 uclong cpu_start; /* CPU start Register (write) */
180 uclong cpu_stop; /* CPU stop Register (write) */
181 uclong misc_reg; /* Miscelaneous Register */
182 uclong idt_mode; /* IDT mode Register */
183 uclong uart_irq_status; /* UART IRQ status Register */
184 uclong clear_timer0_irq; /* Clear timer interrupt Register */
185 uclong clear_timer1_irq; /* Clear timer interrupt Register */
186 uclong clear_timer2_irq; /* Clear timer interrupt Register */
187 uclong test_register; /* Test Register */
188 uclong test_count; /* Test Count Register */
189 uclong timer_select; /* Timer select register */
190 uclong pr_uart_irq_status; /* Prioritized UART IRQ stat Reg */
191 uclong ram_wait_state; /* RAM wait-state Register */
192 uclong uart_wait_state; /* UART wait-state Register */
193 uclong timer_wait_state; /* timer wait-state Register */
194 uclong ack_wait_state; /* ACK wait State Register */
195};
196
197/*
198 * RUNTIME_9060 - PLX PCI9060ES local configuration and shared runtime
199 * registers. This structure can be used to access the 9060 registers
200 * (memory mapped).
201 */
202
203struct RUNTIME_9060 {
204 uclong loc_addr_range; /* 00h - Local Address Range */
205 uclong loc_addr_base; /* 04h - Local Address Base */
206 uclong loc_arbitr; /* 08h - Local Arbitration */
207 uclong endian_descr; /* 0Ch - Big/Little Endian Descriptor */
208 uclong loc_rom_range; /* 10h - Local ROM Range */
209 uclong loc_rom_base; /* 14h - Local ROM Base */
210 uclong loc_bus_descr; /* 18h - Local Bus descriptor */
211 uclong loc_range_mst; /* 1Ch - Local Range for Master to PCI */
212 uclong loc_base_mst; /* 20h - Local Base for Master PCI */
213 uclong loc_range_io; /* 24h - Local Range for Master IO */
214 uclong pci_base_mst; /* 28h - PCI Base for Master PCI */
215 uclong pci_conf_io; /* 2Ch - PCI configuration for Master IO */
216 uclong filler1; /* 30h */
217 uclong filler2; /* 34h */
218 uclong filler3; /* 38h */
219 uclong filler4; /* 3Ch */
220 uclong mail_box_0; /* 40h - Mail Box 0 */
221 uclong mail_box_1; /* 44h - Mail Box 1 */
222 uclong mail_box_2; /* 48h - Mail Box 2 */
223 uclong mail_box_3; /* 4Ch - Mail Box 3 */
224 uclong filler5; /* 50h */
225 uclong filler6; /* 54h */
226 uclong filler7; /* 58h */
227 uclong filler8; /* 5Ch */
228 uclong pci_doorbell; /* 60h - PCI to Local Doorbell */
229 uclong loc_doorbell; /* 64h - Local to PCI Doorbell */
230 uclong intr_ctrl_stat; /* 68h - Interrupt Control/Status */
231 uclong init_ctrl; /* 6Ch - EEPROM control, Init Control, etc */
232};
233
234/* Values for the Local Base Address re-map register */
235
236#define WIN_RAM 0x00000001L /* set the sliding window to RAM */
237#define WIN_CREG 0x14000001L /* set the window to custom Registers */
238
239/* Values timer select registers */
240
241#define TIMER_BY_1M 0x00 /* clock divided by 1M */
242#define TIMER_BY_256K 0x01 /* clock divided by 256k */
243#define TIMER_BY_128K 0x02 /* clock divided by 128k */
244#define TIMER_BY_32K 0x03 /* clock divided by 32k */
245
246/****************** ****************** *******************/
247#endif
248
249#ifndef ZFIRM_ID
250/* #include "zfwint.h" */
251/****************** ****************** *******************/
252/*
253 * This file contains the definitions for interfacing with the
254 * Cyclom-Z ZFIRM Firmware.
255 */
256
257/* General Constant definitions */
258
259#define MAX_CHAN 64 /* max number of channels per board */
260
261/* firmware id structure (set after boot) */
262
263#define ID_ADDRESS 0x00000180L /* signature/pointer address */
264#define ZFIRM_ID 0x5557465AL /* ZFIRM/U signature */
265#define ZFIRM_HLT 0x59505B5CL /* ZFIRM needs external power supply */
266#define ZFIRM_RST 0x56040674L /* RST signal (due to FW reset) */
267
268#define ZF_TINACT_DEF 1000 /* default inactivity timeout
269 (1000 ms) */
270#define ZF_TINACT ZF_TINACT_DEF
271
272struct FIRM_ID {
273 uclong signature; /* ZFIRM/U signature */
274 uclong zfwctrl_addr; /* pointer to ZFW_CTRL structure */
275};
276
277/* Op. System id */
278
279#define C_OS_LINUX 0x00000030 /* generic Linux system */
280
281/* channel op_mode */
282
283#define C_CH_DISABLE 0x00000000 /* channel is disabled */
284#define C_CH_TXENABLE 0x00000001 /* channel Tx enabled */
285#define C_CH_RXENABLE 0x00000002 /* channel Rx enabled */
286#define C_CH_ENABLE 0x00000003 /* channel Tx/Rx enabled */
287#define C_CH_LOOPBACK 0x00000004 /* Loopback mode */
288
289/* comm_parity - parity */
290
291#define C_PR_NONE 0x00000000 /* None */
292#define C_PR_ODD 0x00000001 /* Odd */
293#define C_PR_EVEN 0x00000002 /* Even */
294#define C_PR_MARK 0x00000004 /* Mark */
295#define C_PR_SPACE 0x00000008 /* Space */
296#define C_PR_PARITY 0x000000ff
297
298#define C_PR_DISCARD 0x00000100 /* discard char with frame/par error */
299#define C_PR_IGNORE 0x00000200 /* ignore frame/par error */
300
301/* comm_data_l - data length and stop bits */
302
303#define C_DL_CS5 0x00000001
304#define C_DL_CS6 0x00000002
305#define C_DL_CS7 0x00000004
306#define C_DL_CS8 0x00000008
307#define C_DL_CS 0x0000000f
308#define C_DL_1STOP 0x00000010
309#define C_DL_15STOP 0x00000020
310#define C_DL_2STOP 0x00000040
311#define C_DL_STOP 0x000000f0
312
313/* interrupt enabling/status */
314
315#define C_IN_DISABLE 0x00000000 /* zero, disable interrupts */
316#define C_IN_TXBEMPTY 0x00000001 /* tx buffer empty */
317#define C_IN_TXLOWWM 0x00000002 /* tx buffer below LWM */
318#define C_IN_RXHIWM 0x00000010 /* rx buffer above HWM */
319#define C_IN_RXNNDT 0x00000020 /* rx no new data timeout */
320#define C_IN_MDCD 0x00000100 /* modem DCD change */
321#define C_IN_MDSR 0x00000200 /* modem DSR change */
322#define C_IN_MRI 0x00000400 /* modem RI change */
323#define C_IN_MCTS 0x00000800 /* modem CTS change */
324#define C_IN_RXBRK 0x00001000 /* Break received */
325#define C_IN_PR_ERROR 0x00002000 /* parity error */
326#define C_IN_FR_ERROR 0x00004000 /* frame error */
327#define C_IN_OVR_ERROR 0x00008000 /* overrun error */
328#define C_IN_RXOFL 0x00010000 /* RX buffer overflow */
329#define C_IN_IOCTLW 0x00020000 /* I/O control w/ wait */
330#define C_IN_MRTS 0x00040000 /* modem RTS drop */
331#define C_IN_ICHAR 0x00080000
332
333/* flow control */
334
335#define C_FL_OXX 0x00000001 /* output Xon/Xoff flow control */
336#define C_FL_IXX 0x00000002 /* output Xon/Xoff flow control */
337#define C_FL_OIXANY 0x00000004 /* output Xon/Xoff (any xon) */
338#define C_FL_SWFLOW 0x0000000f
339
340/* flow status */
341
342#define C_FS_TXIDLE 0x00000000 /* no Tx data in the buffer or UART */
343#define C_FS_SENDING 0x00000001 /* UART is sending data */
344#define C_FS_SWFLOW 0x00000002 /* Tx is stopped by received Xoff */
345
346/* rs_control/rs_status RS-232 signals */
347
348#define C_RS_PARAM 0x80000000 /* Indicates presence of parameter in
349 IOCTLM command */
350#define C_RS_RTS 0x00000001 /* RTS */
351#define C_RS_DTR 0x00000004 /* DTR */
352#define C_RS_DCD 0x00000100 /* CD */
353#define C_RS_DSR 0x00000200 /* DSR */
354#define C_RS_RI 0x00000400 /* RI */
355#define C_RS_CTS 0x00000800 /* CTS */
356
357/* commands Host <-> Board */
358
359#define C_CM_RESET 0x01 /* reset/flush buffers */
360#define C_CM_IOCTL 0x02 /* re-read CH_CTRL */
361#define C_CM_IOCTLW 0x03 /* re-read CH_CTRL, intr when done */
362#define C_CM_IOCTLM 0x04 /* RS-232 outputs change */
363#define C_CM_SENDXOFF 0x10 /* send Xoff */
364#define C_CM_SENDXON 0x11 /* send Xon */
365#define C_CM_CLFLOW 0x12 /* Clear flow control (resume) */
366#define C_CM_SENDBRK 0x41 /* send break */
367#define C_CM_INTBACK 0x42 /* Interrupt back */
368#define C_CM_SET_BREAK 0x43 /* Tx break on */
369#define C_CM_CLR_BREAK 0x44 /* Tx break off */
370#define C_CM_CMD_DONE 0x45 /* Previous command done */
371#define C_CM_INTBACK2 0x46 /* Alternate Interrupt back */
372#define C_CM_TINACT 0x51 /* set inactivity detection */
373#define C_CM_IRQ_ENBL 0x52 /* enable generation of interrupts */
374#define C_CM_IRQ_DSBL 0x53 /* disable generation of interrupts */
375#define C_CM_ACK_ENBL 0x54 /* enable acknowledged interrupt mode */
376#define C_CM_ACK_DSBL 0x55 /* disable acknowledged intr mode */
377#define C_CM_FLUSH_RX 0x56 /* flushes Rx buffer */
378#define C_CM_FLUSH_TX 0x57 /* flushes Tx buffer */
379#define C_CM_Q_ENABLE 0x58 /* enables queue access from the
380 driver */
381#define C_CM_Q_DISABLE 0x59 /* disables queue access from the
382 driver */
383
384#define C_CM_TXBEMPTY 0x60 /* Tx buffer is empty */
385#define C_CM_TXLOWWM 0x61 /* Tx buffer low water mark */
386#define C_CM_RXHIWM 0x62 /* Rx buffer high water mark */
387#define C_CM_RXNNDT 0x63 /* rx no new data timeout */
388#define C_CM_TXFEMPTY 0x64
389#define C_CM_ICHAR 0x65
390#define C_CM_MDCD 0x70 /* modem DCD change */
391#define C_CM_MDSR 0x71 /* modem DSR change */
392#define C_CM_MRI 0x72 /* modem RI change */
393#define C_CM_MCTS 0x73 /* modem CTS change */
394#define C_CM_MRTS 0x74 /* modem RTS drop */
395#define C_CM_RXBRK 0x84 /* Break received */
396#define C_CM_PR_ERROR 0x85 /* Parity error */
397#define C_CM_FR_ERROR 0x86 /* Frame error */
398#define C_CM_OVR_ERROR 0x87 /* Overrun error */
399#define C_CM_RXOFL 0x88 /* RX buffer overflow */
400#define C_CM_CMDERROR 0x90 /* command error */
401#define C_CM_FATAL 0x91 /* fatal error */
402#define C_CM_HW_RESET 0x92 /* reset board */
403
404/*
405 * CH_CTRL - This per port structure contains all parameters
406 * that control an specific port. It can be seen as the
407 * configuration registers of a "super-serial-controller".
408 */
409
410struct CH_CTRL {
411 uclong op_mode; /* operation mode */
412 uclong intr_enable; /* interrupt masking */
413 uclong sw_flow; /* SW flow control */
414 uclong flow_status; /* output flow status */
415 uclong comm_baud; /* baud rate - numerically specified */
416 uclong comm_parity; /* parity */
417 uclong comm_data_l; /* data length/stop */
418 uclong comm_flags; /* other flags */
419 uclong hw_flow; /* HW flow control */
420 uclong rs_control; /* RS-232 outputs */
421 uclong rs_status; /* RS-232 inputs */
422 uclong flow_xon; /* xon char */
423 uclong flow_xoff; /* xoff char */
424 uclong hw_overflow; /* hw overflow counter */
425 uclong sw_overflow; /* sw overflow counter */
426 uclong comm_error; /* frame/parity error counter */
427 uclong ichar;
428 uclong filler[7];
429};
430
431
432/*
433 * BUF_CTRL - This per channel structure contains
434 * all Tx and Rx buffer control for a given channel.
435 */
436
437struct BUF_CTRL {
438 uclong flag_dma; /* buffers are in Host memory */
439 uclong tx_bufaddr; /* address of the tx buffer */
440 uclong tx_bufsize; /* tx buffer size */
441 uclong tx_threshold; /* tx low water mark */
442 uclong tx_get; /* tail index tx buf */
443 uclong tx_put; /* head index tx buf */
444 uclong rx_bufaddr; /* address of the rx buffer */
445 uclong rx_bufsize; /* rx buffer size */
446 uclong rx_threshold; /* rx high water mark */
447 uclong rx_get; /* tail index rx buf */
448 uclong rx_put; /* head index rx buf */
449 uclong filler[5]; /* filler to align structures */
450};
451
452/*
453 * BOARD_CTRL - This per board structure contains all global
454 * control fields related to the board.
455 */
456
457struct BOARD_CTRL {
458
459 /* static info provided by the on-board CPU */
460 uclong n_channel; /* number of channels */
461 uclong fw_version; /* firmware version */
462
463 /* static info provided by the driver */
464 uclong op_system; /* op_system id */
465 uclong dr_version; /* driver version */
466
467 /* board control area */
468 uclong inactivity; /* inactivity control */
469
470 /* host to FW commands */
471 uclong hcmd_channel; /* channel number */
472 uclong hcmd_param; /* pointer to parameters */
473
474 /* FW to Host commands */
475 uclong fwcmd_channel; /* channel number */
476 uclong fwcmd_param; /* pointer to parameters */
477 uclong zf_int_queue_addr; /* offset for INT_QUEUE structure */
478
479 /* filler so the structures are aligned */
480 uclong filler[6];
481};
482
483/* Host Interrupt Queue */
484
485#define QUEUE_SIZE (10*MAX_CHAN)
486
487struct INT_QUEUE {
488 unsigned char intr_code[QUEUE_SIZE];
489 unsigned long channel[QUEUE_SIZE];
490 unsigned long param[QUEUE_SIZE];
491 unsigned long put;
492 unsigned long get;
493};
494
495/*
496 * ZFW_CTRL - This is the data structure that includes all other
497 * data structures used by the Firmware.
498 */
499
500struct ZFW_CTRL {
501 struct BOARD_CTRL board_ctrl;
502 struct CH_CTRL ch_ctrl[MAX_CHAN];
503 struct BUF_CTRL buf_ctrl[MAX_CHAN];
504};
505
506/****************** ****************** *******************/
507#endif
508
509/* Per card data structure */
510struct resource;
511struct cyclades_card {
512 unsigned long base_phys;
513 unsigned long ctl_phys;
514 void __iomem *base_addr;
515 void __iomem *ctl_addr;
516 int irq;
517 int num_chips; /* 0 if card absent, -1 if Z/PCI, else Y */
518 int first_line; /* minor number of first channel on card */
519 int nports; /* Number of ports in the card */
520 int bus_index; /* address shift - 0 for ISA, 1 for PCI */
521 int intr_enabled; /* FW Interrupt flag - 0 disabled, 1 enabled */
522 struct pci_dev *pdev;
523#ifdef __KERNEL__
524 spinlock_t card_lock;
525#else
526 unsigned long filler;
527#endif
528};
529
530struct cyclades_chip {
531 int filler;
532};
533
534
535#ifdef __KERNEL__
536
537/***************************************
538 * Memory access functions/macros *
539 * (required to support Alpha systems) *
540 ***************************************/
541
542#define cy_writeb(port,val) {writeb((val),(port)); mb();}
543#define cy_writew(port,val) {writew((val),(port)); mb();}
544#define cy_writel(port,val) {writel((val),(port)); mb();}
545
546#define cy_readb(port) readb(port)
547#define cy_readw(port) readw(port)
548#define cy_readl(port) readl(port)
549
550/*
551 * Statistics counters
552 */
553struct cyclades_icount {
554 __u32 cts, dsr, rng, dcd, tx, rx;
555 __u32 frame, parity, overrun, brk;
556 __u32 buf_overrun;
557};
558
559/*
560 * This is our internal structure for each serial port's state.
561 *
562 * Many fields are paralleled by the structure used by the serial_struct
563 * structure.
564 *
565 * For definitions of the flags field, see tty.h
566 */
567
568struct cyclades_port {
569 int magic;
570 int card;
571 int line;
572 int flags; /* defined in tty.h */
573 int type; /* UART type */
574 struct tty_struct *tty;
575 int read_status_mask;
576 int ignore_status_mask;
577 int timeout;
578 int xmit_fifo_size;
579 int cor1,cor2,cor3,cor4,cor5;
580 int tbpr,tco,rbpr,rco;
581 int baud;
582 int rflow;
583 int rtsdtr_inv;
584 int chip_rev;
585 int custom_divisor;
586 int x_char; /* to be pushed out ASAP */
587 int close_delay;
588 unsigned short closing_wait;
589 unsigned long event;
590 unsigned long last_active;
591 int count; /* # of fd on device */
592 int breakon;
593 int breakoff;
594 int blocked_open; /* # of blocked opens */
595 unsigned char *xmit_buf;
596 int xmit_head;
597 int xmit_tail;
598 int xmit_cnt;
599 int default_threshold;
600 int default_timeout;
601 unsigned long jiffies[3];
602 unsigned long rflush_count;
603 struct cyclades_monitor mon;
604 struct cyclades_idle_stats idle_stats;
605 struct cyclades_icount icount;
606 struct work_struct tqueue;
607 wait_queue_head_t open_wait;
608 wait_queue_head_t close_wait;
609 wait_queue_head_t shutdown_wait;
610 wait_queue_head_t delta_msr_wait;
611 int throttle;
612};
613
614/*
615 * Events are used to schedule things to happen at timer-interrupt
616 * time, instead of at cy interrupt time.
617 */
618#define Cy_EVENT_READ_PROCESS 0
619#define Cy_EVENT_WRITE_WAKEUP 1
620#define Cy_EVENT_HANGUP 2
621#define Cy_EVENT_BREAK 3
622#define Cy_EVENT_OPEN_WAKEUP 4
623#define Cy_EVENT_SHUTDOWN_WAKEUP 5
624#define Cy_EVENT_DELTA_WAKEUP 6
625#define Cy_EVENT_Z_RX_FULL 7
626
627#define CLOSING_WAIT_DELAY 30*HZ
628#define CY_CLOSING_WAIT_NONE 65535
629#define CY_CLOSING_WAIT_INF 0
630
631
632#define CyMAX_CHIPS_PER_CARD 8
633#define CyMAX_CHAR_FIFO 12
634#define CyPORTS_PER_CHIP 4
635#define CD1400_MAX_SPEED 115200
636
637#define CyISA_Ywin 0x2000
638
639#define CyPCI_Ywin 0x4000
640#define CyPCI_Yctl 0x80
641#define CyPCI_Zctl CTRL_WINDOW_SIZE
642#define CyPCI_Zwin 0x80000
643#define CyPCI_Ze_win (2 * CyPCI_Zwin)
644
645#define PCI_DEVICE_ID_MASK 0x06
646
647/**** CD1400 registers ****/
648
649#define CD1400_REV_G 0x46
650#define CD1400_REV_J 0x48
651
652#define CyRegSize 0x0400
653#define Cy_HwReset 0x1400
654#define Cy_ClrIntr 0x1800
655#define Cy_EpldRev 0x1e00
656
657/* Global Registers */
658
659#define CyGFRCR (0x40*2)
660#define CyRevE (44)
661#define CyCAR (0x68*2)
662#define CyCHAN_0 (0x00)
663#define CyCHAN_1 (0x01)
664#define CyCHAN_2 (0x02)
665#define CyCHAN_3 (0x03)
666#define CyGCR (0x4B*2)
667#define CyCH0_SERIAL (0x00)
668#define CyCH0_PARALLEL (0x80)
669#define CySVRR (0x67*2)
670#define CySRModem (0x04)
671#define CySRTransmit (0x02)
672#define CySRReceive (0x01)
673#define CyRICR (0x44*2)
674#define CyTICR (0x45*2)
675#define CyMICR (0x46*2)
676#define CyICR0 (0x00)
677#define CyICR1 (0x01)
678#define CyICR2 (0x02)
679#define CyICR3 (0x03)
680#define CyRIR (0x6B*2)
681#define CyTIR (0x6A*2)
682#define CyMIR (0x69*2)
683#define CyIRDirEq (0x80)
684#define CyIRBusy (0x40)
685#define CyIRUnfair (0x20)
686#define CyIRContext (0x1C)
687#define CyIRChannel (0x03)
688#define CyPPR (0x7E*2)
689#define CyCLOCK_20_1MS (0x27)
690#define CyCLOCK_25_1MS (0x31)
691#define CyCLOCK_25_5MS (0xf4)
692#define CyCLOCK_60_1MS (0x75)
693#define CyCLOCK_60_2MS (0xea)
694
695/* Virtual Registers */
696
697#define CyRIVR (0x43*2)
698#define CyTIVR (0x42*2)
699#define CyMIVR (0x41*2)
700#define CyIVRMask (0x07)
701#define CyIVRRxEx (0x07)
702#define CyIVRRxOK (0x03)
703#define CyIVRTxOK (0x02)
704#define CyIVRMdmOK (0x01)
705#define CyTDR (0x63*2)
706#define CyRDSR (0x62*2)
707#define CyTIMEOUT (0x80)
708#define CySPECHAR (0x70)
709#define CyBREAK (0x08)
710#define CyPARITY (0x04)
711#define CyFRAME (0x02)
712#define CyOVERRUN (0x01)
713#define CyMISR (0x4C*2)
714/* see CyMCOR_ and CyMSVR_ for bits*/
715#define CyEOSRR (0x60*2)
716
717/* Channel Registers */
718
719#define CyLIVR (0x18*2)
720#define CyMscsr (0x01)
721#define CyTdsr (0x02)
722#define CyRgdsr (0x03)
723#define CyRedsr (0x07)
724#define CyCCR (0x05*2)
725/* Format 1 */
726#define CyCHAN_RESET (0x80)
727#define CyCHIP_RESET (0x81)
728#define CyFlushTransFIFO (0x82)
729/* Format 2 */
730#define CyCOR_CHANGE (0x40)
731#define CyCOR1ch (0x02)
732#define CyCOR2ch (0x04)
733#define CyCOR3ch (0x08)
734/* Format 3 */
735#define CySEND_SPEC_1 (0x21)
736#define CySEND_SPEC_2 (0x22)
737#define CySEND_SPEC_3 (0x23)
738#define CySEND_SPEC_4 (0x24)
739/* Format 4 */
740#define CyCHAN_CTL (0x10)
741#define CyDIS_RCVR (0x01)
742#define CyENB_RCVR (0x02)
743#define CyDIS_XMTR (0x04)
744#define CyENB_XMTR (0x08)
745#define CySRER (0x06*2)
746#define CyMdmCh (0x80)
747#define CyRxData (0x10)
748#define CyTxRdy (0x04)
749#define CyTxMpty (0x02)
750#define CyNNDT (0x01)
751#define CyCOR1 (0x08*2)
752#define CyPARITY_NONE (0x00)
753#define CyPARITY_0 (0x20)
754#define CyPARITY_1 (0xA0)
755#define CyPARITY_E (0x40)
756#define CyPARITY_O (0xC0)
757#define Cy_1_STOP (0x00)
758#define Cy_1_5_STOP (0x04)
759#define Cy_2_STOP (0x08)
760#define Cy_5_BITS (0x00)
761#define Cy_6_BITS (0x01)
762#define Cy_7_BITS (0x02)
763#define Cy_8_BITS (0x03)
764#define CyCOR2 (0x09*2)
765#define CyIXM (0x80)
766#define CyTxIBE (0x40)
767#define CyETC (0x20)
768#define CyAUTO_TXFL (0x60)
769#define CyLLM (0x10)
770#define CyRLM (0x08)
771#define CyRtsAO (0x04)
772#define CyCtsAE (0x02)
773#define CyDsrAE (0x01)
774#define CyCOR3 (0x0A*2)
775#define CySPL_CH_DRANGE (0x80) /* special character detect range */
776#define CySPL_CH_DET1 (0x40) /* enable special character detection
777 on SCHR4-SCHR3 */
778#define CyFL_CTRL_TRNSP (0x20) /* Flow Control Transparency */
779#define CySPL_CH_DET2 (0x10) /* Enable special character detection
780 on SCHR2-SCHR1 */
781#define CyREC_FIFO (0x0F) /* Receive FIFO threshold */
782#define CyCOR4 (0x1E*2)
783#define CyCOR5 (0x1F*2)
784#define CyCCSR (0x0B*2)
785#define CyRxEN (0x80)
786#define CyRxFloff (0x40)
787#define CyRxFlon (0x20)
788#define CyTxEN (0x08)
789#define CyTxFloff (0x04)
790#define CyTxFlon (0x02)
791#define CyRDCR (0x0E*2)
792#define CySCHR1 (0x1A*2)
793#define CySCHR2 (0x1B*2)
794#define CySCHR3 (0x1C*2)
795#define CySCHR4 (0x1D*2)
796#define CySCRL (0x22*2)
797#define CySCRH (0x23*2)
798#define CyLNC (0x24*2)
799#define CyMCOR1 (0x15*2)
800#define CyMCOR2 (0x16*2)
801#define CyRTPR (0x21*2)
802#define CyMSVR1 (0x6C*2)
803#define CyMSVR2 (0x6D*2)
804#define CyANY_DELTA (0xF0)
805#define CyDSR (0x80)
806#define CyCTS (0x40)
807#define CyRI (0x20)
808#define CyDCD (0x10)
809#define CyDTR (0x02)
810#define CyRTS (0x01)
811#define CyPVSR (0x6F*2)
812#define CyRBPR (0x78*2)
813#define CyRCOR (0x7C*2)
814#define CyTBPR (0x72*2)
815#define CyTCOR (0x76*2)
816
817/* Custom Registers */
818
819#define CyPLX_VER (0x3400)
820#define PLX_9050 0x0b
821#define PLX_9060 0x0c
822#define PLX_9080 0x0d
823
824/***************************************************************************/
825
826#endif /* __KERNEL__ */
827#endif /* _LINUX_CYCLADES_H */
diff --git a/include/linux/cyclomx.h b/include/linux/cyclomx.h
new file mode 100644
index 000000000000..04fa7dff079c
--- /dev/null
+++ b/include/linux/cyclomx.h
@@ -0,0 +1,80 @@
1#ifndef _CYCLOMX_H
2#define _CYCLOMX_H
3/*
4* cyclomx.h Cyclom 2X WAN Link Driver.
5* User-level API definitions.
6*
7* Author: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
8*
9* Copyright: (c) 1998-2003 Arnaldo Carvalho de Melo
10*
11* Based on wanpipe.h by Gene Kozin <genek@compuserve.com>
12*
13* This program is free software; you can redistribute it and/or
14* modify it under the terms of the GNU General Public License
15* as published by the Free Software Foundation; either version
16* 2 of the License, or (at your option) any later version.
17* ============================================================================
18* 2000/07/13 acme remove crap #if KERNEL_VERSION > blah
19* 2000/01/21 acme rename cyclomx_open to cyclomx_mod_inc_use_count
20* and cyclomx_close to cyclomx_mod_dec_use_count
21* 1999/05/19 acme wait_queue_head_t wait_stats(support for 2.3.*)
22* 1999/01/03 acme judicious use of data types
23* 1998/12/27 acme cleanup: PACKED not needed
24* 1998/08/08 acme Version 0.0.1
25*/
26
27#include <linux/config.h>
28#include <linux/wanrouter.h>
29#include <linux/spinlock.h>
30
31#ifdef __KERNEL__
32/* Kernel Interface */
33
34#include <linux/cycx_drv.h> /* Cyclom 2X support module API definitions */
35#include <linux/cycx_cfm.h> /* Cyclom 2X firmware module definitions */
36#ifdef CONFIG_CYCLOMX_X25
37#include <linux/cycx_x25.h>
38#endif
39
40#define is_digit(ch) (((ch)>=(unsigned)'0'&&(ch)<=(unsigned)'9')?1:0)
41
42/* Adapter Data Space.
43 * This structure is needed because we handle multiple cards, otherwise
44 * static data would do it.
45 */
46struct cycx_device {
47 char devname[WAN_DRVNAME_SZ + 1];/* card name */
48 struct cycx_hw hw; /* hardware configuration */
49 struct wan_device wandev; /* WAN device data space */
50 u32 state_tick; /* link state timestamp */
51 spinlock_t lock;
52 char in_isr; /* interrupt-in-service flag */
53 char buff_int_mode_unbusy; /* flag for carrying out dev_tint */
54 wait_queue_head_t wait_stats; /* to wait for the STATS indication */
55 void __iomem *mbox; /* -> mailbox */
56 void (*isr)(struct cycx_device* card); /* interrupt service routine */
57 int (*exec)(struct cycx_device* card, void* u_cmd, void* u_data);
58 union {
59#ifdef CONFIG_CYCLOMX_X25
60 struct { /* X.25 specific data */
61 u32 lo_pvc;
62 u32 hi_pvc;
63 u32 lo_svc;
64 u32 hi_svc;
65 struct cycx_x25_stats stats;
66 spinlock_t lock;
67 u32 connection_keys;
68 } x;
69#endif
70 } u;
71};
72
73/* Public Functions */
74void cycx_set_state(struct cycx_device *card, int state);
75
76#ifdef CONFIG_CYCLOMX_X25
77int cycx_x25_wan_init(struct cycx_device *card, wandev_conf_t *conf);
78#endif
79#endif /* __KERNEL__ */
80#endif /* _CYCLOMX_H */
diff --git a/include/linux/cycx_cfm.h b/include/linux/cycx_cfm.h
new file mode 100644
index 000000000000..032d26ed8384
--- /dev/null
+++ b/include/linux/cycx_cfm.h
@@ -0,0 +1,101 @@
1/*
2* cycx_cfm.h Cyclom 2X WAN Link Driver.
3* Definitions for the Cyclom 2X Firmware Module (CFM).
4*
5* Author: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
6*
7* Copyright: (c) 1998-2003 Arnaldo Carvalho de Melo
8*
9* Based on sdlasfm.h by Gene Kozin <74604.152@compuserve.com>
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* 1998/08/08 acme Initial version.
17*/
18#ifndef _CYCX_CFM_H
19#define _CYCX_CFM_H
20
21/* Defines */
22
23#define CFM_VERSION 2
24#define CFM_SIGNATURE "CFM - Cyclades CYCX Firmware Module"
25
26/* min/max */
27#define CFM_IMAGE_SIZE 0x20000 /* max size of CYCX code image file */
28#define CFM_DESCR_LEN 256 /* max length of description string */
29#define CFM_MAX_CYCX 1 /* max number of compatible adapters */
30#define CFM_LOAD_BUFSZ 0x400 /* buffer size for reset code (buffer_load) */
31
32/* Firmware Commands */
33#define GEN_POWER_ON 0x1280
34
35#define GEN_SET_SEG 0x1401 /* boot segment setting. */
36#define GEN_BOOT_DAT 0x1402 /* boot data. */
37#define GEN_START 0x1403 /* board start. */
38#define GEN_DEFPAR 0x1404 /* buffer length for boot. */
39
40/* Adapter Types */
41#define CYCX_2X 2
42/* for now only the 2X is supported, no plans to support 8X or 16X */
43#define CYCX_8X 8
44#define CYCX_16X 16
45
46#define CFID_X25_2X 5200
47
48/**
49 * struct cycx_fw_info - firmware module information.
50 * @codeid - firmware ID
51 * @version - firmware version number
52 * @adapter - compatible adapter types
53 * @memsize - minimum memory size
54 * @reserved - reserved
55 * @startoffs - entry point offset
56 * @winoffs - dual-port memory window offset
57 * @codeoffs - code load offset
58 * @codesize - code size
59 * @dataoffs - configuration data load offset
60 * @datasize - configuration data size
61 */
62struct cycx_fw_info {
63 unsigned short codeid;
64 unsigned short version;
65 unsigned short adapter[CFM_MAX_CYCX];
66 unsigned long memsize;
67 unsigned short reserved[2];
68 unsigned short startoffs;
69 unsigned short winoffs;
70 unsigned short codeoffs;
71 unsigned long codesize;
72 unsigned short dataoffs;
73 unsigned long datasize;
74};
75
76/**
77 * struct cycx_firmware - CYCX firmware file structure
78 * @signature - CFM file signature
79 * @version - file format version
80 * @checksum - info + image
81 * @reserved - reserved
82 * @descr - description string
83 * @info - firmware module info
84 * @image - code image (variable size)
85 */
86struct cycx_firmware {
87 char signature[80];
88 unsigned short version;
89 unsigned short checksum;
90 unsigned short reserved[6];
91 char descr[CFM_DESCR_LEN];
92 struct cycx_fw_info info;
93 unsigned char image[0];
94};
95
96struct cycx_fw_header {
97 unsigned long reset_size;
98 unsigned long data_size;
99 unsigned long code_size;
100};
101#endif /* _CYCX_CFM_H */
diff --git a/include/linux/cycx_drv.h b/include/linux/cycx_drv.h
new file mode 100644
index 000000000000..6621df86a748
--- /dev/null
+++ b/include/linux/cycx_drv.h
@@ -0,0 +1,65 @@
1/*
2* cycx_drv.h CYCX Support Module. Kernel API Definitions.
3*
4* Author: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
5*
6* Copyright: (c) 1998-2003 Arnaldo Carvalho de Melo
7*
8* Based on sdladrv.h by Gene Kozin <genek@compuserve.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* 1999/10/23 acme cycxhw_t cleanup
16* 1999/01/03 acme more judicious use of data types...
17* uclong, ucchar, etc deleted, the u8, u16, u32
18* types are the portable way to go.
19* 1999/01/03 acme judicious use of data types... u16, u32, etc
20* 1998/12/26 acme FIXED_BUFFERS, CONF_OFFSET,
21* removal of cy_read{bwl}
22* 1998/08/08 acme Initial version.
23*/
24#ifndef _CYCX_DRV_H
25#define _CYCX_DRV_H
26
27#define CYCX_WINDOWSIZE 0x4000 /* default dual-port memory window size */
28#define GEN_CYCX_INTR 0x02
29#define RST_ENABLE 0x04
30#define START_CPU 0x06
31#define RST_DISABLE 0x08
32#define FIXED_BUFFERS 0x08
33#define TEST_PATTERN 0xaa55
34#define CMD_OFFSET 0x20
35#define CONF_OFFSET 0x0380
36#define RESET_OFFSET 0x3c00 /* For reset file load */
37#define DATA_OFFSET 0x0100 /* For code and data files load */
38#define START_OFFSET 0x3ff0 /* 80186 starts here */
39
40/**
41 * struct cycx_hw - Adapter hardware configuration
42 * @fwid - firmware ID
43 * @irq - interrupt request level
44 * @dpmbase - dual-port memory base
45 * @dpmsize - dual-port memory size
46 * @reserved - reserved for future use
47 */
48struct cycx_hw {
49 u32 fwid;
50 int irq;
51 void __iomem *dpmbase;
52 u32 dpmsize;
53 u32 reserved[5];
54};
55
56/* Function Prototypes */
57extern int cycx_setup(struct cycx_hw *hw, void *sfm, u32 len, unsigned long base);
58extern int cycx_down(struct cycx_hw *hw);
59extern int cycx_peek(struct cycx_hw *hw, u32 addr, void *buf, u32 len);
60extern int cycx_poke(struct cycx_hw *hw, u32 addr, void *buf, u32 len);
61extern int cycx_exec(void __iomem *addr);
62
63extern void cycx_inten(struct cycx_hw *hw);
64extern void cycx_intr(struct cycx_hw *hw);
65#endif /* _CYCX_DRV_H */
diff --git a/include/linux/cycx_x25.h b/include/linux/cycx_x25.h
new file mode 100644
index 000000000000..b10a7f3a8cac
--- /dev/null
+++ b/include/linux/cycx_x25.h
@@ -0,0 +1,125 @@
1#ifndef _CYCX_X25_H
2#define _CYCX_X25_H
3/*
4* cycx_x25.h Cyclom X.25 firmware API definitions.
5*
6* Author: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
7*
8* Copyright: (c) 1998-2003 Arnaldo Carvalho de Melo
9*
10* Based on sdla_x25.h by Gene Kozin <74604.152@compuserve.com>
11*
12* This program is free software; you can redistribute it and/or
13* modify it under the terms of the GNU General Public License
14* as published by the Free Software Foundation; either version
15* 2 of the License, or (at your option) any later version.
16* ============================================================================
17* 2000/04/02 acme dprintk and cycx_debug
18* 1999/01/03 acme judicious use of data types
19* 1999/01/02 acme #define X25_ACK_N3 0x4411
20* 1998/12/28 acme cleanup: lot'o'things removed
21* commands listed,
22* TX25Cmd & TX25Config structs
23* typedef'ed
24*/
25#ifndef PACKED
26#define PACKED __attribute__((packed))
27#endif
28
29/* X.25 shared memory layout. */
30#define X25_MBOX_OFFS 0x300 /* general mailbox block */
31#define X25_RXMBOX_OFFS 0x340 /* receive mailbox */
32
33/* Debug */
34#define dprintk(level, format, a...) if (cycx_debug >= level) printk(format, ##a)
35
36extern unsigned int cycx_debug;
37
38/* Data Structures */
39/* X.25 Command Block. */
40struct cycx_x25_cmd {
41 u16 command PACKED;
42 u16 link PACKED; /* values: 0 or 1 */
43 u16 len PACKED; /* values: 0 thru 0x205 (517) */
44 u32 buf PACKED;
45};
46
47/* Defines for the 'command' field. */
48#define X25_CONNECT_REQUEST 0x4401
49#define X25_CONNECT_RESPONSE 0x4402
50#define X25_DISCONNECT_REQUEST 0x4403
51#define X25_DISCONNECT_RESPONSE 0x4404
52#define X25_DATA_REQUEST 0x4405
53#define X25_ACK_TO_VC 0x4406
54#define X25_INTERRUPT_RESPONSE 0x4407
55#define X25_CONFIG 0x4408
56#define X25_CONNECT_INDICATION 0x4409
57#define X25_CONNECT_CONFIRM 0x440A
58#define X25_DISCONNECT_INDICATION 0x440B
59#define X25_DISCONNECT_CONFIRM 0x440C
60#define X25_DATA_INDICATION 0x440E
61#define X25_INTERRUPT_INDICATION 0x440F
62#define X25_ACK_FROM_VC 0x4410
63#define X25_ACK_N3 0x4411
64#define X25_CONNECT_COLLISION 0x4413
65#define X25_N3WIN 0x4414
66#define X25_LINE_ON 0x4415
67#define X25_LINE_OFF 0x4416
68#define X25_RESET_REQUEST 0x4417
69#define X25_LOG 0x4500
70#define X25_STATISTIC 0x4600
71#define X25_TRACE 0x4700
72#define X25_N2TRACEXC 0x4702
73#define X25_N3TRACEXC 0x4703
74
75/**
76 * struct cycx_x25_config - cyclom2x x25 firmware configuration
77 * @link - link number
78 * @speed - line speed
79 * @clock - internal/external
80 * @n2 - # of level 2 retransm.(values: 1 thru FF)
81 * @n2win - level 2 window (values: 1 thru 7)
82 * @n3win - level 3 window (values: 1 thru 7)
83 * @nvc - # of logical channels (values: 1 thru 64)
84 * @pktlen - level 3 packet lenght - log base 2 of size
85 * @locaddr - my address
86 * @remaddr - remote address
87 * @t1 - time, in seconds
88 * @t2 - time, in seconds
89 * @t21 - time, in seconds
90 * @npvc - # of permanent virt. circuits (1 thru nvc)
91 * @t23 - time, in seconds
92 * @flags - see dosx25.doc, in portuguese, for details
93 */
94struct cycx_x25_config {
95 u8 link PACKED;
96 u8 speed PACKED;
97 u8 clock PACKED;
98 u8 n2 PACKED;
99 u8 n2win PACKED;
100 u8 n3win PACKED;
101 u8 nvc PACKED;
102 u8 pktlen PACKED;
103 u8 locaddr PACKED;
104 u8 remaddr PACKED;
105 u16 t1 PACKED;
106 u16 t2 PACKED;
107 u8 t21 PACKED;
108 u8 npvc PACKED;
109 u8 t23 PACKED;
110 u8 flags PACKED;
111};
112
113struct cycx_x25_stats {
114 u16 rx_crc_errors PACKED;
115 u16 rx_over_errors PACKED;
116 u16 n2_tx_frames PACKED;
117 u16 n2_rx_frames PACKED;
118 u16 tx_timeouts PACKED;
119 u16 rx_timeouts PACKED;
120 u16 n3_tx_packets PACKED;
121 u16 n3_rx_packets PACKED;
122 u16 tx_aborts PACKED;
123 u16 rx_aborts PACKED;
124};
125#endif /* _CYCX_X25_H */
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
new file mode 100644
index 000000000000..50be290d24d2
--- /dev/null
+++ b/include/linux/dcache.h
@@ -0,0 +1,338 @@
1#ifndef __LINUX_DCACHE_H
2#define __LINUX_DCACHE_H
3
4#ifdef __KERNEL__
5
6#include <asm/atomic.h>
7#include <linux/list.h>
8#include <linux/spinlock.h>
9#include <linux/cache.h>
10#include <linux/rcupdate.h>
11#include <asm/bug.h>
12
13struct nameidata;
14struct vfsmount;
15
16/*
17 * linux/include/linux/dcache.h
18 *
19 * Dirent cache data structures
20 *
21 * (C) Copyright 1997 Thomas Schoebel-Theuer,
22 * with heavy changes by Linus Torvalds
23 */
24
25#define IS_ROOT(x) ((x) == (x)->d_parent)
26
27/*
28 * "quick string" -- eases parameter passing, but more importantly
29 * saves "metadata" about the string (ie length and the hash).
30 *
31 * hash comes first so it snuggles against d_parent in the
32 * dentry.
33 */
34struct qstr {
35 unsigned int hash;
36 unsigned int len;
37 const unsigned char *name;
38};
39
40struct dentry_stat_t {
41 int nr_dentry;
42 int nr_unused;
43 int age_limit; /* age in seconds */
44 int want_pages; /* pages requested by system */
45 int dummy[2];
46};
47extern struct dentry_stat_t dentry_stat;
48
49/* Name hashing routines. Initial hash value */
50/* Hash courtesy of the R5 hash in reiserfs modulo sign bits */
51#define init_name_hash() 0
52
53/* partial hash update function. Assume roughly 4 bits per character */
54static inline unsigned long
55partial_name_hash(unsigned long c, unsigned long prevhash)
56{
57 return (prevhash + (c << 4) + (c >> 4)) * 11;
58}
59
60/*
61 * Finally: cut down the number of bits to a int value (and try to avoid
62 * losing bits)
63 */
64static inline unsigned long end_name_hash(unsigned long hash)
65{
66 return (unsigned int) hash;
67}
68
69/* Compute the hash for a name string. */
70static inline unsigned int
71full_name_hash(const unsigned char *name, unsigned int len)
72{
73 unsigned long hash = init_name_hash();
74 while (len--)
75 hash = partial_name_hash(*name++, hash);
76 return end_name_hash(hash);
77}
78
79struct dcookie_struct;
80
81#define DNAME_INLINE_LEN_MIN 36
82
83struct dentry {
84 atomic_t d_count;
85 unsigned int d_flags; /* protected by d_lock */
86 spinlock_t d_lock; /* per dentry lock */
87 struct inode *d_inode; /* Where the name belongs to - NULL is
88 * negative */
89 /*
90 * The next three fields are touched by __d_lookup. Place them here
91 * so they all fit in a 16-byte range, with 16-byte alignment.
92 */
93 struct dentry *d_parent; /* parent directory */
94 struct qstr d_name;
95
96 struct list_head d_lru; /* LRU list */
97 struct list_head d_child; /* child of parent list */
98 struct list_head d_subdirs; /* our children */
99 struct list_head d_alias; /* inode alias list */
100 unsigned long d_time; /* used by d_revalidate */
101 struct dentry_operations *d_op;
102 struct super_block *d_sb; /* The root of the dentry tree */
103 void *d_fsdata; /* fs-specific data */
104 struct rcu_head d_rcu;
105 struct dcookie_struct *d_cookie; /* cookie, if any */
106 struct hlist_node d_hash; /* lookup hash list */
107 int d_mounted;
108 unsigned char d_iname[DNAME_INLINE_LEN_MIN]; /* small names */
109};
110
111struct dentry_operations {
112 int (*d_revalidate)(struct dentry *, struct nameidata *);
113 int (*d_hash) (struct dentry *, struct qstr *);
114 int (*d_compare) (struct dentry *, struct qstr *, struct qstr *);
115 int (*d_delete)(struct dentry *);
116 void (*d_release)(struct dentry *);
117 void (*d_iput)(struct dentry *, struct inode *);
118};
119
120/* the dentry parameter passed to d_hash and d_compare is the parent
121 * directory of the entries to be compared. It is used in case these
122 * functions need any directory specific information for determining
123 * equivalency classes. Using the dentry itself might not work, as it
124 * might be a negative dentry which has no information associated with
125 * it */
126
127/*
128locking rules:
129 big lock dcache_lock d_lock may block
130d_revalidate: no no no yes
131d_hash no no no yes
132d_compare: no yes yes no
133d_delete: no yes no no
134d_release: no no no yes
135d_iput: no no no yes
136 */
137
138/* d_flags entries */
139#define DCACHE_AUTOFS_PENDING 0x0001 /* autofs: "under construction" */
140#define DCACHE_NFSFS_RENAMED 0x0002 /* this dentry has been "silly
141 * renamed" and has to be
142 * deleted on the last dput()
143 */
144#define DCACHE_DISCONNECTED 0x0004
145 /* This dentry is possibly not currently connected to the dcache tree,
146 * in which case its parent will either be itself, or will have this
147 * flag as well. nfsd will not use a dentry with this bit set, but will
148 * first endeavour to clear the bit either by discovering that it is
149 * connected, or by performing lookup operations. Any filesystem which
150 * supports nfsd_operations MUST have a lookup function which, if it finds
151 * a directory inode with a DCACHE_DISCONNECTED dentry, will d_move
152 * that dentry into place and return that dentry rather than the passed one,
153 * typically using d_splice_alias.
154 */
155
156#define DCACHE_REFERENCED 0x0008 /* Recently used, don't discard. */
157#define DCACHE_UNHASHED 0x0010
158
159extern spinlock_t dcache_lock;
160
161/**
162 * d_drop - drop a dentry
163 * @dentry: dentry to drop
164 *
165 * d_drop() unhashes the entry from the parent dentry hashes, so that it won't
166 * be found through a VFS lookup any more. Note that this is different from
167 * deleting the dentry - d_delete will try to mark the dentry negative if
168 * possible, giving a successful _negative_ lookup, while d_drop will
169 * just make the cache lookup fail.
170 *
171 * d_drop() is used mainly for stuff that wants to invalidate a dentry for some
172 * reason (NFS timeouts or autofs deletes).
173 *
174 * __d_drop requires dentry->d_lock.
175 */
176
177static inline void __d_drop(struct dentry *dentry)
178{
179 if (!(dentry->d_flags & DCACHE_UNHASHED)) {
180 dentry->d_flags |= DCACHE_UNHASHED;
181 hlist_del_rcu(&dentry->d_hash);
182 }
183}
184
185static inline void d_drop(struct dentry *dentry)
186{
187 spin_lock(&dcache_lock);
188 spin_lock(&dentry->d_lock);
189 __d_drop(dentry);
190 spin_unlock(&dentry->d_lock);
191 spin_unlock(&dcache_lock);
192}
193
194static inline int dname_external(struct dentry *dentry)
195{
196 return dentry->d_name.name != dentry->d_iname;
197}
198
199/*
200 * These are the low-level FS interfaces to the dcache..
201 */
202extern void d_instantiate(struct dentry *, struct inode *);
203extern struct dentry * d_instantiate_unique(struct dentry *, struct inode *);
204extern void d_delete(struct dentry *);
205
206/* allocate/de-allocate */
207extern struct dentry * d_alloc(struct dentry *, const struct qstr *);
208extern struct dentry * d_alloc_anon(struct inode *);
209extern struct dentry * d_splice_alias(struct inode *, struct dentry *);
210extern void shrink_dcache_sb(struct super_block *);
211extern void shrink_dcache_parent(struct dentry *);
212extern void shrink_dcache_anon(struct hlist_head *);
213extern int d_invalidate(struct dentry *);
214
215/* only used at mount-time */
216extern struct dentry * d_alloc_root(struct inode *);
217
218/* <clickety>-<click> the ramfs-type tree */
219extern void d_genocide(struct dentry *);
220
221extern struct dentry *d_find_alias(struct inode *);
222extern void d_prune_aliases(struct inode *);
223
224/* test whether we have any submounts in a subdir tree */
225extern int have_submounts(struct dentry *);
226
227/*
228 * This adds the entry to the hash queues.
229 */
230extern void d_rehash(struct dentry *);
231
232/**
233 * d_add - add dentry to hash queues
234 * @entry: dentry to add
235 * @inode: The inode to attach to this dentry
236 *
237 * This adds the entry to the hash queues and initializes @inode.
238 * The entry was actually filled in earlier during d_alloc().
239 */
240
241static inline void d_add(struct dentry *entry, struct inode *inode)
242{
243 d_instantiate(entry, inode);
244 d_rehash(entry);
245}
246
247/**
248 * d_add_unique - add dentry to hash queues without aliasing
249 * @entry: dentry to add
250 * @inode: The inode to attach to this dentry
251 *
252 * This adds the entry to the hash queues and initializes @inode.
253 * The entry was actually filled in earlier during d_alloc().
254 */
255static inline struct dentry *d_add_unique(struct dentry *entry, struct inode *inode)
256{
257 struct dentry *res;
258
259 res = d_instantiate_unique(entry, inode);
260 d_rehash(res != NULL ? res : entry);
261 return res;
262}
263
264/* used for rename() and baskets */
265extern void d_move(struct dentry *, struct dentry *);
266
267/* appendix may either be NULL or be used for transname suffixes */
268extern struct dentry * d_lookup(struct dentry *, struct qstr *);
269extern struct dentry * __d_lookup(struct dentry *, struct qstr *);
270
271/* validate "insecure" dentry pointer */
272extern int d_validate(struct dentry *, struct dentry *);
273
274extern char * d_path(struct dentry *, struct vfsmount *, char *, int);
275
276/* Allocation counts.. */
277
278/**
279 * dget, dget_locked - get a reference to a dentry
280 * @dentry: dentry to get a reference to
281 *
282 * Given a dentry or %NULL pointer increment the reference count
283 * if appropriate and return the dentry. A dentry will not be
284 * destroyed when it has references. dget() should never be
285 * called for dentries with zero reference counter. For these cases
286 * (preferably none, functions in dcache.c are sufficient for normal
287 * needs and they take necessary precautions) you should hold dcache_lock
288 * and call dget_locked() instead of dget().
289 */
290
291static inline struct dentry *dget(struct dentry *dentry)
292{
293 if (dentry) {
294 BUG_ON(!atomic_read(&dentry->d_count));
295 atomic_inc(&dentry->d_count);
296 }
297 return dentry;
298}
299
300extern struct dentry * dget_locked(struct dentry *);
301
302/**
303 * d_unhashed - is dentry hashed
304 * @dentry: entry to check
305 *
306 * Returns true if the dentry passed is not currently hashed.
307 */
308
309static inline int d_unhashed(struct dentry *dentry)
310{
311 return (dentry->d_flags & DCACHE_UNHASHED);
312}
313
314static inline struct dentry *dget_parent(struct dentry *dentry)
315{
316 struct dentry *ret;
317
318 spin_lock(&dentry->d_lock);
319 ret = dget(dentry->d_parent);
320 spin_unlock(&dentry->d_lock);
321 return ret;
322}
323
324extern void dput(struct dentry *);
325
326static inline int d_mountpoint(struct dentry *dentry)
327{
328 return dentry->d_mounted;
329}
330
331extern struct vfsmount *lookup_mnt(struct vfsmount *, struct dentry *);
332extern struct dentry *lookup_create(struct nameidata *nd, int is_dir);
333
334extern int sysctl_vfs_cache_pressure;
335
336#endif /* __KERNEL__ */
337
338#endif /* __LINUX_DCACHE_H */
diff --git a/include/linux/dcookies.h b/include/linux/dcookies.h
new file mode 100644
index 000000000000..c28050136164
--- /dev/null
+++ b/include/linux/dcookies.h
@@ -0,0 +1,69 @@
1/*
2 * dcookies.h
3 *
4 * Persistent cookie-path mappings
5 *
6 * Copyright 2002 John Levon <levon@movementarian.org>
7 */
8
9#ifndef DCOOKIES_H
10#define DCOOKIES_H
11
12#include <linux/config.h>
13
14#ifdef CONFIG_PROFILING
15
16#include <linux/types.h>
17
18struct dcookie_user;
19
20/**
21 * dcookie_register - register a user of dcookies
22 *
23 * Register as a dcookie user. Returns %NULL on failure.
24 */
25struct dcookie_user * dcookie_register(void);
26
27/**
28 * dcookie_unregister - unregister a user of dcookies
29 *
30 * Unregister as a dcookie user. This may invalidate
31 * any dcookie values returned from get_dcookie().
32 */
33void dcookie_unregister(struct dcookie_user * user);
34
35/**
36 * get_dcookie - acquire a dcookie
37 *
38 * Convert the given dentry/vfsmount pair into
39 * a cookie value.
40 *
41 * Returns -EINVAL if no living task has registered as a
42 * dcookie user.
43 *
44 * Returns 0 on success, with *cookie filled in
45 */
46int get_dcookie(struct dentry * dentry, struct vfsmount * vfsmnt,
47 unsigned long * cookie);
48
49#else
50
51struct dcookie_user * dcookie_register(void)
52{
53 return NULL;
54}
55
56void dcookie_unregister(struct dcookie_user * user)
57{
58 return;
59}
60
61static inline int get_dcookie(struct dentry * dentry,
62 struct vfsmount * vfsmnt, unsigned long * cookie)
63{
64 return -ENOSYS;
65}
66
67#endif /* CONFIG_PROFILING */
68
69#endif /* DCOOKIES_H */
diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h
new file mode 100644
index 000000000000..f7a7b86f6eef
--- /dev/null
+++ b/include/linux/debugfs.h
@@ -0,0 +1,92 @@
1/*
2 * debugfs.h - a tiny little debug file system
3 *
4 * Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.com>
5 * Copyright (C) 2004 IBM Inc.
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 version
9 * 2 as published by the Free Software Foundation.
10 *
11 * debugfs is for people to use instead of /proc or /sys.
12 * See Documentation/DocBook/kernel-api for more details.
13 */
14
15#ifndef _DEBUGFS_H_
16#define _DEBUGFS_H_
17
18#include <linux/fs.h>
19
20#if defined(CONFIG_DEBUG_FS)
21struct dentry *debugfs_create_file(const char *name, mode_t mode,
22 struct dentry *parent, void *data,
23 struct file_operations *fops);
24
25struct dentry *debugfs_create_dir(const char *name, struct dentry *parent);
26
27void debugfs_remove(struct dentry *dentry);
28
29struct dentry *debugfs_create_u8(const char *name, mode_t mode,
30 struct dentry *parent, u8 *value);
31struct dentry *debugfs_create_u16(const char *name, mode_t mode,
32 struct dentry *parent, u16 *value);
33struct dentry *debugfs_create_u32(const char *name, mode_t mode,
34 struct dentry *parent, u32 *value);
35struct dentry *debugfs_create_bool(const char *name, mode_t mode,
36 struct dentry *parent, u32 *value);
37
38#else
39/*
40 * We do not return NULL from these functions if CONFIG_DEBUG_FS is not enabled
41 * so users have a chance to detect if there was a real error or not. We don't
42 * want to duplicate the design decision mistakes of procfs and devfs again.
43 */
44
45static inline struct dentry *debugfs_create_file(const char *name, mode_t mode,
46 struct dentry *parent,
47 void *data,
48 struct file_operations *fops)
49{
50 return ERR_PTR(-ENODEV);
51}
52
53static inline struct dentry *debugfs_create_dir(const char *name,
54 struct dentry *parent)
55{
56 return ERR_PTR(-ENODEV);
57}
58
59static inline void debugfs_remove(struct dentry *dentry)
60{ }
61
62static inline struct dentry *debugfs_create_u8(const char *name, mode_t mode,
63 struct dentry *parent,
64 u8 *value)
65{
66 return ERR_PTR(-ENODEV);
67}
68
69static inline struct dentry *debugfs_create_u16(const char *name, mode_t mode,
70 struct dentry *parent,
71 u8 *value)
72{
73 return ERR_PTR(-ENODEV);
74}
75
76static inline struct dentry *debugfs_create_u32(const char *name, mode_t mode,
77 struct dentry *parent,
78 u8 *value)
79{
80 return ERR_PTR(-ENODEV);
81}
82
83static inline struct dentry *debugfs_create_bool(const char *name, mode_t mode,
84 struct dentry *parent,
85 u8 *value)
86{
87 return ERR_PTR(-ENODEV);
88}
89
90#endif
91
92#endif
diff --git a/include/linux/delay.h b/include/linux/delay.h
new file mode 100644
index 000000000000..acb74865b973
--- /dev/null
+++ b/include/linux/delay.h
@@ -0,0 +1,50 @@
1#ifndef _LINUX_DELAY_H
2#define _LINUX_DELAY_H
3
4/*
5 * Copyright (C) 1993 Linus Torvalds
6 *
7 * Delay routines, using a pre-computed "loops_per_jiffy" value.
8 */
9
10extern unsigned long loops_per_jiffy;
11
12#include <asm/delay.h>
13
14/*
15 * Using udelay() for intervals greater than a few milliseconds can
16 * risk overflow for high loops_per_jiffy (high bogomips) machines. The
17 * mdelay() provides a wrapper to prevent this. For delays greater
18 * than MAX_UDELAY_MS milliseconds, the wrapper is used. Architecture
19 * specific values can be defined in asm-???/delay.h as an override.
20 * The 2nd mdelay() definition ensures GCC will optimize away the
21 * while loop for the common cases where n <= MAX_UDELAY_MS -- Paul G.
22 */
23
24#ifndef MAX_UDELAY_MS
25#define MAX_UDELAY_MS 5
26#endif
27
28#ifdef notdef
29#define mdelay(n) (\
30 {unsigned long __ms=(n); while (__ms--) udelay(1000);})
31#else
32#define mdelay(n) (\
33 (__builtin_constant_p(n) && (n)<=MAX_UDELAY_MS) ? udelay((n)*1000) : \
34 ({unsigned long __ms=(n); while (__ms--) udelay(1000);}))
35#endif
36
37#ifndef ndelay
38#define ndelay(x) udelay(((x)+999)/1000)
39#endif
40
41void calibrate_delay(void);
42void msleep(unsigned int msecs);
43unsigned long msleep_interruptible(unsigned int msecs);
44
45static inline void ssleep(unsigned int seconds)
46{
47 msleep(seconds * 1000);
48}
49
50#endif /* defined(_LINUX_DELAY_H) */
diff --git a/include/linux/devfs_fs.h b/include/linux/devfs_fs.h
new file mode 100644
index 000000000000..de236f431877
--- /dev/null
+++ b/include/linux/devfs_fs.h
@@ -0,0 +1,41 @@
1#ifndef _LINUX_DEVFS_FS_H
2#define _LINUX_DEVFS_FS_H
3
4#include <linux/ioctl.h>
5
6#define DEVFSD_PROTOCOL_REVISION_KERNEL 5
7
8#define DEVFSD_IOCTL_BASE 'd'
9
10/* These are the various ioctls */
11#define DEVFSDIOC_GET_PROTO_REV _IOR(DEVFSD_IOCTL_BASE, 0, int)
12#define DEVFSDIOC_SET_EVENT_MASK _IOW(DEVFSD_IOCTL_BASE, 2, int)
13#define DEVFSDIOC_RELEASE_EVENT_QUEUE _IOW(DEVFSD_IOCTL_BASE, 3, int)
14#define DEVFSDIOC_SET_DEBUG_MASK _IOW(DEVFSD_IOCTL_BASE, 4, int)
15
16#define DEVFSD_NOTIFY_REGISTERED 0
17#define DEVFSD_NOTIFY_UNREGISTERED 1
18#define DEVFSD_NOTIFY_ASYNC_OPEN 2
19#define DEVFSD_NOTIFY_CLOSE 3
20#define DEVFSD_NOTIFY_LOOKUP 4
21#define DEVFSD_NOTIFY_CHANGE 5
22#define DEVFSD_NOTIFY_CREATE 6
23#define DEVFSD_NOTIFY_DELETE 7
24
25#define DEVFS_PATHLEN 1024 /* Never change this otherwise the
26 binary interface will change */
27
28struct devfsd_notify_struct { /* Use native C types to ensure same types in kernel and user space */
29 unsigned int type; /* DEVFSD_NOTIFY_* value */
30 unsigned int mode; /* Mode of the inode or device entry */
31 unsigned int major; /* Major number of device entry */
32 unsigned int minor; /* Minor number of device entry */
33 unsigned int uid; /* Uid of process, inode or device entry */
34 unsigned int gid; /* Gid of process, inode or device entry */
35 unsigned int overrun_count; /* Number of lost events */
36 unsigned int namelen; /* Number of characters not including '\0' */
37 /* The device name MUST come last */
38 char devname[DEVFS_PATHLEN]; /* This will be '\0' terminated */
39};
40
41#endif /* _LINUX_DEVFS_FS_H */
diff --git a/include/linux/devfs_fs_kernel.h b/include/linux/devfs_fs_kernel.h
new file mode 100644
index 000000000000..89810e73d256
--- /dev/null
+++ b/include/linux/devfs_fs_kernel.h
@@ -0,0 +1,58 @@
1#ifndef _LINUX_DEVFS_FS_KERNEL_H
2#define _LINUX_DEVFS_FS_KERNEL_H
3
4#include <linux/fs.h>
5#include <linux/config.h>
6#include <linux/spinlock.h>
7#include <linux/types.h>
8
9#include <asm/semaphore.h>
10
11#define DEVFS_SUPER_MAGIC 0x1373
12
13#ifdef CONFIG_DEVFS_FS
14extern int devfs_mk_bdev(dev_t dev, umode_t mode, const char *fmt, ...)
15 __attribute__ ((format(printf, 3, 4)));
16extern int devfs_mk_cdev(dev_t dev, umode_t mode, const char *fmt, ...)
17 __attribute__ ((format(printf, 3, 4)));
18extern int devfs_mk_symlink(const char *name, const char *link);
19extern int devfs_mk_dir(const char *fmt, ...)
20 __attribute__ ((format(printf, 1, 2)));
21extern void devfs_remove(const char *fmt, ...)
22 __attribute__ ((format(printf, 1, 2)));
23extern int devfs_register_tape(const char *name);
24extern void devfs_unregister_tape(int num);
25extern void mount_devfs_fs(void);
26#else /* CONFIG_DEVFS_FS */
27static inline int devfs_mk_bdev(dev_t dev, umode_t mode, const char *fmt, ...)
28{
29 return 0;
30}
31static inline int devfs_mk_cdev(dev_t dev, umode_t mode, const char *fmt, ...)
32{
33 return 0;
34}
35static inline int devfs_mk_symlink(const char *name, const char *link)
36{
37 return 0;
38}
39static inline int devfs_mk_dir(const char *fmt, ...)
40{
41 return 0;
42}
43static inline void devfs_remove(const char *fmt, ...)
44{
45}
46static inline int devfs_register_tape(const char *name)
47{
48 return -1;
49}
50static inline void devfs_unregister_tape(int num)
51{
52}
53static inline void mount_devfs_fs(void)
54{
55 return;
56}
57#endif /* CONFIG_DEVFS_FS */
58#endif /* _LINUX_DEVFS_FS_KERNEL_H */
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h
new file mode 100644
index 000000000000..83c7d207b80e
--- /dev/null
+++ b/include/linux/device-mapper.h
@@ -0,0 +1,130 @@
1/*
2 * Copyright (C) 2001 Sistina Software (UK) Limited.
3 * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
4 *
5 * This file is released under the LGPL.
6 */
7
8#ifndef _LINUX_DEVICE_MAPPER_H
9#define _LINUX_DEVICE_MAPPER_H
10
11struct dm_target;
12struct dm_table;
13struct dm_dev;
14
15typedef enum { STATUSTYPE_INFO, STATUSTYPE_TABLE } status_type_t;
16
17union map_info {
18 void *ptr;
19 unsigned long long ll;
20};
21
22/*
23 * In the constructor the target parameter will already have the
24 * table, type, begin and len fields filled in.
25 */
26typedef int (*dm_ctr_fn) (struct dm_target *target,
27 unsigned int argc, char **argv);
28
29/*
30 * The destructor doesn't need to free the dm_target, just
31 * anything hidden ti->private.
32 */
33typedef void (*dm_dtr_fn) (struct dm_target *ti);
34
35/*
36 * The map function must return:
37 * < 0: error
38 * = 0: The target will handle the io by resubmitting it later
39 * > 0: simple remap complete
40 */
41typedef int (*dm_map_fn) (struct dm_target *ti, struct bio *bio,
42 union map_info *map_context);
43
44/*
45 * Returns:
46 * < 0 : error (currently ignored)
47 * 0 : ended successfully
48 * 1 : for some reason the io has still not completed (eg,
49 * multipath target might want to requeue a failed io).
50 */
51typedef int (*dm_endio_fn) (struct dm_target *ti,
52 struct bio *bio, int error,
53 union map_info *map_context);
54
55typedef void (*dm_presuspend_fn) (struct dm_target *ti);
56typedef void (*dm_postsuspend_fn) (struct dm_target *ti);
57typedef void (*dm_resume_fn) (struct dm_target *ti);
58
59typedef int (*dm_status_fn) (struct dm_target *ti, status_type_t status_type,
60 char *result, unsigned int maxlen);
61
62typedef int (*dm_message_fn) (struct dm_target *ti, unsigned argc, char **argv);
63
64void dm_error(const char *message);
65
66/*
67 * Constructors should call these functions to ensure destination devices
68 * are opened/closed correctly.
69 * FIXME: too many arguments.
70 */
71int dm_get_device(struct dm_target *ti, const char *path, sector_t start,
72 sector_t len, int mode, struct dm_dev **result);
73void dm_put_device(struct dm_target *ti, struct dm_dev *d);
74
75/*
76 * Information about a target type
77 */
78struct target_type {
79 const char *name;
80 struct module *module;
81 unsigned version[3];
82 dm_ctr_fn ctr;
83 dm_dtr_fn dtr;
84 dm_map_fn map;
85 dm_endio_fn end_io;
86 dm_presuspend_fn presuspend;
87 dm_postsuspend_fn postsuspend;
88 dm_resume_fn resume;
89 dm_status_fn status;
90 dm_message_fn message;
91};
92
93struct io_restrictions {
94 unsigned short max_sectors;
95 unsigned short max_phys_segments;
96 unsigned short max_hw_segments;
97 unsigned short hardsect_size;
98 unsigned int max_segment_size;
99 unsigned long seg_boundary_mask;
100};
101
102struct dm_target {
103 struct dm_table *table;
104 struct target_type *type;
105
106 /* target limits */
107 sector_t begin;
108 sector_t len;
109
110 /* FIXME: turn this into a mask, and merge with io_restrictions */
111 /* Always a power of 2 */
112 sector_t split_io;
113
114 /*
115 * These are automatically filled in by
116 * dm_table_get_device.
117 */
118 struct io_restrictions limits;
119
120 /* target specific data */
121 void *private;
122
123 /* Used to provide an error string from the ctr */
124 char *error;
125};
126
127int dm_register_target(struct target_type *t);
128int dm_unregister_target(struct target_type *t);
129
130#endif /* _LINUX_DEVICE_MAPPER_H */
diff --git a/include/linux/device.h b/include/linux/device.h
new file mode 100644
index 000000000000..cf470459fa69
--- /dev/null
+++ b/include/linux/device.h
@@ -0,0 +1,426 @@
1/*
2 * device.h - generic, centralized driver model
3 *
4 * Copyright (c) 2001-2003 Patrick Mochel <mochel@osdl.org>
5 *
6 * This file is released under the GPLv2
7 *
8 * See Documentation/driver-model/ for more information.
9 */
10
11#ifndef _DEVICE_H_
12#define _DEVICE_H_
13
14#include <linux/config.h>
15#include <linux/ioport.h>
16#include <linux/kobject.h>
17#include <linux/list.h>
18#include <linux/types.h>
19#include <linux/module.h>
20#include <linux/pm.h>
21#include <asm/semaphore.h>
22#include <asm/atomic.h>
23
24#define DEVICE_NAME_SIZE 50
25#define DEVICE_NAME_HALF __stringify(20) /* Less than half to accommodate slop */
26#define DEVICE_ID_SIZE 32
27#define BUS_ID_SIZE KOBJ_NAME_LEN
28
29
30enum {
31 SUSPEND_NOTIFY,
32 SUSPEND_SAVE_STATE,
33 SUSPEND_DISABLE,
34 SUSPEND_POWER_DOWN,
35};
36
37enum {
38 RESUME_POWER_ON,
39 RESUME_RESTORE_STATE,
40 RESUME_ENABLE,
41};
42
43struct device;
44struct device_driver;
45struct class;
46struct class_device;
47struct class_simple;
48
49struct bus_type {
50 char * name;
51
52 struct subsystem subsys;
53 struct kset drivers;
54 struct kset devices;
55
56 struct bus_attribute * bus_attrs;
57 struct device_attribute * dev_attrs;
58 struct driver_attribute * drv_attrs;
59
60 int (*match)(struct device * dev, struct device_driver * drv);
61 int (*hotplug) (struct device *dev, char **envp,
62 int num_envp, char *buffer, int buffer_size);
63 int (*suspend)(struct device * dev, pm_message_t state);
64 int (*resume)(struct device * dev);
65};
66
67extern int bus_register(struct bus_type * bus);
68extern void bus_unregister(struct bus_type * bus);
69
70extern int bus_rescan_devices(struct bus_type * bus);
71
72extern struct bus_type * get_bus(struct bus_type * bus);
73extern void put_bus(struct bus_type * bus);
74
75extern struct bus_type * find_bus(char * name);
76
77/* iterator helpers for buses */
78
79int bus_for_each_dev(struct bus_type * bus, struct device * start, void * data,
80 int (*fn)(struct device *, void *));
81
82int bus_for_each_drv(struct bus_type * bus, struct device_driver * start,
83 void * data, int (*fn)(struct device_driver *, void *));
84
85
86/* driverfs interface for exporting bus attributes */
87
88struct bus_attribute {
89 struct attribute attr;
90 ssize_t (*show)(struct bus_type *, char * buf);
91 ssize_t (*store)(struct bus_type *, const char * buf, size_t count);
92};
93
94#define BUS_ATTR(_name,_mode,_show,_store) \
95struct bus_attribute bus_attr_##_name = __ATTR(_name,_mode,_show,_store)
96
97extern int bus_create_file(struct bus_type *, struct bus_attribute *);
98extern void bus_remove_file(struct bus_type *, struct bus_attribute *);
99
100struct device_driver {
101 char * name;
102 struct bus_type * bus;
103
104 struct completion unloaded;
105 struct kobject kobj;
106 struct list_head devices;
107
108 struct module * owner;
109
110 int (*probe) (struct device * dev);
111 int (*remove) (struct device * dev);
112 void (*shutdown) (struct device * dev);
113 int (*suspend) (struct device * dev, pm_message_t state, u32 level);
114 int (*resume) (struct device * dev, u32 level);
115};
116
117
118extern int driver_register(struct device_driver * drv);
119extern void driver_unregister(struct device_driver * drv);
120
121extern struct device_driver * get_driver(struct device_driver * drv);
122extern void put_driver(struct device_driver * drv);
123extern struct device_driver *driver_find(const char *name, struct bus_type *bus);
124
125
126/* driverfs interface for exporting driver attributes */
127
128struct driver_attribute {
129 struct attribute attr;
130 ssize_t (*show)(struct device_driver *, char * buf);
131 ssize_t (*store)(struct device_driver *, const char * buf, size_t count);
132};
133
134#define DRIVER_ATTR(_name,_mode,_show,_store) \
135struct driver_attribute driver_attr_##_name = __ATTR(_name,_mode,_show,_store)
136
137extern int driver_create_file(struct device_driver *, struct driver_attribute *);
138extern void driver_remove_file(struct device_driver *, struct driver_attribute *);
139
140
141/*
142 * device classes
143 */
144struct class {
145 char * name;
146
147 struct subsystem subsys;
148 struct list_head children;
149 struct list_head interfaces;
150 struct semaphore sem; /* locks both the children and interfaces lists */
151
152 struct class_attribute * class_attrs;
153 struct class_device_attribute * class_dev_attrs;
154
155 int (*hotplug)(struct class_device *dev, char **envp,
156 int num_envp, char *buffer, int buffer_size);
157
158 void (*release)(struct class_device *dev);
159 void (*class_release)(struct class *class);
160};
161
162extern int class_register(struct class *);
163extern void class_unregister(struct class *);
164
165extern struct class * class_get(struct class *);
166extern void class_put(struct class *);
167
168
169struct class_attribute {
170 struct attribute attr;
171 ssize_t (*show)(struct class *, char * buf);
172 ssize_t (*store)(struct class *, const char * buf, size_t count);
173};
174
175#define CLASS_ATTR(_name,_mode,_show,_store) \
176struct class_attribute class_attr_##_name = __ATTR(_name,_mode,_show,_store)
177
178extern int class_create_file(struct class *, const struct class_attribute *);
179extern void class_remove_file(struct class *, const struct class_attribute *);
180
181
182struct class_device {
183 struct list_head node;
184
185 struct kobject kobj;
186 struct class * class; /* required */
187 dev_t devt; /* dev_t, creates the sysfs "dev" */
188 struct device * dev; /* not necessary, but nice to have */
189 void * class_data; /* class-specific data */
190
191 char class_id[BUS_ID_SIZE]; /* unique to this class */
192};
193
194static inline void *
195class_get_devdata (struct class_device *dev)
196{
197 return dev->class_data;
198}
199
200static inline void
201class_set_devdata (struct class_device *dev, void *data)
202{
203 dev->class_data = data;
204}
205
206
207extern int class_device_register(struct class_device *);
208extern void class_device_unregister(struct class_device *);
209extern void class_device_initialize(struct class_device *);
210extern int class_device_add(struct class_device *);
211extern void class_device_del(struct class_device *);
212
213extern int class_device_rename(struct class_device *, char *);
214
215extern struct class_device * class_device_get(struct class_device *);
216extern void class_device_put(struct class_device *);
217
218struct class_device_attribute {
219 struct attribute attr;
220 ssize_t (*show)(struct class_device *, char * buf);
221 ssize_t (*store)(struct class_device *, const char * buf, size_t count);
222};
223
224#define CLASS_DEVICE_ATTR(_name,_mode,_show,_store) \
225struct class_device_attribute class_device_attr_##_name = \
226 __ATTR(_name,_mode,_show,_store)
227
228extern int class_device_create_file(struct class_device *,
229 const struct class_device_attribute *);
230extern void class_device_remove_file(struct class_device *,
231 const struct class_device_attribute *);
232extern int class_device_create_bin_file(struct class_device *,
233 struct bin_attribute *);
234extern void class_device_remove_bin_file(struct class_device *,
235 struct bin_attribute *);
236
237struct class_interface {
238 struct list_head node;
239 struct class *class;
240
241 int (*add) (struct class_device *);
242 void (*remove) (struct class_device *);
243};
244
245extern int class_interface_register(struct class_interface *);
246extern void class_interface_unregister(struct class_interface *);
247
248/* interface for class simple stuff */
249extern struct class_simple *class_simple_create(struct module *owner, char *name);
250extern void class_simple_destroy(struct class_simple *cs);
251extern struct class_device *class_simple_device_add(struct class_simple *cs, dev_t dev, struct device *device, const char *fmt, ...)
252 __attribute__((format(printf,4,5)));
253extern int class_simple_set_hotplug(struct class_simple *,
254 int (*hotplug)(struct class_device *dev, char **envp, int num_envp, char *buffer, int buffer_size));
255extern void class_simple_device_remove(dev_t dev);
256
257
258struct device {
259 struct list_head node; /* node in sibling list */
260 struct list_head bus_list; /* node in bus's list */
261 struct list_head driver_list;
262 struct list_head children;
263 struct device * parent;
264
265 struct kobject kobj;
266 char bus_id[BUS_ID_SIZE]; /* position on parent bus */
267
268 struct bus_type * bus; /* type of bus device is on */
269 struct device_driver *driver; /* which driver has allocated this
270 device */
271 void *driver_data; /* data private to the driver */
272 void *platform_data; /* Platform specific data (e.g. ACPI,
273 BIOS data relevant to device) */
274 struct dev_pm_info power;
275
276 u32 detach_state; /* State to enter when device is
277 detached from its driver. */
278
279 u64 *dma_mask; /* dma mask (if dma'able device) */
280 u64 coherent_dma_mask;/* Like dma_mask, but for
281 alloc_coherent mappings as
282 not all hardware supports
283 64 bit addresses for consistent
284 allocations such descriptors. */
285
286 struct list_head dma_pools; /* dma pools (if dma'ble) */
287
288 struct dma_coherent_mem *dma_mem; /* internal for coherent mem
289 override */
290
291 void (*release)(struct device * dev);
292};
293
294static inline struct device *
295list_to_dev(struct list_head *node)
296{
297 return list_entry(node, struct device, node);
298}
299
300static inline void *
301dev_get_drvdata (struct device *dev)
302{
303 return dev->driver_data;
304}
305
306static inline void
307dev_set_drvdata (struct device *dev, void *data)
308{
309 dev->driver_data = data;
310}
311
312/*
313 * High level routines for use by the bus drivers
314 */
315extern int device_register(struct device * dev);
316extern void device_unregister(struct device * dev);
317extern void device_initialize(struct device * dev);
318extern int device_add(struct device * dev);
319extern void device_del(struct device * dev);
320extern int device_for_each_child(struct device *, void *,
321 int (*fn)(struct device *, void *));
322
323/*
324 * Manual binding of a device to driver. See drivers/base/bus.c
325 * for information on use.
326 */
327extern int driver_probe_device(struct device_driver * drv, struct device * dev);
328extern void device_bind_driver(struct device * dev);
329extern void device_release_driver(struct device * dev);
330extern int device_attach(struct device * dev);
331extern void driver_attach(struct device_driver * drv);
332
333
334/* driverfs interface for exporting device attributes */
335
336struct device_attribute {
337 struct attribute attr;
338 ssize_t (*show)(struct device * dev, char * buf);
339 ssize_t (*store)(struct device * dev, const char * buf, size_t count);
340};
341
342#define DEVICE_ATTR(_name,_mode,_show,_store) \
343struct device_attribute dev_attr_##_name = __ATTR(_name,_mode,_show,_store)
344
345
346extern int device_create_file(struct device *device, struct device_attribute * entry);
347extern void device_remove_file(struct device * dev, struct device_attribute * attr);
348
349/*
350 * Platform "fixup" functions - allow the platform to have their say
351 * about devices and actions that the general device layer doesn't
352 * know about.
353 */
354/* Notify platform of device discovery */
355extern int (*platform_notify)(struct device * dev);
356
357extern int (*platform_notify_remove)(struct device * dev);
358
359
360/**
361 * get_device - atomically increment the reference count for the device.
362 *
363 */
364extern struct device * get_device(struct device * dev);
365extern void put_device(struct device * dev);
366extern struct device *device_find(const char *name, struct bus_type *bus);
367
368
369/* drivers/base/platform.c */
370
371struct platform_device {
372 char * name;
373 u32 id;
374 struct device dev;
375 u32 num_resources;
376 struct resource * resource;
377};
378
379#define to_platform_device(x) container_of((x), struct platform_device, dev)
380
381extern int platform_device_register(struct platform_device *);
382extern void platform_device_unregister(struct platform_device *);
383
384extern struct bus_type platform_bus_type;
385extern struct device platform_bus;
386
387extern struct resource *platform_get_resource(struct platform_device *, unsigned int, unsigned int);
388extern int platform_get_irq(struct platform_device *, unsigned int);
389extern struct resource *platform_get_resource_byname(struct platform_device *, unsigned int, char *);
390extern int platform_get_irq_byname(struct platform_device *, char *);
391extern int platform_add_devices(struct platform_device **, int);
392
393extern struct platform_device *platform_device_register_simple(char *, unsigned int, struct resource *, unsigned int);
394
395/* drivers/base/power.c */
396extern void device_shutdown(void);
397
398
399/* drivers/base/firmware.c */
400extern int firmware_register(struct subsystem *);
401extern void firmware_unregister(struct subsystem *);
402
403/* debugging and troubleshooting/diagnostic helpers. */
404#define dev_printk(level, dev, format, arg...) \
405 printk(level "%s %s: " format , (dev)->driver ? (dev)->driver->name : "" , (dev)->bus_id , ## arg)
406
407#ifdef DEBUG
408#define dev_dbg(dev, format, arg...) \
409 dev_printk(KERN_DEBUG , dev , format , ## arg)
410#else
411#define dev_dbg(dev, format, arg...) do { (void)(dev); } while (0)
412#endif
413
414#define dev_err(dev, format, arg...) \
415 dev_printk(KERN_ERR , dev , format , ## arg)
416#define dev_info(dev, format, arg...) \
417 dev_printk(KERN_INFO , dev , format , ## arg)
418#define dev_warn(dev, format, arg...) \
419 dev_printk(KERN_WARNING , dev , format , ## arg)
420
421/* Create alias, so I can be autoloaded. */
422#define MODULE_ALIAS_CHARDEV(major,minor) \
423 MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor))
424#define MODULE_ALIAS_CHARDEV_MAJOR(major) \
425 MODULE_ALIAS("char-major-" __stringify(major) "-*")
426#endif /* _DEVICE_H_ */
diff --git a/include/linux/devpts_fs.h b/include/linux/devpts_fs.h
new file mode 100644
index 000000000000..b672ddc00735
--- /dev/null
+++ b/include/linux/devpts_fs.h
@@ -0,0 +1,34 @@
1/* -*- linux-c -*- --------------------------------------------------------- *
2 *
3 * linux/include/linux/devpts_fs.h
4 *
5 * Copyright 1998-2004 H. Peter Anvin -- All Rights Reserved
6 *
7 * This file is part of the Linux kernel and is made available under
8 * the terms of the GNU General Public License, version 2, or at your
9 * option, any later version, incorporated herein by reference.
10 *
11 * ------------------------------------------------------------------------- */
12
13#ifndef _LINUX_DEVPTS_FS_H
14#define _LINUX_DEVPTS_FS_H
15
16#include <linux/errno.h>
17
18#ifdef CONFIG_UNIX98_PTYS
19
20int devpts_pty_new(struct tty_struct *tty); /* mknod in devpts */
21struct tty_struct *devpts_get_tty(int number); /* get tty structure */
22void devpts_pty_kill(int number); /* unlink */
23
24#else
25
26/* Dummy stubs in the no-pty case */
27static inline int devpts_pty_new(struct tty_struct *tty) { return -EINVAL; }
28static inline struct tty_struct *devpts_get_tty(int number) { return NULL; }
29static inline void devpts_pty_kill(int number) { }
30
31#endif
32
33
34#endif /* _LINUX_DEVPTS_FS_H */
diff --git a/include/linux/dio.h b/include/linux/dio.h
new file mode 100644
index 000000000000..fae9395fcf4f
--- /dev/null
+++ b/include/linux/dio.h
@@ -0,0 +1,312 @@
1/* header file for DIO boards for the HP300 architecture.
2 * Maybe this should handle DIO-II later?
3 * The general structure of this is vaguely based on how
4 * the Amiga port handles Zorro boards.
5 * Copyright (C) Peter Maydell 05/1998 <pmaydell@chiark.greenend.org.uk>
6 * Converted to driver model Jochen Friedrich <jochen@scram.de>
7 *
8 * The board IDs are from the NetBSD kernel, which for once provided
9 * helpful comments...
10 *
11 * This goes with drivers/dio/dio.c
12 */
13
14#ifndef _LINUX_DIO_H
15#define _LINUX_DIO_H
16
17/* The DIO boards in a system are distinguished by 'select codes' which
18 * range from 0-63 (DIO) and 132-255 (DIO-II).
19 * The DIO board with select code sc is located at physical address
20 * 0x600000 + sc * 0x10000
21 * So DIO cards cover [0x600000-0x800000); the areas [0x200000-0x400000) and
22 * [0x800000-0x1000000) are for additional space required by things
23 * like framebuffers. [0x400000-0x600000) is for miscellaneous internal I/O.
24 * On Linux, this is currently all mapped into the virtual address space
25 * at 0xf0000000 on bootup.
26 * DIO-II boards are at 0x1000000 + (sc - 132) * 0x400000
27 * which is address range [0x1000000-0x20000000) -- too big to map completely,
28 * so currently we just don't handle DIO-II boards. It wouldn't be hard to
29 * do with ioremap() though.
30 */
31
32#include <linux/device.h>
33
34#ifdef __KERNEL__
35
36#include <asm/hp300hw.h>
37
38typedef __u16 dio_id;
39
40 /*
41 * DIO devices
42 */
43
44struct dio_dev {
45 struct dio_bus *bus;
46 dio_id id;
47 int scode;
48 struct dio_driver *driver; /* which driver has allocated this device */
49 struct device dev; /* Generic device interface */
50 u8 ipl;
51 char name[64];
52 struct resource resource;
53};
54
55#define to_dio_dev(n) container_of(n, struct dio_dev, dev)
56
57 /*
58 * DIO bus
59 */
60
61struct dio_bus {
62 struct list_head devices; /* list of devices on this bus */
63 unsigned int num_resources; /* number of resources */
64 struct resource resources[2]; /* address space routed to this bus */
65 struct device dev;
66 char name[10];
67};
68
69extern struct dio_bus dio_bus; /* Single DIO bus */
70extern struct bus_type dio_bus_type;
71
72 /*
73 * DIO device IDs
74 */
75
76struct dio_device_id {
77 dio_id id; /* Device ID or DIO_WILDCARD */
78 unsigned long driver_data; /* Data private to the driver */
79};
80
81 /*
82 * DIO device drivers
83 */
84
85struct dio_driver {
86 struct list_head node;
87 char *name;
88 const struct dio_device_id *id_table; /* NULL if wants all devices */
89 int (*probe)(struct dio_dev *z, const struct dio_device_id *id);
90/* New device inserted */
91 void (*remove)(struct dio_dev *z); /* Device removed (NULL if not a hot-plug capable driver) */
92 struct device_driver driver;
93};
94
95#define to_dio_driver(drv) container_of(drv, struct dio_driver, driver)
96
97/* DIO/DIO-II boards all have the following 8bit registers.
98 * These are offsets from the base of the device.
99 */
100#define DIO_IDOFF 0x01 /* primary device ID */
101#define DIO_IPLOFF 0x03 /* interrupt priority level */
102#define DIO_SECIDOFF 0x15 /* secondary device ID */
103#define DIOII_SIZEOFF 0x101 /* device size, DIO-II only */
104#define DIO_VIRADDRBASE 0xf0000000UL /* vir addr where IOspace is mapped */
105
106#define DIO_BASE 0x600000 /* start of DIO space */
107#define DIO_END 0x1000000 /* end of DIO space */
108#define DIO_DEVSIZE 0x10000 /* size of a DIO device */
109
110#define DIOII_BASE 0x01000000 /* start of DIO-II space */
111#define DIOII_END 0x20000000 /* end of DIO-II space */
112#define DIOII_DEVSIZE 0x00400000 /* size of a DIO-II device */
113
114/* Highest valid select code. If we add DIO-II support this should become
115 * 256 for everything except HP320, which only has DIO.
116 */
117#define DIO_SCMAX (hp300_model == HP_320 ? 32 : 256)
118#define DIOII_SCBASE 132 /* lowest DIO-II select code */
119#define DIO_SCINHOLE(scode) (((scode) >= 32) && ((scode) < DIOII_SCBASE))
120#define DIO_ISDIOII(scode) ((scode) >= 132 && (scode) < 256)
121
122/* macros to read device IDs, given base address */
123#define DIO_ID(baseaddr) in_8((baseaddr) + DIO_IDOFF)
124#define DIO_SECID(baseaddr) in_8((baseaddr) + DIO_SECIDOFF)
125
126/* extract the interrupt level */
127#define DIO_IPL(baseaddr) (((in_8((baseaddr) + DIO_IPLOFF) >> 4) & 0x03) + 3)
128
129/* find the size of a DIO-II board's address space.
130 * DIO boards are all fixed length.
131 */
132#define DIOII_SIZE(baseaddr) ((in_8((baseaddr) + DIOII_SIZEOFF) + 1) * 0x100000)
133
134/* general purpose macro for both DIO and DIO-II */
135#define DIO_SIZE(scode, base) (DIO_ISDIOII((scode)) ? DIOII_SIZE((base)) : DIO_DEVSIZE)
136
137/* The hardware has primary and secondary IDs; we encode these in a single
138 * int as PRIMARY ID & (SECONDARY ID << 8).
139 * In practice this is only important for framebuffers,
140 * and everybody else just sets ID fields equal to the DIO_ID_FOO value.
141 */
142#define DIO_ENCODE_ID(pr,sec) ((((int)sec & 0xff) << 8) | ((int)pr & 0xff))
143/* macro to determine whether a given primary ID requires a secondary ID byte */
144#define DIO_NEEDSSECID(id) ((id) == DIO_ID_FBUFFER)
145#define DIO_WILDCARD 0xff
146
147/* Now a whole slew of macros giving device IDs and descriptive strings: */
148#define DIO_ID_DCA0 0x02 /* 98644A serial */
149#define DIO_DESC_DCA0 "98644A DCA0 serial"
150#define DIO_ID_DCA0REM 0x82 /* 98644A serial */
151#define DIO_DESC_DCA0REM "98644A DCA0REM serial"
152#define DIO_ID_DCA1 0x42 /* 98644A serial */
153#define DIO_DESC_DCA1 "98644A DCA1 serial"
154#define DIO_ID_DCA1REM 0xc2 /* 98644A serial */
155#define DIO_DESC_DCA1REM "98644A DCA1REM serial"
156#define DIO_ID_DCM 0x05 /* 98642A serial MUX */
157#define DIO_DESC_DCM "98642A DCM serial MUX"
158#define DIO_ID_DCMREM 0x85 /* 98642A serial MUX */
159#define DIO_DESC_DCMREM "98642A DCMREM serial MUX"
160#define DIO_ID_LAN 0x15 /* 98643A LAN */
161#define DIO_DESC_LAN "98643A LANCE ethernet"
162#define DIO_ID_FHPIB 0x08 /* 98625A/98625B fast HP-IB */
163#define DIO_DESC_FHPIB "98625A/98625B fast HPIB"
164#define DIO_ID_NHPIB 0x01 /* 98624A HP-IB (normal ie slow) */
165#define DIO_DESC_NHPIB "98624A HPIB"
166#define DIO_ID_SCSI0 0x07 /* 98265A SCSI */
167#define DIO_DESC_SCSI0 "98265A SCSI0"
168#define DIO_ID_SCSI1 0x27 /* ditto */
169#define DIO_DESC_SCSI1 "98265A SCSI1"
170#define DIO_ID_SCSI2 0x47 /* ditto */
171#define DIO_DESC_SCSI2 "98265A SCSI2"
172#define DIO_ID_SCSI3 0x67 /* ditto */
173#define DIO_DESC_SCSI3 "98265A SCSI3"
174#define DIO_ID_FBUFFER 0x39 /* framebuffer: flavour is distinguished by secondary ID */
175#define DIO_DESC_FBUFFER "bitmapped display"
176/* the NetBSD kernel source is a bit unsure as to what these next IDs actually do :-> */
177#define DIO_ID_MISC0 0x03 /* 98622A */
178#define DIO_DESC_MISC0 "98622A"
179#define DIO_ID_MISC1 0x04 /* 98623A */
180#define DIO_DESC_MISC1 "98623A"
181#define DIO_ID_PARALLEL 0x06 /* internal parallel */
182#define DIO_DESC_PARALLEL "internal parallel"
183#define DIO_ID_MISC2 0x09 /* 98287A keyboard */
184#define DIO_DESC_MISC2 "98287A keyboard"
185#define DIO_ID_MISC3 0x0a /* HP98635A FP accelerator */
186#define DIO_DESC_MISC3 "HP98635A FP accelerator"
187#define DIO_ID_MISC4 0x0b /* timer */
188#define DIO_DESC_MISC4 "timer"
189#define DIO_ID_MISC5 0x12 /* 98640A */
190#define DIO_DESC_MISC5 "98640A"
191#define DIO_ID_MISC6 0x16 /* 98659A */
192#define DIO_DESC_MISC6 "98659A"
193#define DIO_ID_MISC7 0x19 /* 237 display */
194#define DIO_DESC_MISC7 "237 display"
195#define DIO_ID_MISC8 0x1a /* quad-wide card */
196#define DIO_DESC_MISC8 "quad-wide card"
197#define DIO_ID_MISC9 0x1b /* 98253A */
198#define DIO_DESC_MISC9 "98253A"
199#define DIO_ID_MISC10 0x1c /* 98627A */
200#define DIO_DESC_MISC10 "98253A"
201#define DIO_ID_MISC11 0x1d /* 98633A */
202#define DIO_DESC_MISC11 "98633A"
203#define DIO_ID_MISC12 0x1e /* 98259A */
204#define DIO_DESC_MISC12 "98259A"
205#define DIO_ID_MISC13 0x1f /* 8741 */
206#define DIO_DESC_MISC13 "8741"
207#define DIO_ID_VME 0x31 /* 98577A VME adapter */
208#define DIO_DESC_VME "98577A VME adapter"
209#define DIO_ID_DCL 0x34 /* 98628A serial */
210#define DIO_DESC_DCL "98628A DCL serial"
211#define DIO_ID_DCLREM 0xb4 /* 98628A serial */
212#define DIO_DESC_DCLREM "98628A DCLREM serial"
213/* These are the secondary IDs for the framebuffers */
214#define DIO_ID2_GATORBOX 0x01 /* 98700/98710 "gatorbox" */
215#define DIO_DESC2_GATORBOX "98700/98710 \"gatorbox\" display"
216#define DIO_ID2_TOPCAT 0x02 /* 98544/98545/98547 "topcat" */
217#define DIO_DESC2_TOPCAT "98544/98545/98547 \"topcat\" display"
218#define DIO_ID2_RENAISSANCE 0x04 /* 98720/98721 "renaissance" */
219#define DIO_DESC2_RENAISSANCE "98720/98721 \"renaissance\" display"
220#define DIO_ID2_LRCATSEYE 0x05 /* lowres "catseye" */
221#define DIO_DESC2_LRCATSEYE "low-res catseye display"
222#define DIO_ID2_HRCCATSEYE 0x06 /* highres colour "catseye" */
223#define DIO_DESC2_HRCCATSEYE "high-res color catseye display"
224#define DIO_ID2_HRMCATSEYE 0x07 /* highres mono "catseye" */
225#define DIO_DESC2_HRMCATSEYE "high-res mono catseye display"
226#define DIO_ID2_DAVINCI 0x08 /* 98730/98731 "davinci" */
227#define DIO_DESC2_DAVINCI "98730/98731 \"davinci\" display"
228#define DIO_ID2_XXXCATSEYE 0x09 /* "catseye" */
229#define DIO_DESC2_XXXCATSEYE "catseye display"
230#define DIO_ID2_HYPERION 0x0e /* A1096A "hyperion" */
231#define DIO_DESC2_HYPERION "A1096A \"hyperion\" display"
232#define DIO_ID2_XGENESIS 0x0b /* "x-genesis"; no NetBSD support */
233#define DIO_DESC2_XGENESIS "\"x-genesis\" display"
234#define DIO_ID2_TIGER 0x0c /* "tiger"; no NetBSD support */
235#define DIO_DESC2_TIGER "\"tiger\" display"
236#define DIO_ID2_YGENESIS 0x0d /* "y-genesis"; no NetBSD support */
237#define DIO_DESC2_YGENESIS "\"y-genesis\" display"
238/* if you add new IDs then you should tell dio.c about them so it can
239 * identify them...
240 */
241
242extern int dio_find(int deviceid);
243extern unsigned long dio_scodetophysaddr(int scode);
244extern void dio_create_sysfs_dev_files(struct dio_dev *);
245
246/* New-style probing */
247extern int dio_register_driver(struct dio_driver *);
248extern void dio_unregister_driver(struct dio_driver *);
249extern const struct dio_device_id *dio_match_device(const struct dio_device_id *ids, const struct dio_dev *z);
250static inline struct dio_driver *dio_dev_driver(const struct dio_dev *d)
251{
252 return d->driver;
253}
254
255#define dio_resource_start(d) ((d)->resource.start)
256#define dio_resource_end(d) ((d)->resource.end)
257#define dio_resource_len(d) ((d)->resource.end-(d)->resource.start+1)
258#define dio_resource_flags(d) ((d)->resource.flags)
259
260#define dio_request_device(d, name) \
261 request_mem_region(dio_resource_start(d), dio_resource_len(d), name)
262#define dio_release_device(d) \
263 release_mem_region(dio_resource_start(d), dio_resource_len(d))
264
265/* Similar to the helpers above, these manipulate per-dio_dev
266 * driver-specific data. They are really just a wrapper around
267 * the generic device structure functions of these calls.
268 */
269static inline void *dio_get_drvdata (struct dio_dev *d)
270{
271 return dev_get_drvdata(&d->dev);
272}
273
274static inline void dio_set_drvdata (struct dio_dev *d, void *data)
275{
276 dev_set_drvdata(&d->dev, data);
277}
278
279/*
280 * A helper function which helps ensure correct dio_driver
281 * setup and cleanup for commonly-encountered hotplug/modular cases
282 *
283 * This MUST stay in a header, as it checks for -DMODULE
284 */
285static inline int dio_module_init(struct dio_driver *drv)
286{
287 int rc = dio_register_driver(drv);
288
289 if (rc > 0)
290 return 0;
291
292 /* iff CONFIG_HOTPLUG and built into kernel, we should
293 * leave the driver around for future hotplug events.
294 * For the module case, a hotplug daemon of some sort
295 * should load a module in response to an insert event. */
296#if defined(CONFIG_HOTPLUG) && !defined(MODULE)
297 if (rc == 0)
298 return 0;
299#else
300 if (rc == 0)
301 rc = -ENODEV;
302#endif
303
304 /* if we get here, we need to clean up DIO driver instance
305 * and return some sort of error */
306 dio_unregister_driver(drv);
307
308 return rc;
309}
310
311#endif /* __KERNEL__ */
312#endif /* ndef _LINUX_DIO_H */
diff --git a/include/linux/dirent.h b/include/linux/dirent.h
new file mode 100644
index 000000000000..5d6023b87800
--- /dev/null
+++ b/include/linux/dirent.h
@@ -0,0 +1,32 @@
1#ifndef _LINUX_DIRENT_H
2#define _LINUX_DIRENT_H
3
4struct dirent {
5 long d_ino;
6 __kernel_off_t d_off;
7 unsigned short d_reclen;
8 char d_name[256]; /* We must not include limits.h! */
9};
10
11struct dirent64 {
12 __u64 d_ino;
13 __s64 d_off;
14 unsigned short d_reclen;
15 unsigned char d_type;
16 char d_name[256];
17};
18
19#ifdef __KERNEL__
20
21struct linux_dirent64 {
22 u64 d_ino;
23 s64 d_off;
24 unsigned short d_reclen;
25 unsigned char d_type;
26 char d_name[0];
27};
28
29#endif /* __KERNEL__ */
30
31
32#endif
diff --git a/include/linux/divert.h b/include/linux/divert.h
new file mode 100644
index 000000000000..6919b09133d4
--- /dev/null
+++ b/include/linux/divert.h
@@ -0,0 +1,132 @@
1/*
2 * Frame Diversion, Benoit Locher <Benoit.Locher@skf.com>
3 *
4 * Changes:
5 * 06/09/2000 BL: initial version
6 *
7 */
8
9#ifndef _LINUX_DIVERT_H
10#define _LINUX_DIVERT_H
11
12#include <asm/types.h>
13
14#define MAX_DIVERT_PORTS 8 /* Max number of ports to divert (tcp, udp) */
15
16/* Divertable protocols */
17#define DIVERT_PROTO_NONE 0x0000
18#define DIVERT_PROTO_IP 0x0001
19#define DIVERT_PROTO_ICMP 0x0002
20#define DIVERT_PROTO_TCP 0x0004
21#define DIVERT_PROTO_UDP 0x0008
22
23/*
24 * This is an Ethernet Frame Diverter option block
25 */
26struct divert_blk
27{
28 int divert; /* are we active */
29 unsigned int protos; /* protocols */
30 u16 tcp_dst[MAX_DIVERT_PORTS]; /* specific tcp dst ports to divert */
31 u16 tcp_src[MAX_DIVERT_PORTS]; /* specific tcp src ports to divert */
32 u16 udp_dst[MAX_DIVERT_PORTS]; /* specific udp dst ports to divert */
33 u16 udp_src[MAX_DIVERT_PORTS]; /* specific udp src ports to divert */
34};
35
36/*
37 * Diversion control block, for configuration with the userspace tool
38 * divert
39 */
40
41typedef union _divert_cf_arg
42{
43 s16 int16;
44 u16 uint16;
45 s32 int32;
46 u32 uint32;
47 s64 int64;
48 u64 uint64;
49 void __user *ptr;
50} divert_cf_arg;
51
52
53struct divert_cf
54{
55 int cmd; /* Command */
56 divert_cf_arg arg1,
57 arg2,
58 arg3;
59 int dev_index; /* device index (eth0=0, etc...) */
60};
61
62
63/* Diversion commands */
64#define DIVCMD_DIVERT 1 /* ENABLE/DISABLE diversion */
65#define DIVCMD_IP 2 /* ENABLE/DISABLE whold IP diversion */
66#define DIVCMD_TCP 3 /* ENABLE/DISABLE whold TCP diversion */
67#define DIVCMD_TCPDST 4 /* ADD/REMOVE TCP DST port for diversion */
68#define DIVCMD_TCPSRC 5 /* ADD/REMOVE TCP SRC port for diversion */
69#define DIVCMD_UDP 6 /* ENABLE/DISABLE whole UDP diversion */
70#define DIVCMD_UDPDST 7 /* ADD/REMOVE UDP DST port for diversion */
71#define DIVCMD_UDPSRC 8 /* ADD/REMOVE UDP SRC port for diversion */
72#define DIVCMD_ICMP 9 /* ENABLE/DISABLE whole ICMP diversion */
73#define DIVCMD_GETSTATUS 10 /* GET the status of the diverter */
74#define DIVCMD_RESET 11 /* Reset the diverter on the specified dev */
75#define DIVCMD_GETVERSION 12 /* Retrieve the diverter code version (char[32]) */
76
77/* General syntax of the commands:
78 *
79 * DIVCMD_xxxxxx(arg1, arg2, arg3, dev_index)
80 *
81 * SIOCSIFDIVERT:
82 * DIVCMD_DIVERT(DIVARG1_ENABLE|DIVARG1_DISABLE, , ,ifindex)
83 * DIVCMD_IP(DIVARG1_ENABLE|DIVARG1_DISABLE, , , ifindex)
84 * DIVCMD_TCP(DIVARG1_ENABLE|DIVARG1_DISABLE, , , ifindex)
85 * DIVCMD_TCPDST(DIVARG1_ADD|DIVARG1_REMOVE, port, , ifindex)
86 * DIVCMD_TCPSRC(DIVARG1_ADD|DIVARG1_REMOVE, port, , ifindex)
87 * DIVCMD_UDP(DIVARG1_ENABLE|DIVARG1_DISABLE, , , ifindex)
88 * DIVCMD_UDPDST(DIVARG1_ADD|DIVARG1_REMOVE, port, , ifindex)
89 * DIVCMD_UDPSRC(DIVARG1_ADD|DIVARG1_REMOVE, port, , ifindex)
90 * DIVCMD_ICMP(DIVARG1_ENABLE|DIVARG1_DISABLE, , , ifindex)
91 * DIVCMD_RESET(, , , ifindex)
92 *
93 * SIOGIFDIVERT:
94 * DIVCMD_GETSTATUS(divert_blk, , , ifindex)
95 * DIVCMD_GETVERSION(string[3])
96 */
97
98
99/* Possible values for arg1 */
100#define DIVARG1_ENABLE 0 /* ENABLE something */
101#define DIVARG1_DISABLE 1 /* DISABLE something */
102#define DIVARG1_ADD 2 /* ADD something */
103#define DIVARG1_REMOVE 3 /* REMOVE something */
104
105
106#ifdef __KERNEL__
107
108/* diverter functions */
109#include <linux/skbuff.h>
110
111#ifdef CONFIG_NET_DIVERT
112#include <linux/netdevice.h>
113
114int alloc_divert_blk(struct net_device *);
115void free_divert_blk(struct net_device *);
116int divert_ioctl(unsigned int cmd, struct divert_cf __user *arg);
117void divert_frame(struct sk_buff *skb);
118static inline void handle_diverter(struct sk_buff *skb)
119{
120 /* if diversion is supported on device, then divert */
121 if (skb->dev->divert && skb->dev->divert->divert)
122 divert_frame(skb);
123}
124
125#else
126# define alloc_divert_blk(dev) (0)
127# define free_divert_blk(dev) do {} while (0)
128# define divert_ioctl(cmd, arg) (-ENOPKG)
129# define handle_diverter(skb) do {} while (0)
130#endif
131#endif
132#endif /* _LINUX_DIVERT_H */
diff --git a/include/linux/dm-ioctl.h b/include/linux/dm-ioctl.h
new file mode 100644
index 000000000000..f5eb6b6cd109
--- /dev/null
+++ b/include/linux/dm-ioctl.h
@@ -0,0 +1,308 @@
1/*
2 * Copyright (C) 2001 - 2003 Sistina Software (UK) Limited.
3 * Copyright (C) 2004 - 2005 Red Hat, Inc. All rights reserved.
4 *
5 * This file is released under the LGPL.
6 */
7
8#ifndef _LINUX_DM_IOCTL_V4_H
9#define _LINUX_DM_IOCTL_V4_H
10
11#include <linux/types.h>
12
13#define DM_DIR "mapper" /* Slashes not supported */
14#define DM_MAX_TYPE_NAME 16
15#define DM_NAME_LEN 128
16#define DM_UUID_LEN 129
17
18/*
19 * A traditional ioctl interface for the device mapper.
20 *
21 * Each device can have two tables associated with it, an
22 * 'active' table which is the one currently used by io passing
23 * through the device, and an 'inactive' one which is a table
24 * that is being prepared as a replacement for the 'active' one.
25 *
26 * DM_VERSION:
27 * Just get the version information for the ioctl interface.
28 *
29 * DM_REMOVE_ALL:
30 * Remove all dm devices, destroy all tables. Only really used
31 * for debug.
32 *
33 * DM_LIST_DEVICES:
34 * Get a list of all the dm device names.
35 *
36 * DM_DEV_CREATE:
37 * Create a new device, neither the 'active' or 'inactive' table
38 * slots will be filled. The device will be in suspended state
39 * after creation, however any io to the device will get errored
40 * since it will be out-of-bounds.
41 *
42 * DM_DEV_REMOVE:
43 * Remove a device, destroy any tables.
44 *
45 * DM_DEV_RENAME:
46 * Rename a device.
47 *
48 * DM_SUSPEND:
49 * This performs both suspend and resume, depending which flag is
50 * passed in.
51 * Suspend: This command will not return until all pending io to
52 * the device has completed. Further io will be deferred until
53 * the device is resumed.
54 * Resume: It is no longer an error to issue this command on an
55 * unsuspended device. If a table is present in the 'inactive'
56 * slot, it will be moved to the active slot, then the old table
57 * from the active slot will be _destroyed_. Finally the device
58 * is resumed.
59 *
60 * DM_DEV_STATUS:
61 * Retrieves the status for the table in the 'active' slot.
62 *
63 * DM_DEV_WAIT:
64 * Wait for a significant event to occur to the device. This
65 * could either be caused by an event triggered by one of the
66 * targets of the table in the 'active' slot, or a table change.
67 *
68 * DM_TABLE_LOAD:
69 * Load a table into the 'inactive' slot for the device. The
70 * device does _not_ need to be suspended prior to this command.
71 *
72 * DM_TABLE_CLEAR:
73 * Destroy any table in the 'inactive' slot (ie. abort).
74 *
75 * DM_TABLE_DEPS:
76 * Return a set of device dependencies for the 'active' table.
77 *
78 * DM_TABLE_STATUS:
79 * Return the targets status for the 'active' table.
80 *
81 * DM_TARGET_MSG:
82 * Pass a message string to the target at a specific offset of a device.
83 */
84
85/*
86 * All ioctl arguments consist of a single chunk of memory, with
87 * this structure at the start. If a uuid is specified any
88 * lookup (eg. for a DM_INFO) will be done on that, *not* the
89 * name.
90 */
91struct dm_ioctl {
92 /*
93 * The version number is made up of three parts:
94 * major - no backward or forward compatibility,
95 * minor - only backwards compatible,
96 * patch - both backwards and forwards compatible.
97 *
98 * All clients of the ioctl interface should fill in the
99 * version number of the interface that they were
100 * compiled with.
101 *
102 * All recognised ioctl commands (ie. those that don't
103 * return -ENOTTY) fill out this field, even if the
104 * command failed.
105 */
106 uint32_t version[3]; /* in/out */
107 uint32_t data_size; /* total size of data passed in
108 * including this struct */
109
110 uint32_t data_start; /* offset to start of data
111 * relative to start of this struct */
112
113 uint32_t target_count; /* in/out */
114 int32_t open_count; /* out */
115 uint32_t flags; /* in/out */
116 uint32_t event_nr; /* in/out */
117 uint32_t padding;
118
119 uint64_t dev; /* in/out */
120
121 char name[DM_NAME_LEN]; /* device name */
122 char uuid[DM_UUID_LEN]; /* unique identifier for
123 * the block device */
124};
125
126/*
127 * Used to specify tables. These structures appear after the
128 * dm_ioctl.
129 */
130struct dm_target_spec {
131 uint64_t sector_start;
132 uint64_t length;
133 int32_t status; /* used when reading from kernel only */
134
135 /*
136 * Location of the next dm_target_spec.
137 * - When specifying targets on a DM_TABLE_LOAD command, this value is
138 * the number of bytes from the start of the "current" dm_target_spec
139 * to the start of the "next" dm_target_spec.
140 * - When retrieving targets on a DM_TABLE_STATUS command, this value
141 * is the number of bytes from the start of the first dm_target_spec
142 * (that follows the dm_ioctl struct) to the start of the "next"
143 * dm_target_spec.
144 */
145 uint32_t next;
146
147 char target_type[DM_MAX_TYPE_NAME];
148
149 /*
150 * Parameter string starts immediately after this object.
151 * Be careful to add padding after string to ensure correct
152 * alignment of subsequent dm_target_spec.
153 */
154};
155
156/*
157 * Used to retrieve the target dependencies.
158 */
159struct dm_target_deps {
160 uint32_t count; /* Array size */
161 uint32_t padding; /* unused */
162 uint64_t dev[0]; /* out */
163};
164
165/*
166 * Used to get a list of all dm devices.
167 */
168struct dm_name_list {
169 uint64_t dev;
170 uint32_t next; /* offset to the next record from
171 the _start_ of this */
172 char name[0];
173};
174
175/*
176 * Used to retrieve the target versions
177 */
178struct dm_target_versions {
179 uint32_t next;
180 uint32_t version[3];
181
182 char name[0];
183};
184
185/*
186 * Used to pass message to a target
187 */
188struct dm_target_msg {
189 uint64_t sector; /* Device sector */
190
191 char message[0];
192};
193
194/*
195 * If you change this make sure you make the corresponding change
196 * to dm-ioctl.c:lookup_ioctl()
197 */
198enum {
199 /* Top level cmds */
200 DM_VERSION_CMD = 0,
201 DM_REMOVE_ALL_CMD,
202 DM_LIST_DEVICES_CMD,
203
204 /* device level cmds */
205 DM_DEV_CREATE_CMD,
206 DM_DEV_REMOVE_CMD,
207 DM_DEV_RENAME_CMD,
208 DM_DEV_SUSPEND_CMD,
209 DM_DEV_STATUS_CMD,
210 DM_DEV_WAIT_CMD,
211
212 /* Table level cmds */
213 DM_TABLE_LOAD_CMD,
214 DM_TABLE_CLEAR_CMD,
215 DM_TABLE_DEPS_CMD,
216 DM_TABLE_STATUS_CMD,
217
218 /* Added later */
219 DM_LIST_VERSIONS_CMD,
220 DM_TARGET_MSG_CMD,
221};
222
223/*
224 * The dm_ioctl struct passed into the ioctl is just the header
225 * on a larger chunk of memory. On x86-64 and other
226 * architectures the dm-ioctl struct will be padded to an 8 byte
227 * boundary so the size will be different, which would change the
228 * ioctl code - yes I really messed up. This hack forces these
229 * architectures to have the correct ioctl code.
230 */
231#ifdef CONFIG_COMPAT
232typedef char ioctl_struct[308];
233#define DM_VERSION_32 _IOWR(DM_IOCTL, DM_VERSION_CMD, ioctl_struct)
234#define DM_REMOVE_ALL_32 _IOWR(DM_IOCTL, DM_REMOVE_ALL_CMD, ioctl_struct)
235#define DM_LIST_DEVICES_32 _IOWR(DM_IOCTL, DM_LIST_DEVICES_CMD, ioctl_struct)
236
237#define DM_DEV_CREATE_32 _IOWR(DM_IOCTL, DM_DEV_CREATE_CMD, ioctl_struct)
238#define DM_DEV_REMOVE_32 _IOWR(DM_IOCTL, DM_DEV_REMOVE_CMD, ioctl_struct)
239#define DM_DEV_RENAME_32 _IOWR(DM_IOCTL, DM_DEV_RENAME_CMD, ioctl_struct)
240#define DM_DEV_SUSPEND_32 _IOWR(DM_IOCTL, DM_DEV_SUSPEND_CMD, ioctl_struct)
241#define DM_DEV_STATUS_32 _IOWR(DM_IOCTL, DM_DEV_STATUS_CMD, ioctl_struct)
242#define DM_DEV_WAIT_32 _IOWR(DM_IOCTL, DM_DEV_WAIT_CMD, ioctl_struct)
243
244#define DM_TABLE_LOAD_32 _IOWR(DM_IOCTL, DM_TABLE_LOAD_CMD, ioctl_struct)
245#define DM_TABLE_CLEAR_32 _IOWR(DM_IOCTL, DM_TABLE_CLEAR_CMD, ioctl_struct)
246#define DM_TABLE_DEPS_32 _IOWR(DM_IOCTL, DM_TABLE_DEPS_CMD, ioctl_struct)
247#define DM_TABLE_STATUS_32 _IOWR(DM_IOCTL, DM_TABLE_STATUS_CMD, ioctl_struct)
248#define DM_LIST_VERSIONS_32 _IOWR(DM_IOCTL, DM_LIST_VERSIONS_CMD, ioctl_struct)
249#define DM_TARGET_MSG_32 _IOWR(DM_IOCTL, DM_TARGET_MSG_CMD, ioctl_struct)
250#endif
251
252#define DM_IOCTL 0xfd
253
254#define DM_VERSION _IOWR(DM_IOCTL, DM_VERSION_CMD, struct dm_ioctl)
255#define DM_REMOVE_ALL _IOWR(DM_IOCTL, DM_REMOVE_ALL_CMD, struct dm_ioctl)
256#define DM_LIST_DEVICES _IOWR(DM_IOCTL, DM_LIST_DEVICES_CMD, struct dm_ioctl)
257
258#define DM_DEV_CREATE _IOWR(DM_IOCTL, DM_DEV_CREATE_CMD, struct dm_ioctl)
259#define DM_DEV_REMOVE _IOWR(DM_IOCTL, DM_DEV_REMOVE_CMD, struct dm_ioctl)
260#define DM_DEV_RENAME _IOWR(DM_IOCTL, DM_DEV_RENAME_CMD, struct dm_ioctl)
261#define DM_DEV_SUSPEND _IOWR(DM_IOCTL, DM_DEV_SUSPEND_CMD, struct dm_ioctl)
262#define DM_DEV_STATUS _IOWR(DM_IOCTL, DM_DEV_STATUS_CMD, struct dm_ioctl)
263#define DM_DEV_WAIT _IOWR(DM_IOCTL, DM_DEV_WAIT_CMD, struct dm_ioctl)
264
265#define DM_TABLE_LOAD _IOWR(DM_IOCTL, DM_TABLE_LOAD_CMD, struct dm_ioctl)
266#define DM_TABLE_CLEAR _IOWR(DM_IOCTL, DM_TABLE_CLEAR_CMD, struct dm_ioctl)
267#define DM_TABLE_DEPS _IOWR(DM_IOCTL, DM_TABLE_DEPS_CMD, struct dm_ioctl)
268#define DM_TABLE_STATUS _IOWR(DM_IOCTL, DM_TABLE_STATUS_CMD, struct dm_ioctl)
269
270#define DM_LIST_VERSIONS _IOWR(DM_IOCTL, DM_LIST_VERSIONS_CMD, struct dm_ioctl)
271
272#define DM_TARGET_MSG _IOWR(DM_IOCTL, DM_TARGET_MSG_CMD, struct dm_ioctl)
273
274#define DM_VERSION_MAJOR 4
275#define DM_VERSION_MINOR 4
276#define DM_VERSION_PATCHLEVEL 0
277#define DM_VERSION_EXTRA "-ioctl (2005-01-12)"
278
279/* Status bits */
280#define DM_READONLY_FLAG (1 << 0) /* In/Out */
281#define DM_SUSPEND_FLAG (1 << 1) /* In/Out */
282#define DM_PERSISTENT_DEV_FLAG (1 << 3) /* In */
283
284/*
285 * Flag passed into ioctl STATUS command to get table information
286 * rather than current status.
287 */
288#define DM_STATUS_TABLE_FLAG (1 << 4) /* In */
289
290/*
291 * Flags that indicate whether a table is present in either of
292 * the two table slots that a device has.
293 */
294#define DM_ACTIVE_PRESENT_FLAG (1 << 5) /* Out */
295#define DM_INACTIVE_PRESENT_FLAG (1 << 6) /* Out */
296
297/*
298 * Indicates that the buffer passed in wasn't big enough for the
299 * results.
300 */
301#define DM_BUFFER_FULL_FLAG (1 << 8) /* Out */
302
303/*
304 * Set this to improve performance when you aren't going to use open_count
305 */
306#define DM_SKIP_BDGET_FLAG (1 << 9) /* In */
307
308#endif /* _LINUX_DM_IOCTL_H */
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
new file mode 100644
index 000000000000..806c305332c1
--- /dev/null
+++ b/include/linux/dma-mapping.h
@@ -0,0 +1,56 @@
1#ifndef _ASM_LINUX_DMA_MAPPING_H
2#define _ASM_LINUX_DMA_MAPPING_H
3
4#include <linux/device.h>
5#include <linux/err.h>
6
7/* These definitions mirror those in pci.h, so they can be used
8 * interchangeably with their PCI_ counterparts */
9enum dma_data_direction {
10 DMA_BIDIRECTIONAL = 0,
11 DMA_TO_DEVICE = 1,
12 DMA_FROM_DEVICE = 2,
13 DMA_NONE = 3,
14};
15
16#define DMA_64BIT_MASK 0xffffffffffffffffULL
17#define DMA_32BIT_MASK 0x00000000ffffffffULL
18
19#include <asm/dma-mapping.h>
20
21/* Backwards compat, remove in 2.7.x */
22#define dma_sync_single dma_sync_single_for_cpu
23#define dma_sync_sg dma_sync_sg_for_cpu
24
25extern u64 dma_get_required_mask(struct device *dev);
26
27/* flags for the coherent memory api */
28#define DMA_MEMORY_MAP 0x01
29#define DMA_MEMORY_IO 0x02
30#define DMA_MEMORY_INCLUDES_CHILDREN 0x04
31#define DMA_MEMORY_EXCLUSIVE 0x08
32
33#ifndef ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
34static inline int
35dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
36 dma_addr_t device_addr, size_t size, int flags)
37{
38 return 0;
39}
40
41static inline void
42dma_release_declared_memory(struct device *dev)
43{
44}
45
46static inline void *
47dma_mark_declared_memory_occupied(struct device *dev,
48 dma_addr_t device_addr, size_t size)
49{
50 return ERR_PTR(-EBUSY);
51}
52#endif
53
54#endif
55
56
diff --git a/include/linux/dmapool.h b/include/linux/dmapool.h
new file mode 100644
index 000000000000..e60bfdac348d
--- /dev/null
+++ b/include/linux/dmapool.h
@@ -0,0 +1,27 @@
1/*
2 * include/linux/dmapool.h
3 *
4 * Allocation pools for DMAable (coherent) memory.
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_DMAPOOL_H
12#define LINUX_DMAPOOL_H
13
14#include <asm/io.h>
15#include <asm/scatterlist.h>
16
17struct dma_pool *dma_pool_create(const char *name, struct device *dev,
18 size_t size, size_t align, size_t allocation);
19
20void dma_pool_destroy(struct dma_pool *pool);
21
22void *dma_pool_alloc(struct dma_pool *pool, int mem_flags, dma_addr_t *handle);
23
24void dma_pool_free(struct dma_pool *pool, void *vaddr, dma_addr_t addr);
25
26#endif
27
diff --git a/include/linux/dmi.h b/include/linux/dmi.h
new file mode 100644
index 000000000000..d2bcf556088b
--- /dev/null
+++ b/include/linux/dmi.h
@@ -0,0 +1,47 @@
1#ifndef __DMI_H__
2#define __DMI_H__
3
4enum dmi_field {
5 DMI_NONE,
6 DMI_BIOS_VENDOR,
7 DMI_BIOS_VERSION,
8 DMI_BIOS_DATE,
9 DMI_SYS_VENDOR,
10 DMI_PRODUCT_NAME,
11 DMI_PRODUCT_VERSION,
12 DMI_BOARD_VENDOR,
13 DMI_BOARD_NAME,
14 DMI_BOARD_VERSION,
15 DMI_STRING_MAX,
16};
17
18/*
19 * DMI callbacks for problem boards
20 */
21struct dmi_strmatch {
22 u8 slot;
23 char *substr;
24};
25
26struct dmi_system_id {
27 int (*callback)(struct dmi_system_id *);
28 char *ident;
29 struct dmi_strmatch matches[4];
30 void *driver_data;
31};
32
33#define DMI_MATCH(a,b) { a, b }
34
35#if defined(CONFIG_X86) && !defined(CONFIG_X86_64)
36
37extern int dmi_check_system(struct dmi_system_id *list);
38extern char * dmi_get_system_info(int field);
39
40#else
41
42static inline int dmi_check_system(struct dmi_system_id *list) { return 0; }
43static inline char * dmi_get_system_info(int field) { return NULL; }
44
45#endif
46
47#endif /* __DMI_H__ */
diff --git a/include/linux/dn.h b/include/linux/dn.h
new file mode 100644
index 000000000000..782cae49e64c
--- /dev/null
+++ b/include/linux/dn.h
@@ -0,0 +1,147 @@
1#ifndef _LINUX_DN_H
2#define _LINUX_DN_H
3
4/*
5
6 DECnet Data Structures and Constants
7
8*/
9
10/*
11 * DNPROTO_NSP can't be the same as SOL_SOCKET,
12 * so increment each by one (compared to ULTRIX)
13 */
14#define DNPROTO_NSP 2 /* NSP protocol number */
15#define DNPROTO_ROU 3 /* Routing protocol number */
16#define DNPROTO_NML 4 /* Net mgt protocol number */
17#define DNPROTO_EVL 5 /* Evl protocol number (usr) */
18#define DNPROTO_EVR 6 /* Evl protocol number (evl) */
19#define DNPROTO_NSPT 7 /* NSP trace protocol number */
20
21
22#define DN_ADDL 2
23#define DN_MAXADDL 2 /* ULTRIX headers have 20 here, but pathworks has 2 */
24#define DN_MAXOPTL 16
25#define DN_MAXOBJL 16
26#define DN_MAXACCL 40
27#define DN_MAXALIASL 128
28#define DN_MAXNODEL 256
29#define DNBUFSIZE 65023
30
31/*
32 * SET/GET Socket options - must match the DSO_ numbers below
33 */
34#define SO_CONDATA 1
35#define SO_CONACCESS 2
36#define SO_PROXYUSR 3
37#define SO_LINKINFO 7
38
39#define DSO_CONDATA 1 /* Set/Get connect data */
40#define DSO_DISDATA 10 /* Set/Get disconnect data */
41#define DSO_CONACCESS 2 /* Set/Get connect access data */
42#define DSO_ACCEPTMODE 4 /* Set/Get accept mode */
43#define DSO_CONACCEPT 5 /* Accept deferred connection */
44#define DSO_CONREJECT 6 /* Reject deferred connection */
45#define DSO_LINKINFO 7 /* Set/Get link information */
46#define DSO_STREAM 8 /* Set socket type to stream */
47#define DSO_SEQPACKET 9 /* Set socket type to sequenced packet */
48#define DSO_MAXWINDOW 11 /* Maximum window size allowed */
49#define DSO_NODELAY 12 /* Turn off nagle */
50#define DSO_CORK 13 /* Wait for more data! */
51#define DSO_SERVICES 14 /* NSP Services field */
52#define DSO_INFO 15 /* NSP Info field */
53#define DSO_MAX 15 /* Maximum option number */
54
55
56/* LINK States */
57#define LL_INACTIVE 0
58#define LL_CONNECTING 1
59#define LL_RUNNING 2
60#define LL_DISCONNECTING 3
61
62#define ACC_IMMED 0
63#define ACC_DEFER 1
64
65#define SDF_WILD 1 /* Wild card object */
66#define SDF_PROXY 2 /* Addr eligible for proxy */
67#define SDF_UICPROXY 4 /* Use uic-based proxy */
68
69/* Structures */
70
71
72struct dn_naddr
73{
74 unsigned short a_len;
75 unsigned char a_addr[DN_MAXADDL];
76};
77
78struct sockaddr_dn
79{
80 unsigned short sdn_family;
81 unsigned char sdn_flags;
82 unsigned char sdn_objnum;
83 unsigned short sdn_objnamel;
84 unsigned char sdn_objname[DN_MAXOBJL];
85 struct dn_naddr sdn_add;
86};
87#define sdn_nodeaddrl sdn_add.a_len /* Node address length */
88#define sdn_nodeaddr sdn_add.a_addr /* Node address */
89
90
91
92/*
93 * DECnet set/get DSO_CONDATA, DSO_DISDATA (optional data) structure
94 */
95struct optdata_dn {
96 unsigned short opt_status; /* Extended status return */
97#define opt_sts opt_status
98 unsigned short opt_optl; /* Length of user data */
99 unsigned char opt_data[16]; /* User data */
100};
101
102struct accessdata_dn
103{
104 unsigned char acc_accl;
105 unsigned char acc_acc[DN_MAXACCL];
106 unsigned char acc_passl;
107 unsigned char acc_pass[DN_MAXACCL];
108 unsigned char acc_userl;
109 unsigned char acc_user[DN_MAXACCL];
110};
111
112/*
113 * DECnet logical link information structure
114 */
115struct linkinfo_dn {
116 unsigned short idn_segsize; /* Segment size for link */
117 unsigned char idn_linkstate; /* Logical link state */
118};
119
120/*
121 * Ethernet address format (for DECnet)
122 */
123union etheraddress {
124 unsigned char dne_addr[6]; /* Full ethernet address */
125 struct {
126 unsigned char dne_hiord[4]; /* DECnet HIORD prefix */
127 unsigned char dne_nodeaddr[2]; /* DECnet node address */
128 } dne_remote;
129};
130
131
132/*
133 * DECnet physical socket address format
134 */
135struct dn_addr {
136 unsigned short dna_family; /* AF_DECnet */
137 union etheraddress dna_netaddr; /* DECnet ethernet address */
138};
139
140#define DECNET_IOCTL_BASE 0x89 /* PROTOPRIVATE range */
141
142#define SIOCSNETADDR _IOW(DECNET_IOCTL_BASE, 0xe0, struct dn_naddr)
143#define SIOCGNETADDR _IOR(DECNET_IOCTL_BASE, 0xe1, struct dn_naddr)
144#define OSIOCSNETADDR _IOW(DECNET_IOCTL_BASE, 0xe0, int)
145#define OSIOCGNETADDR _IOR(DECNET_IOCTL_BASE, 0xe1, int)
146
147#endif /* _LINUX_DN_H */
diff --git a/include/linux/dnotify.h b/include/linux/dnotify.h
new file mode 100644
index 000000000000..f134a01975c7
--- /dev/null
+++ b/include/linux/dnotify.h
@@ -0,0 +1,63 @@
1#ifndef _LINUX_DNOTIFY_H
2#define _LINUX_DNOTIFY_H
3/*
4 * Directory notification for Linux
5 *
6 * Copyright (C) 2000,2002 Stephen Rothwell
7 */
8
9#include <linux/fs.h>
10
11struct dnotify_struct {
12 struct dnotify_struct * dn_next;
13 unsigned long dn_mask;
14 int dn_fd;
15 struct file * dn_filp;
16 fl_owner_t dn_owner;
17};
18
19#ifdef __KERNEL__
20
21#include <linux/config.h>
22
23#ifdef CONFIG_DNOTIFY
24
25extern void __inode_dir_notify(struct inode *, unsigned long);
26extern void dnotify_flush(struct file *, fl_owner_t);
27extern int fcntl_dirnotify(int, struct file *, unsigned long);
28extern void dnotify_parent(struct dentry *, unsigned long);
29
30static inline void inode_dir_notify(struct inode *inode, unsigned long event)
31{
32 if (inode->i_dnotify_mask & (event))
33 __inode_dir_notify(inode, event);
34}
35
36#else
37
38static inline void __inode_dir_notify(struct inode *inode, unsigned long event)
39{
40}
41
42static inline void dnotify_flush(struct file *filp, fl_owner_t id)
43{
44}
45
46static inline int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg)
47{
48 return -EINVAL;
49}
50
51static inline void dnotify_parent(struct dentry *dentry, unsigned long event)
52{
53}
54
55static inline void inode_dir_notify(struct inode *inode, unsigned long event)
56{
57}
58
59#endif /* CONFIG_DNOTIFY */
60
61#endif /* __KERNEL __ */
62
63#endif /* _LINUX_DNOTIFY_H */
diff --git a/include/linux/dqblk_v1.h b/include/linux/dqblk_v1.h
new file mode 100644
index 000000000000..42fbf4797156
--- /dev/null
+++ b/include/linux/dqblk_v1.h
@@ -0,0 +1,18 @@
1/*
2 * File with in-memory structures of old quota format
3 */
4
5#ifndef _LINUX_DQBLK_V1_H
6#define _LINUX_DQBLK_V1_H
7
8/* Id of quota format */
9#define QFMT_VFS_OLD 1
10
11/* Root squash turned on */
12#define V1_DQF_RSQUASH 1
13
14/* Special information about quotafile */
15struct v1_mem_dqinfo {
16};
17
18#endif /* _LINUX_DQBLK_V1_H */
diff --git a/include/linux/dqblk_v2.h b/include/linux/dqblk_v2.h
new file mode 100644
index 000000000000..4a6c5f6867bb
--- /dev/null
+++ b/include/linux/dqblk_v2.h
@@ -0,0 +1,20 @@
1/*
2 * Definitions of structures for vfsv0 quota format
3 */
4
5#ifndef _LINUX_DQBLK_V2_H
6#define _LINUX_DQBLK_V2_H
7
8#include <linux/types.h>
9
10/* id numbers of quota format */
11#define QFMT_VFS_V0 2
12
13/* Inmemory copy of version specific information */
14struct v2_mem_dqinfo {
15 unsigned int dqi_blocks;
16 unsigned int dqi_free_blk;
17 unsigned int dqi_free_entry;
18};
19
20#endif /* _LINUX_DQBLK_V2_H */
diff --git a/include/linux/dqblk_xfs.h b/include/linux/dqblk_xfs.h
new file mode 100644
index 000000000000..cb31719ee192
--- /dev/null
+++ b/include/linux/dqblk_xfs.h
@@ -0,0 +1,159 @@
1/*
2 * Copyright (c) 1995-2001,2004 Silicon Graphics, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2.1 of the GNU Lesser General Public License
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
16 * USA
17 *
18 * Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane,
19 * Mountain View, CA 94043, USA, or: http://www.sgi.com
20 */
21#ifndef _LINUX_DQBLK_XFS_H
22#define _LINUX_DQBLK_XFS_H
23
24#include <linux/types.h>
25
26/*
27 * Disk quota - quotactl(2) commands for the XFS Quota Manager (XQM).
28 */
29
30#define XQM_CMD(x) (('X'<<8)+(x)) /* note: forms first QCMD argument */
31#define XQM_COMMAND(x) (((x) & (0xff<<8)) == ('X'<<8)) /* test if for XFS */
32
33#define XQM_USRQUOTA 0 /* system call user quota type */
34#define XQM_GRPQUOTA 1 /* system call group quota type */
35#define XQM_MAXQUOTAS 2
36
37#define Q_XQUOTAON XQM_CMD(1) /* enable accounting/enforcement */
38#define Q_XQUOTAOFF XQM_CMD(2) /* disable accounting/enforcement */
39#define Q_XGETQUOTA XQM_CMD(3) /* get disk limits and usage */
40#define Q_XSETQLIM XQM_CMD(4) /* set disk limits */
41#define Q_XGETQSTAT XQM_CMD(5) /* get quota subsystem status */
42#define Q_XQUOTARM XQM_CMD(6) /* free disk space used by dquots */
43
44/*
45 * fs_disk_quota structure:
46 *
47 * This contains the current quota information regarding a user/proj/group.
48 * It is 64-bit aligned, and all the blk units are in BBs (Basic Blocks) of
49 * 512 bytes.
50 */
51#define FS_DQUOT_VERSION 1 /* fs_disk_quota.d_version */
52typedef struct fs_disk_quota {
53 __s8 d_version; /* version of this structure */
54 __s8 d_flags; /* XFS_{USER,PROJ,GROUP}_QUOTA */
55 __u16 d_fieldmask; /* field specifier */
56 __u32 d_id; /* user, project, or group ID */
57 __u64 d_blk_hardlimit;/* absolute limit on disk blks */
58 __u64 d_blk_softlimit;/* preferred limit on disk blks */
59 __u64 d_ino_hardlimit;/* maximum # allocated inodes */
60 __u64 d_ino_softlimit;/* preferred inode limit */
61 __u64 d_bcount; /* # disk blocks owned by the user */
62 __u64 d_icount; /* # inodes owned by the user */
63 __s32 d_itimer; /* zero if within inode limits */
64 /* if not, we refuse service */
65 __s32 d_btimer; /* similar to above; for disk blocks */
66 __u16 d_iwarns; /* # warnings issued wrt num inodes */
67 __u16 d_bwarns; /* # warnings issued wrt disk blocks */
68 __s32 d_padding2; /* padding2 - for future use */
69 __u64 d_rtb_hardlimit;/* absolute limit on realtime blks */
70 __u64 d_rtb_softlimit;/* preferred limit on RT disk blks */
71 __u64 d_rtbcount; /* # realtime blocks owned */
72 __s32 d_rtbtimer; /* similar to above; for RT disk blks */
73 __u16 d_rtbwarns; /* # warnings issued wrt RT disk blks */
74 __s16 d_padding3; /* padding3 - for future use */
75 char d_padding4[8]; /* yet more padding */
76} fs_disk_quota_t;
77
78/*
79 * These fields are sent to Q_XSETQLIM to specify fields that need to change.
80 */
81#define FS_DQ_ISOFT (1<<0)
82#define FS_DQ_IHARD (1<<1)
83#define FS_DQ_BSOFT (1<<2)
84#define FS_DQ_BHARD (1<<3)
85#define FS_DQ_RTBSOFT (1<<4)
86#define FS_DQ_RTBHARD (1<<5)
87#define FS_DQ_LIMIT_MASK (FS_DQ_ISOFT | FS_DQ_IHARD | FS_DQ_BSOFT | \
88 FS_DQ_BHARD | FS_DQ_RTBSOFT | FS_DQ_RTBHARD)
89/*
90 * These timers can only be set in super user's dquot. For others, timers are
91 * automatically started and stopped. Superusers timer values set the limits
92 * for the rest. In case these values are zero, the DQ_{F,B}TIMELIMIT values
93 * defined below are used.
94 * These values also apply only to the d_fieldmask field for Q_XSETQLIM.
95 */
96#define FS_DQ_BTIMER (1<<6)
97#define FS_DQ_ITIMER (1<<7)
98#define FS_DQ_RTBTIMER (1<<8)
99#define FS_DQ_TIMER_MASK (FS_DQ_BTIMER | FS_DQ_ITIMER | FS_DQ_RTBTIMER)
100
101/*
102 * Warning counts are set in both super user's dquot and others. For others,
103 * warnings are set/cleared by the administrators (or automatically by going
104 * below the soft limit). Superusers warning values set the warning limits
105 * for the rest. In case these values are zero, the DQ_{F,B}WARNLIMIT values
106 * defined below are used.
107 * These values also apply only to the d_fieldmask field for Q_XSETQLIM.
108 */
109#define FS_DQ_BWARNS (1<<9)
110#define FS_DQ_IWARNS (1<<10)
111#define FS_DQ_RTBWARNS (1<<11)
112#define FS_DQ_WARNS_MASK (FS_DQ_BWARNS | FS_DQ_IWARNS | FS_DQ_RTBWARNS)
113
114/*
115 * Various flags related to quotactl(2). Only relevant to XFS filesystems.
116 */
117#define XFS_QUOTA_UDQ_ACCT (1<<0) /* user quota accounting */
118#define XFS_QUOTA_UDQ_ENFD (1<<1) /* user quota limits enforcement */
119#define XFS_QUOTA_GDQ_ACCT (1<<2) /* group quota accounting */
120#define XFS_QUOTA_GDQ_ENFD (1<<3) /* group quota limits enforcement */
121#define XFS_QUOTA_PDQ_ACCT (1<<4) /* project quota accounting */
122#define XFS_QUOTA_PDQ_ENFD (1<<5) /* project quota limits enforcement */
123
124#define XFS_USER_QUOTA (1<<0) /* user quota type */
125#define XFS_PROJ_QUOTA (1<<1) /* project quota type */
126#define XFS_GROUP_QUOTA (1<<2) /* group quota type */
127
128/*
129 * fs_quota_stat is the struct returned in Q_XGETQSTAT for a given file system.
130 * Provides a centralized way to get meta infomation about the quota subsystem.
131 * eg. space taken up for user and group quotas, number of dquots currently
132 * incore.
133 */
134#define FS_QSTAT_VERSION 1 /* fs_quota_stat.qs_version */
135
136/*
137 * Some basic infomation about 'quota files'.
138 */
139typedef struct fs_qfilestat {
140 __u64 qfs_ino; /* inode number */
141 __u64 qfs_nblks; /* number of BBs 512-byte-blks */
142 __u32 qfs_nextents; /* number of extents */
143} fs_qfilestat_t;
144
145typedef struct fs_quota_stat {
146 __s8 qs_version; /* version number for future changes */
147 __u16 qs_flags; /* XFS_QUOTA_{U,P,G}DQ_{ACCT,ENFD} */
148 __s8 qs_pad; /* unused */
149 fs_qfilestat_t qs_uquota; /* user quota storage information */
150 fs_qfilestat_t qs_gquota; /* group quota storage information */
151 __u32 qs_incoredqs; /* number of dquots incore */
152 __s32 qs_btimelimit; /* limit for blks timer */
153 __s32 qs_itimelimit; /* limit for inodes timer */
154 __s32 qs_rtbtimelimit;/* limit for rt blks timer */
155 __u16 qs_bwarnlimit; /* limit for num warnings */
156 __u16 qs_iwarnlimit; /* limit for num warnings */
157} fs_quota_stat_t;
158
159#endif /* _LINUX_DQBLK_XFS_H */
diff --git a/include/linux/ds1286.h b/include/linux/ds1286.h
new file mode 100644
index 000000000000..d8989860e4ce
--- /dev/null
+++ b/include/linux/ds1286.h
@@ -0,0 +1,54 @@
1/*
2 * Copyright (C) 1998, 1999, 2003 Ralf Baechle
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#ifndef __LINUX_DS1286_H
9#define __LINUX_DS1286_H
10
11#include <asm/ds1286.h>
12
13/**********************************************************************
14 * register summary
15 **********************************************************************/
16#define RTC_HUNDREDTH_SECOND 0
17#define RTC_SECONDS 1
18#define RTC_MINUTES 2
19#define RTC_MINUTES_ALARM 3
20#define RTC_HOURS 4
21#define RTC_HOURS_ALARM 5
22#define RTC_DAY 6
23#define RTC_DAY_ALARM 7
24#define RTC_DATE 8
25#define RTC_MONTH 9
26#define RTC_YEAR 10
27#define RTC_CMD 11
28#define RTC_WHSEC 12
29#define RTC_WSEC 13
30#define RTC_UNUSED 14
31
32/* RTC_*_alarm is always true if 2 MSBs are set */
33# define RTC_ALARM_DONT_CARE 0xC0
34
35
36/*
37 * Bits in the month register
38 */
39#define RTC_EOSC 0x80
40#define RTC_ESQW 0x40
41
42/*
43 * Bits in the Command register
44 */
45#define RTC_TDF 0x01
46#define RTC_WAF 0x02
47#define RTC_TDM 0x04
48#define RTC_WAM 0x08
49#define RTC_PU_LVL 0x10
50#define RTC_IBH_LO 0x20
51#define RTC_IPSW 0x40
52#define RTC_TE 0x80
53
54#endif /* __LINUX_DS1286_H */
diff --git a/include/linux/dtlk.h b/include/linux/dtlk.h
new file mode 100644
index 000000000000..2896d90118a9
--- /dev/null
+++ b/include/linux/dtlk.h
@@ -0,0 +1,104 @@
1#if 0
2
3#define TRACE_TXT(text) \
4 { \
5 if(dtlk_trace) \
6 { \
7 console_print(text); \
8 console_print("\n"); \
9 } \
10 }
11
12#define TRACE_CHR(chr) \
13 { \
14 if(dtlk_trace) \
15 console_print(chr); \
16 } \
17
18#endif
19
20#define DTLK_MINOR 0
21#define DTLK_IO_EXTENT 0x02
22
23 /* ioctl's use magic number of 0xa3 */
24#define DTLK_INTERROGATE 0xa390 /* get settings from the DoubleTalk */
25#define DTLK_STATUS 0xa391 /* get status from the DoubleTalk */
26
27
28#define DTLK_CLEAR 0x18 /* stops speech */
29
30#define DTLK_MAX_RETRIES (loops_per_jiffy/(10000/HZ))
31
32 /* TTS Port Status Flags */
33#define TTS_READABLE 0x80 /* mask for bit which is nonzero if a
34 byte can be read from the TTS port */
35#define TTS_SPEAKING 0x40 /* mask for SYNC bit, which is nonzero
36 while DoubleTalk is producing
37 output with TTS, PCM or CVSD
38 synthesizers or tone generators
39 (that is, all but LPC) */
40#define TTS_SPEAKING2 0x20 /* mask for SYNC2 bit,
41 which falls to zero up to 0.4 sec
42 before speech stops */
43#define TTS_WRITABLE 0x10 /* mask for RDY bit, which when set to
44 1, indicates the TTS port is ready
45 to accept a byte of data. The RDY
46 bit goes zero 2-3 usec after
47 writing, and goes 1 again 180-190
48 usec later. */
49#define TTS_ALMOST_FULL 0x08 /* mask for AF bit: When set to 1,
50 indicates that less than 300 free
51 bytes are available in the TTS
52 input buffer. AF is always 0 in the
53 PCM, TGN and CVSD modes. */
54#define TTS_ALMOST_EMPTY 0x04 /* mask for AE bit: When set to 1,
55 indicates that less than 300 bytes
56 of data remain in DoubleTalk's
57 input (TTS or PCM) buffer. AE is
58 always 1 in the TGN and CVSD
59 modes. */
60
61 /* LPC speak commands */
62#define LPC_5220_NORMAL 0x60 /* 5220 format decoding table, normal rate */
63#define LPC_5220_FAST 0x64 /* 5220 format decoding table, fast rate */
64#define LPC_D6_NORMAL 0x20 /* D6 format decoding table, normal rate */
65#define LPC_D6_FAST 0x24 /* D6 format decoding table, fast rate */
66
67 /* LPC Port Status Flags (valid only after one of the LPC
68 speak commands) */
69#define LPC_SPEAKING 0x80 /* mask for TS bit: When set to 1,
70 indicates the LPC synthesizer is
71 producing speech.*/
72#define LPC_BUFFER_LOW 0x40 /* mask for BL bit: When set to 1,
73 indicates that the hardware LPC
74 data buffer has less than 30 bytes
75 remaining. (Total internal buffer
76 size = 4096 bytes.) */
77#define LPC_BUFFER_EMPTY 0x20 /* mask for BE bit: When set to 1,
78 indicates that the LPC data buffer
79 ran out of data (error condition if
80 TS is also 1). */
81
82 /* data returned by Interrogate command */
83struct dtlk_settings
84{
85 unsigned short serial_number; /* 0-7Fh:0-7Fh */
86 unsigned char rom_version[24]; /* null terminated string */
87 unsigned char mode; /* 0=Character; 1=Phoneme; 2=Text */
88 unsigned char punc_level; /* nB; 0-7 */
89 unsigned char formant_freq; /* nF; 0-9 */
90 unsigned char pitch; /* nP; 0-99 */
91 unsigned char speed; /* nS; 0-9 */
92 unsigned char volume; /* nV; 0-9 */
93 unsigned char tone; /* nX; 0-2 */
94 unsigned char expression; /* nE; 0-9 */
95 unsigned char ext_dict_loaded; /* 1=exception dictionary loaded */
96 unsigned char ext_dict_status; /* 1=exception dictionary enabled */
97 unsigned char free_ram; /* # pages (truncated) remaining for
98 text buffer */
99 unsigned char articulation; /* nA; 0-9 */
100 unsigned char reverb; /* nR; 0-9 */
101 unsigned char eob; /* 7Fh value indicating end of
102 parameter block */
103 unsigned char has_indexing; /* nonzero if indexing is implemented */
104};
diff --git a/include/linux/dvb/audio.h b/include/linux/dvb/audio.h
new file mode 100644
index 000000000000..cc314443f1c4
--- /dev/null
+++ b/include/linux/dvb/audio.h
@@ -0,0 +1,124 @@
1/*
2 * audio.h
3 *
4 * Copyright (C) 2000 Ralph Metzler <ralph@convergence.de>
5 * & Marcus Metzler <marcus@convergence.de>
6 * for convergence integrated media GmbH
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Lesser Public License
10 * as published by the Free Software Foundation; either version 2.1
11 * of the License, or (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 Lesser General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 *
22 */
23
24#ifndef _DVBAUDIO_H_
25#define _DVBAUDIO_H_
26
27#ifdef __KERNEL__
28#include <linux/types.h>
29#else
30#include <stdint.h>
31#endif
32
33
34typedef enum {
35 AUDIO_SOURCE_DEMUX, /* Select the demux as the main source */
36 AUDIO_SOURCE_MEMORY /* Select internal memory as the main source */
37} audio_stream_source_t;
38
39
40typedef enum {
41 AUDIO_STOPPED, /* Device is stopped */
42 AUDIO_PLAYING, /* Device is currently playing */
43 AUDIO_PAUSED /* Device is paused */
44} audio_play_state_t;
45
46
47typedef enum {
48 AUDIO_STEREO,
49 AUDIO_MONO_LEFT,
50 AUDIO_MONO_RIGHT
51} audio_channel_select_t;
52
53
54typedef struct audio_mixer {
55 unsigned int volume_left;
56 unsigned int volume_right;
57 // what else do we need? bass, pass-through, ...
58} audio_mixer_t;
59
60
61typedef struct audio_status {
62 int AV_sync_state; /* sync audio and video? */
63 int mute_state; /* audio is muted */
64 audio_play_state_t play_state; /* current playback state */
65 audio_stream_source_t stream_source; /* current stream source */
66 audio_channel_select_t channel_select; /* currently selected channel */
67 int bypass_mode; /* pass on audio data to */
68 audio_mixer_t mixer_state; /* current mixer state */
69} audio_status_t; /* separate decoder hardware */
70
71
72typedef
73struct audio_karaoke{ /* if Vocal1 or Vocal2 are non-zero, they get mixed */
74 int vocal1; /* into left and right t at 70% each */
75 int vocal2; /* if both, Vocal1 and Vocal2 are non-zero, Vocal1 gets*/
76 int melody; /* mixed into the left channel and */
77 /* Vocal2 into the right channel at 100% each. */
78 /* if Melody is non-zero, the melody channel gets mixed*/
79} audio_karaoke_t; /* into left and right */
80
81
82typedef uint16_t audio_attributes_t;
83/* bits: descr. */
84/* 15-13 audio coding mode (0=ac3, 2=mpeg1, 3=mpeg2ext, 4=LPCM, 6=DTS, */
85/* 12 multichannel extension */
86/* 11-10 audio type (0=not spec, 1=language included) */
87/* 9- 8 audio application mode (0=not spec, 1=karaoke, 2=surround) */
88/* 7- 6 Quantization / DRC (mpeg audio: 1=DRC exists)(lpcm: 0=16bit, */
89/* 5- 4 Sample frequency fs (0=48kHz, 1=96kHz) */
90/* 2- 0 number of audio channels (n+1 channels) */
91
92
93/* for GET_CAPABILITIES and SET_FORMAT, the latter should only set one bit */
94#define AUDIO_CAP_DTS 1
95#define AUDIO_CAP_LPCM 2
96#define AUDIO_CAP_MP1 4
97#define AUDIO_CAP_MP2 8
98#define AUDIO_CAP_MP3 16
99#define AUDIO_CAP_AAC 32
100#define AUDIO_CAP_OGG 64
101#define AUDIO_CAP_SDDS 128
102#define AUDIO_CAP_AC3 256
103
104#define AUDIO_STOP _IO('o', 1)
105#define AUDIO_PLAY _IO('o', 2)
106#define AUDIO_PAUSE _IO('o', 3)
107#define AUDIO_CONTINUE _IO('o', 4)
108#define AUDIO_SELECT_SOURCE _IO('o', 5)
109#define AUDIO_SET_MUTE _IO('o', 6)
110#define AUDIO_SET_AV_SYNC _IO('o', 7)
111#define AUDIO_SET_BYPASS_MODE _IO('o', 8)
112#define AUDIO_CHANNEL_SELECT _IO('o', 9)
113#define AUDIO_GET_STATUS _IOR('o', 10, audio_status_t)
114
115#define AUDIO_GET_CAPABILITIES _IOR('o', 11, unsigned int)
116#define AUDIO_CLEAR_BUFFER _IO('o', 12)
117#define AUDIO_SET_ID _IO('o', 13)
118#define AUDIO_SET_MIXER _IOW('o', 14, audio_mixer_t)
119#define AUDIO_SET_STREAMTYPE _IO('o', 15)
120#define AUDIO_SET_EXT_ID _IO('o', 16)
121#define AUDIO_SET_ATTRIBUTES _IOW('o', 17, audio_attributes_t)
122#define AUDIO_SET_KARAOKE _IOW('o', 18, audio_karaoke_t)
123
124#endif /* _DVBAUDIO_H_ */
diff --git a/include/linux/dvb/ca.h b/include/linux/dvb/ca.h
new file mode 100644
index 000000000000..558af0cc7692
--- /dev/null
+++ b/include/linux/dvb/ca.h
@@ -0,0 +1,90 @@
1/*
2 * ca.h
3 *
4 * Copyright (C) 2000 Ralph Metzler <ralph@convergence.de>
5 * & Marcus Metzler <marcus@convergence.de>
6 * for convergence integrated media GmbH
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Lesser Public License
10 * as published by the Free Software Foundation; either version 2.1
11 * of the License, or (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 Lesser General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 *
22 */
23
24#ifndef _DVBCA_H_
25#define _DVBCA_H_
26
27/* slot interface types and info */
28
29typedef struct ca_slot_info {
30 int num; /* slot number */
31
32 int type; /* CA interface this slot supports */
33#define CA_CI 1 /* CI high level interface */
34#define CA_CI_LINK 2 /* CI link layer level interface */
35#define CA_CI_PHYS 4 /* CI physical layer level interface */
36#define CA_DESCR 8 /* built-in descrambler */
37#define CA_SC 128 /* simple smart card interface */
38
39 unsigned int flags;
40#define CA_CI_MODULE_PRESENT 1 /* module (or card) inserted */
41#define CA_CI_MODULE_READY 2
42} ca_slot_info_t;
43
44
45/* descrambler types and info */
46
47typedef struct ca_descr_info {
48 unsigned int num; /* number of available descramblers (keys) */
49 unsigned int type; /* type of supported scrambling system */
50#define CA_ECD 1
51#define CA_NDS 2
52#define CA_DSS 4
53} ca_descr_info_t;
54
55typedef struct ca_caps {
56 unsigned int slot_num; /* total number of CA card and module slots */
57 unsigned int slot_type; /* OR of all supported types */
58 unsigned int descr_num; /* total number of descrambler slots (keys) */
59 unsigned int descr_type; /* OR of all supported types */
60} ca_caps_t;
61
62/* a message to/from a CI-CAM */
63typedef struct ca_msg {
64 unsigned int index;
65 unsigned int type;
66 unsigned int length;
67 unsigned char msg[256];
68} ca_msg_t;
69
70typedef struct ca_descr {
71 unsigned int index;
72 unsigned int parity; /* 0 == even, 1 == odd */
73 unsigned char cw[8];
74} ca_descr_t;
75
76typedef struct ca_pid {
77 unsigned int pid;
78 int index; /* -1 == disable*/
79} ca_pid_t;
80
81#define CA_RESET _IO('o', 128)
82#define CA_GET_CAP _IOR('o', 129, ca_caps_t)
83#define CA_GET_SLOT_INFO _IOR('o', 130, ca_slot_info_t)
84#define CA_GET_DESCR_INFO _IOR('o', 131, ca_descr_info_t)
85#define CA_GET_MSG _IOR('o', 132, ca_msg_t)
86#define CA_SEND_MSG _IOW('o', 133, ca_msg_t)
87#define CA_SET_DESCR _IOW('o', 134, ca_descr_t)
88#define CA_SET_PID _IOW('o', 135, ca_pid_t)
89
90#endif
diff --git a/include/linux/dvb/dmx.h b/include/linux/dvb/dmx.h
new file mode 100644
index 000000000000..ce3f829da82c
--- /dev/null
+++ b/include/linux/dvb/dmx.h
@@ -0,0 +1,180 @@
1/*
2 * dmx.h
3 *
4 * Copyright (C) 2000 Marcus Metzler <marcus@convergence.de>
5 * & Ralph Metzler <ralph@convergence.de>
6 * for convergence integrated media GmbH
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 2.1
11 * of the License, or (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 Lesser General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 *
22 */
23
24#ifndef _DVBDMX_H_
25#define _DVBDMX_H_
26
27#include <asm/types.h>
28#ifdef __KERNEL__
29#include <linux/time.h>
30#else
31#include <time.h>
32#endif
33
34
35#define DMX_FILTER_SIZE 16
36
37typedef enum
38{
39 DMX_OUT_DECODER, /* Streaming directly to decoder. */
40 DMX_OUT_TAP, /* Output going to a memory buffer */
41 /* (to be retrieved via the read command).*/
42 DMX_OUT_TS_TAP /* Output multiplexed into a new TS */
43 /* (to be retrieved by reading from the */
44 /* logical DVR device). */
45} dmx_output_t;
46
47
48typedef enum
49{
50 DMX_IN_FRONTEND, /* Input from a front-end device. */
51 DMX_IN_DVR /* Input from the logical DVR device. */
52} dmx_input_t;
53
54
55typedef enum
56{
57 DMX_PES_AUDIO0,
58 DMX_PES_VIDEO0,
59 DMX_PES_TELETEXT0,
60 DMX_PES_SUBTITLE0,
61 DMX_PES_PCR0,
62
63 DMX_PES_AUDIO1,
64 DMX_PES_VIDEO1,
65 DMX_PES_TELETEXT1,
66 DMX_PES_SUBTITLE1,
67 DMX_PES_PCR1,
68
69 DMX_PES_AUDIO2,
70 DMX_PES_VIDEO2,
71 DMX_PES_TELETEXT2,
72 DMX_PES_SUBTITLE2,
73 DMX_PES_PCR2,
74
75 DMX_PES_AUDIO3,
76 DMX_PES_VIDEO3,
77 DMX_PES_TELETEXT3,
78 DMX_PES_SUBTITLE3,
79 DMX_PES_PCR3,
80
81 DMX_PES_OTHER
82} dmx_pes_type_t;
83
84#define DMX_PES_AUDIO DMX_PES_AUDIO0
85#define DMX_PES_VIDEO DMX_PES_VIDEO0
86#define DMX_PES_TELETEXT DMX_PES_TELETEXT0
87#define DMX_PES_SUBTITLE DMX_PES_SUBTITLE0
88#define DMX_PES_PCR DMX_PES_PCR0
89
90
91typedef enum
92{
93 DMX_SCRAMBLING_EV,
94 DMX_FRONTEND_EV
95} dmx_event_t;
96
97
98typedef enum
99{
100 DMX_SCRAMBLING_OFF,
101 DMX_SCRAMBLING_ON
102} dmx_scrambling_status_t;
103
104
105typedef struct dmx_filter
106{
107 __u8 filter[DMX_FILTER_SIZE];
108 __u8 mask[DMX_FILTER_SIZE];
109 __u8 mode[DMX_FILTER_SIZE];
110} dmx_filter_t;
111
112
113struct dmx_sct_filter_params
114{
115 __u16 pid;
116 dmx_filter_t filter;
117 __u32 timeout;
118 __u32 flags;
119#define DMX_CHECK_CRC 1
120#define DMX_ONESHOT 2
121#define DMX_IMMEDIATE_START 4
122#define DMX_KERNEL_CLIENT 0x8000
123};
124
125
126struct dmx_pes_filter_params
127{
128 __u16 pid;
129 dmx_input_t input;
130 dmx_output_t output;
131 dmx_pes_type_t pes_type;
132 __u32 flags;
133};
134
135
136struct dmx_event
137{
138 dmx_event_t event;
139 time_t timeStamp;
140 union
141 {
142 dmx_scrambling_status_t scrambling;
143 } u;
144};
145
146typedef struct dmx_caps {
147 __u32 caps;
148 int num_decoders;
149} dmx_caps_t;
150
151typedef enum {
152 DMX_SOURCE_FRONT0 = 0,
153 DMX_SOURCE_FRONT1,
154 DMX_SOURCE_FRONT2,
155 DMX_SOURCE_FRONT3,
156 DMX_SOURCE_DVR0 = 16,
157 DMX_SOURCE_DVR1,
158 DMX_SOURCE_DVR2,
159 DMX_SOURCE_DVR3
160} dmx_source_t;
161
162struct dmx_stc {
163 unsigned int num; /* input : which STC? 0..N */
164 unsigned int base; /* output: divisor for stc to get 90 kHz clock */
165 __u64 stc; /* output: stc in 'base'*90 kHz units */
166};
167
168
169#define DMX_START _IO('o', 41)
170#define DMX_STOP _IO('o', 42)
171#define DMX_SET_FILTER _IOW('o', 43, struct dmx_sct_filter_params)
172#define DMX_SET_PES_FILTER _IOW('o', 44, struct dmx_pes_filter_params)
173#define DMX_SET_BUFFER_SIZE _IO('o', 45)
174#define DMX_GET_EVENT _IOR('o', 46, struct dmx_event)
175#define DMX_GET_PES_PIDS _IOR('o', 47, __u16[5])
176#define DMX_GET_CAPS _IOR('o', 48, dmx_caps_t)
177#define DMX_SET_SOURCE _IOW('o', 49, dmx_source_t)
178#define DMX_GET_STC _IOWR('o', 50, struct dmx_stc)
179
180#endif /*_DVBDMX_H_*/
diff --git a/include/linux/dvb/frontend.h b/include/linux/dvb/frontend.h
new file mode 100644
index 000000000000..d41df7047ed7
--- /dev/null
+++ b/include/linux/dvb/frontend.h
@@ -0,0 +1,267 @@
1/*
2 * frontend.h
3 *
4 * Copyright (C) 2000 Marcus Metzler <marcus@convergence.de>
5 * Ralph Metzler <ralph@convergence.de>
6 * Holger Waechtler <holger@convergence.de>
7 * Andre Draszik <ad@convergence.de>
8 * for convergence integrated media GmbH
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public License
12 * as published by the Free Software Foundation; either version 2.1
13 * of the License, or (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 Lesser General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 *
24 */
25
26#ifndef _DVBFRONTEND_H_
27#define _DVBFRONTEND_H_
28
29#include <asm/types.h>
30
31
32typedef enum fe_type {
33 FE_QPSK,
34 FE_QAM,
35 FE_OFDM,
36 FE_ATSC
37} fe_type_t;
38
39
40typedef enum fe_caps {
41 FE_IS_STUPID = 0,
42 FE_CAN_INVERSION_AUTO = 0x1,
43 FE_CAN_FEC_1_2 = 0x2,
44 FE_CAN_FEC_2_3 = 0x4,
45 FE_CAN_FEC_3_4 = 0x8,
46 FE_CAN_FEC_4_5 = 0x10,
47 FE_CAN_FEC_5_6 = 0x20,
48 FE_CAN_FEC_6_7 = 0x40,
49 FE_CAN_FEC_7_8 = 0x80,
50 FE_CAN_FEC_8_9 = 0x100,
51 FE_CAN_FEC_AUTO = 0x200,
52 FE_CAN_QPSK = 0x400,
53 FE_CAN_QAM_16 = 0x800,
54 FE_CAN_QAM_32 = 0x1000,
55 FE_CAN_QAM_64 = 0x2000,
56 FE_CAN_QAM_128 = 0x4000,
57 FE_CAN_QAM_256 = 0x8000,
58 FE_CAN_QAM_AUTO = 0x10000,
59 FE_CAN_TRANSMISSION_MODE_AUTO = 0x20000,
60 FE_CAN_BANDWIDTH_AUTO = 0x40000,
61 FE_CAN_GUARD_INTERVAL_AUTO = 0x80000,
62 FE_CAN_HIERARCHY_AUTO = 0x100000,
63 FE_CAN_8VSB = 0x200000,
64 FE_CAN_16VSB = 0x400000,
65 FE_NEEDS_BENDING = 0x20000000, // not supported anymore, don't use (frontend requires frequency bending)
66 FE_CAN_RECOVER = 0x40000000, // frontend can recover from a cable unplug automatically
67 FE_CAN_MUTE_TS = 0x80000000 // frontend can stop spurious TS data output
68} fe_caps_t;
69
70
71struct dvb_frontend_info {
72 char name[128];
73 fe_type_t type;
74 __u32 frequency_min;
75 __u32 frequency_max;
76 __u32 frequency_stepsize;
77 __u32 frequency_tolerance;
78 __u32 symbol_rate_min;
79 __u32 symbol_rate_max;
80 __u32 symbol_rate_tolerance; /* ppm */
81 __u32 notifier_delay; /* DEPRECATED */
82 fe_caps_t caps;
83};
84
85
86/**
87 * Check out the DiSEqC bus spec available on http://www.eutelsat.org/ for
88 * the meaning of this struct...
89 */
90struct dvb_diseqc_master_cmd {
91 __u8 msg [6]; /* { framing, address, command, data [3] } */
92 __u8 msg_len; /* valid values are 3...6 */
93};
94
95
96struct dvb_diseqc_slave_reply {
97 __u8 msg [4]; /* { framing, data [3] } */
98 __u8 msg_len; /* valid values are 0...4, 0 means no msg */
99 int timeout; /* return from ioctl after timeout ms with */
100}; /* errorcode when no message was received */
101
102
103typedef enum fe_sec_voltage {
104 SEC_VOLTAGE_13,
105 SEC_VOLTAGE_18,
106 SEC_VOLTAGE_OFF
107} fe_sec_voltage_t;
108
109
110typedef enum fe_sec_tone_mode {
111 SEC_TONE_ON,
112 SEC_TONE_OFF
113} fe_sec_tone_mode_t;
114
115
116typedef enum fe_sec_mini_cmd {
117 SEC_MINI_A,
118 SEC_MINI_B
119} fe_sec_mini_cmd_t;
120
121
122typedef enum fe_status {
123 FE_HAS_SIGNAL = 0x01, /* found something above the noise level */
124 FE_HAS_CARRIER = 0x02, /* found a DVB signal */
125 FE_HAS_VITERBI = 0x04, /* FEC is stable */
126 FE_HAS_SYNC = 0x08, /* found sync bytes */
127 FE_HAS_LOCK = 0x10, /* everything's working... */
128 FE_TIMEDOUT = 0x20, /* no lock within the last ~2 seconds */
129 FE_REINIT = 0x40 /* frontend was reinitialized, */
130} fe_status_t; /* application is recommended to reset */
131 /* DiSEqC, tone and parameters */
132
133typedef enum fe_spectral_inversion {
134 INVERSION_OFF,
135 INVERSION_ON,
136 INVERSION_AUTO
137} fe_spectral_inversion_t;
138
139
140typedef enum fe_code_rate {
141 FEC_NONE = 0,
142 FEC_1_2,
143 FEC_2_3,
144 FEC_3_4,
145 FEC_4_5,
146 FEC_5_6,
147 FEC_6_7,
148 FEC_7_8,
149 FEC_8_9,
150 FEC_AUTO
151} fe_code_rate_t;
152
153
154typedef enum fe_modulation {
155 QPSK,
156 QAM_16,
157 QAM_32,
158 QAM_64,
159 QAM_128,
160 QAM_256,
161 QAM_AUTO,
162 VSB_8,
163 VSB_16
164} fe_modulation_t;
165
166typedef enum fe_transmit_mode {
167 TRANSMISSION_MODE_2K,
168 TRANSMISSION_MODE_8K,
169 TRANSMISSION_MODE_AUTO
170} fe_transmit_mode_t;
171
172typedef enum fe_bandwidth {
173 BANDWIDTH_8_MHZ,
174 BANDWIDTH_7_MHZ,
175 BANDWIDTH_6_MHZ,
176 BANDWIDTH_AUTO
177} fe_bandwidth_t;
178
179
180typedef enum fe_guard_interval {
181 GUARD_INTERVAL_1_32,
182 GUARD_INTERVAL_1_16,
183 GUARD_INTERVAL_1_8,
184 GUARD_INTERVAL_1_4,
185 GUARD_INTERVAL_AUTO
186} fe_guard_interval_t;
187
188
189typedef enum fe_hierarchy {
190 HIERARCHY_NONE,
191 HIERARCHY_1,
192 HIERARCHY_2,
193 HIERARCHY_4,
194 HIERARCHY_AUTO
195} fe_hierarchy_t;
196
197
198struct dvb_qpsk_parameters {
199 __u32 symbol_rate; /* symbol rate in Symbols per second */
200 fe_code_rate_t fec_inner; /* forward error correction (see above) */
201};
202
203struct dvb_qam_parameters {
204 __u32 symbol_rate; /* symbol rate in Symbols per second */
205 fe_code_rate_t fec_inner; /* forward error correction (see above) */
206 fe_modulation_t modulation; /* modulation type (see above) */
207};
208
209struct dvb_vsb_parameters {
210 fe_modulation_t modulation; /* modulation type (see above) */
211};
212
213struct dvb_ofdm_parameters {
214 fe_bandwidth_t bandwidth;
215 fe_code_rate_t code_rate_HP; /* high priority stream code rate */
216 fe_code_rate_t code_rate_LP; /* low priority stream code rate */
217 fe_modulation_t constellation; /* modulation type (see above) */
218 fe_transmit_mode_t transmission_mode;
219 fe_guard_interval_t guard_interval;
220 fe_hierarchy_t hierarchy_information;
221};
222
223
224struct dvb_frontend_parameters {
225 __u32 frequency; /* (absolute) frequency in Hz for QAM/OFDM/ATSC */
226 /* intermediate frequency in kHz for QPSK */
227 fe_spectral_inversion_t inversion;
228 union {
229 struct dvb_qpsk_parameters qpsk;
230 struct dvb_qam_parameters qam;
231 struct dvb_ofdm_parameters ofdm;
232 struct dvb_vsb_parameters vsb;
233 } u;
234};
235
236
237struct dvb_frontend_event {
238 fe_status_t status;
239 struct dvb_frontend_parameters parameters;
240};
241
242
243
244#define FE_GET_INFO _IOR('o', 61, struct dvb_frontend_info)
245
246#define FE_DISEQC_RESET_OVERLOAD _IO('o', 62)
247#define FE_DISEQC_SEND_MASTER_CMD _IOW('o', 63, struct dvb_diseqc_master_cmd)
248#define FE_DISEQC_RECV_SLAVE_REPLY _IOR('o', 64, struct dvb_diseqc_slave_reply)
249#define FE_DISEQC_SEND_BURST _IO('o', 65) /* fe_sec_mini_cmd_t */
250
251#define FE_SET_TONE _IO('o', 66) /* fe_sec_tone_mode_t */
252#define FE_SET_VOLTAGE _IO('o', 67) /* fe_sec_voltage_t */
253#define FE_ENABLE_HIGH_LNB_VOLTAGE _IO('o', 68) /* int */
254
255#define FE_READ_STATUS _IOR('o', 69, fe_status_t)
256#define FE_READ_BER _IOR('o', 70, __u32)
257#define FE_READ_SIGNAL_STRENGTH _IOR('o', 71, __u16)
258#define FE_READ_SNR _IOR('o', 72, __u16)
259#define FE_READ_UNCORRECTED_BLOCKS _IOR('o', 73, __u32)
260
261#define FE_SET_FRONTEND _IOW('o', 76, struct dvb_frontend_parameters)
262#define FE_GET_FRONTEND _IOR('o', 77, struct dvb_frontend_parameters)
263#define FE_GET_EVENT _IOR('o', 78, struct dvb_frontend_event)
264
265#define FE_DISHNETWORK_SEND_LEGACY_CMD _IO('o', 80) /* unsigned int */
266
267#endif /*_DVBFRONTEND_H_*/
diff --git a/include/linux/dvb/net.h b/include/linux/dvb/net.h
new file mode 100644
index 000000000000..5be474bf0d2b
--- /dev/null
+++ b/include/linux/dvb/net.h
@@ -0,0 +1,53 @@
1/*
2 * net.h
3 *
4 * Copyright (C) 2000 Marcus Metzler <marcus@convergence.de>
5 * & Ralph Metzler <ralph@convergence.de>
6 * for convergence integrated media GmbH
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 2.1
11 * of the License, or (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 Lesser General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 *
22 */
23
24#ifndef _DVBNET_H_
25#define _DVBNET_H_
26
27#include <asm/types.h>
28
29
30struct dvb_net_if {
31 __u16 pid;
32 __u16 if_num;
33 __u8 feedtype;
34#define DVB_NET_FEEDTYPE_MPE 0 /* multi protocol encapsulation */
35#define DVB_NET_FEEDTYPE_ULE 1 /* ultra lightweight encapsulation */
36};
37
38
39#define NET_ADD_IF _IOWR('o', 52, struct dvb_net_if)
40#define NET_REMOVE_IF _IO('o', 53)
41#define NET_GET_IF _IOWR('o', 54, struct dvb_net_if)
42
43
44/* binary compatibility cruft: */
45struct __dvb_net_if_old {
46 __u16 pid;
47 __u16 if_num;
48};
49#define __NET_ADD_IF_OLD _IOWR('o', 52, struct __dvb_net_if_old)
50#define __NET_GET_IF_OLD _IOWR('o', 54, struct __dvb_net_if_old)
51
52
53#endif /*_DVBNET_H_*/
diff --git a/include/linux/dvb/osd.h b/include/linux/dvb/osd.h
new file mode 100644
index 000000000000..0e1973d54a6b
--- /dev/null
+++ b/include/linux/dvb/osd.h
@@ -0,0 +1,144 @@
1/*
2 * osd.h
3 *
4 * Copyright (C) 2001 Ralph Metzler <ralph@convergence.de>
5 * & Marcus Metzler <marcus@convergence.de>
6 * for convergence integrated media GmbH
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Lesser Public License
10 * as published by the Free Software Foundation; either version 2.1
11 * of the License, or (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 Lesser General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 *
22 */
23
24#ifndef _DVBOSD_H_
25#define _DVBOSD_H_
26
27#include <linux/compiler.h>
28
29typedef enum {
30 // All functions return -2 on "not open"
31 OSD_Close=1, // ()
32 // Disables OSD and releases the buffers
33 // returns 0 on success
34 OSD_Open, // (x0,y0,x1,y1,BitPerPixel[2/4/8](color&0x0F),mix[0..15](color&0xF0))
35 // Opens OSD with this size and bit depth
36 // returns 0 on success, -1 on DRAM allocation error, -2 on "already open"
37 OSD_Show, // ()
38 // enables OSD mode
39 // returns 0 on success
40 OSD_Hide, // ()
41 // disables OSD mode
42 // returns 0 on success
43 OSD_Clear, // ()
44 // Sets all pixel to color 0
45 // returns 0 on success
46 OSD_Fill, // (color)
47 // Sets all pixel to color <col>
48 // returns 0 on success
49 OSD_SetColor, // (color,R{x0},G{y0},B{x1},opacity{y1})
50 // set palette entry <num> to <r,g,b>, <mix> and <trans> apply
51 // R,G,B: 0..255
52 // R=Red, G=Green, B=Blue
53 // opacity=0: pixel opacity 0% (only video pixel shows)
54 // opacity=1..254: pixel opacity as specified in header
55 // opacity=255: pixel opacity 100% (only OSD pixel shows)
56 // returns 0 on success, -1 on error
57 OSD_SetPalette, // (firstcolor{color},lastcolor{x0},data)
58 // Set a number of entries in the palette
59 // sets the entries "firstcolor" through "lastcolor" from the array "data"
60 // data has 4 byte for each color:
61 // R,G,B, and a opacity value: 0->transparent, 1..254->mix, 255->pixel
62 OSD_SetTrans, // (transparency{color})
63 // Sets transparency of mixed pixel (0..15)
64 // returns 0 on success
65 OSD_SetPixel, // (x0,y0,color)
66 // sets pixel <x>,<y> to color number <col>
67 // returns 0 on success, -1 on error
68 OSD_GetPixel, // (x0,y0)
69 // returns color number of pixel <x>,<y>, or -1
70 OSD_SetRow, // (x0,y0,x1,data)
71 // fills pixels x0,y through x1,y with the content of data[]
72 // returns 0 on success, -1 on clipping all pixel (no pixel drawn)
73 OSD_SetBlock, // (x0,y0,x1,y1,increment{color},data)
74 // fills pixels x0,y0 through x1,y1 with the content of data[]
75 // inc contains the width of one line in the data block,
76 // inc<=0 uses blockwidth as linewidth
77 // returns 0 on success, -1 on clipping all pixel
78 OSD_FillRow, // (x0,y0,x1,color)
79 // fills pixels x0,y through x1,y with the color <col>
80 // returns 0 on success, -1 on clipping all pixel
81 OSD_FillBlock, // (x0,y0,x1,y1,color)
82 // fills pixels x0,y0 through x1,y1 with the color <col>
83 // returns 0 on success, -1 on clipping all pixel
84 OSD_Line, // (x0,y0,x1,y1,color)
85 // draw a line from x0,y0 to x1,y1 with the color <col>
86 // returns 0 on success
87 OSD_Query, // (x0,y0,x1,y1,xasp{color}}), yasp=11
88 // fills parameters with the picture dimensions and the pixel aspect ratio
89 // returns 0 on success
90 OSD_Test, // ()
91 // draws a test picture. for debugging purposes only
92 // returns 0 on success
93// TODO: remove "test" in final version
94 OSD_Text, // (x0,y0,size,color,text)
95 OSD_SetWindow, // (x0) set window with number 0<x0<8 as current
96 OSD_MoveWindow, // move current window to (x0, y0)
97 OSD_OpenRaw, // Open other types of OSD windows
98} OSD_Command;
99
100typedef struct osd_cmd_s {
101 OSD_Command cmd;
102 int x0;
103 int y0;
104 int x1;
105 int y1;
106 int color;
107 void __user *data;
108} osd_cmd_t;
109
110/* OSD_OpenRaw: set 'color' to desired window type */
111typedef enum {
112 OSD_BITMAP1, /* 1 bit bitmap */
113 OSD_BITMAP2, /* 2 bit bitmap */
114 OSD_BITMAP4, /* 4 bit bitmap */
115 OSD_BITMAP8, /* 8 bit bitmap */
116 OSD_BITMAP1HR, /* 1 Bit bitmap half resolution */
117 OSD_BITMAP2HR, /* 2 bit bitmap half resolution */
118 OSD_BITMAP4HR, /* 4 bit bitmap half resolution */
119 OSD_BITMAP8HR, /* 8 bit bitmap half resolution */
120 OSD_YCRCB422, /* 4:2:2 YCRCB Graphic Display */
121 OSD_YCRCB444, /* 4:4:4 YCRCB Graphic Display */
122 OSD_YCRCB444HR, /* 4:4:4 YCRCB graphic half resolution */
123 OSD_VIDEOTSIZE, /* True Size Normal MPEG Video Display */
124 OSD_VIDEOHSIZE, /* MPEG Video Display Half Resolution */
125 OSD_VIDEOQSIZE, /* MPEG Video Display Quarter Resolution */
126 OSD_VIDEODSIZE, /* MPEG Video Display Double Resolution */
127 OSD_VIDEOTHSIZE, /* True Size MPEG Video Display Half Resolution */
128 OSD_VIDEOTQSIZE, /* True Size MPEG Video Display Quarter Resolution*/
129 OSD_VIDEOTDSIZE, /* True Size MPEG Video Display Double Resolution */
130 OSD_VIDEONSIZE, /* Full Size MPEG Video Display */
131 OSD_CURSOR /* Cursor */
132} osd_raw_window_t;
133
134typedef struct osd_cap_s {
135 int cmd;
136#define OSD_CAP_MEMSIZE 1 /* memory size */
137 long val;
138} osd_cap_t;
139
140
141#define OSD_SEND_CMD _IOW('o', 160, osd_cmd_t)
142#define OSD_GET_CAPABILITY _IOR('o', 161, osd_cap_t)
143
144#endif
diff --git a/include/linux/dvb/version.h b/include/linux/dvb/version.h
new file mode 100644
index 000000000000..6183c9c4849e
--- /dev/null
+++ b/include/linux/dvb/version.h
@@ -0,0 +1,29 @@
1/*
2 * version.h
3 *
4 * Copyright (C) 2000 Holger Waechtler <holger@convergence.de>
5 * for convergence integrated media GmbH
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * as published by the Free Software Foundation; either version 2.1
10 * of the License, or (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 Lesser General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 *
21 */
22
23#ifndef _DVBVERSION_H_
24#define _DVBVERSION_H_
25
26#define DVB_API_VERSION 3
27#define DVB_API_VERSION_MINOR 1
28
29#endif /*_DVBVERSION_H_*/
diff --git a/include/linux/dvb/video.h b/include/linux/dvb/video.h
new file mode 100644
index 000000000000..941045e9ab89
--- /dev/null
+++ b/include/linux/dvb/video.h
@@ -0,0 +1,203 @@
1/*
2 * video.h
3 *
4 * Copyright (C) 2000 Marcus Metzler <marcus@convergence.de>
5 * & Ralph Metzler <ralph@convergence.de>
6 * for convergence integrated media GmbH
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 2.1
11 * of the License, or (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 Lesser General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 *
22 */
23
24#ifndef _DVBVIDEO_H_
25#define _DVBVIDEO_H_
26
27#include <linux/compiler.h>
28
29#ifdef __KERNEL__
30#include <linux/types.h>
31#else
32#include <stdint.h>
33#include <time.h>
34#endif
35
36
37typedef enum {
38 VIDEO_FORMAT_4_3, /* Select 4:3 format */
39 VIDEO_FORMAT_16_9, /* Select 16:9 format. */
40 VIDEO_FORMAT_221_1 /* 2.21:1 */
41} video_format_t;
42
43
44typedef enum {
45 VIDEO_SYSTEM_PAL,
46 VIDEO_SYSTEM_NTSC,
47 VIDEO_SYSTEM_PALN,
48 VIDEO_SYSTEM_PALNc,
49 VIDEO_SYSTEM_PALM,
50 VIDEO_SYSTEM_NTSC60,
51 VIDEO_SYSTEM_PAL60,
52 VIDEO_SYSTEM_PALM60
53} video_system_t;
54
55
56typedef enum {
57 VIDEO_PAN_SCAN, /* use pan and scan format */
58 VIDEO_LETTER_BOX, /* use letterbox format */
59 VIDEO_CENTER_CUT_OUT /* use center cut out format */
60} video_displayformat_t;
61
62typedef struct {
63 int w;
64 int h;
65 video_format_t aspect_ratio;
66} video_size_t;
67
68typedef enum {
69 VIDEO_SOURCE_DEMUX, /* Select the demux as the main source */
70 VIDEO_SOURCE_MEMORY /* If this source is selected, the stream
71 comes from the user through the write
72 system call */
73} video_stream_source_t;
74
75
76typedef enum {
77 VIDEO_STOPPED, /* Video is stopped */
78 VIDEO_PLAYING, /* Video is currently playing */
79 VIDEO_FREEZED /* Video is freezed */
80} video_play_state_t;
81
82
83struct video_event {
84 int32_t type;
85#define VIDEO_EVENT_SIZE_CHANGED 1
86#define VIDEO_EVENT_FRAME_RATE_CHANGED 2
87 time_t timestamp;
88 union {
89 video_size_t size;
90 unsigned int frame_rate; /* in frames per 1000sec */
91 } u;
92};
93
94
95struct video_status {
96 int video_blank; /* blank video on freeze? */
97 video_play_state_t play_state; /* current state of playback */
98 video_stream_source_t stream_source; /* current source (demux/memory) */
99 video_format_t video_format; /* current aspect ratio of stream*/
100 video_displayformat_t display_format;/* selected cropping mode */
101};
102
103
104struct video_still_picture {
105 char __user *iFrame; /* pointer to a single iframe in memory */
106 int32_t size;
107};
108
109
110typedef
111struct video_highlight {
112 int active; /* 1=show highlight, 0=hide highlight */
113 uint8_t contrast1; /* 7- 4 Pattern pixel contrast */
114 /* 3- 0 Background pixel contrast */
115 uint8_t contrast2; /* 7- 4 Emphasis pixel-2 contrast */
116 /* 3- 0 Emphasis pixel-1 contrast */
117 uint8_t color1; /* 7- 4 Pattern pixel color */
118 /* 3- 0 Background pixel color */
119 uint8_t color2; /* 7- 4 Emphasis pixel-2 color */
120 /* 3- 0 Emphasis pixel-1 color */
121 uint32_t ypos; /* 23-22 auto action mode */
122 /* 21-12 start y */
123 /* 9- 0 end y */
124 uint32_t xpos; /* 23-22 button color number */
125 /* 21-12 start x */
126 /* 9- 0 end x */
127} video_highlight_t;
128
129
130typedef struct video_spu {
131 int active;
132 int stream_id;
133} video_spu_t;
134
135
136typedef struct video_spu_palette { /* SPU Palette information */
137 int length;
138 uint8_t *palette;
139} video_spu_palette_t;
140
141
142typedef struct video_navi_pack {
143 int length; /* 0 ... 1024 */
144 uint8_t data[1024];
145} video_navi_pack_t;
146
147
148typedef uint16_t video_attributes_t;
149/* bits: descr. */
150/* 15-14 Video compression mode (0=MPEG-1, 1=MPEG-2) */
151/* 13-12 TV system (0=525/60, 1=625/50) */
152/* 11-10 Aspect ratio (0=4:3, 3=16:9) */
153/* 9- 8 permitted display mode on 4:3 monitor (0=both, 1=only pan-sca */
154/* 7 line 21-1 data present in GOP (1=yes, 0=no) */
155/* 6 line 21-2 data present in GOP (1=yes, 0=no) */
156/* 5- 3 source resolution (0=720x480/576, 1=704x480/576, 2=352x480/57 */
157/* 2 source letterboxed (1=yes, 0=no) */
158/* 0 film/camera mode (0=camera, 1=film (625/50 only)) */
159
160
161/* bit definitions for capabilities: */
162/* can the hardware decode MPEG1 and/or MPEG2? */
163#define VIDEO_CAP_MPEG1 1
164#define VIDEO_CAP_MPEG2 2
165/* can you send a system and/or program stream to video device?
166 (you still have to open the video and the audio device but only
167 send the stream to the video device) */
168#define VIDEO_CAP_SYS 4
169#define VIDEO_CAP_PROG 8
170/* can the driver also handle SPU, NAVI and CSS encoded data?
171 (CSS API is not present yet) */
172#define VIDEO_CAP_SPU 16
173#define VIDEO_CAP_NAVI 32
174#define VIDEO_CAP_CSS 64
175
176
177#define VIDEO_STOP _IO('o', 21)
178#define VIDEO_PLAY _IO('o', 22)
179#define VIDEO_FREEZE _IO('o', 23)
180#define VIDEO_CONTINUE _IO('o', 24)
181#define VIDEO_SELECT_SOURCE _IO('o', 25)
182#define VIDEO_SET_BLANK _IO('o', 26)
183#define VIDEO_GET_STATUS _IOR('o', 27, struct video_status)
184#define VIDEO_GET_EVENT _IOR('o', 28, struct video_event)
185#define VIDEO_SET_DISPLAY_FORMAT _IO('o', 29)
186#define VIDEO_STILLPICTURE _IOW('o', 30, struct video_still_picture)
187#define VIDEO_FAST_FORWARD _IO('o', 31)
188#define VIDEO_SLOWMOTION _IO('o', 32)
189#define VIDEO_GET_CAPABILITIES _IOR('o', 33, unsigned int)
190#define VIDEO_CLEAR_BUFFER _IO('o', 34)
191#define VIDEO_SET_ID _IO('o', 35)
192#define VIDEO_SET_STREAMTYPE _IO('o', 36)
193#define VIDEO_SET_FORMAT _IO('o', 37)
194#define VIDEO_SET_SYSTEM _IO('o', 38)
195#define VIDEO_SET_HIGHLIGHT _IOW('o', 39, video_highlight_t)
196#define VIDEO_SET_SPU _IOW('o', 50, video_spu_t)
197#define VIDEO_SET_SPU_PALETTE _IOW('o', 51, video_spu_palette_t)
198#define VIDEO_GET_NAVI _IOR('o', 52, video_navi_pack_t)
199#define VIDEO_SET_ATTRIBUTES _IO('o', 53)
200#define VIDEO_GET_SIZE _IOR('o', 55, video_size_t)
201#define VIDEO_GET_FRAME_RATE _IOR('o', 56, unsigned int)
202
203#endif /*_DVBVIDEO_H_*/
diff --git a/include/linux/edd.h b/include/linux/edd.h
new file mode 100644
index 000000000000..c6e6747a401d
--- /dev/null
+++ b/include/linux/edd.h
@@ -0,0 +1,194 @@
1/*
2 * linux/include/linux/edd.h
3 * Copyright (C) 2002, 2003, 2004 Dell Inc.
4 * by Matt Domsch <Matt_Domsch@dell.com>
5 *
6 * structures and definitions for the int 13h, ax={41,48}h
7 * BIOS Enhanced Disk Drive Services
8 * This is based on the T13 group document D1572 Revision 0 (August 14 2002)
9 * available at http://www.t13.org/docs2002/d1572r0.pdf. It is
10 * very similar to D1484 Revision 3 http://www.t13.org/docs2002/d1484r3.pdf
11 *
12 * In a nutshell, arch/{i386,x86_64}/boot/setup.S populates a scratch
13 * table in the boot_params that contains a list of BIOS-enumerated
14 * boot devices.
15 * In arch/{i386,x86_64}/kernel/setup.c, this information is
16 * transferred into the edd structure, and in drivers/firmware/edd.c, that
17 * information is used to identify BIOS boot disk. The code in setup.S
18 * is very sensitive to the size of these structures.
19 *
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License v2.0 as published by
22 * the Free Software Foundation
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
28 *
29 */
30#ifndef _LINUX_EDD_H
31#define _LINUX_EDD_H
32
33#define EDDNR 0x1e9 /* addr of number of edd_info structs at EDDBUF
34 in boot_params - treat this as 1 byte */
35#define EDDBUF 0x600 /* addr of edd_info structs in boot_params */
36#define EDDMAXNR 6 /* number of edd_info structs starting at EDDBUF */
37#define EDDEXTSIZE 8 /* change these if you muck with the structures */
38#define EDDPARMSIZE 74
39#define CHECKEXTENSIONSPRESENT 0x41
40#define GETDEVICEPARAMETERS 0x48
41#define LEGACYGETDEVICEPARAMETERS 0x08
42#define EDDMAGIC1 0x55AA
43#define EDDMAGIC2 0xAA55
44
45
46#define READ_SECTORS 0x02 /* int13 AH=0x02 is READ_SECTORS command */
47#define EDD_MBR_SIG_OFFSET 0x1B8 /* offset of signature in the MBR */
48#define EDD_MBR_SIG_BUF 0x290 /* addr in boot params */
49#define EDD_MBR_SIG_MAX 16 /* max number of signatures to store */
50#define EDD_MBR_SIG_NR_BUF 0x1ea /* addr of number of MBR signtaures at EDD_MBR_SIG_BUF
51 in boot_params - treat this as 1 byte */
52#define EDD_CL_EQUALS 0x3d646465 /* "edd=" */
53#define EDD_CL_OFF 0x666f /* "of" for off */
54#define EDD_CL_SKIP 0x6b73 /* "sk" for skipmbr */
55
56#ifndef __ASSEMBLY__
57
58#define EDD_EXT_FIXED_DISK_ACCESS (1 << 0)
59#define EDD_EXT_DEVICE_LOCKING_AND_EJECTING (1 << 1)
60#define EDD_EXT_ENHANCED_DISK_DRIVE_SUPPORT (1 << 2)
61#define EDD_EXT_64BIT_EXTENSIONS (1 << 3)
62
63#define EDD_INFO_DMA_BOUNDARY_ERROR_TRANSPARENT (1 << 0)
64#define EDD_INFO_GEOMETRY_VALID (1 << 1)
65#define EDD_INFO_REMOVABLE (1 << 2)
66#define EDD_INFO_WRITE_VERIFY (1 << 3)
67#define EDD_INFO_MEDIA_CHANGE_NOTIFICATION (1 << 4)
68#define EDD_INFO_LOCKABLE (1 << 5)
69#define EDD_INFO_NO_MEDIA_PRESENT (1 << 6)
70#define EDD_INFO_USE_INT13_FN50 (1 << 7)
71
72struct edd_device_params {
73 u16 length;
74 u16 info_flags;
75 u32 num_default_cylinders;
76 u32 num_default_heads;
77 u32 sectors_per_track;
78 u64 number_of_sectors;
79 u16 bytes_per_sector;
80 u32 dpte_ptr; /* 0xFFFFFFFF for our purposes */
81 u16 key; /* = 0xBEDD */
82 u8 device_path_info_length; /* = 44 */
83 u8 reserved2;
84 u16 reserved3;
85 u8 host_bus_type[4];
86 u8 interface_type[8];
87 union {
88 struct {
89 u16 base_address;
90 u16 reserved1;
91 u32 reserved2;
92 } __attribute__ ((packed)) isa;
93 struct {
94 u8 bus;
95 u8 slot;
96 u8 function;
97 u8 channel;
98 u32 reserved;
99 } __attribute__ ((packed)) pci;
100 /* pcix is same as pci */
101 struct {
102 u64 reserved;
103 } __attribute__ ((packed)) ibnd;
104 struct {
105 u64 reserved;
106 } __attribute__ ((packed)) xprs;
107 struct {
108 u64 reserved;
109 } __attribute__ ((packed)) htpt;
110 struct {
111 u64 reserved;
112 } __attribute__ ((packed)) unknown;
113 } interface_path;
114 union {
115 struct {
116 u8 device;
117 u8 reserved1;
118 u16 reserved2;
119 u32 reserved3;
120 u64 reserved4;
121 } __attribute__ ((packed)) ata;
122 struct {
123 u8 device;
124 u8 lun;
125 u8 reserved1;
126 u8 reserved2;
127 u32 reserved3;
128 u64 reserved4;
129 } __attribute__ ((packed)) atapi;
130 struct {
131 u16 id;
132 u64 lun;
133 u16 reserved1;
134 u32 reserved2;
135 } __attribute__ ((packed)) scsi;
136 struct {
137 u64 serial_number;
138 u64 reserved;
139 } __attribute__ ((packed)) usb;
140 struct {
141 u64 eui;
142 u64 reserved;
143 } __attribute__ ((packed)) i1394;
144 struct {
145 u64 wwid;
146 u64 lun;
147 } __attribute__ ((packed)) fibre;
148 struct {
149 u64 identity_tag;
150 u64 reserved;
151 } __attribute__ ((packed)) i2o;
152 struct {
153 u32 array_number;
154 u32 reserved1;
155 u64 reserved2;
156 } __attribute__ ((packed)) raid;
157 struct {
158 u8 device;
159 u8 reserved1;
160 u16 reserved2;
161 u32 reserved3;
162 u64 reserved4;
163 } __attribute__ ((packed)) sata;
164 struct {
165 u64 reserved1;
166 u64 reserved2;
167 } __attribute__ ((packed)) unknown;
168 } device_path;
169 u8 reserved4;
170 u8 checksum;
171} __attribute__ ((packed));
172
173struct edd_info {
174 u8 device;
175 u8 version;
176 u16 interface_support;
177 u16 legacy_max_cylinder;
178 u8 legacy_max_head;
179 u8 legacy_sectors_per_track;
180 struct edd_device_params params;
181} __attribute__ ((packed));
182
183struct edd {
184 unsigned int mbr_signature[EDD_MBR_SIG_MAX];
185 struct edd_info edd_info[EDDMAXNR];
186 unsigned char mbr_signature_nr;
187 unsigned char edd_info_nr;
188};
189
190extern struct edd edd;
191
192#endif /*!__ASSEMBLY__ */
193
194#endif /* _LINUX_EDD_H */
diff --git a/include/linux/eeprom.h b/include/linux/eeprom.h
new file mode 100644
index 000000000000..38afd9da1dfe
--- /dev/null
+++ b/include/linux/eeprom.h
@@ -0,0 +1,136 @@
1/* credit winbond-840.c
2 */
3#include <asm/io.h>
4struct eeprom_ops {
5 void (*set_cs)(void *ee);
6 void (*clear_cs)(void *ee);
7};
8
9#define EEPOL_EEDI 0x01
10#define EEPOL_EEDO 0x02
11#define EEPOL_EECLK 0x04
12#define EEPOL_EESEL 0x08
13
14struct eeprom {
15 void *dev;
16 struct eeprom_ops *ops;
17
18 void __iomem * addr;
19
20 unsigned ee_addr_bits;
21
22 unsigned eesel;
23 unsigned eeclk;
24 unsigned eedo;
25 unsigned eedi;
26 unsigned polarity;
27 unsigned ee_state;
28
29 spinlock_t *lock;
30 u32 *cache;
31};
32
33
34u8 eeprom_readb(struct eeprom *ee, unsigned address);
35void eeprom_read(struct eeprom *ee, unsigned address, u8 *bytes,
36 unsigned count);
37void eeprom_writeb(struct eeprom *ee, unsigned address, u8 data);
38void eeprom_write(struct eeprom *ee, unsigned address, u8 *bytes,
39 unsigned count);
40
41/* The EEPROM commands include the alway-set leading bit. */
42enum EEPROM_Cmds {
43 EE_WriteCmd=(5 << 6), EE_ReadCmd=(6 << 6), EE_EraseCmd=(7 << 6),
44};
45
46void setup_ee_mem_bitbanger(struct eeprom *ee, void __iomem *memaddr, int eesel_bit, int eeclk_bit, int eedo_bit, int eedi_bit, unsigned polarity)
47{
48 ee->addr = memaddr;
49 ee->eesel = 1 << eesel_bit;
50 ee->eeclk = 1 << eeclk_bit;
51 ee->eedo = 1 << eedo_bit;
52 ee->eedi = 1 << eedi_bit;
53
54 ee->polarity = polarity;
55
56 *ee->cache = readl(ee->addr);
57}
58
59/* foo. put this in a .c file */
60static inline void eeprom_update(struct eeprom *ee, u32 mask, int pol)
61{
62 unsigned long flags;
63 u32 data;
64
65 spin_lock_irqsave(ee->lock, flags);
66 data = *ee->cache;
67
68 data &= ~mask;
69 if (pol)
70 data |= mask;
71
72 *ee->cache = data;
73//printk("update: %08x\n", data);
74 writel(data, ee->addr);
75 spin_unlock_irqrestore(ee->lock, flags);
76}
77
78void eeprom_clk_lo(struct eeprom *ee)
79{
80 int pol = !!(ee->polarity & EEPOL_EECLK);
81
82 eeprom_update(ee, ee->eeclk, pol);
83 udelay(2);
84}
85
86void eeprom_clk_hi(struct eeprom *ee)
87{
88 int pol = !!(ee->polarity & EEPOL_EECLK);
89
90 eeprom_update(ee, ee->eeclk, !pol);
91 udelay(2);
92}
93
94void eeprom_send_addr(struct eeprom *ee, unsigned address)
95{
96 int pol = !!(ee->polarity & EEPOL_EEDI);
97 unsigned i;
98 address |= 6 << 6;
99
100 /* Shift the read command bits out. */
101 for (i=0; i<11; i++) {
102 eeprom_update(ee, ee->eedi, ((address >> 10) & 1) ^ pol);
103 address <<= 1;
104 eeprom_clk_hi(ee);
105 eeprom_clk_lo(ee);
106 }
107 eeprom_update(ee, ee->eedi, pol);
108}
109
110u16 eeprom_readw(struct eeprom *ee, unsigned address)
111{
112 unsigned i;
113 u16 res = 0;
114
115 eeprom_clk_lo(ee);
116 eeprom_update(ee, ee->eesel, 1 ^ !!(ee->polarity & EEPOL_EESEL));
117 eeprom_send_addr(ee, address);
118
119 for (i=0; i<16; i++) {
120 u32 data;
121 eeprom_clk_hi(ee);
122 res <<= 1;
123 data = readl(ee->addr);
124//printk("eeprom_readw: %08x\n", data);
125 res |= !!(data & ee->eedo) ^ !!(ee->polarity & EEPOL_EEDO);
126 eeprom_clk_lo(ee);
127 }
128 eeprom_update(ee, ee->eesel, 0 ^ !!(ee->polarity & EEPOL_EESEL));
129
130 return res;
131}
132
133
134void eeprom_writeb(struct eeprom *ee, unsigned address, u8 data)
135{
136}
diff --git a/include/linux/efi.h b/include/linux/efi.h
new file mode 100644
index 000000000000..047e7222df7a
--- /dev/null
+++ b/include/linux/efi.h
@@ -0,0 +1,398 @@
1#ifndef _LINUX_EFI_H
2#define _LINUX_EFI_H
3
4/*
5 * Extensible Firmware Interface
6 * Based on 'Extensible Firmware Interface Specification' version 0.9, April 30, 1999
7 *
8 * Copyright (C) 1999 VA Linux Systems
9 * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
10 * Copyright (C) 1999, 2002-2003 Hewlett-Packard Co.
11 * David Mosberger-Tang <davidm@hpl.hp.com>
12 * Stephane Eranian <eranian@hpl.hp.com>
13 */
14#include <linux/init.h>
15#include <linux/string.h>
16#include <linux/time.h>
17#include <linux/types.h>
18#include <linux/proc_fs.h>
19#include <linux/rtc.h>
20#include <linux/ioport.h>
21
22#include <asm/page.h>
23#include <asm/system.h>
24
25#define EFI_SUCCESS 0
26#define EFI_LOAD_ERROR ( 1 | (1UL << (BITS_PER_LONG-1)))
27#define EFI_INVALID_PARAMETER ( 2 | (1UL << (BITS_PER_LONG-1)))
28#define EFI_UNSUPPORTED ( 3 | (1UL << (BITS_PER_LONG-1)))
29#define EFI_BAD_BUFFER_SIZE ( 4 | (1UL << (BITS_PER_LONG-1)))
30#define EFI_BUFFER_TOO_SMALL ( 5 | (1UL << (BITS_PER_LONG-1)))
31#define EFI_NOT_FOUND (14 | (1UL << (BITS_PER_LONG-1)))
32
33typedef unsigned long efi_status_t;
34typedef u8 efi_bool_t;
35typedef u16 efi_char16_t; /* UNICODE character */
36
37
38typedef struct {
39 u8 b[16];
40} efi_guid_t;
41
42#define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \
43((efi_guid_t) \
44{{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \
45 (b) & 0xff, ((b) >> 8) & 0xff, \
46 (c) & 0xff, ((c) >> 8) & 0xff, \
47 (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }})
48
49/*
50 * Generic EFI table header
51 */
52typedef struct {
53 u64 signature;
54 u32 revision;
55 u32 headersize;
56 u32 crc32;
57 u32 reserved;
58} efi_table_hdr_t;
59
60/*
61 * Memory map descriptor:
62 */
63
64/* Memory types: */
65#define EFI_RESERVED_TYPE 0
66#define EFI_LOADER_CODE 1
67#define EFI_LOADER_DATA 2
68#define EFI_BOOT_SERVICES_CODE 3
69#define EFI_BOOT_SERVICES_DATA 4
70#define EFI_RUNTIME_SERVICES_CODE 5
71#define EFI_RUNTIME_SERVICES_DATA 6
72#define EFI_CONVENTIONAL_MEMORY 7
73#define EFI_UNUSABLE_MEMORY 8
74#define EFI_ACPI_RECLAIM_MEMORY 9
75#define EFI_ACPI_MEMORY_NVS 10
76#define EFI_MEMORY_MAPPED_IO 11
77#define EFI_MEMORY_MAPPED_IO_PORT_SPACE 12
78#define EFI_PAL_CODE 13
79#define EFI_MAX_MEMORY_TYPE 14
80
81/* Attribute values: */
82#define EFI_MEMORY_UC ((u64)0x0000000000000001ULL) /* uncached */
83#define EFI_MEMORY_WC ((u64)0x0000000000000002ULL) /* write-coalescing */
84#define EFI_MEMORY_WT ((u64)0x0000000000000004ULL) /* write-through */
85#define EFI_MEMORY_WB ((u64)0x0000000000000008ULL) /* write-back */
86#define EFI_MEMORY_WP ((u64)0x0000000000001000ULL) /* write-protect */
87#define EFI_MEMORY_RP ((u64)0x0000000000002000ULL) /* read-protect */
88#define EFI_MEMORY_XP ((u64)0x0000000000004000ULL) /* execute-protect */
89#define EFI_MEMORY_RUNTIME ((u64)0x8000000000000000ULL) /* range requires runtime mapping */
90#define EFI_MEMORY_DESCRIPTOR_VERSION 1
91
92#define EFI_PAGE_SHIFT 12
93
94/*
95 * For current x86 implementations of EFI, there is
96 * additional padding in the mem descriptors. This is not
97 * the case in ia64. Need to have this fixed in the f/w.
98 */
99typedef struct {
100 u32 type;
101 u32 pad;
102 u64 phys_addr;
103 u64 virt_addr;
104 u64 num_pages;
105 u64 attribute;
106#if defined (__i386__)
107 u64 pad1;
108#endif
109} efi_memory_desc_t;
110
111typedef int (*efi_freemem_callback_t) (unsigned long start, unsigned long end, void *arg);
112
113/*
114 * Types and defines for Time Services
115 */
116#define EFI_TIME_ADJUST_DAYLIGHT 0x1
117#define EFI_TIME_IN_DAYLIGHT 0x2
118#define EFI_UNSPECIFIED_TIMEZONE 0x07ff
119
120typedef struct {
121 u16 year;
122 u8 month;
123 u8 day;
124 u8 hour;
125 u8 minute;
126 u8 second;
127 u8 pad1;
128 u32 nanosecond;
129 s16 timezone;
130 u8 daylight;
131 u8 pad2;
132} efi_time_t;
133
134typedef struct {
135 u32 resolution;
136 u32 accuracy;
137 u8 sets_to_zero;
138} efi_time_cap_t;
139
140/*
141 * Types and defines for EFI ResetSystem
142 */
143#define EFI_RESET_COLD 0
144#define EFI_RESET_WARM 1
145#define EFI_RESET_SHUTDOWN 2
146
147/*
148 * EFI Runtime Services table
149 */
150#define EFI_RUNTIME_SERVICES_SIGNATURE ((u64)0x5652453544e5552ULL)
151#define EFI_RUNTIME_SERVICES_REVISION 0x00010000
152
153typedef struct {
154 efi_table_hdr_t hdr;
155 unsigned long get_time;
156 unsigned long set_time;
157 unsigned long get_wakeup_time;
158 unsigned long set_wakeup_time;
159 unsigned long set_virtual_address_map;
160 unsigned long convert_pointer;
161 unsigned long get_variable;
162 unsigned long get_next_variable;
163 unsigned long set_variable;
164 unsigned long get_next_high_mono_count;
165 unsigned long reset_system;
166} efi_runtime_services_t;
167
168typedef efi_status_t efi_get_time_t (efi_time_t *tm, efi_time_cap_t *tc);
169typedef efi_status_t efi_set_time_t (efi_time_t *tm);
170typedef efi_status_t efi_get_wakeup_time_t (efi_bool_t *enabled, efi_bool_t *pending,
171 efi_time_t *tm);
172typedef efi_status_t efi_set_wakeup_time_t (efi_bool_t enabled, efi_time_t *tm);
173typedef efi_status_t efi_get_variable_t (efi_char16_t *name, efi_guid_t *vendor, u32 *attr,
174 unsigned long *data_size, void *data);
175typedef efi_status_t efi_get_next_variable_t (unsigned long *name_size, efi_char16_t *name,
176 efi_guid_t *vendor);
177typedef efi_status_t efi_set_variable_t (efi_char16_t *name, efi_guid_t *vendor,
178 unsigned long attr, unsigned long data_size,
179 void *data);
180typedef efi_status_t efi_get_next_high_mono_count_t (u32 *count);
181typedef void efi_reset_system_t (int reset_type, efi_status_t status,
182 unsigned long data_size, efi_char16_t *data);
183typedef efi_status_t efi_set_virtual_address_map_t (unsigned long memory_map_size,
184 unsigned long descriptor_size,
185 u32 descriptor_version,
186 efi_memory_desc_t *virtual_map);
187
188/*
189 * EFI Configuration Table and GUID definitions
190 */
191#define NULL_GUID \
192 EFI_GUID( 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 )
193
194#define MPS_TABLE_GUID \
195 EFI_GUID( 0xeb9d2d2f, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d )
196
197#define ACPI_TABLE_GUID \
198 EFI_GUID( 0xeb9d2d30, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d )
199
200#define ACPI_20_TABLE_GUID \
201 EFI_GUID( 0x8868e871, 0xe4f1, 0x11d3, 0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 )
202
203#define SMBIOS_TABLE_GUID \
204 EFI_GUID( 0xeb9d2d31, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d )
205
206#define SAL_SYSTEM_TABLE_GUID \
207 EFI_GUID( 0xeb9d2d32, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d )
208
209#define HCDP_TABLE_GUID \
210 EFI_GUID( 0xf951938d, 0x620b, 0x42ef, 0x82, 0x79, 0xa8, 0x4b, 0x79, 0x61, 0x78, 0x98 )
211
212#define UGA_IO_PROTOCOL_GUID \
213 EFI_GUID( 0x61a4d49e, 0x6f68, 0x4f1b, 0xb9, 0x22, 0xa8, 0x6e, 0xed, 0xb, 0x7, 0xa2 )
214
215#define EFI_GLOBAL_VARIABLE_GUID \
216 EFI_GUID( 0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c )
217
218typedef struct {
219 efi_guid_t guid;
220 unsigned long table;
221} efi_config_table_t;
222
223#define EFI_SYSTEM_TABLE_SIGNATURE ((u64)0x5453595320494249ULL)
224#define EFI_SYSTEM_TABLE_REVISION ((1 << 16) | 00)
225
226typedef struct {
227 efi_table_hdr_t hdr;
228 unsigned long fw_vendor; /* physical addr of CHAR16 vendor string */
229 u32 fw_revision;
230 unsigned long con_in_handle;
231 unsigned long con_in;
232 unsigned long con_out_handle;
233 unsigned long con_out;
234 unsigned long stderr_handle;
235 unsigned long stderr;
236 efi_runtime_services_t *runtime;
237 unsigned long boottime;
238 unsigned long nr_tables;
239 unsigned long tables;
240} efi_system_table_t;
241
242struct efi_memory_map {
243 efi_memory_desc_t *phys_map;
244 efi_memory_desc_t *map;
245 int nr_map;
246 unsigned long desc_version;
247};
248
249/*
250 * All runtime access to EFI goes through this structure:
251 */
252extern struct efi {
253 efi_system_table_t *systab; /* EFI system table */
254 void *mps; /* MPS table */
255 void *acpi; /* ACPI table (IA64 ext 0.71) */
256 void *acpi20; /* ACPI table (ACPI 2.0) */
257 void *smbios; /* SM BIOS table */
258 void *sal_systab; /* SAL system table */
259 void *boot_info; /* boot info table */
260 void *hcdp; /* HCDP table */
261 void *uga; /* UGA table */
262 efi_get_time_t *get_time;
263 efi_set_time_t *set_time;
264 efi_get_wakeup_time_t *get_wakeup_time;
265 efi_set_wakeup_time_t *set_wakeup_time;
266 efi_get_variable_t *get_variable;
267 efi_get_next_variable_t *get_next_variable;
268 efi_set_variable_t *set_variable;
269 efi_get_next_high_mono_count_t *get_next_high_mono_count;
270 efi_reset_system_t *reset_system;
271 efi_set_virtual_address_map_t *set_virtual_address_map;
272} efi;
273
274static inline int
275efi_guidcmp (efi_guid_t left, efi_guid_t right)
276{
277 return memcmp(&left, &right, sizeof (efi_guid_t));
278}
279
280static inline char *
281efi_guid_unparse(efi_guid_t *guid, char *out)
282{
283 sprintf(out, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
284 guid->b[3], guid->b[2], guid->b[1], guid->b[0],
285 guid->b[5], guid->b[4], guid->b[7], guid->b[6],
286 guid->b[8], guid->b[9], guid->b[10], guid->b[11],
287 guid->b[12], guid->b[13], guid->b[14], guid->b[15]);
288 return out;
289}
290
291extern void efi_init (void);
292extern void *efi_get_pal_addr (void);
293extern void efi_map_pal_code (void);
294extern void efi_map_memmap(void);
295extern void efi_memmap_walk (efi_freemem_callback_t callback, void *arg);
296extern void efi_gettimeofday (struct timespec *ts);
297extern void efi_enter_virtual_mode (void); /* switch EFI to virtual mode, if possible */
298extern u64 efi_get_iobase (void);
299extern u32 efi_mem_type (unsigned long phys_addr);
300extern u64 efi_mem_attributes (unsigned long phys_addr);
301extern int __init efi_uart_console_only (void);
302extern void efi_initialize_iomem_resources(struct resource *code_resource,
303 struct resource *data_resource);
304extern unsigned long __init efi_get_time(void);
305extern int __init efi_set_rtc_mmss(unsigned long nowtime);
306extern struct efi_memory_map memmap;
307
308/**
309 * efi_range_is_wc - check the WC bit on an address range
310 * @start: starting kvirt address
311 * @len: length of range
312 *
313 * Consult the EFI memory map and make sure it's ok to set this range WC.
314 * Returns true or false.
315 */
316static inline int efi_range_is_wc(unsigned long start, unsigned long len)
317{
318 int i;
319
320 for (i = 0; i < len; i += (1UL << EFI_PAGE_SHIFT)) {
321 unsigned long paddr = __pa(start + i);
322 if (!(efi_mem_attributes(paddr) & EFI_MEMORY_WC))
323 return 0;
324 }
325 /* The range checked out */
326 return 1;
327}
328
329#ifdef CONFIG_EFI_PCDP
330extern int __init efi_setup_pcdp_console(char *);
331#endif
332
333/*
334 * We play games with efi_enabled so that the compiler will, if possible, remove
335 * EFI-related code altogether.
336 */
337#ifdef CONFIG_EFI
338# ifdef CONFIG_X86
339 extern int efi_enabled;
340# else
341# define efi_enabled 1
342# endif
343#else
344# define efi_enabled 0
345#endif
346
347/*
348 * Variable Attributes
349 */
350#define EFI_VARIABLE_NON_VOLATILE 0x0000000000000001
351#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x0000000000000002
352#define EFI_VARIABLE_RUNTIME_ACCESS 0x0000000000000004
353
354/*
355 * EFI Device Path information
356 */
357#define EFI_DEV_HW 0x01
358#define EFI_DEV_PCI 1
359#define EFI_DEV_PCCARD 2
360#define EFI_DEV_MEM_MAPPED 3
361#define EFI_DEV_VENDOR 4
362#define EFI_DEV_CONTROLLER 5
363#define EFI_DEV_ACPI 0x02
364#define EFI_DEV_BASIC_ACPI 1
365#define EFI_DEV_EXPANDED_ACPI 2
366#define EFI_DEV_MSG 0x03
367#define EFI_DEV_MSG_ATAPI 1
368#define EFI_DEV_MSG_SCSI 2
369#define EFI_DEV_MSG_FC 3
370#define EFI_DEV_MSG_1394 4
371#define EFI_DEV_MSG_USB 5
372#define EFI_DEV_MSG_USB_CLASS 15
373#define EFI_DEV_MSG_I20 6
374#define EFI_DEV_MSG_MAC 11
375#define EFI_DEV_MSG_IPV4 12
376#define EFI_DEV_MSG_IPV6 13
377#define EFI_DEV_MSG_INFINIBAND 9
378#define EFI_DEV_MSG_UART 14
379#define EFI_DEV_MSG_VENDOR 10
380#define EFI_DEV_MEDIA 0x04
381#define EFI_DEV_MEDIA_HARD_DRIVE 1
382#define EFI_DEV_MEDIA_CDROM 2
383#define EFI_DEV_MEDIA_VENDOR 3
384#define EFI_DEV_MEDIA_FILE 4
385#define EFI_DEV_MEDIA_PROTOCOL 5
386#define EFI_DEV_BIOS_BOOT 0x05
387#define EFI_DEV_END_PATH 0x7F
388#define EFI_DEV_END_PATH2 0xFF
389#define EFI_DEV_END_INSTANCE 0x01
390#define EFI_DEV_END_ENTIRE 0xFF
391
392struct efi_generic_dev_path {
393 u8 type;
394 u8 sub_type;
395 u16 length;
396} __attribute ((packed));
397
398#endif /* _LINUX_EFI_H */
diff --git a/include/linux/efs_dir.h b/include/linux/efs_dir.h
new file mode 100644
index 000000000000..a09ec010569c
--- /dev/null
+++ b/include/linux/efs_dir.h
@@ -0,0 +1,42 @@
1/*
2 * efs_dir.h
3 *
4 * Copyright (c) 1999 Al Smith
5 */
6
7#ifndef __EFS_DIR_H__
8#define __EFS_DIR_H__
9
10#define EFS_DIRBSIZE_BITS EFS_BLOCKSIZE_BITS
11#define EFS_DIRBSIZE (1 << EFS_DIRBSIZE_BITS)
12
13struct efs_dentry {
14 __be32 inode;
15 unsigned char namelen;
16 char name[3];
17};
18
19#define EFS_DENTSIZE (sizeof(struct efs_dentry) - 3 + 1)
20#define EFS_MAXNAMELEN ((1 << (sizeof(char) * 8)) - 1)
21
22#define EFS_DIRBLK_HEADERSIZE 4
23#define EFS_DIRBLK_MAGIC 0xbeef /* moo */
24
25struct efs_dir {
26 __be16 magic;
27 unsigned char firstused;
28 unsigned char slots;
29
30 unsigned char space[EFS_DIRBSIZE - EFS_DIRBLK_HEADERSIZE];
31};
32
33#define EFS_MAXENTS \
34 ((EFS_DIRBSIZE - EFS_DIRBLK_HEADERSIZE) / \
35 (EFS_DENTSIZE + sizeof(char)))
36
37#define EFS_SLOTAT(dir, slot) EFS_REALOFF((dir)->space[slot])
38
39#define EFS_REALOFF(offset) ((offset << 1))
40
41#endif /* __EFS_DIR_H__ */
42
diff --git a/include/linux/efs_fs.h b/include/linux/efs_fs.h
new file mode 100644
index 000000000000..28f368c526fb
--- /dev/null
+++ b/include/linux/efs_fs.h
@@ -0,0 +1,51 @@
1/*
2 * efs_fs.h
3 *
4 * Copyright (c) 1999 Al Smith
5 *
6 * Portions derived from work (c) 1995,1996 Christian Vogelgsang.
7 */
8
9#ifndef __EFS_FS_H__
10#define __EFS_FS_H__
11
12#define EFS_VERSION "1.0a"
13
14static const char cprt[] = "EFS: "EFS_VERSION" - (c) 1999 Al Smith <Al.Smith@aeschi.ch.eu.org>";
15
16#include <asm/uaccess.h>
17
18/* 1 block is 512 bytes */
19#define EFS_BLOCKSIZE_BITS 9
20#define EFS_BLOCKSIZE (1 << EFS_BLOCKSIZE_BITS)
21
22#include <linux/fs.h>
23#include <linux/efs_fs_i.h>
24#include <linux/efs_fs_sb.h>
25#include <linux/efs_dir.h>
26
27static inline struct efs_inode_info *INODE_INFO(struct inode *inode)
28{
29 return container_of(inode, struct efs_inode_info, vfs_inode);
30}
31
32static inline struct efs_sb_info *SUPER_INFO(struct super_block *sb)
33{
34 return sb->s_fs_info;
35}
36
37struct statfs;
38
39extern struct inode_operations efs_dir_inode_operations;
40extern struct file_operations efs_dir_operations;
41extern struct address_space_operations efs_symlink_aops;
42
43extern void efs_read_inode(struct inode *);
44extern efs_block_t efs_map_block(struct inode *, efs_block_t);
45extern int efs_get_block(struct inode *, sector_t, struct buffer_head *, int);
46
47extern struct dentry *efs_lookup(struct inode *, struct dentry *, struct nameidata *);
48extern struct dentry *efs_get_parent(struct dentry *);
49extern int efs_bmap(struct inode *, int);
50
51#endif /* __EFS_FS_H__ */
diff --git a/include/linux/efs_fs_i.h b/include/linux/efs_fs_i.h
new file mode 100644
index 000000000000..617c474ca659
--- /dev/null
+++ b/include/linux/efs_fs_i.h
@@ -0,0 +1,68 @@
1/*
2 * efs_fs_i.h
3 *
4 * Copyright (c) 1999 Al Smith
5 *
6 * Portions derived from IRIX header files (c) 1988 Silicon Graphics
7 */
8
9#ifndef __EFS_FS_I_H__
10#define __EFS_FS_I_H__
11
12typedef int32_t efs_block_t;
13typedef uint32_t efs_ino_t;
14
15#define EFS_DIRECTEXTENTS 12
16
17/*
18 * layout of an extent, in memory and on disk. 8 bytes exactly.
19 */
20typedef union extent_u {
21 unsigned char raw[8];
22 struct extent_s {
23 unsigned int ex_magic:8; /* magic # (zero) */
24 unsigned int ex_bn:24; /* basic block */
25 unsigned int ex_length:8; /* numblocks in this extent */
26 unsigned int ex_offset:24; /* logical offset into file */
27 } cooked;
28} efs_extent;
29
30typedef struct edevs {
31 __be16 odev;
32 __be32 ndev;
33} efs_devs;
34
35/*
36 * extent based filesystem inode as it appears on disk. The efs inode
37 * is exactly 128 bytes long.
38 */
39struct efs_dinode {
40 __be16 di_mode; /* mode and type of file */
41 __be16 di_nlink; /* number of links to file */
42 __be16 di_uid; /* owner's user id */
43 __be16 di_gid; /* owner's group id */
44 __be32 di_size; /* number of bytes in file */
45 __be32 di_atime; /* time last accessed */
46 __be32 di_mtime; /* time last modified */
47 __be32 di_ctime; /* time created */
48 __be32 di_gen; /* generation number */
49 __be16 di_numextents; /* # of extents */
50 u_char di_version; /* version of inode */
51 u_char di_spare; /* spare - used by AFS */
52 union di_addr {
53 efs_extent di_extents[EFS_DIRECTEXTENTS];
54 efs_devs di_dev; /* device for IFCHR/IFBLK */
55 } di_u;
56};
57
58/* efs inode storage in memory */
59struct efs_inode_info {
60 int numextents;
61 int lastextent;
62
63 efs_extent extents[EFS_DIRECTEXTENTS];
64 struct inode vfs_inode;
65};
66
67#endif /* __EFS_FS_I_H__ */
68
diff --git a/include/linux/efs_fs_sb.h b/include/linux/efs_fs_sb.h
new file mode 100644
index 000000000000..c76088baef28
--- /dev/null
+++ b/include/linux/efs_fs_sb.h
@@ -0,0 +1,62 @@
1/*
2 * efs_fs_sb.h
3 *
4 * Copyright (c) 1999 Al Smith
5 *
6 * Portions derived from IRIX header files (c) 1988 Silicon Graphics
7 */
8
9#ifndef __EFS_FS_SB_H__
10#define __EFS_FS_SB_H__
11
12/* statfs() magic number for EFS */
13#define EFS_SUPER_MAGIC 0x414A53
14
15/* EFS superblock magic numbers */
16#define EFS_MAGIC 0x072959
17#define EFS_NEWMAGIC 0x07295a
18
19#define IS_EFS_MAGIC(x) ((x == EFS_MAGIC) || (x == EFS_NEWMAGIC))
20
21#define EFS_SUPER 1
22#define EFS_ROOTINODE 2
23
24/* efs superblock on disk */
25struct efs_super {
26 __be32 fs_size; /* size of filesystem, in sectors */
27 __be32 fs_firstcg; /* bb offset to first cg */
28 __be32 fs_cgfsize; /* size of cylinder group in bb's */
29 __be16 fs_cgisize; /* bb's of inodes per cylinder group */
30 __be16 fs_sectors; /* sectors per track */
31 __be16 fs_heads; /* heads per cylinder */
32 __be16 fs_ncg; /* # of cylinder groups in filesystem */
33 __be16 fs_dirty; /* fs needs to be fsck'd */
34 __be32 fs_time; /* last super-block update */
35 __be32 fs_magic; /* magic number */
36 char fs_fname[6]; /* file system name */
37 char fs_fpack[6]; /* file system pack name */
38 __be32 fs_bmsize; /* size of bitmap in bytes */
39 __be32 fs_tfree; /* total free data blocks */
40 __be32 fs_tinode; /* total free inodes */
41 __be32 fs_bmblock; /* bitmap location. */
42 __be32 fs_replsb; /* Location of replicated superblock. */
43 __be32 fs_lastialloc; /* last allocated inode */
44 char fs_spare[20]; /* space for expansion - MUST BE ZERO */
45 __be32 fs_checksum; /* checksum of volume portion of fs */
46};
47
48/* efs superblock information in memory */
49struct efs_sb_info {
50 __u32 fs_magic; /* superblock magic number */
51 __u32 fs_start; /* first block of filesystem */
52 __u32 first_block; /* first data block in filesystem */
53 __u32 total_blocks; /* total number of blocks in filesystem */
54 __u32 group_size; /* # of blocks a group consists of */
55 __u32 data_free; /* # of free data blocks */
56 __u32 inode_free; /* # of free inodes */
57 __u16 inode_blocks; /* # of blocks used for inodes in every grp */
58 __u16 total_groups; /* # of groups */
59};
60
61#endif /* __EFS_FS_SB_H__ */
62
diff --git a/include/linux/efs_vh.h b/include/linux/efs_vh.h
new file mode 100644
index 000000000000..8a11150c61fe
--- /dev/null
+++ b/include/linux/efs_vh.h
@@ -0,0 +1,53 @@
1/*
2 * efs_vh.h
3 *
4 * Copyright (c) 1999 Al Smith
5 *
6 * Portions derived from IRIX header files (c) 1985 MIPS Computer Systems, Inc.
7 */
8
9#ifndef __EFS_VH_H__
10#define __EFS_VH_H__
11
12#define VHMAGIC 0xbe5a941 /* volume header magic number */
13#define NPARTAB 16 /* 16 unix partitions */
14#define NVDIR 15 /* max of 15 directory entries */
15#define BFNAMESIZE 16 /* max 16 chars in boot file name */
16#define VDNAMESIZE 8
17
18struct volume_directory {
19 char vd_name[VDNAMESIZE]; /* name */
20 __be32 vd_lbn; /* logical block number */
21 __be32 vd_nbytes; /* file length in bytes */
22};
23
24struct partition_table { /* one per logical partition */
25 __be32 pt_nblks; /* # of logical blks in partition */
26 __be32 pt_firstlbn; /* first lbn of partition */
27 __be32 pt_type; /* use of partition */
28};
29
30struct volume_header {
31 __be32 vh_magic; /* identifies volume header */
32 __be16 vh_rootpt; /* root partition number */
33 __be16 vh_swappt; /* swap partition number */
34 char vh_bootfile[BFNAMESIZE]; /* name of file to boot */
35 char pad[48]; /* device param space */
36 struct volume_directory vh_vd[NVDIR]; /* other vol hdr contents */
37 struct partition_table vh_pt[NPARTAB]; /* device partition layout */
38 __be32 vh_csum; /* volume header checksum */
39 __be32 vh_fill; /* fill out to 512 bytes */
40};
41
42/* partition type sysv is used for EFS format CD-ROM partitions */
43#define SGI_SYSV 0x05
44#define SGI_EFS 0x07
45#define IS_EFS(x) (((x) == SGI_EFS) || ((x) == SGI_SYSV))
46
47struct pt_types {
48 int pt_type;
49 char *pt_name;
50};
51
52#endif /* __EFS_VH_H__ */
53
diff --git a/include/linux/eisa.h b/include/linux/eisa.h
new file mode 100644
index 000000000000..4079242dced8
--- /dev/null
+++ b/include/linux/eisa.h
@@ -0,0 +1,107 @@
1#ifndef _LINUX_EISA_H
2#define _LINUX_EISA_H
3
4#include <linux/ioport.h>
5#include <linux/device.h>
6
7#define EISA_SIG_LEN 8
8#define EISA_MAX_SLOTS 8
9
10#define EISA_MAX_RESOURCES 4
11
12/* A few EISA constants/offsets... */
13
14#define EISA_DMA1_STATUS 8
15#define EISA_INT1_CTRL 0x20
16#define EISA_INT1_MASK 0x21
17#define EISA_INT2_CTRL 0xA0
18#define EISA_INT2_MASK 0xA1
19#define EISA_DMA2_STATUS 0xD0
20#define EISA_DMA2_WRITE_SINGLE 0xD4
21#define EISA_EXT_NMI_RESET_CTRL 0x461
22#define EISA_INT1_EDGE_LEVEL 0x4D0
23#define EISA_INT2_EDGE_LEVEL 0x4D1
24#define EISA_VENDOR_ID_OFFSET 0xC80
25#define EISA_CONFIG_OFFSET 0xC84
26
27#define EISA_CONFIG_ENABLED 1
28#define EISA_CONFIG_FORCED 2
29
30/* The EISA signature, in ASCII form, null terminated */
31struct eisa_device_id {
32 char sig[EISA_SIG_LEN];
33 unsigned long driver_data;
34};
35
36/* There is not much we can say about an EISA device, apart from
37 * signature, slot number, and base address. dma_mask is set by
38 * default to parent device mask..*/
39
40struct eisa_device {
41 struct eisa_device_id id;
42 int slot;
43 int state;
44 unsigned long base_addr;
45 struct resource res[EISA_MAX_RESOURCES];
46 u64 dma_mask;
47 struct device dev; /* generic device */
48#ifdef CONFIG_EISA_NAMES
49 char pretty_name[DEVICE_NAME_SIZE];
50#endif
51};
52
53#define to_eisa_device(n) container_of(n, struct eisa_device, dev)
54
55static inline int eisa_get_region_index (void *addr)
56{
57 unsigned long x = (unsigned long) addr;
58
59 x &= 0xc00;
60 return (x >> 12);
61}
62
63struct eisa_driver {
64 const struct eisa_device_id *id_table;
65 struct device_driver driver;
66};
67
68#define to_eisa_driver(drv) container_of(drv,struct eisa_driver, driver)
69
70extern struct bus_type eisa_bus_type;
71int eisa_driver_register (struct eisa_driver *edrv);
72void eisa_driver_unregister (struct eisa_driver *edrv);
73
74/* Mimics pci.h... */
75static inline void *eisa_get_drvdata (struct eisa_device *edev)
76{
77 return edev->dev.driver_data;
78}
79
80static inline void eisa_set_drvdata (struct eisa_device *edev, void *data)
81{
82 edev->dev.driver_data = data;
83}
84
85/* The EISA root device. There's rumours about machines with multiple
86 * busses (PA-RISC ?), so we try to handle that. */
87
88struct eisa_root_device {
89 struct device *dev; /* Pointer to bridge device */
90 struct resource *res;
91 unsigned long bus_base_addr;
92 int slots; /* Max slot number */
93 int force_probe; /* Probe even when no slot 0 */
94 u64 dma_mask; /* from bridge device */
95 int bus_nr; /* Set by eisa_root_register */
96 struct resource eisa_root_res; /* ditto */
97};
98
99int eisa_root_register (struct eisa_root_device *root);
100
101#ifdef CONFIG_EISA
102extern int EISA_bus;
103#else
104# define EISA_bus 0
105#endif
106
107#endif
diff --git a/include/linux/elevator.h b/include/linux/elevator.h
new file mode 100644
index 000000000000..ee54f81faad5
--- /dev/null
+++ b/include/linux/elevator.h
@@ -0,0 +1,145 @@
1#ifndef _LINUX_ELEVATOR_H
2#define _LINUX_ELEVATOR_H
3
4typedef int (elevator_merge_fn) (request_queue_t *, struct request **,
5 struct bio *);
6
7typedef void (elevator_merge_req_fn) (request_queue_t *, struct request *, struct request *);
8
9typedef void (elevator_merged_fn) (request_queue_t *, struct request *);
10
11typedef struct request *(elevator_next_req_fn) (request_queue_t *);
12
13typedef void (elevator_add_req_fn) (request_queue_t *, struct request *, int);
14typedef int (elevator_queue_empty_fn) (request_queue_t *);
15typedef void (elevator_remove_req_fn) (request_queue_t *, struct request *);
16typedef void (elevator_requeue_req_fn) (request_queue_t *, struct request *);
17typedef struct request *(elevator_request_list_fn) (request_queue_t *, struct request *);
18typedef void (elevator_completed_req_fn) (request_queue_t *, struct request *);
19typedef int (elevator_may_queue_fn) (request_queue_t *, int);
20
21typedef int (elevator_set_req_fn) (request_queue_t *, struct request *, int);
22typedef void (elevator_put_req_fn) (request_queue_t *, struct request *);
23typedef void (elevator_deactivate_req_fn) (request_queue_t *, struct request *);
24
25typedef int (elevator_init_fn) (request_queue_t *, elevator_t *);
26typedef void (elevator_exit_fn) (elevator_t *);
27
28struct elevator_ops
29{
30 elevator_merge_fn *elevator_merge_fn;
31 elevator_merged_fn *elevator_merged_fn;
32 elevator_merge_req_fn *elevator_merge_req_fn;
33
34 elevator_next_req_fn *elevator_next_req_fn;
35 elevator_add_req_fn *elevator_add_req_fn;
36 elevator_remove_req_fn *elevator_remove_req_fn;
37 elevator_requeue_req_fn *elevator_requeue_req_fn;
38 elevator_deactivate_req_fn *elevator_deactivate_req_fn;
39
40 elevator_queue_empty_fn *elevator_queue_empty_fn;
41 elevator_completed_req_fn *elevator_completed_req_fn;
42
43 elevator_request_list_fn *elevator_former_req_fn;
44 elevator_request_list_fn *elevator_latter_req_fn;
45
46 elevator_set_req_fn *elevator_set_req_fn;
47 elevator_put_req_fn *elevator_put_req_fn;
48
49 elevator_may_queue_fn *elevator_may_queue_fn;
50
51 elevator_init_fn *elevator_init_fn;
52 elevator_exit_fn *elevator_exit_fn;
53};
54
55#define ELV_NAME_MAX (16)
56
57/*
58 * identifies an elevator type, such as AS or deadline
59 */
60struct elevator_type
61{
62 struct list_head list;
63 struct elevator_ops ops;
64 struct elevator_type *elevator_type;
65 struct kobj_type *elevator_ktype;
66 char elevator_name[ELV_NAME_MAX];
67 struct module *elevator_owner;
68};
69
70/*
71 * each queue has an elevator_queue assoicated with it
72 */
73struct elevator_queue
74{
75 struct elevator_ops *ops;
76 void *elevator_data;
77 struct kobject kobj;
78 struct elevator_type *elevator_type;
79};
80
81/*
82 * block elevator interface
83 */
84extern void elv_add_request(request_queue_t *, struct request *, int, int);
85extern void __elv_add_request(request_queue_t *, struct request *, int, int);
86extern int elv_merge(request_queue_t *, struct request **, struct bio *);
87extern void elv_merge_requests(request_queue_t *, struct request *,
88 struct request *);
89extern void elv_merged_request(request_queue_t *, struct request *);
90extern void elv_remove_request(request_queue_t *, struct request *);
91extern void elv_requeue_request(request_queue_t *, struct request *);
92extern void elv_deactivate_request(request_queue_t *, struct request *);
93extern int elv_queue_empty(request_queue_t *);
94extern struct request *elv_next_request(struct request_queue *q);
95extern struct request *elv_former_request(request_queue_t *, struct request *);
96extern struct request *elv_latter_request(request_queue_t *, struct request *);
97extern int elv_register_queue(request_queue_t *q);
98extern void elv_unregister_queue(request_queue_t *q);
99extern int elv_may_queue(request_queue_t *, int);
100extern void elv_completed_request(request_queue_t *, struct request *);
101extern int elv_set_request(request_queue_t *, struct request *, int);
102extern void elv_put_request(request_queue_t *, struct request *);
103
104/*
105 * io scheduler registration
106 */
107extern int elv_register(struct elevator_type *);
108extern void elv_unregister(struct elevator_type *);
109
110/*
111 * io scheduler sysfs switching
112 */
113extern ssize_t elv_iosched_show(request_queue_t *, char *);
114extern ssize_t elv_iosched_store(request_queue_t *, const char *, size_t);
115
116extern int elevator_init(request_queue_t *, char *);
117extern void elevator_exit(elevator_t *);
118extern int elv_rq_merge_ok(struct request *, struct bio *);
119extern int elv_try_merge(struct request *, struct bio *);
120extern int elv_try_last_merge(request_queue_t *, struct bio *);
121
122/*
123 * Return values from elevator merger
124 */
125#define ELEVATOR_NO_MERGE 0
126#define ELEVATOR_FRONT_MERGE 1
127#define ELEVATOR_BACK_MERGE 2
128
129/*
130 * Insertion selection
131 */
132#define ELEVATOR_INSERT_FRONT 1
133#define ELEVATOR_INSERT_BACK 2
134#define ELEVATOR_INSERT_SORT 3
135
136/*
137 * return values from elevator_may_queue_fn
138 */
139enum {
140 ELV_MQUEUE_MAY,
141 ELV_MQUEUE_NO,
142 ELV_MQUEUE_MUST,
143};
144
145#endif
diff --git a/include/linux/elf-fdpic.h b/include/linux/elf-fdpic.h
new file mode 100644
index 000000000000..9f5b7456bff3
--- /dev/null
+++ b/include/linux/elf-fdpic.h
@@ -0,0 +1,68 @@
1/* elf-fdpic.h: FDPIC ELF load map
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
12#ifndef _LINUX_ELF_FDPIC_H
13#define _LINUX_ELF_FDPIC_H
14
15#include <linux/elf.h>
16
17#define PT_GNU_STACK (PT_LOOS + 0x474e551)
18
19/* segment mappings for ELF FDPIC libraries/executables/interpreters */
20struct elf32_fdpic_loadseg {
21 Elf32_Addr addr; /* core address to which mapped */
22 Elf32_Addr p_vaddr; /* VMA recorded in file */
23 Elf32_Word p_memsz; /* allocation size recorded in file */
24};
25
26struct elf32_fdpic_loadmap {
27 Elf32_Half version; /* version of these structures, just in case... */
28 Elf32_Half nsegs; /* number of segments */
29 struct elf32_fdpic_loadseg segs[];
30};
31
32#define ELF32_FDPIC_LOADMAP_VERSION 0x0000
33
34/*
35 * binfmt binary parameters structure
36 */
37struct elf_fdpic_params {
38 struct elfhdr hdr; /* ref copy of ELF header */
39 struct elf_phdr *phdrs; /* ref copy of PT_PHDR table */
40 struct elf32_fdpic_loadmap *loadmap; /* loadmap to be passed to userspace */
41 unsigned long elfhdr_addr; /* mapped ELF header user address */
42 unsigned long ph_addr; /* mapped PT_PHDR user address */
43 unsigned long map_addr; /* mapped loadmap user address */
44 unsigned long entry_addr; /* mapped entry user address */
45 unsigned long stack_size; /* stack size requested (PT_GNU_STACK) */
46 unsigned long dynamic_addr; /* mapped PT_DYNAMIC user address */
47 unsigned long load_addr; /* user address at which to map binary */
48 unsigned long flags;
49#define ELF_FDPIC_FLAG_ARRANGEMENT 0x0000000f /* PT_LOAD arrangement flags */
50#define ELF_FDPIC_FLAG_INDEPENDENT 0x00000000 /* PT_LOADs can be put anywhere */
51#define ELF_FDPIC_FLAG_HONOURVADDR 0x00000001 /* PT_LOAD.vaddr must be honoured */
52#define ELF_FDPIC_FLAG_CONSTDISP 0x00000002 /* PT_LOADs require constant
53 * displacement */
54#define ELF_FDPIC_FLAG_CONTIGUOUS 0x00000003 /* PT_LOADs should be contiguous */
55#define ELF_FDPIC_FLAG_EXEC_STACK 0x00000010 /* T if stack to be executable */
56#define ELF_FDPIC_FLAG_NOEXEC_STACK 0x00000020 /* T if stack not to be executable */
57#define ELF_FDPIC_FLAG_EXECUTABLE 0x00000040 /* T if this object is the executable */
58#define ELF_FDPIC_FLAG_PRESENT 0x80000000 /* T if this object is present */
59};
60
61#ifdef CONFIG_MMU
62extern void elf_fdpic_arch_lay_out_mm(struct elf_fdpic_params *exec_params,
63 struct elf_fdpic_params *interp_params,
64 unsigned long *start_stack,
65 unsigned long *start_brk);
66#endif
67
68#endif /* _LINUX_ELF_FDPIC_H */
diff --git a/include/linux/elf.h b/include/linux/elf.h
new file mode 100644
index 000000000000..f5b3ba5a317d
--- /dev/null
+++ b/include/linux/elf.h
@@ -0,0 +1,449 @@
1#ifndef _LINUX_ELF_H
2#define _LINUX_ELF_H
3
4#include <linux/types.h>
5#include <asm/elf.h>
6
7#ifndef elf_read_implies_exec
8 /* Executables for which elf_read_implies_exec() returns TRUE will
9 have the READ_IMPLIES_EXEC personality flag set automatically.
10 Override in asm/elf.h as needed. */
11# define elf_read_implies_exec(ex, have_pt_gnu_stack) 0
12#endif
13
14/* 32-bit ELF base types. */
15typedef __u32 Elf32_Addr;
16typedef __u16 Elf32_Half;
17typedef __u32 Elf32_Off;
18typedef __s32 Elf32_Sword;
19typedef __u32 Elf32_Word;
20
21/* 64-bit ELF base types. */
22typedef __u64 Elf64_Addr;
23typedef __u16 Elf64_Half;
24typedef __s16 Elf64_SHalf;
25typedef __u64 Elf64_Off;
26typedef __s32 Elf64_Sword;
27typedef __u32 Elf64_Word;
28typedef __u64 Elf64_Xword;
29typedef __s64 Elf64_Sxword;
30
31/* These constants are for the segment types stored in the image headers */
32#define PT_NULL 0
33#define PT_LOAD 1
34#define PT_DYNAMIC 2
35#define PT_INTERP 3
36#define PT_NOTE 4
37#define PT_SHLIB 5
38#define PT_PHDR 6
39#define PT_TLS 7 /* Thread local storage segment */
40#define PT_LOOS 0x60000000 /* OS-specific */
41#define PT_HIOS 0x6fffffff /* OS-specific */
42#define PT_LOPROC 0x70000000
43#define PT_HIPROC 0x7fffffff
44#define PT_GNU_EH_FRAME 0x6474e550
45
46#define PT_GNU_STACK (PT_LOOS + 0x474e551)
47
48/* These constants define the different elf file types */
49#define ET_NONE 0
50#define ET_REL 1
51#define ET_EXEC 2
52#define ET_DYN 3
53#define ET_CORE 4
54#define ET_LOPROC 0xff00
55#define ET_HIPROC 0xffff
56
57/* These constants define the various ELF target machines */
58#define EM_NONE 0
59#define EM_M32 1
60#define EM_SPARC 2
61#define EM_386 3
62#define EM_68K 4
63#define EM_88K 5
64#define EM_486 6 /* Perhaps disused */
65#define EM_860 7
66
67#define EM_MIPS 8 /* MIPS R3000 (officially, big-endian only) */
68
69#define EM_MIPS_RS4_BE 10 /* MIPS R4000 big-endian */
70
71#define EM_PARISC 15 /* HPPA */
72
73#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */
74
75#define EM_PPC 20 /* PowerPC */
76#define EM_PPC64 21 /* PowerPC64 */
77
78#define EM_SH 42 /* SuperH */
79
80#define EM_SPARCV9 43 /* SPARC v9 64-bit */
81
82#define EM_IA_64 50 /* HP/Intel IA-64 */
83
84#define EM_X86_64 62 /* AMD x86-64 */
85
86#define EM_S390 22 /* IBM S/390 */
87
88#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */
89
90#define EM_V850 87 /* NEC v850 */
91
92#define EM_M32R 88 /* Renesas M32R */
93
94#define EM_H8_300 46 /* Renesas H8/300,300H,H8S */
95
96/*
97 * This is an interim value that we will use until the committee comes
98 * up with a final number.
99 */
100#define EM_ALPHA 0x9026
101
102/* Bogus old v850 magic number, used by old tools. */
103#define EM_CYGNUS_V850 0x9080
104
105/* Bogus old m32r magic number, used by old tools. */
106#define EM_CYGNUS_M32R 0x9041
107
108/*
109 * This is the old interim value for S/390 architecture
110 */
111#define EM_S390_OLD 0xA390
112
113#define EM_FRV 0x5441 /* Fujitsu FR-V */
114
115/* This is the info that is needed to parse the dynamic section of the file */
116#define DT_NULL 0
117#define DT_NEEDED 1
118#define DT_PLTRELSZ 2
119#define DT_PLTGOT 3
120#define DT_HASH 4
121#define DT_STRTAB 5
122#define DT_SYMTAB 6
123#define DT_RELA 7
124#define DT_RELASZ 8
125#define DT_RELAENT 9
126#define DT_STRSZ 10
127#define DT_SYMENT 11
128#define DT_INIT 12
129#define DT_FINI 13
130#define DT_SONAME 14
131#define DT_RPATH 15
132#define DT_SYMBOLIC 16
133#define DT_REL 17
134#define DT_RELSZ 18
135#define DT_RELENT 19
136#define DT_PLTREL 20
137#define DT_DEBUG 21
138#define DT_TEXTREL 22
139#define DT_JMPREL 23
140#define DT_LOPROC 0x70000000
141#define DT_HIPROC 0x7fffffff
142
143/* This info is needed when parsing the symbol table */
144#define STB_LOCAL 0
145#define STB_GLOBAL 1
146#define STB_WEAK 2
147
148#define STT_NOTYPE 0
149#define STT_OBJECT 1
150#define STT_FUNC 2
151#define STT_SECTION 3
152#define STT_FILE 4
153
154#define ELF_ST_BIND(x) ((x) >> 4)
155#define ELF_ST_TYPE(x) (((unsigned int) x) & 0xf)
156#define ELF32_ST_BIND(x) ELF_ST_BIND(x)
157#define ELF32_ST_TYPE(x) ELF_ST_TYPE(x)
158#define ELF64_ST_BIND(x) ELF_ST_BIND(x)
159#define ELF64_ST_TYPE(x) ELF_ST_TYPE(x)
160
161/* Symbolic values for the entries in the auxiliary table
162 put on the initial stack */
163#define AT_NULL 0 /* end of vector */
164#define AT_IGNORE 1 /* entry should be ignored */
165#define AT_EXECFD 2 /* file descriptor of program */
166#define AT_PHDR 3 /* program headers for program */
167#define AT_PHENT 4 /* size of program header entry */
168#define AT_PHNUM 5 /* number of program headers */
169#define AT_PAGESZ 6 /* system page size */
170#define AT_BASE 7 /* base address of interpreter */
171#define AT_FLAGS 8 /* flags */
172#define AT_ENTRY 9 /* entry point of program */
173#define AT_NOTELF 10 /* program is not ELF */
174#define AT_UID 11 /* real uid */
175#define AT_EUID 12 /* effective uid */
176#define AT_GID 13 /* real gid */
177#define AT_EGID 14 /* effective gid */
178#define AT_PLATFORM 15 /* string identifying CPU for optimizations */
179#define AT_HWCAP 16 /* arch dependent hints at CPU capabilities */
180#define AT_CLKTCK 17 /* frequency at which times() increments */
181
182#define AT_SECURE 23 /* secure mode boolean */
183
184typedef struct dynamic{
185 Elf32_Sword d_tag;
186 union{
187 Elf32_Sword d_val;
188 Elf32_Addr d_ptr;
189 } d_un;
190} Elf32_Dyn;
191
192typedef struct {
193 Elf64_Sxword d_tag; /* entry tag value */
194 union {
195 Elf64_Xword d_val;
196 Elf64_Addr d_ptr;
197 } d_un;
198} Elf64_Dyn;
199
200/* The following are used with relocations */
201#define ELF32_R_SYM(x) ((x) >> 8)
202#define ELF32_R_TYPE(x) ((x) & 0xff)
203
204#define ELF64_R_SYM(i) ((i) >> 32)
205#define ELF64_R_TYPE(i) ((i) & 0xffffffff)
206
207typedef struct elf32_rel {
208 Elf32_Addr r_offset;
209 Elf32_Word r_info;
210} Elf32_Rel;
211
212typedef struct elf64_rel {
213 Elf64_Addr r_offset; /* Location at which to apply the action */
214 Elf64_Xword r_info; /* index and type of relocation */
215} Elf64_Rel;
216
217typedef struct elf32_rela{
218 Elf32_Addr r_offset;
219 Elf32_Word r_info;
220 Elf32_Sword r_addend;
221} Elf32_Rela;
222
223typedef struct elf64_rela {
224 Elf64_Addr r_offset; /* Location at which to apply the action */
225 Elf64_Xword r_info; /* index and type of relocation */
226 Elf64_Sxword r_addend; /* Constant addend used to compute value */
227} Elf64_Rela;
228
229typedef struct elf32_sym{
230 Elf32_Word st_name;
231 Elf32_Addr st_value;
232 Elf32_Word st_size;
233 unsigned char st_info;
234 unsigned char st_other;
235 Elf32_Half st_shndx;
236} Elf32_Sym;
237
238typedef struct elf64_sym {
239 Elf64_Word st_name; /* Symbol name, index in string tbl */
240 unsigned char st_info; /* Type and binding attributes */
241 unsigned char st_other; /* No defined meaning, 0 */
242 Elf64_Half st_shndx; /* Associated section index */
243 Elf64_Addr st_value; /* Value of the symbol */
244 Elf64_Xword st_size; /* Associated symbol size */
245} Elf64_Sym;
246
247
248#define EI_NIDENT 16
249
250typedef struct elf32_hdr{
251 unsigned char e_ident[EI_NIDENT];
252 Elf32_Half e_type;
253 Elf32_Half e_machine;
254 Elf32_Word e_version;
255 Elf32_Addr e_entry; /* Entry point */
256 Elf32_Off e_phoff;
257 Elf32_Off e_shoff;
258 Elf32_Word e_flags;
259 Elf32_Half e_ehsize;
260 Elf32_Half e_phentsize;
261 Elf32_Half e_phnum;
262 Elf32_Half e_shentsize;
263 Elf32_Half e_shnum;
264 Elf32_Half e_shstrndx;
265} Elf32_Ehdr;
266
267typedef struct elf64_hdr {
268 unsigned char e_ident[16]; /* ELF "magic number" */
269 Elf64_Half e_type;
270 Elf64_Half e_machine;
271 Elf64_Word e_version;
272 Elf64_Addr e_entry; /* Entry point virtual address */
273 Elf64_Off e_phoff; /* Program header table file offset */
274 Elf64_Off e_shoff; /* Section header table file offset */
275 Elf64_Word e_flags;
276 Elf64_Half e_ehsize;
277 Elf64_Half e_phentsize;
278 Elf64_Half e_phnum;
279 Elf64_Half e_shentsize;
280 Elf64_Half e_shnum;
281 Elf64_Half e_shstrndx;
282} Elf64_Ehdr;
283
284/* These constants define the permissions on sections in the program
285 header, p_flags. */
286#define PF_R 0x4
287#define PF_W 0x2
288#define PF_X 0x1
289
290typedef struct elf32_phdr{
291 Elf32_Word p_type;
292 Elf32_Off p_offset;
293 Elf32_Addr p_vaddr;
294 Elf32_Addr p_paddr;
295 Elf32_Word p_filesz;
296 Elf32_Word p_memsz;
297 Elf32_Word p_flags;
298 Elf32_Word p_align;
299} Elf32_Phdr;
300
301typedef struct elf64_phdr {
302 Elf64_Word p_type;
303 Elf64_Word p_flags;
304 Elf64_Off p_offset; /* Segment file offset */
305 Elf64_Addr p_vaddr; /* Segment virtual address */
306 Elf64_Addr p_paddr; /* Segment physical address */
307 Elf64_Xword p_filesz; /* Segment size in file */
308 Elf64_Xword p_memsz; /* Segment size in memory */
309 Elf64_Xword p_align; /* Segment alignment, file & memory */
310} Elf64_Phdr;
311
312/* sh_type */
313#define SHT_NULL 0
314#define SHT_PROGBITS 1
315#define SHT_SYMTAB 2
316#define SHT_STRTAB 3
317#define SHT_RELA 4
318#define SHT_HASH 5
319#define SHT_DYNAMIC 6
320#define SHT_NOTE 7
321#define SHT_NOBITS 8
322#define SHT_REL 9
323#define SHT_SHLIB 10
324#define SHT_DYNSYM 11
325#define SHT_NUM 12
326#define SHT_LOPROC 0x70000000
327#define SHT_HIPROC 0x7fffffff
328#define SHT_LOUSER 0x80000000
329#define SHT_HIUSER 0xffffffff
330
331/* sh_flags */
332#define SHF_WRITE 0x1
333#define SHF_ALLOC 0x2
334#define SHF_EXECINSTR 0x4
335#define SHF_MASKPROC 0xf0000000
336
337/* special section indexes */
338#define SHN_UNDEF 0
339#define SHN_LORESERVE 0xff00
340#define SHN_LOPROC 0xff00
341#define SHN_HIPROC 0xff1f
342#define SHN_ABS 0xfff1
343#define SHN_COMMON 0xfff2
344#define SHN_HIRESERVE 0xffff
345
346typedef struct {
347 Elf32_Word sh_name;
348 Elf32_Word sh_type;
349 Elf32_Word sh_flags;
350 Elf32_Addr sh_addr;
351 Elf32_Off sh_offset;
352 Elf32_Word sh_size;
353 Elf32_Word sh_link;
354 Elf32_Word sh_info;
355 Elf32_Word sh_addralign;
356 Elf32_Word sh_entsize;
357} Elf32_Shdr;
358
359typedef struct elf64_shdr {
360 Elf64_Word sh_name; /* Section name, index in string tbl */
361 Elf64_Word sh_type; /* Type of section */
362 Elf64_Xword sh_flags; /* Miscellaneous section attributes */
363 Elf64_Addr sh_addr; /* Section virtual addr at execution */
364 Elf64_Off sh_offset; /* Section file offset */
365 Elf64_Xword sh_size; /* Size of section in bytes */
366 Elf64_Word sh_link; /* Index of another section */
367 Elf64_Word sh_info; /* Additional section information */
368 Elf64_Xword sh_addralign; /* Section alignment */
369 Elf64_Xword sh_entsize; /* Entry size if section holds table */
370} Elf64_Shdr;
371
372#define EI_MAG0 0 /* e_ident[] indexes */
373#define EI_MAG1 1
374#define EI_MAG2 2
375#define EI_MAG3 3
376#define EI_CLASS 4
377#define EI_DATA 5
378#define EI_VERSION 6
379#define EI_OSABI 7
380#define EI_PAD 8
381
382#define ELFMAG0 0x7f /* EI_MAG */
383#define ELFMAG1 'E'
384#define ELFMAG2 'L'
385#define ELFMAG3 'F'
386#define ELFMAG "\177ELF"
387#define SELFMAG 4
388
389#define ELFCLASSNONE 0 /* EI_CLASS */
390#define ELFCLASS32 1
391#define ELFCLASS64 2
392#define ELFCLASSNUM 3
393
394#define ELFDATANONE 0 /* e_ident[EI_DATA] */
395#define ELFDATA2LSB 1
396#define ELFDATA2MSB 2
397
398#define EV_NONE 0 /* e_version, EI_VERSION */
399#define EV_CURRENT 1
400#define EV_NUM 2
401
402#define ELFOSABI_NONE 0
403#define ELFOSABI_LINUX 3
404
405#ifndef ELF_OSABI
406#define ELF_OSABI ELFOSABI_NONE
407#endif
408
409/* Notes used in ET_CORE */
410#define NT_PRSTATUS 1
411#define NT_PRFPREG 2
412#define NT_PRPSINFO 3
413#define NT_TASKSTRUCT 4
414#define NT_AUXV 6
415#define NT_PRXFPREG 0x46e62b7f /* copied from gdb5.1/include/elf/common.h */
416
417
418/* Note header in a PT_NOTE section */
419typedef struct elf32_note {
420 Elf32_Word n_namesz; /* Name size */
421 Elf32_Word n_descsz; /* Content size */
422 Elf32_Word n_type; /* Content type */
423} Elf32_Nhdr;
424
425/* Note header in a PT_NOTE section */
426typedef struct elf64_note {
427 Elf64_Word n_namesz; /* Name size */
428 Elf64_Word n_descsz; /* Content size */
429 Elf64_Word n_type; /* Content type */
430} Elf64_Nhdr;
431
432#if ELF_CLASS == ELFCLASS32
433
434extern Elf32_Dyn _DYNAMIC [];
435#define elfhdr elf32_hdr
436#define elf_phdr elf32_phdr
437#define elf_note elf32_note
438
439#else
440
441extern Elf64_Dyn _DYNAMIC [];
442#define elfhdr elf64_hdr
443#define elf_phdr elf64_phdr
444#define elf_note elf64_note
445
446#endif
447
448
449#endif /* _LINUX_ELF_H */
diff --git a/include/linux/elfcore.h b/include/linux/elfcore.h
new file mode 100644
index 000000000000..dbd7bb4a33b7
--- /dev/null
+++ b/include/linux/elfcore.h
@@ -0,0 +1,129 @@
1#ifndef _LINUX_ELFCORE_H
2#define _LINUX_ELFCORE_H
3
4#include <linux/types.h>
5#include <linux/signal.h>
6#include <linux/time.h>
7#include <linux/user.h>
8
9struct elf_siginfo
10{
11 int si_signo; /* signal number */
12 int si_code; /* extra code */
13 int si_errno; /* errno */
14};
15
16#include <asm/elf.h>
17
18#ifndef __KERNEL__
19typedef elf_greg_t greg_t;
20typedef elf_gregset_t gregset_t;
21typedef elf_fpregset_t fpregset_t;
22typedef elf_fpxregset_t fpxregset_t;
23#define NGREG ELF_NGREG
24#endif
25
26/*
27 * Definitions to generate Intel SVR4-like core files.
28 * These mostly have the same names as the SVR4 types with "elf_"
29 * tacked on the front to prevent clashes with linux definitions,
30 * and the typedef forms have been avoided. This is mostly like
31 * the SVR4 structure, but more Linuxy, with things that Linux does
32 * not support and which gdb doesn't really use excluded.
33 * Fields present but not used are marked with "XXX".
34 */
35struct elf_prstatus
36{
37#if 0
38 long pr_flags; /* XXX Process flags */
39 short pr_why; /* XXX Reason for process halt */
40 short pr_what; /* XXX More detailed reason */
41#endif
42 struct elf_siginfo pr_info; /* Info associated with signal */
43 short pr_cursig; /* Current signal */
44 unsigned long pr_sigpend; /* Set of pending signals */
45 unsigned long pr_sighold; /* Set of held signals */
46#if 0
47 struct sigaltstack pr_altstack; /* Alternate stack info */
48 struct sigaction pr_action; /* Signal action for current sig */
49#endif
50 pid_t pr_pid;
51 pid_t pr_ppid;
52 pid_t pr_pgrp;
53 pid_t pr_sid;
54 struct timeval pr_utime; /* User time */
55 struct timeval pr_stime; /* System time */
56 struct timeval pr_cutime; /* Cumulative user time */
57 struct timeval pr_cstime; /* Cumulative system time */
58#if 0
59 long pr_instr; /* Current instruction */
60#endif
61 elf_gregset_t pr_reg; /* GP registers */
62 int pr_fpvalid; /* True if math co-processor being used. */
63};
64
65#define ELF_PRARGSZ (80) /* Number of chars for args */
66
67struct elf_prpsinfo
68{
69 char pr_state; /* numeric process state */
70 char pr_sname; /* char for pr_state */
71 char pr_zomb; /* zombie */
72 char pr_nice; /* nice val */
73 unsigned long pr_flag; /* flags */
74 __kernel_uid_t pr_uid;
75 __kernel_gid_t pr_gid;
76 pid_t pr_pid, pr_ppid, pr_pgrp, pr_sid;
77 /* Lots missing */
78 char pr_fname[16]; /* filename of executable */
79 char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */
80};
81
82#ifndef __KERNEL__
83typedef struct elf_prstatus prstatus_t;
84typedef struct elf_prpsinfo prpsinfo_t;
85#define PRARGSZ ELF_PRARGSZ
86#endif
87
88#ifdef __KERNEL__
89static inline void elf_core_copy_regs(elf_gregset_t *elfregs, struct pt_regs *regs)
90{
91#ifdef ELF_CORE_COPY_REGS
92 ELF_CORE_COPY_REGS((*elfregs), regs)
93#else
94 BUG_ON(sizeof(*elfregs) != sizeof(*regs));
95 *(struct pt_regs *)elfregs = *regs;
96#endif
97}
98
99static inline int elf_core_copy_task_regs(struct task_struct *t, elf_gregset_t* elfregs)
100{
101#ifdef ELF_CORE_COPY_TASK_REGS
102
103 return ELF_CORE_COPY_TASK_REGS(t, elfregs);
104#endif
105 return 0;
106}
107
108extern int dump_fpu (struct pt_regs *, elf_fpregset_t *);
109
110static inline int elf_core_copy_task_fpregs(struct task_struct *t, struct pt_regs *regs, elf_fpregset_t *fpu)
111{
112#ifdef ELF_CORE_COPY_FPREGS
113 return ELF_CORE_COPY_FPREGS(t, fpu);
114#else
115 return dump_fpu(regs, fpu);
116#endif
117}
118
119#ifdef ELF_CORE_COPY_XFPREGS
120static inline int elf_core_copy_task_xfpregs(struct task_struct *t, elf_fpxregset_t *xfpu)
121{
122 return ELF_CORE_COPY_XFPREGS(t, xfpu);
123}
124#endif
125
126#endif /* __KERNEL__ */
127
128
129#endif /* _LINUX_ELFCORE_H */
diff --git a/include/linux/err.h b/include/linux/err.h
new file mode 100644
index 000000000000..17c55df13615
--- /dev/null
+++ b/include/linux/err.h
@@ -0,0 +1,31 @@
1#ifndef _LINUX_ERR_H
2#define _LINUX_ERR_H
3
4#include <linux/compiler.h>
5
6#include <asm/errno.h>
7
8/*
9 * Kernel pointers have redundant information, so we can use a
10 * scheme where we can return either an error code or a dentry
11 * pointer with the same return value.
12 *
13 * This should be a per-architecture thing, to allow different
14 * error and pointer decisions.
15 */
16static inline void *ERR_PTR(long error)
17{
18 return (void *) error;
19}
20
21static inline long PTR_ERR(const void *ptr)
22{
23 return (long) ptr;
24}
25
26static inline long IS_ERR(const void *ptr)
27{
28 return unlikely((unsigned long)ptr > (unsigned long)-1000L);
29}
30
31#endif /* _LINUX_ERR_H */
diff --git a/include/linux/errno.h b/include/linux/errno.h
new file mode 100644
index 000000000000..d90b80f9b28c
--- /dev/null
+++ b/include/linux/errno.h
@@ -0,0 +1,29 @@
1#ifndef _LINUX_ERRNO_H
2#define _LINUX_ERRNO_H
3
4#include <asm/errno.h>
5
6#ifdef __KERNEL__
7
8/* Should never be seen by user programs */
9#define ERESTARTSYS 512
10#define ERESTARTNOINTR 513
11#define ERESTARTNOHAND 514 /* restart if no handler.. */
12#define ENOIOCTLCMD 515 /* No ioctl command */
13#define ERESTART_RESTARTBLOCK 516 /* restart by calling sys_restart_syscall */
14
15/* Defined for the NFSv3 protocol */
16#define EBADHANDLE 521 /* Illegal NFS file handle */
17#define ENOTSYNC 522 /* Update synchronization mismatch */
18#define EBADCOOKIE 523 /* Cookie is stale */
19#define ENOTSUPP 524 /* Operation is not supported */
20#define ETOOSMALL 525 /* Buffer or request is too small */
21#define ESERVERFAULT 526 /* An untranslatable error occurred */
22#define EBADTYPE 527 /* Type not supported by server */
23#define EJUKEBOX 528 /* Request initiated, but will not complete before timeout */
24#define EIOCBQUEUED 529 /* iocb queued, will get completion event */
25#define EIOCBRETRY 530 /* iocb queued, will trigger a retry */
26
27#endif
28
29#endif
diff --git a/include/linux/errqueue.h b/include/linux/errqueue.h
new file mode 100644
index 000000000000..174582fedb8b
--- /dev/null
+++ b/include/linux/errqueue.h
@@ -0,0 +1,47 @@
1#ifndef _LINUX_ERRQUEUE_H
2#define _LINUX_ERRQUEUE_H 1
3
4struct sock_extended_err
5{
6 __u32 ee_errno;
7 __u8 ee_origin;
8 __u8 ee_type;
9 __u8 ee_code;
10 __u8 ee_pad;
11 __u32 ee_info;
12 __u32 ee_data;
13};
14
15#define SO_EE_ORIGIN_NONE 0
16#define SO_EE_ORIGIN_LOCAL 1
17#define SO_EE_ORIGIN_ICMP 2
18#define SO_EE_ORIGIN_ICMP6 3
19
20#define SO_EE_OFFENDER(ee) ((struct sockaddr*)((ee)+1))
21
22#ifdef __KERNEL__
23
24#include <linux/config.h>
25#include <net/ip.h>
26#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
27#include <linux/ipv6.h>
28#endif
29
30#define SKB_EXT_ERR(skb) ((struct sock_exterr_skb *) ((skb)->cb))
31
32struct sock_exterr_skb
33{
34 union {
35 struct inet_skb_parm h4;
36#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
37 struct inet6_skb_parm h6;
38#endif
39 } header;
40 struct sock_extended_err ee;
41 u16 addr_offset;
42 u16 port;
43};
44
45#endif
46
47#endif
diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
new file mode 100644
index 000000000000..396c48cbaeb1
--- /dev/null
+++ b/include/linux/etherdevice.h
@@ -0,0 +1,88 @@
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. NET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Definitions for the Ethernet handlers.
7 *
8 * Version: @(#)eth.h 1.0.4 05/13/93
9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu>
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 *
13 * Relocated to include/linux where it belongs by Alan Cox
14 * <gw4pts@gw4pts.ampr.org>
15 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version
19 * 2 of the License, or (at your option) any later version.
20 *
21 * WARNING: This move may well be temporary. This file will get merged with others RSN.
22 *
23 */
24#ifndef _LINUX_ETHERDEVICE_H
25#define _LINUX_ETHERDEVICE_H
26
27#include <linux/if_ether.h>
28#include <linux/random.h>
29
30#ifdef __KERNEL__
31extern int eth_header(struct sk_buff *skb, struct net_device *dev,
32 unsigned short type, void *daddr,
33 void *saddr, unsigned len);
34extern int eth_rebuild_header(struct sk_buff *skb);
35extern unsigned short eth_type_trans(struct sk_buff *skb, struct net_device *dev);
36extern void eth_header_cache_update(struct hh_cache *hh, struct net_device *dev,
37 unsigned char * haddr);
38extern int eth_header_cache(struct neighbour *neigh,
39 struct hh_cache *hh);
40
41extern struct net_device *alloc_etherdev(int sizeof_priv);
42static inline void eth_copy_and_sum (struct sk_buff *dest,
43 const unsigned char *src,
44 int len, int base)
45{
46 memcpy (dest->data, src, len);
47}
48
49/**
50 * is_zero_ether_addr - Determine if give Ethernet address is all
51 * zeros.
52 */
53static inline int is_zero_ether_addr(const u8 *addr)
54{
55 return !(addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5]);
56}
57
58/**
59 * is_valid_ether_addr - Determine if the given Ethernet address is valid
60 * @addr: Pointer to a six-byte array containing the Ethernet address
61 *
62 * Check that the Ethernet address (MAC) is not 00:00:00:00:00:00, is not
63 * a multicast address, and is not FF:FF:FF:FF:FF:FF. The multicast
64 * and FF:FF:... tests are combined into the single test "!(addr[0]&1)".
65 *
66 * Return true if the address is valid.
67 */
68static inline int is_valid_ether_addr(const u8 *addr)
69{
70 return !(addr[0]&1) && !is_zero_ether_addr(addr);
71}
72
73/**
74 * random_ether_addr - Generate software assigned random Ethernet address
75 * @addr: Pointer to a six-byte array containing the Ethernet address
76 *
77 * Generate a random Ethernet address (MAC) that is not multicast
78 * and has the local assigned bit set.
79 */
80static inline void random_ether_addr(u8 *addr)
81{
82 get_random_bytes (addr, ETH_ALEN);
83 addr [0] &= 0xfe; /* clear multicast bit */
84 addr [0] |= 0x02; /* set local assignment bit (IEEE802) */
85}
86#endif
87
88#endif /* _LINUX_ETHERDEVICE_H */
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
new file mode 100644
index 000000000000..c85b210490ea
--- /dev/null
+++ b/include/linux/ethtool.h
@@ -0,0 +1,471 @@
1/*
2 * ethtool.h: Defines for Linux ethtool.
3 *
4 * Copyright (C) 1998 David S. Miller (davem@redhat.com)
5 * Copyright 2001 Jeff Garzik <jgarzik@pobox.com>
6 * Portions Copyright 2001 Sun Microsystems (thockin@sun.com)
7 * Portions Copyright 2002 Intel (eli.kupermann@intel.com,
8 * christopher.leech@intel.com,
9 * scott.feldman@intel.com)
10 */
11
12#ifndef _LINUX_ETHTOOL_H
13#define _LINUX_ETHTOOL_H
14
15
16/* This should work for both 32 and 64 bit userland. */
17struct ethtool_cmd {
18 u32 cmd;
19 u32 supported; /* Features this interface supports */
20 u32 advertising; /* Features this interface advertises */
21 u16 speed; /* The forced speed, 10Mb, 100Mb, gigabit */
22 u8 duplex; /* Duplex, half or full */
23 u8 port; /* Which connector port */
24 u8 phy_address;
25 u8 transceiver; /* Which transceiver to use */
26 u8 autoneg; /* Enable or disable autonegotiation */
27 u32 maxtxpkt; /* Tx pkts before generating tx int */
28 u32 maxrxpkt; /* Rx pkts before generating rx int */
29 u32 reserved[4];
30};
31
32#define ETHTOOL_BUSINFO_LEN 32
33/* these strings are set to whatever the driver author decides... */
34struct ethtool_drvinfo {
35 u32 cmd;
36 char driver[32]; /* driver short name, "tulip", "eepro100" */
37 char version[32]; /* driver version string */
38 char fw_version[32]; /* firmware version string, if applicable */
39 char bus_info[ETHTOOL_BUSINFO_LEN]; /* Bus info for this IF. */
40 /* For PCI devices, use pci_name(pci_dev). */
41 char reserved1[32];
42 char reserved2[16];
43 u32 n_stats; /* number of u64's from ETHTOOL_GSTATS */
44 u32 testinfo_len;
45 u32 eedump_len; /* Size of data from ETHTOOL_GEEPROM (bytes) */
46 u32 regdump_len; /* Size of data from ETHTOOL_GREGS (bytes) */
47};
48
49#define SOPASS_MAX 6
50/* wake-on-lan settings */
51struct ethtool_wolinfo {
52 u32 cmd;
53 u32 supported;
54 u32 wolopts;
55 u8 sopass[SOPASS_MAX]; /* SecureOn(tm) password */
56};
57
58/* for passing single values */
59struct ethtool_value {
60 u32 cmd;
61 u32 data;
62};
63
64/* for passing big chunks of data */
65struct ethtool_regs {
66 u32 cmd;
67 u32 version; /* driver-specific, indicates different chips/revs */
68 u32 len; /* bytes */
69 u8 data[0];
70};
71
72/* for passing EEPROM chunks */
73struct ethtool_eeprom {
74 u32 cmd;
75 u32 magic;
76 u32 offset; /* in bytes */
77 u32 len; /* in bytes */
78 u8 data[0];
79};
80
81/* for configuring coalescing parameters of chip */
82struct ethtool_coalesce {
83 u32 cmd; /* ETHTOOL_{G,S}COALESCE */
84
85 /* How many usecs to delay an RX interrupt after
86 * a packet arrives. If 0, only rx_max_coalesced_frames
87 * is used.
88 */
89 u32 rx_coalesce_usecs;
90
91 /* How many packets to delay an RX interrupt after
92 * a packet arrives. If 0, only rx_coalesce_usecs is
93 * used. It is illegal to set both usecs and max frames
94 * to zero as this would cause RX interrupts to never be
95 * generated.
96 */
97 u32 rx_max_coalesced_frames;
98
99 /* Same as above two parameters, except that these values
100 * apply while an IRQ is being serviced by the host. Not
101 * all cards support this feature and the values are ignored
102 * in that case.
103 */
104 u32 rx_coalesce_usecs_irq;
105 u32 rx_max_coalesced_frames_irq;
106
107 /* How many usecs to delay a TX interrupt after
108 * a packet is sent. If 0, only tx_max_coalesced_frames
109 * is used.
110 */
111 u32 tx_coalesce_usecs;
112
113 /* How many packets to delay a TX interrupt after
114 * a packet is sent. If 0, only tx_coalesce_usecs is
115 * used. It is illegal to set both usecs and max frames
116 * to zero as this would cause TX interrupts to never be
117 * generated.
118 */
119 u32 tx_max_coalesced_frames;
120
121 /* Same as above two parameters, except that these values
122 * apply while an IRQ is being serviced by the host. Not
123 * all cards support this feature and the values are ignored
124 * in that case.
125 */
126 u32 tx_coalesce_usecs_irq;
127 u32 tx_max_coalesced_frames_irq;
128
129 /* How many usecs to delay in-memory statistics
130 * block updates. Some drivers do not have an in-memory
131 * statistic block, and in such cases this value is ignored.
132 * This value must not be zero.
133 */
134 u32 stats_block_coalesce_usecs;
135
136 /* Adaptive RX/TX coalescing is an algorithm implemented by
137 * some drivers to improve latency under low packet rates and
138 * improve throughput under high packet rates. Some drivers
139 * only implement one of RX or TX adaptive coalescing. Anything
140 * not implemented by the driver causes these values to be
141 * silently ignored.
142 */
143 u32 use_adaptive_rx_coalesce;
144 u32 use_adaptive_tx_coalesce;
145
146 /* When the packet rate (measured in packets per second)
147 * is below pkt_rate_low, the {rx,tx}_*_low parameters are
148 * used.
149 */
150 u32 pkt_rate_low;
151 u32 rx_coalesce_usecs_low;
152 u32 rx_max_coalesced_frames_low;
153 u32 tx_coalesce_usecs_low;
154 u32 tx_max_coalesced_frames_low;
155
156 /* When the packet rate is below pkt_rate_high but above
157 * pkt_rate_low (both measured in packets per second) the
158 * normal {rx,tx}_* coalescing parameters are used.
159 */
160
161 /* When the packet rate is (measured in packets per second)
162 * is above pkt_rate_high, the {rx,tx}_*_high parameters are
163 * used.
164 */
165 u32 pkt_rate_high;
166 u32 rx_coalesce_usecs_high;
167 u32 rx_max_coalesced_frames_high;
168 u32 tx_coalesce_usecs_high;
169 u32 tx_max_coalesced_frames_high;
170
171 /* How often to do adaptive coalescing packet rate sampling,
172 * measured in seconds. Must not be zero.
173 */
174 u32 rate_sample_interval;
175};
176
177/* for configuring RX/TX ring parameters */
178struct ethtool_ringparam {
179 u32 cmd; /* ETHTOOL_{G,S}RINGPARAM */
180
181 /* Read only attributes. These indicate the maximum number
182 * of pending RX/TX ring entries the driver will allow the
183 * user to set.
184 */
185 u32 rx_max_pending;
186 u32 rx_mini_max_pending;
187 u32 rx_jumbo_max_pending;
188 u32 tx_max_pending;
189
190 /* Values changeable by the user. The valid values are
191 * in the range 1 to the "*_max_pending" counterpart above.
192 */
193 u32 rx_pending;
194 u32 rx_mini_pending;
195 u32 rx_jumbo_pending;
196 u32 tx_pending;
197};
198
199/* for configuring link flow control parameters */
200struct ethtool_pauseparam {
201 u32 cmd; /* ETHTOOL_{G,S}PAUSEPARAM */
202
203 /* If the link is being auto-negotiated (via ethtool_cmd.autoneg
204 * being true) the user may set 'autonet' here non-zero to have the
205 * pause parameters be auto-negotiated too. In such a case, the
206 * {rx,tx}_pause values below determine what capabilities are
207 * advertised.
208 *
209 * If 'autoneg' is zero or the link is not being auto-negotiated,
210 * then {rx,tx}_pause force the driver to use/not-use pause
211 * flow control.
212 */
213 u32 autoneg;
214 u32 rx_pause;
215 u32 tx_pause;
216};
217
218#define ETH_GSTRING_LEN 32
219enum ethtool_stringset {
220 ETH_SS_TEST = 0,
221 ETH_SS_STATS,
222};
223
224/* for passing string sets for data tagging */
225struct ethtool_gstrings {
226 u32 cmd; /* ETHTOOL_GSTRINGS */
227 u32 string_set; /* string set id e.c. ETH_SS_TEST, etc*/
228 u32 len; /* number of strings in the string set */
229 u8 data[0];
230};
231
232enum ethtool_test_flags {
233 ETH_TEST_FL_OFFLINE = (1 << 0), /* online / offline */
234 ETH_TEST_FL_FAILED = (1 << 1), /* test passed / failed */
235};
236
237/* for requesting NIC test and getting results*/
238struct ethtool_test {
239 u32 cmd; /* ETHTOOL_TEST */
240 u32 flags; /* ETH_TEST_FL_xxx */
241 u32 reserved;
242 u32 len; /* result length, in number of u64 elements */
243 u64 data[0];
244};
245
246/* for dumping NIC-specific statistics */
247struct ethtool_stats {
248 u32 cmd; /* ETHTOOL_GSTATS */
249 u32 n_stats; /* number of u64's being returned */
250 u64 data[0];
251};
252
253struct net_device;
254
255/* Some generic methods drivers may use in their ethtool_ops */
256u32 ethtool_op_get_link(struct net_device *dev);
257u32 ethtool_op_get_tx_csum(struct net_device *dev);
258int ethtool_op_set_tx_csum(struct net_device *dev, u32 data);
259u32 ethtool_op_get_sg(struct net_device *dev);
260int ethtool_op_set_sg(struct net_device *dev, u32 data);
261u32 ethtool_op_get_tso(struct net_device *dev);
262int ethtool_op_set_tso(struct net_device *dev, u32 data);
263
264/**
265 * &ethtool_ops - Alter and report network device settings
266 * get_settings: Get device-specific settings
267 * set_settings: Set device-specific settings
268 * get_drvinfo: Report driver information
269 * get_regs: Get device registers
270 * get_wol: Report whether Wake-on-Lan is enabled
271 * set_wol: Turn Wake-on-Lan on or off
272 * get_msglevel: Report driver message level
273 * set_msglevel: Set driver message level
274 * nway_reset: Restart autonegotiation
275 * get_link: Get link status
276 * get_eeprom: Read data from the device EEPROM
277 * set_eeprom: Write data to the device EEPROM
278 * get_coalesce: Get interrupt coalescing parameters
279 * set_coalesce: Set interrupt coalescing parameters
280 * get_ringparam: Report ring sizes
281 * set_ringparam: Set ring sizes
282 * get_pauseparam: Report pause parameters
283 * set_pauseparam: Set pause paramters
284 * get_rx_csum: Report whether receive checksums are turned on or off
285 * set_rx_csum: Turn receive checksum on or off
286 * get_tx_csum: Report whether transmit checksums are turned on or off
287 * set_tx_csum: Turn transmit checksums on or off
288 * get_sg: Report whether scatter-gather is enabled
289 * set_sg: Turn scatter-gather on or off
290 * get_tso: Report whether TCP segmentation offload is enabled
291 * set_tso: Turn TCP segmentation offload on or off
292 * self_test: Run specified self-tests
293 * get_strings: Return a set of strings that describe the requested objects
294 * phys_id: Identify the device
295 * get_stats: Return statistics about the device
296 *
297 * Description:
298 *
299 * get_settings:
300 * @get_settings is passed an &ethtool_cmd to fill in. It returns
301 * an negative errno or zero.
302 *
303 * set_settings:
304 * @set_settings is passed an &ethtool_cmd and should attempt to set
305 * all the settings this device supports. It may return an error value
306 * if something goes wrong (otherwise 0).
307 *
308 * get_eeprom:
309 * Should fill in the magic field. Don't need to check len for zero
310 * or wraparound. Fill in the data argument with the eeprom values
311 * from offset to offset + len. Update len to the amount read.
312 * Returns an error or zero.
313 *
314 * set_eeprom:
315 * Should validate the magic field. Don't need to check len for zero
316 * or wraparound. Update len to the amount written. Returns an error
317 * or zero.
318 */
319struct ethtool_ops {
320 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
321 int (*set_settings)(struct net_device *, struct ethtool_cmd *);
322 void (*get_drvinfo)(struct net_device *, struct ethtool_drvinfo *);
323 int (*get_regs_len)(struct net_device *);
324 void (*get_regs)(struct net_device *, struct ethtool_regs *, void *);
325 void (*get_wol)(struct net_device *, struct ethtool_wolinfo *);
326 int (*set_wol)(struct net_device *, struct ethtool_wolinfo *);
327 u32 (*get_msglevel)(struct net_device *);
328 void (*set_msglevel)(struct net_device *, u32);
329 int (*nway_reset)(struct net_device *);
330 u32 (*get_link)(struct net_device *);
331 int (*get_eeprom_len)(struct net_device *);
332 int (*get_eeprom)(struct net_device *, struct ethtool_eeprom *, u8 *);
333 int (*set_eeprom)(struct net_device *, struct ethtool_eeprom *, u8 *);
334 int (*get_coalesce)(struct net_device *, struct ethtool_coalesce *);
335 int (*set_coalesce)(struct net_device *, struct ethtool_coalesce *);
336 void (*get_ringparam)(struct net_device *, struct ethtool_ringparam *);
337 int (*set_ringparam)(struct net_device *, struct ethtool_ringparam *);
338 void (*get_pauseparam)(struct net_device *, struct ethtool_pauseparam*);
339 int (*set_pauseparam)(struct net_device *, struct ethtool_pauseparam*);
340 u32 (*get_rx_csum)(struct net_device *);
341 int (*set_rx_csum)(struct net_device *, u32);
342 u32 (*get_tx_csum)(struct net_device *);
343 int (*set_tx_csum)(struct net_device *, u32);
344 u32 (*get_sg)(struct net_device *);
345 int (*set_sg)(struct net_device *, u32);
346 u32 (*get_tso)(struct net_device *);
347 int (*set_tso)(struct net_device *, u32);
348 int (*self_test_count)(struct net_device *);
349 void (*self_test)(struct net_device *, struct ethtool_test *, u64 *);
350 void (*get_strings)(struct net_device *, u32 stringset, u8 *);
351 int (*phys_id)(struct net_device *, u32);
352 int (*get_stats_count)(struct net_device *);
353 void (*get_ethtool_stats)(struct net_device *, struct ethtool_stats *, u64 *);
354 int (*begin)(struct net_device *);
355 void (*complete)(struct net_device *);
356};
357
358/* CMDs currently supported */
359#define ETHTOOL_GSET 0x00000001 /* Get settings. */
360#define ETHTOOL_SSET 0x00000002 /* Set settings. */
361#define ETHTOOL_GDRVINFO 0x00000003 /* Get driver info. */
362#define ETHTOOL_GREGS 0x00000004 /* Get NIC registers. */
363#define ETHTOOL_GWOL 0x00000005 /* Get wake-on-lan options. */
364#define ETHTOOL_SWOL 0x00000006 /* Set wake-on-lan options. */
365#define ETHTOOL_GMSGLVL 0x00000007 /* Get driver message level */
366#define ETHTOOL_SMSGLVL 0x00000008 /* Set driver msg level. */
367#define ETHTOOL_NWAY_RST 0x00000009 /* Restart autonegotiation. */
368#define ETHTOOL_GLINK 0x0000000a /* Get link status (ethtool_value) */
369#define ETHTOOL_GEEPROM 0x0000000b /* Get EEPROM data */
370#define ETHTOOL_SEEPROM 0x0000000c /* Set EEPROM data. */
371#define ETHTOOL_GCOALESCE 0x0000000e /* Get coalesce config */
372#define ETHTOOL_SCOALESCE 0x0000000f /* Set coalesce config. */
373#define ETHTOOL_GRINGPARAM 0x00000010 /* Get ring parameters */
374#define ETHTOOL_SRINGPARAM 0x00000011 /* Set ring parameters. */
375#define ETHTOOL_GPAUSEPARAM 0x00000012 /* Get pause parameters */
376#define ETHTOOL_SPAUSEPARAM 0x00000013 /* Set pause parameters. */
377#define ETHTOOL_GRXCSUM 0x00000014 /* Get RX hw csum enable (ethtool_value) */
378#define ETHTOOL_SRXCSUM 0x00000015 /* Set RX hw csum enable (ethtool_value) */
379#define ETHTOOL_GTXCSUM 0x00000016 /* Get TX hw csum enable (ethtool_value) */
380#define ETHTOOL_STXCSUM 0x00000017 /* Set TX hw csum enable (ethtool_value) */
381#define ETHTOOL_GSG 0x00000018 /* Get scatter-gather enable
382 * (ethtool_value) */
383#define ETHTOOL_SSG 0x00000019 /* Set scatter-gather enable
384 * (ethtool_value). */
385#define ETHTOOL_TEST 0x0000001a /* execute NIC self-test. */
386#define ETHTOOL_GSTRINGS 0x0000001b /* get specified string set */
387#define ETHTOOL_PHYS_ID 0x0000001c /* identify the NIC */
388#define ETHTOOL_GSTATS 0x0000001d /* get NIC-specific statistics */
389#define ETHTOOL_GTSO 0x0000001e /* Get TSO enable (ethtool_value) */
390#define ETHTOOL_STSO 0x0000001f /* Set TSO enable (ethtool_value) */
391
392/* compatibility with older code */
393#define SPARC_ETH_GSET ETHTOOL_GSET
394#define SPARC_ETH_SSET ETHTOOL_SSET
395
396/* Indicates what features are supported by the interface. */
397#define SUPPORTED_10baseT_Half (1 << 0)
398#define SUPPORTED_10baseT_Full (1 << 1)
399#define SUPPORTED_100baseT_Half (1 << 2)
400#define SUPPORTED_100baseT_Full (1 << 3)
401#define SUPPORTED_1000baseT_Half (1 << 4)
402#define SUPPORTED_1000baseT_Full (1 << 5)
403#define SUPPORTED_Autoneg (1 << 6)
404#define SUPPORTED_TP (1 << 7)
405#define SUPPORTED_AUI (1 << 8)
406#define SUPPORTED_MII (1 << 9)
407#define SUPPORTED_FIBRE (1 << 10)
408#define SUPPORTED_BNC (1 << 11)
409#define SUPPORTED_10000baseT_Full (1 << 12)
410
411/* Indicates what features are advertised by the interface. */
412#define ADVERTISED_10baseT_Half (1 << 0)
413#define ADVERTISED_10baseT_Full (1 << 1)
414#define ADVERTISED_100baseT_Half (1 << 2)
415#define ADVERTISED_100baseT_Full (1 << 3)
416#define ADVERTISED_1000baseT_Half (1 << 4)
417#define ADVERTISED_1000baseT_Full (1 << 5)
418#define ADVERTISED_Autoneg (1 << 6)
419#define ADVERTISED_TP (1 << 7)
420#define ADVERTISED_AUI (1 << 8)
421#define ADVERTISED_MII (1 << 9)
422#define ADVERTISED_FIBRE (1 << 10)
423#define ADVERTISED_BNC (1 << 11)
424#define ADVERTISED_10000baseT_Full (1 << 12)
425
426/* The following are all involved in forcing a particular link
427 * mode for the device for setting things. When getting the
428 * devices settings, these indicate the current mode and whether
429 * it was foced up into this mode or autonegotiated.
430 */
431
432/* The forced speed, 10Mb, 100Mb, gigabit, 10GbE. */
433#define SPEED_10 10
434#define SPEED_100 100
435#define SPEED_1000 1000
436#define SPEED_10000 10000
437
438/* Duplex, half or full. */
439#define DUPLEX_HALF 0x00
440#define DUPLEX_FULL 0x01
441
442/* Which connector port. */
443#define PORT_TP 0x00
444#define PORT_AUI 0x01
445#define PORT_MII 0x02
446#define PORT_FIBRE 0x03
447#define PORT_BNC 0x04
448
449/* Which transceiver to use. */
450#define XCVR_INTERNAL 0x00
451#define XCVR_EXTERNAL 0x01
452#define XCVR_DUMMY1 0x02
453#define XCVR_DUMMY2 0x03
454#define XCVR_DUMMY3 0x04
455
456/* Enable or disable autonegotiation. If this is set to enable,
457 * the forced link modes above are completely ignored.
458 */
459#define AUTONEG_DISABLE 0x00
460#define AUTONEG_ENABLE 0x01
461
462/* Wake-On-Lan options. */
463#define WAKE_PHY (1 << 0)
464#define WAKE_UCAST (1 << 1)
465#define WAKE_MCAST (1 << 2)
466#define WAKE_BCAST (1 << 3)
467#define WAKE_ARP (1 << 4)
468#define WAKE_MAGIC (1 << 5)
469#define WAKE_MAGICSECURE (1 << 6) /* only meaningful if WAKE_MAGIC */
470
471#endif /* _LINUX_ETHTOOL_H */
diff --git a/include/linux/eventpoll.h b/include/linux/eventpoll.h
new file mode 100644
index 000000000000..1289f0ec4c00
--- /dev/null
+++ b/include/linux/eventpoll.h
@@ -0,0 +1,99 @@
1/*
2 * include/linux/eventpoll.h ( Efficent event polling implementation )
3 * Copyright (C) 2001,...,2003 Davide Libenzi
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * Davide Libenzi <davidel@xmailserver.org>
11 *
12 */
13
14#ifndef _LINUX_EVENTPOLL_H
15#define _LINUX_EVENTPOLL_H
16
17#include <linux/types.h>
18
19
20/* Valid opcodes to issue to sys_epoll_ctl() */
21#define EPOLL_CTL_ADD 1
22#define EPOLL_CTL_DEL 2
23#define EPOLL_CTL_MOD 3
24
25/* Set the One Shot behaviour for the target file descriptor */
26#define EPOLLONESHOT (1 << 30)
27
28/* Set the Edge Triggered behaviour for the target file descriptor */
29#define EPOLLET (1 << 31)
30
31/*
32 * On x86-64 make the 64bit structure have the same alignment as the
33 * 32bit structure. This makes 32bit emulation easier.
34 */
35#ifdef __x86_64__
36#define EPOLL_PACKED __attribute__((packed))
37#else
38#define EPOLL_PACKED
39#endif
40
41struct epoll_event {
42 __u32 events;
43 __u64 data;
44} EPOLL_PACKED;
45
46#ifdef __KERNEL__
47
48/* Forward declarations to avoid compiler errors */
49struct file;
50
51
52#ifdef CONFIG_EPOLL
53
54/* Used to initialize the epoll bits inside the "struct file" */
55void eventpoll_init_file(struct file *file);
56
57/* Used to release the epoll bits inside the "struct file" */
58void eventpoll_release_file(struct file *file);
59
60/*
61 * This is called from inside fs/file_table.c:__fput() to unlink files
62 * from the eventpoll interface. We need to have this facility to cleanup
63 * correctly files that are closed without being removed from the eventpoll
64 * interface.
65 */
66static inline void eventpoll_release(struct file *file)
67{
68
69 /*
70 * Fast check to avoid the get/release of the semaphore. Since
71 * we're doing this outside the semaphore lock, it might return
72 * false negatives, but we don't care. It'll help in 99.99% of cases
73 * to avoid the semaphore lock. False positives simply cannot happen
74 * because the file in on the way to be removed and nobody ( but
75 * eventpoll ) has still a reference to this file.
76 */
77 if (likely(list_empty(&file->f_ep_links)))
78 return;
79
80 /*
81 * The file is being closed while it is still linked to an epoll
82 * descriptor. We need to handle this by correctly unlinking it
83 * from its containers.
84 */
85 eventpoll_release_file(file);
86}
87
88
89#else
90
91static inline void eventpoll_init_file(struct file *file) {}
92static inline void eventpoll_release(struct file *file) {}
93
94#endif
95
96#endif /* #ifdef __KERNEL__ */
97
98#endif /* #ifndef _LINUX_EVENTPOLL_H */
99
diff --git a/include/linux/ext2_fs.h b/include/linux/ext2_fs.h
new file mode 100644
index 000000000000..fab43527e597
--- /dev/null
+++ b/include/linux/ext2_fs.h
@@ -0,0 +1,553 @@
1/*
2 * linux/include/linux/ext2_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_EXT2_FS_H
17#define _LINUX_EXT2_FS_H
18
19#include <linux/types.h>
20#include <linux/ext2_fs_sb.h>
21
22/*
23 * The second extended filesystem constants/structures
24 */
25
26/*
27 * Define EXT2FS_DEBUG to produce debug messages
28 */
29#undef EXT2FS_DEBUG
30
31/*
32 * Define EXT2_PREALLOCATE to preallocate data blocks for expanding files
33 */
34#define EXT2_PREALLOCATE
35#define EXT2_DEFAULT_PREALLOC_BLOCKS 8
36
37/*
38 * The second extended file system version
39 */
40#define EXT2FS_DATE "95/08/09"
41#define EXT2FS_VERSION "0.5b"
42
43/*
44 * Debug code
45 */
46#ifdef EXT2FS_DEBUG
47# define ext2_debug(f, a...) { \
48 printk ("EXT2-fs DEBUG (%s, %d): %s:", \
49 __FILE__, __LINE__, __FUNCTION__); \
50 printk (f, ## a); \
51 }
52#else
53# define ext2_debug(f, a...) /**/
54#endif
55
56/*
57 * Special inode numbers
58 */
59#define EXT2_BAD_INO 1 /* Bad blocks inode */
60#define EXT2_ROOT_INO 2 /* Root inode */
61#define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */
62#define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */
63
64/* First non-reserved inode for old ext2 filesystems */
65#define EXT2_GOOD_OLD_FIRST_INO 11
66
67/*
68 * The second extended file system magic number
69 */
70#define EXT2_SUPER_MAGIC 0xEF53
71
72#ifdef __KERNEL__
73static inline struct ext2_sb_info *EXT2_SB(struct super_block *sb)
74{
75 return sb->s_fs_info;
76}
77#else
78/* Assume that user mode programs are passing in an ext2fs superblock, not
79 * a kernel struct super_block. This will allow us to call the feature-test
80 * macros from user land. */
81#define EXT2_SB(sb) (sb)
82#endif
83
84/*
85 * Maximal count of links to a file
86 */
87#define EXT2_LINK_MAX 32000
88
89/*
90 * Macro-instructions used to manage several block sizes
91 */
92#define EXT2_MIN_BLOCK_SIZE 1024
93#define EXT2_MAX_BLOCK_SIZE 4096
94#define EXT2_MIN_BLOCK_LOG_SIZE 10
95#ifdef __KERNEL__
96# define EXT2_BLOCK_SIZE(s) ((s)->s_blocksize)
97#else
98# define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
99#endif
100#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (__u32))
101#ifdef __KERNEL__
102# define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
103#else
104# define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
105#endif
106#ifdef __KERNEL__
107#define EXT2_ADDR_PER_BLOCK_BITS(s) (EXT2_SB(s)->s_addr_per_block_bits)
108#define EXT2_INODE_SIZE(s) (EXT2_SB(s)->s_inode_size)
109#define EXT2_FIRST_INO(s) (EXT2_SB(s)->s_first_ino)
110#else
111#define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
112 EXT2_GOOD_OLD_INODE_SIZE : \
113 (s)->s_inode_size)
114#define EXT2_FIRST_INO(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
115 EXT2_GOOD_OLD_FIRST_INO : \
116 (s)->s_first_ino)
117#endif
118
119/*
120 * Macro-instructions used to manage fragments
121 */
122#define EXT2_MIN_FRAG_SIZE 1024
123#define EXT2_MAX_FRAG_SIZE 4096
124#define EXT2_MIN_FRAG_LOG_SIZE 10
125#ifdef __KERNEL__
126# define EXT2_FRAG_SIZE(s) (EXT2_SB(s)->s_frag_size)
127# define EXT2_FRAGS_PER_BLOCK(s) (EXT2_SB(s)->s_frags_per_block)
128#else
129# define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size)
130# define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
131#endif
132
133/*
134 * Structure of a blocks group descriptor
135 */
136struct ext2_group_desc
137{
138 __le32 bg_block_bitmap; /* Blocks bitmap block */
139 __le32 bg_inode_bitmap; /* Inodes bitmap block */
140 __le32 bg_inode_table; /* Inodes table block */
141 __le16 bg_free_blocks_count; /* Free blocks count */
142 __le16 bg_free_inodes_count; /* Free inodes count */
143 __le16 bg_used_dirs_count; /* Directories count */
144 __le16 bg_pad;
145 __le32 bg_reserved[3];
146};
147
148/*
149 * Macro-instructions used to manage group descriptors
150 */
151#ifdef __KERNEL__
152# define EXT2_BLOCKS_PER_GROUP(s) (EXT2_SB(s)->s_blocks_per_group)
153# define EXT2_DESC_PER_BLOCK(s) (EXT2_SB(s)->s_desc_per_block)
154# define EXT2_INODES_PER_GROUP(s) (EXT2_SB(s)->s_inodes_per_group)
155# define EXT2_DESC_PER_BLOCK_BITS(s) (EXT2_SB(s)->s_desc_per_block_bits)
156#else
157# define EXT2_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group)
158# define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc))
159# define EXT2_INODES_PER_GROUP(s) ((s)->s_inodes_per_group)
160#endif
161
162/*
163 * Constants relative to the data blocks
164 */
165#define EXT2_NDIR_BLOCKS 12
166#define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS
167#define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1)
168#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1)
169#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1)
170
171/*
172 * Inode flags
173 */
174#define EXT2_SECRM_FL 0x00000001 /* Secure deletion */
175#define EXT2_UNRM_FL 0x00000002 /* Undelete */
176#define EXT2_COMPR_FL 0x00000004 /* Compress file */
177#define EXT2_SYNC_FL 0x00000008 /* Synchronous updates */
178#define EXT2_IMMUTABLE_FL 0x00000010 /* Immutable file */
179#define EXT2_APPEND_FL 0x00000020 /* writes to file may only append */
180#define EXT2_NODUMP_FL 0x00000040 /* do not dump file */
181#define EXT2_NOATIME_FL 0x00000080 /* do not update atime */
182/* Reserved for compression usage... */
183#define EXT2_DIRTY_FL 0x00000100
184#define EXT2_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */
185#define EXT2_NOCOMP_FL 0x00000400 /* Don't compress */
186#define EXT2_ECOMPR_FL 0x00000800 /* Compression error */
187/* End compression flags --- maybe not all used */
188#define EXT2_BTREE_FL 0x00001000 /* btree format dir */
189#define EXT2_INDEX_FL 0x00001000 /* hash-indexed directory */
190#define EXT2_IMAGIC_FL 0x00002000 /* AFS directory */
191#define EXT2_JOURNAL_DATA_FL 0x00004000 /* Reserved for ext3 */
192#define EXT2_NOTAIL_FL 0x00008000 /* file tail should not be merged */
193#define EXT2_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
194#define EXT2_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
195#define EXT2_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
196
197#define EXT2_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
198#define EXT2_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
199
200/*
201 * ioctl commands
202 */
203#define EXT2_IOC_GETFLAGS _IOR('f', 1, long)
204#define EXT2_IOC_SETFLAGS _IOW('f', 2, long)
205#define EXT2_IOC_GETVERSION _IOR('v', 1, long)
206#define EXT2_IOC_SETVERSION _IOW('v', 2, long)
207
208/*
209 * Structure of an inode on the disk
210 */
211struct ext2_inode {
212 __le16 i_mode; /* File mode */
213 __le16 i_uid; /* Low 16 bits of Owner Uid */
214 __le32 i_size; /* Size in bytes */
215 __le32 i_atime; /* Access time */
216 __le32 i_ctime; /* Creation time */
217 __le32 i_mtime; /* Modification time */
218 __le32 i_dtime; /* Deletion Time */
219 __le16 i_gid; /* Low 16 bits of Group Id */
220 __le16 i_links_count; /* Links count */
221 __le32 i_blocks; /* Blocks count */
222 __le32 i_flags; /* File flags */
223 union {
224 struct {
225 __le32 l_i_reserved1;
226 } linux1;
227 struct {
228 __le32 h_i_translator;
229 } hurd1;
230 struct {
231 __le32 m_i_reserved1;
232 } masix1;
233 } osd1; /* OS dependent 1 */
234 __le32 i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
235 __le32 i_generation; /* File version (for NFS) */
236 __le32 i_file_acl; /* File ACL */
237 __le32 i_dir_acl; /* Directory ACL */
238 __le32 i_faddr; /* Fragment address */
239 union {
240 struct {
241 __u8 l_i_frag; /* Fragment number */
242 __u8 l_i_fsize; /* Fragment size */
243 __u16 i_pad1;
244 __le16 l_i_uid_high; /* these 2 fields */
245 __le16 l_i_gid_high; /* were reserved2[0] */
246 __u32 l_i_reserved2;
247 } linux2;
248 struct {
249 __u8 h_i_frag; /* Fragment number */
250 __u8 h_i_fsize; /* Fragment size */
251 __le16 h_i_mode_high;
252 __le16 h_i_uid_high;
253 __le16 h_i_gid_high;
254 __le32 h_i_author;
255 } hurd2;
256 struct {
257 __u8 m_i_frag; /* Fragment number */
258 __u8 m_i_fsize; /* Fragment size */
259 __u16 m_pad1;
260 __u32 m_i_reserved2[2];
261 } masix2;
262 } osd2; /* OS dependent 2 */
263};
264
265#define i_size_high i_dir_acl
266
267#if defined(__KERNEL__) || defined(__linux__)
268#define i_reserved1 osd1.linux1.l_i_reserved1
269#define i_frag osd2.linux2.l_i_frag
270#define i_fsize osd2.linux2.l_i_fsize
271#define i_uid_low i_uid
272#define i_gid_low i_gid
273#define i_uid_high osd2.linux2.l_i_uid_high
274#define i_gid_high osd2.linux2.l_i_gid_high
275#define i_reserved2 osd2.linux2.l_i_reserved2
276#endif
277
278#ifdef __hurd__
279#define i_translator osd1.hurd1.h_i_translator
280#define i_frag osd2.hurd2.h_i_frag;
281#define i_fsize osd2.hurd2.h_i_fsize;
282#define i_uid_high osd2.hurd2.h_i_uid_high
283#define i_gid_high osd2.hurd2.h_i_gid_high
284#define i_author osd2.hurd2.h_i_author
285#endif
286
287#ifdef __masix__
288#define i_reserved1 osd1.masix1.m_i_reserved1
289#define i_frag osd2.masix2.m_i_frag
290#define i_fsize osd2.masix2.m_i_fsize
291#define i_reserved2 osd2.masix2.m_i_reserved2
292#endif
293
294/*
295 * File system states
296 */
297#define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */
298#define EXT2_ERROR_FS 0x0002 /* Errors detected */
299
300/*
301 * Mount flags
302 */
303#define EXT2_MOUNT_CHECK 0x0001 /* Do mount-time checks */
304#define EXT2_MOUNT_OLDALLOC 0x0002 /* Don't use the new Orlov allocator */
305#define EXT2_MOUNT_GRPID 0x0004 /* Create files with directory's group */
306#define EXT2_MOUNT_DEBUG 0x0008 /* Some debugging messages */
307#define EXT2_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */
308#define EXT2_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */
309#define EXT2_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */
310#define EXT2_MOUNT_MINIX_DF 0x0080 /* Mimics the Minix statfs */
311#define EXT2_MOUNT_NOBH 0x0100 /* No buffer_heads */
312#define EXT2_MOUNT_NO_UID32 0x0200 /* Disable 32-bit UIDs */
313#define EXT2_MOUNT_XATTR_USER 0x4000 /* Extended user attributes */
314#define EXT2_MOUNT_POSIX_ACL 0x8000 /* POSIX Access Control Lists */
315
316#define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
317#define set_opt(o, opt) o |= EXT2_MOUNT_##opt
318#define test_opt(sb, opt) (EXT2_SB(sb)->s_mount_opt & \
319 EXT2_MOUNT_##opt)
320/*
321 * Maximal mount counts between two filesystem checks
322 */
323#define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */
324#define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */
325
326/*
327 * Behaviour when detecting errors
328 */
329#define EXT2_ERRORS_CONTINUE 1 /* Continue execution */
330#define EXT2_ERRORS_RO 2 /* Remount fs read-only */
331#define EXT2_ERRORS_PANIC 3 /* Panic */
332#define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE
333
334/*
335 * Structure of the super block
336 */
337struct ext2_super_block {
338 __le32 s_inodes_count; /* Inodes count */
339 __le32 s_blocks_count; /* Blocks count */
340 __le32 s_r_blocks_count; /* Reserved blocks count */
341 __le32 s_free_blocks_count; /* Free blocks count */
342 __le32 s_free_inodes_count; /* Free inodes count */
343 __le32 s_first_data_block; /* First Data Block */
344 __le32 s_log_block_size; /* Block size */
345 __le32 s_log_frag_size; /* Fragment size */
346 __le32 s_blocks_per_group; /* # Blocks per group */
347 __le32 s_frags_per_group; /* # Fragments per group */
348 __le32 s_inodes_per_group; /* # Inodes per group */
349 __le32 s_mtime; /* Mount time */
350 __le32 s_wtime; /* Write time */
351 __le16 s_mnt_count; /* Mount count */
352 __le16 s_max_mnt_count; /* Maximal mount count */
353 __le16 s_magic; /* Magic signature */
354 __le16 s_state; /* File system state */
355 __le16 s_errors; /* Behaviour when detecting errors */
356 __le16 s_minor_rev_level; /* minor revision level */
357 __le32 s_lastcheck; /* time of last check */
358 __le32 s_checkinterval; /* max. time between checks */
359 __le32 s_creator_os; /* OS */
360 __le32 s_rev_level; /* Revision level */
361 __le16 s_def_resuid; /* Default uid for reserved blocks */
362 __le16 s_def_resgid; /* Default gid for reserved blocks */
363 /*
364 * These fields are for EXT2_DYNAMIC_REV superblocks only.
365 *
366 * Note: the difference between the compatible feature set and
367 * the incompatible feature set is that if there is a bit set
368 * in the incompatible feature set that the kernel doesn't
369 * know about, it should refuse to mount the filesystem.
370 *
371 * e2fsck's requirements are more strict; if it doesn't know
372 * about a feature in either the compatible or incompatible
373 * feature set, it must abort and not try to meddle with
374 * things it doesn't understand...
375 */
376 __le32 s_first_ino; /* First non-reserved inode */
377 __le16 s_inode_size; /* size of inode structure */
378 __le16 s_block_group_nr; /* block group # of this superblock */
379 __le32 s_feature_compat; /* compatible feature set */
380 __le32 s_feature_incompat; /* incompatible feature set */
381 __le32 s_feature_ro_compat; /* readonly-compatible feature set */
382 __u8 s_uuid[16]; /* 128-bit uuid for volume */
383 char s_volume_name[16]; /* volume name */
384 char s_last_mounted[64]; /* directory where last mounted */
385 __le32 s_algorithm_usage_bitmap; /* For compression */
386 /*
387 * Performance hints. Directory preallocation should only
388 * happen if the EXT2_COMPAT_PREALLOC flag is on.
389 */
390 __u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
391 __u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
392 __u16 s_padding1;
393 /*
394 * Journaling support valid if EXT3_FEATURE_COMPAT_HAS_JOURNAL set.
395 */
396 __u8 s_journal_uuid[16]; /* uuid of journal superblock */
397 __u32 s_journal_inum; /* inode number of journal file */
398 __u32 s_journal_dev; /* device number of journal file */
399 __u32 s_last_orphan; /* start of list of inodes to delete */
400 __u32 s_hash_seed[4]; /* HTREE hash seed */
401 __u8 s_def_hash_version; /* Default hash version to use */
402 __u8 s_reserved_char_pad;
403 __u16 s_reserved_word_pad;
404 __le32 s_default_mount_opts;
405 __le32 s_first_meta_bg; /* First metablock block group */
406 __u32 s_reserved[190]; /* Padding to the end of the block */
407};
408
409/*
410 * Codes for operating systems
411 */
412#define EXT2_OS_LINUX 0
413#define EXT2_OS_HURD 1
414#define EXT2_OS_MASIX 2
415#define EXT2_OS_FREEBSD 3
416#define EXT2_OS_LITES 4
417
418/*
419 * Revision levels
420 */
421#define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */
422#define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */
423
424#define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV
425#define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV
426
427#define EXT2_GOOD_OLD_INODE_SIZE 128
428
429/*
430 * Feature set definitions
431 */
432
433#define EXT2_HAS_COMPAT_FEATURE(sb,mask) \
434 ( EXT2_SB(sb)->s_es->s_feature_compat & cpu_to_le32(mask) )
435#define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask) \
436 ( EXT2_SB(sb)->s_es->s_feature_ro_compat & cpu_to_le32(mask) )
437#define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \
438 ( EXT2_SB(sb)->s_es->s_feature_incompat & cpu_to_le32(mask) )
439#define EXT2_SET_COMPAT_FEATURE(sb,mask) \
440 EXT2_SB(sb)->s_es->s_feature_compat |= cpu_to_le32(mask)
441#define EXT2_SET_RO_COMPAT_FEATURE(sb,mask) \
442 EXT2_SB(sb)->s_es->s_feature_ro_compat |= cpu_to_le32(mask)
443#define EXT2_SET_INCOMPAT_FEATURE(sb,mask) \
444 EXT2_SB(sb)->s_es->s_feature_incompat |= cpu_to_le32(mask)
445#define EXT2_CLEAR_COMPAT_FEATURE(sb,mask) \
446 EXT2_SB(sb)->s_es->s_feature_compat &= ~cpu_to_le32(mask)
447#define EXT2_CLEAR_RO_COMPAT_FEATURE(sb,mask) \
448 EXT2_SB(sb)->s_es->s_feature_ro_compat &= ~cpu_to_le32(mask)
449#define EXT2_CLEAR_INCOMPAT_FEATURE(sb,mask) \
450 EXT2_SB(sb)->s_es->s_feature_incompat &= ~cpu_to_le32(mask)
451
452#define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001
453#define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002
454#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
455#define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008
456#define EXT2_FEATURE_COMPAT_RESIZE_INO 0x0010
457#define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020
458#define EXT2_FEATURE_COMPAT_ANY 0xffffffff
459
460#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
461#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
462#define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004
463#define EXT2_FEATURE_RO_COMPAT_ANY 0xffffffff
464
465#define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001
466#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
467#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004
468#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008
469#define EXT2_FEATURE_INCOMPAT_META_BG 0x0010
470#define EXT2_FEATURE_INCOMPAT_ANY 0xffffffff
471
472#define EXT2_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR
473#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \
474 EXT2_FEATURE_INCOMPAT_META_BG)
475#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
476 EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
477 EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
478#define EXT2_FEATURE_RO_COMPAT_UNSUPPORTED ~EXT2_FEATURE_RO_COMPAT_SUPP
479#define EXT2_FEATURE_INCOMPAT_UNSUPPORTED ~EXT2_FEATURE_INCOMPAT_SUPP
480
481/*
482 * Default values for user and/or group using reserved blocks
483 */
484#define EXT2_DEF_RESUID 0
485#define EXT2_DEF_RESGID 0
486
487/*
488 * Default mount options
489 */
490#define EXT2_DEFM_DEBUG 0x0001
491#define EXT2_DEFM_BSDGROUPS 0x0002
492#define EXT2_DEFM_XATTR_USER 0x0004
493#define EXT2_DEFM_ACL 0x0008
494#define EXT2_DEFM_UID16 0x0010
495 /* Not used by ext2, but reserved for use by ext3 */
496#define EXT3_DEFM_JMODE 0x0060
497#define EXT3_DEFM_JMODE_DATA 0x0020
498#define EXT3_DEFM_JMODE_ORDERED 0x0040
499#define EXT3_DEFM_JMODE_WBACK 0x0060
500
501/*
502 * Structure of a directory entry
503 */
504#define EXT2_NAME_LEN 255
505
506struct ext2_dir_entry {
507 __le32 inode; /* Inode number */
508 __le16 rec_len; /* Directory entry length */
509 __le16 name_len; /* Name length */
510 char name[EXT2_NAME_LEN]; /* File name */
511};
512
513/*
514 * The new version of the directory entry. Since EXT2 structures are
515 * stored in intel byte order, and the name_len field could never be
516 * bigger than 255 chars, it's safe to reclaim the extra byte for the
517 * file_type field.
518 */
519struct ext2_dir_entry_2 {
520 __le32 inode; /* Inode number */
521 __le16 rec_len; /* Directory entry length */
522 __u8 name_len; /* Name length */
523 __u8 file_type;
524 char name[EXT2_NAME_LEN]; /* File name */
525};
526
527/*
528 * Ext2 directory file types. Only the low 3 bits are used. The
529 * other bits are reserved for now.
530 */
531enum {
532 EXT2_FT_UNKNOWN,
533 EXT2_FT_REG_FILE,
534 EXT2_FT_DIR,
535 EXT2_FT_CHRDEV,
536 EXT2_FT_BLKDEV,
537 EXT2_FT_FIFO,
538 EXT2_FT_SOCK,
539 EXT2_FT_SYMLINK,
540 EXT2_FT_MAX
541};
542
543/*
544 * EXT2_DIR_PAD defines the directory entries boundaries
545 *
546 * NOTE: It must be a multiple of 4
547 */
548#define EXT2_DIR_PAD 4
549#define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1)
550#define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \
551 ~EXT2_DIR_ROUND)
552
553#endif /* _LINUX_EXT2_FS_H */
diff --git a/include/linux/ext2_fs_sb.h b/include/linux/ext2_fs_sb.h
new file mode 100644
index 000000000000..4eda0ed76a48
--- /dev/null
+++ b/include/linux/ext2_fs_sb.h
@@ -0,0 +1,58 @@
1/*
2 * linux/include/linux/ext2_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_EXT2_FS_SB
17#define _LINUX_EXT2_FS_SB
18
19#include <linux/blockgroup_lock.h>
20#include <linux/percpu_counter.h>
21
22/*
23 * second extended-fs super-block data in memory
24 */
25struct ext2_sb_info {
26 unsigned long s_frag_size; /* Size of a fragment in bytes */
27 unsigned long s_frags_per_block;/* Number of fragments per block */
28 unsigned long s_inodes_per_block;/* Number of inodes per block */
29 unsigned long s_frags_per_group;/* Number of fragments in a group */
30 unsigned long s_blocks_per_group;/* Number of blocks in a group */
31 unsigned long s_inodes_per_group;/* Number of inodes in a group */
32 unsigned long s_itb_per_group; /* Number of inode table blocks per group */
33 unsigned long s_gdb_count; /* Number of group descriptor blocks */
34 unsigned long s_desc_per_block; /* Number of group descriptors per block */
35 unsigned long s_groups_count; /* Number of groups in the fs */
36 struct buffer_head * s_sbh; /* Buffer containing the super block */
37 struct ext2_super_block * s_es; /* Pointer to the super block in the buffer */
38 struct buffer_head ** s_group_desc;
39 unsigned long s_mount_opt;
40 uid_t s_resuid;
41 gid_t s_resgid;
42 unsigned short s_mount_state;
43 unsigned short s_pad;
44 int s_addr_per_block_bits;
45 int s_desc_per_block_bits;
46 int s_inode_size;
47 int s_first_ino;
48 spinlock_t s_next_gen_lock;
49 u32 s_next_generation;
50 unsigned long s_dir_count;
51 u8 *s_debts;
52 struct percpu_counter s_freeblocks_counter;
53 struct percpu_counter s_freeinodes_counter;
54 struct percpu_counter s_dirs_counter;
55 struct blockgroup_lock s_blockgroup_lock;
56};
57
58#endif /* _LINUX_EXT2_FS_SB */
diff --git a/include/linux/ext3_fs.h b/include/linux/ext3_fs.h
new file mode 100644
index 000000000000..74ad31781e3e
--- /dev/null
+++ b/include/linux/ext3_fs.h
@@ -0,0 +1,830 @@
1/*
2 * linux/include/linux/ext3_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_EXT3_FS_H
17#define _LINUX_EXT3_FS_H
18
19#include <linux/types.h>
20#include <linux/ext3_fs_i.h>
21#include <linux/ext3_fs_sb.h>
22
23
24struct statfs;
25
26/*
27 * The second extended filesystem constants/structures
28 */
29
30/*
31 * Define EXT3FS_DEBUG to produce debug messages
32 */
33#undef EXT3FS_DEBUG
34
35/*
36 * Define EXT3_RESERVATION to reserve data blocks for expanding files
37 */
38#define EXT3_DEFAULT_RESERVE_BLOCKS 8
39#define EXT3_MAX_RESERVE_BLOCKS 1024
40#define EXT3_RESERVE_WINDOW_NOT_ALLOCATED 0
41/*
42 * Always enable hashed directories
43 */
44#define CONFIG_EXT3_INDEX
45
46/*
47 * Debug code
48 */
49#ifdef EXT3FS_DEBUG
50#define ext3_debug(f, a...) \
51 do { \
52 printk (KERN_DEBUG "EXT3-fs DEBUG (%s, %d): %s:", \
53 __FILE__, __LINE__, __FUNCTION__); \
54 printk (KERN_DEBUG f, ## a); \
55 } while (0)
56#else
57#define ext3_debug(f, a...) do {} while (0)
58#endif
59
60/*
61 * Special inodes numbers
62 */
63#define EXT3_BAD_INO 1 /* Bad blocks inode */
64#define EXT3_ROOT_INO 2 /* Root inode */
65#define EXT3_BOOT_LOADER_INO 5 /* Boot loader inode */
66#define EXT3_UNDEL_DIR_INO 6 /* Undelete directory inode */
67#define EXT3_RESIZE_INO 7 /* Reserved group descriptors inode */
68#define EXT3_JOURNAL_INO 8 /* Journal inode */
69
70/* First non-reserved inode for old ext3 filesystems */
71#define EXT3_GOOD_OLD_FIRST_INO 11
72
73/*
74 * The second extended file system magic number
75 */
76#define EXT3_SUPER_MAGIC 0xEF53
77
78/*
79 * Maximal count of links to a file
80 */
81#define EXT3_LINK_MAX 32000
82
83/*
84 * Macro-instructions used to manage several block sizes
85 */
86#define EXT3_MIN_BLOCK_SIZE 1024
87#define EXT3_MAX_BLOCK_SIZE 4096
88#define EXT3_MIN_BLOCK_LOG_SIZE 10
89#ifdef __KERNEL__
90# define EXT3_BLOCK_SIZE(s) ((s)->s_blocksize)
91#else
92# define EXT3_BLOCK_SIZE(s) (EXT3_MIN_BLOCK_SIZE << (s)->s_log_block_size)
93#endif
94#define EXT3_ADDR_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (__u32))
95#ifdef __KERNEL__
96# define EXT3_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
97#else
98# define EXT3_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
99#endif
100#ifdef __KERNEL__
101#define EXT3_ADDR_PER_BLOCK_BITS(s) (EXT3_SB(s)->s_addr_per_block_bits)
102#define EXT3_INODE_SIZE(s) (EXT3_SB(s)->s_inode_size)
103#define EXT3_FIRST_INO(s) (EXT3_SB(s)->s_first_ino)
104#else
105#define EXT3_INODE_SIZE(s) (((s)->s_rev_level == EXT3_GOOD_OLD_REV) ? \
106 EXT3_GOOD_OLD_INODE_SIZE : \
107 (s)->s_inode_size)
108#define EXT3_FIRST_INO(s) (((s)->s_rev_level == EXT3_GOOD_OLD_REV) ? \
109 EXT3_GOOD_OLD_FIRST_INO : \
110 (s)->s_first_ino)
111#endif
112
113/*
114 * Macro-instructions used to manage fragments
115 */
116#define EXT3_MIN_FRAG_SIZE 1024
117#define EXT3_MAX_FRAG_SIZE 4096
118#define EXT3_MIN_FRAG_LOG_SIZE 10
119#ifdef __KERNEL__
120# define EXT3_FRAG_SIZE(s) (EXT3_SB(s)->s_frag_size)
121# define EXT3_FRAGS_PER_BLOCK(s) (EXT3_SB(s)->s_frags_per_block)
122#else
123# define EXT3_FRAG_SIZE(s) (EXT3_MIN_FRAG_SIZE << (s)->s_log_frag_size)
124# define EXT3_FRAGS_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / EXT3_FRAG_SIZE(s))
125#endif
126
127/*
128 * Structure of a blocks group descriptor
129 */
130struct ext3_group_desc
131{
132 __le32 bg_block_bitmap; /* Blocks bitmap block */
133 __le32 bg_inode_bitmap; /* Inodes bitmap block */
134 __le32 bg_inode_table; /* Inodes table block */
135 __le16 bg_free_blocks_count; /* Free blocks count */
136 __le16 bg_free_inodes_count; /* Free inodes count */
137 __le16 bg_used_dirs_count; /* Directories count */
138 __u16 bg_pad;
139 __le32 bg_reserved[3];
140};
141
142/*
143 * Macro-instructions used to manage group descriptors
144 */
145#ifdef __KERNEL__
146# define EXT3_BLOCKS_PER_GROUP(s) (EXT3_SB(s)->s_blocks_per_group)
147# define EXT3_DESC_PER_BLOCK(s) (EXT3_SB(s)->s_desc_per_block)
148# define EXT3_INODES_PER_GROUP(s) (EXT3_SB(s)->s_inodes_per_group)
149# define EXT3_DESC_PER_BLOCK_BITS(s) (EXT3_SB(s)->s_desc_per_block_bits)
150#else
151# define EXT3_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group)
152# define EXT3_DESC_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (struct ext3_group_desc))
153# define EXT3_INODES_PER_GROUP(s) ((s)->s_inodes_per_group)
154#endif
155
156/*
157 * Constants relative to the data blocks
158 */
159#define EXT3_NDIR_BLOCKS 12
160#define EXT3_IND_BLOCK EXT3_NDIR_BLOCKS
161#define EXT3_DIND_BLOCK (EXT3_IND_BLOCK + 1)
162#define EXT3_TIND_BLOCK (EXT3_DIND_BLOCK + 1)
163#define EXT3_N_BLOCKS (EXT3_TIND_BLOCK + 1)
164
165/*
166 * Inode flags
167 */
168#define EXT3_SECRM_FL 0x00000001 /* Secure deletion */
169#define EXT3_UNRM_FL 0x00000002 /* Undelete */
170#define EXT3_COMPR_FL 0x00000004 /* Compress file */
171#define EXT3_SYNC_FL 0x00000008 /* Synchronous updates */
172#define EXT3_IMMUTABLE_FL 0x00000010 /* Immutable file */
173#define EXT3_APPEND_FL 0x00000020 /* writes to file may only append */
174#define EXT3_NODUMP_FL 0x00000040 /* do not dump file */
175#define EXT3_NOATIME_FL 0x00000080 /* do not update atime */
176/* Reserved for compression usage... */
177#define EXT3_DIRTY_FL 0x00000100
178#define EXT3_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */
179#define EXT3_NOCOMPR_FL 0x00000400 /* Don't compress */
180#define EXT3_ECOMPR_FL 0x00000800 /* Compression error */
181/* End compression flags --- maybe not all used */
182#define EXT3_INDEX_FL 0x00001000 /* hash-indexed directory */
183#define EXT3_IMAGIC_FL 0x00002000 /* AFS directory */
184#define EXT3_JOURNAL_DATA_FL 0x00004000 /* file data should be journaled */
185#define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
186#define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
187#define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
188#define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
189
190#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
191#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
192
193/*
194 * Inode dynamic state flags
195 */
196#define EXT3_STATE_JDATA 0x00000001 /* journaled data exists */
197#define EXT3_STATE_NEW 0x00000002 /* inode is newly created */
198#define EXT3_STATE_XATTR 0x00000004 /* has in-inode xattrs */
199
200/* Used to pass group descriptor data when online resize is done */
201struct ext3_new_group_input {
202 __u32 group; /* Group number for this data */
203 __u32 block_bitmap; /* Absolute block number of block bitmap */
204 __u32 inode_bitmap; /* Absolute block number of inode bitmap */
205 __u32 inode_table; /* Absolute block number of inode table start */
206 __u32 blocks_count; /* Total number of blocks in this group */
207 __u16 reserved_blocks; /* Number of reserved blocks in this group */
208 __u16 unused;
209};
210
211/* The struct ext3_new_group_input in kernel space, with free_blocks_count */
212struct ext3_new_group_data {
213 __u32 group;
214 __u32 block_bitmap;
215 __u32 inode_bitmap;
216 __u32 inode_table;
217 __u32 blocks_count;
218 __u16 reserved_blocks;
219 __u16 unused;
220 __u32 free_blocks_count;
221};
222
223
224/*
225 * ioctl commands
226 */
227#define EXT3_IOC_GETFLAGS _IOR('f', 1, long)
228#define EXT3_IOC_SETFLAGS _IOW('f', 2, long)
229#define EXT3_IOC_GETVERSION _IOR('f', 3, long)
230#define EXT3_IOC_SETVERSION _IOW('f', 4, long)
231#define EXT3_IOC_GROUP_EXTEND _IOW('f', 7, unsigned long)
232#define EXT3_IOC_GROUP_ADD _IOW('f', 8,struct ext3_new_group_input)
233#define EXT3_IOC_GETVERSION_OLD _IOR('v', 1, long)
234#define EXT3_IOC_SETVERSION_OLD _IOW('v', 2, long)
235#ifdef CONFIG_JBD_DEBUG
236#define EXT3_IOC_WAIT_FOR_READONLY _IOR('f', 99, long)
237#endif
238#define EXT3_IOC_GETRSVSZ _IOR('f', 5, long)
239#define EXT3_IOC_SETRSVSZ _IOW('f', 6, long)
240
241/*
242 * Structure of an inode on the disk
243 */
244struct ext3_inode {
245 __le16 i_mode; /* File mode */
246 __le16 i_uid; /* Low 16 bits of Owner Uid */
247 __le32 i_size; /* Size in bytes */
248 __le32 i_atime; /* Access time */
249 __le32 i_ctime; /* Creation time */
250 __le32 i_mtime; /* Modification time */
251 __le32 i_dtime; /* Deletion Time */
252 __le16 i_gid; /* Low 16 bits of Group Id */
253 __le16 i_links_count; /* Links count */
254 __le32 i_blocks; /* Blocks count */
255 __le32 i_flags; /* File flags */
256 union {
257 struct {
258 __u32 l_i_reserved1;
259 } linux1;
260 struct {
261 __u32 h_i_translator;
262 } hurd1;
263 struct {
264 __u32 m_i_reserved1;
265 } masix1;
266 } osd1; /* OS dependent 1 */
267 __le32 i_block[EXT3_N_BLOCKS];/* Pointers to blocks */
268 __le32 i_generation; /* File version (for NFS) */
269 __le32 i_file_acl; /* File ACL */
270 __le32 i_dir_acl; /* Directory ACL */
271 __le32 i_faddr; /* Fragment address */
272 union {
273 struct {
274 __u8 l_i_frag; /* Fragment number */
275 __u8 l_i_fsize; /* Fragment size */
276 __u16 i_pad1;
277 __le16 l_i_uid_high; /* these 2 fields */
278 __le16 l_i_gid_high; /* were reserved2[0] */
279 __u32 l_i_reserved2;
280 } linux2;
281 struct {
282 __u8 h_i_frag; /* Fragment number */
283 __u8 h_i_fsize; /* Fragment size */
284 __u16 h_i_mode_high;
285 __u16 h_i_uid_high;
286 __u16 h_i_gid_high;
287 __u32 h_i_author;
288 } hurd2;
289 struct {
290 __u8 m_i_frag; /* Fragment number */
291 __u8 m_i_fsize; /* Fragment size */
292 __u16 m_pad1;
293 __u32 m_i_reserved2[2];
294 } masix2;
295 } osd2; /* OS dependent 2 */
296 __le16 i_extra_isize;
297 __le16 i_pad1;
298};
299
300#define i_size_high i_dir_acl
301
302#if defined(__KERNEL__) || defined(__linux__)
303#define i_reserved1 osd1.linux1.l_i_reserved1
304#define i_frag osd2.linux2.l_i_frag
305#define i_fsize osd2.linux2.l_i_fsize
306#define i_uid_low i_uid
307#define i_gid_low i_gid
308#define i_uid_high osd2.linux2.l_i_uid_high
309#define i_gid_high osd2.linux2.l_i_gid_high
310#define i_reserved2 osd2.linux2.l_i_reserved2
311
312#elif defined(__GNU__)
313
314#define i_translator osd1.hurd1.h_i_translator
315#define i_frag osd2.hurd2.h_i_frag;
316#define i_fsize osd2.hurd2.h_i_fsize;
317#define i_uid_high osd2.hurd2.h_i_uid_high
318#define i_gid_high osd2.hurd2.h_i_gid_high
319#define i_author osd2.hurd2.h_i_author
320
321#elif defined(__masix__)
322
323#define i_reserved1 osd1.masix1.m_i_reserved1
324#define i_frag osd2.masix2.m_i_frag
325#define i_fsize osd2.masix2.m_i_fsize
326#define i_reserved2 osd2.masix2.m_i_reserved2
327
328#endif /* defined(__KERNEL__) || defined(__linux__) */
329
330/*
331 * File system states
332 */
333#define EXT3_VALID_FS 0x0001 /* Unmounted cleanly */
334#define EXT3_ERROR_FS 0x0002 /* Errors detected */
335#define EXT3_ORPHAN_FS 0x0004 /* Orphans being recovered */
336
337/*
338 * Mount flags
339 */
340#define EXT3_MOUNT_CHECK 0x00001 /* Do mount-time checks */
341#define EXT3_MOUNT_OLDALLOC 0x00002 /* Don't use the new Orlov allocator */
342#define EXT3_MOUNT_GRPID 0x00004 /* Create files with directory's group */
343#define EXT3_MOUNT_DEBUG 0x00008 /* Some debugging messages */
344#define EXT3_MOUNT_ERRORS_CONT 0x00010 /* Continue on errors */
345#define EXT3_MOUNT_ERRORS_RO 0x00020 /* Remount fs ro on errors */
346#define EXT3_MOUNT_ERRORS_PANIC 0x00040 /* Panic on errors */
347#define EXT3_MOUNT_MINIX_DF 0x00080 /* Mimics the Minix statfs */
348#define EXT3_MOUNT_NOLOAD 0x00100 /* Don't use existing journal*/
349#define EXT3_MOUNT_ABORT 0x00200 /* Fatal error detected */
350#define EXT3_MOUNT_DATA_FLAGS 0x00C00 /* Mode for data writes: */
351#define EXT3_MOUNT_JOURNAL_DATA 0x00400 /* Write data to journal */
352#define EXT3_MOUNT_ORDERED_DATA 0x00800 /* Flush data before commit */
353#define EXT3_MOUNT_WRITEBACK_DATA 0x00C00 /* No data ordering */
354#define EXT3_MOUNT_UPDATE_JOURNAL 0x01000 /* Update the journal format */
355#define EXT3_MOUNT_NO_UID32 0x02000 /* Disable 32-bit UIDs */
356#define EXT3_MOUNT_XATTR_USER 0x04000 /* Extended user attributes */
357#define EXT3_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */
358#define EXT3_MOUNT_RESERVATION 0x10000 /* Preallocation */
359#define EXT3_MOUNT_BARRIER 0x20000 /* Use block barriers */
360#define EXT3_MOUNT_NOBH 0x40000 /* No bufferheads */
361
362/* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
363#ifndef _LINUX_EXT2_FS_H
364#define clear_opt(o, opt) o &= ~EXT3_MOUNT_##opt
365#define set_opt(o, opt) o |= EXT3_MOUNT_##opt
366#define test_opt(sb, opt) (EXT3_SB(sb)->s_mount_opt & \
367 EXT3_MOUNT_##opt)
368#else
369#define EXT2_MOUNT_NOLOAD EXT3_MOUNT_NOLOAD
370#define EXT2_MOUNT_ABORT EXT3_MOUNT_ABORT
371#define EXT2_MOUNT_DATA_FLAGS EXT3_MOUNT_DATA_FLAGS
372#endif
373
374#define ext3_set_bit ext2_set_bit
375#define ext3_set_bit_atomic ext2_set_bit_atomic
376#define ext3_clear_bit ext2_clear_bit
377#define ext3_clear_bit_atomic ext2_clear_bit_atomic
378#define ext3_test_bit ext2_test_bit
379#define ext3_find_first_zero_bit ext2_find_first_zero_bit
380#define ext3_find_next_zero_bit ext2_find_next_zero_bit
381
382/*
383 * Maximal mount counts between two filesystem checks
384 */
385#define EXT3_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */
386#define EXT3_DFL_CHECKINTERVAL 0 /* Don't use interval check */
387
388/*
389 * Behaviour when detecting errors
390 */
391#define EXT3_ERRORS_CONTINUE 1 /* Continue execution */
392#define EXT3_ERRORS_RO 2 /* Remount fs read-only */
393#define EXT3_ERRORS_PANIC 3 /* Panic */
394#define EXT3_ERRORS_DEFAULT EXT3_ERRORS_CONTINUE
395
396/*
397 * Structure of the super block
398 */
399struct ext3_super_block {
400/*00*/ __le32 s_inodes_count; /* Inodes count */
401 __le32 s_blocks_count; /* Blocks count */
402 __le32 s_r_blocks_count; /* Reserved blocks count */
403 __le32 s_free_blocks_count; /* Free blocks count */
404/*10*/ __le32 s_free_inodes_count; /* Free inodes count */
405 __le32 s_first_data_block; /* First Data Block */
406 __le32 s_log_block_size; /* Block size */
407 __le32 s_log_frag_size; /* Fragment size */
408/*20*/ __le32 s_blocks_per_group; /* # Blocks per group */
409 __le32 s_frags_per_group; /* # Fragments per group */
410 __le32 s_inodes_per_group; /* # Inodes per group */
411 __le32 s_mtime; /* Mount time */
412/*30*/ __le32 s_wtime; /* Write time */
413 __le16 s_mnt_count; /* Mount count */
414 __le16 s_max_mnt_count; /* Maximal mount count */
415 __le16 s_magic; /* Magic signature */
416 __le16 s_state; /* File system state */
417 __le16 s_errors; /* Behaviour when detecting errors */
418 __le16 s_minor_rev_level; /* minor revision level */
419/*40*/ __le32 s_lastcheck; /* time of last check */
420 __le32 s_checkinterval; /* max. time between checks */
421 __le32 s_creator_os; /* OS */
422 __le32 s_rev_level; /* Revision level */
423/*50*/ __le16 s_def_resuid; /* Default uid for reserved blocks */
424 __le16 s_def_resgid; /* Default gid for reserved blocks */
425 /*
426 * These fields are for EXT3_DYNAMIC_REV superblocks only.
427 *
428 * Note: the difference between the compatible feature set and
429 * the incompatible feature set is that if there is a bit set
430 * in the incompatible feature set that the kernel doesn't
431 * know about, it should refuse to mount the filesystem.
432 *
433 * e2fsck's requirements are more strict; if it doesn't know
434 * about a feature in either the compatible or incompatible
435 * feature set, it must abort and not try to meddle with
436 * things it doesn't understand...
437 */
438 __le32 s_first_ino; /* First non-reserved inode */
439 __le16 s_inode_size; /* size of inode structure */
440 __le16 s_block_group_nr; /* block group # of this superblock */
441 __le32 s_feature_compat; /* compatible feature set */
442/*60*/ __le32 s_feature_incompat; /* incompatible feature set */
443 __le32 s_feature_ro_compat; /* readonly-compatible feature set */
444/*68*/ __u8 s_uuid[16]; /* 128-bit uuid for volume */
445/*78*/ char s_volume_name[16]; /* volume name */
446/*88*/ char s_last_mounted[64]; /* directory where last mounted */
447/*C8*/ __le32 s_algorithm_usage_bitmap; /* For compression */
448 /*
449 * Performance hints. Directory preallocation should only
450 * happen if the EXT3_FEATURE_COMPAT_DIR_PREALLOC flag is on.
451 */
452 __u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
453 __u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
454 __u16 s_reserved_gdt_blocks; /* Per group desc for online growth */
455 /*
456 * Journaling support valid if EXT3_FEATURE_COMPAT_HAS_JOURNAL set.
457 */
458/*D0*/ __u8 s_journal_uuid[16]; /* uuid of journal superblock */
459/*E0*/ __le32 s_journal_inum; /* inode number of journal file */
460 __le32 s_journal_dev; /* device number of journal file */
461 __le32 s_last_orphan; /* start of list of inodes to delete */
462 __le32 s_hash_seed[4]; /* HTREE hash seed */
463 __u8 s_def_hash_version; /* Default hash version to use */
464 __u8 s_reserved_char_pad;
465 __u16 s_reserved_word_pad;
466 __le32 s_default_mount_opts;
467 __le32 s_first_meta_bg; /* First metablock block group */
468 __u32 s_reserved[190]; /* Padding to the end of the block */
469};
470
471#ifdef __KERNEL__
472static inline struct ext3_sb_info * EXT3_SB(struct super_block *sb)
473{
474 return sb->s_fs_info;
475}
476static inline struct ext3_inode_info *EXT3_I(struct inode *inode)
477{
478 return container_of(inode, struct ext3_inode_info, vfs_inode);
479}
480#else
481/* Assume that user mode programs are passing in an ext3fs superblock, not
482 * a kernel struct super_block. This will allow us to call the feature-test
483 * macros from user land. */
484#define EXT3_SB(sb) (sb)
485#endif
486
487#define NEXT_ORPHAN(inode) EXT3_I(inode)->i_dtime
488
489/*
490 * Codes for operating systems
491 */
492#define EXT3_OS_LINUX 0
493#define EXT3_OS_HURD 1
494#define EXT3_OS_MASIX 2
495#define EXT3_OS_FREEBSD 3
496#define EXT3_OS_LITES 4
497
498/*
499 * Revision levels
500 */
501#define EXT3_GOOD_OLD_REV 0 /* The good old (original) format */
502#define EXT3_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */
503
504#define EXT3_CURRENT_REV EXT3_GOOD_OLD_REV
505#define EXT3_MAX_SUPP_REV EXT3_DYNAMIC_REV
506
507#define EXT3_GOOD_OLD_INODE_SIZE 128
508
509/*
510 * Feature set definitions
511 */
512
513#define EXT3_HAS_COMPAT_FEATURE(sb,mask) \
514 ( EXT3_SB(sb)->s_es->s_feature_compat & cpu_to_le32(mask) )
515#define EXT3_HAS_RO_COMPAT_FEATURE(sb,mask) \
516 ( EXT3_SB(sb)->s_es->s_feature_ro_compat & cpu_to_le32(mask) )
517#define EXT3_HAS_INCOMPAT_FEATURE(sb,mask) \
518 ( EXT3_SB(sb)->s_es->s_feature_incompat & cpu_to_le32(mask) )
519#define EXT3_SET_COMPAT_FEATURE(sb,mask) \
520 EXT3_SB(sb)->s_es->s_feature_compat |= cpu_to_le32(mask)
521#define EXT3_SET_RO_COMPAT_FEATURE(sb,mask) \
522 EXT3_SB(sb)->s_es->s_feature_ro_compat |= cpu_to_le32(mask)
523#define EXT3_SET_INCOMPAT_FEATURE(sb,mask) \
524 EXT3_SB(sb)->s_es->s_feature_incompat |= cpu_to_le32(mask)
525#define EXT3_CLEAR_COMPAT_FEATURE(sb,mask) \
526 EXT3_SB(sb)->s_es->s_feature_compat &= ~cpu_to_le32(mask)
527#define EXT3_CLEAR_RO_COMPAT_FEATURE(sb,mask) \
528 EXT3_SB(sb)->s_es->s_feature_ro_compat &= ~cpu_to_le32(mask)
529#define EXT3_CLEAR_INCOMPAT_FEATURE(sb,mask) \
530 EXT3_SB(sb)->s_es->s_feature_incompat &= ~cpu_to_le32(mask)
531
532#define EXT3_FEATURE_COMPAT_DIR_PREALLOC 0x0001
533#define EXT3_FEATURE_COMPAT_IMAGIC_INODES 0x0002
534#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
535#define EXT3_FEATURE_COMPAT_EXT_ATTR 0x0008
536#define EXT3_FEATURE_COMPAT_RESIZE_INODE 0x0010
537#define EXT3_FEATURE_COMPAT_DIR_INDEX 0x0020
538
539#define EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
540#define EXT3_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
541#define EXT3_FEATURE_RO_COMPAT_BTREE_DIR 0x0004
542
543#define EXT3_FEATURE_INCOMPAT_COMPRESSION 0x0001
544#define EXT3_FEATURE_INCOMPAT_FILETYPE 0x0002
545#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */
546#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */
547#define EXT3_FEATURE_INCOMPAT_META_BG 0x0010
548
549#define EXT3_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR
550#define EXT3_FEATURE_INCOMPAT_SUPP (EXT3_FEATURE_INCOMPAT_FILETYPE| \
551 EXT3_FEATURE_INCOMPAT_RECOVER| \
552 EXT3_FEATURE_INCOMPAT_META_BG)
553#define EXT3_FEATURE_RO_COMPAT_SUPP (EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER| \
554 EXT3_FEATURE_RO_COMPAT_LARGE_FILE| \
555 EXT3_FEATURE_RO_COMPAT_BTREE_DIR)
556
557/*
558 * Default values for user and/or group using reserved blocks
559 */
560#define EXT3_DEF_RESUID 0
561#define EXT3_DEF_RESGID 0
562
563/*
564 * Default mount options
565 */
566#define EXT3_DEFM_DEBUG 0x0001
567#define EXT3_DEFM_BSDGROUPS 0x0002
568#define EXT3_DEFM_XATTR_USER 0x0004
569#define EXT3_DEFM_ACL 0x0008
570#define EXT3_DEFM_UID16 0x0010
571#define EXT3_DEFM_JMODE 0x0060
572#define EXT3_DEFM_JMODE_DATA 0x0020
573#define EXT3_DEFM_JMODE_ORDERED 0x0040
574#define EXT3_DEFM_JMODE_WBACK 0x0060
575
576/*
577 * Structure of a directory entry
578 */
579#define EXT3_NAME_LEN 255
580
581struct ext3_dir_entry {
582 __le32 inode; /* Inode number */
583 __le16 rec_len; /* Directory entry length */
584 __le16 name_len; /* Name length */
585 char name[EXT3_NAME_LEN]; /* File name */
586};
587
588/*
589 * The new version of the directory entry. Since EXT3 structures are
590 * stored in intel byte order, and the name_len field could never be
591 * bigger than 255 chars, it's safe to reclaim the extra byte for the
592 * file_type field.
593 */
594struct ext3_dir_entry_2 {
595 __le32 inode; /* Inode number */
596 __le16 rec_len; /* Directory entry length */
597 __u8 name_len; /* Name length */
598 __u8 file_type;
599 char name[EXT3_NAME_LEN]; /* File name */
600};
601
602/*
603 * Ext3 directory file types. Only the low 3 bits are used. The
604 * other bits are reserved for now.
605 */
606#define EXT3_FT_UNKNOWN 0
607#define EXT3_FT_REG_FILE 1
608#define EXT3_FT_DIR 2
609#define EXT3_FT_CHRDEV 3
610#define EXT3_FT_BLKDEV 4
611#define EXT3_FT_FIFO 5
612#define EXT3_FT_SOCK 6
613#define EXT3_FT_SYMLINK 7
614
615#define EXT3_FT_MAX 8
616
617/*
618 * EXT3_DIR_PAD defines the directory entries boundaries
619 *
620 * NOTE: It must be a multiple of 4
621 */
622#define EXT3_DIR_PAD 4
623#define EXT3_DIR_ROUND (EXT3_DIR_PAD - 1)
624#define EXT3_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT3_DIR_ROUND) & \
625 ~EXT3_DIR_ROUND)
626/*
627 * Hash Tree Directory indexing
628 * (c) Daniel Phillips, 2001
629 */
630
631#ifdef CONFIG_EXT3_INDEX
632 #define is_dx(dir) (EXT3_HAS_COMPAT_FEATURE(dir->i_sb, \
633 EXT3_FEATURE_COMPAT_DIR_INDEX) && \
634 (EXT3_I(dir)->i_flags & EXT3_INDEX_FL))
635#define EXT3_DIR_LINK_MAX(dir) (!is_dx(dir) && (dir)->i_nlink >= EXT3_LINK_MAX)
636#define EXT3_DIR_LINK_EMPTY(dir) ((dir)->i_nlink == 2 || (dir)->i_nlink == 1)
637#else
638 #define is_dx(dir) 0
639#define EXT3_DIR_LINK_MAX(dir) ((dir)->i_nlink >= EXT3_LINK_MAX)
640#define EXT3_DIR_LINK_EMPTY(dir) ((dir)->i_nlink == 2)
641#endif
642
643/* Legal values for the dx_root hash_version field: */
644
645#define DX_HASH_LEGACY 0
646#define DX_HASH_HALF_MD4 1
647#define DX_HASH_TEA 2
648
649/* hash info structure used by the directory hash */
650struct dx_hash_info
651{
652 u32 hash;
653 u32 minor_hash;
654 int hash_version;
655 u32 *seed;
656};
657
658#define EXT3_HTREE_EOF 0x7fffffff
659
660#ifdef __KERNEL__
661/*
662 * Control parameters used by ext3_htree_next_block
663 */
664#define HASH_NB_ALWAYS 1
665
666
667/*
668 * Describe an inode's exact location on disk and in memory
669 */
670struct ext3_iloc
671{
672 struct buffer_head *bh;
673 unsigned long offset;
674 unsigned long block_group;
675};
676
677static inline struct ext3_inode *ext3_raw_inode(struct ext3_iloc *iloc)
678{
679 return (struct ext3_inode *) (iloc->bh->b_data + iloc->offset);
680}
681
682/*
683 * This structure is stuffed into the struct file's private_data field
684 * for directories. It is where we put information so that we can do
685 * readdir operations in hash tree order.
686 */
687struct dir_private_info {
688 struct rb_root root;
689 struct rb_node *curr_node;
690 struct fname *extra_fname;
691 loff_t last_pos;
692 __u32 curr_hash;
693 __u32 curr_minor_hash;
694 __u32 next_hash;
695};
696
697/*
698 * Special error return code only used by dx_probe() and its callers.
699 */
700#define ERR_BAD_DX_DIR -75000
701
702/*
703 * Function prototypes
704 */
705
706/*
707 * Ok, these declarations are also in <linux/kernel.h> but none of the
708 * ext3 source programs needs to include it so they are duplicated here.
709 */
710# define NORET_TYPE /**/
711# define ATTRIB_NORET __attribute__((noreturn))
712# define NORET_AND noreturn,
713
714/* balloc.c */
715extern int ext3_bg_has_super(struct super_block *sb, int group);
716extern unsigned long ext3_bg_num_gdb(struct super_block *sb, int group);
717extern int ext3_new_block (handle_t *, struct inode *, unsigned long, int *);
718extern void ext3_free_blocks (handle_t *, struct inode *, unsigned long,
719 unsigned long);
720extern void ext3_free_blocks_sb (handle_t *, struct super_block *,
721 unsigned long, unsigned long, int *);
722extern unsigned long ext3_count_free_blocks (struct super_block *);
723extern void ext3_check_blocks_bitmap (struct super_block *);
724extern struct ext3_group_desc * ext3_get_group_desc(struct super_block * sb,
725 unsigned int block_group,
726 struct buffer_head ** bh);
727extern int ext3_should_retry_alloc(struct super_block *sb, int *retries);
728extern void ext3_init_block_alloc_info(struct inode *);
729extern void ext3_rsv_window_add(struct super_block *sb, struct ext3_reserve_window_node *rsv);
730
731/* dir.c */
732extern int ext3_check_dir_entry(const char *, struct inode *,
733 struct ext3_dir_entry_2 *,
734 struct buffer_head *, unsigned long);
735extern int ext3_htree_store_dirent(struct file *dir_file, __u32 hash,
736 __u32 minor_hash,
737 struct ext3_dir_entry_2 *dirent);
738extern void ext3_htree_free_dir_info(struct dir_private_info *p);
739
740/* fsync.c */
741extern int ext3_sync_file (struct file *, struct dentry *, int);
742
743/* hash.c */
744extern int ext3fs_dirhash(const char *name, int len, struct
745 dx_hash_info *hinfo);
746
747/* ialloc.c */
748extern struct inode * ext3_new_inode (handle_t *, struct inode *, int);
749extern void ext3_free_inode (handle_t *, struct inode *);
750extern struct inode * ext3_orphan_get (struct super_block *, unsigned long);
751extern unsigned long ext3_count_free_inodes (struct super_block *);
752extern unsigned long ext3_count_dirs (struct super_block *);
753extern void ext3_check_inodes_bitmap (struct super_block *);
754extern unsigned long ext3_count_free (struct buffer_head *, unsigned);
755
756
757/* inode.c */
758extern int ext3_forget(handle_t *, int, struct inode *, struct buffer_head *, int);
759extern struct buffer_head * ext3_getblk (handle_t *, struct inode *, long, int, int *);
760extern struct buffer_head * ext3_bread (handle_t *, struct inode *, int, int, int *);
761
762extern void ext3_read_inode (struct inode *);
763extern int ext3_write_inode (struct inode *, int);
764extern int ext3_setattr (struct dentry *, struct iattr *);
765extern void ext3_delete_inode (struct inode *);
766extern int ext3_sync_inode (handle_t *, struct inode *);
767extern void ext3_discard_reservation (struct inode *);
768extern void ext3_dirty_inode(struct inode *);
769extern int ext3_change_inode_journal_flag(struct inode *, int);
770extern int ext3_get_inode_loc(struct inode *, struct ext3_iloc *);
771extern void ext3_truncate (struct inode *);
772extern void ext3_set_inode_flags(struct inode *);
773extern void ext3_set_aops(struct inode *inode);
774
775/* ioctl.c */
776extern int ext3_ioctl (struct inode *, struct file *, unsigned int,
777 unsigned long);
778
779/* namei.c */
780extern int ext3_orphan_add(handle_t *, struct inode *);
781extern int ext3_orphan_del(handle_t *, struct inode *);
782extern int ext3_htree_fill_tree(struct file *dir_file, __u32 start_hash,
783 __u32 start_minor_hash, __u32 *next_hash);
784
785/* resize.c */
786extern int ext3_group_add(struct super_block *sb,
787 struct ext3_new_group_data *input);
788extern int ext3_group_extend(struct super_block *sb,
789 struct ext3_super_block *es,
790 unsigned long n_blocks_count);
791
792/* super.c */
793extern void ext3_error (struct super_block *, const char *, const char *, ...)
794 __attribute__ ((format (printf, 3, 4)));
795extern void __ext3_std_error (struct super_block *, const char *, int);
796extern void ext3_abort (struct super_block *, const char *, const char *, ...)
797 __attribute__ ((format (printf, 3, 4)));
798extern void ext3_warning (struct super_block *, const char *, const char *, ...)
799 __attribute__ ((format (printf, 3, 4)));
800extern void ext3_update_dynamic_rev (struct super_block *sb);
801
802#define ext3_std_error(sb, errno) \
803do { \
804 if ((errno)) \
805 __ext3_std_error((sb), __FUNCTION__, (errno)); \
806} while (0)
807
808/*
809 * Inodes and files operations
810 */
811
812/* dir.c */
813extern struct file_operations ext3_dir_operations;
814
815/* file.c */
816extern struct inode_operations ext3_file_inode_operations;
817extern struct file_operations ext3_file_operations;
818
819/* namei.c */
820extern struct inode_operations ext3_dir_inode_operations;
821extern struct inode_operations ext3_special_inode_operations;
822
823/* symlink.c */
824extern struct inode_operations ext3_symlink_inode_operations;
825extern struct inode_operations ext3_fast_symlink_inode_operations;
826
827
828#endif /* __KERNEL__ */
829
830#endif /* _LINUX_EXT3_FS_H */
diff --git a/include/linux/ext3_fs_i.h b/include/linux/ext3_fs_i.h
new file mode 100644
index 000000000000..2914f7b07156
--- /dev/null
+++ b/include/linux/ext3_fs_i.h
@@ -0,0 +1,138 @@
1/*
2 * linux/include/linux/ext3_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_EXT3_FS_I
17#define _LINUX_EXT3_FS_I
18
19#include <linux/rwsem.h>
20#include <linux/rbtree.h>
21#include <linux/seqlock.h>
22
23struct ext3_reserve_window {
24 __u32 _rsv_start; /* First byte reserved */
25 __u32 _rsv_end; /* Last byte reserved or 0 */
26};
27
28struct ext3_reserve_window_node {
29 struct rb_node rsv_node;
30 __u32 rsv_goal_size;
31 __u32 rsv_alloc_hit;
32 struct ext3_reserve_window rsv_window;
33};
34
35struct ext3_block_alloc_info {
36 /* information about reservation window */
37 struct ext3_reserve_window_node rsv_window_node;
38 /*
39 * was i_next_alloc_block in ext3_inode_info
40 * is the logical (file-relative) number of the
41 * most-recently-allocated block in this file.
42 * We use this for detecting linearly ascending allocation requests.
43 */
44 __u32 last_alloc_logical_block;
45 /*
46 * Was i_next_alloc_goal in ext3_inode_info
47 * is the *physical* companion to i_next_alloc_block.
48 * it the the physical block number of the block which was most-recentl
49 * allocated to this file. This give us the goal (target) for the next
50 * allocation when we detect linearly ascending requests.
51 */
52 __u32 last_alloc_physical_block;
53};
54
55#define rsv_start rsv_window._rsv_start
56#define rsv_end rsv_window._rsv_end
57
58/*
59 * third extended file system inode data in memory
60 */
61struct ext3_inode_info {
62 __le32 i_data[15]; /* unconverted */
63 __u32 i_flags;
64#ifdef EXT3_FRAGMENTS
65 __u32 i_faddr;
66 __u8 i_frag_no;
67 __u8 i_frag_size;
68#endif
69 __u32 i_file_acl;
70 __u32 i_dir_acl;
71 __u32 i_dtime;
72
73 /*
74 * i_block_group is the number of the block group which contains
75 * this file's inode. Constant across the lifetime of the inode,
76 * it is ued for making block allocation decisions - we try to
77 * place a file's data blocks near its inode block, and new inodes
78 * near to their parent directory's inode.
79 */
80 __u32 i_block_group;
81 __u32 i_state; /* Dynamic state flags for ext3 */
82
83 /* block reservation info */
84 struct ext3_block_alloc_info *i_block_alloc_info;
85
86 __u32 i_dir_start_lookup;
87#ifdef CONFIG_EXT3_FS_XATTR
88 /*
89 * Extended attributes can be read independently of the main file
90 * data. Taking i_sem even when reading would cause contention
91 * between readers of EAs and writers of regular file data, so
92 * instead we synchronize on xattr_sem when reading or changing
93 * EAs.
94 */
95 struct rw_semaphore xattr_sem;
96#endif
97#ifdef CONFIG_EXT3_FS_POSIX_ACL
98 struct posix_acl *i_acl;
99 struct posix_acl *i_default_acl;
100#endif
101
102 struct list_head i_orphan; /* unlinked but open inodes */
103
104 /*
105 * i_disksize keeps track of what the inode size is ON DISK, not
106 * in memory. During truncate, i_size is set to the new size by
107 * the VFS prior to calling ext3_truncate(), but the filesystem won't
108 * set i_disksize to 0 until the truncate is actually under way.
109 *
110 * The intent is that i_disksize always represents the blocks which
111 * are used by this file. This allows recovery to restart truncate
112 * on orphans if we crash during truncate. We actually write i_disksize
113 * into the on-disk inode when writing inodes out, instead of i_size.
114 *
115 * The only time when i_disksize and i_size may be different is when
116 * a truncate is in progress. The only things which change i_disksize
117 * are ext3_get_block (growth) and ext3_truncate (shrinkth).
118 */
119 loff_t i_disksize;
120
121 /* on-disk additional length */
122 __u16 i_extra_isize;
123
124 /*
125 * truncate_sem is for serialising ext3_truncate() against
126 * ext3_getblock(). In the 2.4 ext2 design, great chunks of inode's
127 * data tree are chopped off during truncate. We can't do that in
128 * ext3 because whenever we perform intermediate commits during
129 * truncate, the inode and all the metadata blocks *must* be in a
130 * consistent state which allows truncation of the orphans to restart
131 * during recovery. Hence we must fix the get_block-vs-truncate race
132 * by other means, so we have truncate_sem.
133 */
134 struct semaphore truncate_sem;
135 struct inode vfs_inode;
136};
137
138#endif /* _LINUX_EXT3_FS_I */
diff --git a/include/linux/ext3_fs_sb.h b/include/linux/ext3_fs_sb.h
new file mode 100644
index 000000000000..f61309c81cc4
--- /dev/null
+++ b/include/linux/ext3_fs_sb.h
@@ -0,0 +1,83 @@
1/*
2 * linux/include/linux/ext3_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_EXT3_FS_SB
17#define _LINUX_EXT3_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 ext3_sb_info {
31 unsigned long s_frag_size; /* Size of a fragment in bytes */
32 unsigned long s_frags_per_block;/* Number of fragments per block */
33 unsigned long s_inodes_per_block;/* Number of inodes per block */
34 unsigned long s_frags_per_group;/* Number of fragments in a group */
35 unsigned long s_blocks_per_group;/* Number of blocks in a group */
36 unsigned long s_inodes_per_group;/* Number of inodes in a group */
37 unsigned long s_itb_per_group; /* Number of inode table blocks per group */
38 unsigned long s_gdb_count; /* Number of group descriptor blocks */
39 unsigned long s_desc_per_block; /* Number of group descriptors per block */
40 unsigned long s_groups_count; /* Number of groups in the fs */
41 struct buffer_head * s_sbh; /* Buffer containing the super block */
42 struct ext3_super_block * s_es; /* Pointer to the super block in the buffer */
43 struct buffer_head ** s_group_desc;
44 unsigned long s_mount_opt;
45 uid_t s_resuid;
46 gid_t s_resgid;
47 unsigned short s_mount_state;
48 unsigned short s_pad;
49 int s_addr_per_block_bits;
50 int s_desc_per_block_bits;
51 int s_inode_size;
52 int s_first_ino;
53 spinlock_t s_next_gen_lock;
54 u32 s_next_generation;
55 u32 s_hash_seed[4];
56 int s_def_hash_version;
57 struct percpu_counter s_freeblocks_counter;
58 struct percpu_counter s_freeinodes_counter;
59 struct percpu_counter s_dirs_counter;
60 struct blockgroup_lock s_blockgroup_lock;
61
62 /* root of the per fs reservation window tree */
63 spinlock_t s_rsv_window_lock;
64 struct rb_root s_rsv_window_root;
65 struct ext3_reserve_window_node s_rsv_window_head;
66
67 /* Journaling */
68 struct inode * s_journal_inode;
69 struct journal_s * s_journal;
70 struct list_head s_orphan;
71 unsigned long s_commit_interval;
72 struct block_device *journal_bdev;
73#ifdef CONFIG_JBD_DEBUG
74 struct timer_list turn_ro_timer; /* For turning read-only (crash simulation) */
75 wait_queue_head_t ro_wait_queue; /* For people waiting for the fs to go read-only */
76#endif
77#ifdef CONFIG_QUOTA
78 char *s_qf_names[MAXQUOTAS]; /* Names of quota files with journalled quota */
79 int s_jquota_fmt; /* Format of quota to use */
80#endif
81};
82
83#endif /* _LINUX_EXT3_FS_SB */
diff --git a/include/linux/ext3_jbd.h b/include/linux/ext3_jbd.h
new file mode 100644
index 000000000000..e8292af9033b
--- /dev/null
+++ b/include/linux/ext3_jbd.h
@@ -0,0 +1,265 @@
1/*
2 * linux/include/linux/ext3_jbd.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 * Ext3-specific journaling extensions.
13 */
14
15#ifndef _LINUX_EXT3_JBD_H
16#define _LINUX_EXT3_JBD_H
17
18#include <linux/fs.h>
19#include <linux/jbd.h>
20#include <linux/ext3_fs.h>
21
22#define EXT3_JOURNAL(inode) (EXT3_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#define EXT3_SINGLEDATA_TRANS_BLOCKS 8U
32
33/* Extended attribute operations touch at most two data buffers,
34 * two bitmap buffers, and two group summaries, in addition to the inode
35 * and the superblock, which are already accounted for. */
36
37#define EXT3_XATTR_TRANS_BLOCKS 6U
38
39/* Define the minimum size for a transaction which modifies data. This
40 * needs to take into account the fact that we may end up modifying two
41 * quota files too (one for the group, one for the user quota). The
42 * superblock only gets updated once, of course, so don't bother
43 * counting that again for the quota updates. */
44
45#define EXT3_DATA_TRANS_BLOCKS (EXT3_SINGLEDATA_TRANS_BLOCKS + \
46 EXT3_XATTR_TRANS_BLOCKS - 2 + \
47 2*EXT3_QUOTA_TRANS_BLOCKS)
48
49/* Delete operations potentially hit one directory's namespace plus an
50 * entire inode, plus arbitrary amounts of bitmap/indirection data. Be
51 * generous. We can grow the delete transaction later if necessary. */
52
53#define EXT3_DELETE_TRANS_BLOCKS (2 * EXT3_DATA_TRANS_BLOCKS + 64)
54
55/* Define an arbitrary limit for the amount of data we will anticipate
56 * writing to any given transaction. For unbounded transactions such as
57 * write(2) and truncate(2) we can write more than this, but we always
58 * start off at the maximum transaction size and grow the transaction
59 * optimistically as we go. */
60
61#define EXT3_MAX_TRANS_DATA 64U
62
63/* We break up a large truncate or write transaction once the handle's
64 * buffer credits gets this low, we need either to extend the
65 * transaction or to start a new one. Reserve enough space here for
66 * inode, bitmap, superblock, group and indirection updates for at least
67 * one block, plus two quota updates. Quota allocations are not
68 * needed. */
69
70#define EXT3_RESERVE_TRANS_BLOCKS 12U
71
72#define EXT3_INDEX_EXTRA_TRANS_BLOCKS 8
73
74#ifdef CONFIG_QUOTA
75/* Amount of blocks needed for quota update - we know that the structure was
76 * allocated so we need to update only inode+data */
77#define EXT3_QUOTA_TRANS_BLOCKS 2
78/* Amount of blocks needed for quota insert/delete - we do some block writes
79 * but inode, sb and group updates are done only once */
80#define EXT3_QUOTA_INIT_BLOCKS (DQUOT_MAX_WRITES*\
81 (EXT3_SINGLEDATA_TRANS_BLOCKS-3)+3)
82#else
83#define EXT3_QUOTA_TRANS_BLOCKS 0
84#define EXT3_QUOTA_INIT_BLOCKS 0
85#endif
86
87int
88ext3_mark_iloc_dirty(handle_t *handle,
89 struct inode *inode,
90 struct ext3_iloc *iloc);
91
92/*
93 * On success, We end up with an outstanding reference count against
94 * iloc->bh. This _must_ be cleaned up later.
95 */
96
97int ext3_reserve_inode_write(handle_t *handle, struct inode *inode,
98 struct ext3_iloc *iloc);
99
100int ext3_mark_inode_dirty(handle_t *handle, struct inode *inode);
101
102/*
103 * Wrapper functions with which ext3 calls into JBD. The intent here is
104 * to allow these to be turned into appropriate stubs so ext3 can control
105 * ext2 filesystems, so ext2+ext3 systems only nee one fs. This work hasn't
106 * been done yet.
107 */
108
109void ext3_journal_abort_handle(const char *caller, const char *err_fn,
110 struct buffer_head *bh, handle_t *handle, int err);
111
112static inline int
113__ext3_journal_get_undo_access(const char *where, handle_t *handle,
114 struct buffer_head *bh)
115{
116 int err = journal_get_undo_access(handle, bh);
117 if (err)
118 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
119 return err;
120}
121
122static inline int
123__ext3_journal_get_write_access(const char *where, handle_t *handle,
124 struct buffer_head *bh)
125{
126 int err = journal_get_write_access(handle, bh);
127 if (err)
128 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
129 return err;
130}
131
132static inline void
133ext3_journal_release_buffer(handle_t *handle, struct buffer_head *bh)
134{
135 journal_release_buffer(handle, bh);
136}
137
138static inline int
139__ext3_journal_forget(const char *where, handle_t *handle, struct buffer_head *bh)
140{
141 int err = journal_forget(handle, bh);
142 if (err)
143 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
144 return err;
145}
146
147static inline int
148__ext3_journal_revoke(const char *where, handle_t *handle,
149 unsigned long blocknr, struct buffer_head *bh)
150{
151 int err = journal_revoke(handle, blocknr, bh);
152 if (err)
153 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
154 return err;
155}
156
157static inline int
158__ext3_journal_get_create_access(const char *where,
159 handle_t *handle, struct buffer_head *bh)
160{
161 int err = journal_get_create_access(handle, bh);
162 if (err)
163 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
164 return err;
165}
166
167static inline int
168__ext3_journal_dirty_metadata(const char *where,
169 handle_t *handle, struct buffer_head *bh)
170{
171 int err = journal_dirty_metadata(handle, bh);
172 if (err)
173 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
174 return err;
175}
176
177
178#define ext3_journal_get_undo_access(handle, bh) \
179 __ext3_journal_get_undo_access(__FUNCTION__, (handle), (bh))
180#define ext3_journal_get_write_access(handle, bh) \
181 __ext3_journal_get_write_access(__FUNCTION__, (handle), (bh))
182#define ext3_journal_revoke(handle, blocknr, bh) \
183 __ext3_journal_revoke(__FUNCTION__, (handle), (blocknr), (bh))
184#define ext3_journal_get_create_access(handle, bh) \
185 __ext3_journal_get_create_access(__FUNCTION__, (handle), (bh))
186#define ext3_journal_dirty_metadata(handle, bh) \
187 __ext3_journal_dirty_metadata(__FUNCTION__, (handle), (bh))
188#define ext3_journal_forget(handle, bh) \
189 __ext3_journal_forget(__FUNCTION__, (handle), (bh))
190
191int ext3_journal_dirty_data(handle_t *handle, struct buffer_head *bh);
192
193handle_t *ext3_journal_start_sb(struct super_block *sb, int nblocks);
194int __ext3_journal_stop(const char *where, handle_t *handle);
195
196static inline handle_t *ext3_journal_start(struct inode *inode, int nblocks)
197{
198 return ext3_journal_start_sb(inode->i_sb, nblocks);
199}
200
201#define ext3_journal_stop(handle) \
202 __ext3_journal_stop(__FUNCTION__, (handle))
203
204static inline handle_t *ext3_journal_current_handle(void)
205{
206 return journal_current_handle();
207}
208
209static inline int ext3_journal_extend(handle_t *handle, int nblocks)
210{
211 return journal_extend(handle, nblocks);
212}
213
214static inline int ext3_journal_restart(handle_t *handle, int nblocks)
215{
216 return journal_restart(handle, nblocks);
217}
218
219static inline int ext3_journal_blocks_per_page(struct inode *inode)
220{
221 return journal_blocks_per_page(inode);
222}
223
224static inline int ext3_journal_force_commit(journal_t *journal)
225{
226 return journal_force_commit(journal);
227}
228
229/* super.c */
230int ext3_force_commit(struct super_block *sb);
231
232static inline int ext3_should_journal_data(struct inode *inode)
233{
234 if (!S_ISREG(inode->i_mode))
235 return 1;
236 if (test_opt(inode->i_sb, DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA)
237 return 1;
238 if (EXT3_I(inode)->i_flags & EXT3_JOURNAL_DATA_FL)
239 return 1;
240 return 0;
241}
242
243static inline int ext3_should_order_data(struct inode *inode)
244{
245 if (!S_ISREG(inode->i_mode))
246 return 0;
247 if (EXT3_I(inode)->i_flags & EXT3_JOURNAL_DATA_FL)
248 return 0;
249 if (test_opt(inode->i_sb, DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA)
250 return 1;
251 return 0;
252}
253
254static inline int ext3_should_writeback_data(struct inode *inode)
255{
256 if (!S_ISREG(inode->i_mode))
257 return 0;
258 if (EXT3_I(inode)->i_flags & EXT3_JOURNAL_DATA_FL)
259 return 0;
260 if (test_opt(inode->i_sb, DATA_FLAGS) == EXT3_MOUNT_WRITEBACK_DATA)
261 return 1;
262 return 0;
263}
264
265#endif /* _LINUX_EXT3_JBD_H */
diff --git a/include/linux/fadvise.h b/include/linux/fadvise.h
new file mode 100644
index 000000000000..6fc656dfb93d
--- /dev/null
+++ b/include/linux/fadvise.h
@@ -0,0 +1,11 @@
1#ifndef FADVISE_H_INCLUDED
2#define FADVISE_H_INCLUDED
3
4#define POSIX_FADV_NORMAL 0 /* No further special treatment. */
5#define POSIX_FADV_RANDOM 1 /* Expect random page references. */
6#define POSIX_FADV_SEQUENTIAL 2 /* Expect sequential page references. */
7#define POSIX_FADV_WILLNEED 3 /* Will need these pages. */
8#define POSIX_FADV_DONTNEED 4 /* Don't need these pages. */
9#define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */
10
11#endif /* FADVISE_H_INCLUDED */
diff --git a/include/linux/fb.h b/include/linux/fb.h
new file mode 100644
index 000000000000..b45d3e2d711a
--- /dev/null
+++ b/include/linux/fb.h
@@ -0,0 +1,932 @@
1#ifndef _LINUX_FB_H
2#define _LINUX_FB_H
3
4#include <asm/types.h>
5
6/* Definitions of frame buffers */
7
8#define FB_MAJOR 29
9#define FB_MAX 32 /* sufficient for now */
10
11/* ioctls
12 0x46 is 'F' */
13#define FBIOGET_VSCREENINFO 0x4600
14#define FBIOPUT_VSCREENINFO 0x4601
15#define FBIOGET_FSCREENINFO 0x4602
16#define FBIOGETCMAP 0x4604
17#define FBIOPUTCMAP 0x4605
18#define FBIOPAN_DISPLAY 0x4606
19#ifdef __KERNEL__
20#define FBIO_CURSOR _IOWR('F', 0x08, struct fb_cursor_user)
21#else
22#define FBIO_CURSOR _IOWR('F', 0x08, struct fb_cursor)
23#endif
24/* 0x4607-0x460B are defined below */
25/* #define FBIOGET_MONITORSPEC 0x460C */
26/* #define FBIOPUT_MONITORSPEC 0x460D */
27/* #define FBIOSWITCH_MONIBIT 0x460E */
28#define FBIOGET_CON2FBMAP 0x460F
29#define FBIOPUT_CON2FBMAP 0x4610
30#define FBIOBLANK 0x4611 /* arg: 0 or vesa level + 1 */
31#define FBIOGET_VBLANK _IOR('F', 0x12, struct fb_vblank)
32#define FBIO_ALLOC 0x4613
33#define FBIO_FREE 0x4614
34#define FBIOGET_GLYPH 0x4615
35#define FBIOGET_HWCINFO 0x4616
36#define FBIOPUT_MODEINFO 0x4617
37#define FBIOGET_DISPINFO 0x4618
38
39
40#define FB_TYPE_PACKED_PIXELS 0 /* Packed Pixels */
41#define FB_TYPE_PLANES 1 /* Non interleaved planes */
42#define FB_TYPE_INTERLEAVED_PLANES 2 /* Interleaved planes */
43#define FB_TYPE_TEXT 3 /* Text/attributes */
44#define FB_TYPE_VGA_PLANES 4 /* EGA/VGA planes */
45
46#define FB_AUX_TEXT_MDA 0 /* Monochrome text */
47#define FB_AUX_TEXT_CGA 1 /* CGA/EGA/VGA Color text */
48#define FB_AUX_TEXT_S3_MMIO 2 /* S3 MMIO fasttext */
49#define FB_AUX_TEXT_MGA_STEP16 3 /* MGA Millenium I: text, attr, 14 reserved bytes */
50#define FB_AUX_TEXT_MGA_STEP8 4 /* other MGAs: text, attr, 6 reserved bytes */
51
52#define FB_AUX_VGA_PLANES_VGA4 0 /* 16 color planes (EGA/VGA) */
53#define FB_AUX_VGA_PLANES_CFB4 1 /* CFB4 in planes (VGA) */
54#define FB_AUX_VGA_PLANES_CFB8 2 /* CFB8 in planes (VGA) */
55
56#define FB_VISUAL_MONO01 0 /* Monochr. 1=Black 0=White */
57#define FB_VISUAL_MONO10 1 /* Monochr. 1=White 0=Black */
58#define FB_VISUAL_TRUECOLOR 2 /* True color */
59#define FB_VISUAL_PSEUDOCOLOR 3 /* Pseudo color (like atari) */
60#define FB_VISUAL_DIRECTCOLOR 4 /* Direct color */
61#define FB_VISUAL_STATIC_PSEUDOCOLOR 5 /* Pseudo color readonly */
62
63#define FB_ACCEL_NONE 0 /* no hardware accelerator */
64#define FB_ACCEL_ATARIBLITT 1 /* Atari Blitter */
65#define FB_ACCEL_AMIGABLITT 2 /* Amiga Blitter */
66#define FB_ACCEL_S3_TRIO64 3 /* Cybervision64 (S3 Trio64) */
67#define FB_ACCEL_NCR_77C32BLT 4 /* RetinaZ3 (NCR 77C32BLT) */
68#define FB_ACCEL_S3_VIRGE 5 /* Cybervision64/3D (S3 ViRGE) */
69#define FB_ACCEL_ATI_MACH64GX 6 /* ATI Mach 64GX family */
70#define FB_ACCEL_DEC_TGA 7 /* DEC 21030 TGA */
71#define FB_ACCEL_ATI_MACH64CT 8 /* ATI Mach 64CT family */
72#define FB_ACCEL_ATI_MACH64VT 9 /* ATI Mach 64CT family VT class */
73#define FB_ACCEL_ATI_MACH64GT 10 /* ATI Mach 64CT family GT class */
74#define FB_ACCEL_SUN_CREATOR 11 /* Sun Creator/Creator3D */
75#define FB_ACCEL_SUN_CGSIX 12 /* Sun cg6 */
76#define FB_ACCEL_SUN_LEO 13 /* Sun leo/zx */
77#define FB_ACCEL_IMS_TWINTURBO 14 /* IMS Twin Turbo */
78#define FB_ACCEL_3DLABS_PERMEDIA2 15 /* 3Dlabs Permedia 2 */
79#define FB_ACCEL_MATROX_MGA2064W 16 /* Matrox MGA2064W (Millenium) */
80#define FB_ACCEL_MATROX_MGA1064SG 17 /* Matrox MGA1064SG (Mystique) */
81#define FB_ACCEL_MATROX_MGA2164W 18 /* Matrox MGA2164W (Millenium II) */
82#define FB_ACCEL_MATROX_MGA2164W_AGP 19 /* Matrox MGA2164W (Millenium II) */
83#define FB_ACCEL_MATROX_MGAG100 20 /* Matrox G100 (Productiva G100) */
84#define FB_ACCEL_MATROX_MGAG200 21 /* Matrox G200 (Myst, Mill, ...) */
85#define FB_ACCEL_SUN_CG14 22 /* Sun cgfourteen */
86#define FB_ACCEL_SUN_BWTWO 23 /* Sun bwtwo */
87#define FB_ACCEL_SUN_CGTHREE 24 /* Sun cgthree */
88#define FB_ACCEL_SUN_TCX 25 /* Sun tcx */
89#define FB_ACCEL_MATROX_MGAG400 26 /* Matrox G400 */
90#define FB_ACCEL_NV3 27 /* nVidia RIVA 128 */
91#define FB_ACCEL_NV4 28 /* nVidia RIVA TNT */
92#define FB_ACCEL_NV5 29 /* nVidia RIVA TNT2 */
93#define FB_ACCEL_CT_6555x 30 /* C&T 6555x */
94#define FB_ACCEL_3DFX_BANSHEE 31 /* 3Dfx Banshee */
95#define FB_ACCEL_ATI_RAGE128 32 /* ATI Rage128 family */
96#define FB_ACCEL_IGS_CYBER2000 33 /* CyberPro 2000 */
97#define FB_ACCEL_IGS_CYBER2010 34 /* CyberPro 2010 */
98#define FB_ACCEL_IGS_CYBER5000 35 /* CyberPro 5000 */
99#define FB_ACCEL_SIS_GLAMOUR 36 /* SiS 300/630/540 */
100#define FB_ACCEL_3DLABS_PERMEDIA3 37 /* 3Dlabs Permedia 3 */
101#define FB_ACCEL_ATI_RADEON 38 /* ATI Radeon family */
102#define FB_ACCEL_I810 39 /* Intel 810/815 */
103#define FB_ACCEL_SIS_GLAMOUR_2 40 /* SiS 315, 650, 740 */
104#define FB_ACCEL_SIS_XABRE 41 /* SiS 330 ("Xabre") */
105#define FB_ACCEL_I830 42 /* Intel 830M/845G/85x/865G */
106#define FB_ACCEL_NV_10 43 /* nVidia Arch 10 */
107#define FB_ACCEL_NV_20 44 /* nVidia Arch 20 */
108#define FB_ACCEL_NV_30 45 /* nVidia Arch 30 */
109#define FB_ACCEL_NV_40 46 /* nVidia Arch 40 */
110#define FB_ACCEL_NEOMAGIC_NM2070 90 /* NeoMagic NM2070 */
111#define FB_ACCEL_NEOMAGIC_NM2090 91 /* NeoMagic NM2090 */
112#define FB_ACCEL_NEOMAGIC_NM2093 92 /* NeoMagic NM2093 */
113#define FB_ACCEL_NEOMAGIC_NM2097 93 /* NeoMagic NM2097 */
114#define FB_ACCEL_NEOMAGIC_NM2160 94 /* NeoMagic NM2160 */
115#define FB_ACCEL_NEOMAGIC_NM2200 95 /* NeoMagic NM2200 */
116#define FB_ACCEL_NEOMAGIC_NM2230 96 /* NeoMagic NM2230 */
117#define FB_ACCEL_NEOMAGIC_NM2360 97 /* NeoMagic NM2360 */
118#define FB_ACCEL_NEOMAGIC_NM2380 98 /* NeoMagic NM2380 */
119
120#define FB_ACCEL_SAVAGE4 0x80 /* S3 Savage4 */
121#define FB_ACCEL_SAVAGE3D 0x81 /* S3 Savage3D */
122#define FB_ACCEL_SAVAGE3D_MV 0x82 /* S3 Savage3D-MV */
123#define FB_ACCEL_SAVAGE2000 0x83 /* S3 Savage2000 */
124#define FB_ACCEL_SAVAGE_MX_MV 0x84 /* S3 Savage/MX-MV */
125#define FB_ACCEL_SAVAGE_MX 0x85 /* S3 Savage/MX */
126#define FB_ACCEL_SAVAGE_IX_MV 0x86 /* S3 Savage/IX-MV */
127#define FB_ACCEL_SAVAGE_IX 0x87 /* S3 Savage/IX */
128#define FB_ACCEL_PROSAVAGE_PM 0x88 /* S3 ProSavage PM133 */
129#define FB_ACCEL_PROSAVAGE_KM 0x89 /* S3 ProSavage KM133 */
130#define FB_ACCEL_S3TWISTER_P 0x8a /* S3 Twister */
131#define FB_ACCEL_S3TWISTER_K 0x8b /* S3 TwisterK */
132#define FB_ACCEL_SUPERSAVAGE 0x8c /* S3 Supersavage */
133#define FB_ACCEL_PROSAVAGE_DDR 0x8d /* S3 ProSavage DDR */
134#define FB_ACCEL_PROSAVAGE_DDRK 0x8e /* S3 ProSavage DDR-K */
135
136struct fb_fix_screeninfo {
137 char id[16]; /* identification string eg "TT Builtin" */
138 unsigned long smem_start; /* Start of frame buffer mem */
139 /* (physical address) */
140 __u32 smem_len; /* Length of frame buffer mem */
141 __u32 type; /* see FB_TYPE_* */
142 __u32 type_aux; /* Interleave for interleaved Planes */
143 __u32 visual; /* see FB_VISUAL_* */
144 __u16 xpanstep; /* zero if no hardware panning */
145 __u16 ypanstep; /* zero if no hardware panning */
146 __u16 ywrapstep; /* zero if no hardware ywrap */
147 __u32 line_length; /* length of a line in bytes */
148 unsigned long mmio_start; /* Start of Memory Mapped I/O */
149 /* (physical address) */
150 __u32 mmio_len; /* Length of Memory Mapped I/O */
151 __u32 accel; /* Indicate to driver which */
152 /* specific chip/card we have */
153 __u16 reserved[3]; /* Reserved for future compatibility */
154};
155
156/* Interpretation of offset for color fields: All offsets are from the right,
157 * inside a "pixel" value, which is exactly 'bits_per_pixel' wide (means: you
158 * can use the offset as right argument to <<). A pixel afterwards is a bit
159 * stream and is written to video memory as that unmodified. This implies
160 * big-endian byte order if bits_per_pixel is greater than 8.
161 */
162struct fb_bitfield {
163 __u32 offset; /* beginning of bitfield */
164 __u32 length; /* length of bitfield */
165 __u32 msb_right; /* != 0 : Most significant bit is */
166 /* right */
167};
168
169#define FB_NONSTD_HAM 1 /* Hold-And-Modify (HAM) */
170
171#define FB_ACTIVATE_NOW 0 /* set values immediately (or vbl)*/
172#define FB_ACTIVATE_NXTOPEN 1 /* activate on next open */
173#define FB_ACTIVATE_TEST 2 /* don't set, round up impossible */
174#define FB_ACTIVATE_MASK 15
175 /* values */
176#define FB_ACTIVATE_VBL 16 /* activate values on next vbl */
177#define FB_CHANGE_CMAP_VBL 32 /* change colormap on vbl */
178#define FB_ACTIVATE_ALL 64 /* change all VCs on this fb */
179#define FB_ACTIVATE_FORCE 128 /* force apply even when no change*/
180#define FB_ACTIVATE_INV_MODE 256 /* invalidate videomode */
181
182#define FB_ACCELF_TEXT 1 /* (OBSOLETE) see fb_info.flags and vc_mode */
183
184#define FB_SYNC_HOR_HIGH_ACT 1 /* horizontal sync high active */
185#define FB_SYNC_VERT_HIGH_ACT 2 /* vertical sync high active */
186#define FB_SYNC_EXT 4 /* external sync */
187#define FB_SYNC_COMP_HIGH_ACT 8 /* composite sync high active */
188#define FB_SYNC_BROADCAST 16 /* broadcast video timings */
189 /* vtotal = 144d/288n/576i => PAL */
190 /* vtotal = 121d/242n/484i => NTSC */
191#define FB_SYNC_ON_GREEN 32 /* sync on green */
192
193#define FB_VMODE_NONINTERLACED 0 /* non interlaced */
194#define FB_VMODE_INTERLACED 1 /* interlaced */
195#define FB_VMODE_DOUBLE 2 /* double scan */
196#define FB_VMODE_MASK 255
197
198#define FB_VMODE_YWRAP 256 /* ywrap instead of panning */
199#define FB_VMODE_SMOOTH_XPAN 512 /* smooth xpan possible (internally used) */
200#define FB_VMODE_CONUPDATE 512 /* don't update x/yoffset */
201
202#define PICOS2KHZ(a) (1000000000UL/(a))
203#define KHZ2PICOS(a) (1000000000UL/(a))
204
205struct fb_var_screeninfo {
206 __u32 xres; /* visible resolution */
207 __u32 yres;
208 __u32 xres_virtual; /* virtual resolution */
209 __u32 yres_virtual;
210 __u32 xoffset; /* offset from virtual to visible */
211 __u32 yoffset; /* resolution */
212
213 __u32 bits_per_pixel; /* guess what */
214 __u32 grayscale; /* != 0 Graylevels instead of colors */
215
216 struct fb_bitfield red; /* bitfield in fb mem if true color, */
217 struct fb_bitfield green; /* else only length is significant */
218 struct fb_bitfield blue;
219 struct fb_bitfield transp; /* transparency */
220
221 __u32 nonstd; /* != 0 Non standard pixel format */
222
223 __u32 activate; /* see FB_ACTIVATE_* */
224
225 __u32 height; /* height of picture in mm */
226 __u32 width; /* width of picture in mm */
227
228 __u32 accel_flags; /* (OBSOLETE) see fb_info.flags */
229
230 /* Timing: All values in pixclocks, except pixclock (of course) */
231 __u32 pixclock; /* pixel clock in ps (pico seconds) */
232 __u32 left_margin; /* time from sync to picture */
233 __u32 right_margin; /* time from picture to sync */
234 __u32 upper_margin; /* time from sync to picture */
235 __u32 lower_margin;
236 __u32 hsync_len; /* length of horizontal sync */
237 __u32 vsync_len; /* length of vertical sync */
238 __u32 sync; /* see FB_SYNC_* */
239 __u32 vmode; /* see FB_VMODE_* */
240 __u32 rotate; /* angle we rotate counter clockwise */
241 __u32 reserved[5]; /* Reserved for future compatibility */
242};
243
244struct fb_cmap {
245 __u32 start; /* First entry */
246 __u32 len; /* Number of entries */
247 __u16 *red; /* Red values */
248 __u16 *green;
249 __u16 *blue;
250 __u16 *transp; /* transparency, can be NULL */
251};
252
253struct fb_con2fbmap {
254 __u32 console;
255 __u32 framebuffer;
256};
257
258/* VESA Blanking Levels */
259#define VESA_NO_BLANKING 0
260#define VESA_VSYNC_SUSPEND 1
261#define VESA_HSYNC_SUSPEND 2
262#define VESA_POWERDOWN 3
263
264
265enum {
266 /* screen: unblanked, hsync: on, vsync: on */
267 FB_BLANK_UNBLANK = VESA_NO_BLANKING,
268
269 /* screen: blanked, hsync: on, vsync: on */
270 FB_BLANK_NORMAL = VESA_NO_BLANKING + 1,
271
272 /* screen: blanked, hsync: on, vsync: off */
273 FB_BLANK_VSYNC_SUSPEND = VESA_VSYNC_SUSPEND + 1,
274
275 /* screen: blanked, hsync: off, vsync: on */
276 FB_BLANK_HSYNC_SUSPEND = VESA_HSYNC_SUSPEND + 1,
277
278 /* screen: blanked, hsync: off, vsync: off */
279 FB_BLANK_POWERDOWN = VESA_POWERDOWN + 1
280};
281
282#define FB_VBLANK_VBLANKING 0x001 /* currently in a vertical blank */
283#define FB_VBLANK_HBLANKING 0x002 /* currently in a horizontal blank */
284#define FB_VBLANK_HAVE_VBLANK 0x004 /* vertical blanks can be detected */
285#define FB_VBLANK_HAVE_HBLANK 0x008 /* horizontal blanks can be detected */
286#define FB_VBLANK_HAVE_COUNT 0x010 /* global retrace counter is available */
287#define FB_VBLANK_HAVE_VCOUNT 0x020 /* the vcount field is valid */
288#define FB_VBLANK_HAVE_HCOUNT 0x040 /* the hcount field is valid */
289#define FB_VBLANK_VSYNCING 0x080 /* currently in a vsync */
290#define FB_VBLANK_HAVE_VSYNC 0x100 /* verical syncs can be detected */
291
292struct fb_vblank {
293 __u32 flags; /* FB_VBLANK flags */
294 __u32 count; /* counter of retraces since boot */
295 __u32 vcount; /* current scanline position */
296 __u32 hcount; /* current scandot position */
297 __u32 reserved[4]; /* reserved for future compatibility */
298};
299
300/* Internal HW accel */
301#define ROP_COPY 0
302#define ROP_XOR 1
303
304struct fb_copyarea {
305 __u32 dx;
306 __u32 dy;
307 __u32 width;
308 __u32 height;
309 __u32 sx;
310 __u32 sy;
311};
312
313struct fb_fillrect {
314 __u32 dx; /* screen-relative */
315 __u32 dy;
316 __u32 width;
317 __u32 height;
318 __u32 color;
319 __u32 rop;
320};
321
322struct fb_image {
323 __u32 dx; /* Where to place image */
324 __u32 dy;
325 __u32 width; /* Size of image */
326 __u32 height;
327 __u32 fg_color; /* Only used when a mono bitmap */
328 __u32 bg_color;
329 __u8 depth; /* Depth of the image */
330 const char *data; /* Pointer to image data */
331 struct fb_cmap cmap; /* color map info */
332};
333
334/*
335 * hardware cursor control
336 */
337
338#define FB_CUR_SETIMAGE 0x01
339#define FB_CUR_SETPOS 0x02
340#define FB_CUR_SETHOT 0x04
341#define FB_CUR_SETCMAP 0x08
342#define FB_CUR_SETSHAPE 0x10
343#define FB_CUR_SETSIZE 0x20
344#define FB_CUR_SETALL 0xFF
345
346struct fbcurpos {
347 __u16 x, y;
348};
349
350struct fb_cursor {
351 __u16 set; /* what to set */
352 __u16 enable; /* cursor on/off */
353 __u16 rop; /* bitop operation */
354 const char *mask; /* cursor mask bits */
355 struct fbcurpos hot; /* cursor hot spot */
356 struct fb_image image; /* Cursor image */
357};
358
359#ifdef __KERNEL__
360
361#include <linux/fs.h>
362#include <linux/init.h>
363#include <linux/tty.h>
364#include <linux/device.h>
365#include <linux/workqueue.h>
366#include <linux/devfs_fs_kernel.h>
367#include <linux/notifier.h>
368#include <linux/list.h>
369#include <asm/io.h>
370
371struct vm_area_struct;
372struct fb_info;
373struct device;
374struct file;
375
376/* Definitions below are used in the parsed monitor specs */
377#define FB_DPMS_ACTIVE_OFF 1
378#define FB_DPMS_SUSPEND 2
379#define FB_DPMS_STANDBY 4
380
381#define FB_DISP_DDI 1
382#define FB_DISP_ANA_700_300 2
383#define FB_DISP_ANA_714_286 4
384#define FB_DISP_ANA_1000_400 8
385#define FB_DISP_ANA_700_000 16
386
387#define FB_DISP_MONO 32
388#define FB_DISP_RGB 64
389#define FB_DISP_MULTI 128
390#define FB_DISP_UNKNOWN 256
391
392#define FB_SIGNAL_NONE 0
393#define FB_SIGNAL_BLANK_BLANK 1
394#define FB_SIGNAL_SEPARATE 2
395#define FB_SIGNAL_COMPOSITE 4
396#define FB_SIGNAL_SYNC_ON_GREEN 8
397#define FB_SIGNAL_SERRATION_ON 16
398
399#define FB_MISC_PRIM_COLOR 1
400#define FB_MISC_1ST_DETAIL 2 /* First Detailed Timing is preferred */
401struct fb_chroma {
402 __u32 redx; /* in fraction of 1024 */
403 __u32 greenx;
404 __u32 bluex;
405 __u32 whitex;
406 __u32 redy;
407 __u32 greeny;
408 __u32 bluey;
409 __u32 whitey;
410};
411
412struct fb_monspecs {
413 struct fb_chroma chroma;
414 struct fb_videomode *modedb; /* mode database */
415 __u8 manufacturer[4]; /* Manufacturer */
416 __u8 monitor[14]; /* Monitor String */
417 __u8 serial_no[14]; /* Serial Number */
418 __u8 ascii[14]; /* ? */
419 __u32 modedb_len; /* mode database length */
420 __u32 model; /* Monitor Model */
421 __u32 serial; /* Serial Number - Integer */
422 __u32 year; /* Year manufactured */
423 __u32 week; /* Week Manufactured */
424 __u32 hfmin; /* hfreq lower limit (Hz) */
425 __u32 hfmax; /* hfreq upper limit (Hz) */
426 __u32 dclkmin; /* pixelclock lower limit (Hz) */
427 __u32 dclkmax; /* pixelclock upper limit (Hz) */
428 __u16 input; /* display type - see FB_DISP_* */
429 __u16 dpms; /* DPMS support - see FB_DPMS_ */
430 __u16 signal; /* Signal Type - see FB_SIGNAL_* */
431 __u16 vfmin; /* vfreq lower limit (Hz) */
432 __u16 vfmax; /* vfreq upper limit (Hz) */
433 __u16 gamma; /* Gamma - in fractions of 100 */
434 __u16 gtf : 1; /* supports GTF */
435 __u16 misc; /* Misc flags - see FB_MISC_* */
436 __u8 version; /* EDID version... */
437 __u8 revision; /* ...and revision */
438 __u8 max_x; /* Maximum horizontal size (cm) */
439 __u8 max_y; /* Maximum vertical size (cm) */
440};
441
442struct fb_cmap_user {
443 __u32 start; /* First entry */
444 __u32 len; /* Number of entries */
445 __u16 __user *red; /* Red values */
446 __u16 __user *green;
447 __u16 __user *blue;
448 __u16 __user *transp; /* transparency, can be NULL */
449};
450
451struct fb_image_user {
452 __u32 dx; /* Where to place image */
453 __u32 dy;
454 __u32 width; /* Size of image */
455 __u32 height;
456 __u32 fg_color; /* Only used when a mono bitmap */
457 __u32 bg_color;
458 __u8 depth; /* Depth of the image */
459 const char __user *data; /* Pointer to image data */
460 struct fb_cmap_user cmap; /* color map info */
461};
462
463struct fb_cursor_user {
464 __u16 set; /* what to set */
465 __u16 enable; /* cursor on/off */
466 __u16 rop; /* bitop operation */
467 const char __user *mask; /* cursor mask bits */
468 struct fbcurpos hot; /* cursor hot spot */
469 struct fb_image_user image; /* Cursor image */
470};
471
472/*
473 * Register/unregister for framebuffer events
474 */
475
476/* The resolution of the passed in fb_info about to change */
477#define FB_EVENT_MODE_CHANGE 0x01
478/* The display on this fb_info is beeing suspended, no access to the
479 * framebuffer is allowed any more after that call returns
480 */
481#define FB_EVENT_SUSPEND 0x02
482/* The display on this fb_info was resumed, you can restore the display
483 * if you own it
484 */
485#define FB_EVENT_RESUME 0x03
486/* An entry from the modelist was removed */
487#define FB_EVENT_MODE_DELETE 0x04
488/* A driver registered itself */
489#define FB_EVENT_FB_REGISTERED 0x05
490/* get console to framebuffer mapping */
491#define FB_EVENT_GET_CONSOLE_MAP 0x06
492/* set console to framebuffer mapping */
493#define FB_EVENT_SET_CONSOLE_MAP 0x07
494/* A display blank is requested */
495#define FB_EVENT_BLANK 0x08
496/* Private modelist is to be replaced */
497#define FB_EVENT_NEW_MODELIST 0x09
498
499struct fb_event {
500 struct fb_info *info;
501 void *data;
502};
503
504
505extern int fb_register_client(struct notifier_block *nb);
506extern int fb_unregister_client(struct notifier_block *nb);
507
508/*
509 * Pixmap structure definition
510 *
511 * The purpose of this structure is to translate data
512 * from the hardware independent format of fbdev to what
513 * format the hardware needs.
514 */
515
516#define FB_PIXMAP_DEFAULT 1 /* used internally by fbcon */
517#define FB_PIXMAP_SYSTEM 2 /* memory is in system RAM */
518#define FB_PIXMAP_IO 4 /* memory is iomapped */
519#define FB_PIXMAP_SYNC 256 /* set if GPU can DMA */
520
521struct fb_pixmap {
522 u8 *addr; /* pointer to memory */
523 u32 size; /* size of buffer in bytes */
524 u32 offset; /* current offset to buffer */
525 u32 buf_align; /* byte alignment of each bitmap */
526 u32 scan_align; /* alignment per scanline */
527 u32 access_align; /* alignment per read/write */
528 u32 flags; /* see FB_PIXMAP_* */
529 /* access methods */
530 void (*outbuf)(struct fb_info *info, u8 *addr, u8 *src, unsigned int size);
531 u8 (*inbuf) (struct fb_info *info, u8 *addr);
532};
533
534
535/*
536 * Frame buffer operations
537 *
538 * LOCKING NOTE: those functions must _ALL_ be called with the console
539 * semaphore held, this is the only suitable locking mecanism we have
540 * in 2.6. Some may be called at interrupt time at this point though.
541 */
542
543struct fb_ops {
544 /* open/release and usage marking */
545 struct module *owner;
546 int (*fb_open)(struct fb_info *info, int user);
547 int (*fb_release)(struct fb_info *info, int user);
548
549 /* For framebuffers with strange non linear layouts or that do not
550 * work with normal memory mapped access
551 */
552 ssize_t (*fb_read)(struct file *file, char __user *buf, size_t count, loff_t *ppos);
553 ssize_t (*fb_write)(struct file *file, const char __user *buf, size_t count, loff_t *ppos);
554
555 /* checks var and eventually tweaks it to something supported,
556 * DO NOT MODIFY PAR */
557 int (*fb_check_var)(struct fb_var_screeninfo *var, struct fb_info *info);
558
559 /* set the video mode according to info->var */
560 int (*fb_set_par)(struct fb_info *info);
561
562 /* set color register */
563 int (*fb_setcolreg)(unsigned regno, unsigned red, unsigned green,
564 unsigned blue, unsigned transp, struct fb_info *info);
565
566 /* blank display */
567 int (*fb_blank)(int blank, struct fb_info *info);
568
569 /* pan display */
570 int (*fb_pan_display)(struct fb_var_screeninfo *var, struct fb_info *info);
571
572 /* Draws a rectangle */
573 void (*fb_fillrect) (struct fb_info *info, const struct fb_fillrect *rect);
574 /* Copy data from area to another */
575 void (*fb_copyarea) (struct fb_info *info, const struct fb_copyarea *region);
576 /* Draws a image to the display */
577 void (*fb_imageblit) (struct fb_info *info, const struct fb_image *image);
578
579 /* Draws cursor */
580 int (*fb_cursor) (struct fb_info *info, struct fb_cursor *cursor);
581
582 /* Rotates the display */
583 void (*fb_rotate)(struct fb_info *info, int angle);
584
585 /* wait for blit idle, optional */
586 int (*fb_sync)(struct fb_info *info);
587
588 /* perform fb specific ioctl (optional) */
589 int (*fb_ioctl)(struct inode *inode, struct file *file, unsigned int cmd,
590 unsigned long arg, struct fb_info *info);
591
592 /* Handle 32bit compat ioctl (optional) */
593 long (*fb_compat_ioctl)(struct file *f, unsigned cmd, unsigned long arg,
594 struct fb_info *info);
595
596 /* perform fb specific mmap */
597 int (*fb_mmap)(struct fb_info *info, struct file *file, struct vm_area_struct *vma);
598};
599
600#ifdef CONFIG_FB_TILEBLITTING
601
602#define FB_TILE_CURSOR_NONE 0
603#define FB_TILE_CURSOR_UNDERLINE 1
604#define FB_TILE_CURSOR_LOWER_THIRD 2
605#define FB_TILE_CURSOR_LOWER_HALF 3
606#define FB_TILE_CURSOR_TWO_THIRDS 4
607#define FB_TILE_CURSOR_BLOCK 5
608
609struct fb_tilemap {
610 __u32 width; /* width of each tile in pixels */
611 __u32 height; /* height of each tile in scanlines */
612 __u32 depth; /* color depth of each tile */
613 __u32 length; /* number of tiles in the map */
614 __u8 *data; /* actual tile map: a bitmap array, packed
615 to the nearest byte */
616};
617
618struct fb_tilerect {
619 __u32 sx; /* origin in the x-axis */
620 __u32 sy; /* origin in the y-axis */
621 __u32 width; /* number of tiles in the x-axis */
622 __u32 height; /* number of tiles in the y-axis */
623 __u32 index; /* what tile to use: index to tile map */
624 __u32 fg; /* foreground color */
625 __u32 bg; /* background color */
626 __u32 rop; /* raster operation */
627};
628
629struct fb_tilearea {
630 __u32 sx; /* source origin in the x-axis */
631 __u32 sy; /* source origin in the y-axis */
632 __u32 dx; /* destination origin in the x-axis */
633 __u32 dy; /* destination origin in the y-axis */
634 __u32 width; /* number of tiles in the x-axis */
635 __u32 height; /* number of tiles in the y-axis */
636};
637
638struct fb_tileblit {
639 __u32 sx; /* origin in the x-axis */
640 __u32 sy; /* origin in the y-axis */
641 __u32 width; /* number of tiles in the x-axis */
642 __u32 height; /* number of tiles in the y-axis */
643 __u32 fg; /* foreground color */
644 __u32 bg; /* background color */
645 __u32 length; /* number of tiles to draw */
646 __u32 *indices; /* array of indices to tile map */
647};
648
649struct fb_tilecursor {
650 __u32 sx; /* cursor position in the x-axis */
651 __u32 sy; /* cursor position in the y-axis */
652 __u32 mode; /* 0 = erase, 1 = draw */
653 __u32 shape; /* see FB_TILE_CURSOR_* */
654 __u32 fg; /* foreground color */
655 __u32 bg; /* background color */
656};
657
658struct fb_tile_ops {
659 /* set tile characteristics */
660 void (*fb_settile)(struct fb_info *info, struct fb_tilemap *map);
661
662 /* all dimensions from hereon are in terms of tiles */
663
664 /* move a rectangular region of tiles from one area to another*/
665 void (*fb_tilecopy)(struct fb_info *info, struct fb_tilearea *area);
666 /* fill a rectangular region with a tile */
667 void (*fb_tilefill)(struct fb_info *info, struct fb_tilerect *rect);
668 /* copy an array of tiles */
669 void (*fb_tileblit)(struct fb_info *info, struct fb_tileblit *blit);
670 /* cursor */
671 void (*fb_tilecursor)(struct fb_info *info,
672 struct fb_tilecursor *cursor);
673};
674#endif /* CONFIG_FB_TILEBLITTING */
675
676/* FBINFO_* = fb_info.flags bit flags */
677#define FBINFO_MODULE 0x0001 /* Low-level driver is a module */
678#define FBINFO_HWACCEL_DISABLED 0x0002
679 /* When FBINFO_HWACCEL_DISABLED is set:
680 * Hardware acceleration is turned off. Software implementations
681 * of required functions (copyarea(), fillrect(), and imageblit())
682 * takes over; acceleration engine should be in a quiescent state */
683
684/* hints */
685#define FBINFO_PARTIAL_PAN_OK 0x0040 /* otw use pan only for double-buffering */
686#define FBINFO_READS_FAST 0x0080 /* soft-copy faster than rendering */
687
688/* hardware supported ops */
689/* semantics: when a bit is set, it indicates that the operation is
690 * accelerated by hardware.
691 * required functions will still work even if the bit is not set.
692 * optional functions may not even exist if the flag bit is not set.
693 */
694#define FBINFO_HWACCEL_NONE 0x0000
695#define FBINFO_HWACCEL_COPYAREA 0x0100 /* required */
696#define FBINFO_HWACCEL_FILLRECT 0x0200 /* required */
697#define FBINFO_HWACCEL_IMAGEBLIT 0x0400 /* required */
698#define FBINFO_HWACCEL_ROTATE 0x0800 /* optional */
699#define FBINFO_HWACCEL_XPAN 0x1000 /* optional */
700#define FBINFO_HWACCEL_YPAN 0x2000 /* optional */
701#define FBINFO_HWACCEL_YWRAP 0x4000 /* optional */
702
703#define FBINFO_MISC_USEREVENT 0x10000 /* event request
704 from userspace */
705#define FBINFO_MISC_TILEBLITTING 0x20000 /* use tile blitting */
706
707struct fb_info {
708 int node;
709 int flags;
710 struct fb_var_screeninfo var; /* Current var */
711 struct fb_fix_screeninfo fix; /* Current fix */
712 struct fb_monspecs monspecs; /* Current Monitor specs */
713 struct work_struct queue; /* Framebuffer event queue */
714 struct fb_pixmap pixmap; /* Image hardware mapper */
715 struct fb_pixmap sprite; /* Cursor hardware mapper */
716 struct fb_cmap cmap; /* Current cmap */
717 struct list_head modelist; /* mode list */
718 struct fb_videomode *mode; /* current mode */
719 struct fb_ops *fbops;
720 struct device *device;
721 struct class_device *class_device; /* sysfs per device attrs */
722#ifdef CONFIG_FB_TILEBLITTING
723 struct fb_tile_ops *tileops; /* Tile Blitting */
724#endif
725 char __iomem *screen_base; /* Virtual address */
726 unsigned long screen_size; /* Amount of ioremapped VRAM or 0 */
727 void *pseudo_palette; /* Fake palette of 16 colors */
728#define FBINFO_STATE_RUNNING 0
729#define FBINFO_STATE_SUSPENDED 1
730 u32 state; /* Hardware state i.e suspend */
731 void *fbcon_par; /* fbcon use-only private area */
732 /* From here on everything is device dependent */
733 void *par;
734};
735
736#ifdef MODULE
737#define FBINFO_DEFAULT FBINFO_MODULE
738#else
739#define FBINFO_DEFAULT 0
740#endif
741
742// This will go away
743#define FBINFO_FLAG_MODULE FBINFO_MODULE
744#define FBINFO_FLAG_DEFAULT FBINFO_DEFAULT
745
746/* This will go away
747 * fbset currently hacks in FB_ACCELF_TEXT into var.accel_flags
748 * when it wants to turn the acceleration engine on. This is
749 * really a separate operation, and should be modified via sysfs.
750 * But for now, we leave it broken with the following define
751 */
752#define STUPID_ACCELF_TEXT_SHIT
753
754// This will go away
755#if defined(__sparc__)
756
757/* We map all of our framebuffers such that big-endian accesses
758 * are what we want, so the following is sufficient.
759 */
760
761// This will go away
762#define fb_readb sbus_readb
763#define fb_readw sbus_readw
764#define fb_readl sbus_readl
765#define fb_readq sbus_readq
766#define fb_writeb sbus_writeb
767#define fb_writew sbus_writew
768#define fb_writel sbus_writel
769#define fb_writeq sbus_writeq
770#define fb_memset sbus_memset_io
771
772#elif defined(__i386__) || defined(__alpha__) || defined(__x86_64__) || defined(__hppa__) || (defined(__sh__) && !defined(__SH5__)) || defined(__powerpc__)
773
774#define fb_readb __raw_readb
775#define fb_readw __raw_readw
776#define fb_readl __raw_readl
777#define fb_readq __raw_readq
778#define fb_writeb __raw_writeb
779#define fb_writew __raw_writew
780#define fb_writel __raw_writel
781#define fb_writeq __raw_writeq
782#define fb_memset memset_io
783
784#else
785
786#define fb_readb(addr) (*(volatile u8 *) (addr))
787#define fb_readw(addr) (*(volatile u16 *) (addr))
788#define fb_readl(addr) (*(volatile u32 *) (addr))
789#define fb_readq(addr) (*(volatile u64 *) (addr))
790#define fb_writeb(b,addr) (*(volatile u8 *) (addr) = (b))
791#define fb_writew(b,addr) (*(volatile u16 *) (addr) = (b))
792#define fb_writel(b,addr) (*(volatile u32 *) (addr) = (b))
793#define fb_writeq(b,addr) (*(volatile u64 *) (addr) = (b))
794#define fb_memset memset
795
796#endif
797
798 /*
799 * `Generic' versions of the frame buffer device operations
800 */
801
802extern int fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var);
803extern int fb_pan_display(struct fb_info *info, struct fb_var_screeninfo *var);
804extern int fb_blank(struct fb_info *info, int blank);
805extern int soft_cursor(struct fb_info *info, struct fb_cursor *cursor);
806extern void cfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect);
807extern void cfb_copyarea(struct fb_info *info, const struct fb_copyarea *area);
808extern void cfb_imageblit(struct fb_info *info, const struct fb_image *image);
809
810/* drivers/video/fbmem.c */
811extern int register_framebuffer(struct fb_info *fb_info);
812extern int unregister_framebuffer(struct fb_info *fb_info);
813extern int fb_prepare_logo(struct fb_info *fb_info);
814extern int fb_show_logo(struct fb_info *fb_info);
815extern char* fb_get_buffer_offset(struct fb_info *info, struct fb_pixmap *buf, u32 size);
816extern void fb_iomove_buf_unaligned(struct fb_info *info, struct fb_pixmap *buf,
817 u8 *dst, u32 d_pitch, u8 *src, u32 idx,
818 u32 height, u32 shift_high, u32 shift_low, u32 mod);
819extern void fb_iomove_buf_aligned(struct fb_info *info, struct fb_pixmap *buf,
820 u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch,
821 u32 height);
822extern void fb_sysmove_buf_unaligned(struct fb_info *info, struct fb_pixmap *buf,
823 u8 *dst, u32 d_pitch, u8 *src, u32 idx,
824 u32 height, u32 shift_high, u32 shift_low, u32 mod);
825extern void fb_sysmove_buf_aligned(struct fb_info *info, struct fb_pixmap *buf,
826 u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch,
827 u32 height);
828extern void fb_set_suspend(struct fb_info *info, int state);
829extern int fb_get_color_depth(struct fb_var_screeninfo *var);
830extern int fb_get_options(char *name, char **option);
831extern int fb_new_modelist(struct fb_info *info);
832
833extern struct fb_info *registered_fb[FB_MAX];
834extern int num_registered_fb;
835
836/* drivers/video/fbsysfs.c */
837extern struct fb_info *framebuffer_alloc(size_t size, struct device *dev);
838extern void framebuffer_release(struct fb_info *info);
839extern int fb_init_class_device(struct fb_info *fb_info);
840extern void fb_cleanup_class_device(struct fb_info *head);
841
842/* drivers/video/fbmon.c */
843#define FB_MAXTIMINGS 0
844#define FB_VSYNCTIMINGS 1
845#define FB_HSYNCTIMINGS 2
846#define FB_DCLKTIMINGS 3
847#define FB_IGNOREMON 0x100
848
849#define FB_MODE_IS_UNKNOWN 0
850#define FB_MODE_IS_DETAILED 1
851#define FB_MODE_IS_STANDARD 2
852#define FB_MODE_IS_VESA 4
853#define FB_MODE_IS_CALCULATED 8
854#define FB_MODE_IS_FIRST 16
855#define FB_MODE_IS_FROM_VAR 32
856
857extern int fbmon_valid_timings(u_int pixclock, u_int htotal, u_int vtotal,
858 const struct fb_info *fb_info);
859extern int fbmon_dpms(const struct fb_info *fb_info);
860extern int fb_get_mode(int flags, u32 val, struct fb_var_screeninfo *var,
861 struct fb_info *info);
862extern int fb_validate_mode(const struct fb_var_screeninfo *var,
863 struct fb_info *info);
864extern int fb_parse_edid(unsigned char *edid, struct fb_var_screeninfo *var);
865extern void fb_edid_to_monspecs(unsigned char *edid, struct fb_monspecs *specs);
866extern void fb_destroy_modedb(struct fb_videomode *modedb);
867
868/* drivers/video/modedb.c */
869#define VESA_MODEDB_SIZE 34
870extern void fb_var_to_videomode(struct fb_videomode *mode,
871 struct fb_var_screeninfo *var);
872extern void fb_videomode_to_var(struct fb_var_screeninfo *var,
873 struct fb_videomode *mode);
874extern int fb_mode_is_equal(struct fb_videomode *mode1,
875 struct fb_videomode *mode2);
876extern int fb_add_videomode(struct fb_videomode *mode, struct list_head *head);
877extern void fb_delete_videomode(struct fb_videomode *mode,
878 struct list_head *head);
879extern struct fb_videomode *fb_match_mode(struct fb_var_screeninfo *var,
880 struct list_head *head);
881extern struct fb_videomode *fb_find_best_mode(struct fb_var_screeninfo *var,
882 struct list_head *head);
883extern struct fb_videomode *fb_find_nearest_mode(struct fb_var_screeninfo *var,
884 struct list_head *head);
885extern void fb_destroy_modelist(struct list_head *head);
886extern void fb_videomode_to_modelist(struct fb_videomode *modedb, int num,
887 struct list_head *head);
888
889/* drivers/video/fbcmap.c */
890extern int fb_alloc_cmap(struct fb_cmap *cmap, int len, int transp);
891extern void fb_dealloc_cmap(struct fb_cmap *cmap);
892extern int fb_copy_cmap(struct fb_cmap *from, struct fb_cmap *to);
893extern int fb_cmap_to_user(struct fb_cmap *from, struct fb_cmap_user *to);
894extern int fb_set_cmap(struct fb_cmap *cmap, struct fb_info *fb_info);
895extern int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *fb_info);
896extern struct fb_cmap *fb_default_cmap(int len);
897extern void fb_invert_cmaps(void);
898
899struct fb_videomode {
900 const char *name; /* optional */
901 u32 refresh; /* optional */
902 u32 xres;
903 u32 yres;
904 u32 pixclock;
905 u32 left_margin;
906 u32 right_margin;
907 u32 upper_margin;
908 u32 lower_margin;
909 u32 hsync_len;
910 u32 vsync_len;
911 u32 sync;
912 u32 vmode;
913 u32 flag;
914};
915
916extern const struct fb_videomode vesa_modes[];
917
918struct fb_modelist {
919 struct list_head list;
920 struct fb_videomode mode;
921};
922
923extern int fb_find_mode(struct fb_var_screeninfo *var,
924 struct fb_info *info, const char *mode_option,
925 const struct fb_videomode *db,
926 unsigned int dbsize,
927 const struct fb_videomode *default_mode,
928 unsigned int default_bpp);
929
930#endif /* __KERNEL__ */
931
932#endif /* _LINUX_FB_H */
diff --git a/include/linux/fcdevice.h b/include/linux/fcdevice.h
new file mode 100644
index 000000000000..e460ef831984
--- /dev/null
+++ b/include/linux/fcdevice.h
@@ -0,0 +1,33 @@
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. NET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Definitions for the Fibre Channel handlers.
7 *
8 * Version: @(#)fcdevice.h 1.0.0 09/26/98
9 *
10 * Authors: Vineet Abraham <vma@iol.unh.edu>
11 *
12 * Relocated to include/linux where it belongs by Alan Cox
13 * <gw4pts@gw4pts.ampr.org>
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version
18 * 2 of the License, or (at your option) any later version.
19 *
20 * WARNING: This move may well be temporary. This file will get merged with others RSN.
21 *
22 */
23#ifndef _LINUX_FCDEVICE_H
24#define _LINUX_FCDEVICE_H
25
26
27#include <linux/if_fc.h>
28
29#ifdef __KERNEL__
30extern struct net_device *alloc_fcdev(int sizeof_priv);
31#endif
32
33#endif /* _LINUX_FCDEVICE_H */
diff --git a/include/linux/fcntl.h b/include/linux/fcntl.h
new file mode 100644
index 000000000000..704fb76b6334
--- /dev/null
+++ b/include/linux/fcntl.h
@@ -0,0 +1,50 @@
1#ifndef _LINUX_FCNTL_H
2#define _LINUX_FCNTL_H
3
4#include <asm/fcntl.h>
5
6#define F_SETLEASE (F_LINUX_SPECIFIC_BASE+0)
7#define F_GETLEASE (F_LINUX_SPECIFIC_BASE+1)
8
9/*
10 * Request nofications on a directory.
11 * See below for events that may be notified.
12 */
13#define F_NOTIFY (F_LINUX_SPECIFIC_BASE+2)
14
15/*
16 * Types of directory notifications that may be requested.
17 */
18#define DN_ACCESS 0x00000001 /* File accessed */
19#define DN_MODIFY 0x00000002 /* File modified */
20#define DN_CREATE 0x00000004 /* File created */
21#define DN_DELETE 0x00000008 /* File removed */
22#define DN_RENAME 0x00000010 /* File renamed */
23#define DN_ATTRIB 0x00000020 /* File changed attibutes */
24#define DN_MULTISHOT 0x80000000 /* Don't remove notifier */
25
26#ifdef __KERNEL__
27
28#if BITS_PER_LONG == 32
29#define IS_GETLK32(cmd) ((cmd) == F_GETLK)
30#define IS_SETLK32(cmd) ((cmd) == F_SETLK)
31#define IS_SETLKW32(cmd) ((cmd) == F_SETLKW)
32#define IS_GETLK64(cmd) ((cmd) == F_GETLK64)
33#define IS_SETLK64(cmd) ((cmd) == F_SETLK64)
34#define IS_SETLKW64(cmd) ((cmd) == F_SETLKW64)
35#else
36#define IS_GETLK32(cmd) (0)
37#define IS_SETLK32(cmd) (0)
38#define IS_SETLKW32(cmd) (0)
39#define IS_GETLK64(cmd) ((cmd) == F_GETLK)
40#define IS_SETLK64(cmd) ((cmd) == F_SETLK)
41#define IS_SETLKW64(cmd) ((cmd) == F_SETLKW)
42#endif /* BITS_PER_LONG == 32 */
43
44#define IS_GETLK(cmd) (IS_GETLK32(cmd) || IS_GETLK64(cmd))
45#define IS_SETLK(cmd) (IS_SETLK32(cmd) || IS_SETLK64(cmd))
46#define IS_SETLKW(cmd) (IS_SETLKW32(cmd) || IS_SETLKW64(cmd))
47
48#endif /* __KERNEL__ */
49
50#endif
diff --git a/include/linux/fd.h b/include/linux/fd.h
new file mode 100644
index 000000000000..b6bd41d2b460
--- /dev/null
+++ b/include/linux/fd.h
@@ -0,0 +1,374 @@
1#ifndef _LINUX_FD_H
2#define _LINUX_FD_H
3
4#include <linux/ioctl.h>
5#include <linux/compiler.h>
6
7/* New file layout: Now the ioctl definitions immediately follow the
8 * definitions of the structures that they use */
9
10/*
11 * Geometry
12 */
13struct floppy_struct {
14 unsigned int size, /* nr of sectors total */
15 sect, /* sectors per track */
16 head, /* nr of heads */
17 track, /* nr of tracks */
18 stretch; /* !=0 means double track steps */
19#define FD_STRETCH 1
20#define FD_SWAPSIDES 2
21#define FD_ZEROBASED 4
22
23 unsigned char gap, /* gap1 size */
24
25 rate, /* data rate. |= 0x40 for perpendicular */
26#define FD_2M 0x4
27#define FD_SIZECODEMASK 0x38
28#define FD_SIZECODE(floppy) (((((floppy)->rate&FD_SIZECODEMASK)>> 3)+ 2) %8)
29#define FD_SECTSIZE(floppy) ( (floppy)->rate & FD_2M ? \
30 512 : 128 << FD_SIZECODE(floppy) )
31#define FD_PERP 0x40
32
33 spec1, /* stepping rate, head unload time */
34 fmt_gap; /* gap2 size */
35 const char * name; /* used only for predefined formats */
36};
37
38
39/* commands needing write access have 0x40 set */
40/* commands needing super user access have 0x80 set */
41
42#define FDCLRPRM _IO(2, 0x41)
43/* clear user-defined parameters */
44
45#define FDSETPRM _IOW(2, 0x42, struct floppy_struct)
46#define FDSETMEDIAPRM FDSETPRM
47/* set user-defined parameters for current media */
48
49#define FDDEFPRM _IOW(2, 0x43, struct floppy_struct)
50#define FDGETPRM _IOR(2, 0x04, struct floppy_struct)
51#define FDDEFMEDIAPRM FDDEFPRM
52#define FDGETMEDIAPRM FDGETPRM
53/* set/get disk parameters */
54
55
56#define FDMSGON _IO(2,0x45)
57#define FDMSGOFF _IO(2,0x46)
58/* issue/don't issue kernel messages on media type change */
59
60
61/*
62 * Formatting (obsolete)
63 */
64#define FD_FILL_BYTE 0xF6 /* format fill byte. */
65
66struct format_descr {
67 unsigned int device,head,track;
68};
69
70#define FDFMTBEG _IO(2,0x47)
71/* begin formatting a disk */
72#define FDFMTTRK _IOW(2,0x48, struct format_descr)
73/* format the specified track */
74#define FDFMTEND _IO(2,0x49)
75/* end formatting a disk */
76
77
78/*
79 * Error thresholds
80 */
81struct floppy_max_errors {
82 unsigned int
83 abort, /* number of errors to be reached before aborting */
84 read_track, /* maximal number of errors permitted to read an
85 * entire track at once */
86 reset, /* maximal number of errors before a reset is tried */
87 recal, /* maximal number of errors before a recalibrate is
88 * tried */
89
90 /*
91 * Threshold for reporting FDC errors to the console.
92 * Setting this to zero may flood your screen when using
93 * ultra cheap floppies ;-)
94 */
95 reporting;
96
97};
98
99#define FDSETEMSGTRESH _IO(2,0x4a)
100/* set fdc error reporting threshold */
101
102#define FDFLUSH _IO(2,0x4b)
103/* flush buffers for media; either for verifying media, or for
104 * handling a media change without closing the file descriptor */
105
106#define FDSETMAXERRS _IOW(2, 0x4c, struct floppy_max_errors)
107#define FDGETMAXERRS _IOR(2, 0x0e, struct floppy_max_errors)
108/* set/get abortion and read_track threshold. See also floppy_drive_params
109 * structure */
110
111
112typedef char floppy_drive_name[16];
113#define FDGETDRVTYP _IOR(2, 0x0f, floppy_drive_name)
114/* get drive type: 5 1/4 or 3 1/2 */
115
116
117/*
118 * Drive parameters (user modifiable)
119 */
120struct floppy_drive_params {
121 signed char cmos; /* CMOS type */
122
123 /* Spec2 is (HLD<<1 | ND), where HLD is head load time (1=2ms, 2=4 ms
124 * etc) and ND is set means no DMA. Hardcoded to 6 (HLD=6ms, use DMA).
125 */
126 unsigned long max_dtr; /* Step rate, usec */
127 unsigned long hlt; /* Head load/settle time, msec */
128 unsigned long hut; /* Head unload time (remnant of
129 * 8" drives) */
130 unsigned long srt; /* Step rate, usec */
131
132 unsigned long spinup; /* time needed for spinup (expressed
133 * in jiffies) */
134 unsigned long spindown; /* timeout needed for spindown */
135 unsigned char spindown_offset; /* decides in which position the disk
136 * will stop */
137 unsigned char select_delay; /* delay to wait after select */
138 unsigned char rps; /* rotations per second */
139 unsigned char tracks; /* maximum number of tracks */
140 unsigned long timeout; /* timeout for interrupt requests */
141
142 unsigned char interleave_sect; /* if there are more sectors, use
143 * interleave */
144
145 struct floppy_max_errors max_errors;
146
147 char flags; /* various flags, including ftd_msg */
148/*
149 * Announce successful media type detection and media information loss after
150 * disk changes.
151 * Also used to enable/disable printing of overrun warnings.
152 */
153
154#define FTD_MSG 0x10
155#define FD_BROKEN_DCL 0x20
156#define FD_DEBUG 0x02
157#define FD_SILENT_DCL_CLEAR 0x4
158#define FD_INVERTED_DCL 0x80 /* must be 0x80, because of hardware
159 considerations */
160
161 char read_track; /* use readtrack during probing? */
162
163/*
164 * Auto-detection. Each drive type has eight formats which are
165 * used in succession to try to read the disk. If the FDC cannot lock onto
166 * the disk, the next format is tried. This uses the variable 'probing'.
167 */
168 short autodetect[8]; /* autodetected formats */
169
170 int checkfreq; /* how often should the drive be checked for disk
171 * changes */
172 int native_format; /* native format of this drive */
173};
174
175enum {
176 FD_NEED_TWADDLE_BIT, /* more magic */
177 FD_VERIFY_BIT, /* inquire for write protection */
178 FD_DISK_NEWCHANGE_BIT, /* change detected, and no action undertaken yet
179 * to clear media change status */
180 FD_UNUSED_BIT,
181 FD_DISK_CHANGED_BIT, /* disk has been changed since last i/o */
182 FD_DISK_WRITABLE_BIT /* disk is writable */
183};
184
185#define FDSETDRVPRM _IOW(2, 0x90, struct floppy_drive_params)
186#define FDGETDRVPRM _IOR(2, 0x11, struct floppy_drive_params)
187/* set/get drive parameters */
188
189
190/*
191 * Current drive state (not directly modifiable by user, readonly)
192 */
193struct floppy_drive_struct {
194 unsigned long flags;
195/* values for these flags */
196#define FD_NEED_TWADDLE (1 << FD_NEED_TWADDLE_BIT)
197#define FD_VERIFY (1 << FD_VERIFY_BIT)
198#define FD_DISK_NEWCHANGE (1 << FD_DISK_NEWCHANGE_BIT)
199#define FD_DISK_CHANGED (1 << FD_DISK_CHANGED_BIT)
200#define FD_DISK_WRITABLE (1 << FD_DISK_WRITABLE_BIT)
201
202 unsigned long spinup_date;
203 unsigned long select_date;
204 unsigned long first_read_date;
205 short probed_format;
206 short track; /* current track */
207 short maxblock; /* id of highest block read */
208 short maxtrack; /* id of highest half track read */
209 int generation; /* how many diskchanges? */
210
211/*
212 * (User-provided) media information is _not_ discarded after a media change
213 * if the corresponding keep_data flag is non-zero. Positive values are
214 * decremented after each probe.
215 */
216 int keep_data;
217
218 /* Prevent "aliased" accesses. */
219 int fd_ref;
220 int fd_device;
221 unsigned long last_checked; /* when was the drive last checked for a disk
222 * change? */
223
224 char *dmabuf;
225 int bufblocks;
226};
227
228#define FDGETDRVSTAT _IOR(2, 0x12, struct floppy_drive_struct)
229#define FDPOLLDRVSTAT _IOR(2, 0x13, struct floppy_drive_struct)
230/* get drive state: GET returns the cached state, POLL polls for new state */
231
232
233/*
234 * reset FDC
235 */
236enum reset_mode {
237 FD_RESET_IF_NEEDED, /* reset only if the reset flags is set */
238 FD_RESET_IF_RAWCMD, /* obsolete */
239 FD_RESET_ALWAYS /* reset always */
240};
241#define FDRESET _IO(2, 0x54)
242
243
244/*
245 * FDC state
246 */
247struct floppy_fdc_state {
248 int spec1; /* spec1 value last used */
249 int spec2; /* spec2 value last used */
250 int dtr;
251 unsigned char version; /* FDC version code */
252 unsigned char dor;
253 unsigned long address; /* io address */
254 unsigned int rawcmd:2;
255 unsigned int reset:1;
256 unsigned int need_configure:1;
257 unsigned int perp_mode:2;
258 unsigned int has_fifo:1;
259 unsigned int driver_version; /* version code for floppy driver */
260#define FD_DRIVER_VERSION 0x100
261/* user programs using the floppy API should use floppy_fdc_state to
262 * get the version number of the floppy driver that they are running
263 * on. If this version number is bigger than the one compiled into the
264 * user program (the FD_DRIVER_VERSION define), it should be prepared
265 * to bigger structures
266 */
267
268 unsigned char track[4];
269 /* Position of the heads of the 4 units attached to this FDC,
270 * as stored on the FDC. In the future, the position as stored
271 * on the FDC might not agree with the actual physical
272 * position of these drive heads. By allowing such
273 * disagreement, it will be possible to reset the FDC without
274 * incurring the expensive cost of repositioning all heads.
275 * Right now, these positions are hard wired to 0. */
276
277};
278
279#define FDGETFDCSTAT _IOR(2, 0x15, struct floppy_fdc_state)
280
281
282/*
283 * Asynchronous Write error tracking
284 */
285struct floppy_write_errors {
286 /* Write error logging.
287 *
288 * These fields can be cleared with the FDWERRORCLR ioctl.
289 * Only writes that were attempted but failed due to a physical media
290 * error are logged. write(2) calls that fail and return an error code
291 * to the user process are not counted.
292 */
293
294 unsigned int write_errors; /* number of physical write errors
295 * encountered */
296
297 /* position of first and last write errors */
298 unsigned long first_error_sector;
299 int first_error_generation;
300 unsigned long last_error_sector;
301 int last_error_generation;
302
303 unsigned int badness; /* highest retry count for a read or write
304 * operation */
305};
306
307#define FDWERRORCLR _IO(2, 0x56)
308/* clear write error and badness information */
309#define FDWERRORGET _IOR(2, 0x17, struct floppy_write_errors)
310/* get write error and badness information */
311
312
313/*
314 * Raw commands
315 */
316/* new interface flag: now we can do them in batches */
317#define FDHAVEBATCHEDRAWCMD
318
319struct floppy_raw_cmd {
320 unsigned int flags;
321#define FD_RAW_READ 1
322#define FD_RAW_WRITE 2
323#define FD_RAW_NO_MOTOR 4
324#define FD_RAW_DISK_CHANGE 4 /* out: disk change flag was set */
325#define FD_RAW_INTR 8 /* wait for an interrupt */
326#define FD_RAW_SPIN 0x10 /* spin up the disk for this command */
327#define FD_RAW_NO_MOTOR_AFTER 0x20 /* switch the motor off after command
328 * completion */
329#define FD_RAW_NEED_DISK 0x40 /* this command needs a disk to be present */
330#define FD_RAW_NEED_SEEK 0x80 /* this command uses an implied seek (soft) */
331
332/* more "in" flags */
333#define FD_RAW_MORE 0x100 /* more records follow */
334#define FD_RAW_STOP_IF_FAILURE 0x200 /* stop if we encounter a failure */
335#define FD_RAW_STOP_IF_SUCCESS 0x400 /* stop if command successful */
336#define FD_RAW_SOFTFAILURE 0x800 /* consider the return value for failure
337 * detection too */
338
339/* more "out" flags */
340#define FD_RAW_FAILURE 0x10000 /* command sent to fdc, fdc returned error */
341#define FD_RAW_HARDFAILURE 0x20000 /* fdc had to be reset, or timed out */
342
343 void __user *data;
344 char *kernel_data; /* location of data buffer in the kernel */
345 struct floppy_raw_cmd *next; /* used for chaining of raw cmd's
346 * within the kernel */
347 long length; /* in: length of dma transfer. out: remaining bytes */
348 long phys_length; /* physical length, if different from dma length */
349 int buffer_length; /* length of allocated buffer */
350
351 unsigned char rate;
352 unsigned char cmd_count;
353 unsigned char cmd[16];
354 unsigned char reply_count;
355 unsigned char reply[16];
356 int track;
357 int resultcode;
358
359 int reserved1;
360 int reserved2;
361};
362
363#define FDRAWCMD _IO(2, 0x58)
364/* send a raw command to the fdc. Structure size not included, because of
365 * batches */
366
367#define FDTWADDLE _IO(2, 0x59)
368/* flicker motor-on bit before reading a sector. Experimental */
369
370
371#define FDEJECT _IO(2, 0x5a)
372/* eject the disk */
373
374#endif
diff --git a/include/linux/fd1772.h b/include/linux/fd1772.h
new file mode 100644
index 000000000000..871d6e4c677e
--- /dev/null
+++ b/include/linux/fd1772.h
@@ -0,0 +1,80 @@
1#ifndef _LINUX_FD1772REG_H
2#define _LINUX_FD1772REG_H
3
4/*
5** WD1772 stuff - originally from the M68K Linux
6 * Modified for Archimedes by Dave Gilbert (gilbertd@cs.man.ac.uk)
7 */
8
9/* register codes */
10
11#define FDC1772SELREG_STP (0x80) /* command/status register */
12#define FDC1772SELREG_TRA (0x82) /* track register */
13#define FDC1772SELREG_SEC (0x84) /* sector register */
14#define FDC1772SELREG_DTA (0x86) /* data register */
15
16/* register names for FDC1772_READ/WRITE macros */
17
18#define FDC1772REG_CMD 0
19#define FDC1772REG_STATUS 0
20#define FDC1772REG_TRACK 2
21#define FDC1772REG_SECTOR 4
22#define FDC1772REG_DATA 6
23
24/* command opcodes */
25
26#define FDC1772CMD_RESTORE (0x00) /* - */
27#define FDC1772CMD_SEEK (0x10) /* | */
28#define FDC1772CMD_STEP (0x20) /* | TYP 1 Commands */
29#define FDC1772CMD_STIN (0x40) /* | */
30#define FDC1772CMD_STOT (0x60) /* - */
31#define FDC1772CMD_RDSEC (0x80) /* - TYP 2 Commands */
32#define FDC1772CMD_WRSEC (0xa0) /* - " */
33#define FDC1772CMD_RDADR (0xc0) /* - */
34#define FDC1772CMD_RDTRA (0xe0) /* | TYP 3 Commands */
35#define FDC1772CMD_WRTRA (0xf0) /* - */
36#define FDC1772CMD_FORCI (0xd0) /* - TYP 4 Command */
37
38/* command modifier bits */
39
40#define FDC1772CMDADD_SR6 (0x00) /* step rate settings */
41#define FDC1772CMDADD_SR12 (0x01)
42#define FDC1772CMDADD_SR2 (0x02)
43#define FDC1772CMDADD_SR3 (0x03)
44#define FDC1772CMDADD_V (0x04) /* verify */
45#define FDC1772CMDADD_H (0x08) /* wait for spin-up */
46#define FDC1772CMDADD_U (0x10) /* update track register */
47#define FDC1772CMDADD_M (0x10) /* multiple sector access */
48#define FDC1772CMDADD_E (0x04) /* head settling flag */
49#define FDC1772CMDADD_P (0x02) /* precompensation */
50#define FDC1772CMDADD_A0 (0x01) /* DAM flag */
51
52/* status register bits */
53
54#define FDC1772STAT_MOTORON (0x80) /* motor on */
55#define FDC1772STAT_WPROT (0x40) /* write protected (FDC1772CMD_WR*) */
56#define FDC1772STAT_SPINUP (0x20) /* motor speed stable (Type I) */
57#define FDC1772STAT_DELDAM (0x20) /* sector has deleted DAM (Type II+III) */
58#define FDC1772STAT_RECNF (0x10) /* record not found */
59#define FDC1772STAT_CRC (0x08) /* CRC error */
60#define FDC1772STAT_TR00 (0x04) /* Track 00 flag (Type I) */
61#define FDC1772STAT_LOST (0x04) /* Lost Data (Type II+III) */
62#define FDC1772STAT_IDX (0x02) /* Index status (Type I) */
63#define FDC1772STAT_DRQ (0x02) /* DRQ status (Type II+III) */
64#define FDC1772STAT_BUSY (0x01) /* FDC1772 is busy */
65
66
67/* PSG Port A Bit Nr 0 .. Side Sel .. 0 -> Side 1 1 -> Side 2 */
68#define DSKSIDE (0x01)
69
70#define DSKDRVNONE (0x06)
71#define DSKDRV0 (0x02)
72#define DSKDRV1 (0x04)
73
74/* step rates */
75#define FDC1772STEP_6 0x00
76#define FDC1772STEP_12 0x01
77#define FDC1772STEP_2 0x02
78#define FDC1772STEP_3 0x03
79
80#endif
diff --git a/include/linux/fddidevice.h b/include/linux/fddidevice.h
new file mode 100644
index 000000000000..2e5ee47f3e1e
--- /dev/null
+++ b/include/linux/fddidevice.h
@@ -0,0 +1,33 @@
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Definitions for the FDDI handlers.
7 *
8 * Version: @(#)fddidevice.h 1.0.0 08/12/96
9 *
10 * Author: Lawrence V. Stefani, <stefani@lkg.dec.com>
11 *
12 * fddidevice.h is based on previous trdevice.h work by
13 * Ross Biro, <bir7@leland.Stanford.Edu>
14 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
15 * Alan Cox, <gw4pts@gw4pts.ampr.org>
16 *
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License
19 * as published by the Free Software Foundation; either version
20 * 2 of the License, or (at your option) any later version.
21 */
22#ifndef _LINUX_FDDIDEVICE_H
23#define _LINUX_FDDIDEVICE_H
24
25#include <linux/if_fddi.h>
26
27#ifdef __KERNEL__
28extern unsigned short fddi_type_trans(struct sk_buff *skb,
29 struct net_device *dev);
30extern struct net_device *alloc_fddidev(int sizeof_priv);
31#endif
32
33#endif /* _LINUX_FDDIDEVICE_H */
diff --git a/include/linux/fdreg.h b/include/linux/fdreg.h
new file mode 100644
index 000000000000..c2eeb63b72db
--- /dev/null
+++ b/include/linux/fdreg.h
@@ -0,0 +1,137 @@
1#ifndef _LINUX_FDREG_H
2#define _LINUX_FDREG_H
3/*
4 * This file contains some defines for the floppy disk controller.
5 * Various sources. Mostly "IBM Microcomputers: A Programmers
6 * Handbook", Sanches and Canton.
7 */
8
9#ifdef FDPATCHES
10#define FD_IOPORT fdc_state[fdc].address
11#else
12/* It would be a lot saner just to force fdc_state[fdc].address to always
13 be set ! FIXME */
14#define FD_IOPORT 0x3f0
15#endif
16
17/* Fd controller regs. S&C, about page 340 */
18#define FD_STATUS (4 + FD_IOPORT )
19#define FD_DATA (5 + FD_IOPORT )
20
21/* Digital Output Register */
22#define FD_DOR (2 + FD_IOPORT )
23
24/* Digital Input Register (read) */
25#define FD_DIR (7 + FD_IOPORT )
26
27/* Diskette Control Register (write)*/
28#define FD_DCR (7 + FD_IOPORT )
29
30/* Bits of main status register */
31#define STATUS_BUSYMASK 0x0F /* drive busy mask */
32#define STATUS_BUSY 0x10 /* FDC busy */
33#define STATUS_DMA 0x20 /* 0- DMA mode */
34#define STATUS_DIR 0x40 /* 0- cpu->fdc */
35#define STATUS_READY 0x80 /* Data reg ready */
36
37/* Bits of FD_ST0 */
38#define ST0_DS 0x03 /* drive select mask */
39#define ST0_HA 0x04 /* Head (Address) */
40#define ST0_NR 0x08 /* Not Ready */
41#define ST0_ECE 0x10 /* Equipment check error */
42#define ST0_SE 0x20 /* Seek end */
43#define ST0_INTR 0xC0 /* Interrupt code mask */
44
45/* Bits of FD_ST1 */
46#define ST1_MAM 0x01 /* Missing Address Mark */
47#define ST1_WP 0x02 /* Write Protect */
48#define ST1_ND 0x04 /* No Data - unreadable */
49#define ST1_OR 0x10 /* OverRun */
50#define ST1_CRC 0x20 /* CRC error in data or addr */
51#define ST1_EOC 0x80 /* End Of Cylinder */
52
53/* Bits of FD_ST2 */
54#define ST2_MAM 0x01 /* Missing Address Mark (again) */
55#define ST2_BC 0x02 /* Bad Cylinder */
56#define ST2_SNS 0x04 /* Scan Not Satisfied */
57#define ST2_SEH 0x08 /* Scan Equal Hit */
58#define ST2_WC 0x10 /* Wrong Cylinder */
59#define ST2_CRC 0x20 /* CRC error in data field */
60#define ST2_CM 0x40 /* Control Mark = deleted */
61
62/* Bits of FD_ST3 */
63#define ST3_HA 0x04 /* Head (Address) */
64#define ST3_DS 0x08 /* drive is double-sided */
65#define ST3_TZ 0x10 /* Track Zero signal (1=track 0) */
66#define ST3_RY 0x20 /* drive is ready */
67#define ST3_WP 0x40 /* Write Protect */
68#define ST3_FT 0x80 /* Drive Fault */
69
70/* Values for FD_COMMAND */
71#define FD_RECALIBRATE 0x07 /* move to track 0 */
72#define FD_SEEK 0x0F /* seek track */
73#define FD_READ 0xE6 /* read with MT, MFM, SKip deleted */
74#define FD_WRITE 0xC5 /* write with MT, MFM */
75#define FD_SENSEI 0x08 /* Sense Interrupt Status */
76#define FD_SPECIFY 0x03 /* specify HUT etc */
77#define FD_FORMAT 0x4D /* format one track */
78#define FD_VERSION 0x10 /* get version code */
79#define FD_CONFIGURE 0x13 /* configure FIFO operation */
80#define FD_PERPENDICULAR 0x12 /* perpendicular r/w mode */
81#define FD_GETSTATUS 0x04 /* read ST3 */
82#define FD_DUMPREGS 0x0E /* dump the contents of the fdc regs */
83#define FD_READID 0xEA /* prints the header of a sector */
84#define FD_UNLOCK 0x14 /* Fifo config unlock */
85#define FD_LOCK 0x94 /* Fifo config lock */
86#define FD_RSEEK_OUT 0x8f /* seek out (i.e. to lower tracks) */
87#define FD_RSEEK_IN 0xcf /* seek in (i.e. to higher tracks) */
88
89/* the following commands are new in the 82078. They are not used in the
90 * floppy driver, except the first three. These commands may be useful for apps
91 * which use the FDRAWCMD interface. For doc, get the 82078 spec sheets at
92 * http://www-techdoc.intel.com/docs/periph/fd_contr/datasheets/ */
93
94#define FD_PARTID 0x18 /* part id ("extended" version cmd) */
95#define FD_SAVE 0x2e /* save fdc regs for later restore */
96#define FD_DRIVESPEC 0x8e /* drive specification: Access to the
97 * 2 Mbps data transfer rate for tape
98 * drives */
99
100#define FD_RESTORE 0x4e /* later restore */
101#define FD_POWERDOWN 0x27 /* configure FDC's powersave features */
102#define FD_FORMAT_N_WRITE 0xef /* format and write in one go. */
103#define FD_OPTION 0x33 /* ISO format (which is a clean way to
104 * pack more sectors on a track) */
105
106/* DMA commands */
107#define DMA_READ 0x46
108#define DMA_WRITE 0x4A
109
110/* FDC version return types */
111#define FDC_NONE 0x00
112#define FDC_UNKNOWN 0x10 /* DO NOT USE THIS TYPE EXCEPT IF IDENTIFICATION
113 FAILS EARLY */
114#define FDC_8272A 0x20 /* Intel 8272a, NEC 765 */
115#define FDC_765ED 0x30 /* Non-Intel 1MB-compatible FDC, can't detect */
116#define FDC_82072 0x40 /* Intel 82072; 8272a + FIFO + DUMPREGS */
117#define FDC_82072A 0x45 /* 82072A (on Sparcs) */
118#define FDC_82077_ORIG 0x51 /* Original version of 82077AA, sans LOCK */
119#define FDC_82077 0x52 /* 82077AA-1 */
120#define FDC_82078_UNKN 0x5f /* Unknown 82078 variant */
121#define FDC_82078 0x60 /* 44pin 82078 or 64pin 82078SL */
122#define FDC_82078_1 0x61 /* 82078-1 (2Mbps fdc) */
123#define FDC_S82078B 0x62 /* S82078B (first seen on Adaptec AVA-2825 VLB
124 * SCSI/EIDE/Floppy controller) */
125#define FDC_87306 0x63 /* National Semiconductor PC 87306 */
126
127/*
128 * Beware: the fdc type list is roughly sorted by increasing features.
129 * Presence of features is tested by comparing the FDC version id with the
130 * "oldest" version that has the needed feature.
131 * If during FDC detection, an obscure test fails late in the sequence, don't
132 * assign FDC_UNKNOWN. Else the FDC will be treated as a dumb 8272a, or worse.
133 * This is especially true if the tests are unneeded.
134 */
135
136#define FD_RESET_DELAY 20
137#endif
diff --git a/include/linux/file.h b/include/linux/file.h
new file mode 100644
index 000000000000..5206beb9a80e
--- /dev/null
+++ b/include/linux/file.h
@@ -0,0 +1,84 @@
1/*
2 * Wrapper functions for accessing the file_struct fd array.
3 */
4
5#ifndef __LINUX_FILE_H
6#define __LINUX_FILE_H
7
8#include <asm/atomic.h>
9#include <linux/posix_types.h>
10#include <linux/compiler.h>
11#include <linux/spinlock.h>
12
13/*
14 * The default fd array needs to be at least BITS_PER_LONG,
15 * as this is the granularity returned by copy_fdset().
16 */
17#define NR_OPEN_DEFAULT BITS_PER_LONG
18
19/*
20 * Open file table structure
21 */
22struct files_struct {
23 atomic_t count;
24 spinlock_t file_lock; /* Protects all the below members. Nests inside tsk->alloc_lock */
25 int max_fds;
26 int max_fdset;
27 int next_fd;
28 struct file ** fd; /* current fd array */
29 fd_set *close_on_exec;
30 fd_set *open_fds;
31 fd_set close_on_exec_init;
32 fd_set open_fds_init;
33 struct file * fd_array[NR_OPEN_DEFAULT];
34};
35
36extern void FASTCALL(__fput(struct file *));
37extern void FASTCALL(fput(struct file *));
38
39static inline void fput_light(struct file *file, int fput_needed)
40{
41 if (unlikely(fput_needed))
42 fput(file);
43}
44
45extern struct file * FASTCALL(fget(unsigned int fd));
46extern struct file * FASTCALL(fget_light(unsigned int fd, int *fput_needed));
47extern void FASTCALL(set_close_on_exec(unsigned int fd, int flag));
48extern void put_filp(struct file *);
49extern int get_unused_fd(void);
50extern void FASTCALL(put_unused_fd(unsigned int fd));
51struct kmem_cache_s;
52extern void filp_ctor(void * objp, struct kmem_cache_s *cachep, unsigned long cflags);
53extern void filp_dtor(void * objp, struct kmem_cache_s *cachep, unsigned long dflags);
54
55extern struct file ** alloc_fd_array(int);
56extern void free_fd_array(struct file **, int);
57
58extern fd_set *alloc_fdset(int);
59extern void free_fdset(fd_set *, int);
60
61extern int expand_files(struct files_struct *, int nr);
62
63static inline struct file * fcheck_files(struct files_struct *files, unsigned int fd)
64{
65 struct file * file = NULL;
66
67 if (fd < files->max_fds)
68 file = files->fd[fd];
69 return file;
70}
71
72/*
73 * Check whether the specified fd has an open file.
74 */
75#define fcheck(fd) fcheck_files(current->files, fd)
76
77extern void FASTCALL(fd_install(unsigned int fd, struct file * file));
78
79struct task_struct;
80
81struct files_struct *get_files_struct(struct task_struct *);
82void FASTCALL(put_files_struct(struct files_struct *fs));
83
84#endif /* __LINUX_FILE_H */
diff --git a/include/linux/filter.h b/include/linux/filter.h
new file mode 100644
index 000000000000..3ba843c46382
--- /dev/null
+++ b/include/linux/filter.h
@@ -0,0 +1,151 @@
1/*
2 * Linux Socket Filter Data Structures
3 */
4
5#ifndef __LINUX_FILTER_H__
6#define __LINUX_FILTER_H__
7
8#include <linux/compiler.h>
9#include <linux/types.h>
10
11#ifdef __KERNEL__
12#include <asm/atomic.h>
13#endif
14
15/*
16 * Current version of the filter code architecture.
17 */
18#define BPF_MAJOR_VERSION 1
19#define BPF_MINOR_VERSION 1
20
21/*
22 * Try and keep these values and structures similar to BSD, especially
23 * the BPF code definitions which need to match so you can share filters
24 */
25
26struct sock_filter /* Filter block */
27{
28 __u16 code; /* Actual filter code */
29 __u8 jt; /* Jump true */
30 __u8 jf; /* Jump false */
31 __u32 k; /* Generic multiuse field */
32};
33
34struct sock_fprog /* Required for SO_ATTACH_FILTER. */
35{
36 unsigned short len; /* Number of filter blocks */
37 struct sock_filter __user *filter;
38};
39
40#ifdef __KERNEL__
41struct sk_filter
42{
43 atomic_t refcnt;
44 unsigned int len; /* Number of filter blocks */
45 struct sock_filter insns[0];
46};
47
48static inline unsigned int sk_filter_len(struct sk_filter *fp)
49{
50 return fp->len*sizeof(struct sock_filter) + sizeof(*fp);
51}
52#endif
53
54/*
55 * Instruction classes
56 */
57
58#define BPF_CLASS(code) ((code) & 0x07)
59#define BPF_LD 0x00
60#define BPF_LDX 0x01
61#define BPF_ST 0x02
62#define BPF_STX 0x03
63#define BPF_ALU 0x04
64#define BPF_JMP 0x05
65#define BPF_RET 0x06
66#define BPF_MISC 0x07
67
68/* ld/ldx fields */
69#define BPF_SIZE(code) ((code) & 0x18)
70#define BPF_W 0x00
71#define BPF_H 0x08
72#define BPF_B 0x10
73#define BPF_MODE(code) ((code) & 0xe0)
74#define BPF_IMM 0x00
75#define BPF_ABS 0x20
76#define BPF_IND 0x40
77#define BPF_MEM 0x60
78#define BPF_LEN 0x80
79#define BPF_MSH 0xa0
80
81/* alu/jmp fields */
82#define BPF_OP(code) ((code) & 0xf0)
83#define BPF_ADD 0x00
84#define BPF_SUB 0x10
85#define BPF_MUL 0x20
86#define BPF_DIV 0x30
87#define BPF_OR 0x40
88#define BPF_AND 0x50
89#define BPF_LSH 0x60
90#define BPF_RSH 0x70
91#define BPF_NEG 0x80
92#define BPF_JA 0x00
93#define BPF_JEQ 0x10
94#define BPF_JGT 0x20
95#define BPF_JGE 0x30
96#define BPF_JSET 0x40
97#define BPF_SRC(code) ((code) & 0x08)
98#define BPF_K 0x00
99#define BPF_X 0x08
100
101/* ret - BPF_K and BPF_X also apply */
102#define BPF_RVAL(code) ((code) & 0x18)
103#define BPF_A 0x10
104
105/* misc */
106#define BPF_MISCOP(code) ((code) & 0xf8)
107#define BPF_TAX 0x00
108#define BPF_TXA 0x80
109
110#ifndef BPF_MAXINSNS
111#define BPF_MAXINSNS 4096
112#endif
113
114/*
115 * Macros for filter block array initializers.
116 */
117#ifndef BPF_STMT
118#define BPF_STMT(code, k) { (unsigned short)(code), 0, 0, k }
119#endif
120#ifndef BPF_JUMP
121#define BPF_JUMP(code, k, jt, jf) { (unsigned short)(code), jt, jf, k }
122#endif
123
124/*
125 * Number of scratch memory words for: BPF_ST and BPF_STX
126 */
127#define BPF_MEMWORDS 16
128
129/* RATIONALE. Negative offsets are invalid in BPF.
130 We use them to reference ancillary data.
131 Unlike introduction new instructions, it does not break
132 existing compilers/optimizers.
133 */
134#define SKF_AD_OFF (-0x1000)
135#define SKF_AD_PROTOCOL 0
136#define SKF_AD_PKTTYPE 4
137#define SKF_AD_IFINDEX 8
138#define SKF_AD_MAX 12
139#define SKF_NET_OFF (-0x100000)
140#define SKF_LL_OFF (-0x200000)
141
142#ifdef __KERNEL__
143struct sk_buff;
144struct sock;
145
146extern int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int flen);
147extern int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk);
148extern int sk_chk_filter(struct sock_filter *filter, int flen);
149#endif /* __KERNEL__ */
150
151#endif /* __LINUX_FILTER_H__ */
diff --git a/include/linux/firmware.h b/include/linux/firmware.h
new file mode 100644
index 000000000000..886255b69bb9
--- /dev/null
+++ b/include/linux/firmware.h
@@ -0,0 +1,20 @@
1#ifndef _LINUX_FIRMWARE_H
2#define _LINUX_FIRMWARE_H
3#include <linux/module.h>
4#include <linux/types.h>
5#define FIRMWARE_NAME_MAX 30
6struct firmware {
7 size_t size;
8 u8 *data;
9};
10struct device;
11int request_firmware(const struct firmware **fw, const char *name,
12 struct device *device);
13int request_firmware_nowait(
14 struct module *module,
15 const char *name, struct device *device, void *context,
16 void (*cont)(const struct firmware *fw, void *context));
17
18void release_firmware(const struct firmware *fw);
19void register_firmware(const char *name, const u8 *data, size_t size);
20#endif
diff --git a/include/linux/flat.h b/include/linux/flat.h
new file mode 100644
index 000000000000..ec56852e2659
--- /dev/null
+++ b/include/linux/flat.h
@@ -0,0 +1,100 @@
1/*
2 * Copyright (C) 2002-2003 David McCullough <davidm@snapgear.com>
3 * Copyright (C) 1998 Kenneth Albanowski <kjahds@kjahds.com>
4 * The Silver Hammer Group, Ltd.
5 *
6 * This file provides the definitions and structures needed to
7 * support uClinux flat-format executables.
8 */
9
10#ifndef _LINUX_FLAT_H
11#define _LINUX_FLAT_H
12
13#ifdef __KERNEL__
14#include <asm/flat.h>
15#endif
16
17#define FLAT_VERSION 0x00000004L
18
19#ifdef CONFIG_BINFMT_SHARED_FLAT
20#define MAX_SHARED_LIBS (4)
21#else
22#define MAX_SHARED_LIBS (1)
23#endif
24
25/*
26 * To make everything easier to port and manage cross platform
27 * development, all fields are in network byte order.
28 */
29
30struct flat_hdr {
31 char magic[4];
32 unsigned long rev; /* version (as above) */
33 unsigned long entry; /* Offset of first executable instruction
34 with text segment from beginning of file */
35 unsigned long data_start; /* Offset of data segment from beginning of
36 file */
37 unsigned long data_end; /* Offset of end of data segment
38 from beginning of file */
39 unsigned long bss_end; /* Offset of end of bss segment from beginning
40 of file */
41
42 /* (It is assumed that data_end through bss_end forms the bss segment.) */
43
44 unsigned long stack_size; /* Size of stack, in bytes */
45 unsigned long reloc_start; /* Offset of relocation records from
46 beginning of file */
47 unsigned long reloc_count; /* Number of relocation records */
48 unsigned long flags;
49 unsigned long build_date; /* When the program/library was built */
50 unsigned long filler[5]; /* Reservered, set to zero */
51};
52
53#define FLAT_FLAG_RAM 0x0001 /* load program entirely into RAM */
54#define FLAT_FLAG_GOTPIC 0x0002 /* program is PIC with GOT */
55#define FLAT_FLAG_GZIP 0x0004 /* all but the header is compressed */
56#define FLAT_FLAG_GZDATA 0x0008 /* only data/relocs are compressed (for XIP) */
57#define FLAT_FLAG_KTRACE 0x0010 /* output useful kernel trace for debugging */
58
59
60#ifdef __KERNEL__ /* so systems without linux headers can compile the apps */
61/*
62 * While it would be nice to keep this header clean, users of older
63 * tools still need this support in the kernel. So this section is
64 * purely for compatibility with old tool chains.
65 *
66 * DO NOT make changes or enhancements to the old format please, just work
67 * with the format above, except to fix bugs with old format support.
68 */
69
70#include <asm/byteorder.h>
71
72#define OLD_FLAT_VERSION 0x00000002L
73#define OLD_FLAT_RELOC_TYPE_TEXT 0
74#define OLD_FLAT_RELOC_TYPE_DATA 1
75#define OLD_FLAT_RELOC_TYPE_BSS 2
76
77typedef union {
78 unsigned long value;
79 struct {
80# if defined(mc68000) && !defined(CONFIG_COLDFIRE)
81 signed long offset : 30;
82 unsigned long type : 2;
83# define OLD_FLAT_FLAG_RAM 0x1 /* load program entirely into RAM */
84# elif defined(__BIG_ENDIAN_BITFIELD)
85 unsigned long type : 2;
86 signed long offset : 30;
87# define OLD_FLAT_FLAG_RAM 0x1 /* load program entirely into RAM */
88# elif defined(__LITTLE_ENDIAN_BITFIELD)
89 signed long offset : 30;
90 unsigned long type : 2;
91# define OLD_FLAT_FLAG_RAM 0x1 /* load program entirely into RAM */
92# else
93# error "Unknown bitfield order for flat files."
94# endif
95 } reloc;
96} flat_v2_reloc_t;
97
98#endif /* __KERNEL__ */
99
100#endif /* _LINUX_FLAT_H */
diff --git a/include/linux/font.h b/include/linux/font.h
new file mode 100644
index 000000000000..fc2d690c9d5f
--- /dev/null
+++ b/include/linux/font.h
@@ -0,0 +1,53 @@
1/*
2 * font.h -- `Soft' font definitions
3 *
4 * Created 1995 by Geert Uytterhoeven
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#ifndef _VIDEO_FONT_H
12#define _VIDEO_FONT_H
13
14#include <linux/types.h>
15
16struct font_desc {
17 int idx;
18 char *name;
19 int width, height;
20 void *data;
21 int pref;
22};
23
24#define VGA8x8_IDX 0
25#define VGA8x16_IDX 1
26#define PEARL8x8_IDX 2
27#define VGA6x11_IDX 3
28#define SUN8x16_IDX 4
29#define SUN12x22_IDX 5
30#define ACORN8x8_IDX 6
31#define MINI4x6_IDX 7
32
33extern struct font_desc font_vga_8x8,
34 font_vga_8x16,
35 font_pearl_8x8,
36 font_vga_6x11,
37 font_sun_8x16,
38 font_sun_12x22,
39 font_acorn_8x8,
40 font_mini_4x6;
41
42/* Find a font with a specific name */
43
44extern struct font_desc *find_font(char *name);
45
46/* Get the default font for a specific screen size */
47
48extern struct font_desc *get_default_font(int xres, int yres);
49
50/* Max. length for the name of a predefined font */
51#define MAX_FONT_NAME 32
52
53#endif /* _VIDEO_FONT_H */
diff --git a/include/linux/fs.h b/include/linux/fs.h
new file mode 100644
index 000000000000..5df687d940fa
--- /dev/null
+++ b/include/linux/fs.h
@@ -0,0 +1,1677 @@
1#ifndef _LINUX_FS_H
2#define _LINUX_FS_H
3
4/*
5 * This file has definitions for some important file table
6 * structures etc.
7 */
8
9#include <linux/config.h>
10#include <linux/limits.h>
11#include <linux/ioctl.h>
12
13/*
14 * It's silly to have NR_OPEN bigger than NR_FILE, but you can change
15 * the file limit at runtime and only root can increase the per-process
16 * nr_file rlimit, so it's safe to set up a ridiculously high absolute
17 * upper limit on files-per-process.
18 *
19 * Some programs (notably those using select()) may have to be
20 * recompiled to take full advantage of the new limits..
21 */
22
23/* Fixed constants first: */
24#undef NR_OPEN
25#define NR_OPEN (1024*1024) /* Absolute upper limit on fd num */
26#define INR_OPEN 1024 /* Initial setting for nfile rlimits */
27
28#define BLOCK_SIZE_BITS 10
29#define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
30
31/* And dynamically-tunable limits and defaults: */
32struct files_stat_struct {
33 int nr_files; /* read only */
34 int nr_free_files; /* read only */
35 int max_files; /* tunable */
36};
37extern struct files_stat_struct files_stat;
38
39struct inodes_stat_t {
40 int nr_inodes;
41 int nr_unused;
42 int dummy[5];
43};
44extern struct inodes_stat_t inodes_stat;
45
46extern int leases_enable, lease_break_time;
47
48#ifdef CONFIG_DNOTIFY
49extern int dir_notify_enable;
50#endif
51
52#define NR_FILE 8192 /* this can well be larger on a larger system */
53
54#define MAY_EXEC 1
55#define MAY_WRITE 2
56#define MAY_READ 4
57#define MAY_APPEND 8
58
59#define FMODE_READ 1
60#define FMODE_WRITE 2
61
62/* Internal kernel extensions */
63#define FMODE_LSEEK 4
64#define FMODE_PREAD 8
65#define FMODE_PWRITE FMODE_PREAD /* These go hand in hand */
66
67#define RW_MASK 1
68#define RWA_MASK 2
69#define READ 0
70#define WRITE 1
71#define READA 2 /* read-ahead - don't block if no resources */
72#define SPECIAL 4 /* For non-blockdevice requests in request queue */
73#define READ_SYNC (READ | (1 << BIO_RW_SYNC))
74#define WRITE_SYNC (WRITE | (1 << BIO_RW_SYNC))
75#define WRITE_BARRIER ((1 << BIO_RW) | (1 << BIO_RW_BARRIER))
76
77#define SEL_IN 1
78#define SEL_OUT 2
79#define SEL_EX 4
80
81/* public flags for file_system_type */
82#define FS_REQUIRES_DEV 1
83#define FS_BINARY_MOUNTDATA 2
84#define FS_REVAL_DOT 16384 /* Check the paths ".", ".." for staleness */
85#define FS_ODD_RENAME 32768 /* Temporary stuff; will go away as soon
86 * as nfs_rename() will be cleaned up
87 */
88/*
89 * These are the fs-independent mount-flags: up to 32 flags are supported
90 */
91#define MS_RDONLY 1 /* Mount read-only */
92#define MS_NOSUID 2 /* Ignore suid and sgid bits */
93#define MS_NODEV 4 /* Disallow access to device special files */
94#define MS_NOEXEC 8 /* Disallow program execution */
95#define MS_SYNCHRONOUS 16 /* Writes are synced at once */
96#define MS_REMOUNT 32 /* Alter flags of a mounted FS */
97#define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
98#define MS_DIRSYNC 128 /* Directory modifications are synchronous */
99#define MS_NOATIME 1024 /* Do not update access times. */
100#define MS_NODIRATIME 2048 /* Do not update directory access times */
101#define MS_BIND 4096
102#define MS_MOVE 8192
103#define MS_REC 16384
104#define MS_VERBOSE 32768
105#define MS_POSIXACL (1<<16) /* VFS does not apply the umask */
106#define MS_ACTIVE (1<<30)
107#define MS_NOUSER (1<<31)
108
109/*
110 * Superblock flags that can be altered by MS_REMOUNT
111 */
112#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_NOATIME|\
113 MS_NODIRATIME)
114
115/*
116 * Old magic mount flag and mask
117 */
118#define MS_MGC_VAL 0xC0ED0000
119#define MS_MGC_MSK 0xffff0000
120
121/* Inode flags - they have nothing to superblock flags now */
122
123#define S_SYNC 1 /* Writes are synced at once */
124#define S_NOATIME 2 /* Do not update access times */
125#define S_APPEND 4 /* Append-only file */
126#define S_IMMUTABLE 8 /* Immutable file */
127#define S_DEAD 16 /* removed, but still open directory */
128#define S_NOQUOTA 32 /* Inode is not counted to quota */
129#define S_DIRSYNC 64 /* Directory modifications are synchronous */
130#define S_NOCMTIME 128 /* Do not update file c/mtime */
131#define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
132#define S_PRIVATE 512 /* Inode is fs-internal */
133
134/*
135 * Note that nosuid etc flags are inode-specific: setting some file-system
136 * flags just means all the inodes inherit those flags by default. It might be
137 * possible to override it selectively if you really wanted to with some
138 * ioctl() that is not currently implemented.
139 *
140 * Exception: MS_RDONLY is always applied to the entire file system.
141 *
142 * Unfortunately, it is possible to change a filesystems flags with it mounted
143 * with files in use. This means that all of the inodes will not have their
144 * i_flags updated. Hence, i_flags no longer inherit the superblock mount
145 * flags, so these have to be checked separately. -- rmk@arm.uk.linux.org
146 */
147#define __IS_FLG(inode,flg) ((inode)->i_sb->s_flags & (flg))
148
149#define IS_RDONLY(inode) ((inode)->i_sb->s_flags & MS_RDONLY)
150#define IS_SYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS) || \
151 ((inode)->i_flags & S_SYNC))
152#define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
153 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
154#define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
155
156#define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
157#define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
158#define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
159#define IS_NOATIME(inode) (__IS_FLG(inode, MS_NOATIME) || ((inode)->i_flags & S_NOATIME))
160#define IS_NODIRATIME(inode) __IS_FLG(inode, MS_NODIRATIME)
161#define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
162
163#define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
164#define IS_NOCMTIME(inode) ((inode)->i_flags & S_NOCMTIME)
165#define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
166#define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
167
168/* the read-only stuff doesn't really belong here, but any other place is
169 probably as bad and I don't want to create yet another include file. */
170
171#define BLKROSET _IO(0x12,93) /* set device read-only (0 = read-write) */
172#define BLKROGET _IO(0x12,94) /* get read-only status (0 = read_write) */
173#define BLKRRPART _IO(0x12,95) /* re-read partition table */
174#define BLKGETSIZE _IO(0x12,96) /* return device size /512 (long *arg) */
175#define BLKFLSBUF _IO(0x12,97) /* flush buffer cache */
176#define BLKRASET _IO(0x12,98) /* set read ahead for block device */
177#define BLKRAGET _IO(0x12,99) /* get current read ahead setting */
178#define BLKFRASET _IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
179#define BLKFRAGET _IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
180#define BLKSECTSET _IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
181#define BLKSECTGET _IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
182#define BLKSSZGET _IO(0x12,104)/* get block device sector size */
183#if 0
184#define BLKPG _IO(0x12,105)/* See blkpg.h */
185
186/* Some people are morons. Do not use sizeof! */
187
188#define BLKELVGET _IOR(0x12,106,size_t)/* elevator get */
189#define BLKELVSET _IOW(0x12,107,size_t)/* elevator set */
190/* This was here just to show that the number is taken -
191 probably all these _IO(0x12,*) ioctls should be moved to blkpg.h. */
192#endif
193/* A jump here: 108-111 have been used for various private purposes. */
194#define BLKBSZGET _IOR(0x12,112,size_t)
195#define BLKBSZSET _IOW(0x12,113,size_t)
196#define BLKGETSIZE64 _IOR(0x12,114,size_t) /* return device size in bytes (u64 *arg) */
197
198#define BMAP_IOCTL 1 /* obsolete - kept for compatibility */
199#define FIBMAP _IO(0x00,1) /* bmap access */
200#define FIGETBSZ _IO(0x00,2) /* get the block size used for bmap */
201
202#ifdef __KERNEL__
203
204#include <linux/linkage.h>
205#include <linux/wait.h>
206#include <linux/types.h>
207#include <linux/kdev_t.h>
208#include <linux/dcache.h>
209#include <linux/stat.h>
210#include <linux/cache.h>
211#include <linux/kobject.h>
212#include <linux/list.h>
213#include <linux/radix-tree.h>
214#include <linux/prio_tree.h>
215#include <linux/init.h>
216
217#include <asm/atomic.h>
218#include <asm/semaphore.h>
219#include <asm/byteorder.h>
220
221struct iovec;
222struct nameidata;
223struct pipe_inode_info;
224struct poll_table_struct;
225struct kstatfs;
226struct vm_area_struct;
227struct vfsmount;
228
229/* Used to be a macro which just called the function, now just a function */
230extern void update_atime (struct inode *);
231
232extern void __init inode_init(unsigned long);
233extern void __init inode_init_early(void);
234extern void __init mnt_init(unsigned long);
235extern void __init files_init(unsigned long);
236
237struct buffer_head;
238typedef int (get_block_t)(struct inode *inode, sector_t iblock,
239 struct buffer_head *bh_result, int create);
240typedef int (get_blocks_t)(struct inode *inode, sector_t iblock,
241 unsigned long max_blocks,
242 struct buffer_head *bh_result, int create);
243typedef void (dio_iodone_t)(struct inode *inode, loff_t offset,
244 ssize_t bytes, void *private);
245
246/*
247 * Attribute flags. These should be or-ed together to figure out what
248 * has been changed!
249 */
250#define ATTR_MODE 1
251#define ATTR_UID 2
252#define ATTR_GID 4
253#define ATTR_SIZE 8
254#define ATTR_ATIME 16
255#define ATTR_MTIME 32
256#define ATTR_CTIME 64
257#define ATTR_ATIME_SET 128
258#define ATTR_MTIME_SET 256
259#define ATTR_FORCE 512 /* Not a change, but a change it */
260#define ATTR_ATTR_FLAG 1024
261#define ATTR_KILL_SUID 2048
262#define ATTR_KILL_SGID 4096
263
264/*
265 * This is the Inode Attributes structure, used for notify_change(). It
266 * uses the above definitions as flags, to know which values have changed.
267 * Also, in this manner, a Filesystem can look at only the values it cares
268 * about. Basically, these are the attributes that the VFS layer can
269 * request to change from the FS layer.
270 *
271 * Derek Atkins <warlord@MIT.EDU> 94-10-20
272 */
273struct iattr {
274 unsigned int ia_valid;
275 umode_t ia_mode;
276 uid_t ia_uid;
277 gid_t ia_gid;
278 loff_t ia_size;
279 struct timespec ia_atime;
280 struct timespec ia_mtime;
281 struct timespec ia_ctime;
282 unsigned int ia_attr_flags;
283};
284
285/*
286 * This is the inode attributes flag definitions
287 */
288#define ATTR_FLAG_SYNCRONOUS 1 /* Syncronous write */
289#define ATTR_FLAG_NOATIME 2 /* Don't update atime */
290#define ATTR_FLAG_APPEND 4 /* Append-only file */
291#define ATTR_FLAG_IMMUTABLE 8 /* Immutable file */
292#define ATTR_FLAG_NODIRATIME 16 /* Don't update atime for directory */
293
294/*
295 * Includes for diskquotas.
296 */
297#include <linux/quota.h>
298
299/*
300 * oh the beauties of C type declarations.
301 */
302struct page;
303struct address_space;
304struct writeback_control;
305struct kiocb;
306
307struct address_space_operations {
308 int (*writepage)(struct page *page, struct writeback_control *wbc);
309 int (*readpage)(struct file *, struct page *);
310 int (*sync_page)(struct page *);
311
312 /* Write back some dirty pages from this mapping. */
313 int (*writepages)(struct address_space *, struct writeback_control *);
314
315 /* Set a page dirty */
316 int (*set_page_dirty)(struct page *page);
317
318 int (*readpages)(struct file *filp, struct address_space *mapping,
319 struct list_head *pages, unsigned nr_pages);
320
321 /*
322 * ext3 requires that a successful prepare_write() call be followed
323 * by a commit_write() call - they must be balanced
324 */
325 int (*prepare_write)(struct file *, struct page *, unsigned, unsigned);
326 int (*commit_write)(struct file *, struct page *, unsigned, unsigned);
327 /* Unfortunately this kludge is needed for FIBMAP. Don't use it */
328 sector_t (*bmap)(struct address_space *, sector_t);
329 int (*invalidatepage) (struct page *, unsigned long);
330 int (*releasepage) (struct page *, int);
331 ssize_t (*direct_IO)(int, struct kiocb *, const struct iovec *iov,
332 loff_t offset, unsigned long nr_segs);
333};
334
335struct backing_dev_info;
336struct address_space {
337 struct inode *host; /* owner: inode, block_device */
338 struct radix_tree_root page_tree; /* radix tree of all pages */
339 rwlock_t tree_lock; /* and rwlock protecting it */
340 unsigned int i_mmap_writable;/* count VM_SHARED mappings */
341 struct prio_tree_root i_mmap; /* tree of private and shared mappings */
342 struct list_head i_mmap_nonlinear;/*list VM_NONLINEAR mappings */
343 spinlock_t i_mmap_lock; /* protect tree, count, list */
344 unsigned int truncate_count; /* Cover race condition with truncate */
345 unsigned long nrpages; /* number of total pages */
346 pgoff_t writeback_index;/* writeback starts here */
347 struct address_space_operations *a_ops; /* methods */
348 unsigned long flags; /* error bits/gfp mask */
349 struct backing_dev_info *backing_dev_info; /* device readahead, etc */
350 spinlock_t private_lock; /* for use by the address_space */
351 struct list_head private_list; /* ditto */
352 struct address_space *assoc_mapping; /* ditto */
353} __attribute__((aligned(sizeof(long))));
354 /*
355 * On most architectures that alignment is already the case; but
356 * must be enforced here for CRIS, to let the least signficant bit
357 * of struct page's "mapping" pointer be used for PAGE_MAPPING_ANON.
358 */
359
360struct block_device {
361 dev_t bd_dev; /* not a kdev_t - it's a search key */
362 struct inode * bd_inode; /* will die */
363 int bd_openers;
364 struct semaphore bd_sem; /* open/close mutex */
365 struct semaphore bd_mount_sem; /* mount mutex */
366 struct list_head bd_inodes;
367 void * bd_holder;
368 int bd_holders;
369 struct block_device * bd_contains;
370 unsigned bd_block_size;
371 struct hd_struct * bd_part;
372 /* number of times partitions within this device have been opened. */
373 unsigned bd_part_count;
374 int bd_invalidated;
375 struct gendisk * bd_disk;
376 struct list_head bd_list;
377 struct backing_dev_info *bd_inode_backing_dev_info;
378 /*
379 * Private data. You must have bd_claim'ed the block_device
380 * to use this. NOTE: bd_claim allows an owner to claim
381 * the same device multiple times, the owner must take special
382 * care to not mess up bd_private for that case.
383 */
384 unsigned long bd_private;
385};
386
387/*
388 * Radix-tree tags, for tagging dirty and writeback pages within the pagecache
389 * radix trees
390 */
391#define PAGECACHE_TAG_DIRTY 0
392#define PAGECACHE_TAG_WRITEBACK 1
393
394int mapping_tagged(struct address_space *mapping, int tag);
395
396/*
397 * Might pages of this file be mapped into userspace?
398 */
399static inline int mapping_mapped(struct address_space *mapping)
400{
401 return !prio_tree_empty(&mapping->i_mmap) ||
402 !list_empty(&mapping->i_mmap_nonlinear);
403}
404
405/*
406 * Might pages of this file have been modified in userspace?
407 * Note that i_mmap_writable counts all VM_SHARED vmas: do_mmap_pgoff
408 * marks vma as VM_SHARED if it is shared, and the file was opened for
409 * writing i.e. vma may be mprotected writable even if now readonly.
410 */
411static inline int mapping_writably_mapped(struct address_space *mapping)
412{
413 return mapping->i_mmap_writable != 0;
414}
415
416/*
417 * Use sequence counter to get consistent i_size on 32-bit processors.
418 */
419#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
420#include <linux/seqlock.h>
421#define __NEED_I_SIZE_ORDERED
422#define i_size_ordered_init(inode) seqcount_init(&inode->i_size_seqcount)
423#else
424#define i_size_ordered_init(inode) do { } while (0)
425#endif
426
427struct inode {
428 struct hlist_node i_hash;
429 struct list_head i_list;
430 struct list_head i_sb_list;
431 struct list_head i_dentry;
432 unsigned long i_ino;
433 atomic_t i_count;
434 umode_t i_mode;
435 unsigned int i_nlink;
436 uid_t i_uid;
437 gid_t i_gid;
438 dev_t i_rdev;
439 loff_t i_size;
440 struct timespec i_atime;
441 struct timespec i_mtime;
442 struct timespec i_ctime;
443 unsigned int i_blkbits;
444 unsigned long i_blksize;
445 unsigned long i_version;
446 unsigned long i_blocks;
447 unsigned short i_bytes;
448 spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */
449 struct semaphore i_sem;
450 struct rw_semaphore i_alloc_sem;
451 struct inode_operations *i_op;
452 struct file_operations *i_fop; /* former ->i_op->default_file_ops */
453 struct super_block *i_sb;
454 struct file_lock *i_flock;
455 struct address_space *i_mapping;
456 struct address_space i_data;
457#ifdef CONFIG_QUOTA
458 struct dquot *i_dquot[MAXQUOTAS];
459#endif
460 /* These three should probably be a union */
461 struct list_head i_devices;
462 struct pipe_inode_info *i_pipe;
463 struct block_device *i_bdev;
464 struct cdev *i_cdev;
465 int i_cindex;
466
467 __u32 i_generation;
468
469#ifdef CONFIG_DNOTIFY
470 unsigned long i_dnotify_mask; /* Directory notify events */
471 struct dnotify_struct *i_dnotify; /* for directory notifications */
472#endif
473
474 unsigned long i_state;
475 unsigned long dirtied_when; /* jiffies of first dirtying */
476
477 unsigned int i_flags;
478
479 atomic_t i_writecount;
480 void *i_security;
481 union {
482 void *generic_ip;
483 } u;
484#ifdef __NEED_I_SIZE_ORDERED
485 seqcount_t i_size_seqcount;
486#endif
487};
488
489/*
490 * NOTE: in a 32bit arch with a preemptable kernel and
491 * an UP compile the i_size_read/write must be atomic
492 * with respect to the local cpu (unlike with preempt disabled),
493 * but they don't need to be atomic with respect to other cpus like in
494 * true SMP (so they need either to either locally disable irq around
495 * the read or for example on x86 they can be still implemented as a
496 * cmpxchg8b without the need of the lock prefix). For SMP compiles
497 * and 64bit archs it makes no difference if preempt is enabled or not.
498 */
499static inline loff_t i_size_read(struct inode *inode)
500{
501#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
502 loff_t i_size;
503 unsigned int seq;
504
505 do {
506 seq = read_seqcount_begin(&inode->i_size_seqcount);
507 i_size = inode->i_size;
508 } while (read_seqcount_retry(&inode->i_size_seqcount, seq));
509 return i_size;
510#elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPT)
511 loff_t i_size;
512
513 preempt_disable();
514 i_size = inode->i_size;
515 preempt_enable();
516 return i_size;
517#else
518 return inode->i_size;
519#endif
520}
521
522
523static inline void i_size_write(struct inode *inode, loff_t i_size)
524{
525#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
526 write_seqcount_begin(&inode->i_size_seqcount);
527 inode->i_size = i_size;
528 write_seqcount_end(&inode->i_size_seqcount);
529#elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPT)
530 preempt_disable();
531 inode->i_size = i_size;
532 preempt_enable();
533#else
534 inode->i_size = i_size;
535#endif
536}
537
538static inline unsigned iminor(struct inode *inode)
539{
540 return MINOR(inode->i_rdev);
541}
542
543static inline unsigned imajor(struct inode *inode)
544{
545 return MAJOR(inode->i_rdev);
546}
547
548extern struct block_device *I_BDEV(struct inode *inode);
549
550struct fown_struct {
551 rwlock_t lock; /* protects pid, uid, euid fields */
552 int pid; /* pid or -pgrp where SIGIO should be sent */
553 uid_t uid, euid; /* uid/euid of process setting the owner */
554 void *security;
555 int signum; /* posix.1b rt signal to be delivered on IO */
556};
557
558/*
559 * Track a single file's readahead state
560 */
561struct file_ra_state {
562 unsigned long start; /* Current window */
563 unsigned long size;
564 unsigned long flags; /* ra flags RA_FLAG_xxx*/
565 unsigned long cache_hit; /* cache hit count*/
566 unsigned long prev_page; /* Cache last read() position */
567 unsigned long ahead_start; /* Ahead window */
568 unsigned long ahead_size;
569 unsigned long ra_pages; /* Maximum readahead window */
570 unsigned long mmap_hit; /* Cache hit stat for mmap accesses */
571 unsigned long mmap_miss; /* Cache miss stat for mmap accesses */
572};
573#define RA_FLAG_MISS 0x01 /* a cache miss occured against this file */
574#define RA_FLAG_INCACHE 0x02 /* file is already in cache */
575
576struct file {
577 struct list_head f_list;
578 struct dentry *f_dentry;
579 struct vfsmount *f_vfsmnt;
580 struct file_operations *f_op;
581 atomic_t f_count;
582 unsigned int f_flags;
583 mode_t f_mode;
584 int f_error;
585 loff_t f_pos;
586 struct fown_struct f_owner;
587 unsigned int f_uid, f_gid;
588 struct file_ra_state f_ra;
589
590 size_t f_maxcount;
591 unsigned long f_version;
592 void *f_security;
593
594 /* needed for tty driver, and maybe others */
595 void *private_data;
596
597#ifdef CONFIG_EPOLL
598 /* Used by fs/eventpoll.c to link all the hooks to this file */
599 struct list_head f_ep_links;
600 spinlock_t f_ep_lock;
601#endif /* #ifdef CONFIG_EPOLL */
602 struct address_space *f_mapping;
603};
604extern spinlock_t files_lock;
605#define file_list_lock() spin_lock(&files_lock);
606#define file_list_unlock() spin_unlock(&files_lock);
607
608#define get_file(x) atomic_inc(&(x)->f_count)
609#define file_count(x) atomic_read(&(x)->f_count)
610
611#define MAX_NON_LFS ((1UL<<31) - 1)
612
613/* Page cache limit. The filesystems should put that into their s_maxbytes
614 limits, otherwise bad things can happen in VM. */
615#if BITS_PER_LONG==32
616#define MAX_LFS_FILESIZE (((u64)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1)
617#elif BITS_PER_LONG==64
618#define MAX_LFS_FILESIZE 0x7fffffffffffffffUL
619#endif
620
621#define FL_POSIX 1
622#define FL_FLOCK 2
623#define FL_ACCESS 8 /* not trying to lock, just looking */
624#define FL_LOCKD 16 /* lock held by rpc.lockd */
625#define FL_LEASE 32 /* lease held on this file */
626#define FL_SLEEP 128 /* A blocking lock */
627
628/*
629 * The POSIX file lock owner is determined by
630 * the "struct files_struct" in the thread group
631 * (or NULL for no owner - BSD locks).
632 *
633 * Lockd stuffs a "host" pointer into this.
634 */
635typedef struct files_struct *fl_owner_t;
636
637struct file_lock_operations {
638 void (*fl_insert)(struct file_lock *); /* lock insertion callback */
639 void (*fl_remove)(struct file_lock *); /* lock removal callback */
640 void (*fl_copy_lock)(struct file_lock *, struct file_lock *);
641 void (*fl_release_private)(struct file_lock *);
642};
643
644struct lock_manager_operations {
645 int (*fl_compare_owner)(struct file_lock *, struct file_lock *);
646 void (*fl_notify)(struct file_lock *); /* unblock callback */
647 void (*fl_copy_lock)(struct file_lock *, struct file_lock *);
648 void (*fl_release_private)(struct file_lock *);
649 void (*fl_break)(struct file_lock *);
650 int (*fl_mylease)(struct file_lock *, struct file_lock *);
651 int (*fl_change)(struct file_lock **, int);
652};
653
654/* that will die - we need it for nfs_lock_info */
655#include <linux/nfs_fs_i.h>
656
657struct file_lock {
658 struct file_lock *fl_next; /* singly linked list for this inode */
659 struct list_head fl_link; /* doubly linked list of all locks */
660 struct list_head fl_block; /* circular list of blocked processes */
661 fl_owner_t fl_owner;
662 unsigned int fl_pid;
663 wait_queue_head_t fl_wait;
664 struct file *fl_file;
665 unsigned char fl_flags;
666 unsigned char fl_type;
667 loff_t fl_start;
668 loff_t fl_end;
669
670 struct fasync_struct * fl_fasync; /* for lease break notifications */
671 unsigned long fl_break_time; /* for nonblocking lease breaks */
672
673 struct file_lock_operations *fl_ops; /* Callbacks for filesystems */
674 struct lock_manager_operations *fl_lmops; /* Callbacks for lockmanagers */
675 union {
676 struct nfs_lock_info nfs_fl;
677 } fl_u;
678};
679
680/* The following constant reflects the upper bound of the file/locking space */
681#ifndef OFFSET_MAX
682#define INT_LIMIT(x) (~((x)1 << (sizeof(x)*8 - 1)))
683#define OFFSET_MAX INT_LIMIT(loff_t)
684#define OFFT_OFFSET_MAX INT_LIMIT(off_t)
685#endif
686
687extern struct list_head file_lock_list;
688
689#include <linux/fcntl.h>
690
691extern int fcntl_getlk(struct file *, struct flock __user *);
692extern int fcntl_setlk(struct file *, unsigned int, struct flock __user *);
693
694#if BITS_PER_LONG == 32
695extern int fcntl_getlk64(struct file *, struct flock64 __user *);
696extern int fcntl_setlk64(struct file *, unsigned int, struct flock64 __user *);
697#endif
698
699extern void send_sigio(struct fown_struct *fown, int fd, int band);
700extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg);
701extern int fcntl_getlease(struct file *filp);
702
703/* fs/locks.c */
704extern void locks_init_lock(struct file_lock *);
705extern void locks_copy_lock(struct file_lock *, struct file_lock *);
706extern void locks_remove_posix(struct file *, fl_owner_t);
707extern void locks_remove_flock(struct file *);
708extern struct file_lock *posix_test_lock(struct file *, struct file_lock *);
709extern int posix_lock_file(struct file *, struct file_lock *);
710extern int posix_lock_file_wait(struct file *, struct file_lock *);
711extern void posix_block_lock(struct file_lock *, struct file_lock *);
712extern void posix_unblock_lock(struct file *, struct file_lock *);
713extern int posix_locks_deadlock(struct file_lock *, struct file_lock *);
714extern int flock_lock_file_wait(struct file *filp, struct file_lock *fl);
715extern int __break_lease(struct inode *inode, unsigned int flags);
716extern void lease_get_mtime(struct inode *, struct timespec *time);
717extern int setlease(struct file *, long, struct file_lock **);
718extern int lease_modify(struct file_lock **, int);
719extern int lock_may_read(struct inode *, loff_t start, unsigned long count);
720extern int lock_may_write(struct inode *, loff_t start, unsigned long count);
721extern void steal_locks(fl_owner_t from);
722
723struct fasync_struct {
724 int magic;
725 int fa_fd;
726 struct fasync_struct *fa_next; /* singly linked list */
727 struct file *fa_file;
728};
729
730#define FASYNC_MAGIC 0x4601
731
732/* SMP safe fasync helpers: */
733extern int fasync_helper(int, struct file *, int, struct fasync_struct **);
734/* can be called from interrupts */
735extern void kill_fasync(struct fasync_struct **, int, int);
736/* only for net: no internal synchronization */
737extern void __kill_fasync(struct fasync_struct *, int, int);
738
739extern int f_setown(struct file *filp, unsigned long arg, int force);
740extern void f_delown(struct file *filp);
741extern int send_sigurg(struct fown_struct *fown);
742
743/*
744 * Umount options
745 */
746
747#define MNT_FORCE 0x00000001 /* Attempt to forcibily umount */
748#define MNT_DETACH 0x00000002 /* Just detach from the tree */
749#define MNT_EXPIRE 0x00000004 /* Mark for expiry */
750
751extern struct list_head super_blocks;
752extern spinlock_t sb_lock;
753
754#define sb_entry(list) list_entry((list), struct super_block, s_list)
755#define S_BIAS (1<<30)
756struct super_block {
757 struct list_head s_list; /* Keep this first */
758 dev_t s_dev; /* search index; _not_ kdev_t */
759 unsigned long s_blocksize;
760 unsigned long s_old_blocksize;
761 unsigned char s_blocksize_bits;
762 unsigned char s_dirt;
763 unsigned long long s_maxbytes; /* Max file size */
764 struct file_system_type *s_type;
765 struct super_operations *s_op;
766 struct dquot_operations *dq_op;
767 struct quotactl_ops *s_qcop;
768 struct export_operations *s_export_op;
769 unsigned long s_flags;
770 unsigned long s_magic;
771 struct dentry *s_root;
772 struct rw_semaphore s_umount;
773 struct semaphore s_lock;
774 int s_count;
775 int s_syncing;
776 int s_need_sync_fs;
777 atomic_t s_active;
778 void *s_security;
779 struct xattr_handler **s_xattr;
780
781 struct list_head s_inodes; /* all inodes */
782 struct list_head s_dirty; /* dirty inodes */
783 struct list_head s_io; /* parked for writeback */
784 struct hlist_head s_anon; /* anonymous dentries for (nfs) exporting */
785 struct list_head s_files;
786
787 struct block_device *s_bdev;
788 struct list_head s_instances;
789 struct quota_info s_dquot; /* Diskquota specific options */
790
791 int s_frozen;
792 wait_queue_head_t s_wait_unfrozen;
793
794 char s_id[32]; /* Informational name */
795
796 void *s_fs_info; /* Filesystem private info */
797
798 /*
799 * The next field is for VFS *only*. No filesystems have any business
800 * even looking at it. You had been warned.
801 */
802 struct semaphore s_vfs_rename_sem; /* Kludge */
803
804 /* Granuality of c/m/atime in ns.
805 Cannot be worse than a second */
806 u32 s_time_gran;
807};
808
809extern struct timespec current_fs_time(struct super_block *sb);
810
811/*
812 * Snapshotting support.
813 */
814enum {
815 SB_UNFROZEN = 0,
816 SB_FREEZE_WRITE = 1,
817 SB_FREEZE_TRANS = 2,
818};
819
820#define vfs_check_frozen(sb, level) \
821 wait_event((sb)->s_wait_unfrozen, ((sb)->s_frozen < (level)))
822
823/*
824 * Superblock locking.
825 */
826static inline void lock_super(struct super_block * sb)
827{
828 down(&sb->s_lock);
829}
830
831static inline void unlock_super(struct super_block * sb)
832{
833 up(&sb->s_lock);
834}
835
836/*
837 * VFS helper functions..
838 */
839extern int vfs_create(struct inode *, struct dentry *, int, struct nameidata *);
840extern int vfs_mkdir(struct inode *, struct dentry *, int);
841extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t);
842extern int vfs_symlink(struct inode *, struct dentry *, const char *, int);
843extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
844extern int vfs_rmdir(struct inode *, struct dentry *);
845extern int vfs_unlink(struct inode *, struct dentry *);
846extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
847
848/*
849 * VFS dentry helper functions.
850 */
851extern void dentry_unhash(struct dentry *dentry);
852
853/*
854 * File types
855 *
856 * NOTE! These match bits 12..15 of stat.st_mode
857 * (ie "(i_mode >> 12) & 15").
858 */
859#define DT_UNKNOWN 0
860#define DT_FIFO 1
861#define DT_CHR 2
862#define DT_DIR 4
863#define DT_BLK 6
864#define DT_REG 8
865#define DT_LNK 10
866#define DT_SOCK 12
867#define DT_WHT 14
868
869#define OSYNC_METADATA (1<<0)
870#define OSYNC_DATA (1<<1)
871#define OSYNC_INODE (1<<2)
872int generic_osync_inode(struct inode *, struct address_space *, int);
873
874/*
875 * This is the "filldir" function type, used by readdir() to let
876 * the kernel specify what kind of dirent layout it wants to have.
877 * This allows the kernel to read directories into kernel space or
878 * to have different dirent layouts depending on the binary type.
879 */
880typedef int (*filldir_t)(void *, const char *, int, loff_t, ino_t, unsigned);
881
882struct block_device_operations {
883 int (*open) (struct inode *, struct file *);
884 int (*release) (struct inode *, struct file *);
885 int (*ioctl) (struct inode *, struct file *, unsigned, unsigned long);
886 long (*compat_ioctl) (struct file *, unsigned, unsigned long);
887 int (*media_changed) (struct gendisk *);
888 int (*revalidate_disk) (struct gendisk *);
889 struct module *owner;
890};
891
892/*
893 * "descriptor" for what we're up to with a read for sendfile().
894 * This allows us to use the same read code yet
895 * have multiple different users of the data that
896 * we read from a file.
897 *
898 * The simplest case just copies the data to user
899 * mode.
900 */
901typedef struct {
902 size_t written;
903 size_t count;
904 union {
905 char __user * buf;
906 void *data;
907 } arg;
908 int error;
909} read_descriptor_t;
910
911typedef int (*read_actor_t)(read_descriptor_t *, struct page *, unsigned long, unsigned long);
912
913/* These macros are for out of kernel modules to test that
914 * the kernel supports the unlocked_ioctl and compat_ioctl
915 * fields in struct file_operations. */
916#define HAVE_COMPAT_IOCTL 1
917#define HAVE_UNLOCKED_IOCTL 1
918
919/*
920 * NOTE:
921 * read, write, poll, fsync, readv, writev, unlocked_ioctl and compat_ioctl
922 * can be called without the big kernel lock held in all filesystems.
923 */
924struct file_operations {
925 struct module *owner;
926 loff_t (*llseek) (struct file *, loff_t, int);
927 ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
928 ssize_t (*aio_read) (struct kiocb *, char __user *, size_t, loff_t);
929 ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
930 ssize_t (*aio_write) (struct kiocb *, const char __user *, size_t, loff_t);
931 int (*readdir) (struct file *, void *, filldir_t);
932 unsigned int (*poll) (struct file *, struct poll_table_struct *);
933 int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
934 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
935 long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
936 int (*mmap) (struct file *, struct vm_area_struct *);
937 int (*open) (struct inode *, struct file *);
938 int (*flush) (struct file *);
939 int (*release) (struct inode *, struct file *);
940 int (*fsync) (struct file *, struct dentry *, int datasync);
941 int (*aio_fsync) (struct kiocb *, int datasync);
942 int (*fasync) (int, struct file *, int);
943 int (*lock) (struct file *, int, struct file_lock *);
944 ssize_t (*readv) (struct file *, const struct iovec *, unsigned long, loff_t *);
945 ssize_t (*writev) (struct file *, const struct iovec *, unsigned long, loff_t *);
946 ssize_t (*sendfile) (struct file *, loff_t *, size_t, read_actor_t, void *);
947 ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);
948 unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
949 int (*check_flags)(int);
950 int (*dir_notify)(struct file *filp, unsigned long arg);
951 int (*flock) (struct file *, int, struct file_lock *);
952};
953
954struct inode_operations {
955 int (*create) (struct inode *,struct dentry *,int, struct nameidata *);
956 struct dentry * (*lookup) (struct inode *,struct dentry *, struct nameidata *);
957 int (*link) (struct dentry *,struct inode *,struct dentry *);
958 int (*unlink) (struct inode *,struct dentry *);
959 int (*symlink) (struct inode *,struct dentry *,const char *);
960 int (*mkdir) (struct inode *,struct dentry *,int);
961 int (*rmdir) (struct inode *,struct dentry *);
962 int (*mknod) (struct inode *,struct dentry *,int,dev_t);
963 int (*rename) (struct inode *, struct dentry *,
964 struct inode *, struct dentry *);
965 int (*readlink) (struct dentry *, char __user *,int);
966 int (*follow_link) (struct dentry *, struct nameidata *);
967 void (*put_link) (struct dentry *, struct nameidata *);
968 void (*truncate) (struct inode *);
969 int (*permission) (struct inode *, int, struct nameidata *);
970 int (*setattr) (struct dentry *, struct iattr *);
971 int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
972 int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);
973 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
974 ssize_t (*listxattr) (struct dentry *, char *, size_t);
975 int (*removexattr) (struct dentry *, const char *);
976};
977
978struct seq_file;
979
980extern ssize_t vfs_read(struct file *, char __user *, size_t, loff_t *);
981extern ssize_t vfs_write(struct file *, const char __user *, size_t, loff_t *);
982extern ssize_t vfs_readv(struct file *, const struct iovec __user *,
983 unsigned long, loff_t *);
984extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
985 unsigned long, loff_t *);
986
987/*
988 * NOTE: write_inode, delete_inode, clear_inode, put_inode can be called
989 * without the big kernel lock held in all filesystems.
990 */
991struct super_operations {
992 struct inode *(*alloc_inode)(struct super_block *sb);
993 void (*destroy_inode)(struct inode *);
994
995 void (*read_inode) (struct inode *);
996
997 void (*dirty_inode) (struct inode *);
998 int (*write_inode) (struct inode *, int);
999 void (*put_inode) (struct inode *);
1000 void (*drop_inode) (struct inode *);
1001 void (*delete_inode) (struct inode *);
1002 void (*put_super) (struct super_block *);
1003 void (*write_super) (struct super_block *);
1004 int (*sync_fs)(struct super_block *sb, int wait);
1005 void (*write_super_lockfs) (struct super_block *);
1006 void (*unlockfs) (struct super_block *);
1007 int (*statfs) (struct super_block *, struct kstatfs *);
1008 int (*remount_fs) (struct super_block *, int *, char *);
1009 void (*clear_inode) (struct inode *);
1010 void (*umount_begin) (struct super_block *);
1011
1012 int (*show_options)(struct seq_file *, struct vfsmount *);
1013
1014 ssize_t (*quota_read)(struct super_block *, int, char *, size_t, loff_t);
1015 ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t);
1016};
1017
1018/* Inode state bits. Protected by inode_lock. */
1019#define I_DIRTY_SYNC 1 /* Not dirty enough for O_DATASYNC */
1020#define I_DIRTY_DATASYNC 2 /* Data-related inode changes pending */
1021#define I_DIRTY_PAGES 4 /* Data-related inode changes pending */
1022#define __I_LOCK 3
1023#define I_LOCK (1 << __I_LOCK)
1024#define I_FREEING 16
1025#define I_CLEAR 32
1026#define I_NEW 64
1027
1028#define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES)
1029
1030extern void __mark_inode_dirty(struct inode *, int);
1031static inline void mark_inode_dirty(struct inode *inode)
1032{
1033 __mark_inode_dirty(inode, I_DIRTY);
1034}
1035
1036static inline void mark_inode_dirty_sync(struct inode *inode)
1037{
1038 __mark_inode_dirty(inode, I_DIRTY_SYNC);
1039}
1040
1041static inline void touch_atime(struct vfsmount *mnt, struct dentry *dentry)
1042{
1043 /* per-mountpoint checks will go here */
1044 update_atime(dentry->d_inode);
1045}
1046
1047static inline void file_accessed(struct file *file)
1048{
1049 if (!(file->f_flags & O_NOATIME))
1050 touch_atime(file->f_vfsmnt, file->f_dentry);
1051}
1052
1053int sync_inode(struct inode *inode, struct writeback_control *wbc);
1054
1055/**
1056 * &export_operations - for nfsd to communicate with file systems
1057 * decode_fh: decode a file handle fragment and return a &struct dentry
1058 * encode_fh: encode a file handle fragment from a dentry
1059 * get_name: find the name for a given inode in a given directory
1060 * get_parent: find the parent of a given directory
1061 * get_dentry: find a dentry for the inode given a file handle sub-fragment
1062 *
1063 * Description:
1064 * The export_operations structure provides a means for nfsd to communicate
1065 * with a particular exported file system - particularly enabling nfsd and
1066 * the filesystem to co-operate when dealing with file handles.
1067 *
1068 * export_operations contains two basic operation for dealing with file handles,
1069 * decode_fh() and encode_fh(), and allows for some other operations to be defined
1070 * which standard helper routines use to get specific information from the
1071 * filesystem.
1072 *
1073 * nfsd encodes information use to determine which filesystem a filehandle
1074 * applies to in the initial part of the file handle. The remainder, termed a
1075 * file handle fragment, is controlled completely by the filesystem.
1076 * The standard helper routines assume that this fragment will contain one or two
1077 * sub-fragments, one which identifies the file, and one which may be used to
1078 * identify the (a) directory containing the file.
1079 *
1080 * In some situations, nfsd needs to get a dentry which is connected into a
1081 * specific part of the file tree. To allow for this, it passes the function
1082 * acceptable() together with a @context which can be used to see if the dentry
1083 * is acceptable. As there can be multiple dentrys for a given file, the filesystem
1084 * should check each one for acceptability before looking for the next. As soon
1085 * as an acceptable one is found, it should be returned.
1086 *
1087 * decode_fh:
1088 * @decode_fh is given a &struct super_block (@sb), a file handle fragment (@fh, @fh_len)
1089 * and an acceptability testing function (@acceptable, @context). It should return
1090 * a &struct dentry which refers to the same file that the file handle fragment refers
1091 * to, and which passes the acceptability test. If it cannot, it should return
1092 * a %NULL pointer if the file was found but no acceptable &dentries were available, or
1093 * a %ERR_PTR error code indicating why it couldn't be found (e.g. %ENOENT or %ENOMEM).
1094 *
1095 * encode_fh:
1096 * @encode_fh should store in the file handle fragment @fh (using at most @max_len bytes)
1097 * information that can be used by @decode_fh to recover the file refered to by the
1098 * &struct dentry @de. If the @connectable flag is set, the encode_fh() should store
1099 * sufficient information so that a good attempt can be made to find not only
1100 * the file but also it's place in the filesystem. This typically means storing
1101 * a reference to de->d_parent in the filehandle fragment.
1102 * encode_fh() should return the number of bytes stored or a negative error code
1103 * such as %-ENOSPC
1104 *
1105 * get_name:
1106 * @get_name should find a name for the given @child in the given @parent directory.
1107 * The name should be stored in the @name (with the understanding that it is already
1108 * pointing to a a %NAME_MAX+1 sized buffer. get_name() should return %0 on success,
1109 * a negative error code or error.
1110 * @get_name will be called without @parent->i_sem held.
1111 *
1112 * get_parent:
1113 * @get_parent should find the parent directory for the given @child which is also
1114 * a directory. In the event that it cannot be found, or storage space cannot be
1115 * allocated, a %ERR_PTR should be returned.
1116 *
1117 * get_dentry:
1118 * Given a &super_block (@sb) and a pointer to a file-system specific inode identifier,
1119 * possibly an inode number, (@inump) get_dentry() should find the identified inode and
1120 * return a dentry for that inode.
1121 * Any suitable dentry can be returned including, if necessary, a new dentry created
1122 * with d_alloc_root. The caller can then find any other extant dentrys by following the
1123 * d_alias links. If a new dentry was created using d_alloc_root, DCACHE_NFSD_DISCONNECTED
1124 * should be set, and the dentry should be d_rehash()ed.
1125 *
1126 * If the inode cannot be found, either a %NULL pointer or an %ERR_PTR code can be returned.
1127 * The @inump will be whatever was passed to nfsd_find_fh_dentry() in either the
1128 * @obj or @parent parameters.
1129 *
1130 * Locking rules:
1131 * get_parent is called with child->d_inode->i_sem down
1132 * get_name is not (which is possibly inconsistent)
1133 */
1134
1135struct export_operations {
1136 struct dentry *(*decode_fh)(struct super_block *sb, __u32 *fh, int fh_len, int fh_type,
1137 int (*acceptable)(void *context, struct dentry *de),
1138 void *context);
1139 int (*encode_fh)(struct dentry *de, __u32 *fh, int *max_len,
1140 int connectable);
1141
1142 /* the following are only called from the filesystem itself */
1143 int (*get_name)(struct dentry *parent, char *name,
1144 struct dentry *child);
1145 struct dentry * (*get_parent)(struct dentry *child);
1146 struct dentry * (*get_dentry)(struct super_block *sb, void *inump);
1147
1148 /* This is set by the exporting module to a standard helper */
1149 struct dentry * (*find_exported_dentry)(
1150 struct super_block *sb, void *obj, void *parent,
1151 int (*acceptable)(void *context, struct dentry *de),
1152 void *context);
1153
1154
1155};
1156
1157extern struct dentry *
1158find_exported_dentry(struct super_block *sb, void *obj, void *parent,
1159 int (*acceptable)(void *context, struct dentry *de),
1160 void *context);
1161
1162struct file_system_type {
1163 const char *name;
1164 int fs_flags;
1165 struct super_block *(*get_sb) (struct file_system_type *, int,
1166 const char *, void *);
1167 void (*kill_sb) (struct super_block *);
1168 struct module *owner;
1169 struct file_system_type * next;
1170 struct list_head fs_supers;
1171};
1172
1173struct super_block *get_sb_bdev(struct file_system_type *fs_type,
1174 int flags, const char *dev_name, void *data,
1175 int (*fill_super)(struct super_block *, void *, int));
1176struct super_block *get_sb_single(struct file_system_type *fs_type,
1177 int flags, void *data,
1178 int (*fill_super)(struct super_block *, void *, int));
1179struct super_block *get_sb_nodev(struct file_system_type *fs_type,
1180 int flags, void *data,
1181 int (*fill_super)(struct super_block *, void *, int));
1182void generic_shutdown_super(struct super_block *sb);
1183void kill_block_super(struct super_block *sb);
1184void kill_anon_super(struct super_block *sb);
1185void kill_litter_super(struct super_block *sb);
1186void deactivate_super(struct super_block *sb);
1187int set_anon_super(struct super_block *s, void *data);
1188struct super_block *sget(struct file_system_type *type,
1189 int (*test)(struct super_block *,void *),
1190 int (*set)(struct super_block *,void *),
1191 void *data);
1192struct super_block *get_sb_pseudo(struct file_system_type *, char *,
1193 struct super_operations *ops, unsigned long);
1194int __put_super(struct super_block *sb);
1195int __put_super_and_need_restart(struct super_block *sb);
1196void unnamed_dev_init(void);
1197
1198/* Alas, no aliases. Too much hassle with bringing module.h everywhere */
1199#define fops_get(fops) \
1200 (((fops) && try_module_get((fops)->owner) ? (fops) : NULL))
1201#define fops_put(fops) \
1202 do { if (fops) module_put((fops)->owner); } while(0)
1203
1204extern int register_filesystem(struct file_system_type *);
1205extern int unregister_filesystem(struct file_system_type *);
1206extern struct vfsmount *kern_mount(struct file_system_type *);
1207extern int may_umount_tree(struct vfsmount *);
1208extern int may_umount(struct vfsmount *);
1209extern long do_mount(char *, char *, char *, unsigned long, void *);
1210
1211extern int vfs_statfs(struct super_block *, struct kstatfs *);
1212
1213#define FLOCK_VERIFY_READ 1
1214#define FLOCK_VERIFY_WRITE 2
1215
1216extern int locks_mandatory_locked(struct inode *);
1217extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t);
1218
1219/*
1220 * Candidates for mandatory locking have the setgid bit set
1221 * but no group execute bit - an otherwise meaningless combination.
1222 */
1223#define MANDATORY_LOCK(inode) \
1224 (IS_MANDLOCK(inode) && ((inode)->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
1225
1226static inline int locks_verify_locked(struct inode *inode)
1227{
1228 if (MANDATORY_LOCK(inode))
1229 return locks_mandatory_locked(inode);
1230 return 0;
1231}
1232
1233extern int rw_verify_area(int, struct file *, loff_t *, size_t);
1234
1235static inline int locks_verify_truncate(struct inode *inode,
1236 struct file *filp,
1237 loff_t size)
1238{
1239 if (inode->i_flock && MANDATORY_LOCK(inode))
1240 return locks_mandatory_area(
1241 FLOCK_VERIFY_WRITE, inode, filp,
1242 size < inode->i_size ? size : inode->i_size,
1243 (size < inode->i_size ? inode->i_size - size
1244 : size - inode->i_size)
1245 );
1246 return 0;
1247}
1248
1249static inline int break_lease(struct inode *inode, unsigned int mode)
1250{
1251 if (inode->i_flock)
1252 return __break_lease(inode, mode);
1253 return 0;
1254}
1255
1256/* fs/open.c */
1257
1258extern int do_truncate(struct dentry *, loff_t start);
1259extern struct file *filp_open(const char *, int, int);
1260extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
1261extern int filp_close(struct file *, fl_owner_t id);
1262extern char * getname(const char __user *);
1263
1264/* fs/dcache.c */
1265extern void __init vfs_caches_init_early(void);
1266extern void __init vfs_caches_init(unsigned long);
1267
1268#define __getname() kmem_cache_alloc(names_cachep, SLAB_KERNEL)
1269#define __putname(name) kmem_cache_free(names_cachep, (void *)(name))
1270#ifndef CONFIG_AUDITSYSCALL
1271#define putname(name) __putname(name)
1272#else
1273extern void putname(const char *name);
1274#endif
1275
1276extern int register_blkdev(unsigned int, const char *);
1277extern int unregister_blkdev(unsigned int, const char *);
1278extern struct block_device *bdget(dev_t);
1279extern void bd_set_size(struct block_device *, loff_t size);
1280extern void bd_forget(struct inode *inode);
1281extern void bdput(struct block_device *);
1282extern struct block_device *open_by_devnum(dev_t, unsigned);
1283extern struct file_operations def_blk_fops;
1284extern struct address_space_operations def_blk_aops;
1285extern struct file_operations def_chr_fops;
1286extern struct file_operations bad_sock_fops;
1287extern struct file_operations def_fifo_fops;
1288extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long);
1289extern int blkdev_ioctl(struct inode *, struct file *, unsigned, unsigned long);
1290extern long compat_blkdev_ioctl(struct file *, unsigned, unsigned long);
1291extern int blkdev_get(struct block_device *, mode_t, unsigned);
1292extern int blkdev_put(struct block_device *);
1293extern int bd_claim(struct block_device *, void *);
1294extern void bd_release(struct block_device *);
1295
1296/* fs/char_dev.c */
1297extern int alloc_chrdev_region(dev_t *, unsigned, unsigned, const char *);
1298extern int register_chrdev_region(dev_t, unsigned, const char *);
1299extern int register_chrdev(unsigned int, const char *,
1300 struct file_operations *);
1301extern int unregister_chrdev(unsigned int, const char *);
1302extern void unregister_chrdev_region(dev_t, unsigned);
1303extern int chrdev_open(struct inode *, struct file *);
1304
1305/* fs/block_dev.c */
1306#define BDEVNAME_SIZE 32 /* Largest string for a blockdev identifier */
1307extern const char *__bdevname(dev_t, char *buffer);
1308extern const char *bdevname(struct block_device *bdev, char *buffer);
1309extern struct block_device *lookup_bdev(const char *);
1310extern struct block_device *open_bdev_excl(const char *, int, void *);
1311extern void close_bdev_excl(struct block_device *);
1312
1313extern void init_special_inode(struct inode *, umode_t, dev_t);
1314
1315/* Invalid inode operations -- fs/bad_inode.c */
1316extern void make_bad_inode(struct inode *);
1317extern int is_bad_inode(struct inode *);
1318
1319extern struct file_operations read_fifo_fops;
1320extern struct file_operations write_fifo_fops;
1321extern struct file_operations rdwr_fifo_fops;
1322extern struct file_operations read_pipe_fops;
1323extern struct file_operations write_pipe_fops;
1324extern struct file_operations rdwr_pipe_fops;
1325
1326extern int fs_may_remount_ro(struct super_block *);
1327
1328/*
1329 * return READ, READA, or WRITE
1330 */
1331#define bio_rw(bio) ((bio)->bi_rw & (RW_MASK | RWA_MASK))
1332
1333/*
1334 * return data direction, READ or WRITE
1335 */
1336#define bio_data_dir(bio) ((bio)->bi_rw & 1)
1337
1338extern int check_disk_change(struct block_device *);
1339extern int invalidate_inodes(struct super_block *);
1340extern int __invalidate_device(struct block_device *, int);
1341extern int invalidate_partition(struct gendisk *, int);
1342unsigned long invalidate_mapping_pages(struct address_space *mapping,
1343 pgoff_t start, pgoff_t end);
1344unsigned long invalidate_inode_pages(struct address_space *mapping);
1345static inline void invalidate_remote_inode(struct inode *inode)
1346{
1347 if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
1348 S_ISLNK(inode->i_mode))
1349 invalidate_inode_pages(inode->i_mapping);
1350}
1351extern int invalidate_inode_pages2(struct address_space *mapping);
1352extern int invalidate_inode_pages2_range(struct address_space *mapping,
1353 pgoff_t start, pgoff_t end);
1354extern int write_inode_now(struct inode *, int);
1355extern int filemap_fdatawrite(struct address_space *);
1356extern int filemap_flush(struct address_space *);
1357extern int filemap_fdatawait(struct address_space *);
1358extern int filemap_write_and_wait(struct address_space *mapping);
1359extern int filemap_write_and_wait_range(struct address_space *mapping,
1360 loff_t lstart, loff_t lend);
1361extern void sync_supers(void);
1362extern void sync_filesystems(int wait);
1363extern void emergency_sync(void);
1364extern void emergency_remount(void);
1365extern int do_remount_sb(struct super_block *sb, int flags,
1366 void *data, int force);
1367extern sector_t bmap(struct inode *, sector_t);
1368extern int setattr_mask(unsigned int);
1369extern int notify_change(struct dentry *, struct iattr *);
1370extern int permission(struct inode *, int, struct nameidata *);
1371extern int generic_permission(struct inode *, int,
1372 int (*check_acl)(struct inode *, int));
1373
1374extern int get_write_access(struct inode *);
1375extern int deny_write_access(struct file *);
1376static inline void put_write_access(struct inode * inode)
1377{
1378 atomic_dec(&inode->i_writecount);
1379}
1380static inline void allow_write_access(struct file *file)
1381{
1382 if (file)
1383 atomic_inc(&file->f_dentry->d_inode->i_writecount);
1384}
1385extern int do_pipe(int *);
1386
1387extern int open_namei(const char *, int, int, struct nameidata *);
1388extern int may_open(struct nameidata *, int, int);
1389
1390extern int kernel_read(struct file *, unsigned long, char *, unsigned long);
1391extern struct file * open_exec(const char *);
1392
1393/* fs/dcache.c -- generic fs support functions */
1394extern int is_subdir(struct dentry *, struct dentry *);
1395extern ino_t find_inode_number(struct dentry *, struct qstr *);
1396
1397#include <linux/err.h>
1398
1399/* needed for stackable file system support */
1400extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
1401
1402extern loff_t vfs_llseek(struct file *file, loff_t offset, int origin);
1403
1404extern void inode_init_once(struct inode *);
1405extern void iput(struct inode *);
1406extern struct inode * igrab(struct inode *);
1407extern ino_t iunique(struct super_block *, ino_t);
1408extern int inode_needs_sync(struct inode *inode);
1409extern void generic_delete_inode(struct inode *inode);
1410
1411extern struct inode *ilookup5(struct super_block *sb, unsigned long hashval,
1412 int (*test)(struct inode *, void *), void *data);
1413extern struct inode *ilookup(struct super_block *sb, unsigned long ino);
1414
1415extern struct inode * iget5_locked(struct super_block *, unsigned long, int (*test)(struct inode *, void *), int (*set)(struct inode *, void *), void *);
1416extern struct inode * iget_locked(struct super_block *, unsigned long);
1417extern void unlock_new_inode(struct inode *);
1418
1419static inline struct inode *iget(struct super_block *sb, unsigned long ino)
1420{
1421 struct inode *inode = iget_locked(sb, ino);
1422
1423 if (inode && (inode->i_state & I_NEW)) {
1424 sb->s_op->read_inode(inode);
1425 unlock_new_inode(inode);
1426 }
1427
1428 return inode;
1429}
1430
1431extern void __iget(struct inode * inode);
1432extern void clear_inode(struct inode *);
1433extern void destroy_inode(struct inode *);
1434extern struct inode *new_inode(struct super_block *);
1435extern int remove_suid(struct dentry *);
1436extern void remove_dquot_ref(struct super_block *, int, struct list_head *);
1437extern struct semaphore iprune_sem;
1438
1439extern void __insert_inode_hash(struct inode *, unsigned long hashval);
1440extern void remove_inode_hash(struct inode *);
1441static inline void insert_inode_hash(struct inode *inode) {
1442 __insert_inode_hash(inode, inode->i_ino);
1443}
1444
1445extern struct file * get_empty_filp(void);
1446extern void file_move(struct file *f, struct list_head *list);
1447extern void file_kill(struct file *f);
1448struct bio;
1449extern void submit_bio(int, struct bio *);
1450extern int bdev_read_only(struct block_device *);
1451extern int set_blocksize(struct block_device *, int);
1452extern int sb_set_blocksize(struct super_block *, int);
1453extern int sb_min_blocksize(struct super_block *, int);
1454
1455extern int generic_file_mmap(struct file *, struct vm_area_struct *);
1456extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *);
1457extern int file_read_actor(read_descriptor_t * desc, struct page *page, unsigned long offset, unsigned long size);
1458extern int file_send_actor(read_descriptor_t * desc, struct page *page, unsigned long offset, unsigned long size);
1459extern ssize_t generic_file_read(struct file *, char __user *, size_t, loff_t *);
1460int generic_write_checks(struct file *file, loff_t *pos, size_t *count, int isblk);
1461extern ssize_t generic_file_write(struct file *, const char __user *, size_t, loff_t *);
1462extern ssize_t generic_file_aio_read(struct kiocb *, char __user *, size_t, loff_t);
1463extern ssize_t __generic_file_aio_read(struct kiocb *, const struct iovec *, unsigned long, loff_t *);
1464extern ssize_t generic_file_aio_write(struct kiocb *, const char __user *, size_t, loff_t);
1465extern ssize_t generic_file_aio_write_nolock(struct kiocb *, const struct iovec *,
1466 unsigned long, loff_t *);
1467extern ssize_t generic_file_direct_write(struct kiocb *, const struct iovec *,
1468 unsigned long *, loff_t, loff_t *, size_t, size_t);
1469extern ssize_t generic_file_buffered_write(struct kiocb *, const struct iovec *,
1470 unsigned long, loff_t, loff_t *, size_t, ssize_t);
1471extern ssize_t do_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos);
1472extern ssize_t do_sync_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos);
1473ssize_t generic_file_write_nolock(struct file *file, const struct iovec *iov,
1474 unsigned long nr_segs, loff_t *ppos);
1475extern ssize_t generic_file_sendfile(struct file *, loff_t *, size_t, read_actor_t, void *);
1476extern void do_generic_mapping_read(struct address_space *mapping,
1477 struct file_ra_state *, struct file *,
1478 loff_t *, read_descriptor_t *, read_actor_t);
1479extern void
1480file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping);
1481extern ssize_t generic_file_direct_IO(int rw, struct kiocb *iocb,
1482 const struct iovec *iov, loff_t offset, unsigned long nr_segs);
1483extern ssize_t generic_file_readv(struct file *filp, const struct iovec *iov,
1484 unsigned long nr_segs, loff_t *ppos);
1485ssize_t generic_file_writev(struct file *filp, const struct iovec *iov,
1486 unsigned long nr_segs, loff_t *ppos);
1487extern loff_t no_llseek(struct file *file, loff_t offset, int origin);
1488extern loff_t generic_file_llseek(struct file *file, loff_t offset, int origin);
1489extern loff_t remote_llseek(struct file *file, loff_t offset, int origin);
1490extern int generic_file_open(struct inode * inode, struct file * filp);
1491extern int nonseekable_open(struct inode * inode, struct file * filp);
1492
1493static inline void do_generic_file_read(struct file * filp, loff_t *ppos,
1494 read_descriptor_t * desc,
1495 read_actor_t actor)
1496{
1497 do_generic_mapping_read(filp->f_mapping,
1498 &filp->f_ra,
1499 filp,
1500 ppos,
1501 desc,
1502 actor);
1503}
1504
1505ssize_t __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
1506 struct block_device *bdev, const struct iovec *iov, loff_t offset,
1507 unsigned long nr_segs, get_blocks_t get_blocks, dio_iodone_t end_io,
1508 int lock_type);
1509
1510enum {
1511 DIO_LOCKING = 1, /* need locking between buffered and direct access */
1512 DIO_NO_LOCKING, /* bdev; no locking at all between buffered/direct */
1513 DIO_OWN_LOCKING, /* filesystem locks buffered and direct internally */
1514};
1515
1516static inline ssize_t blockdev_direct_IO(int rw, struct kiocb *iocb,
1517 struct inode *inode, struct block_device *bdev, const struct iovec *iov,
1518 loff_t offset, unsigned long nr_segs, get_blocks_t get_blocks,
1519 dio_iodone_t end_io)
1520{
1521 return __blockdev_direct_IO(rw, iocb, inode, bdev, iov, offset,
1522 nr_segs, get_blocks, end_io, DIO_LOCKING);
1523}
1524
1525static inline ssize_t blockdev_direct_IO_no_locking(int rw, struct kiocb *iocb,
1526 struct inode *inode, struct block_device *bdev, const struct iovec *iov,
1527 loff_t offset, unsigned long nr_segs, get_blocks_t get_blocks,
1528 dio_iodone_t end_io)
1529{
1530 return __blockdev_direct_IO(rw, iocb, inode, bdev, iov, offset,
1531 nr_segs, get_blocks, end_io, DIO_NO_LOCKING);
1532}
1533
1534static inline ssize_t blockdev_direct_IO_own_locking(int rw, struct kiocb *iocb,
1535 struct inode *inode, struct block_device *bdev, const struct iovec *iov,
1536 loff_t offset, unsigned long nr_segs, get_blocks_t get_blocks,
1537 dio_iodone_t end_io)
1538{
1539 return __blockdev_direct_IO(rw, iocb, inode, bdev, iov, offset,
1540 nr_segs, get_blocks, end_io, DIO_OWN_LOCKING);
1541}
1542
1543extern struct file_operations generic_ro_fops;
1544
1545#define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
1546
1547extern int vfs_readlink(struct dentry *, char __user *, int, const char *);
1548extern int vfs_follow_link(struct nameidata *, const char *);
1549extern int page_readlink(struct dentry *, char __user *, int);
1550extern int page_follow_link_light(struct dentry *, struct nameidata *);
1551extern void page_put_link(struct dentry *, struct nameidata *);
1552extern int page_symlink(struct inode *inode, const char *symname, int len);
1553extern struct inode_operations page_symlink_inode_operations;
1554extern int generic_readlink(struct dentry *, char __user *, int);
1555extern void generic_fillattr(struct inode *, struct kstat *);
1556extern int vfs_getattr(struct vfsmount *, struct dentry *, struct kstat *);
1557void inode_add_bytes(struct inode *inode, loff_t bytes);
1558void inode_sub_bytes(struct inode *inode, loff_t bytes);
1559loff_t inode_get_bytes(struct inode *inode);
1560void inode_set_bytes(struct inode *inode, loff_t bytes);
1561
1562extern int vfs_readdir(struct file *, filldir_t, void *);
1563
1564extern int vfs_stat(char __user *, struct kstat *);
1565extern int vfs_lstat(char __user *, struct kstat *);
1566extern int vfs_fstat(unsigned int, struct kstat *);
1567
1568extern int vfs_ioctl(struct file *, unsigned int, unsigned int, unsigned long);
1569
1570extern struct file_system_type *get_fs_type(const char *name);
1571extern struct super_block *get_super(struct block_device *);
1572extern struct super_block *user_get_super(dev_t);
1573extern void drop_super(struct super_block *sb);
1574
1575extern int dcache_dir_open(struct inode *, struct file *);
1576extern int dcache_dir_close(struct inode *, struct file *);
1577extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
1578extern int dcache_readdir(struct file *, void *, filldir_t);
1579extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
1580extern int simple_statfs(struct super_block *, struct kstatfs *);
1581extern int simple_link(struct dentry *, struct inode *, struct dentry *);
1582extern int simple_unlink(struct inode *, struct dentry *);
1583extern int simple_rmdir(struct inode *, struct dentry *);
1584extern int simple_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
1585extern int simple_sync_file(struct file *, struct dentry *, int);
1586extern int simple_empty(struct dentry *);
1587extern int simple_readpage(struct file *file, struct page *page);
1588extern int simple_prepare_write(struct file *file, struct page *page,
1589 unsigned offset, unsigned to);
1590extern int simple_commit_write(struct file *file, struct page *page,
1591 unsigned offset, unsigned to);
1592
1593extern struct dentry *simple_lookup(struct inode *, struct dentry *, struct nameidata *);
1594extern ssize_t generic_read_dir(struct file *, char __user *, size_t, loff_t *);
1595extern struct file_operations simple_dir_operations;
1596extern struct inode_operations simple_dir_inode_operations;
1597struct tree_descr { char *name; struct file_operations *ops; int mode; };
1598struct dentry *d_alloc_name(struct dentry *, const char *);
1599extern int simple_fill_super(struct super_block *, int, struct tree_descr *);
1600extern int simple_pin_fs(char *name, struct vfsmount **mount, int *count);
1601extern void simple_release_fs(struct vfsmount **mount, int *count);
1602
1603extern ssize_t simple_read_from_buffer(void __user *, size_t, loff_t *, const void *, size_t);
1604
1605extern int inode_change_ok(struct inode *, struct iattr *);
1606extern int __must_check inode_setattr(struct inode *, struct iattr *);
1607
1608extern void inode_update_time(struct inode *inode, int ctime_too);
1609
1610static inline ino_t parent_ino(struct dentry *dentry)
1611{
1612 ino_t res;
1613
1614 spin_lock(&dentry->d_lock);
1615 res = dentry->d_parent->d_inode->i_ino;
1616 spin_unlock(&dentry->d_lock);
1617 return res;
1618}
1619
1620/* kernel/fork.c */
1621extern int unshare_files(void);
1622
1623/* Transaction based IO helpers */
1624
1625/*
1626 * An argresp is stored in an allocated page and holds the
1627 * size of the argument or response, along with its content
1628 */
1629struct simple_transaction_argresp {
1630 ssize_t size;
1631 char data[0];
1632};
1633
1634#define SIMPLE_TRANSACTION_LIMIT (PAGE_SIZE - sizeof(struct simple_transaction_argresp))
1635
1636char *simple_transaction_get(struct file *file, const char __user *buf,
1637 size_t size);
1638ssize_t simple_transaction_read(struct file *file, char __user *buf,
1639 size_t size, loff_t *pos);
1640int simple_transaction_release(struct inode *inode, struct file *file);
1641
1642static inline void simple_transaction_set(struct file *file, size_t n)
1643{
1644 struct simple_transaction_argresp *ar = file->private_data;
1645
1646 BUG_ON(n > SIMPLE_TRANSACTION_LIMIT);
1647
1648 /*
1649 * The barrier ensures that ar->size will really remain zero until
1650 * ar->data is ready for reading.
1651 */
1652 smp_mb();
1653 ar->size = n;
1654}
1655
1656#ifdef CONFIG_SECURITY
1657static inline char *alloc_secdata(void)
1658{
1659 return (char *)get_zeroed_page(GFP_KERNEL);
1660}
1661
1662static inline void free_secdata(void *secdata)
1663{
1664 free_page((unsigned long)secdata);
1665}
1666#else
1667static inline char *alloc_secdata(void)
1668{
1669 return (char *)1;
1670}
1671
1672static inline void free_secdata(void *secdata)
1673{ }
1674#endif /* CONFIG_SECURITY */
1675
1676#endif /* __KERNEL__ */
1677#endif /* _LINUX_FS_H */
diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
new file mode 100644
index 000000000000..c623d12a486e
--- /dev/null
+++ b/include/linux/fs_struct.h
@@ -0,0 +1,28 @@
1#ifndef _LINUX_FS_STRUCT_H
2#define _LINUX_FS_STRUCT_H
3
4struct dentry;
5struct vfsmount;
6
7struct fs_struct {
8 atomic_t count;
9 rwlock_t lock;
10 int umask;
11 struct dentry * root, * pwd, * altroot;
12 struct vfsmount * rootmnt, * pwdmnt, * altrootmnt;
13};
14
15#define INIT_FS { \
16 .count = ATOMIC_INIT(1), \
17 .lock = RW_LOCK_UNLOCKED, \
18 .umask = 0022, \
19}
20
21extern void exit_fs(struct task_struct *);
22extern void set_fs_altroot(void);
23extern void set_fs_root(struct fs_struct *, struct vfsmount *, struct dentry *);
24extern void set_fs_pwd(struct fs_struct *, struct vfsmount *, struct dentry *);
25extern struct fs_struct *copy_fs_struct(struct fs_struct *);
26extern void put_fs_struct(struct fs_struct *);
27
28#endif /* _LINUX_FS_STRUCT_H */
diff --git a/include/linux/fsl_devices.h b/include/linux/fsl_devices.h
new file mode 100644
index 000000000000..faaff4c64559
--- /dev/null
+++ b/include/linux/fsl_devices.h
@@ -0,0 +1,78 @@
1/*
2 * include/linux/fsl_devices.h
3 *
4 * Definitions for any platform device related flags or structures for
5 * Freescale processor devices
6 *
7 * Maintainer: Kumar Gala (kumar.gala@freescale.com)
8 *
9 * Copyright 2004 Freescale Semiconductor, Inc
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 */
16
17#ifdef __KERNEL__
18#ifndef _FSL_DEVICE_H_
19#define _FSL_DEVICE_H_
20
21#include <linux/types.h>
22
23/*
24 * Some conventions on how we handle peripherals on Freescale chips
25 *
26 * unique device: a platform_device entry in fsl_plat_devs[] plus
27 * associated device information in its platform_data structure.
28 *
29 * A chip is described by a set of unique devices.
30 *
31 * Each sub-arch has its own master list of unique devices and
32 * enumerates them by enum fsl_devices in a sub-arch specific header
33 *
34 * The platform data structure is broken into two parts. The
35 * first is device specific information that help identify any
36 * unique features of a peripheral. The second is any
37 * information that may be defined by the board or how the device
38 * is connected externally of the chip.
39 *
40 * naming conventions:
41 * - platform data structures: <driver>_platform_data
42 * - platform data device flags: FSL_<driver>_DEV_<FLAG>
43 * - platform data board flags: FSL_<driver>_BRD_<FLAG>
44 *
45 */
46
47struct gianfar_platform_data {
48 /* device specific information */
49 u32 device_flags;
50 u32 phy_reg_addr;
51
52 /* board specific information */
53 u32 board_flags;
54 u32 phyid;
55 u32 interruptPHY;
56 u8 mac_addr[6];
57};
58
59/* Flags related to gianfar device features */
60#define FSL_GIANFAR_DEV_HAS_GIGABIT 0x00000001
61#define FSL_GIANFAR_DEV_HAS_COALESCE 0x00000002
62#define FSL_GIANFAR_DEV_HAS_RMON 0x00000004
63#define FSL_GIANFAR_DEV_HAS_MULTI_INTR 0x00000008
64
65/* Flags in gianfar_platform_data */
66#define FSL_GIANFAR_BRD_HAS_PHY_INTR 0x00000001 /* if not set use a timer */
67
68struct fsl_i2c_platform_data {
69 /* device specific information */
70 u32 device_flags;
71};
72
73/* Flags related to I2C device features */
74#define FSL_I2C_DEV_SEPARATE_DFSRR 0x00000001
75#define FSL_I2C_DEV_CLOCK_5200 0x00000002
76
77#endif /* _FSL_DEVICE_H_ */
78#endif /* __KERNEL__ */
diff --git a/include/linux/ftape-header-segment.h b/include/linux/ftape-header-segment.h
new file mode 100644
index 000000000000..4732218f0708
--- /dev/null
+++ b/include/linux/ftape-header-segment.h
@@ -0,0 +1,122 @@
1#ifndef _FTAPE_HEADER_SEGMENT_H
2#define _FTAPE_HEADER_SEGMENT_H
3
4/*
5 * Copyright (C) 1996-1997 Claus-Justus Heine.
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 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; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 *
22 * $Source: /homes/cvs/ftape-stacked/include/linux/ftape-header-segment.h,v $
23 * $Revision: 1.2 $
24 * $Date: 1997/10/05 19:19:28 $
25 *
26 * This file defines some offsets into the header segment of a
27 * floppy tape cartridge. For use with the QIC-40/80/3010/3020
28 * floppy-tape driver "ftape" for Linux.
29 */
30
31#define FT_SIGNATURE 0 /* must be 0xaa55aa55 */
32#define FT_FMT_CODE 4
33#define FT_REV_LEVEL 5 /* only for QIC-80 since. Rev. L (== 0x0c) */
34#define FT_HSEG_1 6 /* first header segment, except for format code 6 */
35#define FT_HSEG_2 8 /* second header segment, except for format code 6 */
36#define FT_FRST_SEG 10 /* first data segment, except for format code 6 */
37#define FT_LAST_SEG 12 /* last data segment, except for format code 6 */
38#define FT_FMT_DATE 14 /* date and time of most recent format, see below */
39#define FT_WR_DATE 18 /* date and time of most recent write or format */
40#define FT_SPT 24 /* segments per track */
41#define FT_TPC 26 /* tracks per cartridge */
42#define FT_FHM 27 /* floppy drive head (maximum of it) */
43#define FT_FTM 28 /* floppy track max. */
44#define FT_FSM 29 /* floppy sector max. (128) */
45#define FT_LABEL 30 /* floppy tape label */
46#define FT_LABEL_DATE 74 /* date and time the tape label was written */
47#define FT_LABEL_SZ (FT_LABEL_DATE - FT_LABEL)
48#define FT_CMAP_START 78 /* starting segment of compression map */
49#define FT_FMT_ERROR 128 /* must be set to 0xff if remainder gets lost during
50 * tape format
51 */
52#define FT_SEG_CNT 130 /* number of seg. written, formatted or verified
53 * through lifetime of tape (why not read?)
54 */
55#define FT_INIT_DATE 138 /* date and time of initial tape format */
56#define FT_FMT_CNT 142 /* number of times tape has been formatted */
57#define FT_FSL_CNT 144 /* number of segments in failed sector log */
58#define FT_MK_CODE 146 /* id string of tape manufacturer */
59#define FT_LOT_CODE 190 /* tape manufacturer lot code */
60#define FT_6_HSEG_1 234 /* first header segment for format code 6 */
61#define FT_6_HSEG_2 238 /* second header segment for format code 6 */
62#define FT_6_FRST_SEG 242 /* first data segment for format code 6 */
63#define FT_6_LAST_SEG 246 /* last data segment for format code 6 */
64
65#define FT_FSL 256
66#define FT_HEADER_END 256 /* space beyond this point:
67 * format codes 2, 3 and 5:
68 * - failed sector log until byte 2047
69 * - bad sector map in the reamining part of segment
70 * format codes 4 and 6:
71 * - bad sector map starts hear
72 */
73
74
75/* value to be stored at the FT_SIGNATURE offset
76 */
77#define FT_HSEG_MAGIC 0xaa55aa55
78#define FT_D2G_MAGIC 0x82288228 /* Ditto 2GB */
79
80/* data and time encoding: */
81#define FT_YEAR_SHIFT 25
82#define FT_YEAR_MASK 0xfe000000
83#define FT_YEAR_0 1970
84#define FT_YEAR_MAX 127
85#define FT_YEAR(year) ((((year)-FT_YEAR_0)<<FT_YEAR_SHIFT)&FT_YEAR_MASK)
86
87#define FT_TIME_SHIFT 0
88#define FT_TIME_MASK 0x01FFFFFF
89#define FT_TIME_MAX 0x01ea6dff /* last second of a year */
90#define FT_TIME(mo,d,h,m,s) \
91 ((((s)+60*((m)+60*((h)+24*((d)+31*(mo))))) & FT_TIME_MASK))
92
93#define FT_TIME_STAMP(y,mo,d,h,m,s) (FT_YEAR(y) | FT_TIME(mo,d,h,m,s))
94
95/* values for the format code field */
96typedef enum {
97 fmt_normal = 2, /* QIC-80 post Rev. B 205Ft or 307Ft tape */
98 fmt_1100ft = 3, /* QIC-80 post Rev. B 1100Ft tape */
99 fmt_var = 4, /* QIC-80 post Rev. B variabel length format */
100 fmt_425ft = 5, /* QIC-80 post Rev. B 425Ft tape */
101 fmt_big = 6 /* QIC-3010/3020 variable length tape with more
102 * than 2^16 segments per tape
103 */
104} ft_format_type;
105
106/* definitions for the failed sector log */
107#define FT_FSL_SIZE (2 * FT_SECTOR_SIZE - FT_HEADER_END)
108#define FT_FSL_MAX_ENTRIES (FT_FSL_SIZE/sizeof(__u32))
109
110typedef struct ft_fsl_entry {
111 __u16 segment;
112 __u16 date;
113} __attribute__ ((packed)) ft_fsl_entry;
114
115
116/* date encoding for the failed sector log
117 * month: 1..12, day: 1..31, year: 1970..2097
118 */
119#define FT_FSL_TIME_STAMP(y,m,d) \
120 (((((y) - FT_YEAR_0)<<9)&0xfe00) | (((m)<<5)&0x01e0) | ((d)&0x001f))
121
122#endif /* _FTAPE_HEADER_SEGMENT_H */
diff --git a/include/linux/ftape-vendors.h b/include/linux/ftape-vendors.h
new file mode 100644
index 000000000000..ec1a81f059e5
--- /dev/null
+++ b/include/linux/ftape-vendors.h
@@ -0,0 +1,137 @@
1#ifndef _FTAPE_VENDORS_H
2#define _FTAPE_VENDORS_H
3
4/*
5 * Copyright (C) 1993-1996 Bas Laarhoven,
6 * (C) 1996-1997 Claus-Justus Heine.
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, or (at your option)
11 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; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 *
23 * $Source: /homes/cvs/ftape-stacked/include/linux/ftape-vendors.h,v $
24 * $Revision: 1.6 $
25 * $Date: 1997/10/09 15:38:11 $
26 *
27 * This file contains the supported drive types with their
28 * QIC-117 spec. vendor code and drive dependent configuration
29 * information.
30 */
31
32typedef enum {
33 unknown_wake_up = 0,
34 no_wake_up,
35 wake_up_colorado,
36 wake_up_mountain,
37 wake_up_insight,
38} wake_up_types;
39
40typedef struct {
41 wake_up_types wake_up; /* see wake_up_types */
42 char *name; /* Text describing the drive */
43} wakeup_method;
44
45/* Note: order of entries in WAKEUP_METHODS must be so that a variable
46 * of type wake_up_types can be used as an index in the array.
47 */
48#define WAKEUP_METHODS { \
49 { unknown_wake_up, "Unknown" }, \
50 { no_wake_up, "None" }, \
51 { wake_up_colorado, "Colorado" }, \
52 { wake_up_mountain, "Mountain" }, \
53 { wake_up_insight, "Motor-on" }, \
54}
55
56typedef struct {
57 unsigned int vendor_id; /* vendor id from drive */
58 int speed; /* maximum tape transport speed (ips) */
59 wake_up_types wake_up; /* see wake_up_types */
60 char *name; /* Text describing the drive */
61} vendor_struct;
62
63#define UNKNOWN_VENDOR (-1)
64
65#define QIC117_VENDORS { \
66/* see _vendor_struct */ \
67 { 0x00000, 82, wake_up_colorado, "Colorado DJ-10 (old)" }, \
68 { 0x00047, 90, wake_up_colorado, "Colorado DJ-10/DJ-20" }, \
69 { 0x011c2, 84, wake_up_colorado, "Colorado 700" }, \
70 { 0x011c3, 90, wake_up_colorado, "Colorado 1400" }, \
71 { 0x011c4, 84, wake_up_colorado, "Colorado DJ-10/DJ-20 (new)" }, \
72 { 0x011c5, 84, wake_up_colorado, "HP Colorado T1000" }, \
73 { 0x011c6, 90, wake_up_colorado, "HP Colorado T3000" }, \
74 { 0x00005, 45, wake_up_mountain, "Archive 5580i" }, \
75 { 0x10005, 50, wake_up_insight, "Insight 80Mb, Irwin 80SX" }, \
76 { 0x00140, 74, wake_up_mountain, "Archive S.Hornet [Identity/Escom]" }, \
77 { 0x00146, 72, wake_up_mountain, "Archive 31250Q [Escom]" }, \
78 { 0x0014a, 100, wake_up_mountain, "Archive XL9250i [Conner/Escom]" }, \
79 { 0x0014c, 98, wake_up_mountain, "Conner C250MQT" }, \
80 { 0x0014e, 80, wake_up_mountain, "Conner C250MQ" }, \
81 { 0x00150, 80, wake_up_mountain, "Conner TSM420R/TST800R" }, \
82 { 0x00152, 80, wake_up_mountain, "Conner TSM850R" }, \
83 { 0x00156, 80, wake_up_mountain, "Conner TSM850R/1700R/TST3200R" }, \
84 { 0x00180, 0, wake_up_mountain, "Summit SE 150" }, \
85 { 0x00181, 85, wake_up_mountain, "Summit SE 250, Mountain FS8000" }, \
86 { 0x001c1, 82, no_wake_up, "Wangtek 3040F" }, \
87 { 0x001c8, 64, no_wake_up, "Wangtek 3080F" }, \
88 { 0x001c8, 64, wake_up_colorado, "Wangtek 3080F" }, \
89 { 0x001ca, 67, no_wake_up, "Wangtek 3080F (new)" }, \
90 { 0x001cc, 77, wake_up_colorado, "Wangtek 3200 / Teac 700" }, \
91 { 0x001cd, 75, wake_up_colorado, "Reveal TB1400" }, \
92 { 0x00380, 85, wake_up_colorado, "Exabyte Eagle-96" }, \
93 { 0x00381, 85, wake_up_colorado, "Exabyte Eagle TR-3" }, \
94 { 0x00382, 85, wake_up_colorado, "Exabyte Eagle TR-3" }, \
95 { 0x003ce, 77, wake_up_colorado, "Teac 800" }, \
96 { 0x003cf, 0, wake_up_colorado, "Teac FT3010TR" }, \
97 { 0x08880, 64, no_wake_up, "Iomega 250, Ditto 800" }, \
98 { 0x08880, 64, wake_up_colorado, "Iomega 250, Ditto 800" }, \
99 { 0x08880, 64, wake_up_insight, "Iomega 250, Ditto 800" }, \
100 { 0x08881, 80, wake_up_colorado, "Iomega 700" }, \
101 { 0x08882, 80, wake_up_colorado, "Iomega 3200" }, \
102 { 0x08883, 80, wake_up_colorado, "Iomega DITTO 2GB" }, \
103 { 0x00021, 70, no_wake_up, "AIWA CT-803" }, \
104 { 0x004c0, 80, no_wake_up, "AIWA TD-S1600" }, \
105 { 0x00021, 0, wake_up_mountain, "COREtape QIC80" }, \
106 { 0x00441, 0, wake_up_mountain, "ComByte DoublePlay" }, \
107 { 0x00481, 127, wake_up_mountain, "PERTEC MyTape 800" }, \
108 { 0x00483, 130, wake_up_mountain, "PERTEC MyTape 3200" }, \
109 { UNKNOWN_VENDOR, 0, no_wake_up, "unknown" } \
110}
111
112#define QIC117_MAKE_CODES { \
113 { 0, "Unassigned" }, \
114 { 1, "Alloy Computer Products" }, \
115 { 2, "3M" }, \
116 { 3, "Tandberg Data" }, \
117 { 4, "Colorado" }, \
118 { 5, "Archive/Conner" }, \
119 { 6, "Mountain/Summit Memory Systems" }, \
120 { 7, "Wangtek/Rexon/Tecmar" }, \
121 { 8, "Sony" }, \
122 { 9, "Cipher Data Products" }, \
123 { 10, "Irwin Magnetic Systems" }, \
124 { 11, "Braemar" }, \
125 { 12, "Verbatim" }, \
126 { 13, "Core International" }, \
127 { 14, "Exabyte" }, \
128 { 15, "Teac" }, \
129 { 16, "Gigatek" }, \
130 { 17, "ComByte" }, \
131 { 18, "PERTEC Memories" }, \
132 { 19, "Aiwa" }, \
133 { 71, "Colorado" }, \
134 { 546, "Iomega Inc" }, \
135}
136
137#endif /* _FTAPE_VENDORS_H */
diff --git a/include/linux/ftape.h b/include/linux/ftape.h
new file mode 100644
index 000000000000..c6b38d5b9186
--- /dev/null
+++ b/include/linux/ftape.h
@@ -0,0 +1,202 @@
1#ifndef _FTAPE_H
2#define _FTAPE_H
3
4/*
5 * Copyright (C) 1994-1996 Bas Laarhoven,
6 * (C) 1996-1997 Claus-Justus Heine.
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, or (at your option)
11 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; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 *
23 * $Source: /homes/cvs/ftape-stacked/include/linux/ftape.h,v $
24 * $Revision: 1.17.6.4 $
25 * $Date: 1997/11/25 01:52:54 $
26 *
27 * This file contains global definitions, typedefs and macro's
28 * for the QIC-40/80/3010/3020 floppy-tape driver for Linux.
29 */
30
31#define FTAPE_VERSION "ftape v3.04d 25/11/97"
32
33#ifdef __KERNEL__
34#include <linux/interrupt.h>
35#include <linux/mm.h>
36#endif
37#include <linux/types.h>
38#include <linux/config.h>
39#include <linux/mtio.h>
40
41#define FT_SECTOR(x) (x+1) /* sector offset into real sector */
42#define FT_SECTOR_SIZE 1024
43#define FT_SECTORS_PER_SEGMENT 32
44#define FT_ECC_SECTORS 3
45#define FT_SEGMENT_SIZE ((FT_SECTORS_PER_SEGMENT - FT_ECC_SECTORS) * FT_SECTOR_SIZE)
46#define FT_BUFF_SIZE (FT_SECTORS_PER_SEGMENT * FT_SECTOR_SIZE)
47
48/*
49 * bits of the minor device number that define drive selection
50 * methods. Could be used one day to access multiple tape
51 * drives on the same controller.
52 */
53#define FTAPE_SEL_A 0
54#define FTAPE_SEL_B 1
55#define FTAPE_SEL_C 2
56#define FTAPE_SEL_D 3
57#define FTAPE_SEL_MASK 3
58#define FTAPE_SEL(unit) ((unit) & FTAPE_SEL_MASK)
59#define FTAPE_NO_REWIND 4 /* mask for minor nr */
60
61/* the following two may be reported when MTIOCGET is requested ... */
62typedef union {
63 struct {
64 __u8 error;
65 __u8 command;
66 } error;
67 long space;
68} ft_drive_error;
69typedef union {
70 struct {
71 __u8 drive_status;
72 __u8 drive_config;
73 __u8 tape_status;
74 } status;
75 long space;
76} ft_drive_status;
77
78#ifdef __KERNEL__
79
80#define FT_RQM_DELAY 12
81#define FT_MILLISECOND 1
82#define FT_SECOND 1000
83#define FT_FOREVER -1
84#ifndef HZ
85#error "HZ undefined."
86#endif
87#define FT_USPT (1000000/HZ) /* microseconds per tick */
88
89/* This defines the number of retries that the driver will allow
90 * before giving up (and letting a higher level handle the error).
91 */
92#ifdef TESTING
93#define FT_SOFT_RETRIES 1 /* number of low level retries */
94#define FT_RETRIES_ON_ECC_ERROR 3 /* ecc error when correcting segment */
95#else
96#define FT_SOFT_RETRIES 6 /* number of low level retries (triple) */
97#define FT_RETRIES_ON_ECC_ERROR 3 /* ecc error when correcting segment */
98#endif
99
100#ifndef THE_FTAPE_MAINTAINER
101#define THE_FTAPE_MAINTAINER "the ftape maintainer"
102#endif
103
104/* Initialize missing configuration parameters.
105 */
106#ifndef CONFIG_FT_NR_BUFFERS
107# define CONFIG_FT_NR_BUFFERS 3
108#endif
109#ifndef CONFIG_FT_FDC_THR
110# define CONFIG_FT_FDC_THR 8
111#endif
112#ifndef CONFIG_FT_FDC_MAX_RATE
113# define CONFIG_FT_FDC_MAX_RATE 2000
114#endif
115#ifndef CONFIG_FT_FDC_BASE
116# define CONFIG_FT_FDC_BASE 0
117#endif
118#ifndef CONFIG_FT_FDC_IRQ
119# define CONFIG_FT_FDC_IRQ 0
120#endif
121#ifndef CONFIG_FT_FDC_DMA
122# define CONFIG_FT_FDC_DMA 0
123#endif
124
125/* Turn some booleans into numbers.
126 */
127#ifdef CONFIG_FT_PROBE_FC10
128# undef CONFIG_FT_PROBE_FC10
129# define CONFIG_FT_PROBE_FC10 1
130#else
131# define CONFIG_FT_PROBE_FC10 0
132#endif
133#ifdef CONFIG_FT_MACH2
134# undef CONFIG_FT_MACH2
135# define CONFIG_FT_MACH2 1
136#else
137# define CONFIG_FT_MACH2 0
138#endif
139
140/* Insert default settings
141 */
142#if CONFIG_FT_PROBE_FC10 == 1
143# if CONFIG_FT_FDC_BASE == 0
144# undef CONFIG_FT_FDC_BASE
145# define CONFIG_FT_FDC_BASE 0x180
146# endif
147# if CONFIG_FT_FDC_IRQ == 0
148# undef CONFIG_FT_FDC_IRQ
149# define CONFIG_FT_FDC_IRQ 9
150# endif
151# if CONFIG_FT_FDC_DMA == 0
152# undef CONFIG_FT_FDC_DMA
153# define CONFIG_FT_FDC_DMA 3
154# endif
155#elif CONFIG_FT_MACH2 == 1 /* CONFIG_FT_PROBE_FC10 == 1 */
156# if CONFIG_FT_FDC_BASE == 0
157# undef CONFIG_FT_FDC_BASE
158# define CONFIG_FT_FDC_BASE 0x1E0
159# endif
160# if CONFIG_FT_FDC_IRQ == 0
161# undef CONFIG_FT_FDC_IRQ
162# define CONFIG_FT_FDC_IRQ 6
163# endif
164# if CONFIG_FT_FDC_DMA == 0
165# undef CONFIG_FT_FDC_DMA
166# define CONFIG_FT_FDC_DMA 2
167# endif
168#elif CONFIG_FT_ALT_FDC == 1 /* CONFIG_FT_MACH2 */
169# if CONFIG_FT_FDC_BASE == 0
170# undef CONFIG_FT_FDC_BASE
171# define CONFIG_FT_FDC_BASE 0x370
172# endif
173# if CONFIG_FT_FDC_IRQ == 0
174# undef CONFIG_FT_FDC_IRQ
175# define CONFIG_FT_FDC_IRQ 6
176# endif
177# if CONFIG_FT_FDC_DMA == 0
178# undef CONFIG_FT_FDC_DMA
179# define CONFIG_FT_FDC_DMA 2
180# endif
181#else /* CONFIG_FT_ALT_FDC */
182# if CONFIG_FT_FDC_BASE == 0
183# undef CONFIG_FT_FDC_BASE
184# define CONFIG_FT_FDC_BASE 0x3f0
185# endif
186# if CONFIG_FT_FDC_IRQ == 0
187# undef CONFIG_FT_FDC_IRQ
188# define CONFIG_FT_FDC_IRQ 6
189# endif
190# if CONFIG_FT_FDC_DMA == 0
191# undef CONFIG_FT_FDC_DMA
192# define CONFIG_FT_FDC_DMA 2
193# endif
194#endif /* standard FDC */
195
196/* some useful macro's
197 */
198#define NR_ITEMS(x) (int)(sizeof(x)/ sizeof(*x))
199
200#endif /* __KERNEL__ */
201
202#endif
diff --git a/include/linux/futex.h b/include/linux/futex.h
new file mode 100644
index 000000000000..65d6cfdb6d39
--- /dev/null
+++ b/include/linux/futex.h
@@ -0,0 +1,17 @@
1#ifndef _LINUX_FUTEX_H
2#define _LINUX_FUTEX_H
3
4/* Second argument to futex syscall */
5
6
7#define FUTEX_WAIT (0)
8#define FUTEX_WAKE (1)
9#define FUTEX_FD (2)
10#define FUTEX_REQUEUE (3)
11#define FUTEX_CMP_REQUEUE (4)
12
13long do_futex(unsigned long uaddr, int op, int val,
14 unsigned long timeout, unsigned long uaddr2, int val2,
15 int val3);
16
17#endif
diff --git a/include/linux/gameport.h b/include/linux/gameport.h
new file mode 100644
index 000000000000..b1272f822cfa
--- /dev/null
+++ b/include/linux/gameport.h
@@ -0,0 +1,198 @@
1#ifndef _GAMEPORT_H
2#define _GAMEPORT_H
3
4/*
5 * Copyright (c) 1999-2002 Vojtech Pavlik
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#include <asm/io.h>
13#include <linux/list.h>
14#include <linux/device.h>
15
16struct gameport {
17
18 void *port_data; /* Private pointer for gameport drivers */
19 char name[32];
20 char phys[32];
21
22 int io;
23 int speed;
24 int fuzz;
25
26 void (*trigger)(struct gameport *);
27 unsigned char (*read)(struct gameport *);
28 int (*cooked_read)(struct gameport *, int *, int *);
29 int (*calibrate)(struct gameport *, int *, int *);
30 int (*open)(struct gameport *, int);
31 void (*close)(struct gameport *);
32
33 struct timer_list poll_timer;
34 unsigned int poll_interval; /* in msecs */
35 spinlock_t timer_lock;
36 unsigned int poll_cnt;
37 void (*poll_handler)(struct gameport *);
38
39 struct gameport *parent, *child;
40
41 struct gameport_driver *drv;
42 struct semaphore drv_sem; /* protects serio->drv so attributes can pin driver */
43
44 struct device dev;
45 unsigned int registered; /* port has been fully registered with driver core */
46
47 struct list_head node;
48};
49#define to_gameport_port(d) container_of(d, struct gameport, dev)
50
51struct gameport_driver {
52
53 void *private;
54 char *description;
55
56 int (*connect)(struct gameport *, struct gameport_driver *drv);
57 int (*reconnect)(struct gameport *);
58 void (*disconnect)(struct gameport *);
59
60 struct device_driver driver;
61
62 unsigned int ignore;
63};
64#define to_gameport_driver(d) container_of(d, struct gameport_driver, driver)
65
66int gameport_open(struct gameport *gameport, struct gameport_driver *drv, int mode);
67void gameport_close(struct gameport *gameport);
68void gameport_rescan(struct gameport *gameport);
69
70void __gameport_register_port(struct gameport *gameport, struct module *owner);
71static inline void gameport_register_port(struct gameport *gameport)
72{
73 __gameport_register_port(gameport, THIS_MODULE);
74}
75
76void gameport_unregister_port(struct gameport *gameport);
77
78static inline struct gameport *gameport_allocate_port(void)
79{
80 struct gameport *gameport = kcalloc(1, sizeof(struct gameport), GFP_KERNEL);
81
82 return gameport;
83}
84
85static inline void gameport_free_port(struct gameport *gameport)
86{
87 kfree(gameport);
88}
89
90static inline void gameport_set_name(struct gameport *gameport, const char *name)
91{
92 strlcpy(gameport->name, name, sizeof(gameport->name));
93}
94
95void gameport_set_phys(struct gameport *gameport, const char *fmt, ...)
96 __attribute__ ((format (printf, 2, 3)));
97
98/*
99 * Use the following fucntions to manipulate gameport's per-port
100 * driver-specific data.
101 */
102static inline void *gameport_get_drvdata(struct gameport *gameport)
103{
104 return dev_get_drvdata(&gameport->dev);
105}
106
107static inline void gameport_set_drvdata(struct gameport *gameport, void *data)
108{
109 dev_set_drvdata(&gameport->dev, data);
110}
111
112/*
113 * Use the following fucntions to pin gameport's driver in process context
114 */
115static inline int gameport_pin_driver(struct gameport *gameport)
116{
117 return down_interruptible(&gameport->drv_sem);
118}
119
120static inline void gameport_unpin_driver(struct gameport *gameport)
121{
122 up(&gameport->drv_sem);
123}
124
125void __gameport_register_driver(struct gameport_driver *drv, struct module *owner);
126static inline void gameport_register_driver(struct gameport_driver *drv)
127{
128 __gameport_register_driver(drv, THIS_MODULE);
129}
130
131void gameport_unregister_driver(struct gameport_driver *drv);
132
133#define GAMEPORT_MODE_DISABLED 0
134#define GAMEPORT_MODE_RAW 1
135#define GAMEPORT_MODE_COOKED 2
136
137#define GAMEPORT_ID_VENDOR_ANALOG 0x0001
138#define GAMEPORT_ID_VENDOR_MADCATZ 0x0002
139#define GAMEPORT_ID_VENDOR_LOGITECH 0x0003
140#define GAMEPORT_ID_VENDOR_CREATIVE 0x0004
141#define GAMEPORT_ID_VENDOR_GENIUS 0x0005
142#define GAMEPORT_ID_VENDOR_INTERACT 0x0006
143#define GAMEPORT_ID_VENDOR_MICROSOFT 0x0007
144#define GAMEPORT_ID_VENDOR_THRUSTMASTER 0x0008
145#define GAMEPORT_ID_VENDOR_GRAVIS 0x0009
146#define GAMEPORT_ID_VENDOR_GUILLEMOT 0x000a
147
148static inline void gameport_trigger(struct gameport *gameport)
149{
150 if (gameport->trigger)
151 gameport->trigger(gameport);
152 else
153 outb(0xff, gameport->io);
154}
155
156static inline unsigned char gameport_read(struct gameport *gameport)
157{
158 if (gameport->read)
159 return gameport->read(gameport);
160 else
161 return inb(gameport->io);
162}
163
164static inline int gameport_cooked_read(struct gameport *gameport, int *axes, int *buttons)
165{
166 if (gameport->cooked_read)
167 return gameport->cooked_read(gameport, axes, buttons);
168 else
169 return -1;
170}
171
172static inline int gameport_calibrate(struct gameport *gameport, int *axes, int *max)
173{
174 if (gameport->calibrate)
175 return gameport->calibrate(gameport, axes, max);
176 else
177 return -1;
178}
179
180static inline int gameport_time(struct gameport *gameport, int time)
181{
182 return (time * gameport->speed) / 1000;
183}
184
185static inline void gameport_set_poll_handler(struct gameport *gameport, void (*handler)(struct gameport *))
186{
187 gameport->poll_handler = handler;
188}
189
190static inline void gameport_set_poll_interval(struct gameport *gameport, unsigned int msecs)
191{
192 gameport->poll_interval = msecs;
193}
194
195void gameport_start_polling(struct gameport *gameport);
196void gameport_stop_polling(struct gameport *gameport);
197
198#endif
diff --git a/include/linux/gen_stats.h b/include/linux/gen_stats.h
new file mode 100644
index 000000000000..13f4e74609ac
--- /dev/null
+++ b/include/linux/gen_stats.h
@@ -0,0 +1,67 @@
1#ifndef __LINUX_GEN_STATS_H
2#define __LINUX_GEN_STATS_H
3
4#include <linux/types.h>
5
6enum {
7 TCA_STATS_UNSPEC,
8 TCA_STATS_BASIC,
9 TCA_STATS_RATE_EST,
10 TCA_STATS_QUEUE,
11 TCA_STATS_APP,
12 __TCA_STATS_MAX,
13};
14#define TCA_STATS_MAX (__TCA_STATS_MAX - 1)
15
16/**
17 * struct gnet_stats_basic - byte/packet throughput statistics
18 * @bytes: number of seen bytes
19 * @packets: number of seen packets
20 */
21struct gnet_stats_basic
22{
23 __u64 bytes;
24 __u32 packets;
25};
26
27/**
28 * struct gnet_stats_rate_est - rate estimator
29 * @bps: current byte rate
30 * @pps: current packet rate
31 */
32struct gnet_stats_rate_est
33{
34 __u32 bps;
35 __u32 pps;
36};
37
38/**
39 * struct gnet_stats_queue - queuing statistics
40 * @qlen: queue length
41 * @backlog: backlog size of queue
42 * @drops: number of dropped packets
43 * @requeues: number of requeues
44 * @overlimits: number of enqueues over the limit
45 */
46struct gnet_stats_queue
47{
48 __u32 qlen;
49 __u32 backlog;
50 __u32 drops;
51 __u32 requeues;
52 __u32 overlimits;
53};
54
55/**
56 * struct gnet_estimator - rate estimator configuration
57 * @interval: sampling period
58 * @ewma_log: the log of measurement window weight
59 */
60struct gnet_estimator
61{
62 signed char interval;
63 unsigned char ewma_log;
64};
65
66
67#endif /* __LINUX_GEN_STATS_H */
diff --git a/include/linux/generic_serial.h b/include/linux/generic_serial.h
new file mode 100644
index 000000000000..0abe9d9a0069
--- /dev/null
+++ b/include/linux/generic_serial.h
@@ -0,0 +1,96 @@
1/*
2 * generic_serial.h
3 *
4 * Copyright (C) 1998 R.E.Wolff@BitWizard.nl
5 *
6 * written for the SX serial driver.
7 * Contains the code that should be shared over all the serial drivers.
8 *
9 * Version 0.1 -- December, 1998.
10 */
11
12#ifndef GENERIC_SERIAL_H
13#define GENERIC_SERIAL_H
14
15struct real_driver {
16 void (*disable_tx_interrupts) (void *);
17 void (*enable_tx_interrupts) (void *);
18 void (*disable_rx_interrupts) (void *);
19 void (*enable_rx_interrupts) (void *);
20 int (*get_CD) (void *);
21 void (*shutdown_port) (void*);
22 int (*set_real_termios) (void*);
23 int (*chars_in_buffer) (void*);
24 void (*close) (void*);
25 void (*hungup) (void*);
26 void (*getserial) (void*, struct serial_struct *sp);
27};
28
29
30
31struct gs_port {
32 int magic;
33 unsigned char *xmit_buf;
34 int xmit_head;
35 int xmit_tail;
36 int xmit_cnt;
37 struct semaphore port_write_sem;
38 int flags;
39 wait_queue_head_t open_wait;
40 wait_queue_head_t close_wait;
41 int count;
42 int blocked_open;
43 struct tty_struct *tty;
44 unsigned long event;
45 unsigned short closing_wait;
46 int close_delay;
47 struct real_driver *rd;
48 int wakeup_chars;
49 int baud_base;
50 int baud;
51 int custom_divisor;
52 spinlock_t driver_lock;
53};
54
55
56/* Flags */
57/* Warning: serial.h defines some ASYNC_ flags, they say they are "only"
58 used in serial.c, but they are also used in all other serial drivers.
59 Make sure they don't clash with these here... */
60#define GS_TX_INTEN 0x00800000
61#define GS_RX_INTEN 0x00400000
62#define GS_ACTIVE 0x00200000
63
64
65
66#define GS_TYPE_NORMAL 1
67
68#define GS_DEBUG_FLUSH 0x00000001
69#define GS_DEBUG_BTR 0x00000002
70#define GS_DEBUG_TERMIOS 0x00000004
71#define GS_DEBUG_STUFF 0x00000008
72#define GS_DEBUG_CLOSE 0x00000010
73#define GS_DEBUG_FLOW 0x00000020
74#define GS_DEBUG_WRITE 0x00000040
75
76
77void gs_put_char(struct tty_struct *tty, unsigned char ch);
78int gs_write(struct tty_struct *tty,
79 const unsigned char *buf, int count);
80int gs_write_room(struct tty_struct *tty);
81int gs_chars_in_buffer(struct tty_struct *tty);
82void gs_flush_buffer(struct tty_struct *tty);
83void gs_flush_chars(struct tty_struct *tty);
84void gs_stop(struct tty_struct *tty);
85void gs_start(struct tty_struct *tty);
86void gs_hangup(struct tty_struct *tty);
87int gs_block_til_ready(void *port, struct file *filp);
88void gs_close(struct tty_struct *tty, struct file *filp);
89void gs_set_termios (struct tty_struct * tty,
90 struct termios * old_termios);
91int gs_init_port(struct gs_port *port);
92int gs_setserial(struct gs_port *port, struct serial_struct __user *sp);
93int gs_getserial(struct gs_port *port, struct serial_struct __user *sp);
94void gs_got_break(struct gs_port *port);
95
96#endif
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
new file mode 100644
index 000000000000..47dedaf971d6
--- /dev/null
+++ b/include/linux/genhd.h
@@ -0,0 +1,424 @@
1#ifndef _LINUX_GENHD_H
2#define _LINUX_GENHD_H
3
4/*
5 * genhd.h Copyright (C) 1992 Drew Eckhardt
6 * Generic hard disk header file by
7 * Drew Eckhardt
8 *
9 * <drew@colorado.edu>
10 */
11
12#include <linux/config.h>
13#include <linux/types.h>
14#include <linux/major.h>
15#include <linux/device.h>
16#include <linux/smp.h>
17#include <linux/string.h>
18#include <linux/fs.h>
19
20enum {
21/* These three have identical behaviour; use the second one if DOS FDISK gets
22 confused about extended/logical partitions starting past cylinder 1023. */
23 DOS_EXTENDED_PARTITION = 5,
24 LINUX_EXTENDED_PARTITION = 0x85,
25 WIN98_EXTENDED_PARTITION = 0x0f,
26
27 LINUX_SWAP_PARTITION = 0x82,
28 LINUX_RAID_PARTITION = 0xfd, /* autodetect RAID partition */
29
30 SOLARIS_X86_PARTITION = LINUX_SWAP_PARTITION,
31 NEW_SOLARIS_X86_PARTITION = 0xbf,
32
33 DM6_AUX1PARTITION = 0x51, /* no DDO: use xlated geom */
34 DM6_AUX3PARTITION = 0x53, /* no DDO: use xlated geom */
35 DM6_PARTITION = 0x54, /* has DDO: use xlated geom & offset */
36 EZD_PARTITION = 0x55, /* EZ-DRIVE */
37
38 FREEBSD_PARTITION = 0xa5, /* FreeBSD Partition ID */
39 OPENBSD_PARTITION = 0xa6, /* OpenBSD Partition ID */
40 NETBSD_PARTITION = 0xa9, /* NetBSD Partition ID */
41 BSDI_PARTITION = 0xb7, /* BSDI Partition ID */
42 MINIX_PARTITION = 0x81, /* Minix Partition ID */
43 UNIXWARE_PARTITION = 0x63, /* Same as GNU_HURD and SCO Unix */
44};
45
46#ifndef __KERNEL__
47
48struct partition {
49 unsigned char boot_ind; /* 0x80 - active */
50 unsigned char head; /* starting head */
51 unsigned char sector; /* starting sector */
52 unsigned char cyl; /* starting cylinder */
53 unsigned char sys_ind; /* What partition type */
54 unsigned char end_head; /* end head */
55 unsigned char end_sector; /* end sector */
56 unsigned char end_cyl; /* end cylinder */
57 unsigned int start_sect; /* starting sector counting from 0 */
58 unsigned int nr_sects; /* nr of sectors in partition */
59} __attribute__((packed));
60
61#endif
62
63#ifdef __KERNEL__
64struct partition {
65 unsigned char boot_ind; /* 0x80 - active */
66 unsigned char head; /* starting head */
67 unsigned char sector; /* starting sector */
68 unsigned char cyl; /* starting cylinder */
69 unsigned char sys_ind; /* What partition type */
70 unsigned char end_head; /* end head */
71 unsigned char end_sector; /* end sector */
72 unsigned char end_cyl; /* end cylinder */
73 __le32 start_sect; /* starting sector counting from 0 */
74 __le32 nr_sects; /* nr of sectors in partition */
75} __attribute__((packed));
76
77struct hd_struct {
78 sector_t start_sect;
79 sector_t nr_sects;
80 struct kobject kobj;
81 unsigned reads, read_sectors, writes, write_sectors;
82 int policy, partno;
83};
84
85#define GENHD_FL_REMOVABLE 1
86#define GENHD_FL_DRIVERFS 2
87#define GENHD_FL_CD 8
88#define GENHD_FL_UP 16
89#define GENHD_FL_SUPPRESS_PARTITION_INFO 32
90
91struct disk_stats {
92 unsigned read_sectors, write_sectors;
93 unsigned reads, writes;
94 unsigned read_merges, write_merges;
95 unsigned read_ticks, write_ticks;
96 unsigned io_ticks;
97 unsigned time_in_queue;
98};
99
100struct gendisk {
101 int major; /* major number of driver */
102 int first_minor;
103 int minors; /* maximum number of minors, =1 for
104 * disks that can't be partitioned. */
105 char disk_name[32]; /* name of major driver */
106 struct hd_struct **part; /* [indexed by minor] */
107 struct block_device_operations *fops;
108 struct request_queue *queue;
109 void *private_data;
110 sector_t capacity;
111
112 int flags;
113 char devfs_name[64]; /* devfs crap */
114 int number; /* more of the same */
115 struct device *driverfs_dev;
116 struct kobject kobj;
117
118 struct timer_rand_state *random;
119 int policy;
120
121 atomic_t sync_io; /* RAID */
122 unsigned long stamp, stamp_idle;
123 int in_flight;
124#ifdef CONFIG_SMP
125 struct disk_stats *dkstats;
126#else
127 struct disk_stats dkstats;
128#endif
129};
130
131/* Structure for sysfs attributes on block devices */
132struct disk_attribute {
133 struct attribute attr;
134 ssize_t (*show)(struct gendisk *, char *);
135};
136
137/*
138 * Macros to operate on percpu disk statistics:
139 *
140 * The __ variants should only be called in critical sections. The full
141 * variants disable/enable preemption.
142 */
143#ifdef CONFIG_SMP
144#define __disk_stat_add(gendiskp, field, addnd) \
145 (per_cpu_ptr(gendiskp->dkstats, smp_processor_id())->field += addnd)
146
147#define disk_stat_read(gendiskp, field) \
148({ \
149 typeof(gendiskp->dkstats->field) res = 0; \
150 int i; \
151 for (i=0; i < NR_CPUS; i++) { \
152 if (!cpu_possible(i)) \
153 continue; \
154 res += per_cpu_ptr(gendiskp->dkstats, i)->field; \
155 } \
156 res; \
157})
158
159static inline void disk_stat_set_all(struct gendisk *gendiskp, int value) {
160 int i;
161 for (i=0; i < NR_CPUS; i++) {
162 if (cpu_possible(i)) {
163 memset(per_cpu_ptr(gendiskp->dkstats, i), value,
164 sizeof (struct disk_stats));
165 }
166 }
167}
168
169#else
170#define __disk_stat_add(gendiskp, field, addnd) \
171 (gendiskp->dkstats.field += addnd)
172#define disk_stat_read(gendiskp, field) (gendiskp->dkstats.field)
173
174static inline void disk_stat_set_all(struct gendisk *gendiskp, int value) {
175 memset(&gendiskp->dkstats, value, sizeof (struct disk_stats));
176}
177#endif
178
179#define disk_stat_add(gendiskp, field, addnd) \
180 do { \
181 preempt_disable(); \
182 __disk_stat_add(gendiskp, field, addnd); \
183 preempt_enable(); \
184 } while (0)
185
186#define __disk_stat_dec(gendiskp, field) __disk_stat_add(gendiskp, field, -1)
187#define disk_stat_dec(gendiskp, field) disk_stat_add(gendiskp, field, -1)
188
189#define __disk_stat_inc(gendiskp, field) __disk_stat_add(gendiskp, field, 1)
190#define disk_stat_inc(gendiskp, field) disk_stat_add(gendiskp, field, 1)
191
192#define __disk_stat_sub(gendiskp, field, subnd) \
193 __disk_stat_add(gendiskp, field, -subnd)
194#define disk_stat_sub(gendiskp, field, subnd) \
195 disk_stat_add(gendiskp, field, -subnd)
196
197
198/* Inlines to alloc and free disk stats in struct gendisk */
199#ifdef CONFIG_SMP
200static inline int init_disk_stats(struct gendisk *disk)
201{
202 disk->dkstats = alloc_percpu(struct disk_stats);
203 if (!disk->dkstats)
204 return 0;
205 return 1;
206}
207
208static inline void free_disk_stats(struct gendisk *disk)
209{
210 free_percpu(disk->dkstats);
211}
212#else /* CONFIG_SMP */
213static inline int init_disk_stats(struct gendisk *disk)
214{
215 return 1;
216}
217
218static inline void free_disk_stats(struct gendisk *disk)
219{
220}
221#endif /* CONFIG_SMP */
222
223/* drivers/block/ll_rw_blk.c */
224extern void disk_round_stats(struct gendisk *disk);
225
226/* drivers/block/genhd.c */
227extern int get_blkdev_list(char *);
228extern void add_disk(struct gendisk *disk);
229extern void del_gendisk(struct gendisk *gp);
230extern void unlink_gendisk(struct gendisk *gp);
231extern struct gendisk *get_gendisk(dev_t dev, int *part);
232
233extern void set_device_ro(struct block_device *bdev, int flag);
234extern void set_disk_ro(struct gendisk *disk, int flag);
235
236/* drivers/char/random.c */
237extern void add_disk_randomness(struct gendisk *disk);
238extern void rand_initialize_disk(struct gendisk *disk);
239
240static inline sector_t get_start_sect(struct block_device *bdev)
241{
242 return bdev->bd_contains == bdev ? 0 : bdev->bd_part->start_sect;
243}
244static inline sector_t get_capacity(struct gendisk *disk)
245{
246 return disk->capacity;
247}
248static inline void set_capacity(struct gendisk *disk, sector_t size)
249{
250 disk->capacity = size;
251}
252
253#endif /* __KERNEL__ */
254
255#ifdef CONFIG_SOLARIS_X86_PARTITION
256
257#define SOLARIS_X86_NUMSLICE 8
258#define SOLARIS_X86_VTOC_SANE (0x600DDEEEUL)
259
260struct solaris_x86_slice {
261 __le16 s_tag; /* ID tag of partition */
262 __le16 s_flag; /* permission flags */
263 __le32 s_start; /* start sector no of partition */
264 __le32 s_size; /* # of blocks in partition */
265};
266
267struct solaris_x86_vtoc {
268 unsigned int v_bootinfo[3]; /* info needed by mboot (unsupported) */
269 __le32 v_sanity; /* to verify vtoc sanity */
270 __le32 v_version; /* layout version */
271 char v_volume[8]; /* volume name */
272 __le16 v_sectorsz; /* sector size in bytes */
273 __le16 v_nparts; /* number of partitions */
274 unsigned int v_reserved[10]; /* free space */
275 struct solaris_x86_slice
276 v_slice[SOLARIS_X86_NUMSLICE]; /* slice headers */
277 unsigned int timestamp[SOLARIS_X86_NUMSLICE]; /* timestamp (unsupported) */
278 char v_asciilabel[128]; /* for compatibility */
279};
280
281#endif /* CONFIG_SOLARIS_X86_PARTITION */
282
283#ifdef CONFIG_BSD_DISKLABEL
284/*
285 * BSD disklabel support by Yossi Gottlieb <yogo@math.tau.ac.il>
286 * updated by Marc Espie <Marc.Espie@openbsd.org>
287 */
288
289/* check against BSD src/sys/sys/disklabel.h for consistency */
290
291#define BSD_DISKMAGIC (0x82564557UL) /* The disk magic number */
292#define BSD_MAXPARTITIONS 16
293#define OPENBSD_MAXPARTITIONS 16
294#define BSD_FS_UNUSED 0 /* disklabel unused partition entry ID */
295struct bsd_disklabel {
296 __le32 d_magic; /* the magic number */
297 __s16 d_type; /* drive type */
298 __s16 d_subtype; /* controller/d_type specific */
299 char d_typename[16]; /* type name, e.g. "eagle" */
300 char d_packname[16]; /* pack identifier */
301 __u32 d_secsize; /* # of bytes per sector */
302 __u32 d_nsectors; /* # of data sectors per track */
303 __u32 d_ntracks; /* # of tracks per cylinder */
304 __u32 d_ncylinders; /* # of data cylinders per unit */
305 __u32 d_secpercyl; /* # of data sectors per cylinder */
306 __u32 d_secperunit; /* # of data sectors per unit */
307 __u16 d_sparespertrack; /* # of spare sectors per track */
308 __u16 d_sparespercyl; /* # of spare sectors per cylinder */
309 __u32 d_acylinders; /* # of alt. cylinders per unit */
310 __u16 d_rpm; /* rotational speed */
311 __u16 d_interleave; /* hardware sector interleave */
312 __u16 d_trackskew; /* sector 0 skew, per track */
313 __u16 d_cylskew; /* sector 0 skew, per cylinder */
314 __u32 d_headswitch; /* head switch time, usec */
315 __u32 d_trkseek; /* track-to-track seek, usec */
316 __u32 d_flags; /* generic flags */
317#define NDDATA 5
318 __u32 d_drivedata[NDDATA]; /* drive-type specific information */
319#define NSPARE 5
320 __u32 d_spare[NSPARE]; /* reserved for future use */
321 __le32 d_magic2; /* the magic number (again) */
322 __le16 d_checksum; /* xor of data incl. partitions */
323
324 /* filesystem and partition information: */
325 __le16 d_npartitions; /* number of partitions in following */
326 __le32 d_bbsize; /* size of boot area at sn0, bytes */
327 __le32 d_sbsize; /* max size of fs superblock, bytes */
328 struct bsd_partition { /* the partition table */
329 __le32 p_size; /* number of sectors in partition */
330 __le32 p_offset; /* starting sector */
331 __le32 p_fsize; /* filesystem basic fragment size */
332 __u8 p_fstype; /* filesystem type, see below */
333 __u8 p_frag; /* filesystem fragments per block */
334 __le16 p_cpg; /* filesystem cylinders per group */
335 } d_partitions[BSD_MAXPARTITIONS]; /* actually may be more */
336};
337
338#endif /* CONFIG_BSD_DISKLABEL */
339
340#ifdef CONFIG_UNIXWARE_DISKLABEL
341/*
342 * Unixware slices support by Andrzej Krzysztofowicz <ankry@mif.pg.gda.pl>
343 * and Krzysztof G. Baranowski <kgb@knm.org.pl>
344 */
345
346#define UNIXWARE_DISKMAGIC (0xCA5E600DUL) /* The disk magic number */
347#define UNIXWARE_DISKMAGIC2 (0x600DDEEEUL) /* The slice table magic nr */
348#define UNIXWARE_NUMSLICE 16
349#define UNIXWARE_FS_UNUSED 0 /* Unused slice entry ID */
350
351struct unixware_slice {
352 __le16 s_label; /* label */
353 __le16 s_flags; /* permission flags */
354 __le32 start_sect; /* starting sector */
355 __le32 nr_sects; /* number of sectors in slice */
356};
357
358struct unixware_disklabel {
359 __le32 d_type; /* drive type */
360 __le32 d_magic; /* the magic number */
361 __le32 d_version; /* version number */
362 char d_serial[12]; /* serial number of the device */
363 __le32 d_ncylinders; /* # of data cylinders per device */
364 __le32 d_ntracks; /* # of tracks per cylinder */
365 __le32 d_nsectors; /* # of data sectors per track */
366 __le32 d_secsize; /* # of bytes per sector */
367 __le32 d_part_start; /* # of first sector of this partition */
368 __le32 d_unknown1[12]; /* ? */
369 __le32 d_alt_tbl; /* byte offset of alternate table */
370 __le32 d_alt_len; /* byte length of alternate table */
371 __le32 d_phys_cyl; /* # of physical cylinders per device */
372 __le32 d_phys_trk; /* # of physical tracks per cylinder */
373 __le32 d_phys_sec; /* # of physical sectors per track */
374 __le32 d_phys_bytes; /* # of physical bytes per sector */
375 __le32 d_unknown2; /* ? */
376 __le32 d_unknown3; /* ? */
377 __le32 d_pad[8]; /* pad */
378
379 struct unixware_vtoc {
380 __le32 v_magic; /* the magic number */
381 __le32 v_version; /* version number */
382 char v_name[8]; /* volume name */
383 __le16 v_nslices; /* # of slices */
384 __le16 v_unknown1; /* ? */
385 __le32 v_reserved[10]; /* reserved */
386 struct unixware_slice
387 v_slice[UNIXWARE_NUMSLICE]; /* slice headers */
388 } vtoc;
389
390}; /* 408 */
391
392#endif /* CONFIG_UNIXWARE_DISKLABEL */
393
394#ifdef CONFIG_MINIX_SUBPARTITION
395# define MINIX_NR_SUBPARTITIONS 4
396#endif /* CONFIG_MINIX_SUBPARTITION */
397
398#ifdef __KERNEL__
399
400char *disk_name (struct gendisk *hd, int part, char *buf);
401
402extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev);
403extern void add_partition(struct gendisk *, int, sector_t, sector_t);
404extern void delete_partition(struct gendisk *, int);
405
406extern struct gendisk *alloc_disk(int minors);
407extern struct kobject *get_disk(struct gendisk *disk);
408extern void put_disk(struct gendisk *disk);
409
410extern void blk_register_region(dev_t dev, unsigned long range,
411 struct module *module,
412 struct kobject *(*probe)(dev_t, int *, void *),
413 int (*lock)(dev_t, void *),
414 void *data);
415extern void blk_unregister_region(dev_t dev, unsigned long range);
416
417static inline struct block_device *bdget_disk(struct gendisk *disk, int index)
418{
419 return bdget(MKDEV(disk->major, disk->first_minor) + index);
420}
421
422#endif
423
424#endif
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
new file mode 100644
index 000000000000..848a1baac079
--- /dev/null
+++ b/include/linux/gfp.h
@@ -0,0 +1,134 @@
1#ifndef __LINUX_GFP_H
2#define __LINUX_GFP_H
3
4#include <linux/mmzone.h>
5#include <linux/stddef.h>
6#include <linux/linkage.h>
7#include <linux/config.h>
8
9struct vm_area_struct;
10
11/*
12 * GFP bitmasks..
13 */
14/* Zone modifiers in GFP_ZONEMASK (see linux/mmzone.h - low two bits) */
15#define __GFP_DMA 0x01
16#define __GFP_HIGHMEM 0x02
17
18/*
19 * Action modifiers - doesn't change the zoning
20 *
21 * __GFP_REPEAT: Try hard to allocate the memory, but the allocation attempt
22 * _might_ fail. This depends upon the particular VM implementation.
23 *
24 * __GFP_NOFAIL: The VM implementation _must_ retry infinitely: the caller
25 * cannot handle allocation failures.
26 *
27 * __GFP_NORETRY: The VM implementation must not retry indefinitely.
28 */
29#define __GFP_WAIT 0x10u /* Can wait and reschedule? */
30#define __GFP_HIGH 0x20u /* Should access emergency pools? */
31#define __GFP_IO 0x40u /* Can start physical IO? */
32#define __GFP_FS 0x80u /* Can call down to low-level FS? */
33#define __GFP_COLD 0x100u /* Cache-cold page required */
34#define __GFP_NOWARN 0x200u /* Suppress page allocation failure warning */
35#define __GFP_REPEAT 0x400u /* Retry the allocation. Might fail */
36#define __GFP_NOFAIL 0x800u /* Retry for ever. Cannot fail */
37#define __GFP_NORETRY 0x1000u /* Do not retry. Might fail */
38#define __GFP_NO_GROW 0x2000u /* Slab internal usage */
39#define __GFP_COMP 0x4000u /* Add compound page metadata */
40#define __GFP_ZERO 0x8000u /* Return zeroed page on success */
41
42#define __GFP_BITS_SHIFT 16 /* Room for 16 __GFP_FOO bits */
43#define __GFP_BITS_MASK ((1 << __GFP_BITS_SHIFT) - 1)
44
45/* if you forget to add the bitmask here kernel will crash, period */
46#define GFP_LEVEL_MASK (__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_FS| \
47 __GFP_COLD|__GFP_NOWARN|__GFP_REPEAT| \
48 __GFP_NOFAIL|__GFP_NORETRY|__GFP_NO_GROW|__GFP_COMP)
49
50#define GFP_ATOMIC (__GFP_HIGH)
51#define GFP_NOIO (__GFP_WAIT)
52#define GFP_NOFS (__GFP_WAIT | __GFP_IO)
53#define GFP_KERNEL (__GFP_WAIT | __GFP_IO | __GFP_FS)
54#define GFP_USER (__GFP_WAIT | __GFP_IO | __GFP_FS)
55#define GFP_HIGHUSER (__GFP_WAIT | __GFP_IO | __GFP_FS | __GFP_HIGHMEM)
56
57/* Flag - indicates that the buffer will be suitable for DMA. Ignored on some
58 platforms, used as appropriate on others */
59
60#define GFP_DMA __GFP_DMA
61
62
63/*
64 * There is only one page-allocator function, and two main namespaces to
65 * it. The alloc_page*() variants return 'struct page *' and as such
66 * can allocate highmem pages, the *get*page*() variants return
67 * virtual kernel addresses to the allocated page(s).
68 */
69
70/*
71 * We get the zone list from the current node and the gfp_mask.
72 * This zone list contains a maximum of MAXNODES*MAX_NR_ZONES zones.
73 *
74 * For the normal case of non-DISCONTIGMEM systems the NODE_DATA() gets
75 * optimized to &contig_page_data at compile-time.
76 */
77
78#ifndef HAVE_ARCH_FREE_PAGE
79static inline void arch_free_page(struct page *page, int order) { }
80#endif
81
82extern struct page *
83FASTCALL(__alloc_pages(unsigned int, unsigned int, struct zonelist *));
84
85static inline struct page *alloc_pages_node(int nid, unsigned int __nocast gfp_mask,
86 unsigned int order)
87{
88 if (unlikely(order >= MAX_ORDER))
89 return NULL;
90
91 return __alloc_pages(gfp_mask, order,
92 NODE_DATA(nid)->node_zonelists + (gfp_mask & GFP_ZONEMASK));
93}
94
95#ifdef CONFIG_NUMA
96extern struct page *alloc_pages_current(unsigned int __nocast gfp_mask, unsigned order);
97
98static inline struct page *
99alloc_pages(unsigned int __nocast gfp_mask, unsigned int order)
100{
101 if (unlikely(order >= MAX_ORDER))
102 return NULL;
103
104 return alloc_pages_current(gfp_mask, order);
105}
106extern struct page *alloc_page_vma(unsigned __nocast gfp_mask,
107 struct vm_area_struct *vma, unsigned long addr);
108#else
109#define alloc_pages(gfp_mask, order) \
110 alloc_pages_node(numa_node_id(), gfp_mask, order)
111#define alloc_page_vma(gfp_mask, vma, addr) alloc_pages(gfp_mask, 0)
112#endif
113#define alloc_page(gfp_mask) alloc_pages(gfp_mask, 0)
114
115extern unsigned long FASTCALL(__get_free_pages(unsigned int __nocast gfp_mask, unsigned int order));
116extern unsigned long FASTCALL(get_zeroed_page(unsigned int __nocast gfp_mask));
117
118#define __get_free_page(gfp_mask) \
119 __get_free_pages((gfp_mask),0)
120
121#define __get_dma_pages(gfp_mask, order) \
122 __get_free_pages((gfp_mask) | GFP_DMA,(order))
123
124extern void FASTCALL(__free_pages(struct page *page, unsigned int order));
125extern void FASTCALL(free_pages(unsigned long addr, unsigned int order));
126extern void FASTCALL(free_hot_page(struct page *page));
127extern void FASTCALL(free_cold_page(struct page *page));
128
129#define __free_page(page) __free_pages((page), 0)
130#define free_page(addr) free_pages((addr),0)
131
132void page_alloc_init(void);
133
134#endif /* __LINUX_GFP_H */
diff --git a/include/linux/hardirq.h b/include/linux/hardirq.h
new file mode 100644
index 000000000000..ebc712e91066
--- /dev/null
+++ b/include/linux/hardirq.h
@@ -0,0 +1,106 @@
1#ifndef LINUX_HARDIRQ_H
2#define LINUX_HARDIRQ_H
3
4#include <linux/config.h>
5#include <linux/smp_lock.h>
6#include <asm/hardirq.h>
7#include <asm/system.h>
8
9/*
10 * We put the hardirq and softirq counter into the preemption
11 * counter. The bitmask has the following meaning:
12 *
13 * - bits 0-7 are the preemption count (max preemption depth: 256)
14 * - bits 8-15 are the softirq count (max # of softirqs: 256)
15 *
16 * The hardirq count can be overridden per architecture, the default is:
17 *
18 * - bits 16-27 are the hardirq count (max # of hardirqs: 4096)
19 * - ( bit 28 is the PREEMPT_ACTIVE flag. )
20 *
21 * PREEMPT_MASK: 0x000000ff
22 * SOFTIRQ_MASK: 0x0000ff00
23 * HARDIRQ_MASK: 0x0fff0000
24 */
25#define PREEMPT_BITS 8
26#define SOFTIRQ_BITS 8
27
28#ifndef HARDIRQ_BITS
29#define HARDIRQ_BITS 12
30/*
31 * The hardirq mask has to be large enough to have space for potentially
32 * all IRQ sources in the system nesting on a single CPU.
33 */
34#if (1 << HARDIRQ_BITS) < NR_IRQS
35# error HARDIRQ_BITS is too low!
36#endif
37#endif
38
39#define PREEMPT_SHIFT 0
40#define SOFTIRQ_SHIFT (PREEMPT_SHIFT + PREEMPT_BITS)
41#define HARDIRQ_SHIFT (SOFTIRQ_SHIFT + SOFTIRQ_BITS)
42
43#define __IRQ_MASK(x) ((1UL << (x))-1)
44
45#define PREEMPT_MASK (__IRQ_MASK(PREEMPT_BITS) << PREEMPT_SHIFT)
46#define HARDIRQ_MASK (__IRQ_MASK(HARDIRQ_BITS) << HARDIRQ_SHIFT)
47#define SOFTIRQ_MASK (__IRQ_MASK(SOFTIRQ_BITS) << SOFTIRQ_SHIFT)
48
49#define PREEMPT_OFFSET (1UL << PREEMPT_SHIFT)
50#define SOFTIRQ_OFFSET (1UL << SOFTIRQ_SHIFT)
51#define HARDIRQ_OFFSET (1UL << HARDIRQ_SHIFT)
52
53#define hardirq_count() (preempt_count() & HARDIRQ_MASK)
54#define softirq_count() (preempt_count() & SOFTIRQ_MASK)
55#define irq_count() (preempt_count() & (HARDIRQ_MASK | SOFTIRQ_MASK))
56
57/*
58 * Are we doing bottom half or hardware interrupt processing?
59 * Are we in a softirq context? Interrupt context?
60 */
61#define in_irq() (hardirq_count())
62#define in_softirq() (softirq_count())
63#define in_interrupt() (irq_count())
64
65#if defined(CONFIG_PREEMPT) && !defined(CONFIG_PREEMPT_BKL)
66# define in_atomic() ((preempt_count() & ~PREEMPT_ACTIVE) != kernel_locked())
67#else
68# define in_atomic() ((preempt_count() & ~PREEMPT_ACTIVE) != 0)
69#endif
70
71#ifdef CONFIG_PREEMPT
72# define preemptible() (preempt_count() == 0 && !irqs_disabled())
73# define IRQ_EXIT_OFFSET (HARDIRQ_OFFSET-1)
74#else
75# define preemptible() 0
76# define IRQ_EXIT_OFFSET HARDIRQ_OFFSET
77#endif
78
79#ifdef CONFIG_SMP
80extern void synchronize_irq(unsigned int irq);
81#else
82# define synchronize_irq(irq) barrier()
83#endif
84
85#define nmi_enter() irq_enter()
86#define nmi_exit() sub_preempt_count(HARDIRQ_OFFSET)
87
88#ifndef CONFIG_VIRT_CPU_ACCOUNTING
89static inline void account_user_vtime(struct task_struct *tsk)
90{
91}
92
93static inline void account_system_vtime(struct task_struct *tsk)
94{
95}
96#endif
97
98#define irq_enter() \
99 do { \
100 account_system_vtime(current); \
101 add_preempt_count(HARDIRQ_OFFSET); \
102 } while (0)
103
104extern void irq_exit(void);
105
106#endif /* LINUX_HARDIRQ_H */
diff --git a/include/linux/harrier_defs.h b/include/linux/harrier_defs.h
new file mode 100644
index 000000000000..685b252e16cc
--- /dev/null
+++ b/include/linux/harrier_defs.h
@@ -0,0 +1,212 @@
1/*
2 * asm-ppc/harrier_defs.h
3 *
4 * Definitions for Motorola MCG Harrier North Bridge & Memory controller
5 *
6 * Author: Dale Farnsworth
7 * dale.farnsworth@mvista.com
8 *
9 * Extracted from asm-ppc/harrier.h by:
10 * Randy Vinson
11 * rvinson@mvista.com
12 *
13 * Copyright 2001-2002 MontaVista Software Inc.
14 *
15 * This program is free software; you can redistribute it and/or modify it
16 * under the terms of the GNU General Public License as published by the
17 * Free Software Foundation; either version 2 of the License, or (at your
18 * option) any later version.
19 */
20
21#ifndef __ASMPPC_HARRIER_DEFS_H
22#define __ASMPPC_HARRIER_DEFS_H
23
24#define HARRIER_DEFAULT_XCSR_BASE 0xfeff0000
25
26#define HARRIER_VEND_DEV_ID 0x1057480b
27
28#define HARRIER_VENI_OFF 0x00
29
30#define HARRIER_REVI_OFF 0x05
31#define HARRIER_UCTL_OFF 0xd0
32#define HARRIER_XTAL64_MASK 0x02
33
34#define HARRIER_MISC_CSR_OFF 0x1c
35#define HARRIER_RSTOUT 0x01000000
36#define HARRIER_SYSCON 0x08000000
37#define HARRIER_EREADY 0x10000000
38#define HARRIER_ERDYS 0x20000000
39
40/* Function exception registers */
41#define HARRIER_FEEN_OFF 0x40 /* enable */
42#define HARRIER_FEST_OFF 0x44 /* status */
43#define HARRIER_FEMA_OFF 0x48 /* mask */
44#define HARRIER_FECL_OFF 0x4c /* clear */
45
46#define HARRIER_FE_DMA 0x80
47#define HARRIER_FE_MIDB 0x40
48#define HARRIER_FE_MIM0 0x20
49#define HARRIER_FE_MIM1 0x10
50#define HARRIER_FE_MIP 0x08
51#define HARRIER_FE_UA0 0x04
52#define HARRIER_FE_UA1 0x02
53#define HARRIER_FE_ABT 0x01
54
55#define HARRIER_SERIAL_0_OFF 0xc0
56
57#define HARRIER_MBAR_OFF 0xe0
58#define HARRIER_MBAR_MSK 0xfffc0000
59#define HARRIER_MPIC_CSR_OFF 0xe4
60#define HARRIER_MPIC_OPI_ENABLE 0x40
61#define HARRIER_MPIC_IFEVP_OFF 0x10200
62#define HARRIER_MPIC_IFEVP_VECT_MSK 0xff
63#define HARRIER_MPIC_IFEDE_OFF 0x10210
64
65/*
66 * Define the Memory Controller register offsets.
67 */
68#define HARRIER_SDBA_OFF 0x110
69#define HARRIER_SDBB_OFF 0x114
70#define HARRIER_SDBC_OFF 0x118
71#define HARRIER_SDBD_OFF 0x11c
72#define HARRIER_SDBE_OFF 0x120
73#define HARRIER_SDBF_OFF 0x124
74#define HARRIER_SDBG_OFF 0x128
75#define HARRIER_SDBH_OFF 0x12c
76
77#define HARRIER_SDB_ENABLE 0x00000100
78#define HARRIER_SDB_SIZE_MASK 0xf
79#define HARRIER_SDB_SIZE_SHIFT 16
80#define HARRIER_SDB_BASE_MASK 0xff
81#define HARRIER_SDB_BASE_SHIFT 24
82
83/*
84 * Define outbound register offsets.
85 */
86#define HARRIER_OTAD0_OFF 0x220
87#define HARRIER_OTOF0_OFF 0x224
88#define HARRIER_OTAD1_OFF 0x228
89#define HARRIER_OTOF1_OFF 0x22c
90#define HARRIER_OTAD2_OFF 0x230
91#define HARRIER_OTOF2_OFF 0x234
92#define HARRIER_OTAD3_OFF 0x238
93#define HARRIER_OTOF3_OFF 0x23c
94
95#define HARRIER_OTADX_START_MSK 0xffff0000UL
96#define HARRIER_OTADX_END_MSK 0x0000ffffUL
97
98#define HARRIER_OTOFX_OFF_MSK 0xffff0000UL
99#define HARRIER_OTOFX_ENA 0x80UL
100#define HARRIER_OTOFX_WPE 0x10UL
101#define HARRIER_OTOFX_SGE 0x08UL
102#define HARRIER_OTOFX_RAE 0x04UL
103#define HARRIER_OTOFX_MEM 0x02UL
104#define HARRIER_OTOFX_IOM 0x01UL
105
106/*
107 * Define generic message passing register offsets
108 */
109/* Mirrored registers (visible from both PowerPC and PCI space) */
110#define HARRIER_XCSR_MP_BASE_OFF 0x290 /* base offset in XCSR space */
111#define HARRIER_PMEP_MP_BASE_OFF 0x100 /* base offset in PMEM space */
112#define HARRIER_MGOM0_OFF 0x00 /* outbound msg 0 */
113#define HARRIER_MGOM1_OFF 0x04 /* outbound msg 1 */
114#define HARRIER_MGOD_OFF 0x08 /* outbound doorbells */
115
116#define HARRIER_MGIM0_OFF 0x10 /* inbound msg 0 */
117#define HARRIER_MGIM1_OFF 0x14 /* inbound msg 1 */
118#define HARRIER_MGID_OFF 0x18 /* inbound doorbells */
119
120/* PowerPC-only registers */
121#define HARRIER_MGIDM_OFF 0x20 /* inbound doorbell mask */
122
123/* PCI-only registers */
124#define HARRIER_PMEP_MGST_OFF 0x20 /* (outbound) interrupt status */
125#define HARRIER_PMEP_MGMS_OFF 0x24 /* (outbound) interrupt mask */
126#define HARRIER_MG_OMI0 (1<<4)
127#define HARRIER_MG_OMI1 (1<<5)
128
129#define HARRIER_PMEP_MGODM_OFF 0x28 /* outbound doorbell mask */
130
131/*
132 * Define PCI configuration space register offsets
133 */
134#define HARRIER_XCSR_TO_PCFS_OFF 0x300
135
136/*
137 * Define message passing attribute register offset
138 */
139#define HARRIER_MPAT_OFF 0x44
140
141/*
142 * Define inbound attribute register offsets.
143 */
144#define HARRIER_ITSZ0_OFF 0x48
145#define HARRIER_ITAT0_OFF 0x4c
146
147#define HARRIER_ITSZ1_OFF 0x50
148#define HARRIER_ITAT1_OFF 0x54
149
150#define HARRIER_ITSZ2_OFF 0x58
151#define HARRIER_ITAT2_OFF 0x5c
152
153#define HARRIER_ITSZ3_OFF 0x60
154#define HARRIER_ITAT3_OFF 0x64
155
156/* inbound translation size constants */
157#define HARRIER_ITSZ_MSK 0xff
158#define HARRIER_ITSZ_4KB 0x00
159#define HARRIER_ITSZ_8KB 0x01
160#define HARRIER_ITSZ_16KB 0x02
161#define HARRIER_ITSZ_32KB 0x03
162#define HARRIER_ITSZ_64KB 0x04
163#define HARRIER_ITSZ_128KB 0x05
164#define HARRIER_ITSZ_256KB 0x06
165#define HARRIER_ITSZ_512KB 0x07
166#define HARRIER_ITSZ_1MB 0x08
167#define HARRIER_ITSZ_2MB 0x09
168#define HARRIER_ITSZ_4MB 0x0A
169#define HARRIER_ITSZ_8MB 0x0B
170#define HARRIER_ITSZ_16MB 0x0C
171#define HARRIER_ITSZ_32MB 0x0D
172#define HARRIER_ITSZ_64MB 0x0E
173#define HARRIER_ITSZ_128MB 0x0F
174#define HARRIER_ITSZ_256MB 0x10
175#define HARRIER_ITSZ_512MB 0x11
176#define HARRIER_ITSZ_1GB 0x12
177#define HARRIER_ITSZ_2GB 0x13
178
179/* inbound translation offset */
180#define HARRIER_ITOF_SHIFT 0x10
181#define HARRIER_ITOF_MSK 0xffff
182
183/* inbound translation atttributes */
184#define HARRIER_ITAT_PRE (1<<3)
185#define HARRIER_ITAT_RAE (1<<4)
186#define HARRIER_ITAT_WPE (1<<5)
187#define HARRIER_ITAT_MEM (1<<6)
188#define HARRIER_ITAT_ENA (1<<7)
189#define HARRIER_ITAT_GBL (1<<16)
190
191#define HARRIER_LBA_OFF 0x80
192#define HARRIER_LBA_MSK (1<<31)
193
194#define HARRIER_XCSR_SIZE 1024
195
196/* macros to calculate message passing register offsets */
197#define HARRIER_MP_XCSR(x) ((u32)HARRIER_XCSR_MP_BASE_OFF + (u32)x)
198
199#define HARRIER_MP_PMEP(x) ((u32)HARRIER_PMEP_MP_BASE_OFF + (u32)x)
200
201/*
202 * Define PCI configuration space register offsets
203 */
204#define HARRIER_MPBAR_OFF PCI_BASE_ADDRESS_0
205#define HARRIER_ITBAR0_OFF PCI_BASE_ADDRESS_1
206#define HARRIER_ITBAR1_OFF PCI_BASE_ADDRESS_2
207#define HARRIER_ITBAR2_OFF PCI_BASE_ADDRESS_3
208#define HARRIER_ITBAR3_OFF PCI_BASE_ADDRESS_4
209
210#define HARRIER_XCSR_CONFIG(x) ((u32)HARRIER_XCSR_TO_PCFS_OFF + (u32)x)
211
212#endif /* __ASMPPC_HARRIER_DEFS_H */
diff --git a/include/linux/hash.h b/include/linux/hash.h
new file mode 100644
index 000000000000..acf17bb8e7f9
--- /dev/null
+++ b/include/linux/hash.h
@@ -0,0 +1,58 @@
1#ifndef _LINUX_HASH_H
2#define _LINUX_HASH_H
3/* Fast hashing routine for a long.
4 (C) 2002 William Lee Irwin III, IBM */
5
6/*
7 * Knuth recommends primes in approximately golden ratio to the maximum
8 * integer representable by a machine word for multiplicative hashing.
9 * Chuck Lever verified the effectiveness of this technique:
10 * http://www.citi.umich.edu/techreports/reports/citi-tr-00-1.pdf
11 *
12 * These primes are chosen to be bit-sparse, that is operations on
13 * them can use shifts and additions instead of multiplications for
14 * machines where multiplications are slow.
15 */
16#if BITS_PER_LONG == 32
17/* 2^31 + 2^29 - 2^25 + 2^22 - 2^19 - 2^16 + 1 */
18#define GOLDEN_RATIO_PRIME 0x9e370001UL
19#elif BITS_PER_LONG == 64
20/* 2^63 + 2^61 - 2^57 + 2^54 - 2^51 - 2^18 + 1 */
21#define GOLDEN_RATIO_PRIME 0x9e37fffffffc0001UL
22#else
23#error Define GOLDEN_RATIO_PRIME for your wordsize.
24#endif
25
26static inline unsigned long hash_long(unsigned long val, unsigned int bits)
27{
28 unsigned long hash = val;
29
30#if BITS_PER_LONG == 64
31 /* Sigh, gcc can't optimise this alone like it does for 32 bits. */
32 unsigned long n = hash;
33 n <<= 18;
34 hash -= n;
35 n <<= 33;
36 hash -= n;
37 n <<= 3;
38 hash += n;
39 n <<= 3;
40 hash -= n;
41 n <<= 4;
42 hash += n;
43 n <<= 2;
44 hash += n;
45#else
46 /* On some cpus multiply is faster, on others gcc will do shifts */
47 hash *= GOLDEN_RATIO_PRIME;
48#endif
49
50 /* High bits are more random, so use them. */
51 return hash >> (BITS_PER_LONG - bits);
52}
53
54static inline unsigned long hash_ptr(void *ptr, unsigned int bits)
55{
56 return hash_long((unsigned long)ptr, bits);
57}
58#endif /* _LINUX_HASH_H */
diff --git a/include/linux/hayesesp.h b/include/linux/hayesesp.h
new file mode 100644
index 000000000000..b436be7a7fff
--- /dev/null
+++ b/include/linux/hayesesp.h
@@ -0,0 +1,124 @@
1#ifndef HAYESESP_H
2#define HAYESESP_H
3
4struct hayes_esp_config {
5 short flow_on;
6 short flow_off;
7 short rx_trigger;
8 short tx_trigger;
9 short pio_threshold;
10 unsigned char rx_timeout;
11 char dma_channel;
12};
13
14#ifdef __KERNEL__
15
16#define ESP_DMA_CHANNEL 0
17#define ESP_RX_TRIGGER 768
18#define ESP_TX_TRIGGER 768
19#define ESP_FLOW_OFF 1016
20#define ESP_FLOW_ON 944
21#define ESP_RX_TMOUT 128
22#define ESP_PIO_THRESHOLD 32
23
24#define ESP_IN_MAJOR 57 /* major dev # for dial in */
25#define ESP_OUT_MAJOR 58 /* major dev # for dial out */
26#define ESPC_SCALE 3
27#define UART_ESI_BASE 0x00
28#define UART_ESI_SID 0x01
29#define UART_ESI_RX 0x02
30#define UART_ESI_TX 0x02
31#define UART_ESI_CMD1 0x04
32#define UART_ESI_CMD2 0x05
33#define UART_ESI_STAT1 0x04
34#define UART_ESI_STAT2 0x05
35#define UART_ESI_RWS 0x07
36
37#define UART_IER_DMA_TMOUT 0x80
38#define UART_IER_DMA_TC 0x08
39
40#define ESI_SET_IRQ 0x04
41#define ESI_SET_DMA_TMOUT 0x05
42#define ESI_SET_SRV_MASK 0x06
43#define ESI_SET_ERR_MASK 0x07
44#define ESI_SET_FLOW_CNTL 0x08
45#define ESI_SET_FLOW_CHARS 0x09
46#define ESI_SET_FLOW_LVL 0x0a
47#define ESI_SET_TRIGGER 0x0b
48#define ESI_SET_RX_TIMEOUT 0x0c
49#define ESI_SET_FLOW_TMOUT 0x0d
50#define ESI_WRITE_UART 0x0e
51#define ESI_READ_UART 0x0f
52#define ESI_SET_MODE 0x10
53#define ESI_GET_ERR_STAT 0x12
54#define ESI_GET_UART_STAT 0x13
55#define ESI_GET_RX_AVAIL 0x14
56#define ESI_GET_TX_AVAIL 0x15
57#define ESI_START_DMA_RX 0x16
58#define ESI_START_DMA_TX 0x17
59#define ESI_ISSUE_BREAK 0x1a
60#define ESI_FLUSH_RX 0x1b
61#define ESI_FLUSH_TX 0x1c
62#define ESI_SET_BAUD 0x1d
63#define ESI_SET_ENH_IRQ 0x1f
64#define ESI_SET_REINTR 0x20
65#define ESI_SET_PRESCALAR 0x23
66#define ESI_NO_COMMAND 0xff
67
68#define ESP_STAT_RX_TIMEOUT 0x01
69#define ESP_STAT_DMA_RX 0x02
70#define ESP_STAT_DMA_TX 0x04
71#define ESP_STAT_NEVER_DMA 0x08
72#define ESP_STAT_USE_PIO 0x10
73
74#define ESP_EVENT_WRITE_WAKEUP 0
75#define ESP_MAGIC 0x53ee
76#define ESP_XMIT_SIZE 4096
77
78struct esp_struct {
79 int magic;
80 spinlock_t lock;
81 int port;
82 int irq;
83 int flags; /* defined in tty.h */
84 struct tty_struct *tty;
85 int read_status_mask;
86 int ignore_status_mask;
87 int timeout;
88 int stat_flags;
89 int custom_divisor;
90 int close_delay;
91 unsigned short closing_wait;
92 unsigned short closing_wait2;
93 int IER; /* Interrupt Enable Register */
94 int MCR; /* Modem control register */
95 unsigned long event;
96 unsigned long last_active;
97 int line;
98 int count; /* # of fd on device */
99 int blocked_open; /* # of blocked opens */
100 unsigned char *xmit_buf;
101 int xmit_head;
102 int xmit_tail;
103 int xmit_cnt;
104 struct work_struct tqueue;
105 struct work_struct tqueue_hangup;
106 wait_queue_head_t open_wait;
107 wait_queue_head_t close_wait;
108 wait_queue_head_t delta_msr_wait;
109 wait_queue_head_t break_wait;
110 struct async_icount icount; /* kernel counters for the 4 input interrupts */
111 struct hayes_esp_config config; /* port configuration */
112 struct esp_struct *next_port; /* For the linked list */
113};
114
115struct esp_pio_buffer {
116 unsigned char data[1024];
117 struct esp_pio_buffer *next;
118};
119
120#endif /* __KERNEL__ */
121
122
123#endif /* ESP_H */
124
diff --git a/include/linux/hdlc.h b/include/linux/hdlc.h
new file mode 100644
index 000000000000..503194e62fe1
--- /dev/null
+++ b/include/linux/hdlc.h
@@ -0,0 +1,258 @@
1/*
2 * Generic HDLC support routines for Linux
3 *
4 * Copyright (C) 1999-2003 Krzysztof Halasa <khc@pm.waw.pl>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of version 2 of the GNU General Public License
8 * as published by the Free Software Foundation.
9 */
10
11#ifndef __HDLC_H
12#define __HDLC_H
13
14#define GENERIC_HDLC_VERSION 4 /* For synchronization with sethdlc utility */
15
16#define CLOCK_DEFAULT 0 /* Default setting */
17#define CLOCK_EXT 1 /* External TX and RX clock - DTE */
18#define CLOCK_INT 2 /* Internal TX and RX clock - DCE */
19#define CLOCK_TXINT 3 /* Internal TX and external RX clock */
20#define CLOCK_TXFROMRX 4 /* TX clock derived from external RX clock */
21
22
23#define ENCODING_DEFAULT 0 /* Default setting */
24#define ENCODING_NRZ 1
25#define ENCODING_NRZI 2
26#define ENCODING_FM_MARK 3
27#define ENCODING_FM_SPACE 4
28#define ENCODING_MANCHESTER 5
29
30
31#define PARITY_DEFAULT 0 /* Default setting */
32#define PARITY_NONE 1 /* No parity */
33#define PARITY_CRC16_PR0 2 /* CRC16, initial value 0x0000 */
34#define PARITY_CRC16_PR1 3 /* CRC16, initial value 0xFFFF */
35#define PARITY_CRC16_PR0_CCITT 4 /* CRC16, initial 0x0000, ITU-T version */
36#define PARITY_CRC16_PR1_CCITT 5 /* CRC16, initial 0xFFFF, ITU-T version */
37#define PARITY_CRC32_PR0_CCITT 6 /* CRC32, initial value 0x00000000 */
38#define PARITY_CRC32_PR1_CCITT 7 /* CRC32, initial value 0xFFFFFFFF */
39
40#define LMI_DEFAULT 0 /* Default setting */
41#define LMI_NONE 1 /* No LMI, all PVCs are static */
42#define LMI_ANSI 2 /* ANSI Annex D */
43#define LMI_CCITT 3 /* ITU-T Annex A */
44
45#define HDLC_MAX_MTU 1500 /* Ethernet 1500 bytes */
46#define HDLC_MAX_MRU (HDLC_MAX_MTU + 10 + 14 + 4) /* for ETH+VLAN over FR */
47
48
49#ifdef __KERNEL__
50
51#include <linux/skbuff.h>
52#include <linux/netdevice.h>
53#include <net/syncppp.h>
54#include <linux/hdlc/ioctl.h>
55
56
57typedef struct { /* Used in Cisco and PPP mode */
58 u8 address;
59 u8 control;
60 u16 protocol;
61}__attribute__ ((packed)) hdlc_header;
62
63
64
65typedef struct {
66 u32 type; /* code */
67 u32 par1;
68 u32 par2;
69 u16 rel; /* reliability */
70 u32 time;
71}__attribute__ ((packed)) cisco_packet;
72#define CISCO_PACKET_LEN 18
73#define CISCO_BIG_PACKET_LEN 20
74
75
76
77typedef struct pvc_device_struct {
78 struct net_device *master;
79 struct net_device *main;
80 struct net_device *ether; /* bridged Ethernet interface */
81 struct pvc_device_struct *next; /* Sorted in ascending DLCI order */
82 int dlci;
83 int open_count;
84
85 struct {
86 unsigned int new: 1;
87 unsigned int active: 1;
88 unsigned int exist: 1;
89 unsigned int deleted: 1;
90 unsigned int fecn: 1;
91 unsigned int becn: 1;
92 }state;
93}pvc_device;
94
95
96
97typedef struct hdlc_device_struct {
98 /* To be initialized by hardware driver */
99 struct net_device_stats stats;
100
101 /* used by HDLC layer to take control over HDLC device from hw driver*/
102 int (*attach)(struct net_device *dev,
103 unsigned short encoding, unsigned short parity);
104
105 /* hardware driver must handle this instead of dev->hard_start_xmit */
106 int (*xmit)(struct sk_buff *skb, struct net_device *dev);
107
108
109 /* Things below are for HDLC layer internal use only */
110 struct {
111 int (*open)(struct net_device *dev);
112 void (*close)(struct net_device *dev);
113
114 /* if open & DCD */
115 void (*start)(struct net_device *dev);
116 /* if open & !DCD */
117 void (*stop)(struct net_device *dev);
118
119 void (*detach)(struct hdlc_device_struct *hdlc);
120 int (*netif_rx)(struct sk_buff *skb);
121 unsigned short (*type_trans)(struct sk_buff *skb,
122 struct net_device *dev);
123 int id; /* IF_PROTO_HDLC/CISCO/FR/etc. */
124 }proto;
125
126 int carrier;
127 int open;
128 spinlock_t state_lock;
129
130 union {
131 struct {
132 fr_proto settings;
133 pvc_device *first_pvc;
134 int dce_pvc_count;
135
136 struct timer_list timer;
137 unsigned long last_poll;
138 int reliable;
139 int dce_changed;
140 int request;
141 int fullrep_sent;
142 u32 last_errors; /* last errors bit list */
143 u8 n391cnt;
144 u8 txseq; /* TX sequence number */
145 u8 rxseq; /* RX sequence number */
146 }fr;
147
148 struct {
149 cisco_proto settings;
150
151 struct timer_list timer;
152 unsigned long last_poll;
153 int up;
154 int request_sent;
155 u32 txseq; /* TX sequence number */
156 u32 rxseq; /* RX sequence number */
157 }cisco;
158
159 struct {
160 raw_hdlc_proto settings;
161 }raw_hdlc;
162
163 struct {
164 struct ppp_device pppdev;
165 struct ppp_device *syncppp_ptr;
166 int (*old_change_mtu)(struct net_device *dev,
167 int new_mtu);
168 }ppp;
169 }state;
170 void *priv;
171}hdlc_device;
172
173
174
175int hdlc_raw_ioctl(struct net_device *dev, struct ifreq *ifr);
176int hdlc_raw_eth_ioctl(struct net_device *dev, struct ifreq *ifr);
177int hdlc_cisco_ioctl(struct net_device *dev, struct ifreq *ifr);
178int hdlc_ppp_ioctl(struct net_device *dev, struct ifreq *ifr);
179int hdlc_fr_ioctl(struct net_device *dev, struct ifreq *ifr);
180int hdlc_x25_ioctl(struct net_device *dev, struct ifreq *ifr);
181
182
183/* Exported from hdlc.o */
184
185/* Called by hardware driver when a user requests HDLC service */
186int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
187
188/* Must be used by hardware driver on module startup/exit */
189int register_hdlc_device(struct net_device *dev);
190void unregister_hdlc_device(struct net_device *dev);
191
192struct net_device *alloc_hdlcdev(void *priv);
193
194static __inline__ hdlc_device* dev_to_hdlc(struct net_device *dev)
195{
196 return netdev_priv(dev);
197}
198
199
200static __inline__ pvc_device* dev_to_pvc(struct net_device *dev)
201{
202 return (pvc_device*)dev->priv;
203}
204
205
206static __inline__ void debug_frame(const struct sk_buff *skb)
207{
208 int i;
209
210 for (i=0; i < skb->len; i++) {
211 if (i == 100) {
212 printk("...\n");
213 return;
214 }
215 printk(" %02X", skb->data[i]);
216 }
217 printk("\n");
218}
219
220
221/* Must be called by hardware driver when HDLC device is being opened */
222int hdlc_open(struct net_device *dev);
223/* Must be called by hardware driver when HDLC device is being closed */
224void hdlc_close(struct net_device *dev);
225/* Called by hardware driver when DCD line level changes */
226void hdlc_set_carrier(int on, struct net_device *dev);
227
228/* May be used by hardware driver to gain control over HDLC device */
229static __inline__ void hdlc_proto_detach(hdlc_device *hdlc)
230{
231 if (hdlc->proto.detach)
232 hdlc->proto.detach(hdlc);
233 hdlc->proto.detach = NULL;
234}
235
236
237static __inline__ struct net_device_stats *hdlc_stats(struct net_device *dev)
238{
239 return &dev_to_hdlc(dev)->stats;
240}
241
242
243static __inline__ unsigned short hdlc_type_trans(struct sk_buff *skb,
244 struct net_device *dev)
245{
246 hdlc_device *hdlc = dev_to_hdlc(dev);
247
248 skb->mac.raw = skb->data;
249 skb->dev = dev;
250
251 if (hdlc->proto.type_trans)
252 return hdlc->proto.type_trans(skb, dev);
253 else
254 return htons(ETH_P_HDLC);
255}
256
257#endif /* __KERNEL */
258#endif /* __HDLC_H */
diff --git a/include/linux/hdlc/ioctl.h b/include/linux/hdlc/ioctl.h
new file mode 100644
index 000000000000..78430ba3ea69
--- /dev/null
+++ b/include/linux/hdlc/ioctl.h
@@ -0,0 +1,48 @@
1#ifndef __HDLC_IOCTL_H__
2#define __HDLC_IOCTL_H__
3
4typedef struct {
5 unsigned int clock_rate; /* bits per second */
6 unsigned int clock_type; /* internal, external, TX-internal etc. */
7 unsigned short loopback;
8} sync_serial_settings; /* V.35, V.24, X.21 */
9
10typedef struct {
11 unsigned int clock_rate; /* bits per second */
12 unsigned int clock_type; /* internal, external, TX-internal etc. */
13 unsigned short loopback;
14 unsigned int slot_map;
15} te1_settings; /* T1, E1 */
16
17typedef struct {
18 unsigned short encoding;
19 unsigned short parity;
20} raw_hdlc_proto;
21
22typedef struct {
23 unsigned int t391;
24 unsigned int t392;
25 unsigned int n391;
26 unsigned int n392;
27 unsigned int n393;
28 unsigned short lmi;
29 unsigned short dce; /* 1 for DCE (network side) operation */
30} fr_proto;
31
32typedef struct {
33 unsigned int dlci;
34} fr_proto_pvc; /* for creating/deleting FR PVCs */
35
36typedef struct {
37 unsigned int dlci;
38 char master[IFNAMSIZ]; /* Name of master FRAD device */
39}fr_proto_pvc_info; /* for returning PVC information only */
40
41typedef struct {
42 unsigned int interval;
43 unsigned int timeout;
44} cisco_proto;
45
46/* PPP doesn't need any info now - supply length = 0 to ioctl */
47
48#endif /* __HDLC_IOCTL_H__ */
diff --git a/include/linux/hdlcdrv.h b/include/linux/hdlcdrv.h
new file mode 100644
index 000000000000..4f6ee3b267fa
--- /dev/null
+++ b/include/linux/hdlcdrv.h
@@ -0,0 +1,378 @@
1/*
2 * hdlcdrv.h -- HDLC packet radio network driver.
3 * The Linux soundcard driver for 1200 baud and 9600 baud packet radio
4 * (C) 1996-1998 by Thomas Sailer, HB9JNX/AE4WA
5 */
6
7#ifndef _HDLCDRV_H
8#define _HDLCDRV_H
9
10/* -------------------------------------------------------------------- */
11/*
12 * structs for the IOCTL commands
13 */
14
15struct hdlcdrv_params {
16 int iobase;
17 int irq;
18 int dma;
19 int dma2;
20 int seriobase;
21 int pariobase;
22 int midiiobase;
23};
24
25struct hdlcdrv_channel_params {
26 int tx_delay; /* the transmitter keyup delay in 10ms units */
27 int tx_tail; /* the transmitter keyoff delay in 10ms units */
28 int slottime; /* the slottime in 10ms; usually 10 = 100ms */
29 int ppersist; /* the p-persistence 0..255 */
30 int fulldup; /* some driver do not support full duplex, setting */
31 /* this just makes them send even if DCD is on */
32};
33
34struct hdlcdrv_old_channel_state {
35 int ptt;
36 int dcd;
37 int ptt_keyed;
38};
39
40struct hdlcdrv_channel_state {
41 int ptt;
42 int dcd;
43 int ptt_keyed;
44 unsigned long tx_packets;
45 unsigned long tx_errors;
46 unsigned long rx_packets;
47 unsigned long rx_errors;
48};
49
50struct hdlcdrv_ioctl {
51 int cmd;
52 union {
53 struct hdlcdrv_params mp;
54 struct hdlcdrv_channel_params cp;
55 struct hdlcdrv_channel_state cs;
56 struct hdlcdrv_old_channel_state ocs;
57 unsigned int calibrate;
58 unsigned char bits;
59 char modename[128];
60 char drivername[32];
61 } data;
62};
63
64/* -------------------------------------------------------------------- */
65
66/*
67 * ioctl values
68 */
69#define HDLCDRVCTL_GETMODEMPAR 0
70#define HDLCDRVCTL_SETMODEMPAR 1
71#define HDLCDRVCTL_MODEMPARMASK 2 /* not handled by hdlcdrv */
72#define HDLCDRVCTL_GETCHANNELPAR 10
73#define HDLCDRVCTL_SETCHANNELPAR 11
74#define HDLCDRVCTL_OLDGETSTAT 20
75#define HDLCDRVCTL_CALIBRATE 21
76#define HDLCDRVCTL_GETSTAT 22
77
78/*
79 * these are mainly for debugging purposes
80 */
81#define HDLCDRVCTL_GETSAMPLES 30
82#define HDLCDRVCTL_GETBITS 31
83
84/*
85 * not handled by hdlcdrv, but by its depending drivers
86 */
87#define HDLCDRVCTL_GETMODE 40
88#define HDLCDRVCTL_SETMODE 41
89#define HDLCDRVCTL_MODELIST 42
90#define HDLCDRVCTL_DRIVERNAME 43
91
92/*
93 * mask of needed modem parameters, returned by HDLCDRVCTL_MODEMPARMASK
94 */
95#define HDLCDRV_PARMASK_IOBASE (1<<0)
96#define HDLCDRV_PARMASK_IRQ (1<<1)
97#define HDLCDRV_PARMASK_DMA (1<<2)
98#define HDLCDRV_PARMASK_DMA2 (1<<3)
99#define HDLCDRV_PARMASK_SERIOBASE (1<<4)
100#define HDLCDRV_PARMASK_PARIOBASE (1<<5)
101#define HDLCDRV_PARMASK_MIDIIOBASE (1<<6)
102
103/* -------------------------------------------------------------------- */
104
105#ifdef __KERNEL__
106
107#include <linux/netdevice.h>
108#include <linux/if.h>
109#include <linux/spinlock.h>
110
111#define HDLCDRV_MAGIC 0x5ac6e778
112#define HDLCDRV_HDLCBUFFER 32 /* should be a power of 2 for speed reasons */
113#define HDLCDRV_BITBUFFER 256 /* should be a power of 2 for speed reasons */
114#undef HDLCDRV_LOOPBACK /* define for HDLC debugging purposes */
115#define HDLCDRV_DEBUG
116
117/* maximum packet length, excluding CRC */
118#define HDLCDRV_MAXFLEN 400
119
120
121struct hdlcdrv_hdlcbuffer {
122 spinlock_t lock;
123 unsigned rd, wr;
124 unsigned short buf[HDLCDRV_HDLCBUFFER];
125};
126
127#ifdef HDLCDRV_DEBUG
128struct hdlcdrv_bitbuffer {
129 unsigned int rd;
130 unsigned int wr;
131 unsigned int shreg;
132 unsigned char buffer[HDLCDRV_BITBUFFER];
133};
134
135static inline void hdlcdrv_add_bitbuffer(struct hdlcdrv_bitbuffer *buf,
136 unsigned int bit)
137{
138 unsigned char new;
139
140 new = buf->shreg & 1;
141 buf->shreg >>= 1;
142 buf->shreg |= (!!bit) << 7;
143 if (new) {
144 buf->buffer[buf->wr] = buf->shreg;
145 buf->wr = (buf->wr+1) % sizeof(buf->buffer);
146 buf->shreg = 0x80;
147 }
148}
149
150static inline void hdlcdrv_add_bitbuffer_word(struct hdlcdrv_bitbuffer *buf,
151 unsigned int bits)
152{
153 buf->buffer[buf->wr] = bits & 0xff;
154 buf->wr = (buf->wr+1) % sizeof(buf->buffer);
155 buf->buffer[buf->wr] = (bits >> 8) & 0xff;
156 buf->wr = (buf->wr+1) % sizeof(buf->buffer);
157
158}
159#endif /* HDLCDRV_DEBUG */
160
161/* -------------------------------------------------------------------- */
162/*
163 * Information that need to be kept for each driver.
164 */
165
166struct hdlcdrv_ops {
167 /*
168 * first some informations needed by the hdlcdrv routines
169 */
170 const char *drvname;
171 const char *drvinfo;
172 /*
173 * the routines called by the hdlcdrv routines
174 */
175 int (*open)(struct net_device *);
176 int (*close)(struct net_device *);
177 int (*ioctl)(struct net_device *, struct ifreq *,
178 struct hdlcdrv_ioctl *, int);
179};
180
181struct hdlcdrv_state {
182 int magic;
183 int opened;
184
185 const struct hdlcdrv_ops *ops;
186
187 struct {
188 int bitrate;
189 } par;
190
191 struct hdlcdrv_pttoutput {
192 int dma2;
193 int seriobase;
194 int pariobase;
195 int midiiobase;
196 unsigned int flags;
197 } ptt_out;
198
199 struct hdlcdrv_channel_params ch_params;
200
201 struct hdlcdrv_hdlcrx {
202 struct hdlcdrv_hdlcbuffer hbuf;
203 long in_hdlc_rx;
204 /* 0 = sync hunt, != 0 receiving */
205 int rx_state;
206 unsigned int bitstream;
207 unsigned int bitbuf;
208 int numbits;
209 unsigned char dcd;
210
211 int len;
212 unsigned char *bp;
213 unsigned char buffer[HDLCDRV_MAXFLEN+2];
214 } hdlcrx;
215
216 struct hdlcdrv_hdlctx {
217 struct hdlcdrv_hdlcbuffer hbuf;
218 long in_hdlc_tx;
219 /*
220 * 0 = send flags
221 * 1 = send txtail (flags)
222 * 2 = send packet
223 */
224 int tx_state;
225 int numflags;
226 unsigned int bitstream;
227 unsigned char ptt;
228 int calibrate;
229 int slotcnt;
230
231 unsigned int bitbuf;
232 int numbits;
233
234 int len;
235 unsigned char *bp;
236 unsigned char buffer[HDLCDRV_MAXFLEN+2];
237 } hdlctx;
238
239#ifdef HDLCDRV_DEBUG
240 struct hdlcdrv_bitbuffer bitbuf_channel;
241 struct hdlcdrv_bitbuffer bitbuf_hdlc;
242#endif /* HDLCDRV_DEBUG */
243
244 struct net_device_stats stats;
245 int ptt_keyed;
246
247 /* queued skb for transmission */
248 struct sk_buff *skb;
249};
250
251
252/* -------------------------------------------------------------------- */
253
254static inline int hdlcdrv_hbuf_full(struct hdlcdrv_hdlcbuffer *hb)
255{
256 unsigned long flags;
257 int ret;
258
259 spin_lock_irqsave(&hb->lock, flags);
260 ret = !((HDLCDRV_HDLCBUFFER - 1 + hb->rd - hb->wr) % HDLCDRV_HDLCBUFFER);
261 spin_unlock_irqrestore(&hb->lock, flags);
262 return ret;
263}
264
265/* -------------------------------------------------------------------- */
266
267static inline int hdlcdrv_hbuf_empty(struct hdlcdrv_hdlcbuffer *hb)
268{
269 unsigned long flags;
270 int ret;
271
272 spin_lock_irqsave(&hb->lock, flags);
273 ret = (hb->rd == hb->wr);
274 spin_unlock_irqrestore(&hb->lock, flags);
275 return ret;
276}
277
278/* -------------------------------------------------------------------- */
279
280static inline unsigned short hdlcdrv_hbuf_get(struct hdlcdrv_hdlcbuffer *hb)
281{
282 unsigned long flags;
283 unsigned short val;
284 unsigned newr;
285
286 spin_lock_irqsave(&hb->lock, flags);
287 if (hb->rd == hb->wr)
288 val = 0;
289 else {
290 newr = (hb->rd+1) % HDLCDRV_HDLCBUFFER;
291 val = hb->buf[hb->rd];
292 hb->rd = newr;
293 }
294 spin_unlock_irqrestore(&hb->lock, flags);
295 return val;
296}
297
298/* -------------------------------------------------------------------- */
299
300static inline void hdlcdrv_hbuf_put(struct hdlcdrv_hdlcbuffer *hb,
301 unsigned short val)
302{
303 unsigned newp;
304 unsigned long flags;
305
306 spin_lock_irqsave(&hb->lock, flags);
307 newp = (hb->wr+1) % HDLCDRV_HDLCBUFFER;
308 if (newp != hb->rd) {
309 hb->buf[hb->wr] = val & 0xffff;
310 hb->wr = newp;
311 }
312 spin_unlock_irqrestore(&hb->lock, flags);
313}
314
315/* -------------------------------------------------------------------- */
316
317static inline void hdlcdrv_putbits(struct hdlcdrv_state *s, unsigned int bits)
318{
319 hdlcdrv_hbuf_put(&s->hdlcrx.hbuf, bits);
320}
321
322static inline unsigned int hdlcdrv_getbits(struct hdlcdrv_state *s)
323{
324 unsigned int ret;
325
326 if (hdlcdrv_hbuf_empty(&s->hdlctx.hbuf)) {
327 if (s->hdlctx.calibrate > 0)
328 s->hdlctx.calibrate--;
329 else
330 s->hdlctx.ptt = 0;
331 ret = 0;
332 } else
333 ret = hdlcdrv_hbuf_get(&s->hdlctx.hbuf);
334#ifdef HDLCDRV_LOOPBACK
335 hdlcdrv_hbuf_put(&s->hdlcrx.hbuf, ret);
336#endif /* HDLCDRV_LOOPBACK */
337 return ret;
338}
339
340static inline void hdlcdrv_channelbit(struct hdlcdrv_state *s, unsigned int bit)
341{
342#ifdef HDLCDRV_DEBUG
343 hdlcdrv_add_bitbuffer(&s->bitbuf_channel, bit);
344#endif /* HDLCDRV_DEBUG */
345}
346
347static inline void hdlcdrv_setdcd(struct hdlcdrv_state *s, int dcd)
348{
349 s->hdlcrx.dcd = !!dcd;
350}
351
352static inline int hdlcdrv_ptt(struct hdlcdrv_state *s)
353{
354 return s->hdlctx.ptt || (s->hdlctx.calibrate > 0);
355}
356
357/* -------------------------------------------------------------------- */
358
359void hdlcdrv_receiver(struct net_device *, struct hdlcdrv_state *);
360void hdlcdrv_transmitter(struct net_device *, struct hdlcdrv_state *);
361void hdlcdrv_arbitrate(struct net_device *, struct hdlcdrv_state *);
362struct net_device *hdlcdrv_register(const struct hdlcdrv_ops *ops,
363 unsigned int privsize, const char *ifname,
364 unsigned int baseaddr, unsigned int irq,
365 unsigned int dma);
366void hdlcdrv_unregister(struct net_device *dev);
367
368/* -------------------------------------------------------------------- */
369
370
371
372#endif /* __KERNEL__ */
373
374/* -------------------------------------------------------------------- */
375
376#endif /* _HDLCDRV_H */
377
378/* -------------------------------------------------------------------- */
diff --git a/include/linux/hdpu_features.h b/include/linux/hdpu_features.h
new file mode 100644
index 000000000000..6a8715431ae4
--- /dev/null
+++ b/include/linux/hdpu_features.h
@@ -0,0 +1,26 @@
1#include <linux/spinlock.h>
2
3struct cpustate_t {
4 spinlock_t lock;
5 int excl;
6 int open_count;
7 unsigned char cached_val;
8 int inited;
9 unsigned long *set_addr;
10 unsigned long *clr_addr;
11};
12
13
14#define HDPU_CPUSTATE_NAME "hdpu cpustate"
15#define HDPU_NEXUS_NAME "hdpu nexus"
16
17#define CPUSTATE_KERNEL_MAJOR 0x10
18
19#define CPUSTATE_KERNEL_INIT_DRV 0 /* CPU State Driver Initialized */
20#define CPUSTATE_KERNEL_INIT_PCI 1 /* 64360 PCI Busses Init */
21#define CPUSTATE_KERNEL_INIT_REG 2 /* 64360 Bridge Init */
22#define CPUSTATE_KERNEL_CPU1_KICK 3 /* Boot cpu 1 */
23#define CPUSTATE_KERNEL_CPU1_OK 4 /* Cpu 1 has checked in */
24#define CPUSTATE_KERNEL_OK 5 /* Terminal state */
25#define CPUSTATE_KERNEL_RESET 14 /* Board reset via SW*/
26#define CPUSTATE_KERNEL_HALT 15 /* Board halted via SW*/
diff --git a/include/linux/hdreg.h b/include/linux/hdreg.h
new file mode 100644
index 000000000000..b5d660089de4
--- /dev/null
+++ b/include/linux/hdreg.h
@@ -0,0 +1,703 @@
1#ifndef _LINUX_HDREG_H
2#define _LINUX_HDREG_H
3
4#ifdef __KERNEL__
5#include <linux/ata.h>
6
7/*
8 * This file contains some defines for the AT-hd-controller.
9 * Various sources.
10 */
11
12/* ide.c has its own port definitions in "ide.h" */
13
14#define HD_IRQ 14
15
16/* Hd controller regs. Ref: IBM AT Bios-listing */
17#define HD_DATA 0x1f0 /* _CTL when writing */
18#define HD_ERROR 0x1f1 /* see err-bits */
19#define HD_NSECTOR 0x1f2 /* nr of sectors to read/write */
20#define HD_SECTOR 0x1f3 /* starting sector */
21#define HD_LCYL 0x1f4 /* starting cylinder */
22#define HD_HCYL 0x1f5 /* high byte of starting cyl */
23#define HD_CURRENT 0x1f6 /* 101dhhhh , d=drive, hhhh=head */
24#define HD_STATUS 0x1f7 /* see status-bits */
25#define HD_FEATURE HD_ERROR /* same io address, read=error, write=feature */
26#define HD_PRECOMP HD_FEATURE /* obsolete use of this port - predates IDE */
27#define HD_COMMAND HD_STATUS /* same io address, read=status, write=cmd */
28
29#define HD_CMD 0x3f6 /* used for resets */
30#define HD_ALTSTATUS 0x3f6 /* same as HD_STATUS but doesn't clear irq */
31
32/* remainder is shared between hd.c, ide.c, ide-cd.c, and the hdparm utility */
33
34/* Bits of HD_STATUS */
35#define ERR_STAT 0x01
36#define INDEX_STAT 0x02
37#define ECC_STAT 0x04 /* Corrected error */
38#define DRQ_STAT 0x08
39#define SEEK_STAT 0x10
40#define SRV_STAT 0x10
41#define WRERR_STAT 0x20
42#define READY_STAT 0x40
43#define BUSY_STAT 0x80
44
45/* Bits for HD_ERROR */
46#define MARK_ERR 0x01 /* Bad address mark */
47#define TRK0_ERR 0x02 /* couldn't find track 0 */
48#define ABRT_ERR 0x04 /* Command aborted */
49#define MCR_ERR 0x08 /* media change request */
50#define ID_ERR 0x10 /* ID field not found */
51#define MC_ERR 0x20 /* media changed */
52#define ECC_ERR 0x40 /* Uncorrectable ECC error */
53#define BBD_ERR 0x80 /* pre-EIDE meaning: block marked bad */
54#define ICRC_ERR 0x80 /* new meaning: CRC error during transfer */
55
56/* Bits of HD_NSECTOR */
57#define CD 0x01
58#define IO 0x02
59#define REL 0x04
60#define TAG_MASK 0xf8
61#endif /* __KERNEL__ */
62
63/*
64 * Command Header sizes for IOCTL commands
65 */
66
67#define HDIO_DRIVE_CMD_HDR_SIZE (4 * sizeof(u8))
68#define HDIO_DRIVE_HOB_HDR_SIZE (8 * sizeof(u8))
69#define HDIO_DRIVE_TASK_HDR_SIZE (8 * sizeof(u8))
70
71#define IDE_DRIVE_TASK_INVALID -1
72#define IDE_DRIVE_TASK_NO_DATA 0
73#define IDE_DRIVE_TASK_SET_XFER 1
74
75#define IDE_DRIVE_TASK_IN 2
76
77#define IDE_DRIVE_TASK_OUT 3
78#define IDE_DRIVE_TASK_RAW_WRITE 4
79
80/*
81 * Define standard taskfile in/out register
82 */
83#define IDE_TASKFILE_STD_OUT_FLAGS 0xFE
84#define IDE_TASKFILE_STD_IN_FLAGS 0xFE
85#define IDE_HOB_STD_OUT_FLAGS 0x3C
86#define IDE_HOB_STD_IN_FLAGS 0x3C
87
88typedef unsigned char task_ioreg_t;
89typedef unsigned long sata_ioreg_t;
90
91typedef union ide_reg_valid_s {
92 unsigned all : 16;
93 struct {
94 unsigned data : 1;
95 unsigned error_feature : 1;
96 unsigned sector : 1;
97 unsigned nsector : 1;
98 unsigned lcyl : 1;
99 unsigned hcyl : 1;
100 unsigned select : 1;
101 unsigned status_command : 1;
102
103 unsigned data_hob : 1;
104 unsigned error_feature_hob : 1;
105 unsigned sector_hob : 1;
106 unsigned nsector_hob : 1;
107 unsigned lcyl_hob : 1;
108 unsigned hcyl_hob : 1;
109 unsigned select_hob : 1;
110 unsigned control_hob : 1;
111 } b;
112} ide_reg_valid_t;
113
114typedef struct ide_task_request_s {
115 task_ioreg_t io_ports[8];
116 task_ioreg_t hob_ports[8];
117 ide_reg_valid_t out_flags;
118 ide_reg_valid_t in_flags;
119 int data_phase;
120 int req_cmd;
121 unsigned long out_size;
122 unsigned long in_size;
123} ide_task_request_t;
124
125typedef struct ide_ioctl_request_s {
126 ide_task_request_t *task_request;
127 unsigned char *out_buffer;
128 unsigned char *in_buffer;
129} ide_ioctl_request_t;
130
131struct hd_drive_cmd_hdr {
132 task_ioreg_t command;
133 task_ioreg_t sector_number;
134 task_ioreg_t feature;
135 task_ioreg_t sector_count;
136};
137
138typedef struct hd_drive_task_hdr {
139 task_ioreg_t data;
140 task_ioreg_t feature;
141 task_ioreg_t sector_count;
142 task_ioreg_t sector_number;
143 task_ioreg_t low_cylinder;
144 task_ioreg_t high_cylinder;
145 task_ioreg_t device_head;
146 task_ioreg_t command;
147} task_struct_t;
148
149typedef struct hd_drive_hob_hdr {
150 task_ioreg_t data;
151 task_ioreg_t feature;
152 task_ioreg_t sector_count;
153 task_ioreg_t sector_number;
154 task_ioreg_t low_cylinder;
155 task_ioreg_t high_cylinder;
156 task_ioreg_t device_head;
157 task_ioreg_t control;
158} hob_struct_t;
159
160#define TASKFILE_INVALID 0x7fff
161#define TASKFILE_48 0x8000
162
163#define TASKFILE_NO_DATA 0x0000
164
165#define TASKFILE_IN 0x0001
166#define TASKFILE_MULTI_IN 0x0002
167
168#define TASKFILE_OUT 0x0004
169#define TASKFILE_MULTI_OUT 0x0008
170#define TASKFILE_IN_OUT 0x0010
171
172#define TASKFILE_IN_DMA 0x0020
173#define TASKFILE_OUT_DMA 0x0040
174#define TASKFILE_IN_DMAQ 0x0080
175#define TASKFILE_OUT_DMAQ 0x0100
176
177#define TASKFILE_P_IN 0x0200
178#define TASKFILE_P_OUT 0x0400
179#define TASKFILE_P_IN_DMA 0x0800
180#define TASKFILE_P_OUT_DMA 0x1000
181#define TASKFILE_P_IN_DMAQ 0x2000
182#define TASKFILE_P_OUT_DMAQ 0x4000
183
184/* ATA/ATAPI Commands pre T13 Spec */
185#define WIN_NOP 0x00
186/*
187 * 0x01->0x02 Reserved
188 */
189#define CFA_REQ_EXT_ERROR_CODE 0x03 /* CFA Request Extended Error Code */
190/*
191 * 0x04->0x07 Reserved
192 */
193#define WIN_SRST 0x08 /* ATAPI soft reset command */
194#define WIN_DEVICE_RESET 0x08
195/*
196 * 0x09->0x0F Reserved
197 */
198#define WIN_RECAL 0x10
199#define WIN_RESTORE WIN_RECAL
200/*
201 * 0x10->0x1F Reserved
202 */
203#define WIN_READ 0x20 /* 28-Bit */
204#define WIN_READ_ONCE 0x21 /* 28-Bit without retries */
205#define WIN_READ_LONG 0x22 /* 28-Bit */
206#define WIN_READ_LONG_ONCE 0x23 /* 28-Bit without retries */
207#define WIN_READ_EXT 0x24 /* 48-Bit */
208#define WIN_READDMA_EXT 0x25 /* 48-Bit */
209#define WIN_READDMA_QUEUED_EXT 0x26 /* 48-Bit */
210#define WIN_READ_NATIVE_MAX_EXT 0x27 /* 48-Bit */
211/*
212 * 0x28
213 */
214#define WIN_MULTREAD_EXT 0x29 /* 48-Bit */
215/*
216 * 0x2A->0x2F Reserved
217 */
218#define WIN_WRITE 0x30 /* 28-Bit */
219#define WIN_WRITE_ONCE 0x31 /* 28-Bit without retries */
220#define WIN_WRITE_LONG 0x32 /* 28-Bit */
221#define WIN_WRITE_LONG_ONCE 0x33 /* 28-Bit without retries */
222#define WIN_WRITE_EXT 0x34 /* 48-Bit */
223#define WIN_WRITEDMA_EXT 0x35 /* 48-Bit */
224#define WIN_WRITEDMA_QUEUED_EXT 0x36 /* 48-Bit */
225#define WIN_SET_MAX_EXT 0x37 /* 48-Bit */
226#define CFA_WRITE_SECT_WO_ERASE 0x38 /* CFA Write Sectors without erase */
227#define WIN_MULTWRITE_EXT 0x39 /* 48-Bit */
228/*
229 * 0x3A->0x3B Reserved
230 */
231#define WIN_WRITE_VERIFY 0x3C /* 28-Bit */
232/*
233 * 0x3D->0x3F Reserved
234 */
235#define WIN_VERIFY 0x40 /* 28-Bit - Read Verify Sectors */
236#define WIN_VERIFY_ONCE 0x41 /* 28-Bit - without retries */
237#define WIN_VERIFY_EXT 0x42 /* 48-Bit */
238/*
239 * 0x43->0x4F Reserved
240 */
241#define WIN_FORMAT 0x50
242/*
243 * 0x51->0x5F Reserved
244 */
245#define WIN_INIT 0x60
246/*
247 * 0x61->0x5F Reserved
248 */
249#define WIN_SEEK 0x70 /* 0x70-0x7F Reserved */
250
251#define CFA_TRANSLATE_SECTOR 0x87 /* CFA Translate Sector */
252#define WIN_DIAGNOSE 0x90
253#define WIN_SPECIFY 0x91 /* set drive geometry translation */
254#define WIN_DOWNLOAD_MICROCODE 0x92
255#define WIN_STANDBYNOW2 0x94
256#define WIN_STANDBY2 0x96
257#define WIN_SETIDLE2 0x97
258#define WIN_CHECKPOWERMODE2 0x98
259#define WIN_SLEEPNOW2 0x99
260/*
261 * 0x9A VENDOR
262 */
263#define WIN_PACKETCMD 0xA0 /* Send a packet command. */
264#define WIN_PIDENTIFY 0xA1 /* identify ATAPI device */
265#define WIN_QUEUED_SERVICE 0xA2
266#define WIN_SMART 0xB0 /* self-monitoring and reporting */
267#define CFA_ERASE_SECTORS 0xC0
268#define WIN_MULTREAD 0xC4 /* read sectors using multiple mode*/
269#define WIN_MULTWRITE 0xC5 /* write sectors using multiple mode */
270#define WIN_SETMULT 0xC6 /* enable/disable multiple mode */
271#define WIN_READDMA_QUEUED 0xC7 /* read sectors using Queued DMA transfers */
272#define WIN_READDMA 0xC8 /* read sectors using DMA transfers */
273#define WIN_READDMA_ONCE 0xC9 /* 28-Bit - without retries */
274#define WIN_WRITEDMA 0xCA /* write sectors using DMA transfers */
275#define WIN_WRITEDMA_ONCE 0xCB /* 28-Bit - without retries */
276#define WIN_WRITEDMA_QUEUED 0xCC /* write sectors using Queued DMA transfers */
277#define CFA_WRITE_MULTI_WO_ERASE 0xCD /* CFA Write multiple without erase */
278#define WIN_GETMEDIASTATUS 0xDA
279#define WIN_ACKMEDIACHANGE 0xDB /* ATA-1, ATA-2 vendor */
280#define WIN_POSTBOOT 0xDC
281#define WIN_PREBOOT 0xDD
282#define WIN_DOORLOCK 0xDE /* lock door on removable drives */
283#define WIN_DOORUNLOCK 0xDF /* unlock door on removable drives */
284#define WIN_STANDBYNOW1 0xE0
285#define WIN_IDLEIMMEDIATE 0xE1 /* force drive to become "ready" */
286#define WIN_STANDBY 0xE2 /* Set device in Standby Mode */
287#define WIN_SETIDLE1 0xE3
288#define WIN_READ_BUFFER 0xE4 /* force read only 1 sector */
289#define WIN_CHECKPOWERMODE1 0xE5
290#define WIN_SLEEPNOW1 0xE6
291#define WIN_FLUSH_CACHE 0xE7
292#define WIN_WRITE_BUFFER 0xE8 /* force write only 1 sector */
293#define WIN_WRITE_SAME 0xE9 /* read ata-2 to use */
294 /* SET_FEATURES 0x22 or 0xDD */
295#define WIN_FLUSH_CACHE_EXT 0xEA /* 48-Bit */
296#define WIN_IDENTIFY 0xEC /* ask drive to identify itself */
297#define WIN_MEDIAEJECT 0xED
298#define WIN_IDENTIFY_DMA 0xEE /* same as WIN_IDENTIFY, but DMA */
299#define WIN_SETFEATURES 0xEF /* set special drive features */
300#define EXABYTE_ENABLE_NEST 0xF0
301#define WIN_SECURITY_SET_PASS 0xF1
302#define WIN_SECURITY_UNLOCK 0xF2
303#define WIN_SECURITY_ERASE_PREPARE 0xF3
304#define WIN_SECURITY_ERASE_UNIT 0xF4
305#define WIN_SECURITY_FREEZE_LOCK 0xF5
306#define WIN_SECURITY_DISABLE 0xF6
307#define WIN_READ_NATIVE_MAX 0xF8 /* return the native maximum address */
308#define WIN_SET_MAX 0xF9
309#define DISABLE_SEAGATE 0xFB
310
311/* WIN_SMART sub-commands */
312
313#define SMART_READ_VALUES 0xD0
314#define SMART_READ_THRESHOLDS 0xD1
315#define SMART_AUTOSAVE 0xD2
316#define SMART_SAVE 0xD3
317#define SMART_IMMEDIATE_OFFLINE 0xD4
318#define SMART_READ_LOG_SECTOR 0xD5
319#define SMART_WRITE_LOG_SECTOR 0xD6
320#define SMART_WRITE_THRESHOLDS 0xD7
321#define SMART_ENABLE 0xD8
322#define SMART_DISABLE 0xD9
323#define SMART_STATUS 0xDA
324#define SMART_AUTO_OFFLINE 0xDB
325
326/* Password used in TF4 & TF5 executing SMART commands */
327
328#define SMART_LCYL_PASS 0x4F
329#define SMART_HCYL_PASS 0xC2
330
331/* WIN_SETFEATURES sub-commands */
332#define SETFEATURES_EN_8BIT 0x01 /* Enable 8-Bit Transfers */
333#define SETFEATURES_EN_WCACHE 0x02 /* Enable write cache */
334#define SETFEATURES_DIS_DEFECT 0x04 /* Disable Defect Management */
335#define SETFEATURES_EN_APM 0x05 /* Enable advanced power management */
336#define SETFEATURES_EN_SAME_R 0x22 /* for a region ATA-1 */
337#define SETFEATURES_DIS_MSN 0x31 /* Disable Media Status Notification */
338#define SETFEATURES_DIS_RETRY 0x33 /* Disable Retry */
339#define SETFEATURES_EN_AAM 0x42 /* Enable Automatic Acoustic Management */
340#define SETFEATURES_RW_LONG 0x44 /* Set Length of VS bytes */
341#define SETFEATURES_SET_CACHE 0x54 /* Set Cache segments to SC Reg. Val */
342#define SETFEATURES_DIS_RLA 0x55 /* Disable read look-ahead feature */
343#define SETFEATURES_EN_RI 0x5D /* Enable release interrupt */
344#define SETFEATURES_EN_SI 0x5E /* Enable SERVICE interrupt */
345#define SETFEATURES_DIS_RPOD 0x66 /* Disable reverting to power on defaults */
346#define SETFEATURES_DIS_ECC 0x77 /* Disable ECC byte count */
347#define SETFEATURES_DIS_8BIT 0x81 /* Disable 8-Bit Transfers */
348#define SETFEATURES_DIS_WCACHE 0x82 /* Disable write cache */
349#define SETFEATURES_EN_DEFECT 0x84 /* Enable Defect Management */
350#define SETFEATURES_DIS_APM 0x85 /* Disable advanced power management */
351#define SETFEATURES_EN_ECC 0x88 /* Enable ECC byte count */
352#define SETFEATURES_EN_MSN 0x95 /* Enable Media Status Notification */
353#define SETFEATURES_EN_RETRY 0x99 /* Enable Retry */
354#define SETFEATURES_EN_RLA 0xAA /* Enable read look-ahead feature */
355#define SETFEATURES_PREFETCH 0xAB /* Sets drive prefetch value */
356#define SETFEATURES_EN_REST 0xAC /* ATA-1 */
357#define SETFEATURES_4B_RW_LONG 0xBB /* Set Lenght of 4 bytes */
358#define SETFEATURES_DIS_AAM 0xC2 /* Disable Automatic Acoustic Management */
359#define SETFEATURES_EN_RPOD 0xCC /* Enable reverting to power on defaults */
360#define SETFEATURES_DIS_RI 0xDD /* Disable release interrupt ATAPI */
361#define SETFEATURES_EN_SAME_M 0xDD /* for a entire device ATA-1 */
362#define SETFEATURES_DIS_SI 0xDE /* Disable SERVICE interrupt ATAPI */
363
364/* WIN_SECURITY sub-commands */
365
366#define SECURITY_SET_PASSWORD 0xBA
367#define SECURITY_UNLOCK 0xBB
368#define SECURITY_ERASE_PREPARE 0xBC
369#define SECURITY_ERASE_UNIT 0xBD
370#define SECURITY_FREEZE_LOCK 0xBE
371#define SECURITY_DISABLE_PASSWORD 0xBF
372
373struct hd_geometry {
374 unsigned char heads;
375 unsigned char sectors;
376 unsigned short cylinders;
377 unsigned long start;
378};
379
380/* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x030n/0x031n */
381#define HDIO_GETGEO 0x0301 /* get device geometry */
382#define HDIO_GET_UNMASKINTR 0x0302 /* get current unmask setting */
383#define HDIO_GET_MULTCOUNT 0x0304 /* get current IDE blockmode setting */
384#define HDIO_GET_QDMA 0x0305 /* get use-qdma flag */
385
386#define HDIO_SET_XFER 0x0306 /* set transfer rate via proc */
387
388#define HDIO_OBSOLETE_IDENTITY 0x0307 /* OBSOLETE, DO NOT USE: returns 142 bytes */
389#define HDIO_GET_KEEPSETTINGS 0x0308 /* get keep-settings-on-reset flag */
390#define HDIO_GET_32BIT 0x0309 /* get current io_32bit setting */
391#define HDIO_GET_NOWERR 0x030a /* get ignore-write-error flag */
392#define HDIO_GET_DMA 0x030b /* get use-dma flag */
393#define HDIO_GET_NICE 0x030c /* get nice flags */
394#define HDIO_GET_IDENTITY 0x030d /* get IDE identification info */
395#define HDIO_GET_WCACHE 0x030e /* get write cache mode on|off */
396#define HDIO_GET_ACOUSTIC 0x030f /* get acoustic value */
397#define HDIO_GET_ADDRESS 0x0310 /* */
398
399#define HDIO_GET_BUSSTATE 0x031a /* get the bus state of the hwif */
400#define HDIO_TRISTATE_HWIF 0x031b /* execute a channel tristate */
401#define HDIO_DRIVE_RESET 0x031c /* execute a device reset */
402#define HDIO_DRIVE_TASKFILE 0x031d /* execute raw taskfile */
403#define HDIO_DRIVE_TASK 0x031e /* execute task and special drive command */
404#define HDIO_DRIVE_CMD 0x031f /* execute a special drive command */
405#define HDIO_DRIVE_CMD_AEB HDIO_DRIVE_TASK
406
407/* hd/ide ctl's that pass (arg) non-ptr values are numbered 0x032n/0x033n */
408#define HDIO_SET_MULTCOUNT 0x0321 /* change IDE blockmode */
409#define HDIO_SET_UNMASKINTR 0x0322 /* permit other irqs during I/O */
410#define HDIO_SET_KEEPSETTINGS 0x0323 /* keep ioctl settings on reset */
411#define HDIO_SET_32BIT 0x0324 /* change io_32bit flags */
412#define HDIO_SET_NOWERR 0x0325 /* change ignore-write-error flag */
413#define HDIO_SET_DMA 0x0326 /* change use-dma flag */
414#define HDIO_SET_PIO_MODE 0x0327 /* reconfig interface to new speed */
415#define HDIO_SCAN_HWIF 0x0328 /* register and (re)scan interface */
416#define HDIO_SET_NICE 0x0329 /* set nice flags */
417#define HDIO_UNREGISTER_HWIF 0x032a /* unregister interface */
418#define HDIO_SET_WCACHE 0x032b /* change write cache enable-disable */
419#define HDIO_SET_ACOUSTIC 0x032c /* change acoustic behavior */
420#define HDIO_SET_BUSSTATE 0x032d /* set the bus state of the hwif */
421#define HDIO_SET_QDMA 0x032e /* change use-qdma flag */
422#define HDIO_SET_ADDRESS 0x032f /* change lba addressing modes */
423
424/* bus states */
425enum {
426 BUSSTATE_OFF = 0,
427 BUSSTATE_ON,
428 BUSSTATE_TRISTATE
429};
430
431/* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x033n/0x033n */
432/* 0x330 is reserved - used to be HDIO_GETGEO_BIG */
433/* 0x331 is reserved - used to be HDIO_GETGEO_BIG_RAW */
434/* 0x338 is reserved - used to be HDIO_SET_IDE_SCSI */
435/* 0x339 is reserved - used to be HDIO_SET_SCSI_IDE */
436
437#define __NEW_HD_DRIVE_ID
438
439/*
440 * Structure returned by HDIO_GET_IDENTITY, as per ANSI NCITS ATA6 rev.1b spec.
441 *
442 * If you change something here, please remember to update fix_driveid() in
443 * ide/probe.c.
444 */
445struct hd_driveid {
446 unsigned short config; /* lots of obsolete bit flags */
447 unsigned short cyls; /* Obsolete, "physical" cyls */
448 unsigned short reserved2; /* reserved (word 2) */
449 unsigned short heads; /* Obsolete, "physical" heads */
450 unsigned short track_bytes; /* unformatted bytes per track */
451 unsigned short sector_bytes; /* unformatted bytes per sector */
452 unsigned short sectors; /* Obsolete, "physical" sectors per track */
453 unsigned short vendor0; /* vendor unique */
454 unsigned short vendor1; /* vendor unique */
455 unsigned short vendor2; /* Retired vendor unique */
456 unsigned char serial_no[20]; /* 0 = not_specified */
457 unsigned short buf_type; /* Retired */
458 unsigned short buf_size; /* Retired, 512 byte increments
459 * 0 = not_specified
460 */
461 unsigned short ecc_bytes; /* for r/w long cmds; 0 = not_specified */
462 unsigned char fw_rev[8]; /* 0 = not_specified */
463 unsigned char model[40]; /* 0 = not_specified */
464 unsigned char max_multsect; /* 0=not_implemented */
465 unsigned char vendor3; /* vendor unique */
466 unsigned short dword_io; /* 0=not_implemented; 1=implemented */
467 unsigned char vendor4; /* vendor unique */
468 unsigned char capability; /* (upper byte of word 49)
469 * 3: IORDYsup
470 * 2: IORDYsw
471 * 1: LBA
472 * 0: DMA
473 */
474 unsigned short reserved50; /* reserved (word 50) */
475 unsigned char vendor5; /* Obsolete, vendor unique */
476 unsigned char tPIO; /* Obsolete, 0=slow, 1=medium, 2=fast */
477 unsigned char vendor6; /* Obsolete, vendor unique */
478 unsigned char tDMA; /* Obsolete, 0=slow, 1=medium, 2=fast */
479 unsigned short field_valid; /* (word 53)
480 * 2: ultra_ok word 88
481 * 1: eide_ok words 64-70
482 * 0: cur_ok words 54-58
483 */
484 unsigned short cur_cyls; /* Obsolete, logical cylinders */
485 unsigned short cur_heads; /* Obsolete, l heads */
486 unsigned short cur_sectors; /* Obsolete, l sectors per track */
487 unsigned short cur_capacity0; /* Obsolete, l total sectors on drive */
488 unsigned short cur_capacity1; /* Obsolete, (2 words, misaligned int) */
489 unsigned char multsect; /* current multiple sector count */
490 unsigned char multsect_valid; /* when (bit0==1) multsect is ok */
491 unsigned int lba_capacity; /* Obsolete, total number of sectors */
492 unsigned short dma_1word; /* Obsolete, single-word dma info */
493 unsigned short dma_mword; /* multiple-word dma info */
494 unsigned short eide_pio_modes; /* bits 0:mode3 1:mode4 */
495 unsigned short eide_dma_min; /* min mword dma cycle time (ns) */
496 unsigned short eide_dma_time; /* recommended mword dma cycle time (ns) */
497 unsigned short eide_pio; /* min cycle time (ns), no IORDY */
498 unsigned short eide_pio_iordy; /* min cycle time (ns), with IORDY */
499 unsigned short words69_70[2]; /* reserved words 69-70
500 * future command overlap and queuing
501 */
502 /* HDIO_GET_IDENTITY currently returns only words 0 through 70 */
503 unsigned short words71_74[4]; /* reserved words 71-74
504 * for IDENTIFY PACKET DEVICE command
505 */
506 unsigned short queue_depth; /* (word 75)
507 * 15:5 reserved
508 * 4:0 Maximum queue depth -1
509 */
510 unsigned short words76_79[4]; /* reserved words 76-79 */
511 unsigned short major_rev_num; /* (word 80) */
512 unsigned short minor_rev_num; /* (word 81) */
513 unsigned short command_set_1; /* (word 82) supported
514 * 15: Obsolete
515 * 14: NOP command
516 * 13: READ_BUFFER
517 * 12: WRITE_BUFFER
518 * 11: Obsolete
519 * 10: Host Protected Area
520 * 9: DEVICE Reset
521 * 8: SERVICE Interrupt
522 * 7: Release Interrupt
523 * 6: look-ahead
524 * 5: write cache
525 * 4: PACKET Command
526 * 3: Power Management Feature Set
527 * 2: Removable Feature Set
528 * 1: Security Feature Set
529 * 0: SMART Feature Set
530 */
531 unsigned short command_set_2; /* (word 83)
532 * 15: Shall be ZERO
533 * 14: Shall be ONE
534 * 13: FLUSH CACHE EXT
535 * 12: FLUSH CACHE
536 * 11: Device Configuration Overlay
537 * 10: 48-bit Address Feature Set
538 * 9: Automatic Acoustic Management
539 * 8: SET MAX security
540 * 7: reserved 1407DT PARTIES
541 * 6: SetF sub-command Power-Up
542 * 5: Power-Up in Standby Feature Set
543 * 4: Removable Media Notification
544 * 3: APM Feature Set
545 * 2: CFA Feature Set
546 * 1: READ/WRITE DMA QUEUED
547 * 0: Download MicroCode
548 */
549 unsigned short cfsse; /* (word 84)
550 * cmd set-feature supported extensions
551 * 15: Shall be ZERO
552 * 14: Shall be ONE
553 * 13:6 reserved
554 * 5: General Purpose Logging
555 * 4: Streaming Feature Set
556 * 3: Media Card Pass Through
557 * 2: Media Serial Number Valid
558 * 1: SMART selt-test supported
559 * 0: SMART error logging
560 */
561 unsigned short cfs_enable_1; /* (word 85)
562 * command set-feature enabled
563 * 15: Obsolete
564 * 14: NOP command
565 * 13: READ_BUFFER
566 * 12: WRITE_BUFFER
567 * 11: Obsolete
568 * 10: Host Protected Area
569 * 9: DEVICE Reset
570 * 8: SERVICE Interrupt
571 * 7: Release Interrupt
572 * 6: look-ahead
573 * 5: write cache
574 * 4: PACKET Command
575 * 3: Power Management Feature Set
576 * 2: Removable Feature Set
577 * 1: Security Feature Set
578 * 0: SMART Feature Set
579 */
580 unsigned short cfs_enable_2; /* (word 86)
581 * command set-feature enabled
582 * 15: Shall be ZERO
583 * 14: Shall be ONE
584 * 13: FLUSH CACHE EXT
585 * 12: FLUSH CACHE
586 * 11: Device Configuration Overlay
587 * 10: 48-bit Address Feature Set
588 * 9: Automatic Acoustic Management
589 * 8: SET MAX security
590 * 7: reserved 1407DT PARTIES
591 * 6: SetF sub-command Power-Up
592 * 5: Power-Up in Standby Feature Set
593 * 4: Removable Media Notification
594 * 3: APM Feature Set
595 * 2: CFA Feature Set
596 * 1: READ/WRITE DMA QUEUED
597 * 0: Download MicroCode
598 */
599 unsigned short csf_default; /* (word 87)
600 * command set-feature default
601 * 15: Shall be ZERO
602 * 14: Shall be ONE
603 * 13:6 reserved
604 * 5: General Purpose Logging enabled
605 * 4: Valid CONFIGURE STREAM executed
606 * 3: Media Card Pass Through enabled
607 * 2: Media Serial Number Valid
608 * 1: SMART selt-test supported
609 * 0: SMART error logging
610 */
611 unsigned short dma_ultra; /* (word 88) */
612 unsigned short trseuc; /* time required for security erase */
613 unsigned short trsEuc; /* time required for enhanced erase */
614 unsigned short CurAPMvalues; /* current APM values */
615 unsigned short mprc; /* master password revision code */
616 unsigned short hw_config; /* hardware config (word 93)
617 * 15: Shall be ZERO
618 * 14: Shall be ONE
619 * 13:
620 * 12:
621 * 11:
622 * 10:
623 * 9:
624 * 8:
625 * 7:
626 * 6:
627 * 5:
628 * 4:
629 * 3:
630 * 2:
631 * 1:
632 * 0: Shall be ONE
633 */
634 unsigned short acoustic; /* (word 94)
635 * 15:8 Vendor's recommended value
636 * 7:0 current value
637 */
638 unsigned short msrqs; /* min stream request size */
639 unsigned short sxfert; /* stream transfer time */
640 unsigned short sal; /* stream access latency */
641 unsigned int spg; /* stream performance granularity */
642 unsigned long long lba_capacity_2;/* 48-bit total number of sectors */
643 unsigned short words104_125[22];/* reserved words 104-125 */
644 unsigned short last_lun; /* (word 126) */
645 unsigned short word127; /* (word 127) Feature Set
646 * Removable Media Notification
647 * 15:2 reserved
648 * 1:0 00 = not supported
649 * 01 = supported
650 * 10 = reserved
651 * 11 = reserved
652 */
653 unsigned short dlf; /* (word 128)
654 * device lock function
655 * 15:9 reserved
656 * 8 security level 1:max 0:high
657 * 7:6 reserved
658 * 5 enhanced erase
659 * 4 expire
660 * 3 frozen
661 * 2 locked
662 * 1 en/disabled
663 * 0 capability
664 */
665 unsigned short csfo; /* (word 129)
666 * current set features options
667 * 15:4 reserved
668 * 3: auto reassign
669 * 2: reverting
670 * 1: read-look-ahead
671 * 0: write cache
672 */
673 unsigned short words130_155[26];/* reserved vendor words 130-155 */
674 unsigned short word156; /* reserved vendor word 156 */
675 unsigned short words157_159[3];/* reserved vendor words 157-159 */
676 unsigned short cfa_power; /* (word 160) CFA Power Mode
677 * 15 word 160 supported
678 * 14 reserved
679 * 13
680 * 12
681 * 11:0
682 */
683 unsigned short words161_175[15];/* Reserved for CFA */
684 unsigned short words176_205[30];/* Current Media Serial Number */
685 unsigned short words206_254[49];/* reserved words 206-254 */
686 unsigned short integrity_word; /* (word 255)
687 * 15:8 Checksum
688 * 7:0 Signature
689 */
690};
691
692/*
693 * IDE "nice" flags. These are used on a per drive basis to determine
694 * when to be nice and give more bandwidth to the other devices which
695 * share the same IDE bus.
696 */
697#define IDE_NICE_DSC_OVERLAP (0) /* per the DSC overlap protocol */
698#define IDE_NICE_ATAPI_OVERLAP (1) /* not supported yet */
699#define IDE_NICE_0 (2) /* when sure that it won't affect us */
700#define IDE_NICE_1 (3) /* when probably won't affect us much */
701#define IDE_NICE_2 (4) /* when we know it's on our expense */
702
703#endif /* _LINUX_HDREG_H */
diff --git a/include/linux/hdsmart.h b/include/linux/hdsmart.h
new file mode 100644
index 000000000000..7974a47fe582
--- /dev/null
+++ b/include/linux/hdsmart.h
@@ -0,0 +1,124 @@
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#define OFFLINE_FULL_SCAN 0
21#define SHORT_SELF_TEST 1
22#define EXTEND_SELF_TEST 2
23#define SHORT_CAPTIVE_SELF_TEST 129
24#define EXTEND_CAPTIVE_SELF_TEST 130
25
26/* smart_attribute is the vendor specific in SFF-8035 spec */
27typedef struct ata_smart_attribute_s {
28 unsigned char id;
29 unsigned short status_flag;
30 unsigned char normalized;
31 unsigned char worse_normal;
32 unsigned char raw[6];
33 unsigned char reserv;
34} __attribute__ ((packed)) ata_smart_attribute_t;
35
36/* smart_values is format of the read drive Atrribute command */
37typedef struct ata_smart_values_s {
38 unsigned short revnumber;
39 ata_smart_attribute_t vendor_attributes [30];
40 unsigned char offline_data_collection_status;
41 unsigned char self_test_exec_status;
42 unsigned short total_time_to_complete_off_line;
43 unsigned char vendor_specific_366;
44 unsigned char offline_data_collection_capability;
45 unsigned short smart_capability;
46 unsigned char errorlog_capability;
47 unsigned char vendor_specific_371;
48 unsigned char short_test_completion_time;
49 unsigned char extend_test_completion_time;
50 unsigned char reserved_374_385 [12];
51 unsigned char vendor_specific_386_509 [125];
52 unsigned char chksum;
53} __attribute__ ((packed)) ata_smart_values_t;
54
55/* Smart Threshold data structures */
56/* Vendor attribute of SMART Threshold */
57typedef struct ata_smart_threshold_entry_s {
58 unsigned char id;
59 unsigned char normalized_threshold;
60 unsigned char reserved[10];
61} __attribute__ ((packed)) ata_smart_threshold_entry_t;
62
63/* Format of Read SMART THreshold Command */
64typedef struct ata_smart_thresholds_s {
65 unsigned short revnumber;
66 ata_smart_threshold_entry_t thres_entries[30];
67 unsigned char reserved[149];
68 unsigned char chksum;
69} __attribute__ ((packed)) ata_smart_thresholds_t;
70
71typedef struct ata_smart_errorlog_command_struct_s {
72 unsigned char devicecontrolreg;
73 unsigned char featuresreg;
74 unsigned char sector_count;
75 unsigned char sector_number;
76 unsigned char cylinder_low;
77 unsigned char cylinder_high;
78 unsigned char drive_head;
79 unsigned char commandreg;
80 unsigned int timestamp;
81} __attribute__ ((packed)) ata_smart_errorlog_command_struct_t;
82
83typedef struct ata_smart_errorlog_error_struct_s {
84 unsigned char error_condition;
85 unsigned char extended_error[14];
86 unsigned char state;
87 unsigned short timestamp;
88} __attribute__ ((packed)) ata_smart_errorlog_error_struct_t;
89
90typedef struct ata_smart_errorlog_struct_s {
91 ata_smart_errorlog_command_struct_t commands[6];
92 ata_smart_errorlog_error_struct_t error_struct;
93} __attribute__ ((packed)) ata_smart_errorlog_struct_t;
94
95typedef struct ata_smart_errorlog_s {
96 unsigned char revnumber;
97 unsigned char error_log_pointer;
98 ata_smart_errorlog_struct_t errorlog_struct[5];
99 unsigned short ata_error_count;
100 unsigned short non_fatal_count;
101 unsigned short drive_timeout_count;
102 unsigned char reserved[53];
103 unsigned char chksum;
104} __attribute__ ((packed)) ata_smart_errorlog_t;
105
106typedef struct ata_smart_selftestlog_struct_s {
107 unsigned char selftestnumber;
108 unsigned char selfteststatus;
109 unsigned short timestamp;
110 unsigned char selftestfailurecheckpoint;
111 unsigned int lbafirstfailure;
112 unsigned char vendorspecific[15];
113} __attribute__ ((packed)) ata_smart_selftestlog_struct_t;
114
115typedef struct ata_smart_selftestlog_s {
116 unsigned short revnumber;
117 ata_smart_selftestlog_struct_t selftest_struct[21];
118 unsigned char vendorspecific[2];
119 unsigned char mostrecenttest;
120 unsigned char resevered[2];
121 unsigned char chksum;
122} __attribute__ ((packed)) ata_smart_selftestlog_t;
123
124#endif /* _LINUX_HDSMART_H */
diff --git a/include/linux/hiddev.h b/include/linux/hiddev.h
new file mode 100644
index 000000000000..945ba1ad14ac
--- /dev/null
+++ b/include/linux/hiddev.h
@@ -0,0 +1,240 @@
1#ifndef _HIDDEV_H
2#define _HIDDEV_H
3
4/*
5 * $Id: hiddev.h,v 1.2 2001/04/26 11:26:09 vojtech Exp $
6 *
7 * Copyright (c) 1999-2000 Vojtech Pavlik
8 *
9 * Sponsored by SuSE
10 */
11
12/*
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 *
27 * Should you need to contact me, the author, you can do so either by
28 * e-mail - mail your message to <vojtech@suse.cz>, or by paper mail:
29 * Vojtech Pavlik, Ucitelska 1576, Prague 8, 182 00 Czech Republic
30 */
31
32/*
33 * The event structure itself
34 */
35
36struct hiddev_event {
37 unsigned hid;
38 signed int value;
39};
40
41struct hiddev_devinfo {
42 __u32 bustype;
43 __u32 busnum;
44 __u32 devnum;
45 __u32 ifnum;
46 __s16 vendor;
47 __s16 product;
48 __s16 version;
49 __u32 num_applications;
50};
51
52struct hiddev_collection_info {
53 __u32 index;
54 __u32 type;
55 __u32 usage;
56 __u32 level;
57};
58
59#define HID_STRING_SIZE 256
60struct hiddev_string_descriptor {
61 __s32 index;
62 char value[HID_STRING_SIZE];
63};
64
65struct hiddev_report_info {
66 __u32 report_type;
67 __u32 report_id;
68 __u32 num_fields;
69};
70
71/* To do a GUSAGE/SUSAGE, fill in at least usage_code, report_type and
72 * report_id. Set report_id to REPORT_ID_UNKNOWN if the rest of the fields
73 * are unknown. Otherwise use a usage_ref struct filled in from a previous
74 * successful GUSAGE call to save time. To actually send a value to the
75 * device, perform a SUSAGE first, followed by a SREPORT. An INITREPORT or a
76 * GREPORT isn't necessary for a GUSAGE to return valid data.
77 */
78#define HID_REPORT_ID_UNKNOWN 0xffffffff
79#define HID_REPORT_ID_FIRST 0x00000100
80#define HID_REPORT_ID_NEXT 0x00000200
81#define HID_REPORT_ID_MASK 0x000000ff
82#define HID_REPORT_ID_MAX 0x000000ff
83
84#define HID_REPORT_TYPE_INPUT 1
85#define HID_REPORT_TYPE_OUTPUT 2
86#define HID_REPORT_TYPE_FEATURE 3
87#define HID_REPORT_TYPE_MIN 1
88#define HID_REPORT_TYPE_MAX 3
89
90struct hiddev_field_info {
91 __u32 report_type;
92 __u32 report_id;
93 __u32 field_index;
94 __u32 maxusage;
95 __u32 flags;
96 __u32 physical; /* physical usage for this field */
97 __u32 logical; /* logical usage for this field */
98 __u32 application; /* application usage for this field */
99 __s32 logical_minimum;
100 __s32 logical_maximum;
101 __s32 physical_minimum;
102 __s32 physical_maximum;
103 __u32 unit_exponent;
104 __u32 unit;
105};
106
107/* Fill in report_type, report_id and field_index to get the information on a
108 * field.
109 */
110#define HID_FIELD_CONSTANT 0x001
111#define HID_FIELD_VARIABLE 0x002
112#define HID_FIELD_RELATIVE 0x004
113#define HID_FIELD_WRAP 0x008
114#define HID_FIELD_NONLINEAR 0x010
115#define HID_FIELD_NO_PREFERRED 0x020
116#define HID_FIELD_NULL_STATE 0x040
117#define HID_FIELD_VOLATILE 0x080
118#define HID_FIELD_BUFFERED_BYTE 0x100
119
120struct hiddev_usage_ref {
121 __u32 report_type;
122 __u32 report_id;
123 __u32 field_index;
124 __u32 usage_index;
125 __u32 usage_code;
126 __s32 value;
127};
128
129/* hiddev_usage_ref_multi is used for sending multiple bytes to a control.
130 * It really manifests itself as setting the value of consecutive usages */
131#define HID_MAX_MULTI_USAGES 1024
132struct hiddev_usage_ref_multi {
133 struct hiddev_usage_ref uref;
134 __u32 num_values;
135 __s32 values[HID_MAX_MULTI_USAGES];
136};
137
138/* FIELD_INDEX_NONE is returned in read() data from the kernel when flags
139 * is set to (HIDDEV_FLAG_UREF | HIDDEV_FLAG_REPORT) and a new report has
140 * been sent by the device
141 */
142#define HID_FIELD_INDEX_NONE 0xffffffff
143
144/*
145 * Protocol version.
146 */
147
148#define HID_VERSION 0x010004
149
150/*
151 * IOCTLs (0x00 - 0x7f)
152 */
153
154#define HIDIOCGVERSION _IOR('H', 0x01, int)
155#define HIDIOCAPPLICATION _IO('H', 0x02)
156#define HIDIOCGDEVINFO _IOR('H', 0x03, struct hiddev_devinfo)
157#define HIDIOCGSTRING _IOR('H', 0x04, struct hiddev_string_descriptor)
158#define HIDIOCINITREPORT _IO('H', 0x05)
159#define HIDIOCGNAME(len) _IOC(_IOC_READ, 'H', 0x06, len)
160#define HIDIOCGREPORT _IOW('H', 0x07, struct hiddev_report_info)
161#define HIDIOCSREPORT _IOW('H', 0x08, struct hiddev_report_info)
162#define HIDIOCGREPORTINFO _IOWR('H', 0x09, struct hiddev_report_info)
163#define HIDIOCGFIELDINFO _IOWR('H', 0x0A, struct hiddev_field_info)
164#define HIDIOCGUSAGE _IOWR('H', 0x0B, struct hiddev_usage_ref)
165#define HIDIOCSUSAGE _IOW('H', 0x0C, struct hiddev_usage_ref)
166#define HIDIOCGUCODE _IOWR('H', 0x0D, struct hiddev_usage_ref)
167#define HIDIOCGFLAG _IOR('H', 0x0E, int)
168#define HIDIOCSFLAG _IOW('H', 0x0F, int)
169#define HIDIOCGCOLLECTIONINDEX _IOW('H', 0x10, struct hiddev_usage_ref)
170#define HIDIOCGCOLLECTIONINFO _IOWR('H', 0x11, struct hiddev_collection_info)
171#define HIDIOCGPHYS(len) _IOC(_IOC_READ, 'H', 0x12, len)
172
173/* For writing/reading to multiple/consecutive usages */
174#define HIDIOCGUSAGES _IOWR('H', 0x13, struct hiddev_usage_ref_multi)
175#define HIDIOCSUSAGES _IOW('H', 0x14, struct hiddev_usage_ref_multi)
176
177/*
178 * Flags to be used in HIDIOCSFLAG
179 */
180#define HIDDEV_FLAG_UREF 0x1
181#define HIDDEV_FLAG_REPORT 0x2
182#define HIDDEV_FLAGS 0x3
183
184/* To traverse the input report descriptor info for a HID device, perform the
185 * following:
186 *
187 * rinfo.report_type = HID_REPORT_TYPE_INPUT;
188 * rinfo.report_id = HID_REPORT_ID_FIRST;
189 * ret = ioctl(fd, HIDIOCGREPORTINFO, &rinfo);
190 *
191 * while (ret >= 0) {
192 * for (i = 0; i < rinfo.num_fields; i++) {
193 * finfo.report_type = rinfo.report_type;
194 * finfo.report_id = rinfo.report_id;
195 * finfo.field_index = i;
196 * ioctl(fd, HIDIOCGFIELDINFO, &finfo);
197 * for (j = 0; j < finfo.maxusage; j++) {
198 * uref.field_index = i;
199 * uref.usage_index = j;
200 * ioctl(fd, HIDIOCGUCODE, &uref);
201 * ioctl(fd, HIDIOCGUSAGE, &uref);
202 * }
203 * }
204 * rinfo.report_id |= HID_REPORT_ID_NEXT;
205 * ret = ioctl(fd, HIDIOCGREPORTINFO, &rinfo);
206 * }
207 */
208
209
210#ifdef __KERNEL__
211
212/*
213 * In-kernel definitions.
214 */
215
216struct hid_device;
217struct hid_usage;
218struct hid_field;
219struct hid_report;
220
221#ifdef CONFIG_USB_HIDDEV
222int hiddev_connect(struct hid_device *);
223void hiddev_disconnect(struct hid_device *);
224void hiddev_hid_event(struct hid_device *hid, struct hid_field *field,
225 struct hid_usage *usage, __s32 value, struct pt_regs *regs);
226void hiddev_report_event(struct hid_device *hid, struct hid_report *report);
227int __init hiddev_init(void);
228void hiddev_exit(void);
229#else
230static inline int hiddev_connect(struct hid_device *hid) { return -1; }
231static inline void hiddev_disconnect(struct hid_device *hid) { }
232static inline void hiddev_hid_event(struct hid_device *hid, struct hid_field *field,
233 struct hid_usage *usage, __s32 value, struct pt_regs *regs) { }
234static inline void hiddev_report_event(struct hid_device *hid, struct hid_report *report) { }
235static inline int hiddev_init(void) { return 0; }
236static inline void hiddev_exit(void) { }
237#endif
238
239#endif
240#endif
diff --git a/include/linux/highmem.h b/include/linux/highmem.h
new file mode 100644
index 000000000000..2a7e6c65c882
--- /dev/null
+++ b/include/linux/highmem.h
@@ -0,0 +1,104 @@
1#ifndef _LINUX_HIGHMEM_H
2#define _LINUX_HIGHMEM_H
3
4#include <linux/config.h>
5#include <linux/fs.h>
6#include <linux/mm.h>
7
8#include <asm/cacheflush.h>
9
10#ifdef CONFIG_HIGHMEM
11
12#include <asm/highmem.h>
13
14/* declarations for linux/mm/highmem.c */
15unsigned int nr_free_highpages(void);
16
17#else /* CONFIG_HIGHMEM */
18
19static inline unsigned int nr_free_highpages(void) { return 0; }
20
21static inline void *kmap(struct page *page)
22{
23 might_sleep();
24 return page_address(page);
25}
26
27#define kunmap(page) do { (void) (page); } while (0)
28
29#define kmap_atomic(page, idx) page_address(page)
30#define kunmap_atomic(addr, idx) do { } while (0)
31#define kmap_atomic_to_page(ptr) virt_to_page(ptr)
32
33#endif /* CONFIG_HIGHMEM */
34
35/* when CONFIG_HIGHMEM is not set these will be plain clear/copy_page */
36static inline void clear_user_highpage(struct page *page, unsigned long vaddr)
37{
38 void *addr = kmap_atomic(page, KM_USER0);
39 clear_user_page(addr, vaddr, page);
40 kunmap_atomic(addr, KM_USER0);
41 /* Make sure this page is cleared on other CPU's too before using it */
42 smp_wmb();
43}
44
45#ifndef __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
46static inline struct page *
47alloc_zeroed_user_highpage(struct vm_area_struct *vma, unsigned long vaddr)
48{
49 struct page *page = alloc_page_vma(GFP_HIGHUSER, vma, vaddr);
50
51 if (page)
52 clear_user_highpage(page, vaddr);
53
54 return page;
55}
56#endif
57
58static inline void clear_highpage(struct page *page)
59{
60 void *kaddr = kmap_atomic(page, KM_USER0);
61 clear_page(kaddr);
62 kunmap_atomic(kaddr, KM_USER0);
63}
64
65/*
66 * Same but also flushes aliased cache contents to RAM.
67 */
68static inline void memclear_highpage_flush(struct page *page, unsigned int offset, unsigned int size)
69{
70 void *kaddr;
71
72 BUG_ON(offset + size > PAGE_SIZE);
73
74 kaddr = kmap_atomic(page, KM_USER0);
75 memset((char *)kaddr + offset, 0, size);
76 flush_dcache_page(page);
77 kunmap_atomic(kaddr, KM_USER0);
78}
79
80static inline void copy_user_highpage(struct page *to, struct page *from, unsigned long vaddr)
81{
82 char *vfrom, *vto;
83
84 vfrom = kmap_atomic(from, KM_USER0);
85 vto = kmap_atomic(to, KM_USER1);
86 copy_user_page(vto, vfrom, vaddr, to);
87 kunmap_atomic(vfrom, KM_USER0);
88 kunmap_atomic(vto, KM_USER1);
89 /* Make sure this page is cleared on other CPU's too before using it */
90 smp_wmb();
91}
92
93static inline void copy_highpage(struct page *to, struct page *from)
94{
95 char *vfrom, *vto;
96
97 vfrom = kmap_atomic(from, KM_USER0);
98 vto = kmap_atomic(to, KM_USER1);
99 copy_page(vto, vfrom);
100 kunmap_atomic(vfrom, KM_USER0);
101 kunmap_atomic(vto, KM_USER1);
102}
103
104#endif /* _LINUX_HIGHMEM_H */
diff --git a/include/linux/highuid.h b/include/linux/highuid.h
new file mode 100644
index 000000000000..53ecac3905e8
--- /dev/null
+++ b/include/linux/highuid.h
@@ -0,0 +1,98 @@
1#ifndef _LINUX_HIGHUID_H
2#define _LINUX_HIGHUID_H
3
4#include <linux/config.h>
5#include <linux/types.h>
6
7/*
8 * general notes:
9 *
10 * CONFIG_UID16 is defined if the given architecture needs to
11 * support backwards compatibility for old system calls.
12 *
13 * kernel code should use uid_t and gid_t at all times when dealing with
14 * kernel-private data.
15 *
16 * old_uid_t and old_gid_t should only be different if CONFIG_UID16 is
17 * defined, else the platform should provide dummy typedefs for them
18 * such that they are equivalent to __kernel_{u,g}id_t.
19 *
20 * uid16_t and gid16_t are used on all architectures. (when dealing
21 * with structures hard coded to 16 bits, such as in filesystems)
22 */
23
24
25/*
26 * This is the "overflow" UID and GID. They are used to signify uid/gid
27 * overflow to old programs when they request uid/gid information but are
28 * using the old 16 bit interfaces.
29 * When you run a libc5 program, it will think that all highuid files or
30 * processes are owned by this uid/gid.
31 * The idea is that it's better to do so than possibly return 0 in lieu of
32 * 65536, etc.
33 */
34
35extern int overflowuid;
36extern int overflowgid;
37
38extern void __bad_uid(void);
39extern void __bad_gid(void);
40
41#define DEFAULT_OVERFLOWUID 65534
42#define DEFAULT_OVERFLOWGID 65534
43
44#ifdef CONFIG_UID16
45
46/* prevent uid mod 65536 effect by returning a default value for high UIDs */
47#define high2lowuid(uid) ((uid) & ~0xFFFF ? (old_uid_t)overflowuid : (old_uid_t)(uid))
48#define high2lowgid(gid) ((gid) & ~0xFFFF ? (old_gid_t)overflowgid : (old_gid_t)(gid))
49/*
50 * -1 is different in 16 bits than it is in 32 bits
51 * these macros are used by chown(), setreuid(), ...,
52 */
53#define low2highuid(uid) ((uid) == (old_uid_t)-1 ? (uid_t)-1 : (uid_t)(uid))
54#define low2highgid(gid) ((gid) == (old_gid_t)-1 ? (gid_t)-1 : (gid_t)(gid))
55
56#define __convert_uid(size, uid) \
57 (size >= sizeof(uid) ? (uid) : high2lowuid(uid))
58#define __convert_gid(size, gid) \
59 (size >= sizeof(gid) ? (gid) : high2lowgid(gid))
60
61
62#else
63
64#define __convert_uid(size, uid) (uid)
65#define __convert_gid(size, gid) (gid)
66
67#endif /* !CONFIG_UID16 */
68
69/* uid/gid input should be always 32bit uid_t */
70#define SET_UID(var, uid) do { (var) = __convert_uid(sizeof(var), (uid)); } while (0)
71#define SET_GID(var, gid) do { (var) = __convert_gid(sizeof(var), (gid)); } while (0)
72
73/*
74 * Everything below this line is needed on all architectures, to deal with
75 * filesystems that only store 16 bits of the UID/GID, etc.
76 */
77
78/*
79 * This is the UID and GID that will get written to disk if a filesystem
80 * only supports 16-bit UIDs and the kernel has a high UID/GID to write
81 */
82extern int fs_overflowuid;
83extern int fs_overflowgid;
84
85#define DEFAULT_FS_OVERFLOWUID 65534
86#define DEFAULT_FS_OVERFLOWGID 65534
87
88/*
89 * Since these macros are used in architectures that only need limited
90 * 16-bit UID back compatibility, we won't use old_uid_t and old_gid_t
91 */
92#define fs_high2lowuid(uid) ((uid) & ~0xFFFF ? (uid16_t)fs_overflowuid : (uid16_t)(uid))
93#define fs_high2lowgid(gid) ((gid) & ~0xFFFF ? (gid16_t)fs_overflowgid : (gid16_t)(gid))
94
95#define low_16_bits(x) ((x) & 0xFFFF)
96#define high_16_bits(x) (((x) & 0xFFFF0000) >> 16)
97
98#endif /* _LINUX_HIGHUID_H */
diff --git a/include/linux/hippidevice.h b/include/linux/hippidevice.h
new file mode 100644
index 000000000000..89b3a4a5b761
--- /dev/null
+++ b/include/linux/hippidevice.h
@@ -0,0 +1,35 @@
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Definitions for the HIPPI handlers.
7 *
8 * Version: @(#)hippidevice.h 1.0.0 05/26/97
9 *
10 * Author: Jes Sorensen, <Jes.Sorensen@cern.ch>
11 *
12 * hippidevice.h is based on previous fddidevice.h work by
13 * Ross Biro, <bir7@leland.Stanford.Edu>
14 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
15 * Alan Cox, <gw4pts@gw4pts.ampr.org>
16 * Lawrence V. Stefani, <stefani@lkg.dec.com>
17 *
18 * This program is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU General Public License
20 * as published by the Free Software Foundation; either version
21 * 2 of the License, or (at your option) any later version.
22 */
23#ifndef _LINUX_HIPPIDEVICE_H
24#define _LINUX_HIPPIDEVICE_H
25
26#include <linux/if_hippi.h>
27
28#ifdef __KERNEL__
29extern unsigned short hippi_type_trans(struct sk_buff *skb,
30 struct net_device *dev);
31
32extern struct net_device *alloc_hippi_dev(int sizeof_priv);
33#endif
34
35#endif /* _LINUX_HIPPIDEVICE_H */
diff --git a/include/linux/hpet.h b/include/linux/hpet.h
new file mode 100644
index 000000000000..27238194b212
--- /dev/null
+++ b/include/linux/hpet.h
@@ -0,0 +1,136 @@
1#ifndef __HPET__
2#define __HPET__ 1
3
4#include <linux/compiler.h>
5
6/*
7 * Offsets into HPET Registers
8 */
9
10struct hpet {
11 u64 hpet_cap; /* capabilities */
12 u64 res0; /* reserved */
13 u64 hpet_config; /* configuration */
14 u64 res1; /* reserved */
15 u64 hpet_isr; /* interrupt status reg */
16 u64 res2[25]; /* reserved */
17 union { /* main counter */
18 u64 _hpet_mc64;
19 u32 _hpet_mc32;
20 unsigned long _hpet_mc;
21 } _u0;
22 u64 res3; /* reserved */
23 struct hpet_timer {
24 u64 hpet_config; /* configuration/cap */
25 union { /* timer compare register */
26 u64 _hpet_hc64;
27 u32 _hpet_hc32;
28 unsigned long _hpet_compare;
29 } _u1;
30 u64 hpet_fsb[2]; /* FSB route */
31 } hpet_timers[1];
32};
33
34#define hpet_mc _u0._hpet_mc
35#define hpet_compare _u1._hpet_compare
36
37#define HPET_MAX_TIMERS (32)
38
39/*
40 * HPET general capabilities register
41 */
42
43#define HPET_COUNTER_CLK_PERIOD_MASK (0xffffffff00000000ULL)
44#define HPET_COUNTER_CLK_PERIOD_SHIFT (32UL)
45#define HPET_VENDOR_ID_MASK (0x00000000ffff0000ULL)
46#define HPET_VENDOR_ID_SHIFT (16ULL)
47#define HPET_LEG_RT_CAP_MASK (0x8000)
48#define HPET_COUNTER_SIZE_MASK (0x2000)
49#define HPET_NUM_TIM_CAP_MASK (0x1f00)
50#define HPET_NUM_TIM_CAP_SHIFT (8ULL)
51
52/*
53 * HPET general configuration register
54 */
55
56#define HPET_LEG_RT_CNF_MASK (2UL)
57#define HPET_ENABLE_CNF_MASK (1UL)
58
59
60/*
61 * Timer configuration register
62 */
63
64#define Tn_INT_ROUTE_CAP_MASK (0xffffffff00000000ULL)
65#define Tn_INI_ROUTE_CAP_SHIFT (32UL)
66#define Tn_FSB_INT_DELCAP_MASK (0x8000UL)
67#define Tn_FSB_INT_DELCAP_SHIFT (15)
68#define Tn_FSB_EN_CNF_MASK (0x4000UL)
69#define Tn_FSB_EN_CNF_SHIFT (14)
70#define Tn_INT_ROUTE_CNF_MASK (0x3e00UL)
71#define Tn_INT_ROUTE_CNF_SHIFT (9)
72#define Tn_32MODE_CNF_MASK (0x0100UL)
73#define Tn_VAL_SET_CNF_MASK (0x0040UL)
74#define Tn_SIZE_CAP_MASK (0x0020UL)
75#define Tn_PER_INT_CAP_MASK (0x0010UL)
76#define Tn_TYPE_CNF_MASK (0x0008UL)
77#define Tn_INT_ENB_CNF_MASK (0x0004UL)
78#define Tn_INT_TYPE_CNF_MASK (0x0002UL)
79
80/*
81 * Timer FSB Interrupt Route Register
82 */
83
84#define Tn_FSB_INT_ADDR_MASK (0xffffffff00000000ULL)
85#define Tn_FSB_INT_ADDR_SHIFT (32UL)
86#define Tn_FSB_INT_VAL_MASK (0x00000000ffffffffULL)
87
88struct hpet_info {
89 unsigned long hi_ireqfreq; /* Hz */
90 unsigned long hi_flags; /* information */
91 unsigned short hi_hpet;
92 unsigned short hi_timer;
93};
94
95#define HPET_INFO_PERIODIC 0x0001 /* timer is periodic */
96
97#define HPET_IE_ON _IO('h', 0x01) /* interrupt on */
98#define HPET_IE_OFF _IO('h', 0x02) /* interrupt off */
99#define HPET_INFO _IOR('h', 0x03, struct hpet_info)
100#define HPET_EPI _IO('h', 0x04) /* enable periodic */
101#define HPET_DPI _IO('h', 0x05) /* disable periodic */
102#define HPET_IRQFREQ _IOW('h', 0x6, unsigned long) /* IRQFREQ usec */
103
104/*
105 * exported interfaces
106 */
107
108struct hpet_task {
109 void (*ht_func) (void *);
110 void *ht_data;
111 void *ht_opaque;
112};
113
114struct hpet_data {
115 unsigned long hd_phys_address;
116 void __iomem *hd_address;
117 unsigned short hd_nirqs;
118 unsigned short hd_flags;
119 unsigned int hd_state; /* timer allocated */
120 unsigned int hd_irq[HPET_MAX_TIMERS];
121};
122
123#define HPET_DATA_PLATFORM 0x0001 /* platform call to hpet_alloc */
124
125static inline void hpet_reserve_timer(struct hpet_data *hd, int timer)
126{
127 hd->hd_state |= (1 << timer);
128 return;
129}
130
131int hpet_alloc(struct hpet_data *);
132int hpet_register(struct hpet_task *, int);
133int hpet_unregister(struct hpet_task *);
134int hpet_control(struct hpet_task *, unsigned int, unsigned long);
135
136#endif /* !__HPET__ */
diff --git a/include/linux/hpfs_fs.h b/include/linux/hpfs_fs.h
new file mode 100644
index 000000000000..a5028dd94d31
--- /dev/null
+++ b/include/linux/hpfs_fs.h
@@ -0,0 +1,8 @@
1#ifndef _LINUX_HPFS_FS_H
2#define _LINUX_HPFS_FS_H
3
4/* HPFS magic number (word 0 of block 16) */
5
6#define HPFS_SUPER_MAGIC 0xf995e849
7
8#endif
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
new file mode 100644
index 000000000000..ae45676d27ba
--- /dev/null
+++ b/include/linux/hugetlb.h
@@ -0,0 +1,142 @@
1#ifndef _LINUX_HUGETLB_H
2#define _LINUX_HUGETLB_H
3
4#ifdef CONFIG_HUGETLB_PAGE
5
6#include <linux/mempolicy.h>
7
8struct ctl_table;
9
10static inline int is_vm_hugetlb_page(struct vm_area_struct *vma)
11{
12 return vma->vm_flags & VM_HUGETLB;
13}
14
15int hugetlb_sysctl_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *);
16int copy_hugetlb_page_range(struct mm_struct *, struct mm_struct *, struct vm_area_struct *);
17int follow_hugetlb_page(struct mm_struct *, struct vm_area_struct *, struct page **, struct vm_area_struct **, unsigned long *, int *, int);
18void zap_hugepage_range(struct vm_area_struct *, unsigned long, unsigned long);
19void unmap_hugepage_range(struct vm_area_struct *, unsigned long, unsigned long);
20int hugetlb_prefault(struct address_space *, struct vm_area_struct *);
21int hugetlb_report_meminfo(char *);
22int hugetlb_report_node_meminfo(int, char *);
23int is_hugepage_mem_enough(size_t);
24unsigned long hugetlb_total_pages(void);
25struct page *follow_huge_addr(struct mm_struct *mm, unsigned long address,
26 int write);
27struct page *follow_huge_pmd(struct mm_struct *mm, unsigned long address,
28 pmd_t *pmd, int write);
29int is_aligned_hugepage_range(unsigned long addr, unsigned long len);
30int pmd_huge(pmd_t pmd);
31struct page *alloc_huge_page(void);
32void free_huge_page(struct page *);
33
34extern unsigned long max_huge_pages;
35extern const unsigned long hugetlb_zero, hugetlb_infinity;
36extern int sysctl_hugetlb_shm_group;
37
38#ifndef ARCH_HAS_HUGEPAGE_ONLY_RANGE
39#define is_hugepage_only_range(mm, addr, len) 0
40#define hugetlb_free_pgtables(tlb, prev, start, end) do { } while (0)
41#endif
42
43#ifndef ARCH_HAS_PREPARE_HUGEPAGE_RANGE
44#define prepare_hugepage_range(addr, len) \
45 is_aligned_hugepage_range(addr, len)
46#else
47int prepare_hugepage_range(unsigned long addr, unsigned long len);
48#endif
49
50#else /* !CONFIG_HUGETLB_PAGE */
51
52static inline int is_vm_hugetlb_page(struct vm_area_struct *vma)
53{
54 return 0;
55}
56static inline unsigned long hugetlb_total_pages(void)
57{
58 return 0;
59}
60
61#define follow_hugetlb_page(m,v,p,vs,a,b,i) ({ BUG(); 0; })
62#define follow_huge_addr(mm, addr, write) ERR_PTR(-EINVAL)
63#define copy_hugetlb_page_range(src, dst, vma) ({ BUG(); 0; })
64#define hugetlb_prefault(mapping, vma) ({ BUG(); 0; })
65#define zap_hugepage_range(vma, start, len) BUG()
66#define unmap_hugepage_range(vma, start, end) BUG()
67#define is_hugepage_mem_enough(size) 0
68#define hugetlb_report_meminfo(buf) 0
69#define hugetlb_report_node_meminfo(n, buf) 0
70#define follow_huge_pmd(mm, addr, pmd, write) NULL
71#define is_aligned_hugepage_range(addr, len) 0
72#define prepare_hugepage_range(addr, len) (-EINVAL)
73#define pmd_huge(x) 0
74#define is_hugepage_only_range(mm, addr, len) 0
75#define hugetlb_free_pgtables(tlb, prev, start, end) do { } while (0)
76#define alloc_huge_page() ({ NULL; })
77#define free_huge_page(p) ({ (void)(p); BUG(); })
78
79#ifndef HPAGE_MASK
80#define HPAGE_MASK 0 /* Keep the compiler happy */
81#define HPAGE_SIZE 0
82#endif
83
84#endif /* !CONFIG_HUGETLB_PAGE */
85
86#ifdef CONFIG_HUGETLBFS
87struct hugetlbfs_config {
88 uid_t uid;
89 gid_t gid;
90 umode_t mode;
91 long nr_blocks;
92 long nr_inodes;
93};
94
95struct hugetlbfs_sb_info {
96 long max_blocks; /* blocks allowed */
97 long free_blocks; /* blocks free */
98 long max_inodes; /* inodes allowed */
99 long free_inodes; /* inodes free */
100 spinlock_t stat_lock;
101};
102
103
104struct hugetlbfs_inode_info {
105 struct shared_policy policy;
106 struct inode vfs_inode;
107};
108
109static inline struct hugetlbfs_inode_info *HUGETLBFS_I(struct inode *inode)
110{
111 return container_of(inode, struct hugetlbfs_inode_info, vfs_inode);
112}
113
114static inline struct hugetlbfs_sb_info *HUGETLBFS_SB(struct super_block *sb)
115{
116 return sb->s_fs_info;
117}
118
119extern struct file_operations hugetlbfs_file_operations;
120extern struct vm_operations_struct hugetlb_vm_ops;
121struct file *hugetlb_zero_setup(size_t);
122int hugetlb_get_quota(struct address_space *mapping);
123void hugetlb_put_quota(struct address_space *mapping);
124
125static inline int is_file_hugepages(struct file *file)
126{
127 return file->f_op == &hugetlbfs_file_operations;
128}
129
130static inline void set_file_hugepages(struct file *file)
131{
132 file->f_op = &hugetlbfs_file_operations;
133}
134#else /* !CONFIG_HUGETLBFS */
135
136#define is_file_hugepages(file) 0
137#define set_file_hugepages(file) BUG()
138#define hugetlb_zero_setup(size) ERR_PTR(-ENOSYS)
139
140#endif /* !CONFIG_HUGETLBFS */
141
142#endif /* _LINUX_HUGETLB_H */
diff --git a/include/linux/hysdn_if.h b/include/linux/hysdn_if.h
new file mode 100644
index 000000000000..00236ae3b04e
--- /dev/null
+++ b/include/linux/hysdn_if.h
@@ -0,0 +1,33 @@
1/* $Id: hysdn_if.h,v 1.1.8.3 2001/09/23 22:25:05 kai Exp $
2 *
3 * Linux driver for HYSDN cards
4 * ioctl definitions shared by hynetmgr and driver.
5 *
6 * Author Werner Cornelius (werner@titro.de) for Hypercope GmbH
7 * Copyright 1999 by Werner Cornelius (werner@titro.de)
8 *
9 * This software may be used and distributed according to the terms
10 * of the GNU General Public License, incorporated herein by reference.
11 *
12 */
13
14/****************/
15/* error values */
16/****************/
17#define ERR_NONE 0 /* no error occurred */
18#define ERR_ALREADY_BOOT 1000 /* we are already booting */
19#define EPOF_BAD_MAGIC 1001 /* bad magic in POF header */
20#define ERR_BOARD_DPRAM 1002 /* board DPRAM failed */
21#define EPOF_INTERNAL 1003 /* internal POF handler error */
22#define EPOF_BAD_IMG_SIZE 1004 /* POF boot image size invalid */
23#define ERR_BOOTIMG_FAIL 1005 /* 1. stage boot image did not start */
24#define ERR_BOOTSEQ_FAIL 1006 /* 2. stage boot seq handshake timeout */
25#define ERR_POF_TIMEOUT 1007 /* timeout waiting for card pof ready */
26#define ERR_NOT_BOOTED 1008 /* operation only allowed when booted */
27#define ERR_CONF_LONG 1009 /* conf line is too long */
28#define ERR_INV_CHAN 1010 /* invalid channel number */
29#define ERR_ASYNC_TIME 1011 /* timeout sending async data */
30
31
32
33
diff --git a/include/linux/i2c-algo-bit.h b/include/linux/i2c-algo-bit.h
new file mode 100644
index 000000000000..110904481238
--- /dev/null
+++ b/include/linux/i2c-algo-bit.h
@@ -0,0 +1,54 @@
1/* ------------------------------------------------------------------------- */
2/* i2c-algo-bit.h i2c driver algorithms for bit-shift adapters */
3/* ------------------------------------------------------------------------- */
4/* Copyright (C) 1995-99 Simon G. Vogl
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19/* ------------------------------------------------------------------------- */
20
21/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
22 Frodo Looijaard <frodol@dds.nl> */
23
24/* $Id: i2c-algo-bit.h,v 1.10 2003/01/21 08:08:16 kmalkki Exp $ */
25
26#ifndef _LINUX_I2C_ALGO_BIT_H
27#define _LINUX_I2C_ALGO_BIT_H
28
29/* --- Defines for bit-adapters --------------------------------------- */
30/*
31 * This struct contains the hw-dependent functions of bit-style adapters to
32 * manipulate the line states, and to init any hw-specific features. This is
33 * only used if you have more than one hw-type of adapter running.
34 */
35struct i2c_algo_bit_data {
36 void *data; /* private data for lowlevel routines */
37 void (*setsda) (void *data, int state);
38 void (*setscl) (void *data, int state);
39 int (*getsda) (void *data);
40 int (*getscl) (void *data);
41
42 /* local settings */
43 int udelay; /* half-clock-cycle time in microsecs */
44 /* i.e. clock is (500 / udelay) KHz */
45 int mdelay; /* in millisecs, unused */
46 int timeout; /* in jiffies */
47};
48
49#define I2C_BIT_ADAP_MAX 16
50
51int i2c_bit_add_bus(struct i2c_adapter *);
52int i2c_bit_del_bus(struct i2c_adapter *);
53
54#endif /* _LINUX_I2C_ALGO_BIT_H */
diff --git a/include/linux/i2c-algo-ite.h b/include/linux/i2c-algo-ite.h
new file mode 100644
index 000000000000..26a8b89855f1
--- /dev/null
+++ b/include/linux/i2c-algo-ite.h
@@ -0,0 +1,69 @@
1/* ------------------------------------------------------------------------- */
2/* i2c-algo-ite.h i2c driver algorithms for ITE IIC adapters */
3/* ------------------------------------------------------------------------- */
4/* Copyright (C) 1995-97 Simon G. Vogl
5 1998-99 Hans Berglund
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/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
23 Frodo Looijaard <frodol@dds.nl> */
24
25/* Modifications by MontaVista Software, 2001
26 Changes made to support the ITE IIC peripheral */
27
28
29#ifndef I2C_ALGO_ITE_H
30#define I2C_ALGO_ITE_H 1
31
32#include <linux/i2c.h>
33
34/* Example of a sequential read request:
35 struct i2c_iic_msg s_msg;
36
37 s_msg.addr=device_address;
38 s_msg.len=length;
39 s_msg.buf=buffer;
40 s_msg.waddr=word_address;
41 ioctl(file,I2C_SREAD, &s_msg);
42 */
43#define I2C_SREAD 0x780 /* SREAD ioctl command */
44
45struct i2c_iic_msg {
46 __u16 addr; /* device address */
47 __u16 waddr; /* word address */
48 short len; /* msg length */
49 char *buf; /* pointer to msg data */
50};
51
52struct i2c_algo_iic_data {
53 void *data; /* private data for lolevel routines */
54 void (*setiic) (void *data, int ctl, int val);
55 int (*getiic) (void *data, int ctl);
56 int (*getown) (void *data);
57 int (*getclock) (void *data);
58 void (*waitforpin) (void);
59
60 /* local settings */
61 int udelay;
62 int mdelay;
63 int timeout;
64};
65
66int i2c_iic_add_bus(struct i2c_adapter *);
67int i2c_iic_del_bus(struct i2c_adapter *);
68
69#endif /* I2C_ALGO_ITE_H */
diff --git a/include/linux/i2c-algo-pca.h b/include/linux/i2c-algo-pca.h
new file mode 100644
index 000000000000..941b786c5732
--- /dev/null
+++ b/include/linux/i2c-algo-pca.h
@@ -0,0 +1,17 @@
1#ifndef _LINUX_I2C_ALGO_PCA_H
2#define _LINUX_I2C_ALGO_PCA_H
3
4struct i2c_algo_pca_data {
5 int (*get_own) (struct i2c_algo_pca_data *adap); /* Obtain own address */
6 int (*get_clock) (struct i2c_algo_pca_data *adap);
7 void (*write_byte) (struct i2c_algo_pca_data *adap, int reg, int val);
8 int (*read_byte) (struct i2c_algo_pca_data *adap, int reg);
9 int (*wait_for_interrupt) (struct i2c_algo_pca_data *adap);
10};
11
12#define I2C_PCA_ADAP_MAX 16
13
14int i2c_pca_add_bus(struct i2c_adapter *);
15int i2c_pca_del_bus(struct i2c_adapter *);
16
17#endif /* _LINUX_I2C_ALGO_PCA_H */
diff --git a/include/linux/i2c-algo-pcf.h b/include/linux/i2c-algo-pcf.h
new file mode 100644
index 000000000000..2a508562255f
--- /dev/null
+++ b/include/linux/i2c-algo-pcf.h
@@ -0,0 +1,49 @@
1/* ------------------------------------------------------------------------- */
2/* adap-pcf.h i2c driver algorithms for PCF8584 adapters */
3/* ------------------------------------------------------------------------- */
4/* Copyright (C) 1995-97 Simon G. Vogl
5 1998-99 Hans Berglund
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/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
23 Frodo Looijaard <frodol@dds.nl> */
24
25/* $Id: i2c-algo-pcf.h,v 1.8 2003/01/21 08:08:16 kmalkki Exp $ */
26
27#ifndef _LINUX_I2C_ALGO_PCF_H
28#define _LINUX_I2C_ALGO_PCF_H
29
30struct i2c_algo_pcf_data {
31 void *data; /* private data for lolevel routines */
32 void (*setpcf) (void *data, int ctl, int val);
33 int (*getpcf) (void *data, int ctl);
34 int (*getown) (void *data);
35 int (*getclock) (void *data);
36 void (*waitforpin) (void);
37
38 /* local settings */
39 int udelay;
40 int mdelay;
41 int timeout;
42};
43
44#define I2C_PCF_ADAP_MAX 16
45
46int i2c_pcf_add_bus(struct i2c_adapter *);
47int i2c_pcf_del_bus(struct i2c_adapter *);
48
49#endif /* _LINUX_I2C_ALGO_PCF_H */
diff --git a/include/linux/i2c-algo-sgi.h b/include/linux/i2c-algo-sgi.h
new file mode 100644
index 000000000000..4a0113d64064
--- /dev/null
+++ b/include/linux/i2c-algo-sgi.h
@@ -0,0 +1,27 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License version 2 as published by the Free Software Foundation.
4 *
5 * Copyright (C) 2003 Ladislav Michl <ladis@linux-mips.org>
6 */
7
8#ifndef I2C_ALGO_SGI_H
9#define I2C_ALGO_SGI_H 1
10
11#include <linux/i2c.h>
12
13struct i2c_algo_sgi_data {
14 void *data; /* private data for lowlevel routines */
15 unsigned (*getctrl)(void *data);
16 void (*setctrl)(void *data, unsigned val);
17 unsigned (*rdata)(void *data);
18 void (*wdata)(void *data, unsigned val);
19
20 int xfer_timeout;
21 int ack_timeout;
22};
23
24int i2c_sgi_add_bus(struct i2c_adapter *);
25int i2c_sgi_del_bus(struct i2c_adapter *);
26
27#endif /* I2C_ALGO_SGI_H */
diff --git a/include/linux/i2c-algo-sibyte.h b/include/linux/i2c-algo-sibyte.h
new file mode 100644
index 000000000000..03914ded8614
--- /dev/null
+++ b/include/linux/i2c-algo-sibyte.h
@@ -0,0 +1,33 @@
1/*
2 * Copyright (C) 2001,2002,2003 Broadcom Corporation
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (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
19#ifndef I2C_ALGO_SIBYTE_H
20#define I2C_ALGO_SIBYTE_H 1
21
22#include <linux/i2c.h>
23
24struct i2c_algo_sibyte_data {
25 void *data; /* private data */
26 int bus; /* which bus */
27 void *reg_base; /* CSR base */
28};
29
30int i2c_sibyte_add_bus(struct i2c_adapter *, int speed);
31int i2c_sibyte_del_bus(struct i2c_adapter *);
32
33#endif /* I2C_ALGO_SIBYTE_H */
diff --git a/include/linux/i2c-dev.h b/include/linux/i2c-dev.h
new file mode 100644
index 000000000000..d228230ffe5d
--- /dev/null
+++ b/include/linux/i2c-dev.h
@@ -0,0 +1,48 @@
1/*
2 i2c-dev.h - i2c-bus driver, char device interface
3
4 Copyright (C) 1995-97 Simon G. Vogl
5 Copyright (C) 1998-99 Frodo Looijaard <frodol@dds.nl>
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/* $Id: i2c-dev.h,v 1.13 2003/01/21 08:08:16 kmalkki Exp $ */
23
24#ifndef _LINUX_I2C_DEV_H
25#define _LINUX_I2C_DEV_H
26
27#include <linux/types.h>
28
29/* Some IOCTL commands are defined in <linux/i2c.h> */
30/* Note: 10-bit addresses are NOT supported! */
31
32/* This is the structure as used in the I2C_SMBUS ioctl call */
33struct i2c_smbus_ioctl_data {
34 __u8 read_write;
35 __u8 command;
36 __u32 size;
37 union i2c_smbus_data __user *data;
38};
39
40/* This is the structure as used in the I2C_RDWR ioctl call */
41struct i2c_rdwr_ioctl_data {
42 struct i2c_msg __user *msgs; /* pointers to i2c_msgs */
43 __u32 nmsgs; /* number of i2c_msgs */
44};
45
46#define I2C_RDRW_IOCTL_MAX_MSGS 42
47
48#endif /* _LINUX_I2C_DEV_H */
diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h
new file mode 100644
index 000000000000..89270ce51470
--- /dev/null
+++ b/include/linux/i2c-id.h
@@ -0,0 +1,319 @@
1/* ------------------------------------------------------------------------- */
2/* */
3/* i2c.h - definitions for the i2c-bus interface */
4/* */
5/* ------------------------------------------------------------------------- */
6/* Copyright (C) 1995-1999 Simon G. Vogl
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
21/* ------------------------------------------------------------------------- */
22
23#ifndef LINUX_I2C_ID_H
24#define LINUX_I2C_ID_H
25
26/*
27 * This file is part of the i2c-bus package and contains the identifier
28 * values for drivers, adapters and other folk populating these serial
29 * worlds.
30 *
31 * These will change often (i.e. additions) , therefore this has been
32 * separated from the functional interface definitions of the i2c api.
33 *
34 */
35
36/*
37 * ---- Driver types -----------------------------------------------------
38 * device id name + number function description, i2c address(es)
39 *
40 * Range 1000-1999 range is defined in sensors/sensors.h
41 * Range 0x100 - 0x1ff is for V4L2 Common Components
42 * Range 0xf000 - 0xffff is reserved for local experimentation, and should
43 * never be used in official drivers
44 */
45
46#define I2C_DRIVERID_MSP3400 1
47#define I2C_DRIVERID_TUNER 2
48#define I2C_DRIVERID_VIDEOTEX 3 /* please rename */
49#define I2C_DRIVERID_TDA8425 4 /* stereo sound processor */
50#define I2C_DRIVERID_TEA6420 5 /* audio matrix switch */
51#define I2C_DRIVERID_TEA6415C 6 /* video matrix switch */
52#define I2C_DRIVERID_TDA9840 7 /* stereo sound processor */
53#define I2C_DRIVERID_SAA7111A 8 /* video input processor */
54#define I2C_DRIVERID_SAA5281 9 /* videotext decoder */
55#define I2C_DRIVERID_SAA7112 10 /* video decoder, image scaler */
56#define I2C_DRIVERID_SAA7120 11 /* video encoder */
57#define I2C_DRIVERID_SAA7121 12 /* video encoder */
58#define I2C_DRIVERID_SAA7185B 13 /* video encoder */
59#define I2C_DRIVERID_CH7003 14 /* digital pc to tv encoder */
60#define I2C_DRIVERID_PCF8574A 15 /* i2c expander - 8 bit in/out */
61#define I2C_DRIVERID_PCF8582C 16 /* eeprom */
62#define I2C_DRIVERID_AT24Cxx 17 /* eeprom 1/2/4/8/16 K */
63#define I2C_DRIVERID_TEA6300 18 /* audio mixer */
64#define I2C_DRIVERID_BT829 19 /* pc to tv encoder */
65#define I2C_DRIVERID_TDA9850 20 /* audio mixer */
66#define I2C_DRIVERID_TDA9855 21 /* audio mixer */
67#define I2C_DRIVERID_SAA7110 22 /* video decoder */
68#define I2C_DRIVERID_MGATVO 23 /* Matrox TVOut */
69#define I2C_DRIVERID_SAA5249 24 /* SAA5249 and compatibles */
70#define I2C_DRIVERID_PCF8583 25 /* real time clock */
71#define I2C_DRIVERID_SAB3036 26 /* SAB3036 tuner */
72#define I2C_DRIVERID_TDA7432 27 /* Stereo sound processor */
73#define I2C_DRIVERID_TVMIXER 28 /* Mixer driver for tv cards */
74#define I2C_DRIVERID_TVAUDIO 29 /* Generic TV sound driver */
75#define I2C_DRIVERID_DPL3518 30 /* Dolby decoder chip */
76#define I2C_DRIVERID_TDA9873 31 /* TV sound decoder chip */
77#define I2C_DRIVERID_TDA9875 32 /* TV sound decoder chip */
78#define I2C_DRIVERID_PIC16C54_PV9 33 /* Audio mux/ir receiver */
79
80#define I2C_DRIVERID_SBATT 34 /* Smart Battery Device */
81#define I2C_DRIVERID_SBS 35 /* SB System Manager */
82#define I2C_DRIVERID_VES1893 36 /* VLSI DVB-S decoder */
83#define I2C_DRIVERID_VES1820 37 /* VLSI DVB-C decoder */
84#define I2C_DRIVERID_SAA7113 38 /* video decoder */
85#define I2C_DRIVERID_TDA8444 39 /* octuple 6-bit DAC */
86#define I2C_DRIVERID_BT819 40 /* video decoder */
87#define I2C_DRIVERID_BT856 41 /* video encoder */
88#define I2C_DRIVERID_VPX3220 42 /* video decoder+vbi/vtxt */
89#define I2C_DRIVERID_DRP3510 43 /* ADR decoder (Astra Radio) */
90#define I2C_DRIVERID_SP5055 44 /* Satellite tuner */
91#define I2C_DRIVERID_STV0030 45 /* Multipurpose switch */
92#define I2C_DRIVERID_SAA7108 46 /* video decoder, image scaler */
93#define I2C_DRIVERID_DS1307 47 /* DS1307 real time clock */
94#define I2C_DRIVERID_ADV7175 48 /* ADV 7175/7176 video encoder */
95#define I2C_DRIVERID_SAA7114 49 /* video decoder */
96#define I2C_DRIVERID_ZR36120 50 /* Zoran 36120 video encoder */
97#define I2C_DRIVERID_24LC32A 51 /* Microchip 24LC32A 32k EEPROM */
98#define I2C_DRIVERID_STM41T00 52 /* real time clock */
99#define I2C_DRIVERID_UDA1342 53 /* UDA1342 audio codec */
100#define I2C_DRIVERID_ADV7170 54 /* video encoder */
101#define I2C_DRIVERID_RADEON 55 /* I2C bus on Radeon boards */
102#define I2C_DRIVERID_MAX1617 56 /* temp sensor */
103#define I2C_DRIVERID_SAA7191 57 /* video encoder */
104#define I2C_DRIVERID_INDYCAM 58 /* SGI IndyCam */
105#define I2C_DRIVERID_BT832 59 /* CMOS camera video processor */
106#define I2C_DRIVERID_TDA9887 60 /* TDA988x IF-PLL demodulator */
107#define I2C_DRIVERID_OVCAMCHIP 61 /* OmniVision CMOS image sens. */
108#define I2C_DRIVERID_TDA7313 62 /* TDA7313 audio processor */
109#define I2C_DRIVERID_MAX6900 63 /* MAX6900 real-time clock */
110#define I2C_DRIVERID_SAA7114H 64 /* video decoder */
111
112
113#define I2C_DRIVERID_EXP0 0xF0 /* experimental use id's */
114#define I2C_DRIVERID_EXP1 0xF1
115#define I2C_DRIVERID_EXP2 0xF2
116#define I2C_DRIVERID_EXP3 0xF3
117
118#define I2C_DRIVERID_I2CDEV 900
119#define I2C_DRIVERID_I2CPROC 901
120#define I2C_DRIVERID_ARP 902 /* SMBus ARP Client */
121#define I2C_DRIVERID_ALERT 903 /* SMBus Alert Responder Client */
122
123/* IDs -- Use DRIVERIDs 1000-1999 for sensors.
124 These were originally in sensors.h in the lm_sensors package */
125#define I2C_DRIVERID_LM78 1002
126#define I2C_DRIVERID_LM75 1003
127#define I2C_DRIVERID_GL518 1004
128#define I2C_DRIVERID_EEPROM 1005
129#define I2C_DRIVERID_W83781D 1006
130#define I2C_DRIVERID_LM80 1007
131#define I2C_DRIVERID_ADM1021 1008
132#define I2C_DRIVERID_ADM9240 1009
133#define I2C_DRIVERID_LTC1710 1010
134#define I2C_DRIVERID_SIS5595 1011
135#define I2C_DRIVERID_ICSPLL 1012
136#define I2C_DRIVERID_BT869 1013
137#define I2C_DRIVERID_MAXILIFE 1014
138#define I2C_DRIVERID_MATORB 1015
139#define I2C_DRIVERID_GL520 1016
140#define I2C_DRIVERID_THMC50 1017
141#define I2C_DRIVERID_DDCMON 1018
142#define I2C_DRIVERID_VIA686A 1019
143#define I2C_DRIVERID_ADM1025 1020
144#define I2C_DRIVERID_LM87 1021
145#define I2C_DRIVERID_PCF8574 1022
146#define I2C_DRIVERID_MTP008 1023
147#define I2C_DRIVERID_DS1621 1024
148#define I2C_DRIVERID_ADM1024 1025
149#define I2C_DRIVERID_IT87 1026
150#define I2C_DRIVERID_CH700X 1027 /* single driver for CH7003-7009 digital pc to tv encoders */
151#define I2C_DRIVERID_FSCPOS 1028
152#define I2C_DRIVERID_FSCSCY 1029
153#define I2C_DRIVERID_PCF8591 1030
154#define I2C_DRIVERID_SMSC47M1 1031
155#define I2C_DRIVERID_VT1211 1032
156#define I2C_DRIVERID_LM92 1033
157#define I2C_DRIVERID_VT8231 1034
158#define I2C_DRIVERID_SMARTBATT 1035
159#define I2C_DRIVERID_BMCSENSORS 1036
160#define I2C_DRIVERID_FS451 1037
161#define I2C_DRIVERID_W83627HF 1038
162#define I2C_DRIVERID_LM85 1039
163#define I2C_DRIVERID_LM83 1040
164#define I2C_DRIVERID_LM90 1042
165#define I2C_DRIVERID_ASB100 1043
166#define I2C_DRIVERID_FSCHER 1046
167#define I2C_DRIVERID_W83L785TS 1047
168#define I2C_DRIVERID_SMSC47B397 1050
169
170/*
171 * ---- Adapter types ----------------------------------------------------
172 *
173 * First, we distinguish between several algorithms to access the hardware
174 * interface types, as a PCF 8584 needs other care than a bit adapter.
175 */
176
177#define I2C_ALGO_NONE 0x000000
178#define I2C_ALGO_BIT 0x010000 /* bit style adapters */
179#define I2C_ALGO_PCF 0x020000 /* PCF 8584 style adapters */
180#define I2C_ALGO_ATI 0x030000 /* ATI video card */
181#define I2C_ALGO_SMBUS 0x040000
182#define I2C_ALGO_ISA 0x050000 /* lm_sensors ISA pseudo-adapter */
183#define I2C_ALGO_SAA7146 0x060000 /* SAA 7146 video decoder bus */
184#define I2C_ALGO_ACB 0x070000 /* ACCESS.bus algorithm */
185#define I2C_ALGO_IIC 0x080000 /* ITE IIC bus */
186#define I2C_ALGO_SAA7134 0x090000
187#define I2C_ALGO_MPC824X 0x0a0000 /* Motorola 8240 / 8245 */
188#define I2C_ALGO_IPMI 0x0b0000 /* IPMI dummy adapter */
189#define I2C_ALGO_IPMB 0x0c0000 /* IPMB adapter */
190#define I2C_ALGO_MPC107 0x0d0000
191#define I2C_ALGO_EC 0x100000 /* ACPI embedded controller */
192
193#define I2C_ALGO_MPC8XX 0x110000 /* MPC8xx PowerPC I2C algorithm */
194#define I2C_ALGO_OCP 0x120000 /* IBM or otherwise On-chip I2C algorithm */
195#define I2C_ALGO_BITHS 0x130000 /* enhanced bit style adapters */
196#define I2C_ALGO_IOP3XX 0x140000 /* XSCALE IOP3XX On-chip I2C alg */
197#define I2C_ALGO_SIBYTE 0x150000 /* Broadcom SiByte SOCs */
198#define I2C_ALGO_SGI 0x160000 /* SGI algorithm */
199
200#define I2C_ALGO_USB 0x170000 /* USB algorithm */
201#define I2C_ALGO_VIRT 0x180000 /* Virtual bus adapter */
202
203#define I2C_ALGO_MV64XXX 0x190000 /* Marvell mv64xxx i2c ctlr */
204#define I2C_ALGO_PCA 0x1a0000 /* PCA 9564 style adapters */
205#define I2C_ALGO_AU1550 0x1b0000 /* Au1550 PSC algorithm */
206
207#define I2C_ALGO_EXP 0x800000 /* experimental */
208
209#define I2C_ALGO_MASK 0xff0000 /* Mask for algorithms */
210#define I2C_ALGO_SHIFT 0x10 /* right shift to get index values */
211
212#define I2C_HW_ADAPS 0x10000 /* # adapter types */
213#define I2C_HW_MASK 0xffff
214
215
216/* hw specific modules that are defined per algorithm layer
217 */
218
219/* --- Bit algorithm adapters */
220#define I2C_HW_B_LP 0x00 /* Parallel port Philips style adapter */
221#define I2C_HW_B_LPC 0x01 /* Parallel port, over control reg. */
222#define I2C_HW_B_SER 0x02 /* Serial line interface */
223#define I2C_HW_B_ELV 0x03 /* ELV Card */
224#define I2C_HW_B_VELLE 0x04 /* Vellemann K8000 */
225#define I2C_HW_B_BT848 0x05 /* BT848 video boards */
226#define I2C_HW_B_WNV 0x06 /* Winnov Videums */
227#define I2C_HW_B_VIA 0x07 /* Via vt82c586b */
228#define I2C_HW_B_HYDRA 0x08 /* Apple Hydra Mac I/O */
229#define I2C_HW_B_G400 0x09 /* Matrox G400 */
230#define I2C_HW_B_I810 0x0a /* Intel I810 */
231#define I2C_HW_B_VOO 0x0b /* 3dfx Voodoo 3 / Banshee */
232#define I2C_HW_B_PPORT 0x0c /* Primitive parallel port adapter */
233#define I2C_HW_B_SAVG 0x0d /* Savage 4 */
234#define I2C_HW_B_SCX200 0x0e /* Nat'l Semi SCx200 I2C */
235#define I2C_HW_B_RIVA 0x10 /* Riva based graphics cards */
236#define I2C_HW_B_IOC 0x11 /* IOC bit-wiggling */
237#define I2C_HW_B_TSUNA 0x12 /* DEC Tsunami chipset */
238#define I2C_HW_B_FRODO 0x13 /* 2d3D, Inc. SA-1110 Development Board */
239#define I2C_HW_B_OMAHA 0x14 /* Omaha I2C interface (ARM) */
240#define I2C_HW_B_GUIDE 0x15 /* Guide bit-basher */
241#define I2C_HW_B_IXP2000 0x16 /* GPIO on IXP2000 systems */
242#define I2C_HW_B_IXP4XX 0x17 /* GPIO on IXP4XX systems */
243#define I2C_HW_B_S3VIA 0x18 /* S3Via ProSavage adapter */
244#define I2C_HW_B_ZR36067 0x19 /* Zoran-36057/36067 based boards */
245#define I2C_HW_B_PCILYNX 0x1a /* TI PCILynx I2C adapter */
246#define I2C_HW_B_CX2388x 0x1b /* connexant 2388x based tv cards */
247
248/* --- PCF 8584 based algorithms */
249#define I2C_HW_P_LP 0x00 /* Parallel port interface */
250#define I2C_HW_P_ISA 0x01 /* generic ISA Bus inteface card */
251#define I2C_HW_P_ELEK 0x02 /* Elektor ISA Bus inteface card */
252
253/* --- PCA 9564 based algorithms */
254#define I2C_HW_A_ISA 0x00 /* generic ISA Bus interface card */
255
256/* --- ACPI Embedded controller algorithms */
257#define I2C_HW_ACPI_EC 0x00
258
259/* --- MPC824x PowerPC adapters */
260#define I2C_HW_MPC824X 0x00 /* Motorola 8240 / 8245 */
261
262/* --- MPC8xx PowerPC adapters */
263#define I2C_HW_MPC8XX_EPON 0x00 /* Eponymous MPC8xx I2C adapter */
264
265/* --- ITE based algorithms */
266#define I2C_HW_I_IIC 0x00 /* controller on the ITE */
267
268/* --- PowerPC on-chip adapters */
269#define I2C_HW_OCP 0x00 /* IBM on-chip I2C adapter */
270
271/* --- Broadcom SiByte adapters */
272#define I2C_HW_SIBYTE 0x00
273
274/* --- SGI adapters */
275#define I2C_HW_SGI_VINO 0x00
276#define I2C_HW_SGI_MACE 0x01
277
278/* --- XSCALE on-chip adapters */
279#define I2C_HW_IOP3XX 0x00
280
281/* --- Au1550 PSC adapters adapters */
282#define I2C_HW_AU1550_PSC 0x00
283
284/* --- SMBus only adapters */
285#define I2C_HW_SMBUS_PIIX4 0x00
286#define I2C_HW_SMBUS_ALI15X3 0x01
287#define I2C_HW_SMBUS_VIA2 0x02
288#define I2C_HW_SMBUS_VOODOO3 0x03
289#define I2C_HW_SMBUS_I801 0x04
290#define I2C_HW_SMBUS_AMD756 0x05
291#define I2C_HW_SMBUS_SIS5595 0x06
292#define I2C_HW_SMBUS_ALI1535 0x07
293#define I2C_HW_SMBUS_SIS630 0x08
294#define I2C_HW_SMBUS_SIS96X 0x09
295#define I2C_HW_SMBUS_AMD8111 0x0a
296#define I2C_HW_SMBUS_SCX200 0x0b
297#define I2C_HW_SMBUS_NFORCE2 0x0c
298#define I2C_HW_SMBUS_W9968CF 0x0d
299#define I2C_HW_SMBUS_OV511 0x0e /* OV511(+) USB 1.1 webcam ICs */
300#define I2C_HW_SMBUS_OV518 0x0f /* OV518(+) USB 1.1 webcam ICs */
301#define I2C_HW_SMBUS_OV519 0x10 /* OV519 USB 1.1 webcam IC */
302#define I2C_HW_SMBUS_OVFX2 0x11 /* Cypress/OmniVision FX2 webcam */
303
304/* --- ISA pseudo-adapter */
305#define I2C_HW_ISA 0x00
306
307/* --- IPMI pseudo-adapter */
308#define I2C_HW_IPMI 0x00
309
310/* --- IPMB adapter */
311#define I2C_HW_IPMB 0x00
312
313/* --- MCP107 adapter */
314#define I2C_HW_MPC107 0x00
315
316/* --- Marvell mv64xxx i2c adapter */
317#define I2C_HW_MV64XXX 0x00
318
319#endif /* LINUX_I2C_ID_H */
diff --git a/include/linux/i2c-sensor.h b/include/linux/i2c-sensor.h
new file mode 100644
index 000000000000..21b625204956
--- /dev/null
+++ b/include/linux/i2c-sensor.h
@@ -0,0 +1,263 @@
1/*
2 i2c-sensor.h - Part of the i2c package
3 was originally sensors.h - Part of lm_sensors, Linux kernel modules
4 for hardware monitoring
5 Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl>
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 _LINUX_I2C_SENSOR_H
23#define _LINUX_I2C_SENSOR_H
24
25/* A structure containing detect information.
26 Force variables overrule all other variables; they force a detection on
27 that place. If a specific chip is given, the module blindly assumes this
28 chip type is present; if a general force (kind == 0) is given, the module
29 will still try to figure out what type of chip is present. This is useful
30 if for some reasons the detect for SMBus or ISA address space filled
31 fails.
32 probe: insmod parameter. Initialize this list with I2C_CLIENT_ISA_END values.
33 A list of pairs. The first value is a bus number (ANY_I2C_ISA_BUS for
34 the ISA bus, -1 for any I2C bus), the second is the address.
35 kind: The kind of chip. 0 equals any chip.
36*/
37struct i2c_force_data {
38 unsigned short *force;
39 unsigned short kind;
40};
41
42/* A structure containing the detect information.
43 normal_i2c: filled in by the module writer. Terminated by I2C_CLIENT_ISA_END.
44 A list of I2C addresses which should normally be examined.
45 normal_isa: filled in by the module writer. Terminated by SENSORS_ISA_END.
46 A list of ISA addresses which should normally be examined.
47 probe: insmod parameter. Initialize this list with I2C_CLIENT_ISA_END values.
48 A list of pairs. The first value is a bus number (ANY_I2C_ISA_BUS for
49 the ISA bus, -1 for any I2C bus), the second is the address. These
50 addresses are also probed, as if they were in the 'normal' list.
51 ignore: insmod parameter. Initialize this list with I2C_CLIENT_ISA_END values.
52 A list of pairs. The first value is a bus number (ANY_I2C_ISA_BUS for
53 the ISA bus, -1 for any I2C bus), the second is the I2C address. These
54 addresses are never probed. This parameter overrules 'normal' and
55 'probe', but not the 'force' lists.
56 force_data: insmod parameters. A list, ending with an element of which
57 the force field is NULL.
58*/
59struct i2c_address_data {
60 unsigned short *normal_i2c;
61 unsigned int *normal_isa;
62 unsigned short *probe;
63 unsigned short *ignore;
64 struct i2c_force_data *forces;
65};
66
67#define SENSORS_MODULE_PARM_FORCE(name) \
68 I2C_CLIENT_MODULE_PARM(force_ ## name, \
69 "List of adapter,address pairs which are unquestionably" \
70 " assumed to contain a `" # name "' chip")
71
72
73/* This defines several insmod variables, and the addr_data structure */
74#define SENSORS_INSMOD \
75 I2C_CLIENT_MODULE_PARM(probe, \
76 "List of adapter,address pairs to scan additionally"); \
77 I2C_CLIENT_MODULE_PARM(ignore, \
78 "List of adapter,address pairs not to scan"); \
79 static struct i2c_address_data addr_data = { \
80 .normal_i2c = normal_i2c, \
81 .normal_isa = normal_isa, \
82 .probe = probe, \
83 .ignore = ignore, \
84 .forces = forces, \
85 }
86
87/* The following functions create an enum with the chip names as elements.
88 The first element of the enum is any_chip. These are the only macros
89 a module will want to use. */
90
91#define SENSORS_INSMOD_0 \
92 enum chips { any_chip }; \
93 I2C_CLIENT_MODULE_PARM(force, \
94 "List of adapter,address pairs to boldly assume " \
95 "to be present"); \
96 static struct i2c_force_data forces[] = {{force,any_chip},{NULL}}; \
97 SENSORS_INSMOD
98
99#define SENSORS_INSMOD_1(chip1) \
100 enum chips { any_chip, chip1 }; \
101 I2C_CLIENT_MODULE_PARM(force, \
102 "List of adapter,address pairs to boldly assume " \
103 "to be present"); \
104 SENSORS_MODULE_PARM_FORCE(chip1); \
105 static struct i2c_force_data forces[] = {{force,any_chip},\
106 {force_ ## chip1,chip1}, \
107 {NULL}}; \
108 SENSORS_INSMOD
109
110#define SENSORS_INSMOD_2(chip1,chip2) \
111 enum chips { any_chip, chip1, chip2 }; \
112 I2C_CLIENT_MODULE_PARM(force, \
113 "List of adapter,address pairs to boldly assume " \
114 "to be present"); \
115 SENSORS_MODULE_PARM_FORCE(chip1); \
116 SENSORS_MODULE_PARM_FORCE(chip2); \
117 static struct i2c_force_data forces[] = {{force,any_chip}, \
118 {force_ ## chip1,chip1}, \
119 {force_ ## chip2,chip2}, \
120 {NULL}}; \
121 SENSORS_INSMOD
122
123#define SENSORS_INSMOD_3(chip1,chip2,chip3) \
124 enum chips { any_chip, chip1, chip2, chip3 }; \
125 I2C_CLIENT_MODULE_PARM(force, \
126 "List of adapter,address pairs to boldly assume " \
127 "to be present"); \
128 SENSORS_MODULE_PARM_FORCE(chip1); \
129 SENSORS_MODULE_PARM_FORCE(chip2); \
130 SENSORS_MODULE_PARM_FORCE(chip3); \
131 static struct i2c_force_data forces[] = {{force,any_chip}, \
132 {force_ ## chip1,chip1}, \
133 {force_ ## chip2,chip2}, \
134 {force_ ## chip3,chip3}, \
135 {NULL}}; \
136 SENSORS_INSMOD
137
138#define SENSORS_INSMOD_4(chip1,chip2,chip3,chip4) \
139 enum chips { any_chip, chip1, chip2, chip3, chip4 }; \
140 I2C_CLIENT_MODULE_PARM(force, \
141 "List of adapter,address pairs to boldly assume " \
142 "to be present"); \
143 SENSORS_MODULE_PARM_FORCE(chip1); \
144 SENSORS_MODULE_PARM_FORCE(chip2); \
145 SENSORS_MODULE_PARM_FORCE(chip3); \
146 SENSORS_MODULE_PARM_FORCE(chip4); \
147 static struct i2c_force_data forces[] = {{force,any_chip}, \
148 {force_ ## chip1,chip1}, \
149 {force_ ## chip2,chip2}, \
150 {force_ ## chip3,chip3}, \
151 {force_ ## chip4,chip4}, \
152 {NULL}}; \
153 SENSORS_INSMOD
154
155#define SENSORS_INSMOD_5(chip1,chip2,chip3,chip4,chip5) \
156 enum chips { any_chip, chip1, chip2, chip3, chip4, chip5 }; \
157 I2C_CLIENT_MODULE_PARM(force, \
158 "List of adapter,address pairs to boldly assume " \
159 "to be present"); \
160 SENSORS_MODULE_PARM_FORCE(chip1); \
161 SENSORS_MODULE_PARM_FORCE(chip2); \
162 SENSORS_MODULE_PARM_FORCE(chip3); \
163 SENSORS_MODULE_PARM_FORCE(chip4); \
164 SENSORS_MODULE_PARM_FORCE(chip5); \
165 static struct i2c_force_data forces[] = {{force,any_chip}, \
166 {force_ ## chip1,chip1}, \
167 {force_ ## chip2,chip2}, \
168 {force_ ## chip3,chip3}, \
169 {force_ ## chip4,chip4}, \
170 {force_ ## chip5,chip5}, \
171 {NULL}}; \
172 SENSORS_INSMOD
173
174#define SENSORS_INSMOD_6(chip1,chip2,chip3,chip4,chip5,chip6) \
175 enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6 }; \
176 I2C_CLIENT_MODULE_PARM(force, \
177 "List of adapter,address pairs to boldly assume " \
178 "to be present"); \
179 SENSORS_MODULE_PARM_FORCE(chip1); \
180 SENSORS_MODULE_PARM_FORCE(chip2); \
181 SENSORS_MODULE_PARM_FORCE(chip3); \
182 SENSORS_MODULE_PARM_FORCE(chip4); \
183 SENSORS_MODULE_PARM_FORCE(chip5); \
184 SENSORS_MODULE_PARM_FORCE(chip6); \
185 static struct i2c_force_data forces[] = {{force,any_chip}, \
186 {force_ ## chip1,chip1}, \
187 {force_ ## chip2,chip2}, \
188 {force_ ## chip3,chip3}, \
189 {force_ ## chip4,chip4}, \
190 {force_ ## chip5,chip5}, \
191 {force_ ## chip6,chip6}, \
192 {NULL}}; \
193 SENSORS_INSMOD
194
195#define SENSORS_INSMOD_7(chip1,chip2,chip3,chip4,chip5,chip6,chip7) \
196 enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, chip7 }; \
197 I2C_CLIENT_MODULE_PARM(force, \
198 "List of adapter,address pairs to boldly assume " \
199 "to be present"); \
200 SENSORS_MODULE_PARM_FORCE(chip1); \
201 SENSORS_MODULE_PARM_FORCE(chip2); \
202 SENSORS_MODULE_PARM_FORCE(chip3); \
203 SENSORS_MODULE_PARM_FORCE(chip4); \
204 SENSORS_MODULE_PARM_FORCE(chip5); \
205 SENSORS_MODULE_PARM_FORCE(chip6); \
206 SENSORS_MODULE_PARM_FORCE(chip7); \
207 static struct i2c_force_data forces[] = {{force,any_chip}, \
208 {force_ ## chip1,chip1}, \
209 {force_ ## chip2,chip2}, \
210 {force_ ## chip3,chip3}, \
211 {force_ ## chip4,chip4}, \
212 {force_ ## chip5,chip5}, \
213 {force_ ## chip6,chip6}, \
214 {force_ ## chip7,chip7}, \
215 {NULL}}; \
216 SENSORS_INSMOD
217
218#define SENSORS_INSMOD_8(chip1,chip2,chip3,chip4,chip5,chip6,chip7,chip8) \
219 enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, chip7, chip8 }; \
220 I2C_CLIENT_MODULE_PARM(force, \
221 "List of adapter,address pairs to boldly assume " \
222 "to be present"); \
223 SENSORS_MODULE_PARM_FORCE(chip1); \
224 SENSORS_MODULE_PARM_FORCE(chip2); \
225 SENSORS_MODULE_PARM_FORCE(chip3); \
226 SENSORS_MODULE_PARM_FORCE(chip4); \
227 SENSORS_MODULE_PARM_FORCE(chip5); \
228 SENSORS_MODULE_PARM_FORCE(chip6); \
229 SENSORS_MODULE_PARM_FORCE(chip7); \
230 SENSORS_MODULE_PARM_FORCE(chip8); \
231 static struct i2c_force_data forces[] = {{force,any_chip}, \
232 {force_ ## chip1,chip1}, \
233 {force_ ## chip2,chip2}, \
234 {force_ ## chip3,chip3}, \
235 {force_ ## chip4,chip4}, \
236 {force_ ## chip5,chip5}, \
237 {force_ ## chip6,chip6}, \
238 {force_ ## chip7,chip7}, \
239 {force_ ## chip8,chip8}, \
240 {NULL}}; \
241 SENSORS_INSMOD
242
243/* Detect function. It iterates over all possible addresses itself. For
244 SMBus addresses, it will only call found_proc if some client is connected
245 to the SMBus (unless a 'force' matched); for ISA detections, this is not
246 done. */
247extern int i2c_detect(struct i2c_adapter *adapter,
248 struct i2c_address_data *address_data,
249 int (*found_proc) (struct i2c_adapter *, int, int));
250
251
252/* This macro is used to scale user-input to sensible values in almost all
253 chip drivers. */
254static inline int SENSORS_LIMIT(long value, long low, long high)
255{
256 if (value < low)
257 return low;
258 else if (value > high)
259 return high;
260 else
261 return value;
262}
263#endif /* def _LINUX_I2C_SENSOR_H */
diff --git a/include/linux/i2c-vid.h b/include/linux/i2c-vid.h
new file mode 100644
index 000000000000..974835e3530f
--- /dev/null
+++ b/include/linux/i2c-vid.h
@@ -0,0 +1,99 @@
1/*
2 i2c-vid.h - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring
4 Copyright (c) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com>
5 With assistance from Trent Piepho <xyzzy@speakeasy.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 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/*
23 This file contains common code for decoding VID pins.
24 This file is #included in various chip drivers in this directory.
25 As the user is unlikely to load more than one driver which
26 includes this code we don't worry about the wasted space.
27 Reference: VRM x.y DC-DC Converter Design Guidelines,
28 available at http://developer.intel.com
29*/
30
31/*
32 AMD Opteron processors don't follow the Intel VRM spec.
33 I'm going to "make up" 2.4 as the VRM spec for the Opterons.
34 No good reason just a mnemonic for the 24x Opteron processor
35 series
36
37 Opteron VID encoding is:
38
39 00000 = 1.550 V
40 00001 = 1.525 V
41 . . . .
42 11110 = 0.800 V
43 11111 = 0.000 V (off)
44 */
45
46/*
47 Legal val values 0x00 - 0x1f; except for VRD 10.0, 0x00 - 0x3f.
48 vrm is the Intel VRM document version.
49 Note: vrm version is scaled by 10 and the return value is scaled by 1000
50 to avoid floating point in the kernel.
51*/
52
53int i2c_which_vrm(void);
54
55#define DEFAULT_VRM 82
56
57static inline int vid_from_reg(int val, int vrm)
58{
59 int vid;
60
61 switch(vrm) {
62
63 case 0:
64 return 0;
65
66 case 100: /* VRD 10.0 */
67 if((val & 0x1f) == 0x1f)
68 return 0;
69 if((val & 0x1f) <= 0x09 || val == 0x0a)
70 vid = 10875 - (val & 0x1f) * 250;
71 else
72 vid = 18625 - (val & 0x1f) * 250;
73 if(val & 0x20)
74 vid -= 125;
75 vid /= 10; /* only return 3 dec. places for now */
76 return vid;
77
78 case 24: /* Opteron processor */
79 return(val == 0x1f ? 0 : 1550 - val * 25);
80
81 case 91: /* VRM 9.1 */
82 case 90: /* VRM 9.0 */
83 return(val == 0x1f ? 0 :
84 1850 - val * 25);
85
86 case 85: /* VRM 8.5 */
87 return((val & 0x10 ? 25 : 0) +
88 ((val & 0x0f) > 0x04 ? 2050 : 1250) -
89 ((val & 0x0f) * 50));
90
91 case 84: /* VRM 8.4 */
92 val &= 0x0f;
93 /* fall through */
94 default: /* VRM 8.2 */
95 return(val == 0x1f ? 0 :
96 val & 0x10 ? 5100 - (val) * 100 :
97 2050 - (val) * 50);
98 }
99}
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
new file mode 100644
index 000000000000..ebcd745f4cd6
--- /dev/null
+++ b/include/linux/i2c.h
@@ -0,0 +1,594 @@
1/* ------------------------------------------------------------------------- */
2/* */
3/* i2c.h - definitions for the i2c-bus interface */
4/* */
5/* ------------------------------------------------------------------------- */
6/* Copyright (C) 1995-2000 Simon G. Vogl
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
21/* ------------------------------------------------------------------------- */
22
23/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and
24 Frodo Looijaard <frodol@dds.nl> */
25
26/* $Id: i2c.h,v 1.68 2003/01/21 08:08:16 kmalkki Exp $ */
27
28#ifndef _LINUX_I2C_H
29#define _LINUX_I2C_H
30
31#include <linux/module.h>
32#include <linux/types.h>
33#include <linux/i2c-id.h>
34#include <linux/device.h> /* for struct device */
35#include <asm/semaphore.h>
36
37/* --- General options ------------------------------------------------ */
38
39struct i2c_msg;
40struct i2c_algorithm;
41struct i2c_adapter;
42struct i2c_client;
43struct i2c_driver;
44struct i2c_client_address_data;
45union i2c_smbus_data;
46
47/*
48 * The master routines are the ones normally used to transmit data to devices
49 * on a bus (or read from them). Apart from two basic transfer functions to
50 * transmit one message at a time, a more complex version can be used to
51 * transmit an arbitrary number of messages without interruption.
52 */
53extern int i2c_master_send(struct i2c_client *,const char* ,int);
54extern int i2c_master_recv(struct i2c_client *,char* ,int);
55
56/* Transfer num messages.
57 */
58extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num);
59
60/*
61 * Some adapter types (i.e. PCF 8584 based ones) may support slave behaviuor.
62 * This is not tested/implemented yet and will change in the future.
63 */
64extern int i2c_slave_send(struct i2c_client *,char*,int);
65extern int i2c_slave_recv(struct i2c_client *,char*,int);
66
67
68
69/* This is the very generalized SMBus access routine. You probably do not
70 want to use this, though; one of the functions below may be much easier,
71 and probably just as fast.
72 Note that we use i2c_adapter here, because you do not need a specific
73 smbus adapter to call this function. */
74extern s32 i2c_smbus_xfer (struct i2c_adapter * adapter, u16 addr,
75 unsigned short flags,
76 char read_write, u8 command, int size,
77 union i2c_smbus_data * data);
78
79/* Now follow the 'nice' access routines. These also document the calling
80 conventions of smbus_access. */
81
82extern s32 i2c_smbus_write_quick(struct i2c_client * client, u8 value);
83extern s32 i2c_smbus_read_byte(struct i2c_client * client);
84extern s32 i2c_smbus_write_byte(struct i2c_client * client, u8 value);
85extern s32 i2c_smbus_read_byte_data(struct i2c_client * client, u8 command);
86extern s32 i2c_smbus_write_byte_data(struct i2c_client * client,
87 u8 command, u8 value);
88extern s32 i2c_smbus_read_word_data(struct i2c_client * client, u8 command);
89extern s32 i2c_smbus_write_word_data(struct i2c_client * client,
90 u8 command, u16 value);
91/* Returns the number of bytes transferred */
92extern s32 i2c_smbus_write_block_data(struct i2c_client * client,
93 u8 command, u8 length,
94 u8 *values);
95extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client * client,
96 u8 command, u8 *values);
97
98/*
99 * A driver is capable of handling one or more physical devices present on
100 * I2C adapters. This information is used to inform the driver of adapter
101 * events.
102 */
103
104struct i2c_driver {
105 struct module *owner;
106 char name[32];
107 int id;
108 unsigned int class;
109 unsigned int flags; /* div., see below */
110
111 /* Notifies the driver that a new bus has appeared. This routine
112 * can be used by the driver to test if the bus meets its conditions
113 * & seek for the presence of the chip(s) it supports. If found, it
114 * registers the client(s) that are on the bus to the i2c admin. via
115 * i2c_attach_client.
116 */
117 int (*attach_adapter)(struct i2c_adapter *);
118 int (*detach_adapter)(struct i2c_adapter *);
119
120 /* tells the driver that a client is about to be deleted & gives it
121 * the chance to remove its private data. Also, if the client struct
122 * has been dynamically allocated by the driver in the function above,
123 * it must be freed here.
124 */
125 int (*detach_client)(struct i2c_client *);
126
127 /* a ioctl like command that can be used to perform specific functions
128 * with the device.
129 */
130 int (*command)(struct i2c_client *client,unsigned int cmd, void *arg);
131
132 struct device_driver driver;
133 struct list_head list;
134};
135#define to_i2c_driver(d) container_of(d, struct i2c_driver, driver)
136
137#define I2C_NAME_SIZE 50
138
139/*
140 * i2c_client identifies a single device (i.e. chip) that is connected to an
141 * i2c bus. The behaviour is defined by the routines of the driver. This
142 * function is mainly used for lookup & other admin. functions.
143 */
144struct i2c_client {
145 unsigned int flags; /* div., see below */
146 unsigned int addr; /* chip address - NOTE: 7bit */
147 /* addresses are stored in the */
148 /* _LOWER_ 7 bits of this char */
149 /* addr: unsigned int to make lm_sensors i2c-isa adapter work
150 more cleanly. It does not take any more memory space, due to
151 alignment considerations */
152 struct i2c_adapter *adapter; /* the adapter we sit on */
153 struct i2c_driver *driver; /* and our access routines */
154 int usage_count; /* How many accesses currently */
155 /* to the client */
156 struct device dev; /* the device structure */
157 struct list_head list;
158 char name[I2C_NAME_SIZE];
159 struct completion released;
160};
161#define to_i2c_client(d) container_of(d, struct i2c_client, dev)
162
163static inline void *i2c_get_clientdata (struct i2c_client *dev)
164{
165 return dev_get_drvdata (&dev->dev);
166}
167
168static inline void i2c_set_clientdata (struct i2c_client *dev, void *data)
169{
170 dev_set_drvdata (&dev->dev, data);
171}
172
173#define I2C_DEVNAME(str) .name = str
174
175static inline char *i2c_clientname(struct i2c_client *c)
176{
177 return &c->name[0];
178}
179
180/*
181 * The following structs are for those who like to implement new bus drivers:
182 * i2c_algorithm is the interface to a class of hardware solutions which can
183 * be addressed using the same bus algorithms - i.e. bit-banging or the PCF8584
184 * to name two of the most common.
185 */
186struct i2c_algorithm {
187 char name[32]; /* textual description */
188 unsigned int id;
189
190 /* If an adapter algorithm can't do I2C-level access, set master_xfer
191 to NULL. If an adapter algorithm can do SMBus access, set
192 smbus_xfer. If set to NULL, the SMBus protocol is simulated
193 using common I2C messages */
194 int (*master_xfer)(struct i2c_adapter *adap,struct i2c_msg *msgs,
195 int num);
196 int (*smbus_xfer) (struct i2c_adapter *adap, u16 addr,
197 unsigned short flags, char read_write,
198 u8 command, int size, union i2c_smbus_data * data);
199
200 /* --- these optional/future use for some adapter types.*/
201 int (*slave_send)(struct i2c_adapter *,char*,int);
202 int (*slave_recv)(struct i2c_adapter *,char*,int);
203
204 /* --- ioctl like call to set div. parameters. */
205 int (*algo_control)(struct i2c_adapter *, unsigned int, unsigned long);
206
207 /* To determine what the adapter supports */
208 u32 (*functionality) (struct i2c_adapter *);
209};
210
211/*
212 * i2c_adapter is the structure used to identify a physical i2c bus along
213 * with the access algorithms necessary to access it.
214 */
215struct i2c_adapter {
216 struct module *owner;
217 unsigned int id;/* == is algo->id | hwdep.struct->id, */
218 /* for registered values see below */
219 unsigned int class;
220 struct i2c_algorithm *algo;/* the algorithm to access the bus */
221 void *algo_data;
222
223 /* --- administration stuff. */
224 int (*client_register)(struct i2c_client *);
225 int (*client_unregister)(struct i2c_client *);
226
227 /* data fields that are valid for all devices */
228 struct semaphore bus_lock;
229 struct semaphore clist_lock;
230
231 int timeout;
232 int retries;
233 struct device dev; /* the adapter device */
234 struct class_device class_dev; /* the class device */
235
236#ifdef CONFIG_PROC_FS
237 /* No need to set this when you initialize the adapter */
238 int inode;
239#endif /* def CONFIG_PROC_FS */
240
241 int nr;
242 struct list_head clients;
243 struct list_head list;
244 char name[I2C_NAME_SIZE];
245 struct completion dev_released;
246 struct completion class_dev_released;
247};
248#define dev_to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev)
249#define class_dev_to_i2c_adapter(d) container_of(d, struct i2c_adapter, class_dev)
250
251static inline void *i2c_get_adapdata (struct i2c_adapter *dev)
252{
253 return dev_get_drvdata (&dev->dev);
254}
255
256static inline void i2c_set_adapdata (struct i2c_adapter *dev, void *data)
257{
258 dev_set_drvdata (&dev->dev, data);
259}
260
261/*flags for the driver struct: */
262#define I2C_DF_NOTIFY 0x01 /* notify on bus (de/a)ttaches */
263#if 0
264/* this flag is gone -- there is a (optional) driver->detach_adapter
265 * callback now which can be used instead */
266# define I2C_DF_DUMMY 0x02
267#endif
268
269/*flags for the client struct: */
270#define I2C_CLIENT_ALLOW_USE 0x01 /* Client allows access */
271#define I2C_CLIENT_ALLOW_MULTIPLE_USE 0x02 /* Allow multiple access-locks */
272 /* on an i2c_client */
273#define I2C_CLIENT_PEC 0x04 /* Use Packet Error Checking */
274#define I2C_CLIENT_TEN 0x10 /* we have a ten bit chip address */
275 /* Must equal I2C_M_TEN below */
276
277/* i2c adapter classes (bitmask) */
278#define I2C_CLASS_HWMON (1<<0) /* lm_sensors, ... */
279#define I2C_CLASS_TV_ANALOG (1<<1) /* bttv + friends */
280#define I2C_CLASS_TV_DIGITAL (1<<2) /* dvb cards */
281#define I2C_CLASS_DDC (1<<3) /* i2c-matroxfb ? */
282#define I2C_CLASS_CAM_ANALOG (1<<4) /* camera with analog CCD */
283#define I2C_CLASS_CAM_DIGITAL (1<<5) /* most webcams */
284#define I2C_CLASS_SOUND (1<<6) /* sound devices */
285#define I2C_CLASS_ALL (UINT_MAX) /* all of the above */
286
287/* i2c_client_address_data is the struct for holding default client
288 * addresses for a driver and for the parameters supplied on the
289 * command line
290 */
291struct i2c_client_address_data {
292 unsigned short *normal_i2c;
293 unsigned short *normal_i2c_range;
294 unsigned short *probe;
295 unsigned short *probe_range;
296 unsigned short *ignore;
297 unsigned short *ignore_range;
298 unsigned short *force;
299};
300
301/* Internal numbers to terminate lists */
302#define I2C_CLIENT_END 0xfffeU
303#define I2C_CLIENT_ISA_END 0xfffefffeU
304
305/* The numbers to use to set I2C bus address */
306#define ANY_I2C_BUS 0xffff
307#define ANY_I2C_ISA_BUS 9191
308
309
310/* ----- functions exported by i2c.o */
311
312/* administration...
313 */
314extern int i2c_add_adapter(struct i2c_adapter *);
315extern int i2c_del_adapter(struct i2c_adapter *);
316
317extern int i2c_add_driver(struct i2c_driver *);
318extern int i2c_del_driver(struct i2c_driver *);
319
320extern int i2c_attach_client(struct i2c_client *);
321extern int i2c_detach_client(struct i2c_client *);
322
323/* New function: This is to get an i2c_client-struct for controlling the
324 client either by using i2c_control-function or having the
325 client-module export functions that can be used with the i2c_client
326 -struct. */
327extern struct i2c_client *i2c_get_client(int driver_id, int adapter_id,
328 struct i2c_client *prev);
329
330/* Should be used with new function
331 extern struct i2c_client *i2c_get_client(int,int,struct i2c_client *);
332 to make sure that client-struct is valid and that it is okay to access
333 the i2c-client.
334 returns -EACCES if client doesn't allow use (default)
335 returns -EBUSY if client doesn't allow multiple use (default) and
336 usage_count >0 */
337extern int i2c_use_client(struct i2c_client *);
338extern int i2c_release_client(struct i2c_client *);
339
340/* call the i2c_client->command() of all attached clients with
341 * the given arguments */
342extern void i2c_clients_command(struct i2c_adapter *adap,
343 unsigned int cmd, void *arg);
344
345/* returns -EBUSY if address has been taken, 0 if not. Note that the only
346 other place at which this is called is within i2c_attach_client; so
347 you can cheat by simply not registering. Not recommended, of course! */
348extern int i2c_check_addr (struct i2c_adapter *adapter, int addr);
349
350/* Detect function. It iterates over all possible addresses itself.
351 * It will only call found_proc if some client is connected at the
352 * specific address (unless a 'force' matched);
353 */
354extern int i2c_probe(struct i2c_adapter *adapter,
355 struct i2c_client_address_data *address_data,
356 int (*found_proc) (struct i2c_adapter *, int, int));
357
358/* An ioctl like call to set div. parameters of the adapter.
359 */
360extern int i2c_control(struct i2c_client *,unsigned int, unsigned long);
361
362/* This call returns a unique low identifier for each registered adapter,
363 * or -1 if the adapter was not registered.
364 */
365extern int i2c_adapter_id(struct i2c_adapter *adap);
366extern struct i2c_adapter* i2c_get_adapter(int id);
367extern void i2c_put_adapter(struct i2c_adapter *adap);
368
369
370/* Return the functionality mask */
371static inline u32 i2c_get_functionality(struct i2c_adapter *adap)
372{
373 return adap->algo->functionality(adap);
374}
375
376/* Return 1 if adapter supports everything we need, 0 if not. */
377static inline int i2c_check_functionality(struct i2c_adapter *adap, u32 func)
378{
379 return (func & i2c_get_functionality(adap)) == func;
380}
381
382/*
383 * I2C Message - used for pure i2c transaction, also from /dev interface
384 */
385struct i2c_msg {
386 __u16 addr; /* slave address */
387 __u16 flags;
388#define I2C_M_TEN 0x10 /* we have a ten bit chip address */
389#define I2C_M_RD 0x01
390#define I2C_M_NOSTART 0x4000
391#define I2C_M_REV_DIR_ADDR 0x2000
392#define I2C_M_IGNORE_NAK 0x1000
393#define I2C_M_NO_RD_ACK 0x0800
394 __u16 len; /* msg length */
395 __u8 *buf; /* pointer to msg data */
396};
397
398/* To determine what functionality is present */
399
400#define I2C_FUNC_I2C 0x00000001
401#define I2C_FUNC_10BIT_ADDR 0x00000002
402#define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */
403#define I2C_FUNC_SMBUS_HWPEC_CALC 0x00000008 /* SMBus 2.0 */
404#define I2C_FUNC_SMBUS_READ_WORD_DATA_PEC 0x00000800 /* SMBus 2.0 */
405#define I2C_FUNC_SMBUS_WRITE_WORD_DATA_PEC 0x00001000 /* SMBus 2.0 */
406#define I2C_FUNC_SMBUS_PROC_CALL_PEC 0x00002000 /* SMBus 2.0 */
407#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL_PEC 0x00004000 /* SMBus 2.0 */
408#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */
409#define I2C_FUNC_SMBUS_QUICK 0x00010000
410#define I2C_FUNC_SMBUS_READ_BYTE 0x00020000
411#define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000
412#define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000
413#define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000
414#define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000
415#define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000
416#define I2C_FUNC_SMBUS_PROC_CALL 0x00800000
417#define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000
418#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000
419#define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */
420#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */
421#define I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 0x10000000 /* I2C-like block xfer */
422#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK_2 0x20000000 /* w/ 2-byte reg. addr. */
423#define I2C_FUNC_SMBUS_READ_BLOCK_DATA_PEC 0x40000000 /* SMBus 2.0 */
424#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA_PEC 0x80000000 /* SMBus 2.0 */
425
426#define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE | \
427 I2C_FUNC_SMBUS_WRITE_BYTE)
428#define I2C_FUNC_SMBUS_BYTE_DATA (I2C_FUNC_SMBUS_READ_BYTE_DATA | \
429 I2C_FUNC_SMBUS_WRITE_BYTE_DATA)
430#define I2C_FUNC_SMBUS_WORD_DATA (I2C_FUNC_SMBUS_READ_WORD_DATA | \
431 I2C_FUNC_SMBUS_WRITE_WORD_DATA)
432#define I2C_FUNC_SMBUS_BLOCK_DATA (I2C_FUNC_SMBUS_READ_BLOCK_DATA | \
433 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA)
434#define I2C_FUNC_SMBUS_I2C_BLOCK (I2C_FUNC_SMBUS_READ_I2C_BLOCK | \
435 I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)
436#define I2C_FUNC_SMBUS_I2C_BLOCK_2 (I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 | \
437 I2C_FUNC_SMBUS_WRITE_I2C_BLOCK_2)
438#define I2C_FUNC_SMBUS_BLOCK_DATA_PEC (I2C_FUNC_SMBUS_READ_BLOCK_DATA_PEC | \
439 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA_PEC)
440#define I2C_FUNC_SMBUS_WORD_DATA_PEC (I2C_FUNC_SMBUS_READ_WORD_DATA_PEC | \
441 I2C_FUNC_SMBUS_WRITE_WORD_DATA_PEC)
442
443#define I2C_FUNC_SMBUS_READ_BYTE_PEC I2C_FUNC_SMBUS_READ_BYTE_DATA
444#define I2C_FUNC_SMBUS_WRITE_BYTE_PEC I2C_FUNC_SMBUS_WRITE_BYTE_DATA
445#define I2C_FUNC_SMBUS_READ_BYTE_DATA_PEC I2C_FUNC_SMBUS_READ_WORD_DATA
446#define I2C_FUNC_SMBUS_WRITE_BYTE_DATA_PEC I2C_FUNC_SMBUS_WRITE_WORD_DATA
447#define I2C_FUNC_SMBUS_BYTE_PEC I2C_FUNC_SMBUS_BYTE_DATA
448#define I2C_FUNC_SMBUS_BYTE_DATA_PEC I2C_FUNC_SMBUS_WORD_DATA
449
450#define I2C_FUNC_SMBUS_EMUL (I2C_FUNC_SMBUS_QUICK | \
451 I2C_FUNC_SMBUS_BYTE | \
452 I2C_FUNC_SMBUS_BYTE_DATA | \
453 I2C_FUNC_SMBUS_WORD_DATA | \
454 I2C_FUNC_SMBUS_PROC_CALL | \
455 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \
456 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA_PEC | \
457 I2C_FUNC_SMBUS_I2C_BLOCK)
458
459/*
460 * Data for SMBus Messages
461 */
462#define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */
463#define I2C_SMBUS_I2C_BLOCK_MAX 32 /* Not specified but we use same structure */
464union i2c_smbus_data {
465 __u8 byte;
466 __u16 word;
467 __u8 block[I2C_SMBUS_BLOCK_MAX + 3]; /* block[0] is used for length */
468 /* one more for read length in block process call */
469 /* and one more for PEC */
470};
471
472/* smbus_access read or write markers */
473#define I2C_SMBUS_READ 1
474#define I2C_SMBUS_WRITE 0
475
476/* SMBus transaction types (size parameter in the above functions)
477 Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */
478#define I2C_SMBUS_QUICK 0
479#define I2C_SMBUS_BYTE 1
480#define I2C_SMBUS_BYTE_DATA 2
481#define I2C_SMBUS_WORD_DATA 3
482#define I2C_SMBUS_PROC_CALL 4
483#define I2C_SMBUS_BLOCK_DATA 5
484#define I2C_SMBUS_I2C_BLOCK_DATA 6
485#define I2C_SMBUS_BLOCK_PROC_CALL 7 /* SMBus 2.0 */
486#define I2C_SMBUS_BLOCK_DATA_PEC 8 /* SMBus 2.0 */
487#define I2C_SMBUS_PROC_CALL_PEC 9 /* SMBus 2.0 */
488#define I2C_SMBUS_BLOCK_PROC_CALL_PEC 10 /* SMBus 2.0 */
489#define I2C_SMBUS_WORD_DATA_PEC 11 /* SMBus 2.0 */
490
491
492/* ----- commands for the ioctl like i2c_command call:
493 * note that additional calls are defined in the algorithm and hw
494 * dependent layers - these can be listed here, or see the
495 * corresponding header files.
496 */
497 /* -> bit-adapter specific ioctls */
498#define I2C_RETRIES 0x0701 /* number of times a device address */
499 /* should be polled when not */
500 /* acknowledging */
501#define I2C_TIMEOUT 0x0702 /* set timeout - call with int */
502
503
504/* this is for i2c-dev.c */
505#define I2C_SLAVE 0x0703 /* Change slave address */
506 /* Attn.: Slave address is 7 or 10 bits */
507#define I2C_SLAVE_FORCE 0x0706 /* Change slave address */
508 /* Attn.: Slave address is 7 or 10 bits */
509 /* This changes the address, even if it */
510 /* is already taken! */
511#define I2C_TENBIT 0x0704 /* 0 for 7 bit addrs, != 0 for 10 bit */
512
513#define I2C_FUNCS 0x0705 /* Get the adapter functionality */
514#define I2C_RDWR 0x0707 /* Combined R/W transfer (one stop only)*/
515#define I2C_PEC 0x0708 /* != 0 for SMBus PEC */
516#if 0
517#define I2C_ACK_TEST 0x0710 /* See if a slave is at a specific address */
518#endif
519
520#define I2C_SMBUS 0x0720 /* SMBus-level access */
521
522/* ... algo-bit.c recognizes */
523#define I2C_UDELAY 0x0705 /* set delay in microsecs between each */
524 /* written byte (except address) */
525#define I2C_MDELAY 0x0706 /* millisec delay between written bytes */
526
527/* ----- I2C-DEV: char device interface stuff ------------------------- */
528
529#define I2C_MAJOR 89 /* Device major number */
530
531/* These defines are used for probing i2c client addresses */
532/* The length of the option lists */
533#define I2C_CLIENT_MAX_OPTS 48
534
535/* Default fill of many variables */
536#define I2C_CLIENT_DEFAULTS {I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
537 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
538 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
539 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
540 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
541 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
542 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
543 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
544 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
545 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
546 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
547 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
548 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
549 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
550 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
551 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END}
552
553/* I2C_CLIENT_MODULE_PARM creates a module parameter, and puts it in the
554 module header */
555
556#define I2C_CLIENT_MODULE_PARM(var,desc) \
557 static unsigned short var[I2C_CLIENT_MAX_OPTS] = I2C_CLIENT_DEFAULTS; \
558 static unsigned int var##_num; \
559 module_param_array(var, short, &var##_num, 0); \
560 MODULE_PARM_DESC(var,desc)
561
562/* This is the one you want to use in your own modules */
563#define I2C_CLIENT_INSMOD \
564 I2C_CLIENT_MODULE_PARM(probe, \
565 "List of adapter,address pairs to scan additionally"); \
566 I2C_CLIENT_MODULE_PARM(probe_range, \
567 "List of adapter,start-addr,end-addr triples to scan " \
568 "additionally"); \
569 I2C_CLIENT_MODULE_PARM(ignore, \
570 "List of adapter,address pairs not to scan"); \
571 I2C_CLIENT_MODULE_PARM(ignore_range, \
572 "List of adapter,start-addr,end-addr triples not to " \
573 "scan"); \
574 I2C_CLIENT_MODULE_PARM(force, \
575 "List of adapter,address pairs to boldly assume " \
576 "to be present"); \
577 static struct i2c_client_address_data addr_data = { \
578 .normal_i2c = normal_i2c, \
579 .normal_i2c_range = normal_i2c_range, \
580 .probe = probe, \
581 .probe_range = probe_range, \
582 .ignore = ignore, \
583 .ignore_range = ignore_range, \
584 .force = force, \
585 }
586
587/* Detect whether we are on the isa bus. If this returns true, all i2c
588 access will fail! */
589#define i2c_is_isa_client(clientptr) \
590 ((clientptr)->adapter->algo->id == I2C_ALGO_ISA)
591#define i2c_is_isa_adapter(adapptr) \
592 ((adapptr)->algo->id == I2C_ALGO_ISA)
593
594#endif /* _LINUX_I2C_H */
diff --git a/include/linux/i2o-dev.h b/include/linux/i2o-dev.h
new file mode 100644
index 000000000000..ef7f644dd873
--- /dev/null
+++ b/include/linux/i2o-dev.h
@@ -0,0 +1,402 @@
1/*
2 * I2O user space accessible structures/APIs
3 *
4 * (c) Copyright 1999, 2000 Red Hat Software
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 *************************************************************************
12 *
13 * This header file defines the I2O APIs that are available to both
14 * the kernel and user level applications. Kernel specific structures
15 * are defined in i2o_osm. OSMs should include _only_ i2o_osm.h which
16 * automatically includs this file.
17 *
18 */
19
20#ifndef _I2O_DEV_H
21#define _I2O_DEV_H
22
23/* How many controllers are we allowing */
24#define MAX_I2O_CONTROLLERS 32
25
26//#include <linux/ioctl.h>
27
28/*
29 * I2O Control IOCTLs and structures
30 */
31#define I2O_MAGIC_NUMBER 'i'
32#define I2OGETIOPS _IOR(I2O_MAGIC_NUMBER,0,u8[MAX_I2O_CONTROLLERS])
33#define I2OHRTGET _IOWR(I2O_MAGIC_NUMBER,1,struct i2o_cmd_hrtlct)
34#define I2OLCTGET _IOWR(I2O_MAGIC_NUMBER,2,struct i2o_cmd_hrtlct)
35#define I2OPARMSET _IOWR(I2O_MAGIC_NUMBER,3,struct i2o_cmd_psetget)
36#define I2OPARMGET _IOWR(I2O_MAGIC_NUMBER,4,struct i2o_cmd_psetget)
37#define I2OSWDL _IOWR(I2O_MAGIC_NUMBER,5,struct i2o_sw_xfer)
38#define I2OSWUL _IOWR(I2O_MAGIC_NUMBER,6,struct i2o_sw_xfer)
39#define I2OSWDEL _IOWR(I2O_MAGIC_NUMBER,7,struct i2o_sw_xfer)
40#define I2OVALIDATE _IOR(I2O_MAGIC_NUMBER,8,u32)
41#define I2OHTML _IOWR(I2O_MAGIC_NUMBER,9,struct i2o_html)
42#define I2OEVTREG _IOW(I2O_MAGIC_NUMBER,10,struct i2o_evt_id)
43#define I2OEVTGET _IOR(I2O_MAGIC_NUMBER,11,struct i2o_evt_info)
44#define I2OPASSTHRU _IOR(I2O_MAGIC_NUMBER,12,struct i2o_cmd_passthru)
45#define I2OPASSTHRU32 _IOR(I2O_MAGIC_NUMBER,12,struct i2o_cmd_passthru32)
46
47struct i2o_cmd_passthru32 {
48 unsigned int iop; /* IOP unit number */
49 u32 msg; /* message */
50};
51
52struct i2o_cmd_passthru {
53 unsigned int iop; /* IOP unit number */
54 void __user *msg; /* message */
55};
56
57struct i2o_cmd_hrtlct {
58 unsigned int iop; /* IOP unit number */
59 void __user *resbuf; /* Buffer for result */
60 unsigned int __user *reslen; /* Buffer length in bytes */
61};
62
63struct i2o_cmd_psetget {
64 unsigned int iop; /* IOP unit number */
65 unsigned int tid; /* Target device TID */
66 void __user *opbuf; /* Operation List buffer */
67 unsigned int oplen; /* Operation List buffer length in bytes */
68 void __user *resbuf; /* Result List buffer */
69 unsigned int __user *reslen; /* Result List buffer length in bytes */
70};
71
72struct i2o_sw_xfer {
73 unsigned int iop; /* IOP unit number */
74 unsigned char flags; /* Flags field */
75 unsigned char sw_type; /* Software type */
76 unsigned int sw_id; /* Software ID */
77 void __user *buf; /* Pointer to software buffer */
78 unsigned int __user *swlen; /* Length of software data */
79 unsigned int __user *maxfrag; /* Maximum fragment count */
80 unsigned int __user *curfrag; /* Current fragment count */
81};
82
83struct i2o_html {
84 unsigned int iop; /* IOP unit number */
85 unsigned int tid; /* Target device ID */
86 unsigned int page; /* HTML page */
87 void __user *resbuf; /* Buffer for reply HTML page */
88 unsigned int __user *reslen; /* Length in bytes of reply buffer */
89 void __user *qbuf; /* Pointer to HTTP query string */
90 unsigned int qlen; /* Length in bytes of query string buffer */
91};
92
93#define I2O_EVT_Q_LEN 32
94
95struct i2o_evt_id {
96 unsigned int iop;
97 unsigned int tid;
98 unsigned int evt_mask;
99};
100
101/* Event data size = frame size - message header + evt indicator */
102#define I2O_EVT_DATA_SIZE 88
103
104struct i2o_evt_info {
105 struct i2o_evt_id id;
106 unsigned char evt_data[I2O_EVT_DATA_SIZE];
107 unsigned int data_size;
108};
109
110struct i2o_evt_get {
111 struct i2o_evt_info info;
112 int pending;
113 int lost;
114};
115
116/**************************************************************************
117 * HRT related constants and structures
118 **************************************************************************/
119#define I2O_BUS_LOCAL 0
120#define I2O_BUS_ISA 1
121#define I2O_BUS_EISA 2
122#define I2O_BUS_MCA 3
123#define I2O_BUS_PCI 4
124#define I2O_BUS_PCMCIA 5
125#define I2O_BUS_NUBUS 6
126#define I2O_BUS_CARDBUS 7
127#define I2O_BUS_UNKNOWN 0x80
128
129#ifndef __KERNEL__
130
131typedef unsigned char u8;
132typedef unsigned short u16;
133typedef unsigned int u32;
134
135#endif /* __KERNEL__ */
136
137typedef struct _i2o_pci_bus {
138 u8 PciFunctionNumber;
139 u8 PciDeviceNumber;
140 u8 PciBusNumber;
141 u8 reserved;
142 u16 PciVendorID;
143 u16 PciDeviceID;
144} i2o_pci_bus;
145
146typedef struct _i2o_local_bus {
147 u16 LbBaseIOPort;
148 u16 reserved;
149 u32 LbBaseMemoryAddress;
150} i2o_local_bus;
151
152typedef struct _i2o_isa_bus {
153 u16 IsaBaseIOPort;
154 u8 CSN;
155 u8 reserved;
156 u32 IsaBaseMemoryAddress;
157} i2o_isa_bus;
158
159typedef struct _i2o_eisa_bus_info {
160 u16 EisaBaseIOPort;
161 u8 reserved;
162 u8 EisaSlotNumber;
163 u32 EisaBaseMemoryAddress;
164} i2o_eisa_bus;
165
166typedef struct _i2o_mca_bus {
167 u16 McaBaseIOPort;
168 u8 reserved;
169 u8 McaSlotNumber;
170 u32 McaBaseMemoryAddress;
171} i2o_mca_bus;
172
173typedef struct _i2o_other_bus {
174 u16 BaseIOPort;
175 u16 reserved;
176 u32 BaseMemoryAddress;
177} i2o_other_bus;
178
179typedef struct _i2o_hrt_entry {
180 u32 adapter_id;
181 u32 parent_tid:12;
182 u32 state:4;
183 u32 bus_num:8;
184 u32 bus_type:8;
185 union {
186 i2o_pci_bus pci_bus;
187 i2o_local_bus local_bus;
188 i2o_isa_bus isa_bus;
189 i2o_eisa_bus eisa_bus;
190 i2o_mca_bus mca_bus;
191 i2o_other_bus other_bus;
192 } bus;
193} i2o_hrt_entry;
194
195typedef struct _i2o_hrt {
196 u16 num_entries;
197 u8 entry_len;
198 u8 hrt_version;
199 u32 change_ind;
200 i2o_hrt_entry hrt_entry[1];
201} i2o_hrt;
202
203typedef struct _i2o_lct_entry {
204 u32 entry_size:16;
205 u32 tid:12;
206 u32 reserved:4;
207 u32 change_ind;
208 u32 device_flags;
209 u32 class_id:12;
210 u32 version:4;
211 u32 vendor_id:16;
212 u32 sub_class;
213 u32 user_tid:12;
214 u32 parent_tid:12;
215 u32 bios_info:8;
216 u8 identity_tag[8];
217 u32 event_capabilities;
218} i2o_lct_entry;
219
220typedef struct _i2o_lct {
221 u32 table_size:16;
222 u32 boot_tid:12;
223 u32 lct_ver:4;
224 u32 iop_flags;
225 u32 change_ind;
226 i2o_lct_entry lct_entry[1];
227} i2o_lct;
228
229typedef struct _i2o_status_block {
230 u16 org_id;
231 u16 reserved;
232 u16 iop_id:12;
233 u16 reserved1:4;
234 u16 host_unit_id;
235 u16 segment_number:12;
236 u16 i2o_version:4;
237 u8 iop_state;
238 u8 msg_type;
239 u16 inbound_frame_size;
240 u8 init_code;
241 u8 reserved2;
242 u32 max_inbound_frames;
243 u32 cur_inbound_frames;
244 u32 max_outbound_frames;
245 char product_id[24];
246 u32 expected_lct_size;
247 u32 iop_capabilities;
248 u32 desired_mem_size;
249 u32 current_mem_size;
250 u32 current_mem_base;
251 u32 desired_io_size;
252 u32 current_io_size;
253 u32 current_io_base;
254 u32 reserved3:24;
255 u32 cmd_status:8;
256} i2o_status_block;
257
258/* Event indicator mask flags */
259#define I2O_EVT_IND_STATE_CHANGE 0x80000000
260#define I2O_EVT_IND_GENERAL_WARNING 0x40000000
261#define I2O_EVT_IND_CONFIGURATION_FLAG 0x20000000
262#define I2O_EVT_IND_LOCK_RELEASE 0x10000000
263#define I2O_EVT_IND_CAPABILITY_CHANGE 0x08000000
264#define I2O_EVT_IND_DEVICE_RESET 0x04000000
265#define I2O_EVT_IND_EVT_MASK_MODIFIED 0x02000000
266#define I2O_EVT_IND_FIELD_MODIFIED 0x01000000
267#define I2O_EVT_IND_VENDOR_EVT 0x00800000
268#define I2O_EVT_IND_DEVICE_STATE 0x00400000
269
270/* Executive event indicitors */
271#define I2O_EVT_IND_EXEC_RESOURCE_LIMITS 0x00000001
272#define I2O_EVT_IND_EXEC_CONNECTION_FAIL 0x00000002
273#define I2O_EVT_IND_EXEC_ADAPTER_FAULT 0x00000004
274#define I2O_EVT_IND_EXEC_POWER_FAIL 0x00000008
275#define I2O_EVT_IND_EXEC_RESET_PENDING 0x00000010
276#define I2O_EVT_IND_EXEC_RESET_IMMINENT 0x00000020
277#define I2O_EVT_IND_EXEC_HW_FAIL 0x00000040
278#define I2O_EVT_IND_EXEC_XCT_CHANGE 0x00000080
279#define I2O_EVT_IND_EXEC_NEW_LCT_ENTRY 0x00000100
280#define I2O_EVT_IND_EXEC_MODIFIED_LCT 0x00000200
281#define I2O_EVT_IND_EXEC_DDM_AVAILABILITY 0x00000400
282
283/* Random Block Storage Event Indicators */
284#define I2O_EVT_IND_BSA_VOLUME_LOAD 0x00000001
285#define I2O_EVT_IND_BSA_VOLUME_UNLOAD 0x00000002
286#define I2O_EVT_IND_BSA_VOLUME_UNLOAD_REQ 0x00000004
287#define I2O_EVT_IND_BSA_CAPACITY_CHANGE 0x00000008
288#define I2O_EVT_IND_BSA_SCSI_SMART 0x00000010
289
290/* Event data for generic events */
291#define I2O_EVT_STATE_CHANGE_NORMAL 0x00
292#define I2O_EVT_STATE_CHANGE_SUSPENDED 0x01
293#define I2O_EVT_STATE_CHANGE_RESTART 0x02
294#define I2O_EVT_STATE_CHANGE_NA_RECOVER 0x03
295#define I2O_EVT_STATE_CHANGE_NA_NO_RECOVER 0x04
296#define I2O_EVT_STATE_CHANGE_QUIESCE_REQUEST 0x05
297#define I2O_EVT_STATE_CHANGE_FAILED 0x10
298#define I2O_EVT_STATE_CHANGE_FAULTED 0x11
299
300#define I2O_EVT_GEN_WARNING_NORMAL 0x00
301#define I2O_EVT_GEN_WARNING_ERROR_THRESHOLD 0x01
302#define I2O_EVT_GEN_WARNING_MEDIA_FAULT 0x02
303
304#define I2O_EVT_CAPABILITY_OTHER 0x01
305#define I2O_EVT_CAPABILITY_CHANGED 0x02
306
307#define I2O_EVT_SENSOR_STATE_CHANGED 0x01
308
309/*
310 * I2O classes / subclasses
311 */
312
313/* Class ID and Code Assignments
314 * (LCT.ClassID.Version field)
315 */
316#define I2O_CLASS_VERSION_10 0x00
317#define I2O_CLASS_VERSION_11 0x01
318
319/* Class code names
320 * (from v1.5 Table 6-1 Class Code Assignments.)
321 */
322
323#define I2O_CLASS_EXECUTIVE 0x000
324#define I2O_CLASS_DDM 0x001
325#define I2O_CLASS_RANDOM_BLOCK_STORAGE 0x010
326#define I2O_CLASS_SEQUENTIAL_STORAGE 0x011
327#define I2O_CLASS_LAN 0x020
328#define I2O_CLASS_WAN 0x030
329#define I2O_CLASS_FIBRE_CHANNEL_PORT 0x040
330#define I2O_CLASS_FIBRE_CHANNEL_PERIPHERAL 0x041
331#define I2O_CLASS_SCSI_PERIPHERAL 0x051
332#define I2O_CLASS_ATE_PORT 0x060
333#define I2O_CLASS_ATE_PERIPHERAL 0x061
334#define I2O_CLASS_FLOPPY_CONTROLLER 0x070
335#define I2O_CLASS_FLOPPY_DEVICE 0x071
336#define I2O_CLASS_BUS_ADAPTER_PORT 0x080
337#define I2O_CLASS_PEER_TRANSPORT_AGENT 0x090
338#define I2O_CLASS_PEER_TRANSPORT 0x091
339#define I2O_CLASS_END 0xfff
340
341/*
342 * Rest of 0x092 - 0x09f reserved for peer-to-peer classes
343 */
344
345#define I2O_CLASS_MATCH_ANYCLASS 0xffffffff
346
347/*
348 * Subclasses
349 */
350
351#define I2O_SUBCLASS_i960 0x001
352#define I2O_SUBCLASS_HDM 0x020
353#define I2O_SUBCLASS_ISM 0x021
354
355/* Operation functions */
356
357#define I2O_PARAMS_FIELD_GET 0x0001
358#define I2O_PARAMS_LIST_GET 0x0002
359#define I2O_PARAMS_MORE_GET 0x0003
360#define I2O_PARAMS_SIZE_GET 0x0004
361#define I2O_PARAMS_TABLE_GET 0x0005
362#define I2O_PARAMS_FIELD_SET 0x0006
363#define I2O_PARAMS_LIST_SET 0x0007
364#define I2O_PARAMS_ROW_ADD 0x0008
365#define I2O_PARAMS_ROW_DELETE 0x0009
366#define I2O_PARAMS_TABLE_CLEAR 0x000A
367
368/*
369 * I2O serial number conventions / formats
370 * (circa v1.5)
371 */
372
373#define I2O_SNFORMAT_UNKNOWN 0
374#define I2O_SNFORMAT_BINARY 1
375#define I2O_SNFORMAT_ASCII 2
376#define I2O_SNFORMAT_UNICODE 3
377#define I2O_SNFORMAT_LAN48_MAC 4
378#define I2O_SNFORMAT_WAN 5
379
380/*
381 * Plus new in v2.0 (Yellowstone pdf doc)
382 */
383
384#define I2O_SNFORMAT_LAN64_MAC 6
385#define I2O_SNFORMAT_DDM 7
386#define I2O_SNFORMAT_IEEE_REG64 8
387#define I2O_SNFORMAT_IEEE_REG128 9
388#define I2O_SNFORMAT_UNKNOWN2 0xff
389
390/*
391 * I2O Get Status State values
392 */
393
394#define ADAPTER_STATE_INITIALIZING 0x01
395#define ADAPTER_STATE_RESET 0x02
396#define ADAPTER_STATE_HOLD 0x04
397#define ADAPTER_STATE_READY 0x05
398#define ADAPTER_STATE_OPERATIONAL 0x08
399#define ADAPTER_STATE_FAILED 0x10
400#define ADAPTER_STATE_FAULTED 0x11
401
402#endif /* _I2O_DEV_H */
diff --git a/include/linux/i2o.h b/include/linux/i2o.h
new file mode 100644
index 000000000000..ea9a3ad4b67f
--- /dev/null
+++ b/include/linux/i2o.h
@@ -0,0 +1,1003 @@
1/*
2 * I2O kernel space accessible structures/APIs
3 *
4 * (c) Copyright 1999, 2000 Red Hat Software
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 *************************************************************************
12 *
13 * This header file defined the I2O APIs/structures for use by
14 * the I2O kernel modules.
15 *
16 */
17
18#ifndef _I2O_H
19#define _I2O_H
20
21#ifdef __KERNEL__ /* This file to be included by kernel only */
22
23#include <linux/i2o-dev.h>
24
25/* How many different OSM's are we allowing */
26#define I2O_MAX_DRIVERS 8
27
28#include <asm/io.h>
29#include <asm/semaphore.h> /* Needed for MUTEX init macros */
30#include <linux/pci.h>
31#include <linux/dma-mapping.h>
32
33/* message queue empty */
34#define I2O_QUEUE_EMPTY 0xffffffff
35
36/*
37 * Message structures
38 */
39struct i2o_message {
40 union {
41 struct {
42 u8 version_offset;
43 u8 flags;
44 u16 size;
45 u32 target_tid:12;
46 u32 init_tid:12;
47 u32 function:8;
48 u32 icntxt; /* initiator context */
49 u32 tcntxt; /* transaction context */
50 } s;
51 u32 head[4];
52 } u;
53 /* List follows */
54 u32 body[0];
55};
56
57/*
58 * Each I2O device entity has one of these. There is one per device.
59 */
60struct i2o_device {
61 i2o_lct_entry lct_data; /* Device LCT information */
62
63 struct i2o_controller *iop; /* Controlling IOP */
64 struct list_head list; /* node in IOP devices list */
65
66 struct device device;
67
68 struct semaphore lock; /* device lock */
69
70 struct class_device classdev; /* i2o device class */
71};
72
73/*
74 * Event structure provided to the event handling function
75 */
76struct i2o_event {
77 struct work_struct work;
78 struct i2o_device *i2o_dev; /* I2O device pointer from which the
79 event reply was initiated */
80 u16 size; /* Size of data in 32-bit words */
81 u32 tcntxt; /* Transaction context used at
82 registration */
83 u32 event_indicator; /* Event indicator from reply */
84 u32 data[0]; /* Event data from reply */
85};
86
87/*
88 * I2O classes which could be handled by the OSM
89 */
90struct i2o_class_id {
91 u16 class_id:12;
92};
93
94/*
95 * I2O driver structure for OSMs
96 */
97struct i2o_driver {
98 char *name; /* OSM name */
99 int context; /* Low 8 bits of the transaction info */
100 struct i2o_class_id *classes; /* I2O classes that this OSM handles */
101
102 /* Message reply handler */
103 int (*reply) (struct i2o_controller *, u32, struct i2o_message *);
104
105 /* Event handler */
106 void (*event) (struct i2o_event *);
107
108 struct workqueue_struct *event_queue; /* Event queue */
109
110 struct device_driver driver;
111
112 /* notification of changes */
113 void (*notify_controller_add) (struct i2o_controller *);
114 void (*notify_controller_remove) (struct i2o_controller *);
115 void (*notify_device_add) (struct i2o_device *);
116 void (*notify_device_remove) (struct i2o_device *);
117
118 struct semaphore lock;
119};
120
121/*
122 * Contains all information which are necessary for DMA operations
123 */
124struct i2o_dma {
125 void *virt;
126 dma_addr_t phys;
127 u32 len;
128};
129
130/*
131 * Context queue entry, used for 32-bit context on 64-bit systems
132 */
133struct i2o_context_list_element {
134 struct list_head list;
135 u32 context;
136 void *ptr;
137 unsigned long timestamp;
138};
139
140/*
141 * Each I2O controller has one of these objects
142 */
143struct i2o_controller {
144 char name[16];
145 int unit;
146 int type;
147
148 struct pci_dev *pdev; /* PCI device */
149
150 unsigned int short_req:1; /* use small block sizes */
151 unsigned int no_quiesce:1; /* dont quiesce before reset */
152 unsigned int raptor:1; /* split bar */
153 unsigned int promise:1; /* Promise controller */
154
155#ifdef CONFIG_MTRR
156 int mtrr_reg0;
157 int mtrr_reg1;
158#endif
159
160 struct list_head devices; /* list of I2O devices */
161
162 struct notifier_block *event_notifer; /* Events */
163 atomic_t users;
164 struct list_head list; /* Controller list */
165 void __iomem *post_port; /* Inbout port address */
166 void __iomem *reply_port; /* Outbound port address */
167 void __iomem *irq_mask; /* Interrupt register address */
168
169 /* Dynamic LCT related data */
170
171 struct i2o_dma status; /* status of IOP */
172
173 struct i2o_dma hrt; /* HW Resource Table */
174 i2o_lct *lct; /* Logical Config Table */
175 struct i2o_dma dlct; /* Temp LCT */
176 struct semaphore lct_lock; /* Lock for LCT updates */
177 struct i2o_dma status_block; /* IOP status block */
178
179 struct i2o_dma base; /* controller messaging unit */
180 struct i2o_dma in_queue; /* inbound message queue Host->IOP */
181 struct i2o_dma out_queue; /* outbound message queue IOP->Host */
182
183 unsigned int battery:1; /* Has a battery backup */
184 unsigned int io_alloc:1; /* An I/O resource was allocated */
185 unsigned int mem_alloc:1; /* A memory resource was allocated */
186
187 struct resource io_resource; /* I/O resource allocated to the IOP */
188 struct resource mem_resource; /* Mem resource allocated to the IOP */
189
190 struct proc_dir_entry *proc_entry; /* /proc dir */
191
192 struct list_head bus_list; /* list of busses on IOP */
193 struct device device;
194 struct i2o_device *exec; /* Executive */
195#if BITS_PER_LONG == 64
196 spinlock_t context_list_lock; /* lock for context_list */
197 atomic_t context_list_counter; /* needed for unique contexts */
198 struct list_head context_list; /* list of context id's
199 and pointers */
200#endif
201 spinlock_t lock; /* lock for controller
202 configuration */
203
204 void *driver_data[I2O_MAX_DRIVERS]; /* storage for drivers */
205};
206
207/*
208 * I2O System table entry
209 *
210 * The system table contains information about all the IOPs in the
211 * system. It is sent to all IOPs so that they can create peer2peer
212 * connections between them.
213 */
214struct i2o_sys_tbl_entry {
215 u16 org_id;
216 u16 reserved1;
217 u32 iop_id:12;
218 u32 reserved2:20;
219 u16 seg_num:12;
220 u16 i2o_version:4;
221 u8 iop_state;
222 u8 msg_type;
223 u16 frame_size;
224 u16 reserved3;
225 u32 last_changed;
226 u32 iop_capabilities;
227 u32 inbound_low;
228 u32 inbound_high;
229};
230
231struct i2o_sys_tbl {
232 u8 num_entries;
233 u8 version;
234 u16 reserved1;
235 u32 change_ind;
236 u32 reserved2;
237 u32 reserved3;
238 struct i2o_sys_tbl_entry iops[0];
239};
240
241extern struct list_head i2o_controllers;
242
243/* Message functions */
244static inline u32 i2o_msg_get(struct i2o_controller *, struct i2o_message __iomem **);
245extern u32 i2o_msg_get_wait(struct i2o_controller *, struct i2o_message __iomem **,
246 int);
247static inline void i2o_msg_post(struct i2o_controller *, u32);
248static inline int i2o_msg_post_wait(struct i2o_controller *, u32,
249 unsigned long);
250extern int i2o_msg_post_wait_mem(struct i2o_controller *, u32, unsigned long,
251 struct i2o_dma *);
252extern void i2o_msg_nop(struct i2o_controller *, u32);
253static inline void i2o_flush_reply(struct i2o_controller *, u32);
254
255/* DMA handling functions */
256static inline int i2o_dma_alloc(struct device *, struct i2o_dma *, size_t,
257 unsigned int);
258static inline void i2o_dma_free(struct device *, struct i2o_dma *);
259int i2o_dma_realloc(struct device *, struct i2o_dma *, size_t, unsigned int);
260
261static inline int i2o_dma_map(struct device *, struct i2o_dma *);
262static inline void i2o_dma_unmap(struct device *, struct i2o_dma *);
263
264/* IOP functions */
265extern int i2o_status_get(struct i2o_controller *);
266
267extern int i2o_event_register(struct i2o_device *, struct i2o_driver *, int,
268 u32);
269extern struct i2o_device *i2o_iop_find_device(struct i2o_controller *, u16);
270extern struct i2o_controller *i2o_find_iop(int);
271
272/* Functions needed for handling 64-bit pointers in 32-bit context */
273#if BITS_PER_LONG == 64
274extern u32 i2o_cntxt_list_add(struct i2o_controller *, void *);
275extern void *i2o_cntxt_list_get(struct i2o_controller *, u32);
276extern u32 i2o_cntxt_list_remove(struct i2o_controller *, void *);
277extern u32 i2o_cntxt_list_get_ptr(struct i2o_controller *, void *);
278
279static inline u32 i2o_ptr_low(void *ptr)
280{
281 return (u32) (u64) ptr;
282};
283
284static inline u32 i2o_ptr_high(void *ptr)
285{
286 return (u32) ((u64) ptr >> 32);
287};
288#else
289static inline u32 i2o_cntxt_list_add(struct i2o_controller *c, void *ptr)
290{
291 return (u32) ptr;
292};
293
294static inline void *i2o_cntxt_list_get(struct i2o_controller *c, u32 context)
295{
296 return (void *)context;
297};
298
299static inline u32 i2o_cntxt_list_remove(struct i2o_controller *c, void *ptr)
300{
301 return (u32) ptr;
302};
303
304static inline u32 i2o_cntxt_list_get_ptr(struct i2o_controller *c, void *ptr)
305{
306 return (u32) ptr;
307};
308
309static inline u32 i2o_ptr_low(void *ptr)
310{
311 return (u32) ptr;
312};
313
314static inline u32 i2o_ptr_high(void *ptr)
315{
316 return 0;
317};
318#endif
319
320/* I2O driver (OSM) functions */
321extern int i2o_driver_register(struct i2o_driver *);
322extern void i2o_driver_unregister(struct i2o_driver *);
323
324/**
325 * i2o_driver_notify_controller_add - Send notification of added controller
326 * to a single I2O driver
327 *
328 * Send notification of added controller to a single registered driver.
329 */
330static inline void i2o_driver_notify_controller_add(struct i2o_driver *drv,
331 struct i2o_controller *c)
332{
333 if (drv->notify_controller_add)
334 drv->notify_controller_add(c);
335};
336
337/**
338 * i2o_driver_notify_controller_remove - Send notification of removed
339 * controller to a single I2O driver
340 *
341 * Send notification of removed controller to a single registered driver.
342 */
343static inline void i2o_driver_notify_controller_remove(struct i2o_driver *drv,
344 struct i2o_controller *c)
345{
346 if (drv->notify_controller_remove)
347 drv->notify_controller_remove(c);
348};
349
350/**
351 * i2o_driver_notify_device_add - Send notification of added device to a
352 * single I2O driver
353 *
354 * Send notification of added device to a single registered driver.
355 */
356static inline void i2o_driver_notify_device_add(struct i2o_driver *drv,
357 struct i2o_device *i2o_dev)
358{
359 if (drv->notify_device_add)
360 drv->notify_device_add(i2o_dev);
361};
362
363/**
364 * i2o_driver_notify_device_remove - Send notification of removed device
365 * to a single I2O driver
366 *
367 * Send notification of removed device to a single registered driver.
368 */
369static inline void i2o_driver_notify_device_remove(struct i2o_driver *drv,
370 struct i2o_device *i2o_dev)
371{
372 if (drv->notify_device_remove)
373 drv->notify_device_remove(i2o_dev);
374};
375
376extern void i2o_driver_notify_controller_add_all(struct i2o_controller *);
377extern void i2o_driver_notify_controller_remove_all(struct i2o_controller *);
378extern void i2o_driver_notify_device_add_all(struct i2o_device *);
379extern void i2o_driver_notify_device_remove_all(struct i2o_device *);
380
381/* I2O device functions */
382extern int i2o_device_claim(struct i2o_device *);
383extern int i2o_device_claim_release(struct i2o_device *);
384
385/* Exec OSM functions */
386extern int i2o_exec_lct_get(struct i2o_controller *);
387
388/* device to i2o_device and driver to i2o_driver convertion functions */
389#define to_i2o_driver(drv) container_of(drv,struct i2o_driver, driver)
390#define to_i2o_device(dev) container_of(dev, struct i2o_device, device)
391
392/*
393 * Messenger inlines
394 */
395static inline u32 I2O_POST_READ32(struct i2o_controller *c)
396{
397 rmb();
398 return readl(c->post_port);
399};
400
401static inline void I2O_POST_WRITE32(struct i2o_controller *c, u32 val)
402{
403 wmb();
404 writel(val, c->post_port);
405};
406
407static inline u32 I2O_REPLY_READ32(struct i2o_controller *c)
408{
409 rmb();
410 return readl(c->reply_port);
411};
412
413static inline void I2O_REPLY_WRITE32(struct i2o_controller *c, u32 val)
414{
415 wmb();
416 writel(val, c->reply_port);
417};
418
419static inline u32 I2O_IRQ_READ32(struct i2o_controller *c)
420{
421 rmb();
422 return readl(c->irq_mask);
423};
424
425static inline void I2O_IRQ_WRITE32(struct i2o_controller *c, u32 val)
426{
427 wmb();
428 writel(val, c->irq_mask);
429 wmb();
430};
431
432/**
433 * i2o_msg_get - obtain an I2O message from the IOP
434 * @c: I2O controller
435 * @msg: pointer to a I2O message pointer
436 *
437 * This function tries to get a message slot. If no message slot is
438 * available do not wait until one is availabe (see also i2o_msg_get_wait).
439 *
440 * On a success the message is returned and the pointer to the message is
441 * set in msg. The returned message is the physical page frame offset
442 * address from the read port (see the i2o spec). If no message is
443 * available returns I2O_QUEUE_EMPTY and msg is leaved untouched.
444 */
445static inline u32 i2o_msg_get(struct i2o_controller *c,
446 struct i2o_message __iomem **msg)
447{
448 u32 m;
449
450 if ((m = I2O_POST_READ32(c)) != I2O_QUEUE_EMPTY)
451 *msg = c->in_queue.virt + m;
452
453 return m;
454};
455
456/**
457 * i2o_msg_post - Post I2O message to I2O controller
458 * @c: I2O controller to which the message should be send
459 * @m: the message identifier
460 *
461 * Post the message to the I2O controller.
462 */
463static inline void i2o_msg_post(struct i2o_controller *c, u32 m)
464{
465 I2O_POST_WRITE32(c, m);
466};
467
468/**
469 * i2o_msg_post_wait - Post and wait a message and wait until return
470 * @c: controller
471 * @m: message to post
472 * @timeout: time in seconds to wait
473 *
474 * This API allows an OSM to post a message and then be told whether or
475 * not the system received a successful reply. If the message times out
476 * then the value '-ETIMEDOUT' is returned.
477 *
478 * Returns 0 on success or negative error code on failure.
479 */
480static inline int i2o_msg_post_wait(struct i2o_controller *c, u32 m,
481 unsigned long timeout)
482{
483 return i2o_msg_post_wait_mem(c, m, timeout, NULL);
484};
485
486/**
487 * i2o_flush_reply - Flush reply from I2O controller
488 * @c: I2O controller
489 * @m: the message identifier
490 *
491 * The I2O controller must be informed that the reply message is not needed
492 * anymore. If you forget to flush the reply, the message frame can't be
493 * used by the controller anymore and is therefore lost.
494 *
495 * FIXME: is there a timeout after which the controller reuse the message?
496 */
497static inline void i2o_flush_reply(struct i2o_controller *c, u32 m)
498{
499 I2O_REPLY_WRITE32(c, m);
500};
501
502/**
503 * i2o_out_to_virt - Turn an I2O message to a virtual address
504 * @c: controller
505 * @m: message engine value
506 *
507 * Turn a receive message from an I2O controller bus address into
508 * a Linux virtual address. The shared page frame is a linear block
509 * so we simply have to shift the offset. This function does not
510 * work for sender side messages as they are ioremap objects
511 * provided by the I2O controller.
512 */
513static inline struct i2o_message *i2o_msg_out_to_virt(struct i2o_controller *c,
514 u32 m)
515{
516 BUG_ON(m < c->out_queue.phys
517 || m >= c->out_queue.phys + c->out_queue.len);
518
519 return c->out_queue.virt + (m - c->out_queue.phys);
520};
521
522/**
523 * i2o_msg_in_to_virt - Turn an I2O message to a virtual address
524 * @c: controller
525 * @m: message engine value
526 *
527 * Turn a send message from an I2O controller bus address into
528 * a Linux virtual address. The shared page frame is a linear block
529 * so we simply have to shift the offset. This function does not
530 * work for receive side messages as they are kmalloc objects
531 * in a different pool.
532 */
533static inline struct i2o_message __iomem *i2o_msg_in_to_virt(struct i2o_controller *c,
534 u32 m)
535{
536 return c->in_queue.virt + m;
537};
538
539/**
540 * i2o_dma_alloc - Allocate DMA memory
541 * @dev: struct device pointer to the PCI device of the I2O controller
542 * @addr: i2o_dma struct which should get the DMA buffer
543 * @len: length of the new DMA memory
544 * @gfp_mask: GFP mask
545 *
546 * Allocate a coherent DMA memory and write the pointers into addr.
547 *
548 * Returns 0 on success or -ENOMEM on failure.
549 */
550static inline int i2o_dma_alloc(struct device *dev, struct i2o_dma *addr,
551 size_t len, unsigned int gfp_mask)
552{
553 addr->virt = dma_alloc_coherent(dev, len, &addr->phys, gfp_mask);
554 if (!addr->virt)
555 return -ENOMEM;
556
557 memset(addr->virt, 0, len);
558 addr->len = len;
559
560 return 0;
561};
562
563/**
564 * i2o_dma_free - Free DMA memory
565 * @dev: struct device pointer to the PCI device of the I2O controller
566 * @addr: i2o_dma struct which contains the DMA buffer
567 *
568 * Free a coherent DMA memory and set virtual address of addr to NULL.
569 */
570static inline void i2o_dma_free(struct device *dev, struct i2o_dma *addr)
571{
572 if (addr->virt) {
573 if (addr->phys)
574 dma_free_coherent(dev, addr->len, addr->virt,
575 addr->phys);
576 else
577 kfree(addr->virt);
578 addr->virt = NULL;
579 }
580};
581
582/**
583 * i2o_dma_map - Map the memory to DMA
584 * @dev: struct device pointer to the PCI device of the I2O controller
585 * @addr: i2o_dma struct which should be mapped
586 *
587 * Map the memory in addr->virt to coherent DMA memory and write the
588 * physical address into addr->phys.
589 *
590 * Returns 0 on success or -ENOMEM on failure.
591 */
592static inline int i2o_dma_map(struct device *dev, struct i2o_dma *addr)
593{
594 if (!addr->virt)
595 return -EFAULT;
596
597 if (!addr->phys)
598 addr->phys = dma_map_single(dev, addr->virt, addr->len,
599 DMA_BIDIRECTIONAL);
600 if (!addr->phys)
601 return -ENOMEM;
602
603 return 0;
604};
605
606/**
607 * i2o_dma_unmap - Unmap the DMA memory
608 * @dev: struct device pointer to the PCI device of the I2O controller
609 * @addr: i2o_dma struct which should be unmapped
610 *
611 * Unmap the memory in addr->virt from DMA memory.
612 */
613static inline void i2o_dma_unmap(struct device *dev, struct i2o_dma *addr)
614{
615 if (!addr->virt)
616 return;
617
618 if (addr->phys) {
619 dma_unmap_single(dev, addr->phys, addr->len, DMA_BIDIRECTIONAL);
620 addr->phys = 0;
621 }
622};
623
624/*
625 * Endian handling wrapped into the macro - keeps the core code
626 * cleaner.
627 */
628
629#define i2o_raw_writel(val, mem) __raw_writel(cpu_to_le32(val), mem)
630
631extern int i2o_parm_field_get(struct i2o_device *, int, int, void *, int);
632extern int i2o_parm_table_get(struct i2o_device *, int, int, int, void *, int,
633 void *, int);
634
635/* debugging and troubleshooting/diagnostic helpers. */
636#define osm_printk(level, format, arg...) \
637 printk(level "%s: " format, OSM_NAME , ## arg)
638
639#ifdef DEBUG
640#define osm_debug(format, arg...) \
641 osm_printk(KERN_DEBUG, format , ## arg)
642#else
643#define osm_debug(format, arg...) \
644 do { } while (0)
645#endif
646
647#define osm_err(format, arg...) \
648 osm_printk(KERN_ERR, format , ## arg)
649#define osm_info(format, arg...) \
650 osm_printk(KERN_INFO, format , ## arg)
651#define osm_warn(format, arg...) \
652 osm_printk(KERN_WARNING, format , ## arg)
653
654/* debugging functions */
655extern void i2o_report_status(const char *, const char *, struct i2o_message *);
656extern void i2o_dump_message(struct i2o_message *);
657extern void i2o_dump_hrt(struct i2o_controller *c);
658extern void i2o_debug_state(struct i2o_controller *c);
659
660/*
661 * Cache strategies
662 */
663
664/* The NULL strategy leaves everything up to the controller. This tends to be a
665 * pessimal but functional choice.
666 */
667#define CACHE_NULL 0
668/* Prefetch data when reading. We continually attempt to load the next 32 sectors
669 * into the controller cache.
670 */
671#define CACHE_PREFETCH 1
672/* Prefetch data when reading. We sometimes attempt to load the next 32 sectors
673 * into the controller cache. When an I/O is less <= 8K we assume its probably
674 * not sequential and don't prefetch (default)
675 */
676#define CACHE_SMARTFETCH 2
677/* Data is written to the cache and then out on to the disk. The I/O must be
678 * physically on the medium before the write is acknowledged (default without
679 * NVRAM)
680 */
681#define CACHE_WRITETHROUGH 17
682/* Data is written to the cache and then out on to the disk. The controller
683 * is permitted to write back the cache any way it wants. (default if battery
684 * backed NVRAM is present). It can be useful to set this for swap regardless of
685 * battery state.
686 */
687#define CACHE_WRITEBACK 18
688/* Optimise for under powered controllers, especially on RAID1 and RAID0. We
689 * write large I/O's directly to disk bypassing the cache to avoid the extra
690 * memory copy hits. Small writes are writeback cached
691 */
692#define CACHE_SMARTBACK 19
693/* Optimise for under powered controllers, especially on RAID1 and RAID0. We
694 * write large I/O's directly to disk bypassing the cache to avoid the extra
695 * memory copy hits. Small writes are writethrough cached. Suitable for devices
696 * lacking battery backup
697 */
698#define CACHE_SMARTTHROUGH 20
699
700/*
701 * Ioctl structures
702 */
703
704#define BLKI2OGRSTRAT _IOR('2', 1, int)
705#define BLKI2OGWSTRAT _IOR('2', 2, int)
706#define BLKI2OSRSTRAT _IOW('2', 3, int)
707#define BLKI2OSWSTRAT _IOW('2', 4, int)
708
709/*
710 * I2O Function codes
711 */
712
713/*
714 * Executive Class
715 */
716#define I2O_CMD_ADAPTER_ASSIGN 0xB3
717#define I2O_CMD_ADAPTER_READ 0xB2
718#define I2O_CMD_ADAPTER_RELEASE 0xB5
719#define I2O_CMD_BIOS_INFO_SET 0xA5
720#define I2O_CMD_BOOT_DEVICE_SET 0xA7
721#define I2O_CMD_CONFIG_VALIDATE 0xBB
722#define I2O_CMD_CONN_SETUP 0xCA
723#define I2O_CMD_DDM_DESTROY 0xB1
724#define I2O_CMD_DDM_ENABLE 0xD5
725#define I2O_CMD_DDM_QUIESCE 0xC7
726#define I2O_CMD_DDM_RESET 0xD9
727#define I2O_CMD_DDM_SUSPEND 0xAF
728#define I2O_CMD_DEVICE_ASSIGN 0xB7
729#define I2O_CMD_DEVICE_RELEASE 0xB9
730#define I2O_CMD_HRT_GET 0xA8
731#define I2O_CMD_ADAPTER_CLEAR 0xBE
732#define I2O_CMD_ADAPTER_CONNECT 0xC9
733#define I2O_CMD_ADAPTER_RESET 0xBD
734#define I2O_CMD_LCT_NOTIFY 0xA2
735#define I2O_CMD_OUTBOUND_INIT 0xA1
736#define I2O_CMD_PATH_ENABLE 0xD3
737#define I2O_CMD_PATH_QUIESCE 0xC5
738#define I2O_CMD_PATH_RESET 0xD7
739#define I2O_CMD_STATIC_MF_CREATE 0xDD
740#define I2O_CMD_STATIC_MF_RELEASE 0xDF
741#define I2O_CMD_STATUS_GET 0xA0
742#define I2O_CMD_SW_DOWNLOAD 0xA9
743#define I2O_CMD_SW_UPLOAD 0xAB
744#define I2O_CMD_SW_REMOVE 0xAD
745#define I2O_CMD_SYS_ENABLE 0xD1
746#define I2O_CMD_SYS_MODIFY 0xC1
747#define I2O_CMD_SYS_QUIESCE 0xC3
748#define I2O_CMD_SYS_TAB_SET 0xA3
749
750/*
751 * Utility Class
752 */
753#define I2O_CMD_UTIL_NOP 0x00
754#define I2O_CMD_UTIL_ABORT 0x01
755#define I2O_CMD_UTIL_CLAIM 0x09
756#define I2O_CMD_UTIL_RELEASE 0x0B
757#define I2O_CMD_UTIL_PARAMS_GET 0x06
758#define I2O_CMD_UTIL_PARAMS_SET 0x05
759#define I2O_CMD_UTIL_EVT_REGISTER 0x13
760#define I2O_CMD_UTIL_EVT_ACK 0x14
761#define I2O_CMD_UTIL_CONFIG_DIALOG 0x10
762#define I2O_CMD_UTIL_DEVICE_RESERVE 0x0D
763#define I2O_CMD_UTIL_DEVICE_RELEASE 0x0F
764#define I2O_CMD_UTIL_LOCK 0x17
765#define I2O_CMD_UTIL_LOCK_RELEASE 0x19
766#define I2O_CMD_UTIL_REPLY_FAULT_NOTIFY 0x15
767
768/*
769 * SCSI Host Bus Adapter Class
770 */
771#define I2O_CMD_SCSI_EXEC 0x81
772#define I2O_CMD_SCSI_ABORT 0x83
773#define I2O_CMD_SCSI_BUSRESET 0x27
774
775/*
776 * Random Block Storage Class
777 */
778#define I2O_CMD_BLOCK_READ 0x30
779#define I2O_CMD_BLOCK_WRITE 0x31
780#define I2O_CMD_BLOCK_CFLUSH 0x37
781#define I2O_CMD_BLOCK_MLOCK 0x49
782#define I2O_CMD_BLOCK_MUNLOCK 0x4B
783#define I2O_CMD_BLOCK_MMOUNT 0x41
784#define I2O_CMD_BLOCK_MEJECT 0x43
785#define I2O_CMD_BLOCK_POWER 0x70
786
787#define I2O_PRIVATE_MSG 0xFF
788
789/* Command status values */
790
791#define I2O_CMD_IN_PROGRESS 0x01
792#define I2O_CMD_REJECTED 0x02
793#define I2O_CMD_FAILED 0x03
794#define I2O_CMD_COMPLETED 0x04
795
796/* I2O API function return values */
797
798#define I2O_RTN_NO_ERROR 0
799#define I2O_RTN_NOT_INIT 1
800#define I2O_RTN_FREE_Q_EMPTY 2
801#define I2O_RTN_TCB_ERROR 3
802#define I2O_RTN_TRANSACTION_ERROR 4
803#define I2O_RTN_ADAPTER_ALREADY_INIT 5
804#define I2O_RTN_MALLOC_ERROR 6
805#define I2O_RTN_ADPTR_NOT_REGISTERED 7
806#define I2O_RTN_MSG_REPLY_TIMEOUT 8
807#define I2O_RTN_NO_STATUS 9
808#define I2O_RTN_NO_FIRM_VER 10
809#define I2O_RTN_NO_LINK_SPEED 11
810
811/* Reply message status defines for all messages */
812
813#define I2O_REPLY_STATUS_SUCCESS 0x00
814#define I2O_REPLY_STATUS_ABORT_DIRTY 0x01
815#define I2O_REPLY_STATUS_ABORT_NO_DATA_TRANSFER 0x02
816#define I2O_REPLY_STATUS_ABORT_PARTIAL_TRANSFER 0x03
817#define I2O_REPLY_STATUS_ERROR_DIRTY 0x04
818#define I2O_REPLY_STATUS_ERROR_NO_DATA_TRANSFER 0x05
819#define I2O_REPLY_STATUS_ERROR_PARTIAL_TRANSFER 0x06
820#define I2O_REPLY_STATUS_PROCESS_ABORT_DIRTY 0x08
821#define I2O_REPLY_STATUS_PROCESS_ABORT_NO_DATA_TRANSFER 0x09
822#define I2O_REPLY_STATUS_PROCESS_ABORT_PARTIAL_TRANSFER 0x0A
823#define I2O_REPLY_STATUS_TRANSACTION_ERROR 0x0B
824#define I2O_REPLY_STATUS_PROGRESS_REPORT 0x80
825
826/* Status codes and Error Information for Parameter functions */
827
828#define I2O_PARAMS_STATUS_SUCCESS 0x00
829#define I2O_PARAMS_STATUS_BAD_KEY_ABORT 0x01
830#define I2O_PARAMS_STATUS_BAD_KEY_CONTINUE 0x02
831#define I2O_PARAMS_STATUS_BUFFER_FULL 0x03
832#define I2O_PARAMS_STATUS_BUFFER_TOO_SMALL 0x04
833#define I2O_PARAMS_STATUS_FIELD_UNREADABLE 0x05
834#define I2O_PARAMS_STATUS_FIELD_UNWRITEABLE 0x06
835#define I2O_PARAMS_STATUS_INSUFFICIENT_FIELDS 0x07
836#define I2O_PARAMS_STATUS_INVALID_GROUP_ID 0x08
837#define I2O_PARAMS_STATUS_INVALID_OPERATION 0x09
838#define I2O_PARAMS_STATUS_NO_KEY_FIELD 0x0A
839#define I2O_PARAMS_STATUS_NO_SUCH_FIELD 0x0B
840#define I2O_PARAMS_STATUS_NON_DYNAMIC_GROUP 0x0C
841#define I2O_PARAMS_STATUS_OPERATION_ERROR 0x0D
842#define I2O_PARAMS_STATUS_SCALAR_ERROR 0x0E
843#define I2O_PARAMS_STATUS_TABLE_ERROR 0x0F
844#define I2O_PARAMS_STATUS_WRONG_GROUP_TYPE 0x10
845
846/* DetailedStatusCode defines for Executive, DDM, Util and Transaction error
847 * messages: Table 3-2 Detailed Status Codes.*/
848
849#define I2O_DSC_SUCCESS 0x0000
850#define I2O_DSC_BAD_KEY 0x0002
851#define I2O_DSC_TCL_ERROR 0x0003
852#define I2O_DSC_REPLY_BUFFER_FULL 0x0004
853#define I2O_DSC_NO_SUCH_PAGE 0x0005
854#define I2O_DSC_INSUFFICIENT_RESOURCE_SOFT 0x0006
855#define I2O_DSC_INSUFFICIENT_RESOURCE_HARD 0x0007
856#define I2O_DSC_CHAIN_BUFFER_TOO_LARGE 0x0009
857#define I2O_DSC_UNSUPPORTED_FUNCTION 0x000A
858#define I2O_DSC_DEVICE_LOCKED 0x000B
859#define I2O_DSC_DEVICE_RESET 0x000C
860#define I2O_DSC_INAPPROPRIATE_FUNCTION 0x000D
861#define I2O_DSC_INVALID_INITIATOR_ADDRESS 0x000E
862#define I2O_DSC_INVALID_MESSAGE_FLAGS 0x000F
863#define I2O_DSC_INVALID_OFFSET 0x0010
864#define I2O_DSC_INVALID_PARAMETER 0x0011
865#define I2O_DSC_INVALID_REQUEST 0x0012
866#define I2O_DSC_INVALID_TARGET_ADDRESS 0x0013
867#define I2O_DSC_MESSAGE_TOO_LARGE 0x0014
868#define I2O_DSC_MESSAGE_TOO_SMALL 0x0015
869#define I2O_DSC_MISSING_PARAMETER 0x0016
870#define I2O_DSC_TIMEOUT 0x0017
871#define I2O_DSC_UNKNOWN_ERROR 0x0018
872#define I2O_DSC_UNKNOWN_FUNCTION 0x0019
873#define I2O_DSC_UNSUPPORTED_VERSION 0x001A
874#define I2O_DSC_DEVICE_BUSY 0x001B
875#define I2O_DSC_DEVICE_NOT_AVAILABLE 0x001C
876
877/* DetailedStatusCode defines for Block Storage Operation: Table 6-7 Detailed
878 Status Codes.*/
879
880#define I2O_BSA_DSC_SUCCESS 0x0000
881#define I2O_BSA_DSC_MEDIA_ERROR 0x0001
882#define I2O_BSA_DSC_ACCESS_ERROR 0x0002
883#define I2O_BSA_DSC_DEVICE_FAILURE 0x0003
884#define I2O_BSA_DSC_DEVICE_NOT_READY 0x0004
885#define I2O_BSA_DSC_MEDIA_NOT_PRESENT 0x0005
886#define I2O_BSA_DSC_MEDIA_LOCKED 0x0006
887#define I2O_BSA_DSC_MEDIA_FAILURE 0x0007
888#define I2O_BSA_DSC_PROTOCOL_FAILURE 0x0008
889#define I2O_BSA_DSC_BUS_FAILURE 0x0009
890#define I2O_BSA_DSC_ACCESS_VIOLATION 0x000A
891#define I2O_BSA_DSC_WRITE_PROTECTED 0x000B
892#define I2O_BSA_DSC_DEVICE_RESET 0x000C
893#define I2O_BSA_DSC_VOLUME_CHANGED 0x000D
894#define I2O_BSA_DSC_TIMEOUT 0x000E
895
896/* FailureStatusCodes, Table 3-3 Message Failure Codes */
897
898#define I2O_FSC_TRANSPORT_SERVICE_SUSPENDED 0x81
899#define I2O_FSC_TRANSPORT_SERVICE_TERMINATED 0x82
900#define I2O_FSC_TRANSPORT_CONGESTION 0x83
901#define I2O_FSC_TRANSPORT_FAILURE 0x84
902#define I2O_FSC_TRANSPORT_STATE_ERROR 0x85
903#define I2O_FSC_TRANSPORT_TIME_OUT 0x86
904#define I2O_FSC_TRANSPORT_ROUTING_FAILURE 0x87
905#define I2O_FSC_TRANSPORT_INVALID_VERSION 0x88
906#define I2O_FSC_TRANSPORT_INVALID_OFFSET 0x89
907#define I2O_FSC_TRANSPORT_INVALID_MSG_FLAGS 0x8A
908#define I2O_FSC_TRANSPORT_FRAME_TOO_SMALL 0x8B
909#define I2O_FSC_TRANSPORT_FRAME_TOO_LARGE 0x8C
910#define I2O_FSC_TRANSPORT_INVALID_TARGET_ID 0x8D
911#define I2O_FSC_TRANSPORT_INVALID_INITIATOR_ID 0x8E
912#define I2O_FSC_TRANSPORT_INVALID_INITIATOR_CONTEXT 0x8F
913#define I2O_FSC_TRANSPORT_UNKNOWN_FAILURE 0xFF
914
915/* Device Claim Types */
916#define I2O_CLAIM_PRIMARY 0x01000000
917#define I2O_CLAIM_MANAGEMENT 0x02000000
918#define I2O_CLAIM_AUTHORIZED 0x03000000
919#define I2O_CLAIM_SECONDARY 0x04000000
920
921/* Message header defines for VersionOffset */
922#define I2OVER15 0x0001
923#define I2OVER20 0x0002
924
925/* Default is 1.5, FIXME: Need support for both 1.5 and 2.0 */
926#define I2OVERSION I2OVER15
927
928#define SGL_OFFSET_0 I2OVERSION
929#define SGL_OFFSET_4 (0x0040 | I2OVERSION)
930#define SGL_OFFSET_5 (0x0050 | I2OVERSION)
931#define SGL_OFFSET_6 (0x0060 | I2OVERSION)
932#define SGL_OFFSET_7 (0x0070 | I2OVERSION)
933#define SGL_OFFSET_8 (0x0080 | I2OVERSION)
934#define SGL_OFFSET_9 (0x0090 | I2OVERSION)
935#define SGL_OFFSET_10 (0x00A0 | I2OVERSION)
936
937#define TRL_OFFSET_5 (0x0050 | I2OVERSION)
938#define TRL_OFFSET_6 (0x0060 | I2OVERSION)
939
940/* Transaction Reply Lists (TRL) Control Word structure */
941#define TRL_SINGLE_FIXED_LENGTH 0x00
942#define TRL_SINGLE_VARIABLE_LENGTH 0x40
943#define TRL_MULTIPLE_FIXED_LENGTH 0x80
944
945 /* msg header defines for MsgFlags */
946#define MSG_STATIC 0x0100
947#define MSG_64BIT_CNTXT 0x0200
948#define MSG_MULTI_TRANS 0x1000
949#define MSG_FAIL 0x2000
950#define MSG_FINAL 0x4000
951#define MSG_REPLY 0x8000
952
953 /* minimum size msg */
954#define THREE_WORD_MSG_SIZE 0x00030000
955#define FOUR_WORD_MSG_SIZE 0x00040000
956#define FIVE_WORD_MSG_SIZE 0x00050000
957#define SIX_WORD_MSG_SIZE 0x00060000
958#define SEVEN_WORD_MSG_SIZE 0x00070000
959#define EIGHT_WORD_MSG_SIZE 0x00080000
960#define NINE_WORD_MSG_SIZE 0x00090000
961#define TEN_WORD_MSG_SIZE 0x000A0000
962#define ELEVEN_WORD_MSG_SIZE 0x000B0000
963#define I2O_MESSAGE_SIZE(x) ((x)<<16)
964
965/* Special TID Assignments */
966
967#define ADAPTER_TID 0
968#define HOST_TID 1
969
970#define MSG_FRAME_SIZE 128 /* i2o_scsi assumes >= 32 */
971#define REPLY_FRAME_SIZE 17
972#define SG_TABLESIZE 30
973#define NMBR_MSG_FRAMES 128
974
975#define MSG_POOL_SIZE (MSG_FRAME_SIZE*NMBR_MSG_FRAMES*sizeof(u32))
976
977#define I2O_POST_WAIT_OK 0
978#define I2O_POST_WAIT_TIMEOUT -ETIMEDOUT
979
980#define I2O_CONTEXT_LIST_MIN_LENGTH 15
981#define I2O_CONTEXT_LIST_USED 0x01
982#define I2O_CONTEXT_LIST_DELETED 0x02
983
984/* timeouts */
985#define I2O_TIMEOUT_INIT_OUTBOUND_QUEUE 15
986#define I2O_TIMEOUT_MESSAGE_GET 5
987#define I2O_TIMEOUT_RESET 30
988#define I2O_TIMEOUT_STATUS_GET 5
989#define I2O_TIMEOUT_LCT_GET 360
990#define I2O_TIMEOUT_SCSI_SCB_ABORT 240
991
992/* retries */
993#define I2O_HRT_GET_TRIES 3
994#define I2O_LCT_GET_TRIES 3
995
996/* request queue sizes */
997#define I2O_MAX_SECTORS 1024
998#define I2O_MAX_SEGMENTS 128
999
1000#define I2O_REQ_MEMPOOL_SIZE 32
1001
1002#endif /* __KERNEL__ */
1003#endif /* _I2O_H */
diff --git a/include/linux/i8k.h b/include/linux/i8k.h
new file mode 100644
index 000000000000..1c45ba505115
--- /dev/null
+++ b/include/linux/i8k.h
@@ -0,0 +1,46 @@
1/*
2 * i8k.h -- Linux driver for accessing the SMM BIOS on Dell laptops
3 *
4 * Copyright (C) 2001 Massimo Dal Zotto <dz@debian.org>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 */
16
17#ifndef _LINUX_I8K_H
18#define _LINUX_I8K_H
19
20#define I8K_PROC "/proc/i8k"
21#define I8K_PROC_FMT "1.0"
22
23#define I8K_BIOS_VERSION _IOR ('i', 0x80, int) /* broken: meant 4 bytes */
24#define I8K_MACHINE_ID _IOR ('i', 0x81, int) /* broken: meant 16 bytes */
25#define I8K_POWER_STATUS _IOR ('i', 0x82, size_t)
26#define I8K_FN_STATUS _IOR ('i', 0x83, size_t)
27#define I8K_GET_TEMP _IOR ('i', 0x84, size_t)
28#define I8K_GET_SPEED _IOWR('i', 0x85, size_t)
29#define I8K_GET_FAN _IOWR('i', 0x86, size_t)
30#define I8K_SET_FAN _IOWR('i', 0x87, size_t)
31
32#define I8K_FAN_LEFT 1
33#define I8K_FAN_RIGHT 0
34#define I8K_FAN_OFF 0
35#define I8K_FAN_LOW 1
36#define I8K_FAN_HIGH 2
37#define I8K_FAN_MAX I8K_FAN_HIGH
38
39#define I8K_VOL_UP 1
40#define I8K_VOL_DOWN 2
41#define I8K_VOL_MUTE 4
42
43#define I8K_AC 1
44#define I8K_BATTERY 0
45
46#endif
diff --git a/include/linux/ibmtr.h b/include/linux/ibmtr.h
new file mode 100644
index 000000000000..2ef0b21517fb
--- /dev/null
+++ b/include/linux/ibmtr.h
@@ -0,0 +1,373 @@
1#ifndef __LINUX_IBMTR_H__
2#define __LINUX_IBMTR_H__
3
4/* Definitions for an IBM Token Ring card. */
5/* This file is distributed under the GNU GPL */
6
7/* ported to the Alpha architecture 02/20/96 (just used the HZ macro) */
8
9#define TR_RETRY_INTERVAL (30*HZ) /* 500 on PC = 5 s */
10#define TR_RST_TIME (HZ/20) /* 5 on PC = 50 ms */
11#define TR_BUSY_INTERVAL (HZ/5) /* 5 on PC = 200 ms */
12#define TR_SPIN_INTERVAL (3*HZ) /* 3 seconds before init timeout */
13
14#define TR_ISA 1
15#define TR_MCA 2
16#define TR_ISAPNP 3
17#define NOTOK 0
18
19#define IBMTR_SHARED_RAM_SIZE 0x10000
20#define IBMTR_IO_EXTENT 4
21#define IBMTR_MAX_ADAPTERS 4
22
23#define CHANNEL_ID 0X1F30
24#define AIP 0X1F00
25#define AIPADAPTYPE 0X1FA0
26#define AIPDATARATE 0X1FA2
27#define AIPEARLYTOKEN 0X1FA4
28#define AIPAVAILSHRAM 0X1FA6
29#define AIPSHRAMPAGE 0X1FA8
30#define AIP4MBDHB 0X1FAA
31#define AIP16MBDHB 0X1FAC
32#define AIPFID 0X1FBA
33
34#define ADAPTRESET 0x1 /* Control Adapter reset (add to base) */
35#define ADAPTRESETREL 0x2 /* Release Adapter from reset ( """) */
36#define ADAPTINTREL 0x3 /* Adapter interrupt release */
37
38#define GLOBAL_INT_ENABLE 0x02f0
39
40/* MMIO bits 0-4 select register */
41#define RRR_EVEN 0x00 /* Shared RAM relocation registers - even and odd */
42/* Used to set the starting address of shared RAM */
43/* Bits 1 through 7 of this register map to bits 13 through 19 of the shared
44 RAM address.*/
45/* ie: 0x02 sets RAM address to ...ato! issy su wazzoo !! GODZILLA!!! */
46#define RRR_ODD 0x01
47/* Bits 2 and 3 of this register can be read to determine shared RAM size */
48/* 00 for 8k, 01 for 16k, 10 for 32k, 11 for 64k */
49#define WRBR_EVEN 0x02 /* Write region base registers - even and odd */
50#define WRBR_ODD 0x03
51#define WWOR_EVEN 0x04 /* Write window open registers - even and odd */
52#define WWOR_ODD 0x05
53#define WWCR_EVEN 0x06 /* Write window close registers - even and odd */
54#define WWCR_ODD 0x07
55
56/* Interrupt status registers - PC system - even and odd */
57#define ISRP_EVEN 0x08
58
59#define TCR_INT 0x10 /* Bit 4 - Timer interrupt. The TVR_EVEN timer has
60 expired. */
61#define ERR_INT 0x08 /* Bit 3 - Error interrupt. The adapter has had an
62 internal error. */
63#define ACCESS_INT 0x04 /* Bit 2 - Access interrupt. You have attempted to
64 write to an invalid area of shared RAM
65 or an invalid register within the MMIO. */
66/* In addition, the following bits within ISRP_EVEN can be turned on or off */
67/* by you to control the interrupt processing: */
68#define INT_ENABLE 0x40 /* Bit 6 - Interrupt enable. If 0, no interrupts will
69 occur. If 1, interrupts will occur normally.
70 Normally set to 1. */
71/* Bit 0 - Primary or alternate adapter. Set to zero if this adapter is the
72 primary adapter, 1 if this adapter is the alternate adapter. */
73
74
75#define ISRP_ODD 0x09
76
77#define ADAP_CHK_INT 0x40 /* Bit 6 - Adapter check. the adapter has
78 encountered a serious problem and has closed
79 itself. Whoa. */
80#define SRB_RESP_INT 0x20 /* Bit 5 - SRB response. The adapter has accepted
81 an SRB request and set the return code within
82 the SRB. */
83#define ASB_FREE_INT 0x10 /* Bit 4 - ASB free. The adapter has read the ASB
84 and this area can be safely reused. This interrupt
85 is only used if your application has set the ASB
86 free request bit in ISRA_ODD or if an error was
87 detected in your response. */
88#define ARB_CMD_INT 0x08 /* Bit 3 - ARB command. The adapter has given you a
89 command for action. The command is located in the
90 ARB area of shared memory. */
91#define SSB_RESP_INT 0x04 /* Bit 2 - SSB response. The adapter has posted a
92 response to your SRB (the response is located in
93 the SSB area of shared memory). */
94/* Bit 1 - Bridge frame forward complete. */
95
96
97
98#define ISRA_EVEN 0x0A /*Interrupt status registers - adapter - even and odd */
99/* Bit 7 - Internal parity error (on adapter's internal bus) */
100/* Bit 6 - Timer interrupt pending */
101/* Bit 5 - Access interrupt (attempt by adapter to access illegal address) */
102/* Bit 4 - Adapter microcode problem (microcode dead-man timer expired) */
103/* Bit 3 - Adapter processor check status */
104/* Bit 2 - Reserved */
105/* Bit 1 - Adapter hardware interrupt mask (prevents internal interrupts) */
106/* Bit 0 - Adapter software interrupt mask (prevents internal software ints) */
107
108#define ISRA_ODD 0x0B
109#define CMD_IN_SRB 0x20 /* Bit 5 - Indicates that you have placed a new
110 command in the SRB and are ready for the adapter to
111 process the command. */
112#define RESP_IN_ASB 0x10 /* Bit 4 - Indicates that you have placed a response
113 (an ASB) in the shared RAM which is available for
114 the adapter's use. */
115/* Bit 3 - Indicates that you are ready to put an SRB in the shared RAM, but
116 that a previous command is still pending. The adapter will then
117 interrupt you when the previous command is completed */
118/* Bit 2 - Indicates that you are ready to put an ASB in the shared RAM, but
119 that a previous ASB is still pending. The adapter will then interrupt
120 you when the previous ASB is copied. */
121#define ARB_FREE 0x2
122#define SSB_FREE 0x1
123
124#define TCR_EVEN 0x0C /* Timer control registers - even and odd */
125#define TCR_ODD 0x0D
126#define TVR_EVEN 0x0E /* Timer value registers - even and odd */
127#define TVR_ODD 0x0F
128#define SRPR_EVEN 0x18 /* Shared RAM paging registers - even and odd */
129#define SRPR_ENABLE_PAGING 0xc0
130#define SRPR_ODD 0x19 /* Not used. */
131#define TOKREAD 0x60
132#define TOKOR 0x40
133#define TOKAND 0x20
134#define TOKWRITE 0x00
135
136/* MMIO bits 5-6 select operation */
137/* 00 is used to write to a register */
138/* 01 is used to bitwise AND a byte with a register */
139/* 10 is used to bitwise OR a byte with a register */
140/* 11 is used to read from a register */
141
142/* MMIO bits 7-8 select area of interest.. see below */
143/* 00 selects attachment control area. */
144/* 01 is reserved. */
145/* 10 selects adapter identification area A containing the adapter encoded
146 address. */
147/* 11 selects the adapter identification area B containing test patterns. */
148
149#define PCCHANNELID 5049434F3631313039393020
150#define MCCHANNELID 4D4152533633583435313820
151
152#define ACA_OFFSET 0x1e00
153#define ACA_SET 0x40
154#define ACA_RESET 0x20
155#define ACA_RW 0x00
156
157#ifdef ENABLE_PAGING
158#define SET_PAGE(x) (writeb((x), ti->mmio + ACA_OFFSET+ ACA_RW + SRPR_EVEN))
159#else
160#define SET_PAGE(x)
161#endif
162
163/* do_tok_int possible values */
164#define FIRST_INT 1
165#define NOT_FIRST 2
166
167typedef enum { CLOSED, OPEN } open_state;
168//staic const char *printstate[] = { "CLOSED","OPEN"};
169
170struct tok_info {
171 unsigned char irq;
172 void __iomem *mmio;
173 unsigned char hw_address[32];
174 unsigned char adapter_type;
175 unsigned char data_rate;
176 unsigned char token_release;
177 unsigned char avail_shared_ram;
178 unsigned char shared_ram_paging;
179 unsigned char turbo;
180 unsigned short dhb_size4mb;
181 unsigned short rbuf_len4;
182 unsigned short rbuf_cnt4;
183 unsigned short maxmtu4;
184 unsigned short dhb_size16mb;
185 unsigned short rbuf_len16;
186 unsigned short rbuf_cnt16;
187 unsigned short maxmtu16;
188 /* Additions by David Morris */
189 unsigned char do_tok_int;
190 wait_queue_head_t wait_for_reset;
191 unsigned char sram_base;
192 /* Additions by Peter De Schrijver */
193 unsigned char page_mask; /* mask to select RAM page to Map*/
194 unsigned char mapped_ram_size; /* size of RAM page */
195 __u32 sram_phys; /* Shared memory base address */
196 void __iomem *sram_virt; /* Shared memory base address */
197 void __iomem *init_srb; /* Initial System Request Block address */
198 void __iomem *srb; /* System Request Block address */
199 void __iomem *ssb; /* System Status Block address */
200 void __iomem *arb; /* Adapter Request Block address */
201 void __iomem *asb; /* Adapter Status Block address */
202 __u8 init_srb_page;
203 __u8 srb_page;
204 __u8 ssb_page;
205 __u8 arb_page;
206 __u8 asb_page;
207 unsigned short exsap_station_id;
208 unsigned short global_int_enable;
209 struct sk_buff *current_skb;
210 struct net_device_stats tr_stats;
211 unsigned char auto_speedsave;
212 open_state open_status, sap_status;
213 enum {MANUAL, AUTOMATIC} open_mode;
214 enum {FAIL, RESTART, REOPEN} open_action;
215 enum {NO, YES} open_failure;
216 unsigned char readlog_pending;
217 unsigned short adapter_int_enable; /* Adapter-specific int enable */
218 struct timer_list tr_timer;
219 unsigned char ring_speed;
220 spinlock_t lock; /* SMP protection */
221};
222
223/* token ring adapter commands */
224#define DIR_INTERRUPT 0x00 /* struct srb_interrupt */
225#define DIR_MOD_OPEN_PARAMS 0x01
226#define DIR_OPEN_ADAPTER 0x03 /* struct dir_open_adapter */
227#define DIR_CLOSE_ADAPTER 0x04
228#define DIR_SET_GRP_ADDR 0x06
229#define DIR_SET_FUNC_ADDR 0x07 /* struct srb_set_funct_addr */
230#define DIR_READ_LOG 0x08 /* struct srb_read_log */
231#define DLC_OPEN_SAP 0x15 /* struct dlc_open_sap */
232#define DLC_CLOSE_SAP 0x16
233#define DATA_LOST 0x20 /* struct asb_rec */
234#define REC_DATA 0x81 /* struct arb_rec_req */
235#define XMIT_DATA_REQ 0x82 /* struct arb_xmit_req */
236#define DLC_STATUS 0x83 /* struct arb_dlc_status */
237#define RING_STAT_CHANGE 0x84 /* struct dlc_open_sap ??? */
238
239/* DIR_OPEN_ADAPTER options */
240#define OPEN_PASS_BCON_MAC 0x0100
241#define NUM_RCV_BUF 2
242#define RCV_BUF_LEN 1024
243#define DHB_LENGTH 2048
244#define NUM_DHB 2
245#define DLC_MAX_SAP 2
246#define DLC_MAX_STA 1
247
248/* DLC_OPEN_SAP options */
249#define MAX_I_FIELD 0x0088
250#define SAP_OPEN_IND_SAP 0x04
251#define SAP_OPEN_PRIORITY 0x20
252#define SAP_OPEN_STATION_CNT 0x1
253#define XMIT_DIR_FRAME 0x0A
254#define XMIT_UI_FRAME 0x0d
255#define XMIT_XID_CMD 0x0e
256#define XMIT_TEST_CMD 0x11
257
258/* srb close return code */
259#define SIGNAL_LOSS 0x8000
260#define HARD_ERROR 0x4000
261#define XMIT_BEACON 0x1000
262#define LOBE_FAULT 0x0800
263#define AUTO_REMOVAL 0x0400
264#define REMOVE_RECV 0x0100
265#define LOG_OVERFLOW 0x0080
266#define RING_RECOVER 0x0020
267
268struct srb_init_response {
269 unsigned char command;
270 unsigned char init_status;
271 unsigned char init_status_2;
272 unsigned char reserved[3];
273 __u16 bring_up_code;
274 __u16 encoded_address;
275 __u16 level_address;
276 __u16 adapter_address;
277 __u16 parms_address;
278 __u16 mac_address;
279};
280
281struct dir_open_adapter {
282 unsigned char command;
283 char reserved[7];
284 __u16 open_options;
285 unsigned char node_address[6];
286 unsigned char group_address[4];
287 unsigned char funct_address[4];
288 __u16 num_rcv_buf;
289 __u16 rcv_buf_len;
290 __u16 dhb_length;
291 unsigned char num_dhb;
292 char reserved2;
293 unsigned char dlc_max_sap;
294 unsigned char dlc_max_sta;
295 unsigned char dlc_max_gsap;
296 unsigned char dlc_max_gmem;
297 unsigned char dlc_t1_tick_1;
298 unsigned char dlc_t2_tick_1;
299 unsigned char dlc_ti_tick_1;
300 unsigned char dlc_t1_tick_2;
301 unsigned char dlc_t2_tick_2;
302 unsigned char dlc_ti_tick_2;
303 unsigned char product_id[18];
304};
305
306struct dlc_open_sap {
307 unsigned char command;
308 unsigned char reserved1;
309 unsigned char ret_code;
310 unsigned char reserved2;
311 __u16 station_id;
312 unsigned char timer_t1;
313 unsigned char timer_t2;
314 unsigned char timer_ti;
315 unsigned char maxout;
316 unsigned char maxin;
317 unsigned char maxout_incr;
318 unsigned char max_retry_count;
319 unsigned char gsap_max_mem;
320 __u16 max_i_field;
321 unsigned char sap_value;
322 unsigned char sap_options;
323 unsigned char station_count;
324 unsigned char sap_gsap_mem;
325 unsigned char gsap[0];
326};
327
328struct srb_xmit {
329 unsigned char command;
330 unsigned char cmd_corr;
331 unsigned char ret_code;
332 unsigned char reserved1;
333 __u16 station_id;
334};
335
336struct arb_rec_req {
337 unsigned char command;
338 unsigned char reserved1[3];
339 __u16 station_id;
340 __u16 rec_buf_addr;
341 unsigned char lan_hdr_len;
342 unsigned char dlc_hdr_len;
343 __u16 frame_len;
344 unsigned char msg_type;
345};
346
347struct asb_rec {
348 unsigned char command;
349 unsigned char reserved1;
350 unsigned char ret_code;
351 unsigned char reserved2;
352 __u16 station_id;
353 __u16 rec_buf_addr;
354};
355
356struct rec_buf {
357 unsigned char reserved1[2];
358 __u16 buf_ptr;
359 unsigned char reserved2;
360 unsigned char receive_fs;
361 __u16 buf_len;
362 unsigned char data[0];
363};
364
365struct srb_set_funct_addr {
366 unsigned char command;
367 unsigned char reserved1;
368 unsigned char ret_code;
369 unsigned char reserved2[3];
370 unsigned char funct_address[4];
371};
372
373#endif
diff --git a/include/linux/icmp.h b/include/linux/icmp.h
new file mode 100644
index 000000000000..f0b571f1060b
--- /dev/null
+++ b/include/linux/icmp.h
@@ -0,0 +1,96 @@
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Definitions for the ICMP protocol.
7 *
8 * Version: @(#)icmp.h 1.0.3 04/28/93
9 *
10 * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version
15 * 2 of the License, or (at your option) any later version.
16 */
17#ifndef _LINUX_ICMP_H
18#define _LINUX_ICMP_H
19
20#include <linux/types.h>
21
22#define ICMP_ECHOREPLY 0 /* Echo Reply */
23#define ICMP_DEST_UNREACH 3 /* Destination Unreachable */
24#define ICMP_SOURCE_QUENCH 4 /* Source Quench */
25#define ICMP_REDIRECT 5 /* Redirect (change route) */
26#define ICMP_ECHO 8 /* Echo Request */
27#define ICMP_TIME_EXCEEDED 11 /* Time Exceeded */
28#define ICMP_PARAMETERPROB 12 /* Parameter Problem */
29#define ICMP_TIMESTAMP 13 /* Timestamp Request */
30#define ICMP_TIMESTAMPREPLY 14 /* Timestamp Reply */
31#define ICMP_INFO_REQUEST 15 /* Information Request */
32#define ICMP_INFO_REPLY 16 /* Information Reply */
33#define ICMP_ADDRESS 17 /* Address Mask Request */
34#define ICMP_ADDRESSREPLY 18 /* Address Mask Reply */
35#define NR_ICMP_TYPES 18
36
37
38/* Codes for UNREACH. */
39#define ICMP_NET_UNREACH 0 /* Network Unreachable */
40#define ICMP_HOST_UNREACH 1 /* Host Unreachable */
41#define ICMP_PROT_UNREACH 2 /* Protocol Unreachable */
42#define ICMP_PORT_UNREACH 3 /* Port Unreachable */
43#define ICMP_FRAG_NEEDED 4 /* Fragmentation Needed/DF set */
44#define ICMP_SR_FAILED 5 /* Source Route failed */
45#define ICMP_NET_UNKNOWN 6
46#define ICMP_HOST_UNKNOWN 7
47#define ICMP_HOST_ISOLATED 8
48#define ICMP_NET_ANO 9
49#define ICMP_HOST_ANO 10
50#define ICMP_NET_UNR_TOS 11
51#define ICMP_HOST_UNR_TOS 12
52#define ICMP_PKT_FILTERED 13 /* Packet filtered */
53#define ICMP_PREC_VIOLATION 14 /* Precedence violation */
54#define ICMP_PREC_CUTOFF 15 /* Precedence cut off */
55#define NR_ICMP_UNREACH 15 /* instead of hardcoding immediate value */
56
57/* Codes for REDIRECT. */
58#define ICMP_REDIR_NET 0 /* Redirect Net */
59#define ICMP_REDIR_HOST 1 /* Redirect Host */
60#define ICMP_REDIR_NETTOS 2 /* Redirect Net for TOS */
61#define ICMP_REDIR_HOSTTOS 3 /* Redirect Host for TOS */
62
63/* Codes for TIME_EXCEEDED. */
64#define ICMP_EXC_TTL 0 /* TTL count exceeded */
65#define ICMP_EXC_FRAGTIME 1 /* Fragment Reass time exceeded */
66
67
68struct icmphdr {
69 __u8 type;
70 __u8 code;
71 __u16 checksum;
72 union {
73 struct {
74 __u16 id;
75 __u16 sequence;
76 } echo;
77 __u32 gateway;
78 struct {
79 __u16 __unused;
80 __u16 mtu;
81 } frag;
82 } un;
83};
84
85/*
86 * constants for (set|get)sockopt
87 */
88
89#define ICMP_FILTER 1
90
91struct icmp_filter {
92 __u32 data;
93};
94
95
96#endif /* _LINUX_ICMP_H */
diff --git a/include/linux/icmpv6.h b/include/linux/icmpv6.h
new file mode 100644
index 000000000000..0cf6c8b12caf
--- /dev/null
+++ b/include/linux/icmpv6.h
@@ -0,0 +1,171 @@
1#ifndef _LINUX_ICMPV6_H
2#define _LINUX_ICMPV6_H
3
4#include <asm/byteorder.h>
5
6struct icmp6hdr {
7
8 __u8 icmp6_type;
9 __u8 icmp6_code;
10 __u16 icmp6_cksum;
11
12
13 union {
14 __u32 un_data32[1];
15 __u16 un_data16[2];
16 __u8 un_data8[4];
17
18 struct icmpv6_echo {
19 __u16 identifier;
20 __u16 sequence;
21 } u_echo;
22
23 struct icmpv6_nd_advt {
24#if defined(__LITTLE_ENDIAN_BITFIELD)
25 __u32 reserved:5,
26 override:1,
27 solicited:1,
28 router:1,
29 reserved2:24;
30#elif defined(__BIG_ENDIAN_BITFIELD)
31 __u32 router:1,
32 solicited:1,
33 override:1,
34 reserved:29;
35#else
36#error "Please fix <asm/byteorder.h>"
37#endif
38 } u_nd_advt;
39
40 struct icmpv6_nd_ra {
41 __u8 hop_limit;
42#if defined(__LITTLE_ENDIAN_BITFIELD)
43 __u8 reserved:6,
44 other:1,
45 managed:1;
46
47#elif defined(__BIG_ENDIAN_BITFIELD)
48 __u8 managed:1,
49 other:1,
50 reserved:6;
51#else
52#error "Please fix <asm/byteorder.h>"
53#endif
54 __u16 rt_lifetime;
55 } u_nd_ra;
56
57 } icmp6_dataun;
58
59#define icmp6_identifier icmp6_dataun.u_echo.identifier
60#define icmp6_sequence icmp6_dataun.u_echo.sequence
61#define icmp6_pointer icmp6_dataun.un_data32[0]
62#define icmp6_mtu icmp6_dataun.un_data32[0]
63#define icmp6_unused icmp6_dataun.un_data32[0]
64#define icmp6_maxdelay icmp6_dataun.un_data16[0]
65#define icmp6_router icmp6_dataun.u_nd_advt.router
66#define icmp6_solicited icmp6_dataun.u_nd_advt.solicited
67#define icmp6_override icmp6_dataun.u_nd_advt.override
68#define icmp6_ndiscreserved icmp6_dataun.u_nd_advt.reserved
69#define icmp6_hop_limit icmp6_dataun.u_nd_ra.hop_limit
70#define icmp6_addrconf_managed icmp6_dataun.u_nd_ra.managed
71#define icmp6_addrconf_other icmp6_dataun.u_nd_ra.other
72#define icmp6_rt_lifetime icmp6_dataun.u_nd_ra.rt_lifetime
73};
74
75
76#define ICMPV6_DEST_UNREACH 1
77#define ICMPV6_PKT_TOOBIG 2
78#define ICMPV6_TIME_EXCEED 3
79#define ICMPV6_PARAMPROB 4
80
81#define ICMPV6_INFOMSG_MASK 0x80
82
83#define ICMPV6_ECHO_REQUEST 128
84#define ICMPV6_ECHO_REPLY 129
85#define ICMPV6_MGM_QUERY 130
86#define ICMPV6_MGM_REPORT 131
87#define ICMPV6_MGM_REDUCTION 132
88
89#define ICMPV6_NI_QUERY 139
90#define ICMPV6_NI_REPLY 140
91
92#define ICMPV6_MLD2_REPORT 143
93
94#define ICMPV6_DHAAD_REQUEST 144
95#define ICMPV6_DHAAD_REPLY 145
96#define ICMPV6_MOBILE_PREFIX_SOL 146
97#define ICMPV6_MOBILE_PREFIX_ADV 147
98
99/*
100 * Codes for Destination Unreachable
101 */
102#define ICMPV6_NOROUTE 0
103#define ICMPV6_ADM_PROHIBITED 1
104#define ICMPV6_NOT_NEIGHBOUR 2
105#define ICMPV6_ADDR_UNREACH 3
106#define ICMPV6_PORT_UNREACH 4
107
108/*
109 * Codes for Time Exceeded
110 */
111#define ICMPV6_EXC_HOPLIMIT 0
112#define ICMPV6_EXC_FRAGTIME 1
113
114/*
115 * Codes for Parameter Problem
116 */
117#define ICMPV6_HDR_FIELD 0
118#define ICMPV6_UNK_NEXTHDR 1
119#define ICMPV6_UNK_OPTION 2
120
121/*
122 * constants for (set|get)sockopt
123 */
124
125#define ICMPV6_FILTER 1
126
127/*
128 * ICMPV6 filter
129 */
130
131#define ICMPV6_FILTER_BLOCK 1
132#define ICMPV6_FILTER_PASS 2
133#define ICMPV6_FILTER_BLOCKOTHERS 3
134#define ICMPV6_FILTER_PASSONLY 4
135
136struct icmp6_filter {
137 __u32 data[8];
138};
139
140/*
141 * Definitions for MLDv2
142 */
143#define MLD2_MODE_IS_INCLUDE 1
144#define MLD2_MODE_IS_EXCLUDE 2
145#define MLD2_CHANGE_TO_INCLUDE 3
146#define MLD2_CHANGE_TO_EXCLUDE 4
147#define MLD2_ALLOW_NEW_SOURCES 5
148#define MLD2_BLOCK_OLD_SOURCES 6
149
150#define MLD2_ALL_MCR_INIT { { { 0xff,0x02,0,0,0,0,0,0,0,0,0,0,0,0,0,0x16 } } }
151
152#ifdef __KERNEL__
153
154#include <linux/netdevice.h>
155#include <linux/skbuff.h>
156
157
158extern void icmpv6_send(struct sk_buff *skb,
159 int type, int code,
160 __u32 info,
161 struct net_device *dev);
162
163extern int icmpv6_init(struct net_proto_family *ops);
164extern int icmpv6_err_convert(int type, int code,
165 int *err);
166extern void icmpv6_cleanup(void);
167extern void icmpv6_param_prob(struct sk_buff *skb,
168 int code, int pos);
169#endif
170
171#endif
diff --git a/include/linux/ide.h b/include/linux/ide.h
new file mode 100644
index 000000000000..9cfc0999becb
--- /dev/null
+++ b/include/linux/ide.h
@@ -0,0 +1,1516 @@
1#ifndef _IDE_H
2#define _IDE_H
3/*
4 * linux/include/linux/ide.h
5 *
6 * Copyright (C) 1994-2002 Linus Torvalds & authors
7 */
8
9#include <linux/config.h>
10#include <linux/init.h>
11#include <linux/ioport.h>
12#include <linux/hdreg.h>
13#include <linux/hdsmart.h>
14#include <linux/blkdev.h>
15#include <linux/proc_fs.h>
16#include <linux/interrupt.h>
17#include <linux/bitops.h>
18#include <linux/bio.h>
19#include <linux/device.h>
20#include <linux/pci.h>
21#include <asm/byteorder.h>
22#include <asm/system.h>
23#include <asm/io.h>
24#include <asm/semaphore.h>
25
26/*
27 * This is the multiple IDE interface driver, as evolved from hd.c.
28 * It supports up to four IDE interfaces, on one or more IRQs (usually 14 & 15).
29 * There can be up to two drives per interface, as per the ATA-2 spec.
30 *
31 * Primary i/f: ide0: major=3; (hda) minor=0; (hdb) minor=64
32 * Secondary i/f: ide1: major=22; (hdc or hd1a) minor=0; (hdd or hd1b) minor=64
33 * Tertiary i/f: ide2: major=33; (hde) minor=0; (hdf) minor=64
34 * Quaternary i/f: ide3: major=34; (hdg) minor=0; (hdh) minor=64
35 */
36
37/******************************************************************************
38 * IDE driver configuration options (play with these as desired):
39 *
40 * REALLY_SLOW_IO can be defined in ide.c and ide-cd.c, if necessary
41 */
42#define INITIAL_MULT_COUNT 0 /* off=0; on=2,4,8,16,32, etc.. */
43
44#ifndef SUPPORT_SLOW_DATA_PORTS /* 1 to support slow data ports */
45#define SUPPORT_SLOW_DATA_PORTS 1 /* 0 to reduce kernel size */
46#endif
47#ifndef SUPPORT_VLB_SYNC /* 1 to support weird 32-bit chips */
48#define SUPPORT_VLB_SYNC 1 /* 0 to reduce kernel size */
49#endif
50#ifndef OK_TO_RESET_CONTROLLER /* 1 needed for good error recovery */
51#define OK_TO_RESET_CONTROLLER 1 /* 0 for use with AH2372A/B interface */
52#endif
53
54#ifndef DISABLE_IRQ_NOSYNC
55#define DISABLE_IRQ_NOSYNC 0
56#endif
57
58/*
59 * Used to indicate "no IRQ", should be a value that cannot be an IRQ
60 * number.
61 */
62
63#define IDE_NO_IRQ (-1)
64
65/*
66 * "No user-serviceable parts" beyond this point :)
67 *****************************************************************************/
68
69typedef unsigned char byte; /* used everywhere */
70
71/*
72 * Probably not wise to fiddle with these
73 */
74#define ERROR_MAX 8 /* Max read/write errors per sector */
75#define ERROR_RESET 3 /* Reset controller every 4th retry */
76#define ERROR_RECAL 1 /* Recalibrate every 2nd retry */
77
78/*
79 * Tune flags
80 */
81#define IDE_TUNE_NOAUTO 2
82#define IDE_TUNE_AUTO 1
83#define IDE_TUNE_DEFAULT 0
84
85/*
86 * state flags
87 */
88
89#define DMA_PIO_RETRY 1 /* retrying in PIO */
90
91#define HWIF(drive) ((ide_hwif_t *)((drive)->hwif))
92#define HWGROUP(drive) ((ide_hwgroup_t *)(HWIF(drive)->hwgroup))
93
94/*
95 * Definitions for accessing IDE controller registers
96 */
97#define IDE_NR_PORTS (10)
98
99#define IDE_DATA_OFFSET (0)
100#define IDE_ERROR_OFFSET (1)
101#define IDE_NSECTOR_OFFSET (2)
102#define IDE_SECTOR_OFFSET (3)
103#define IDE_LCYL_OFFSET (4)
104#define IDE_HCYL_OFFSET (5)
105#define IDE_SELECT_OFFSET (6)
106#define IDE_STATUS_OFFSET (7)
107#define IDE_CONTROL_OFFSET (8)
108#define IDE_IRQ_OFFSET (9)
109
110#define IDE_FEATURE_OFFSET IDE_ERROR_OFFSET
111#define IDE_COMMAND_OFFSET IDE_STATUS_OFFSET
112
113#define IDE_CONTROL_OFFSET_HOB (7)
114
115#define IDE_DATA_REG (HWIF(drive)->io_ports[IDE_DATA_OFFSET])
116#define IDE_ERROR_REG (HWIF(drive)->io_ports[IDE_ERROR_OFFSET])
117#define IDE_NSECTOR_REG (HWIF(drive)->io_ports[IDE_NSECTOR_OFFSET])
118#define IDE_SECTOR_REG (HWIF(drive)->io_ports[IDE_SECTOR_OFFSET])
119#define IDE_LCYL_REG (HWIF(drive)->io_ports[IDE_LCYL_OFFSET])
120#define IDE_HCYL_REG (HWIF(drive)->io_ports[IDE_HCYL_OFFSET])
121#define IDE_SELECT_REG (HWIF(drive)->io_ports[IDE_SELECT_OFFSET])
122#define IDE_STATUS_REG (HWIF(drive)->io_ports[IDE_STATUS_OFFSET])
123#define IDE_CONTROL_REG (HWIF(drive)->io_ports[IDE_CONTROL_OFFSET])
124#define IDE_IRQ_REG (HWIF(drive)->io_ports[IDE_IRQ_OFFSET])
125
126#define IDE_FEATURE_REG IDE_ERROR_REG
127#define IDE_COMMAND_REG IDE_STATUS_REG
128#define IDE_ALTSTATUS_REG IDE_CONTROL_REG
129#define IDE_IREASON_REG IDE_NSECTOR_REG
130#define IDE_BCOUNTL_REG IDE_LCYL_REG
131#define IDE_BCOUNTH_REG IDE_HCYL_REG
132
133#define OK_STAT(stat,good,bad) (((stat)&((good)|(bad)))==(good))
134#define BAD_R_STAT (BUSY_STAT | ERR_STAT)
135#define BAD_W_STAT (BAD_R_STAT | WRERR_STAT)
136#define BAD_STAT (BAD_R_STAT | DRQ_STAT)
137#define DRIVE_READY (READY_STAT | SEEK_STAT)
138#define DATA_READY (DRQ_STAT)
139
140#define BAD_CRC (ABRT_ERR | ICRC_ERR)
141
142#define SATA_NR_PORTS (3) /* 16 possible ?? */
143
144#define SATA_STATUS_OFFSET (0)
145#define SATA_STATUS_REG (HWIF(drive)->sata_scr[SATA_STATUS_OFFSET])
146#define SATA_ERROR_OFFSET (1)
147#define SATA_ERROR_REG (HWIF(drive)->sata_scr[SATA_ERROR_OFFSET])
148#define SATA_CONTROL_OFFSET (2)
149#define SATA_CONTROL_REG (HWIF(drive)->sata_scr[SATA_CONTROL_OFFSET])
150
151#define SATA_MISC_OFFSET (0)
152#define SATA_MISC_REG (HWIF(drive)->sata_misc[SATA_MISC_OFFSET])
153#define SATA_PHY_OFFSET (1)
154#define SATA_PHY_REG (HWIF(drive)->sata_misc[SATA_PHY_OFFSET])
155#define SATA_IEN_OFFSET (2)
156#define SATA_IEN_REG (HWIF(drive)->sata_misc[SATA_IEN_OFFSET])
157
158/*
159 * Our Physical Region Descriptor (PRD) table should be large enough
160 * to handle the biggest I/O request we are likely to see. Since requests
161 * can have no more than 256 sectors, and since the typical blocksize is
162 * two or more sectors, we could get by with a limit of 128 entries here for
163 * the usual worst case. Most requests seem to include some contiguous blocks,
164 * further reducing the number of table entries required.
165 *
166 * The driver reverts to PIO mode for individual requests that exceed
167 * this limit (possible with 512 byte blocksizes, eg. MSDOS f/s), so handling
168 * 100% of all crazy scenarios here is not necessary.
169 *
170 * As it turns out though, we must allocate a full 4KB page for this,
171 * so the two PRD tables (ide0 & ide1) will each get half of that,
172 * allowing each to have about 256 entries (8 bytes each) from this.
173 */
174#define PRD_BYTES 8
175#define PRD_ENTRIES 256
176
177/*
178 * Some more useful definitions
179 */
180#define PARTN_BITS 6 /* number of minor dev bits for partitions */
181#define MAX_DRIVES 2 /* per interface; 2 assumed by lots of code */
182#define SECTOR_SIZE 512
183#define SECTOR_WORDS (SECTOR_SIZE / 4) /* number of 32bit words per sector */
184#define IDE_LARGE_SEEK(b1,b2,t) (((b1) > (b2) + (t)) || ((b2) > (b1) + (t)))
185
186/*
187 * Timeouts for various operations:
188 */
189#define WAIT_DRQ (HZ/10) /* 100msec - spec allows up to 20ms */
190#define WAIT_READY (5*HZ) /* 5sec - some laptops are very slow */
191#define WAIT_PIDENTIFY (10*HZ) /* 10sec - should be less than 3ms (?), if all ATAPI CD is closed at boot */
192#define WAIT_WORSTCASE (30*HZ) /* 30sec - worst case when spinning up */
193#define WAIT_CMD (10*HZ) /* 10sec - maximum wait for an IRQ to happen */
194#define WAIT_MIN_SLEEP (2*HZ/100) /* 20msec - minimum sleep time */
195
196#define HOST(hwif,chipset) \
197{ \
198 return ((hwif)->chipset == chipset) ? 1 : 0; \
199}
200
201/*
202 * Check for an interrupt and acknowledge the interrupt status
203 */
204struct hwif_s;
205typedef int (ide_ack_intr_t)(struct hwif_s *);
206
207#ifndef NO_DMA
208#define NO_DMA 255
209#endif
210
211/*
212 * hwif_chipset_t is used to keep track of the specific hardware
213 * chipset used by each IDE interface, if known.
214 */
215typedef enum { ide_unknown, ide_generic, ide_pci,
216 ide_cmd640, ide_dtc2278, ide_ali14xx,
217 ide_qd65xx, ide_umc8672, ide_ht6560b,
218 ide_rz1000, ide_trm290,
219 ide_cmd646, ide_cy82c693, ide_4drives,
220 ide_pmac, ide_etrax100, ide_acorn,
221 ide_forced
222} hwif_chipset_t;
223
224/*
225 * Structure to hold all information about the location of this port
226 */
227typedef struct hw_regs_s {
228 unsigned long io_ports[IDE_NR_PORTS]; /* task file registers */
229 int irq; /* our irq number */
230 int dma; /* our dma entry */
231 ide_ack_intr_t *ack_intr; /* acknowledge interrupt */
232 hwif_chipset_t chipset;
233} hw_regs_t;
234
235/*
236 * Register new hardware with ide
237 */
238int ide_register_hw(hw_regs_t *hw, struct hwif_s **hwifp);
239int ide_register_hw_with_fixup(hw_regs_t *, struct hwif_s **, void (*)(struct hwif_s *));
240
241/*
242 * Set up hw_regs_t structure before calling ide_register_hw (optional)
243 */
244void ide_setup_ports( hw_regs_t *hw,
245 unsigned long base,
246 int *offsets,
247 unsigned long ctrl,
248 unsigned long intr,
249 ide_ack_intr_t *ack_intr,
250#if 0
251 ide_io_ops_t *iops,
252#endif
253 int irq);
254
255static inline void ide_std_init_ports(hw_regs_t *hw,
256 unsigned long io_addr,
257 unsigned long ctl_addr)
258{
259 unsigned int i;
260
261 for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++)
262 hw->io_ports[i] = io_addr++;
263
264 hw->io_ports[IDE_CONTROL_OFFSET] = ctl_addr;
265}
266
267#include <asm/ide.h>
268
269/* needed on alpha, x86/x86_64, ia64, mips, ppc32 and sh */
270#ifndef IDE_ARCH_OBSOLETE_DEFAULTS
271# define ide_default_io_base(index) (0)
272# define ide_default_irq(base) (0)
273# define ide_init_default_irq(base) (0)
274#endif
275
276/*
277 * ide_init_hwif_ports() is OBSOLETE and will be removed in 2.7 series.
278 * New ports shouldn't define IDE_ARCH_OBSOLETE_INIT in <asm/ide.h>.
279 */
280#ifdef IDE_ARCH_OBSOLETE_INIT
281static inline void ide_init_hwif_ports(hw_regs_t *hw,
282 unsigned long io_addr,
283 unsigned long ctl_addr,
284 int *irq)
285{
286 if (!ctl_addr)
287 ide_std_init_ports(hw, io_addr, ide_default_io_ctl(io_addr));
288 else
289 ide_std_init_ports(hw, io_addr, ctl_addr);
290
291 if (irq)
292 *irq = 0;
293
294 hw->io_ports[IDE_IRQ_OFFSET] = 0;
295
296#ifdef CONFIG_PPC32
297 if (ppc_ide_md.ide_init_hwif)
298 ppc_ide_md.ide_init_hwif(hw, io_addr, ctl_addr, irq);
299#endif
300}
301#else
302static inline void ide_init_hwif_ports(hw_regs_t *hw,
303 unsigned long io_addr,
304 unsigned long ctl_addr,
305 int *irq)
306{
307 if (io_addr || ctl_addr)
308 printk(KERN_WARNING "%s: must not be called\n", __FUNCTION__);
309}
310#endif /* IDE_ARCH_OBSOLETE_INIT */
311
312/* Currently only m68k, apus and m8xx need it */
313#ifndef IDE_ARCH_ACK_INTR
314# define ide_ack_intr(hwif) (1)
315#endif
316
317/* Currently only Atari needs it */
318#ifndef IDE_ARCH_LOCK
319# define ide_release_lock() do {} while (0)
320# define ide_get_lock(hdlr, data) do {} while (0)
321#endif /* IDE_ARCH_LOCK */
322
323/*
324 * Now for the data we need to maintain per-drive: ide_drive_t
325 */
326
327#define ide_scsi 0x21
328#define ide_disk 0x20
329#define ide_optical 0x7
330#define ide_cdrom 0x5
331#define ide_tape 0x1
332#define ide_floppy 0x0
333
334/*
335 * Special Driver Flags
336 *
337 * set_geometry : respecify drive geometry
338 * recalibrate : seek to cyl 0
339 * set_multmode : set multmode count
340 * set_tune : tune interface for drive
341 * serviced : service command
342 * reserved : unused
343 */
344typedef union {
345 unsigned all : 8;
346 struct {
347#if defined(__LITTLE_ENDIAN_BITFIELD)
348 unsigned set_geometry : 1;
349 unsigned recalibrate : 1;
350 unsigned set_multmode : 1;
351 unsigned set_tune : 1;
352 unsigned serviced : 1;
353 unsigned reserved : 3;
354#elif defined(__BIG_ENDIAN_BITFIELD)
355 unsigned reserved : 3;
356 unsigned serviced : 1;
357 unsigned set_tune : 1;
358 unsigned set_multmode : 1;
359 unsigned recalibrate : 1;
360 unsigned set_geometry : 1;
361#else
362#error "Please fix <asm/byteorder.h>"
363#endif
364 } b;
365} special_t;
366
367/*
368 * ATA DATA Register Special.
369 * ATA NSECTOR Count Register().
370 * ATAPI Byte Count Register.
371 * Channel index ordering pairs.
372 */
373typedef union {
374 unsigned all :16;
375 struct {
376#if defined(__LITTLE_ENDIAN_BITFIELD)
377 unsigned low :8; /* LSB */
378 unsigned high :8; /* MSB */
379#elif defined(__BIG_ENDIAN_BITFIELD)
380 unsigned high :8; /* MSB */
381 unsigned low :8; /* LSB */
382#else
383#error "Please fix <asm/byteorder.h>"
384#endif
385 } b;
386} ata_nsector_t, ata_data_t, atapi_bcount_t, ata_index_t;
387
388/*
389 * ATA-IDE Error Register
390 *
391 * mark : Bad address mark
392 * tzero : Couldn't find track 0
393 * abrt : Aborted Command
394 * mcr : Media Change Request
395 * id : ID field not found
396 * mce : Media Change Event
397 * ecc : Uncorrectable ECC error
398 * bdd : dual meaing
399 */
400typedef union {
401 unsigned all :8;
402 struct {
403#if defined(__LITTLE_ENDIAN_BITFIELD)
404 unsigned mark :1;
405 unsigned tzero :1;
406 unsigned abrt :1;
407 unsigned mcr :1;
408 unsigned id :1;
409 unsigned mce :1;
410 unsigned ecc :1;
411 unsigned bdd :1;
412#elif defined(__BIG_ENDIAN_BITFIELD)
413 unsigned bdd :1;
414 unsigned ecc :1;
415 unsigned mce :1;
416 unsigned id :1;
417 unsigned mcr :1;
418 unsigned abrt :1;
419 unsigned tzero :1;
420 unsigned mark :1;
421#else
422#error "Please fix <asm/byteorder.h>"
423#endif
424 } b;
425} ata_error_t;
426
427/*
428 * ATA-IDE Select Register, aka Device-Head
429 *
430 * head : always zeros here
431 * unit : drive select number: 0/1
432 * bit5 : always 1
433 * lba : using LBA instead of CHS
434 * bit7 : always 1
435 */
436typedef union {
437 unsigned all : 8;
438 struct {
439#if defined(__LITTLE_ENDIAN_BITFIELD)
440 unsigned head : 4;
441 unsigned unit : 1;
442 unsigned bit5 : 1;
443 unsigned lba : 1;
444 unsigned bit7 : 1;
445#elif defined(__BIG_ENDIAN_BITFIELD)
446 unsigned bit7 : 1;
447 unsigned lba : 1;
448 unsigned bit5 : 1;
449 unsigned unit : 1;
450 unsigned head : 4;
451#else
452#error "Please fix <asm/byteorder.h>"
453#endif
454 } b;
455} select_t, ata_select_t;
456
457/*
458 * The ATA-IDE Status Register.
459 * The ATAPI Status Register.
460 *
461 * check : Error occurred
462 * idx : Index Error
463 * corr : Correctable error occurred
464 * drq : Data is request by the device
465 * dsc : Disk Seek Complete : ata
466 * : Media access command finished : atapi
467 * df : Device Fault : ata
468 * : Reserved : atapi
469 * drdy : Ready, Command Mode Capable : ata
470 * : Ignored for ATAPI commands : atapi
471 * bsy : Disk is Busy
472 * : The device has access to the command block
473 */
474typedef union {
475 unsigned all :8;
476 struct {
477#if defined(__LITTLE_ENDIAN_BITFIELD)
478 unsigned check :1;
479 unsigned idx :1;
480 unsigned corr :1;
481 unsigned drq :1;
482 unsigned dsc :1;
483 unsigned df :1;
484 unsigned drdy :1;
485 unsigned bsy :1;
486#elif defined(__BIG_ENDIAN_BITFIELD)
487 unsigned bsy :1;
488 unsigned drdy :1;
489 unsigned df :1;
490 unsigned dsc :1;
491 unsigned drq :1;
492 unsigned corr :1;
493 unsigned idx :1;
494 unsigned check :1;
495#else
496#error "Please fix <asm/byteorder.h>"
497#endif
498 } b;
499} ata_status_t, atapi_status_t;
500
501/*
502 * ATA-IDE Control Register
503 *
504 * bit0 : Should be set to zero
505 * nIEN : device INTRQ to host
506 * SRST : host soft reset bit
507 * bit3 : ATA-2 thingy, Should be set to 1
508 * reserved456 : Reserved
509 * HOB : 48-bit address ordering, High Ordered Bit
510 */
511typedef union {
512 unsigned all : 8;
513 struct {
514#if defined(__LITTLE_ENDIAN_BITFIELD)
515 unsigned bit0 : 1;
516 unsigned nIEN : 1;
517 unsigned SRST : 1;
518 unsigned bit3 : 1;
519 unsigned reserved456 : 3;
520 unsigned HOB : 1;
521#elif defined(__BIG_ENDIAN_BITFIELD)
522 unsigned HOB : 1;
523 unsigned reserved456 : 3;
524 unsigned bit3 : 1;
525 unsigned SRST : 1;
526 unsigned nIEN : 1;
527 unsigned bit0 : 1;
528#else
529#error "Please fix <asm/byteorder.h>"
530#endif
531 } b;
532} ata_control_t;
533
534/*
535 * ATAPI Feature Register
536 *
537 * dma : Using DMA or PIO
538 * reserved321 : Reserved
539 * reserved654 : Reserved (Tag Type)
540 * reserved7 : Reserved
541 */
542typedef union {
543 unsigned all :8;
544 struct {
545#if defined(__LITTLE_ENDIAN_BITFIELD)
546 unsigned dma :1;
547 unsigned reserved321 :3;
548 unsigned reserved654 :3;
549 unsigned reserved7 :1;
550#elif defined(__BIG_ENDIAN_BITFIELD)
551 unsigned reserved7 :1;
552 unsigned reserved654 :3;
553 unsigned reserved321 :3;
554 unsigned dma :1;
555#else
556#error "Please fix <asm/byteorder.h>"
557#endif
558 } b;
559} atapi_feature_t;
560
561/*
562 * ATAPI Interrupt Reason Register.
563 *
564 * cod : Information transferred is command (1) or data (0)
565 * io : The device requests us to read (1) or write (0)
566 * reserved : Reserved
567 */
568typedef union {
569 unsigned all :8;
570 struct {
571#if defined(__LITTLE_ENDIAN_BITFIELD)
572 unsigned cod :1;
573 unsigned io :1;
574 unsigned reserved :6;
575#elif defined(__BIG_ENDIAN_BITFIELD)
576 unsigned reserved :6;
577 unsigned io :1;
578 unsigned cod :1;
579#else
580#error "Please fix <asm/byteorder.h>"
581#endif
582 } b;
583} atapi_ireason_t;
584
585/*
586 * The ATAPI error register.
587 *
588 * ili : Illegal Length Indication
589 * eom : End Of Media Detected
590 * abrt : Aborted command - As defined by ATA
591 * mcr : Media Change Requested - As defined by ATA
592 * sense_key : Sense key of the last failed packet command
593 */
594typedef union {
595 unsigned all :8;
596 struct {
597#if defined(__LITTLE_ENDIAN_BITFIELD)
598 unsigned ili :1;
599 unsigned eom :1;
600 unsigned abrt :1;
601 unsigned mcr :1;
602 unsigned sense_key :4;
603#elif defined(__BIG_ENDIAN_BITFIELD)
604 unsigned sense_key :4;
605 unsigned mcr :1;
606 unsigned abrt :1;
607 unsigned eom :1;
608 unsigned ili :1;
609#else
610#error "Please fix <asm/byteorder.h>"
611#endif
612 } b;
613} atapi_error_t;
614
615/*
616 * ATAPI floppy Drive Select Register
617 *
618 * sam_lun : Logical unit number
619 * reserved3 : Reserved
620 * drv : The responding drive will be drive 0 (0) or drive 1 (1)
621 * one5 : Should be set to 1
622 * reserved6 : Reserved
623 * one7 : Should be set to 1
624 */
625typedef union {
626 unsigned all :8;
627 struct {
628#if defined(__LITTLE_ENDIAN_BITFIELD)
629 unsigned sam_lun :3;
630 unsigned reserved3 :1;
631 unsigned drv :1;
632 unsigned one5 :1;
633 unsigned reserved6 :1;
634 unsigned one7 :1;
635#elif defined(__BIG_ENDIAN_BITFIELD)
636 unsigned one7 :1;
637 unsigned reserved6 :1;
638 unsigned one5 :1;
639 unsigned drv :1;
640 unsigned reserved3 :1;
641 unsigned sam_lun :3;
642#else
643#error "Please fix <asm/byteorder.h>"
644#endif
645 } b;
646} atapi_select_t;
647
648/*
649 * Status returned from various ide_ functions
650 */
651typedef enum {
652 ide_stopped, /* no drive operation was started */
653 ide_started, /* a drive operation was started, handler was set */
654} ide_startstop_t;
655
656struct ide_driver_s;
657struct ide_settings_s;
658
659typedef struct ide_drive_s {
660 char name[4]; /* drive name, such as "hda" */
661 char driver_req[10]; /* requests specific driver */
662
663 request_queue_t *queue; /* request queue */
664
665 struct request *rq; /* current request */
666 struct ide_drive_s *next; /* circular list of hwgroup drives */
667 struct ide_driver_s *driver;/* (ide_driver_t *) */
668 void *driver_data; /* extra driver data */
669 struct hd_driveid *id; /* drive model identification info */
670 struct proc_dir_entry *proc; /* /proc/ide/ directory entry */
671 struct ide_settings_s *settings;/* /proc/ide/ drive settings */
672 char devfs_name[64]; /* devfs crap */
673
674 struct hwif_s *hwif; /* actually (ide_hwif_t *) */
675
676 unsigned long sleep; /* sleep until this time */
677 unsigned long service_start; /* time we started last request */
678 unsigned long service_time; /* service time of last request */
679 unsigned long timeout; /* max time to wait for irq */
680
681 special_t special; /* special action flags */
682 select_t select; /* basic drive/head select reg value */
683
684 u8 keep_settings; /* restore settings after drive reset */
685 u8 autodma; /* device can safely use dma on host */
686 u8 using_dma; /* disk is using dma for read/write */
687 u8 retry_pio; /* retrying dma capable host in pio */
688 u8 state; /* retry state */
689 u8 waiting_for_dma; /* dma currently in progress */
690 u8 unmask; /* okay to unmask other irqs */
691 u8 bswap; /* byte swap data */
692 u8 dsc_overlap; /* DSC overlap */
693 u8 nice1; /* give potential excess bandwidth */
694
695 unsigned present : 1; /* drive is physically present */
696 unsigned dead : 1; /* device ejected hint */
697 unsigned id_read : 1; /* 1=id read from disk 0 = synthetic */
698 unsigned noprobe : 1; /* from: hdx=noprobe */
699 unsigned removable : 1; /* 1 if need to do check_media_change */
700 unsigned attach : 1; /* needed for removable devices */
701 unsigned is_flash : 1; /* 1 if probed as flash */
702 unsigned forced_geom : 1; /* 1 if hdx=c,h,s was given at boot */
703 unsigned no_unmask : 1; /* disallow setting unmask bit */
704 unsigned no_io_32bit : 1; /* disallow enabling 32bit I/O */
705 unsigned atapi_overlap : 1; /* ATAPI overlap (not supported) */
706 unsigned nice0 : 1; /* give obvious excess bandwidth */
707 unsigned nice2 : 1; /* give a share in our own bandwidth */
708 unsigned doorlocking : 1; /* for removable only: door lock/unlock works */
709 unsigned autotune : 2; /* 0=default, 1=autotune, 2=noautotune */
710 unsigned remap_0_to_1 : 1; /* 0=noremap, 1=remap 0->1 (for EZDrive) */
711 unsigned blocked : 1; /* 1=powermanagment told us not to do anything, so sleep nicely */
712 unsigned vdma : 1; /* 1=doing PIO over DMA 0=doing normal DMA */
713 unsigned addressing; /* : 3;
714 * 0=28-bit
715 * 1=48-bit
716 * 2=48-bit doing 28-bit
717 * 3=64-bit
718 */
719 unsigned scsi : 1; /* 0=default, 1=ide-scsi emulation */
720 unsigned sleeping : 1; /* 1=sleeping & sleep field valid */
721 unsigned post_reset : 1;
722
723 u8 quirk_list; /* considered quirky, set for a specific host */
724 u8 init_speed; /* transfer rate set at boot */
725 u8 pio_speed; /* unused by core, used by some drivers for fallback from DMA */
726 u8 current_speed; /* current transfer rate set */
727 u8 dn; /* now wide spread use */
728 u8 wcache; /* status of write cache */
729 u8 acoustic; /* acoustic management */
730 u8 media; /* disk, cdrom, tape, floppy, ... */
731 u8 ctl; /* "normal" value for IDE_CONTROL_REG */
732 u8 ready_stat; /* min status value for drive ready */
733 u8 mult_count; /* current multiple sector setting */
734 u8 mult_req; /* requested multiple sector setting */
735 u8 tune_req; /* requested drive tuning setting */
736 u8 io_32bit; /* 0=16-bit, 1=32-bit, 2/3=32bit+sync */
737 u8 bad_wstat; /* used for ignoring WRERR_STAT */
738 u8 nowerr; /* used for ignoring WRERR_STAT */
739 u8 sect0; /* offset of first sector for DM6:DDO */
740 u8 head; /* "real" number of heads */
741 u8 sect; /* "real" sectors per track */
742 u8 bios_head; /* BIOS/fdisk/LILO number of heads */
743 u8 bios_sect; /* BIOS/fdisk/LILO sectors per track */
744
745 unsigned int bios_cyl; /* BIOS/fdisk/LILO number of cyls */
746 unsigned int cyl; /* "real" number of cyls */
747 unsigned int drive_data; /* use by tuneproc/selectproc */
748 unsigned int usage; /* current "open()" count for drive */
749 unsigned int failures; /* current failure count */
750 unsigned int max_failures; /* maximum allowed failure count */
751
752 u64 capacity64; /* total number of sectors */
753
754 int lun; /* logical unit */
755 int crc_count; /* crc counter to reduce drive speed */
756 struct list_head list;
757 struct device gendev;
758 struct semaphore gendev_rel_sem; /* to deal with device release() */
759} ide_drive_t;
760
761#define IDE_CHIPSET_PCI_MASK \
762 ((1<<ide_pci)|(1<<ide_cmd646)|(1<<ide_ali14xx))
763#define IDE_CHIPSET_IS_PCI(c) ((IDE_CHIPSET_PCI_MASK >> (c)) & 1)
764
765struct ide_pci_device_s;
766
767typedef struct hwif_s {
768 struct hwif_s *next; /* for linked-list in ide_hwgroup_t */
769 struct hwif_s *mate; /* other hwif from same PCI chip */
770 struct hwgroup_s *hwgroup; /* actually (ide_hwgroup_t *) */
771 struct proc_dir_entry *proc; /* /proc/ide/ directory entry */
772
773 char name[6]; /* name of interface, eg. "ide0" */
774
775 /* task file registers for pata and sata */
776 unsigned long io_ports[IDE_NR_PORTS];
777 unsigned long sata_scr[SATA_NR_PORTS];
778 unsigned long sata_misc[SATA_NR_PORTS];
779
780 hw_regs_t hw; /* Hardware info */
781 ide_drive_t drives[MAX_DRIVES]; /* drive info */
782
783 u8 major; /* our major number */
784 u8 index; /* 0 for ide0; 1 for ide1; ... */
785 u8 channel; /* for dual-port chips: 0=primary, 1=secondary */
786 u8 straight8; /* Alan's straight 8 check */
787 u8 bus_state; /* power state of the IDE bus */
788
789 u8 atapi_dma; /* host supports atapi_dma */
790 u8 ultra_mask;
791 u8 mwdma_mask;
792 u8 swdma_mask;
793
794 hwif_chipset_t chipset; /* sub-module for tuning.. */
795
796 struct pci_dev *pci_dev; /* for pci chipsets */
797 struct ide_pci_device_s *cds; /* chipset device struct */
798
799 void (*rw_disk)(ide_drive_t *, struct request *);
800
801#if 0
802 ide_hwif_ops_t *hwifops;
803#else
804 /* routine to tune PIO mode for drives */
805 void (*tuneproc)(ide_drive_t *, u8);
806 /* routine to retune DMA modes for drives */
807 int (*speedproc)(ide_drive_t *, u8);
808 /* tweaks hardware to select drive */
809 void (*selectproc)(ide_drive_t *);
810 /* chipset polling based on hba specifics */
811 int (*reset_poll)(ide_drive_t *);
812 /* chipset specific changes to default for device-hba resets */
813 void (*pre_reset)(ide_drive_t *);
814 /* routine to reset controller after a disk reset */
815 void (*resetproc)(ide_drive_t *);
816 /* special interrupt handling for shared pci interrupts */
817 void (*intrproc)(ide_drive_t *);
818 /* special host masking for drive selection */
819 void (*maskproc)(ide_drive_t *, int);
820 /* check host's drive quirk list */
821 int (*quirkproc)(ide_drive_t *);
822 /* driver soft-power interface */
823 int (*busproc)(ide_drive_t *, int);
824// /* host rate limiter */
825// u8 (*ratemask)(ide_drive_t *);
826// /* device rate limiter */
827// u8 (*ratefilter)(ide_drive_t *, u8);
828#endif
829
830 void (*ata_input_data)(ide_drive_t *, void *, u32);
831 void (*ata_output_data)(ide_drive_t *, void *, u32);
832
833 void (*atapi_input_bytes)(ide_drive_t *, void *, u32);
834 void (*atapi_output_bytes)(ide_drive_t *, void *, u32);
835
836 int (*dma_setup)(ide_drive_t *);
837 void (*dma_exec_cmd)(ide_drive_t *, u8);
838 void (*dma_start)(ide_drive_t *);
839 int (*ide_dma_end)(ide_drive_t *drive);
840 int (*ide_dma_check)(ide_drive_t *drive);
841 int (*ide_dma_on)(ide_drive_t *drive);
842 int (*ide_dma_off_quietly)(ide_drive_t *drive);
843 int (*ide_dma_test_irq)(ide_drive_t *drive);
844 int (*ide_dma_host_on)(ide_drive_t *drive);
845 int (*ide_dma_host_off)(ide_drive_t *drive);
846 int (*ide_dma_lostirq)(ide_drive_t *drive);
847 int (*ide_dma_timeout)(ide_drive_t *drive);
848
849 void (*OUTB)(u8 addr, unsigned long port);
850 void (*OUTBSYNC)(ide_drive_t *drive, u8 addr, unsigned long port);
851 void (*OUTW)(u16 addr, unsigned long port);
852 void (*OUTL)(u32 addr, unsigned long port);
853 void (*OUTSW)(unsigned long port, void *addr, u32 count);
854 void (*OUTSL)(unsigned long port, void *addr, u32 count);
855
856 u8 (*INB)(unsigned long port);
857 u16 (*INW)(unsigned long port);
858 u32 (*INL)(unsigned long port);
859 void (*INSW)(unsigned long port, void *addr, u32 count);
860 void (*INSL)(unsigned long port, void *addr, u32 count);
861
862 /* dma physical region descriptor table (cpu view) */
863 unsigned int *dmatable_cpu;
864 /* dma physical region descriptor table (dma view) */
865 dma_addr_t dmatable_dma;
866 /* Scatter-gather list used to build the above */
867 struct scatterlist *sg_table;
868 int sg_max_nents; /* Maximum number of entries in it */
869 int sg_nents; /* Current number of entries in it */
870 int sg_dma_direction; /* dma transfer direction */
871
872 /* data phase of the active command (currently only valid for PIO/DMA) */
873 int data_phase;
874
875 unsigned int nsect;
876 unsigned int nleft;
877 unsigned int cursg;
878 unsigned int cursg_ofs;
879
880 int mmio; /* hosts iomio (0) or custom (2) select */
881 int rqsize; /* max sectors per request */
882 int irq; /* our irq number */
883
884 unsigned long dma_master; /* reference base addr dmabase */
885 unsigned long dma_base; /* base addr for dma ports */
886 unsigned long dma_command; /* dma command register */
887 unsigned long dma_vendor1; /* dma vendor 1 register */
888 unsigned long dma_status; /* dma status register */
889 unsigned long dma_vendor3; /* dma vendor 3 register */
890 unsigned long dma_prdtable; /* actual prd table address */
891 unsigned long dma_base2; /* extended base addr for dma ports */
892
893 unsigned dma_extra; /* extra addr for dma ports */
894 unsigned long config_data; /* for use by chipset-specific code */
895 unsigned long select_data; /* for use by chipset-specific code */
896
897 unsigned noprobe : 1; /* don't probe for this interface */
898 unsigned present : 1; /* this interface exists */
899 unsigned hold : 1; /* this interface is always present */
900 unsigned serialized : 1; /* serialized all channel operation */
901 unsigned sharing_irq: 1; /* 1 = sharing irq with another hwif */
902 unsigned reset : 1; /* reset after probe */
903 unsigned autodma : 1; /* auto-attempt using DMA at boot */
904 unsigned udma_four : 1; /* 1=ATA-66 capable, 0=default */
905 unsigned no_lba48 : 1; /* 1 = cannot do LBA48 */
906 unsigned no_lba48_dma : 1; /* 1 = cannot do LBA48 DMA */
907 unsigned no_dsc : 1; /* 0 default, 1 dsc_overlap disabled */
908 unsigned auto_poll : 1; /* supports nop auto-poll */
909 unsigned sg_mapped : 1; /* sg_table and sg_nents are ready */
910
911 struct device gendev;
912 struct semaphore gendev_rel_sem; /* To deal with device release() */
913
914 void *hwif_data; /* extra hwif data */
915
916 unsigned dma;
917
918 void (*led_act)(void *data, int rw);
919} ide_hwif_t;
920
921/*
922 * internal ide interrupt handler type
923 */
924typedef ide_startstop_t (ide_pre_handler_t)(ide_drive_t *, struct request *);
925typedef ide_startstop_t (ide_handler_t)(ide_drive_t *);
926typedef int (ide_expiry_t)(ide_drive_t *);
927
928typedef struct hwgroup_s {
929 /* irq handler, if active */
930 ide_startstop_t (*handler)(ide_drive_t *);
931 /* irq handler, suspended if active */
932 ide_startstop_t (*handler_save)(ide_drive_t *);
933 /* BOOL: protects all fields below */
934 volatile int busy;
935 /* BOOL: wake us up on timer expiry */
936 unsigned int sleeping : 1;
937 /* BOOL: polling active & poll_timeout field valid */
938 unsigned int polling : 1;
939 /* current drive */
940 ide_drive_t *drive;
941 /* ptr to current hwif in linked-list */
942 ide_hwif_t *hwif;
943
944 /* for pci chipsets */
945 struct pci_dev *pci_dev;
946 /* chipset device struct */
947 struct ide_pci_device_s *cds;
948
949 /* current request */
950 struct request *rq;
951 /* failsafe timer */
952 struct timer_list timer;
953 /* local copy of current write rq */
954 struct request wrq;
955 /* timeout value during long polls */
956 unsigned long poll_timeout;
957 /* queried upon timeouts */
958 int (*expiry)(ide_drive_t *);
959 /* ide_system_bus_speed */
960 int pio_clock;
961
962 unsigned char cmd_buf[4];
963} ide_hwgroup_t;
964
965/* structure attached to the request for IDE_TASK_CMDS */
966
967/*
968 * configurable drive settings
969 */
970
971#define TYPE_INT 0
972#define TYPE_INTA 1
973#define TYPE_BYTE 2
974#define TYPE_SHORT 3
975
976#define SETTING_READ (1 << 0)
977#define SETTING_WRITE (1 << 1)
978#define SETTING_RW (SETTING_READ | SETTING_WRITE)
979
980typedef int (ide_procset_t)(ide_drive_t *, int);
981typedef struct ide_settings_s {
982 char *name;
983 int rw;
984 int read_ioctl;
985 int write_ioctl;
986 int data_type;
987 int min;
988 int max;
989 int mul_factor;
990 int div_factor;
991 void *data;
992 ide_procset_t *set;
993 int auto_remove;
994 struct ide_settings_s *next;
995} ide_settings_t;
996
997extern struct semaphore ide_setting_sem;
998extern int ide_add_setting(ide_drive_t *drive, const char *name, int rw, int read_ioctl, int write_ioctl, int data_type, int min, int max, int mul_factor, int div_factor, void *data, ide_procset_t *set);
999extern ide_settings_t *ide_find_setting_by_name(ide_drive_t *drive, char *name);
1000extern int ide_read_setting(ide_drive_t *t, ide_settings_t *setting);
1001extern int ide_write_setting(ide_drive_t *drive, ide_settings_t *setting, int val);
1002extern void ide_add_generic_settings(ide_drive_t *drive);
1003
1004/*
1005 * /proc/ide interface
1006 */
1007typedef struct {
1008 const char *name;
1009 mode_t mode;
1010 read_proc_t *read_proc;
1011 write_proc_t *write_proc;
1012} ide_proc_entry_t;
1013
1014#ifdef CONFIG_PROC_FS
1015extern struct proc_dir_entry *proc_ide_root;
1016
1017extern void proc_ide_create(void);
1018extern void proc_ide_destroy(void);
1019extern void create_proc_ide_interfaces(void);
1020void destroy_proc_ide_interface(ide_hwif_t *);
1021extern void ide_add_proc_entries(struct proc_dir_entry *, ide_proc_entry_t *, void *);
1022extern void ide_remove_proc_entries(struct proc_dir_entry *, ide_proc_entry_t *);
1023read_proc_t proc_ide_read_capacity;
1024read_proc_t proc_ide_read_geometry;
1025
1026#ifdef CONFIG_BLK_DEV_IDEPCI
1027void ide_pci_create_host_proc(const char *, get_info_t *);
1028#endif
1029
1030/*
1031 * Standard exit stuff:
1032 */
1033#define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) \
1034{ \
1035 len -= off; \
1036 if (len < count) { \
1037 *eof = 1; \
1038 if (len <= 0) \
1039 return 0; \
1040 } else \
1041 len = count; \
1042 *start = page + off; \
1043 return len; \
1044}
1045#else
1046static inline void create_proc_ide_interfaces(void) { ; }
1047static inline void destroy_proc_ide_interface(ide_hwif_t *hwif) { ; }
1048#define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) return 0;
1049#endif
1050
1051/*
1052 * Power Management step value (rq->pm->pm_step).
1053 *
1054 * The step value starts at 0 (ide_pm_state_start_suspend) for a
1055 * suspend operation or 1000 (ide_pm_state_start_resume) for a
1056 * resume operation.
1057 *
1058 * For each step, the core calls the subdriver start_power_step() first.
1059 * This can return:
1060 * - ide_stopped : In this case, the core calls us back again unless
1061 * step have been set to ide_power_state_completed.
1062 * - ide_started : In this case, the channel is left busy until an
1063 * async event (interrupt) occurs.
1064 * Typically, start_power_step() will issue a taskfile request with
1065 * do_rw_taskfile().
1066 *
1067 * Upon reception of the interrupt, the core will call complete_power_step()
1068 * with the error code if any. This routine should update the step value
1069 * and return. It should not start a new request. The core will call
1070 * start_power_step for the new step value, unless step have been set to
1071 * ide_power_state_completed.
1072 *
1073 * Subdrivers are expected to define their own additional power
1074 * steps from 1..999 for suspend and from 1001..1999 for resume,
1075 * other values are reserved for future use.
1076 */
1077
1078enum {
1079 ide_pm_state_completed = -1,
1080 ide_pm_state_start_suspend = 0,
1081 ide_pm_state_start_resume = 1000,
1082};
1083
1084/*
1085 * Subdrivers support.
1086 */
1087typedef struct ide_driver_s {
1088 struct module *owner;
1089 const char *name;
1090 const char *version;
1091 u8 media;
1092 unsigned busy : 1;
1093 unsigned supports_dsc_overlap : 1;
1094 int (*cleanup)(ide_drive_t *);
1095 ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t);
1096 int (*end_request)(ide_drive_t *, int, int);
1097 ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8);
1098 ide_startstop_t (*abort)(ide_drive_t *, struct request *rq);
1099 int (*ioctl)(ide_drive_t *, struct inode *, struct file *, unsigned int, unsigned long);
1100 ide_proc_entry_t *proc;
1101 int (*attach)(ide_drive_t *);
1102 void (*ata_prebuilder)(ide_drive_t *);
1103 void (*atapi_prebuilder)(ide_drive_t *);
1104 struct device_driver gen_driver;
1105 struct list_head drives;
1106 struct list_head drivers;
1107} ide_driver_t;
1108
1109#define DRIVER(drive) ((drive)->driver)
1110
1111int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, unsigned, unsigned long);
1112
1113/*
1114 * ide_hwifs[] is the master data structure used to keep track
1115 * of just about everything in ide.c. Whenever possible, routines
1116 * should be using pointers to a drive (ide_drive_t *) or
1117 * pointers to a hwif (ide_hwif_t *), rather than indexing this
1118 * structure directly (the allocation/layout may change!).
1119 *
1120 */
1121#ifndef _IDE_C
1122extern ide_hwif_t ide_hwifs[]; /* master data repository */
1123#endif
1124extern int noautodma;
1125
1126extern int ide_end_request (ide_drive_t *drive, int uptodate, int nrsecs);
1127extern int __ide_end_request (ide_drive_t *drive, struct request *rq, int uptodate, int nrsecs);
1128
1129/*
1130 * This is used on exit from the driver to designate the next irq handler
1131 * and also to start the safety timer.
1132 */
1133extern void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry);
1134
1135/*
1136 * This is used on exit from the driver to designate the next irq handler
1137 * and start the safety time safely and atomically from the IRQ handler
1138 * with respect to the command issue (which it also does)
1139 */
1140extern void ide_execute_command(ide_drive_t *, task_ioreg_t cmd, ide_handler_t *, unsigned int, ide_expiry_t *);
1141
1142ide_startstop_t __ide_error(ide_drive_t *, struct request *, u8, u8);
1143
1144/*
1145 * ide_error() takes action based on the error returned by the controller.
1146 * The caller should return immediately after invoking this.
1147 *
1148 * (drive, msg, status)
1149 */
1150ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat);
1151
1152ide_startstop_t __ide_abort(ide_drive_t *, struct request *);
1153
1154/*
1155 * Abort a running command on the controller triggering the abort
1156 * from a host side, non error situation
1157 * (drive, msg)
1158 */
1159extern ide_startstop_t ide_abort(ide_drive_t *, const char *);
1160
1161extern void ide_fix_driveid(struct hd_driveid *);
1162/*
1163 * ide_fixstring() cleans up and (optionally) byte-swaps a text string,
1164 * removing leading/trailing blanks and compressing internal blanks.
1165 * It is primarily used to tidy up the model name/number fields as
1166 * returned by the WIN_[P]IDENTIFY commands.
1167 *
1168 * (s, bytecount, byteswap)
1169 */
1170extern void ide_fixstring(u8 *, const int, const int);
1171
1172/*
1173 * This routine busy-waits for the drive status to be not "busy".
1174 * It then checks the status for all of the "good" bits and none
1175 * of the "bad" bits, and if all is okay it returns 0. All other
1176 * cases return 1 after doing "*startstop = ide_error()", and the
1177 * caller should return the updated value of "startstop" in this case.
1178 * "startstop" is unchanged when the function returns 0;
1179 * (startstop, drive, good, bad, timeout)
1180 */
1181extern int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long);
1182
1183/*
1184 * Start a reset operation for an IDE interface.
1185 * The caller should return immediately after invoking this.
1186 */
1187extern ide_startstop_t ide_do_reset (ide_drive_t *);
1188
1189/*
1190 * This function is intended to be used prior to invoking ide_do_drive_cmd().
1191 */
1192extern void ide_init_drive_cmd (struct request *rq);
1193
1194/*
1195 * this function returns error location sector offset in case of a write error
1196 */
1197extern u64 ide_get_error_location(ide_drive_t *, char *);
1198
1199/*
1200 * "action" parameter type for ide_do_drive_cmd() below.
1201 */
1202typedef enum {
1203 ide_wait, /* insert rq at end of list, and wait for it */
1204 ide_next, /* insert rq immediately after current request */
1205 ide_preempt, /* insert rq in front of current request */
1206 ide_head_wait, /* insert rq in front of current request and wait for it */
1207 ide_end /* insert rq at end of list, but don't wait for it */
1208} ide_action_t;
1209
1210/*
1211 * This function issues a special IDE device request
1212 * onto the request queue.
1213 *
1214 * If action is ide_wait, then the rq is queued at the end of the
1215 * request queue, and the function sleeps until it has been processed.
1216 * This is for use when invoked from an ioctl handler.
1217 *
1218 * If action is ide_preempt, then the rq is queued at the head of
1219 * the request queue, displacing the currently-being-processed
1220 * request and this function returns immediately without waiting
1221 * for the new rq to be completed. This is VERY DANGEROUS, and is
1222 * intended for careful use by the ATAPI tape/cdrom driver code.
1223 *
1224 * If action is ide_next, then the rq is queued immediately after
1225 * the currently-being-processed-request (if any), and the function
1226 * returns without waiting for the new rq to be completed. As above,
1227 * This is VERY DANGEROUS, and is intended for careful use by the
1228 * ATAPI tape/cdrom driver code.
1229 *
1230 * If action is ide_end, then the rq is queued at the end of the
1231 * request queue, and the function returns immediately without waiting
1232 * for the new rq to be completed. This is again intended for careful
1233 * use by the ATAPI tape/cdrom driver code.
1234 */
1235extern int ide_do_drive_cmd(ide_drive_t *, struct request *, ide_action_t);
1236
1237/*
1238 * Clean up after success/failure of an explicit drive cmd.
1239 * stat/err are used only when (HWGROUP(drive)->rq->cmd == IDE_DRIVE_CMD).
1240 * stat/err are used only when (HWGROUP(drive)->rq->cmd == IDE_DRIVE_TASK_MASK).
1241 *
1242 * (ide_drive_t *drive, u8 stat, u8 err)
1243 */
1244extern void ide_end_drive_cmd(ide_drive_t *, u8, u8);
1245
1246/*
1247 * Issue ATA command and wait for completion.
1248 * Use for implementing commands in kernel
1249 *
1250 * (ide_drive_t *drive, u8 cmd, u8 nsect, u8 feature, u8 sectors, u8 *buf)
1251 */
1252extern int ide_wait_cmd(ide_drive_t *, u8, u8, u8, u8, u8 *);
1253
1254typedef struct ide_task_s {
1255/*
1256 * struct hd_drive_task_hdr tf;
1257 * task_struct_t tf;
1258 * struct hd_drive_hob_hdr hobf;
1259 * hob_struct_t hobf;
1260 */
1261 task_ioreg_t tfRegister[8];
1262 task_ioreg_t hobRegister[8];
1263 ide_reg_valid_t tf_out_flags;
1264 ide_reg_valid_t tf_in_flags;
1265 int data_phase;
1266 int command_type;
1267 ide_pre_handler_t *prehandler;
1268 ide_handler_t *handler;
1269 struct request *rq; /* copy of request */
1270 void *special; /* valid_t generally */
1271} ide_task_t;
1272
1273extern u32 ide_read_24(ide_drive_t *);
1274
1275extern void SELECT_DRIVE(ide_drive_t *);
1276extern void SELECT_INTERRUPT(ide_drive_t *);
1277extern void SELECT_MASK(ide_drive_t *, int);
1278extern void QUIRK_LIST(ide_drive_t *);
1279
1280extern int drive_is_ready(ide_drive_t *);
1281extern int wait_for_ready(ide_drive_t *, int /* timeout */);
1282
1283/*
1284 * taskfile io for disks for now...and builds request from ide_ioctl
1285 */
1286extern ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *);
1287
1288/*
1289 * Special Flagged Register Validation Caller
1290 */
1291extern ide_startstop_t flagged_taskfile(ide_drive_t *, ide_task_t *);
1292
1293extern ide_startstop_t set_multmode_intr(ide_drive_t *);
1294extern ide_startstop_t set_geometry_intr(ide_drive_t *);
1295extern ide_startstop_t recal_intr(ide_drive_t *);
1296extern ide_startstop_t task_no_data_intr(ide_drive_t *);
1297extern ide_startstop_t task_in_intr(ide_drive_t *);
1298extern ide_startstop_t pre_task_out_intr(ide_drive_t *, struct request *);
1299
1300extern int ide_raw_taskfile(ide_drive_t *, ide_task_t *, u8 *);
1301
1302int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long);
1303int ide_cmd_ioctl(ide_drive_t *, unsigned int, unsigned long);
1304int ide_task_ioctl(ide_drive_t *, unsigned int, unsigned long);
1305
1306extern int system_bus_clock(void);
1307
1308extern int ide_driveid_update(ide_drive_t *);
1309extern int ide_ata66_check(ide_drive_t *, ide_task_t *);
1310extern int ide_config_drive_speed(ide_drive_t *, u8);
1311extern u8 eighty_ninty_three (ide_drive_t *);
1312extern int set_transfer(ide_drive_t *, ide_task_t *);
1313extern int taskfile_lib_get_identify(ide_drive_t *drive, u8 *);
1314
1315extern int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout);
1316
1317/*
1318 * ide_stall_queue() can be used by a drive to give excess bandwidth back
1319 * to the hwgroup by sleeping for timeout jiffies.
1320 */
1321extern void ide_stall_queue(ide_drive_t *drive, unsigned long timeout);
1322
1323extern int ide_spin_wait_hwgroup(ide_drive_t *);
1324extern void ide_timer_expiry(unsigned long);
1325extern irqreturn_t ide_intr(int irq, void *dev_id, struct pt_regs *regs);
1326extern void do_ide_request(request_queue_t *);
1327extern void ide_init_subdrivers(void);
1328
1329void ide_init_disk(struct gendisk *, ide_drive_t *);
1330
1331extern int ata_attach(ide_drive_t *);
1332
1333extern int ideprobe_init(void);
1334
1335extern void ide_scan_pcibus(int scan_direction) __init;
1336extern int ide_pci_register_driver(struct pci_driver *driver);
1337extern void ide_pci_unregister_driver(struct pci_driver *driver);
1338void ide_pci_setup_ports(struct pci_dev *, struct ide_pci_device_s *, int, ata_index_t *);
1339extern void ide_setup_pci_noise (struct pci_dev *dev, struct ide_pci_device_s *d);
1340
1341extern void default_hwif_iops(ide_hwif_t *);
1342extern void default_hwif_mmiops(ide_hwif_t *);
1343extern void default_hwif_transport(ide_hwif_t *);
1344
1345int ide_register_driver(ide_driver_t *driver);
1346void ide_unregister_driver(ide_driver_t *driver);
1347int ide_register_subdriver(ide_drive_t *, ide_driver_t *);
1348int ide_unregister_subdriver (ide_drive_t *drive);
1349int ide_replace_subdriver(ide_drive_t *drive, const char *driver);
1350
1351#define ON_BOARD 1
1352#define NEVER_BOARD 0
1353
1354#ifdef CONFIG_BLK_DEV_OFFBOARD
1355# define OFF_BOARD ON_BOARD
1356#else /* CONFIG_BLK_DEV_OFFBOARD */
1357# define OFF_BOARD NEVER_BOARD
1358#endif /* CONFIG_BLK_DEV_OFFBOARD */
1359
1360#define NODMA 0
1361#define NOAUTODMA 1
1362#define AUTODMA 2
1363
1364typedef struct ide_pci_enablebit_s {
1365 u8 reg; /* byte pci reg holding the enable-bit */
1366 u8 mask; /* mask to isolate the enable-bit */
1367 u8 val; /* value of masked reg when "enabled" */
1368} ide_pci_enablebit_t;
1369
1370enum {
1371 /* Uses ISA control ports not PCI ones. */
1372 IDEPCI_FLAG_ISA_PORTS = (1 << 0),
1373 IDEPCI_FLAG_FORCE_PDC = (1 << 1),
1374};
1375
1376typedef struct ide_pci_device_s {
1377 char *name;
1378 int (*init_setup)(struct pci_dev *, struct ide_pci_device_s *);
1379 void (*init_setup_dma)(struct pci_dev *, struct ide_pci_device_s *, ide_hwif_t *);
1380 unsigned int (*init_chipset)(struct pci_dev *, const char *);
1381 void (*init_iops)(ide_hwif_t *);
1382 void (*init_hwif)(ide_hwif_t *);
1383 void (*init_dma)(ide_hwif_t *, unsigned long);
1384 void (*fixup)(ide_hwif_t *);
1385 u8 channels;
1386 u8 autodma;
1387 ide_pci_enablebit_t enablebits[2];
1388 u8 bootable;
1389 unsigned int extra;
1390 struct ide_pci_device_s *next;
1391 u8 flags;
1392} ide_pci_device_t;
1393
1394extern int ide_setup_pci_device(struct pci_dev *, ide_pci_device_t *);
1395extern int ide_setup_pci_devices(struct pci_dev *, struct pci_dev *, ide_pci_device_t *);
1396
1397void ide_map_sg(ide_drive_t *, struct request *);
1398void ide_init_sg_cmd(ide_drive_t *, struct request *);
1399
1400#define BAD_DMA_DRIVE 0
1401#define GOOD_DMA_DRIVE 1
1402
1403#ifdef CONFIG_BLK_DEV_IDEDMA
1404int __ide_dma_bad_drive(ide_drive_t *);
1405int __ide_dma_good_drive(ide_drive_t *);
1406int ide_use_dma(ide_drive_t *);
1407int __ide_dma_off(ide_drive_t *);
1408void ide_dma_verbose(ide_drive_t *);
1409ide_startstop_t ide_dma_intr(ide_drive_t *);
1410
1411#ifdef CONFIG_BLK_DEV_IDEDMA_PCI
1412extern int ide_build_sglist(ide_drive_t *, struct request *);
1413extern int ide_build_dmatable(ide_drive_t *, struct request *);
1414extern void ide_destroy_dmatable(ide_drive_t *);
1415extern int ide_release_dma(ide_hwif_t *);
1416extern void ide_setup_dma(ide_hwif_t *, unsigned long, unsigned int);
1417
1418extern int __ide_dma_host_off(ide_drive_t *);
1419extern int __ide_dma_off_quietly(ide_drive_t *);
1420extern int __ide_dma_host_on(ide_drive_t *);
1421extern int __ide_dma_on(ide_drive_t *);
1422extern int __ide_dma_check(ide_drive_t *);
1423extern int ide_dma_setup(ide_drive_t *);
1424extern void ide_dma_start(ide_drive_t *);
1425extern int __ide_dma_end(ide_drive_t *);
1426extern int __ide_dma_lostirq(ide_drive_t *);
1427extern int __ide_dma_timeout(ide_drive_t *);
1428#endif /* CONFIG_BLK_DEV_IDEDMA_PCI */
1429
1430#else
1431static inline int ide_use_dma(ide_drive_t *drive) { return 0; }
1432static inline int __ide_dma_off(ide_drive_t *drive) { return 0; }
1433static inline void ide_dma_verbose(ide_drive_t *drive) { ; }
1434#endif /* CONFIG_BLK_DEV_IDEDMA */
1435
1436#ifndef CONFIG_BLK_DEV_IDEDMA_PCI
1437static inline void ide_release_dma(ide_hwif_t *drive) {;}
1438#endif
1439
1440extern int ide_hwif_request_regions(ide_hwif_t *hwif);
1441extern void ide_hwif_release_regions(ide_hwif_t* hwif);
1442extern void ide_unregister (unsigned int index);
1443
1444void ide_register_region(struct gendisk *);
1445void ide_unregister_region(struct gendisk *);
1446
1447void ide_undecoded_slave(ide_hwif_t *);
1448
1449int probe_hwif_init_with_fixup(ide_hwif_t *, void (*)(ide_hwif_t *));
1450extern int probe_hwif_init(ide_hwif_t *);
1451
1452static inline void *ide_get_hwifdata (ide_hwif_t * hwif)
1453{
1454 return hwif->hwif_data;
1455}
1456
1457static inline void ide_set_hwifdata (ide_hwif_t * hwif, void *data)
1458{
1459 hwif->hwif_data = data;
1460}
1461
1462/* ide-lib.c */
1463extern u8 ide_dma_speed(ide_drive_t *drive, u8 mode);
1464extern u8 ide_rate_filter(u8 mode, u8 speed);
1465extern int ide_dma_enable(ide_drive_t *drive);
1466extern char *ide_xfer_verbose(u8 xfer_rate);
1467extern void ide_toggle_bounce(ide_drive_t *drive, int on);
1468extern int ide_set_xfer_rate(ide_drive_t *drive, u8 rate);
1469
1470u8 ide_dump_status(ide_drive_t *, const char *, u8);
1471
1472typedef struct ide_pio_timings_s {
1473 int setup_time; /* Address setup (ns) minimum */
1474 int active_time; /* Active pulse (ns) minimum */
1475 int cycle_time; /* Cycle time (ns) minimum = (setup + active + recovery) */
1476} ide_pio_timings_t;
1477
1478typedef struct ide_pio_data_s {
1479 u8 pio_mode;
1480 u8 use_iordy;
1481 u8 overridden;
1482 u8 blacklisted;
1483 unsigned int cycle_time;
1484} ide_pio_data_t;
1485
1486extern u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode, ide_pio_data_t *d);
1487extern const ide_pio_timings_t ide_pio_timings[6];
1488
1489
1490extern spinlock_t ide_lock;
1491extern struct semaphore ide_cfg_sem;
1492/*
1493 * Structure locking:
1494 *
1495 * ide_cfg_sem and ide_lock together protect changes to
1496 * ide_hwif_t->{next,hwgroup}
1497 * ide_drive_t->next
1498 *
1499 * ide_hwgroup_t->busy: ide_lock
1500 * ide_hwgroup_t->hwif: ide_lock
1501 * ide_hwif_t->mate: constant, no locking
1502 * ide_drive_t->hwif: constant, no locking
1503 */
1504
1505#define local_irq_set(flags) do { local_save_flags((flags)); local_irq_enable(); } while (0)
1506
1507extern struct bus_type ide_bus_type;
1508
1509/* check if CACHE FLUSH (EXT) command is supported (bits defined in ATA-6) */
1510#define ide_id_has_flush_cache(id) ((id)->cfs_enable_2 & 0x3000)
1511
1512/* some Maxtor disks have bit 13 defined incorrectly so check bit 10 too */
1513#define ide_id_has_flush_cache_ext(id) \
1514 (((id)->cfs_enable_2 & 0x2400) == 0x2400)
1515
1516#endif /* _IDE_H */
diff --git a/include/linux/idr.h b/include/linux/idr.h
new file mode 100644
index 000000000000..ca3b7e462576
--- /dev/null
+++ b/include/linux/idr.h
@@ -0,0 +1,78 @@
1/*
2 * include/linux/idr.h
3 *
4 * 2002-10-18 written by Jim Houston jim.houston@ccur.com
5 * Copyright (C) 2002 by Concurrent Computer Corporation
6 * Distributed under the GNU GPL license version 2.
7 *
8 * Small id to pointer translation service avoiding fixed sized
9 * tables.
10 */
11#include <linux/types.h>
12#include <linux/bitops.h>
13
14#if BITS_PER_LONG == 32
15# define IDR_BITS 5
16# define IDR_FULL 0xfffffffful
17/* We can only use two of the bits in the top level because there is
18 only one possible bit in the top level (5 bits * 7 levels = 35
19 bits, but you only use 31 bits in the id). */
20# define TOP_LEVEL_FULL (IDR_FULL >> 30)
21#elif BITS_PER_LONG == 64
22# define IDR_BITS 6
23# define IDR_FULL 0xfffffffffffffffful
24/* We can only use two of the bits in the top level because there is
25 only one possible bit in the top level (6 bits * 6 levels = 36
26 bits, but you only use 31 bits in the id). */
27# define TOP_LEVEL_FULL (IDR_FULL >> 62)
28#else
29# error "BITS_PER_LONG is not 32 or 64"
30#endif
31
32#define IDR_SIZE (1 << IDR_BITS)
33#define IDR_MASK ((1 << IDR_BITS)-1)
34
35#define MAX_ID_SHIFT (sizeof(int)*8 - 1)
36#define MAX_ID_BIT (1U << MAX_ID_SHIFT)
37#define MAX_ID_MASK (MAX_ID_BIT - 1)
38
39/* Leave the possibility of an incomplete final layer */
40#define MAX_LEVEL (MAX_ID_SHIFT + IDR_BITS - 1) / IDR_BITS
41
42/* Number of id_layer structs to leave in free list */
43#define IDR_FREE_MAX MAX_LEVEL + MAX_LEVEL
44
45struct idr_layer {
46 unsigned long bitmap; /* A zero bit means "space here" */
47 struct idr_layer *ary[1<<IDR_BITS];
48 int count; /* When zero, we can release it */
49};
50
51struct idr {
52 struct idr_layer *top;
53 struct idr_layer *id_free;
54 int layers;
55 int id_free_cnt;
56 spinlock_t lock;
57};
58
59#define IDR_INIT(name) \
60{ \
61 .top = NULL, \
62 .id_free = NULL, \
63 .layers = 0, \
64 .id_free_cnt = 0, \
65 .lock = SPIN_LOCK_UNLOCKED, \
66}
67#define DEFINE_IDR(name) struct idr name = IDR_INIT(name)
68
69/*
70 * This is what we export.
71 */
72
73void *idr_find(struct idr *idp, int id);
74int idr_pre_get(struct idr *idp, unsigned gfp_mask);
75int idr_get_new(struct idr *idp, void *ptr, int *id);
76int idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id);
77void idr_remove(struct idr *idp, int id);
78void idr_init(struct idr *idp);
diff --git a/include/linux/if.h b/include/linux/if.h
new file mode 100644
index 000000000000..110282dbd3e0
--- /dev/null
+++ b/include/linux/if.h
@@ -0,0 +1,193 @@
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Global definitions for the INET interface module.
7 *
8 * Version: @(#)if.h 1.0.2 04/18/93
9 *
10 * Authors: Original taken from Berkeley UNIX 4.3, (c) UCB 1982-1988
11 * Ross Biro, <bir7@leland.Stanford.Edu>
12 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version
17 * 2 of the License, or (at your option) any later version.
18 */
19#ifndef _LINUX_IF_H
20#define _LINUX_IF_H
21
22#include <linux/types.h> /* for "__kernel_caddr_t" et al */
23#include <linux/socket.h> /* for "struct sockaddr" et al */
24#include <linux/compiler.h> /* for "__user" et al */
25
26#define IFNAMSIZ 16
27#include <linux/hdlc/ioctl.h>
28
29/* Standard interface flags (netdevice->flags). */
30#define IFF_UP 0x1 /* interface is up */
31#define IFF_BROADCAST 0x2 /* broadcast address valid */
32#define IFF_DEBUG 0x4 /* turn on debugging */
33#define IFF_LOOPBACK 0x8 /* is a loopback net */
34#define IFF_POINTOPOINT 0x10 /* interface is has p-p link */
35#define IFF_NOTRAILERS 0x20 /* avoid use of trailers */
36#define IFF_RUNNING 0x40 /* resources allocated */
37#define IFF_NOARP 0x80 /* no ARP protocol */
38#define IFF_PROMISC 0x100 /* receive all packets */
39#define IFF_ALLMULTI 0x200 /* receive all multicast packets*/
40
41#define IFF_MASTER 0x400 /* master of a load balancer */
42#define IFF_SLAVE 0x800 /* slave of a load balancer */
43
44#define IFF_MULTICAST 0x1000 /* Supports multicast */
45
46#define IFF_VOLATILE (IFF_LOOPBACK|IFF_POINTOPOINT|IFF_BROADCAST|IFF_MASTER|IFF_SLAVE|IFF_RUNNING)
47
48#define IFF_PORTSEL 0x2000 /* can set media type */
49#define IFF_AUTOMEDIA 0x4000 /* auto media select active */
50#define IFF_DYNAMIC 0x8000 /* dialup device with changing addresses*/
51
52/* Private (from user) interface flags (netdevice->priv_flags). */
53#define IFF_802_1Q_VLAN 0x1 /* 802.1Q VLAN device. */
54#define IFF_EBRIDGE 0x2 /* Ethernet bridging device. */
55
56#define IF_GET_IFACE 0x0001 /* for querying only */
57#define IF_GET_PROTO 0x0002
58
59/* For definitions see hdlc.h */
60#define IF_IFACE_V35 0x1000 /* V.35 serial interface */
61#define IF_IFACE_V24 0x1001 /* V.24 serial interface */
62#define IF_IFACE_X21 0x1002 /* X.21 serial interface */
63#define IF_IFACE_T1 0x1003 /* T1 telco serial interface */
64#define IF_IFACE_E1 0x1004 /* E1 telco serial interface */
65#define IF_IFACE_SYNC_SERIAL 0x1005 /* can't be set by software */
66#define IF_IFACE_X21D 0x1006 /* X.21 Dual Clocking (FarSite) */
67
68/* For definitions see hdlc.h */
69#define IF_PROTO_HDLC 0x2000 /* raw HDLC protocol */
70#define IF_PROTO_PPP 0x2001 /* PPP protocol */
71#define IF_PROTO_CISCO 0x2002 /* Cisco HDLC protocol */
72#define IF_PROTO_FR 0x2003 /* Frame Relay protocol */
73#define IF_PROTO_FR_ADD_PVC 0x2004 /* Create FR PVC */
74#define IF_PROTO_FR_DEL_PVC 0x2005 /* Delete FR PVC */
75#define IF_PROTO_X25 0x2006 /* X.25 */
76#define IF_PROTO_HDLC_ETH 0x2007 /* raw HDLC, Ethernet emulation */
77#define IF_PROTO_FR_ADD_ETH_PVC 0x2008 /* Create FR Ethernet-bridged PVC */
78#define IF_PROTO_FR_DEL_ETH_PVC 0x2009 /* Delete FR Ethernet-bridged PVC */
79#define IF_PROTO_FR_PVC 0x200A /* for reading PVC status */
80#define IF_PROTO_FR_ETH_PVC 0x200B
81#define IF_PROTO_RAW 0x200C /* RAW Socket */
82
83
84/*
85 * Device mapping structure. I'd just gone off and designed a
86 * beautiful scheme using only loadable modules with arguments
87 * for driver options and along come the PCMCIA people 8)
88 *
89 * Ah well. The get() side of this is good for WDSETUP, and it'll
90 * be handy for debugging things. The set side is fine for now and
91 * being very small might be worth keeping for clean configuration.
92 */
93
94struct ifmap
95{
96 unsigned long mem_start;
97 unsigned long mem_end;
98 unsigned short base_addr;
99 unsigned char irq;
100 unsigned char dma;
101 unsigned char port;
102 /* 3 bytes spare */
103};
104
105struct if_settings
106{
107 unsigned int type; /* Type of physical device or protocol */
108 unsigned int size; /* Size of the data allocated by the caller */
109 union {
110 /* {atm/eth/dsl}_settings anyone ? */
111 raw_hdlc_proto __user *raw_hdlc;
112 cisco_proto __user *cisco;
113 fr_proto __user *fr;
114 fr_proto_pvc __user *fr_pvc;
115 fr_proto_pvc_info __user *fr_pvc_info;
116
117 /* interface settings */
118 sync_serial_settings __user *sync;
119 te1_settings __user *te1;
120 } ifs_ifsu;
121};
122
123/*
124 * Interface request structure used for socket
125 * ioctl's. All interface ioctl's must have parameter
126 * definitions which begin with ifr_name. The
127 * remainder may be interface specific.
128 */
129
130struct ifreq
131{
132#define IFHWADDRLEN 6
133 union
134 {
135 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */
136 } ifr_ifrn;
137
138 union {
139 struct sockaddr ifru_addr;
140 struct sockaddr ifru_dstaddr;
141 struct sockaddr ifru_broadaddr;
142 struct sockaddr ifru_netmask;
143 struct sockaddr ifru_hwaddr;
144 short ifru_flags;
145 int ifru_ivalue;
146 int ifru_mtu;
147 struct ifmap ifru_map;
148 char ifru_slave[IFNAMSIZ]; /* Just fits the size */
149 char ifru_newname[IFNAMSIZ];
150 void __user * ifru_data;
151 struct if_settings ifru_settings;
152 } ifr_ifru;
153};
154
155#define ifr_name ifr_ifrn.ifrn_name /* interface name */
156#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */
157#define ifr_addr ifr_ifru.ifru_addr /* address */
158#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-p lnk */
159#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
160#define ifr_netmask ifr_ifru.ifru_netmask /* interface net mask */
161#define ifr_flags ifr_ifru.ifru_flags /* flags */
162#define ifr_metric ifr_ifru.ifru_ivalue /* metric */
163#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
164#define ifr_map ifr_ifru.ifru_map /* device map */
165#define ifr_slave ifr_ifru.ifru_slave /* slave device */
166#define ifr_data ifr_ifru.ifru_data /* for use by interface */
167#define ifr_ifindex ifr_ifru.ifru_ivalue /* interface index */
168#define ifr_bandwidth ifr_ifru.ifru_ivalue /* link bandwidth */
169#define ifr_qlen ifr_ifru.ifru_ivalue /* Queue length */
170#define ifr_newname ifr_ifru.ifru_newname /* New name */
171#define ifr_settings ifr_ifru.ifru_settings /* Device/proto settings*/
172
173/*
174 * Structure used in SIOCGIFCONF request.
175 * Used to retrieve interface configuration
176 * for machine (useful for programs which
177 * must know all networks accessible).
178 */
179
180struct ifconf
181{
182 int ifc_len; /* size of buffer */
183 union
184 {
185 char __user *ifcu_buf;
186 struct ifreq __user *ifcu_req;
187 } ifc_ifcu;
188};
189#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
190#define ifc_req ifc_ifcu.ifcu_req /* array of structures */
191
192
193#endif /* _LINUX_IF_H */
diff --git a/include/linux/if_arcnet.h b/include/linux/if_arcnet.h
new file mode 100644
index 000000000000..af380cb876a0
--- /dev/null
+++ b/include/linux/if_arcnet.h
@@ -0,0 +1,137 @@
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Global definitions for the ARCnet interface.
7 *
8 * Authors: David Woodhouse and Avery Pennarun
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#ifndef _LINUX_IF_ARCNET_H
17#define _LINUX_IF_ARCNET_H
18
19#include <linux/if_ether.h>
20
21
22/*
23 * These are the defined ARCnet Protocol ID's.
24 */
25
26/* CAP mode */
27/* No macro but uses 1-8 */
28
29/* RFC1201 Protocol ID's */
30#define ARC_P_IP 212 /* 0xD4 */
31#define ARC_P_IPV6 196 /* 0xC4: RFC2497 */
32#define ARC_P_ARP 213 /* 0xD5 */
33#define ARC_P_RARP 214 /* 0xD6 */
34#define ARC_P_IPX 250 /* 0xFA */
35#define ARC_P_NOVELL_EC 236 /* 0xEC */
36
37/* Old RFC1051 Protocol ID's */
38#define ARC_P_IP_RFC1051 240 /* 0xF0 */
39#define ARC_P_ARP_RFC1051 241 /* 0xF1 */
40
41/* MS LanMan/WfWg "NDIS" encapsulation */
42#define ARC_P_ETHER 232 /* 0xE8 */
43
44/* Unsupported/indirectly supported protocols */
45#define ARC_P_DATAPOINT_BOOT 0 /* very old Datapoint equipment */
46#define ARC_P_DATAPOINT_MOUNT 1
47#define ARC_P_POWERLAN_BEACON 8 /* Probably ATA-Netbios related */
48#define ARC_P_POWERLAN_BEACON2 243 /* 0xF3 */
49#define ARC_P_LANSOFT 251 /* 0xFB - what is this? */
50#define ARC_P_ATALK 0xDD
51
52/* Hardware address length */
53#define ARCNET_ALEN 1
54
55/*
56 * The RFC1201-specific components of an arcnet packet header.
57 */
58struct arc_rfc1201
59{
60 uint8_t proto; /* protocol ID field - varies */
61 uint8_t split_flag; /* for use with split packets */
62 uint16_t sequence; /* sequence number */
63 uint8_t payload[0]; /* space remaining in packet (504 bytes)*/
64};
65#define RFC1201_HDR_SIZE 4
66
67
68/*
69 * The RFC1051-specific components.
70 */
71struct arc_rfc1051
72{
73 uint8_t proto; /* ARC_P_RFC1051_ARP/RFC1051_IP */
74 uint8_t payload[0]; /* 507 bytes */
75};
76#define RFC1051_HDR_SIZE 1
77
78
79/*
80 * The ethernet-encap-specific components. We have a real ethernet header
81 * and some data.
82 */
83struct arc_eth_encap
84{
85 uint8_t proto; /* Always ARC_P_ETHER */
86 struct ethhdr eth; /* standard ethernet header (yuck!) */
87 uint8_t payload[0]; /* 493 bytes */
88};
89#define ETH_ENCAP_HDR_SIZE 14
90
91
92struct arc_cap
93{
94 uint8_t proto;
95 uint8_t cookie[sizeof(int)]; /* Actually NOT sent over the network */
96 union {
97 uint8_t ack;
98 uint8_t raw[0]; /* 507 bytes */
99 } mes;
100};
101
102/*
103 * The data needed by the actual arcnet hardware.
104 *
105 * Now, in the real arcnet hardware, the third and fourth bytes are the
106 * 'offset' specification instead of the length, and the soft data is at
107 * the _end_ of the 512-byte buffer. We hide this complexity inside the
108 * driver.
109 */
110struct arc_hardware
111{
112 uint8_t source, /* source ARCnet - filled in automagically */
113 dest, /* destination ARCnet - 0 for broadcast */
114 offset[2]; /* offset bytes (some weird semantics) */
115};
116#define ARC_HDR_SIZE 4
117
118/*
119 * This is an ARCnet frame header, as seen by the kernel (and userspace,
120 * when you do a raw packet capture).
121 */
122struct archdr
123{
124 /* hardware requirements */
125 struct arc_hardware hard;
126
127 /* arcnet encapsulation-specific bits */
128 union {
129 struct arc_rfc1201 rfc1201;
130 struct arc_rfc1051 rfc1051;
131 struct arc_eth_encap eth_encap;
132 struct arc_cap cap;
133 uint8_t raw[0]; /* 508 bytes */
134 } soft;
135};
136
137#endif /* _LINUX_IF_ARCNET_H */
diff --git a/include/linux/if_arp.h b/include/linux/if_arp.h
new file mode 100644
index 000000000000..bbf49bcd7705
--- /dev/null
+++ b/include/linux/if_arp.h
@@ -0,0 +1,150 @@
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Global definitions for the ARP (RFC 826) protocol.
7 *
8 * Version: @(#)if_arp.h 1.0.1 04/16/93
9 *
10 * Authors: Original taken from Berkeley UNIX 4.3, (c) UCB 1986-1988
11 * Portions taken from the KA9Q/NOS (v2.00m PA0GRI) source.
12 * Ross Biro, <bir7@leland.Stanford.Edu>
13 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
14 * Florian La Roche,
15 * Jonathan Layes <layes@loran.com>
16 * Arnaldo Carvalho de Melo <acme@conectiva.com.br> ARPHRD_HWX25
17 *
18 * This program is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU General Public License
20 * as published by the Free Software Foundation; either version
21 * 2 of the License, or (at your option) any later version.
22 */
23#ifndef _LINUX_IF_ARP_H
24#define _LINUX_IF_ARP_H
25
26#include <linux/netdevice.h>
27
28/* ARP protocol HARDWARE identifiers. */
29#define ARPHRD_NETROM 0 /* from KA9Q: NET/ROM pseudo */
30#define ARPHRD_ETHER 1 /* Ethernet 10Mbps */
31#define ARPHRD_EETHER 2 /* Experimental Ethernet */
32#define ARPHRD_AX25 3 /* AX.25 Level 2 */
33#define ARPHRD_PRONET 4 /* PROnet token ring */
34#define ARPHRD_CHAOS 5 /* Chaosnet */
35#define ARPHRD_IEEE802 6 /* IEEE 802.2 Ethernet/TR/TB */
36#define ARPHRD_ARCNET 7 /* ARCnet */
37#define ARPHRD_APPLETLK 8 /* APPLEtalk */
38#define ARPHRD_DLCI 15 /* Frame Relay DLCI */
39#define ARPHRD_ATM 19 /* ATM */
40#define ARPHRD_METRICOM 23 /* Metricom STRIP (new IANA id) */
41#define ARPHRD_IEEE1394 24 /* IEEE 1394 IPv4 - RFC 2734 */
42#define ARPHRD_EUI64 27 /* EUI-64 */
43#define ARPHRD_INFINIBAND 32 /* InfiniBand */
44
45/* Dummy types for non ARP hardware */
46#define ARPHRD_SLIP 256
47#define ARPHRD_CSLIP 257
48#define ARPHRD_SLIP6 258
49#define ARPHRD_CSLIP6 259
50#define ARPHRD_RSRVD 260 /* Notional KISS type */
51#define ARPHRD_ADAPT 264
52#define ARPHRD_ROSE 270
53#define ARPHRD_X25 271 /* CCITT X.25 */
54#define ARPHRD_HWX25 272 /* Boards with X.25 in firmware */
55#define ARPHRD_PPP 512
56#define ARPHRD_CISCO 513 /* Cisco HDLC */
57#define ARPHRD_HDLC ARPHRD_CISCO
58#define ARPHRD_LAPB 516 /* LAPB */
59#define ARPHRD_DDCMP 517 /* Digital's DDCMP protocol */
60#define ARPHRD_RAWHDLC 518 /* Raw HDLC */
61
62#define ARPHRD_TUNNEL 768 /* IPIP tunnel */
63#define ARPHRD_TUNNEL6 769 /* IP6IP6 tunnel */
64#define ARPHRD_FRAD 770 /* Frame Relay Access Device */
65#define ARPHRD_SKIP 771 /* SKIP vif */
66#define ARPHRD_LOOPBACK 772 /* Loopback device */
67#define ARPHRD_LOCALTLK 773 /* Localtalk device */
68#define ARPHRD_FDDI 774 /* Fiber Distributed Data Interface */
69#define ARPHRD_BIF 775 /* AP1000 BIF */
70#define ARPHRD_SIT 776 /* sit0 device - IPv6-in-IPv4 */
71#define ARPHRD_IPDDP 777 /* IP over DDP tunneller */
72#define ARPHRD_IPGRE 778 /* GRE over IP */
73#define ARPHRD_PIMREG 779 /* PIMSM register interface */
74#define ARPHRD_HIPPI 780 /* High Performance Parallel Interface */
75#define ARPHRD_ASH 781 /* Nexus 64Mbps Ash */
76#define ARPHRD_ECONET 782 /* Acorn Econet */
77#define ARPHRD_IRDA 783 /* Linux-IrDA */
78/* ARP works differently on different FC media .. so */
79#define ARPHRD_FCPP 784 /* Point to point fibrechannel */
80#define ARPHRD_FCAL 785 /* Fibrechannel arbitrated loop */
81#define ARPHRD_FCPL 786 /* Fibrechannel public loop */
82#define ARPHRD_FCFABRIC 787 /* Fibrechannel fabric */
83 /* 787->799 reserved for fibrechannel media types */
84#define ARPHRD_IEEE802_TR 800 /* Magic type ident for TR */
85#define ARPHRD_IEEE80211 801 /* IEEE 802.11 */
86#define ARPHRD_IEEE80211_PRISM 802 /* IEEE 802.11 + Prism2 header */
87
88#define ARPHRD_VOID 0xFFFF /* Void type, nothing is known */
89#define ARPHRD_NONE 0xFFFE /* zero header length */
90
91/* ARP protocol opcodes. */
92#define ARPOP_REQUEST 1 /* ARP request */
93#define ARPOP_REPLY 2 /* ARP reply */
94#define ARPOP_RREQUEST 3 /* RARP request */
95#define ARPOP_RREPLY 4 /* RARP reply */
96#define ARPOP_InREQUEST 8 /* InARP request */
97#define ARPOP_InREPLY 9 /* InARP reply */
98#define ARPOP_NAK 10 /* (ATM)ARP NAK */
99
100
101/* ARP ioctl request. */
102struct arpreq {
103 struct sockaddr arp_pa; /* protocol address */
104 struct sockaddr arp_ha; /* hardware address */
105 int arp_flags; /* flags */
106 struct sockaddr arp_netmask; /* netmask (only for proxy arps) */
107 char arp_dev[16];
108};
109
110struct arpreq_old {
111 struct sockaddr arp_pa; /* protocol address */
112 struct sockaddr arp_ha; /* hardware address */
113 int arp_flags; /* flags */
114 struct sockaddr arp_netmask; /* netmask (only for proxy arps) */
115};
116
117/* ARP Flag values. */
118#define ATF_COM 0x02 /* completed entry (ha valid) */
119#define ATF_PERM 0x04 /* permanent entry */
120#define ATF_PUBL 0x08 /* publish entry */
121#define ATF_USETRAILERS 0x10 /* has requested trailers */
122#define ATF_NETMASK 0x20 /* want to use a netmask (only
123 for proxy entries) */
124#define ATF_DONTPUB 0x40 /* don't answer this addresses */
125
126/*
127 * This structure defines an ethernet arp header.
128 */
129
130struct arphdr
131{
132 unsigned short ar_hrd; /* format of hardware address */
133 unsigned short ar_pro; /* format of protocol address */
134 unsigned char ar_hln; /* length of hardware address */
135 unsigned char ar_pln; /* length of protocol address */
136 unsigned short ar_op; /* ARP opcode (command) */
137
138#if 0
139 /*
140 * Ethernet looks like this : This bit is variable sized however...
141 */
142 unsigned char ar_sha[ETH_ALEN]; /* sender hardware address */
143 unsigned char ar_sip[4]; /* sender IP address */
144 unsigned char ar_tha[ETH_ALEN]; /* target hardware address */
145 unsigned char ar_tip[4]; /* target IP address */
146#endif
147
148};
149
150#endif /* _LINUX_IF_ARP_H */
diff --git a/include/linux/if_bonding.h b/include/linux/if_bonding.h
new file mode 100644
index 000000000000..57024ce2c74f
--- /dev/null
+++ b/include/linux/if_bonding.h
@@ -0,0 +1,117 @@
1/*
2 * Bond several ethernet interfaces into a Cisco, running 'Etherchannel'.
3 *
4 *
5 * Portions are (c) Copyright 1995 Simon "Guru Aleph-Null" Janes
6 * NCM: Network and Communications Management, Inc.
7 *
8 * BUT, I'm the one who modified it for ethernet, so:
9 * (c) Copyright 1999, Thomas Davis, tadavis@lbl.gov
10 *
11 * This software may be used and distributed according to the terms
12 * of the GNU Public License, incorporated herein by reference.
13 *
14 * 2003/03/18 - Amir Noam <amir.noam at intel dot com>
15 * - Added support for getting slave's speed and duplex via ethtool.
16 * Needed for 802.3ad and other future modes.
17 *
18 * 2003/03/18 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
19 * Shmulik Hen <shmulik.hen at intel dot com>
20 * - Enable support of modes that need to use the unique mac address of
21 * each slave.
22 *
23 * 2003/03/18 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
24 * Amir Noam <amir.noam at intel dot com>
25 * - Moved driver's private data types to bonding.h
26 *
27 * 2003/03/18 - Amir Noam <amir.noam at intel dot com>,
28 * Tsippy Mendelson <tsippy.mendelson at intel dot com> and
29 * Shmulik Hen <shmulik.hen at intel dot com>
30 * - Added support for IEEE 802.3ad Dynamic link aggregation mode.
31 *
32 * 2003/05/01 - Amir Noam <amir.noam at intel dot com>
33 * - Added ABI version control to restore compatibility between
34 * new/old ifenslave and new/old bonding.
35 *
36 * 2003/12/01 - Shmulik Hen <shmulik.hen at intel dot com>
37 * - Code cleanup and style changes
38 */
39
40#ifndef _LINUX_IF_BONDING_H
41#define _LINUX_IF_BONDING_H
42
43#include <linux/if.h>
44#include <linux/types.h>
45#include <linux/if_ether.h>
46
47/* userland - kernel ABI version (2003/05/08) */
48#define BOND_ABI_VERSION 2
49
50/*
51 * We can remove these ioctl definitions in 2.5. People should use the
52 * SIOC*** versions of them instead
53 */
54#define BOND_ENSLAVE_OLD (SIOCDEVPRIVATE)
55#define BOND_RELEASE_OLD (SIOCDEVPRIVATE + 1)
56#define BOND_SETHWADDR_OLD (SIOCDEVPRIVATE + 2)
57#define BOND_SLAVE_INFO_QUERY_OLD (SIOCDEVPRIVATE + 11)
58#define BOND_INFO_QUERY_OLD (SIOCDEVPRIVATE + 12)
59#define BOND_CHANGE_ACTIVE_OLD (SIOCDEVPRIVATE + 13)
60
61#define BOND_CHECK_MII_STATUS (SIOCGMIIPHY)
62
63#define BOND_MODE_ROUNDROBIN 0
64#define BOND_MODE_ACTIVEBACKUP 1
65#define BOND_MODE_XOR 2
66#define BOND_MODE_BROADCAST 3
67#define BOND_MODE_8023AD 4
68#define BOND_MODE_TLB 5
69#define BOND_MODE_ALB 6 /* TLB + RLB (receive load balancing) */
70
71/* each slave's link has 4 states */
72#define BOND_LINK_UP 0 /* link is up and running */
73#define BOND_LINK_FAIL 1 /* link has just gone down */
74#define BOND_LINK_DOWN 2 /* link has been down for too long time */
75#define BOND_LINK_BACK 3 /* link is going back */
76
77/* each slave has several states */
78#define BOND_STATE_ACTIVE 0 /* link is active */
79#define BOND_STATE_BACKUP 1 /* link is backup */
80
81#define BOND_DEFAULT_MAX_BONDS 1 /* Default maximum number of devices to support */
82
83typedef struct ifbond {
84 __s32 bond_mode;
85 __s32 num_slaves;
86 __s32 miimon;
87} ifbond;
88
89typedef struct ifslave
90{
91 __s32 slave_id; /* Used as an IN param to the BOND_SLAVE_INFO_QUERY ioctl */
92 char slave_name[IFNAMSIZ];
93 __s8 link;
94 __s8 state;
95 __u32 link_failure_count;
96} ifslave;
97
98struct ad_info {
99 __u16 aggregator_id;
100 __u16 ports;
101 __u16 actor_key;
102 __u16 partner_key;
103 __u8 partner_system[ETH_ALEN];
104};
105
106#endif /* _LINUX_IF_BONDING_H */
107
108/*
109 * Local variables:
110 * version-control: t
111 * kept-new-versions: 5
112 * c-indent-level: 8
113 * c-basic-offset: 8
114 * tab-width: 8
115 * End:
116 */
117
diff --git a/include/linux/if_bridge.h b/include/linux/if_bridge.h
new file mode 100644
index 000000000000..fd1b6eb94a5f
--- /dev/null
+++ b/include/linux/if_bridge.h
@@ -0,0 +1,113 @@
1/*
2 * Linux ethernet bridge
3 *
4 * Authors:
5 * Lennert Buytenhek <buytenh@gnu.org>
6 *
7 * $Id: if_bridge.h,v 1.1 2000/02/18 16:47:01 davem Exp $
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
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 */
14
15#ifndef _LINUX_IF_BRIDGE_H
16#define _LINUX_IF_BRIDGE_H
17
18#include <linux/types.h>
19
20#define SYSFS_BRIDGE_ATTR "bridge"
21#define SYSFS_BRIDGE_FDB "brforward"
22#define SYSFS_BRIDGE_PORT_SUBDIR "brif"
23#define SYSFS_BRIDGE_PORT_ATTR "brport"
24#define SYSFS_BRIDGE_PORT_LINK "bridge"
25
26#define BRCTL_VERSION 1
27
28#define BRCTL_GET_VERSION 0
29#define BRCTL_GET_BRIDGES 1
30#define BRCTL_ADD_BRIDGE 2
31#define BRCTL_DEL_BRIDGE 3
32#define BRCTL_ADD_IF 4
33#define BRCTL_DEL_IF 5
34#define BRCTL_GET_BRIDGE_INFO 6
35#define BRCTL_GET_PORT_LIST 7
36#define BRCTL_SET_BRIDGE_FORWARD_DELAY 8
37#define BRCTL_SET_BRIDGE_HELLO_TIME 9
38#define BRCTL_SET_BRIDGE_MAX_AGE 10
39#define BRCTL_SET_AGEING_TIME 11
40#define BRCTL_SET_GC_INTERVAL 12
41#define BRCTL_GET_PORT_INFO 13
42#define BRCTL_SET_BRIDGE_STP_STATE 14
43#define BRCTL_SET_BRIDGE_PRIORITY 15
44#define BRCTL_SET_PORT_PRIORITY 16
45#define BRCTL_SET_PATH_COST 17
46#define BRCTL_GET_FDB_ENTRIES 18
47
48#define BR_STATE_DISABLED 0
49#define BR_STATE_LISTENING 1
50#define BR_STATE_LEARNING 2
51#define BR_STATE_FORWARDING 3
52#define BR_STATE_BLOCKING 4
53
54struct __bridge_info
55{
56 __u64 designated_root;
57 __u64 bridge_id;
58 __u32 root_path_cost;
59 __u32 max_age;
60 __u32 hello_time;
61 __u32 forward_delay;
62 __u32 bridge_max_age;
63 __u32 bridge_hello_time;
64 __u32 bridge_forward_delay;
65 __u8 topology_change;
66 __u8 topology_change_detected;
67 __u8 root_port;
68 __u8 stp_enabled;
69 __u32 ageing_time;
70 __u32 gc_interval;
71 __u32 hello_timer_value;
72 __u32 tcn_timer_value;
73 __u32 topology_change_timer_value;
74 __u32 gc_timer_value;
75};
76
77struct __port_info
78{
79 __u64 designated_root;
80 __u64 designated_bridge;
81 __u16 port_id;
82 __u16 designated_port;
83 __u32 path_cost;
84 __u32 designated_cost;
85 __u8 state;
86 __u8 top_change_ack;
87 __u8 config_pending;
88 __u8 unused0;
89 __u32 message_age_timer_value;
90 __u32 forward_delay_timer_value;
91 __u32 hold_timer_value;
92};
93
94struct __fdb_entry
95{
96 __u8 mac_addr[6];
97 __u8 port_no;
98 __u8 is_local;
99 __u32 ageing_timer_value;
100 __u32 unused;
101};
102
103#ifdef __KERNEL__
104
105#include <linux/netdevice.h>
106
107extern void brioctl_set(int (*ioctl_hook)(unsigned int, void __user *));
108extern int (*br_handle_frame_hook)(struct net_bridge_port *p, struct sk_buff **pskb);
109extern int (*br_should_route_hook)(struct sk_buff **pskb);
110
111#endif
112
113#endif
diff --git a/include/linux/if_cablemodem.h b/include/linux/if_cablemodem.h
new file mode 100644
index 000000000000..9ca1007edd93
--- /dev/null
+++ b/include/linux/if_cablemodem.h
@@ -0,0 +1,22 @@
1#ifndef _LINUX_CABLEMODEM_H_
2#define _LINUX_CABLEMODEM_H_
3/*
4 * Author: Franco Venturi <fventuri@mediaone.net>
5 * Copyright 1998 Franco Venturi
6 *
7 * This program is free software; you can redistribute it
8 * and/or modify it under the terms of the GNU General
9 * Public License as published by the Free Software
10 * Foundation; either version 2 of the License, or (at
11 * your option) any later version.
12 */
13
14/* some useful defines for sb1000.c e cmconfig.c - fv */
15#define SIOCGCMSTATS SIOCDEVPRIVATE+0 /* get cable modem stats */
16#define SIOCGCMFIRMWARE SIOCDEVPRIVATE+1 /* get cm firmware version */
17#define SIOCGCMFREQUENCY SIOCDEVPRIVATE+2 /* get cable modem frequency */
18#define SIOCSCMFREQUENCY SIOCDEVPRIVATE+3 /* set cable modem frequency */
19#define SIOCGCMPIDS SIOCDEVPRIVATE+4 /* get cable modem PIDs */
20#define SIOCSCMPIDS SIOCDEVPRIVATE+5 /* set cable modem PIDs */
21
22#endif
diff --git a/include/linux/if_ec.h b/include/linux/if_ec.h
new file mode 100644
index 000000000000..e7499aa79783
--- /dev/null
+++ b/include/linux/if_ec.h
@@ -0,0 +1,72 @@
1/* Definitions for Econet sockets. */
2
3#ifndef __LINUX_IF_EC
4#define __LINUX_IF_EC
5
6/* User visible stuff. Glibc provides its own but libc5 folk will use these */
7
8struct ec_addr
9{
10 unsigned char station; /* Station number. */
11 unsigned char net; /* Network number. */
12};
13
14struct sockaddr_ec
15{
16 unsigned short sec_family;
17 unsigned char port; /* Port number. */
18 unsigned char cb; /* Control/flag byte. */
19 unsigned char type; /* Type of message. */
20 struct ec_addr addr;
21 unsigned long cookie;
22};
23
24#define ECTYPE_PACKET_RECEIVED 0 /* Packet received */
25#define ECTYPE_TRANSMIT_STATUS 0x10 /* Transmit completed,
26 low nibble holds status */
27
28#define ECTYPE_TRANSMIT_OK 1
29#define ECTYPE_TRANSMIT_NOT_LISTENING 2
30#define ECTYPE_TRANSMIT_NET_ERROR 3
31#define ECTYPE_TRANSMIT_NO_CLOCK 4
32#define ECTYPE_TRANSMIT_LINE_JAMMED 5
33#define ECTYPE_TRANSMIT_NOT_PRESENT 6
34
35#ifdef __KERNEL__
36
37#define EC_HLEN 6
38
39/* This is what an Econet frame looks like on the wire. */
40struct ec_framehdr
41{
42 unsigned char dst_stn;
43 unsigned char dst_net;
44 unsigned char src_stn;
45 unsigned char src_net;
46 unsigned char cb;
47 unsigned char port;
48};
49
50struct econet_sock {
51 /* struct sock has to be the first member of econet_sock */
52 struct sock sk;
53 unsigned char cb;
54 unsigned char port;
55 unsigned char station;
56 unsigned char net;
57 unsigned short num;
58};
59
60static inline struct econet_sock *ec_sk(const struct sock *sk)
61{
62 return (struct econet_sock *)sk;
63}
64
65struct ec_device
66{
67 unsigned char station, net; /* Econet protocol address */
68};
69
70#endif
71
72#endif
diff --git a/include/linux/if_eql.h b/include/linux/if_eql.h
new file mode 100644
index 000000000000..b68752fdc5c4
--- /dev/null
+++ b/include/linux/if_eql.h
@@ -0,0 +1,84 @@
1/*
2 * Equalizer Load-balancer for serial network interfaces.
3 *
4 * (c) Copyright 1995 Simon "Guru Aleph-Null" Janes
5 * NCM: Network and Communications Management, Inc.
6 *
7 *
8 * This software may be used and distributed according to the terms
9 * of the GNU General Public License, incorporated herein by reference.
10 *
11 * The author may be reached as simon@ncm.com, or C/O
12 * NCM
13 * Attn: Simon Janes
14 * 6803 Whittier Ave
15 * McLean VA 22101
16 * Phone: 1-703-847-0040 ext 103
17 */
18
19#ifndef _LINUX_IF_EQL_H
20#define _LINUX_IF_EQL_H
21
22#define EQL_DEFAULT_SLAVE_PRIORITY 28800
23#define EQL_DEFAULT_MAX_SLAVES 4
24#define EQL_DEFAULT_MTU 576
25#define EQL_DEFAULT_RESCHED_IVAL 100
26
27#define EQL_ENSLAVE (SIOCDEVPRIVATE)
28#define EQL_EMANCIPATE (SIOCDEVPRIVATE + 1)
29
30#define EQL_GETSLAVECFG (SIOCDEVPRIVATE + 2)
31#define EQL_SETSLAVECFG (SIOCDEVPRIVATE + 3)
32
33#define EQL_GETMASTRCFG (SIOCDEVPRIVATE + 4)
34#define EQL_SETMASTRCFG (SIOCDEVPRIVATE + 5)
35
36#ifdef __KERNEL__
37
38#include <linux/timer.h>
39#include <linux/spinlock.h>
40
41typedef struct slave {
42 struct list_head list;
43 struct net_device *dev;
44 long priority;
45 long priority_bps;
46 long priority_Bps;
47 long bytes_queued;
48} slave_t;
49
50typedef struct slave_queue {
51 spinlock_t lock;
52 struct list_head all_slaves;
53 int num_slaves;
54 struct net_device *master_dev;
55} slave_queue_t;
56
57typedef struct equalizer {
58 slave_queue_t queue;
59 int min_slaves;
60 int max_slaves;
61 struct net_device_stats stats;
62 struct timer_list timer;
63} equalizer_t;
64
65#endif /* __KERNEL__ */
66
67typedef struct master_config {
68 char master_name[16];
69 int max_slaves;
70 int min_slaves;
71} master_config_t;
72
73typedef struct slave_config {
74 char slave_name[16];
75 long priority;
76} slave_config_t;
77
78typedef struct slaving_request {
79 char slave_name[16];
80 long priority;
81} slaving_request_t;
82
83
84#endif /* _LINUX_EQL_H */
diff --git a/include/linux/if_ether.h b/include/linux/if_ether.h
new file mode 100644
index 000000000000..b5b58e9c054c
--- /dev/null
+++ b/include/linux/if_ether.h
@@ -0,0 +1,115 @@
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Global definitions for the Ethernet IEEE 802.3 interface.
7 *
8 * Version: @(#)if_ether.h 1.0.1a 02/08/94
9 *
10 * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
11 * Donald Becker, <becker@super.org>
12 * Alan Cox, <alan@redhat.com>
13 * Steve Whitehouse, <gw7rrm@eeshack3.swan.ac.uk>
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version
18 * 2 of the License, or (at your option) any later version.
19 */
20
21#ifndef _LINUX_IF_ETHER_H
22#define _LINUX_IF_ETHER_H
23
24/*
25 * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble
26 * and FCS/CRC (frame check sequence).
27 */
28
29#define ETH_ALEN 6 /* Octets in one ethernet addr */
30#define ETH_HLEN 14 /* Total octets in header. */
31#define ETH_ZLEN 60 /* Min. octets in frame sans FCS */
32#define ETH_DATA_LEN 1500 /* Max. octets in payload */
33#define ETH_FRAME_LEN 1514 /* Max. octets in frame sans FCS */
34
35/*
36 * These are the defined Ethernet Protocol ID's.
37 */
38
39#define ETH_P_LOOP 0x0060 /* Ethernet Loopback packet */
40#define ETH_P_PUP 0x0200 /* Xerox PUP packet */
41#define ETH_P_PUPAT 0x0201 /* Xerox PUP Addr Trans packet */
42#define ETH_P_IP 0x0800 /* Internet Protocol packet */
43#define ETH_P_X25 0x0805 /* CCITT X.25 */
44#define ETH_P_ARP 0x0806 /* Address Resolution packet */
45#define ETH_P_BPQ 0x08FF /* G8BPQ AX.25 Ethernet Packet [ NOT AN OFFICIALLY REGISTERED ID ] */
46#define ETH_P_IEEEPUP 0x0a00 /* Xerox IEEE802.3 PUP packet */
47#define ETH_P_IEEEPUPAT 0x0a01 /* Xerox IEEE802.3 PUP Addr Trans packet */
48#define ETH_P_DEC 0x6000 /* DEC Assigned proto */
49#define ETH_P_DNA_DL 0x6001 /* DEC DNA Dump/Load */
50#define ETH_P_DNA_RC 0x6002 /* DEC DNA Remote Console */
51#define ETH_P_DNA_RT 0x6003 /* DEC DNA Routing */
52#define ETH_P_LAT 0x6004 /* DEC LAT */
53#define ETH_P_DIAG 0x6005 /* DEC Diagnostics */
54#define ETH_P_CUST 0x6006 /* DEC Customer use */
55#define ETH_P_SCA 0x6007 /* DEC Systems Comms Arch */
56#define ETH_P_RARP 0x8035 /* Reverse Addr Res packet */
57#define ETH_P_ATALK 0x809B /* Appletalk DDP */
58#define ETH_P_AARP 0x80F3 /* Appletalk AARP */
59#define ETH_P_8021Q 0x8100 /* 802.1Q VLAN Extended Header */
60#define ETH_P_IPX 0x8137 /* IPX over DIX */
61#define ETH_P_IPV6 0x86DD /* IPv6 over bluebook */
62#define ETH_P_WCCP 0x883E /* Web-cache coordination protocol
63 * defined in draft-wilson-wrec-wccp-v2-00.txt */
64#define ETH_P_PPP_DISC 0x8863 /* PPPoE discovery messages */
65#define ETH_P_PPP_SES 0x8864 /* PPPoE session messages */
66#define ETH_P_MPLS_UC 0x8847 /* MPLS Unicast traffic */
67#define ETH_P_MPLS_MC 0x8848 /* MPLS Multicast traffic */
68#define ETH_P_ATMMPOA 0x884c /* MultiProtocol Over ATM */
69#define ETH_P_ATMFATE 0x8884 /* Frame-based ATM Transport
70 * over Ethernet
71 */
72#define ETH_P_AOE 0x88A2 /* ATA over Ethernet */
73
74/*
75 * Non DIX types. Won't clash for 1500 types.
76 */
77
78#define ETH_P_802_3 0x0001 /* Dummy type for 802.3 frames */
79#define ETH_P_AX25 0x0002 /* Dummy protocol id for AX.25 */
80#define ETH_P_ALL 0x0003 /* Every packet (be careful!!!) */
81#define ETH_P_802_2 0x0004 /* 802.2 frames */
82#define ETH_P_SNAP 0x0005 /* Internal only */
83#define ETH_P_DDCMP 0x0006 /* DEC DDCMP: Internal only */
84#define ETH_P_WAN_PPP 0x0007 /* Dummy type for WAN PPP frames*/
85#define ETH_P_PPP_MP 0x0008 /* Dummy type for PPP MP frames */
86#define ETH_P_LOCALTALK 0x0009 /* Localtalk pseudo type */
87#define ETH_P_PPPTALK 0x0010 /* Dummy type for Atalk over PPP*/
88#define ETH_P_TR_802_2 0x0011 /* 802.2 frames */
89#define ETH_P_MOBITEX 0x0015 /* Mobitex (kaz@cafe.net) */
90#define ETH_P_CONTROL 0x0016 /* Card specific control frames */
91#define ETH_P_IRDA 0x0017 /* Linux-IrDA */
92#define ETH_P_ECONET 0x0018 /* Acorn Econet */
93#define ETH_P_HDLC 0x0019 /* HDLC frames */
94#define ETH_P_ARCNET 0x001A /* 1A for ArcNet :-) */
95
96/*
97 * This is an Ethernet frame header.
98 */
99
100struct ethhdr {
101 unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
102 unsigned char h_source[ETH_ALEN]; /* source ether addr */
103 unsigned short h_proto; /* packet type ID field */
104} __attribute__((packed));
105
106#ifdef __KERNEL__
107#include <linux/skbuff.h>
108
109static inline struct ethhdr *eth_hdr(const struct sk_buff *skb)
110{
111 return (struct ethhdr *)skb->mac.raw;
112}
113#endif
114
115#endif /* _LINUX_IF_ETHER_H */
diff --git a/include/linux/if_fc.h b/include/linux/if_fc.h
new file mode 100644
index 000000000000..33330b458b95
--- /dev/null
+++ b/include/linux/if_fc.h
@@ -0,0 +1,50 @@
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Global definitions for Fibre Channel.
7 *
8 * Version: @(#)if_fc.h 0.0 11/20/98
9 *
10 * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
11 * Donald Becker, <becker@super.org>
12 * Peter De Schrijver, <stud11@cc4.kuleuven.ac.be>
13 * Vineet Abraham, <vma@iol.unh.edu>
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version
18 * 2 of the License, or (at your option) any later version.
19 */
20#ifndef _LINUX_IF_FC_H
21#define _LINUX_IF_FC_H
22
23
24#define FC_ALEN 6 /* Octets in one ethernet addr */
25#define FC_HLEN (sizeof(struct fch_hdr)+sizeof(struct fcllc))
26#define FC_ID_LEN 3 /* Octets in a Fibre Channel Address */
27
28/* LLC and SNAP constants */
29#define EXTENDED_SAP 0xAA
30#define UI_CMD 0x03
31
32/* This is NOT the Fibre Channel frame header. The FC frame header is
33 * constructed in the driver as the Tachyon needs certain fields in
34 * certains positions. So, it can't be generalized here.*/
35
36struct fch_hdr {
37 __u8 daddr[FC_ALEN]; /* destination address */
38 __u8 saddr[FC_ALEN]; /* source address */
39};
40
41/* This is a Fibre Channel LLC structure */
42struct fcllc {
43 __u8 dsap; /* destination SAP */
44 __u8 ssap; /* source SAP */
45 __u8 llc; /* LLC control field */
46 __u8 protid[3]; /* protocol id */
47 __u16 ethertype; /* ether type field */
48};
49
50#endif /* _LINUX_IF_FC_H */
diff --git a/include/linux/if_fddi.h b/include/linux/if_fddi.h
new file mode 100644
index 000000000000..a912818e6361
--- /dev/null
+++ b/include/linux/if_fddi.h
@@ -0,0 +1,197 @@
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Global definitions for the ANSI FDDI interface.
7 *
8 * Version: @(#)if_fddi.h 1.0.2 Sep 29 2004
9 *
10 * Author: Lawrence V. Stefani, <stefani@lkg.dec.com>
11 *
12 * if_fddi.h is based on previous if_ether.h and if_tr.h work by
13 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
14 * Donald Becker, <becker@super.org>
15 * Alan Cox, <alan@redhat.com>
16 * Steve Whitehouse, <gw7rrm@eeshack3.swan.ac.uk>
17 * Peter De Schrijver, <stud11@cc4.kuleuven.ac.be>
18 *
19 * This program is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU General Public License
21 * as published by the Free Software Foundation; either version
22 * 2 of the License, or (at your option) any later version.
23 */
24#ifndef _LINUX_IF_FDDI_H
25#define _LINUX_IF_FDDI_H
26
27/*
28 * Define max and min legal sizes. The frame sizes do not include
29 * 4 byte FCS/CRC (frame check sequence).
30 */
31#define FDDI_K_ALEN 6 /* Octets in one FDDI address */
32#define FDDI_K_8022_HLEN 16 /* Total octets in 802.2 header */
33#define FDDI_K_SNAP_HLEN 21 /* Total octets in 802.2 SNAP header */
34#define FDDI_K_8022_ZLEN 16 /* Min octets in 802.2 frame sans FCS */
35#define FDDI_K_SNAP_ZLEN 21 /* Min octets in 802.2 SNAP frame sans FCS */
36#define FDDI_K_8022_DLEN 4475 /* Max octets in 802.2 payload */
37#define FDDI_K_SNAP_DLEN 4470 /* Max octets in 802.2 SNAP payload */
38#define FDDI_K_LLC_ZLEN 13 /* Min octets in LLC frame sans FCS */
39#define FDDI_K_LLC_LEN 4491 /* Max octets in LLC frame sans FCS */
40
41/* Define FDDI Frame Control (FC) Byte values */
42#define FDDI_FC_K_VOID 0x00
43#define FDDI_FC_K_NON_RESTRICTED_TOKEN 0x80
44#define FDDI_FC_K_RESTRICTED_TOKEN 0xC0
45#define FDDI_FC_K_SMT_MIN 0x41
46#define FDDI_FC_K_SMT_MAX 0x4F
47#define FDDI_FC_K_MAC_MIN 0xC1
48#define FDDI_FC_K_MAC_MAX 0xCF
49#define FDDI_FC_K_ASYNC_LLC_MIN 0x50
50#define FDDI_FC_K_ASYNC_LLC_DEF 0x54
51#define FDDI_FC_K_ASYNC_LLC_MAX 0x5F
52#define FDDI_FC_K_SYNC_LLC_MIN 0xD0
53#define FDDI_FC_K_SYNC_LLC_MAX 0xD7
54#define FDDI_FC_K_IMPLEMENTOR_MIN 0x60
55#define FDDI_FC_K_IMPLEMENTOR_MAX 0x6F
56#define FDDI_FC_K_RESERVED_MIN 0x70
57#define FDDI_FC_K_RESERVED_MAX 0x7F
58
59/* Define LLC and SNAP constants */
60#define FDDI_EXTENDED_SAP 0xAA
61#define FDDI_UI_CMD 0x03
62
63/* Define 802.2 Type 1 header */
64struct fddi_8022_1_hdr
65 {
66 __u8 dsap; /* destination service access point */
67 __u8 ssap; /* source service access point */
68 __u8 ctrl; /* control byte #1 */
69 } __attribute__ ((packed));
70
71/* Define 802.2 Type 2 header */
72struct fddi_8022_2_hdr
73 {
74 __u8 dsap; /* destination service access point */
75 __u8 ssap; /* source service access point */
76 __u8 ctrl_1; /* control byte #1 */
77 __u8 ctrl_2; /* control byte #2 */
78 } __attribute__ ((packed));
79
80/* Define 802.2 SNAP header */
81#define FDDI_K_OUI_LEN 3
82struct fddi_snap_hdr
83 {
84 __u8 dsap; /* always 0xAA */
85 __u8 ssap; /* always 0xAA */
86 __u8 ctrl; /* always 0x03 */
87 __u8 oui[FDDI_K_OUI_LEN]; /* organizational universal id */
88 __u16 ethertype; /* packet type ID field */
89 } __attribute__ ((packed));
90
91/* Define FDDI LLC frame header */
92struct fddihdr
93 {
94 __u8 fc; /* frame control */
95 __u8 daddr[FDDI_K_ALEN]; /* destination address */
96 __u8 saddr[FDDI_K_ALEN]; /* source address */
97 union
98 {
99 struct fddi_8022_1_hdr llc_8022_1;
100 struct fddi_8022_2_hdr llc_8022_2;
101 struct fddi_snap_hdr llc_snap;
102 } hdr;
103 } __attribute__ ((packed));
104
105/* Define FDDI statistics structure */
106struct fddi_statistics {
107
108 /* Generic statistics. */
109
110 struct net_device_stats gen;
111
112 /* Detailed FDDI statistics. Adopted from RFC 1512 */
113
114 __u8 smt_station_id[8];
115 __u32 smt_op_version_id;
116 __u32 smt_hi_version_id;
117 __u32 smt_lo_version_id;
118 __u8 smt_user_data[32];
119 __u32 smt_mib_version_id;
120 __u32 smt_mac_cts;
121 __u32 smt_non_master_cts;
122 __u32 smt_master_cts;
123 __u32 smt_available_paths;
124 __u32 smt_config_capabilities;
125 __u32 smt_config_policy;
126 __u32 smt_connection_policy;
127 __u32 smt_t_notify;
128 __u32 smt_stat_rpt_policy;
129 __u32 smt_trace_max_expiration;
130 __u32 smt_bypass_present;
131 __u32 smt_ecm_state;
132 __u32 smt_cf_state;
133 __u32 smt_remote_disconnect_flag;
134 __u32 smt_station_status;
135 __u32 smt_peer_wrap_flag;
136 __u32 smt_time_stamp;
137 __u32 smt_transition_time_stamp;
138 __u32 mac_frame_status_functions;
139 __u32 mac_t_max_capability;
140 __u32 mac_tvx_capability;
141 __u32 mac_available_paths;
142 __u32 mac_current_path;
143 __u8 mac_upstream_nbr[FDDI_K_ALEN];
144 __u8 mac_downstream_nbr[FDDI_K_ALEN];
145 __u8 mac_old_upstream_nbr[FDDI_K_ALEN];
146 __u8 mac_old_downstream_nbr[FDDI_K_ALEN];
147 __u32 mac_dup_address_test;
148 __u32 mac_requested_paths;
149 __u32 mac_downstream_port_type;
150 __u8 mac_smt_address[FDDI_K_ALEN];
151 __u32 mac_t_req;
152 __u32 mac_t_neg;
153 __u32 mac_t_max;
154 __u32 mac_tvx_value;
155 __u32 mac_frame_cts;
156 __u32 mac_copied_cts;
157 __u32 mac_transmit_cts;
158 __u32 mac_error_cts;
159 __u32 mac_lost_cts;
160 __u32 mac_frame_error_threshold;
161 __u32 mac_frame_error_ratio;
162 __u32 mac_rmt_state;
163 __u32 mac_da_flag;
164 __u32 mac_una_da_flag;
165 __u32 mac_frame_error_flag;
166 __u32 mac_ma_unitdata_available;
167 __u32 mac_hardware_present;
168 __u32 mac_ma_unitdata_enable;
169 __u32 path_tvx_lower_bound;
170 __u32 path_t_max_lower_bound;
171 __u32 path_max_t_req;
172 __u32 path_configuration[8];
173 __u32 port_my_type[2];
174 __u32 port_neighbor_type[2];
175 __u32 port_connection_policies[2];
176 __u32 port_mac_indicated[2];
177 __u32 port_current_path[2];
178 __u8 port_requested_paths[3*2];
179 __u32 port_mac_placement[2];
180 __u32 port_available_paths[2];
181 __u32 port_pmd_class[2];
182 __u32 port_connection_capabilities[2];
183 __u32 port_bs_flag[2];
184 __u32 port_lct_fail_cts[2];
185 __u32 port_ler_estimate[2];
186 __u32 port_lem_reject_cts[2];
187 __u32 port_lem_cts[2];
188 __u32 port_ler_cutoff[2];
189 __u32 port_ler_alarm[2];
190 __u32 port_connect_state[2];
191 __u32 port_pcm_state[2];
192 __u32 port_pc_withhold[2];
193 __u32 port_ler_flag[2];
194 __u32 port_hardware_present[2];
195 };
196
197#endif /* _LINUX_IF_FDDI_H */
diff --git a/include/linux/if_frad.h b/include/linux/if_frad.h
new file mode 100644
index 000000000000..3c94b1736570
--- /dev/null
+++ b/include/linux/if_frad.h
@@ -0,0 +1,200 @@
1/*
2 * DLCI/FRAD Definitions for Frame Relay Access Devices. DLCI devices are
3 * created for each DLCI associated with a FRAD. The FRAD driver
4 * is not truly a network device, but the lower level device
5 * handler. This allows other FRAD manufacturers to use the DLCI
6 * code, including its RFC1490 encapsulation alongside the current
7 * implementation for the Sangoma cards.
8 *
9 * Version: @(#)if_ifrad.h 0.15 31 Mar 96
10 *
11 * Author: Mike McLagan <mike.mclagan@linux.org>
12 *
13 * Changes:
14 * 0.15 Mike McLagan changed structure defs (packed)
15 * re-arranged flags
16 * added DLCI_RET vars
17 *
18 * This program is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU General Public License
20 * as published by the Free Software Foundation; either version
21 * 2 of the License, or (at your option) any later version.
22 */
23
24#ifndef _FRAD_H_
25#define _FRAD_H_
26
27#include <linux/config.h>
28#include <linux/if.h>
29
30#if defined(CONFIG_DLCI) || defined(CONFIG_DLCI_MODULE)
31
32/* Structures and constants associated with the DLCI device driver */
33
34struct dlci_add
35{
36 char devname[IFNAMSIZ];
37 short dlci;
38};
39
40#define DLCI_GET_CONF (SIOCDEVPRIVATE + 2)
41#define DLCI_SET_CONF (SIOCDEVPRIVATE + 3)
42
43/*
44 * These are related to the Sangoma SDLA and should remain in order.
45 * Code within the SDLA module is based on the specifics of this
46 * structure. Change at your own peril.
47 */
48struct dlci_conf {
49 short flags;
50 short CIR_fwd;
51 short Bc_fwd;
52 short Be_fwd;
53 short CIR_bwd;
54 short Bc_bwd;
55 short Be_bwd;
56
57/* these are part of the status read */
58 short Tc_fwd;
59 short Tc_bwd;
60 short Tf_max;
61 short Tb_max;
62
63/* add any new fields here above is a mirror of sdla_dlci_conf */
64};
65
66#define DLCI_GET_SLAVE (SIOCDEVPRIVATE + 4)
67
68/* configuration flags for DLCI */
69#define DLCI_IGNORE_CIR_OUT 0x0001
70#define DLCI_ACCOUNT_CIR_IN 0x0002
71#define DLCI_BUFFER_IF 0x0008
72
73#define DLCI_VALID_FLAGS 0x000B
74
75/* FRAD driver uses these to indicate what it did with packet */
76#define DLCI_RET_OK 0x00
77#define DLCI_RET_ERR 0x01
78#define DLCI_RET_DROP 0x02
79
80/* defines for the actual Frame Relay hardware */
81#define FRAD_GET_CONF (SIOCDEVPRIVATE)
82#define FRAD_SET_CONF (SIOCDEVPRIVATE + 1)
83
84#define FRAD_LAST_IOCTL FRAD_SET_CONF
85
86/*
87 * Based on the setup for the Sangoma SDLA. If changes are
88 * necessary to this structure, a routine will need to be
89 * added to that module to copy fields.
90 */
91struct frad_conf
92{
93 short station;
94 short flags;
95 short kbaud;
96 short clocking;
97 short mtu;
98 short T391;
99 short T392;
100 short N391;
101 short N392;
102 short N393;
103 short CIR_fwd;
104 short Bc_fwd;
105 short Be_fwd;
106 short CIR_bwd;
107 short Bc_bwd;
108 short Be_bwd;
109
110/* Add new fields here, above is a mirror of the sdla_conf */
111
112};
113
114#define FRAD_STATION_CPE 0x0000
115#define FRAD_STATION_NODE 0x0001
116
117#define FRAD_TX_IGNORE_CIR 0x0001
118#define FRAD_RX_ACCOUNT_CIR 0x0002
119#define FRAD_DROP_ABORTED 0x0004
120#define FRAD_BUFFERIF 0x0008
121#define FRAD_STATS 0x0010
122#define FRAD_MCI 0x0100
123#define FRAD_AUTODLCI 0x8000
124#define FRAD_VALID_FLAGS 0x811F
125
126#define FRAD_CLOCK_INT 0x0001
127#define FRAD_CLOCK_EXT 0x0000
128
129#ifdef __KERNEL__
130
131/* these are the fields of an RFC 1490 header */
132struct frhdr
133{
134 unsigned char control __attribute__((packed));
135
136 /* for IP packets, this can be the NLPID */
137 unsigned char pad __attribute__((packed));
138
139 unsigned char NLPID __attribute__((packed));
140 unsigned char OUI[3] __attribute__((packed));
141 unsigned short PID __attribute__((packed));
142
143#define IP_NLPID pad
144};
145
146/* see RFC 1490 for the definition of the following */
147#define FRAD_I_UI 0x03
148
149#define FRAD_P_PADDING 0x00
150#define FRAD_P_Q933 0x08
151#define FRAD_P_SNAP 0x80
152#define FRAD_P_CLNP 0x81
153#define FRAD_P_IP 0xCC
154
155struct dlci_local
156{
157 struct net_device_stats stats;
158 struct net_device *master;
159 struct net_device *slave;
160 struct dlci_conf config;
161 int configured;
162 struct list_head list;
163
164 /* callback function */
165 void (*receive)(struct sk_buff *skb, struct net_device *);
166};
167
168struct frad_local
169{
170 struct net_device_stats stats;
171
172 /* devices which this FRAD is slaved to */
173 struct net_device *master[CONFIG_DLCI_MAX];
174 short dlci[CONFIG_DLCI_MAX];
175
176 struct frad_conf config;
177 int configured; /* has this device been configured */
178 int initialized; /* mem_start, port, irq set ? */
179
180 /* callback functions */
181 int (*activate)(struct net_device *, struct net_device *);
182 int (*deactivate)(struct net_device *, struct net_device *);
183 int (*assoc)(struct net_device *, struct net_device *);
184 int (*deassoc)(struct net_device *, struct net_device *);
185 int (*dlci_conf)(struct net_device *, struct net_device *, int get);
186
187 /* fields that are used by the Sangoma SDLA cards */
188 struct timer_list timer;
189 int type; /* adapter type */
190 int state; /* state of the S502/8 control latch */
191 int buffer; /* current buffer for S508 firmware */
192};
193
194extern void dlci_ioctl_set(int (*hook)(unsigned int, void __user *));
195
196#endif /* __KERNEL__ */
197
198#endif /* CONFIG_DLCI || CONFIG_DLCI_MODULE */
199
200#endif
diff --git a/include/linux/if_hippi.h b/include/linux/if_hippi.h
new file mode 100644
index 000000000000..c8ca72c46f76
--- /dev/null
+++ b/include/linux/if_hippi.h
@@ -0,0 +1,157 @@
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Global definitions for the HIPPI interface.
7 *
8 * Version: @(#)if_hippi.h 1.0.0 05/26/97
9 *
10 * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
11 * Donald Becker, <becker@super.org>
12 * Alan Cox, <alan@redhat.com>
13 * Steve Whitehouse, <gw7rrm@eeshack3.swan.ac.uk>
14 * Jes Sorensen, <Jes.Sorensen@cern.ch>
15 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version
19 * 2 of the License, or (at your option) any later version.
20 */
21
22#ifndef _LINUX_IF_HIPPI_H
23#define _LINUX_IF_HIPPI_H
24
25#include <asm/byteorder.h>
26
27/*
28 * HIPPI magic constants.
29 */
30
31#define HIPPI_ALEN 6 /* Bytes in one HIPPI hw-addr */
32#define HIPPI_HLEN sizeof(struct hippi_hdr)
33#define HIPPI_ZLEN 0 /* Min. bytes in frame without FCS */
34#define HIPPI_DATA_LEN 65280 /* Max. bytes in payload */
35#define HIPPI_FRAME_LEN (HIPPI_DATA_LEN + HIPPI_HLEN)
36 /* Max. bytes in frame without FCS */
37
38/*
39 * Define LLC and SNAP constants.
40 */
41#define HIPPI_EXTENDED_SAP 0xAA
42#define HIPPI_UI_CMD 0x03
43
44
45/*
46 * Do we need to list some sort of ID's here?
47 */
48
49/*
50 * HIPPI statistics collection data.
51 */
52
53struct hipnet_statistics
54{
55 int rx_packets; /* total packets received */
56 int tx_packets; /* total packets transmitted */
57 int rx_errors; /* bad packets received */
58 int tx_errors; /* packet transmit problems */
59 int rx_dropped; /* no space in linux buffers */
60 int tx_dropped; /* no space available in linux */
61
62 /* detailed rx_errors: */
63 int rx_length_errors;
64 int rx_over_errors; /* receiver ring buff overflow */
65 int rx_crc_errors; /* recved pkt with crc error */
66 int rx_frame_errors; /* recv'd frame alignment error */
67 int rx_fifo_errors; /* recv'r fifo overrun */
68 int rx_missed_errors; /* receiver missed packet */
69
70 /* detailed tx_errors */
71 int tx_aborted_errors;
72 int tx_carrier_errors;
73 int tx_fifo_errors;
74 int tx_heartbeat_errors;
75 int tx_window_errors;
76};
77
78
79struct hippi_fp_hdr
80{
81#if 0
82 __u8 ulp; /* must contain 4 */
83#if defined (__BIG_ENDIAN_BITFIELD)
84 __u8 d1_data_present:1; /* must be 1 */
85 __u8 start_d2_burst_boundary:1; /* must be zero */
86 __u8 reserved:6; /* must be zero */
87#if 0
88 __u16 reserved1:5;
89 __u16 d1_area_size:8; /* must be 3 */
90 __u16 d2_offset:3; /* must be zero */
91#endif
92#elif defined(__LITTLE_ENDIAN_BITFIELD)
93 __u8 reserved:6; /* must be zero */
94 __u8 start_d2_burst_boundary:1; /* must be zero */
95 __u8 d1_data_present:1; /* must be 1 */
96#if 0
97 __u16 d2_offset:3; /* must be zero */
98 __u16 d1_area_size:8; /* must be 3 */
99 __u16 reserved1:5; /* must be zero */
100#endif
101#else
102#error "Please fix <asm/byteorder.h>"
103#endif
104#else
105 __u32 fixed;
106#endif
107 __u32 d2_size;
108} __attribute__ ((packed));
109
110struct hippi_le_hdr
111{
112#if defined (__BIG_ENDIAN_BITFIELD)
113 __u8 fc:3;
114 __u8 double_wide:1;
115 __u8 message_type:4;
116#elif defined(__LITTLE_ENDIAN_BITFIELD)
117 __u8 message_type:4;
118 __u8 double_wide:1;
119 __u8 fc:3;
120#endif
121 __u8 dest_switch_addr[3];
122#if defined (__BIG_ENDIAN_BITFIELD)
123 __u8 dest_addr_type:4,
124 src_addr_type:4;
125#elif defined(__LITTLE_ENDIAN_BITFIELD)
126 __u8 src_addr_type:4,
127 dest_addr_type:4;
128#endif
129 __u8 src_switch_addr[3];
130 __u16 reserved;
131 __u8 daddr[HIPPI_ALEN];
132 __u16 locally_administered;
133 __u8 saddr[HIPPI_ALEN];
134} __attribute__ ((packed));
135
136#define HIPPI_OUI_LEN 3
137/*
138 * Looks like the dsap and ssap fields have been swapped by mistake in
139 * RFC 2067 "IP over HIPPI".
140 */
141struct hippi_snap_hdr
142{
143 __u8 dsap; /* always 0xAA */
144 __u8 ssap; /* always 0xAA */
145 __u8 ctrl; /* always 0x03 */
146 __u8 oui[HIPPI_OUI_LEN]; /* organizational universal id (zero)*/
147 __u16 ethertype; /* packet type ID field */
148} __attribute__ ((packed));
149
150struct hippi_hdr
151{
152 struct hippi_fp_hdr fp;
153 struct hippi_le_hdr le;
154 struct hippi_snap_hdr snap;
155} __attribute__ ((packed));
156
157#endif /* _LINUX_IF_HIPPI_H */
diff --git a/include/linux/if_infiniband.h b/include/linux/if_infiniband.h
new file mode 100644
index 000000000000..3e659ec7dfdd
--- /dev/null
+++ b/include/linux/if_infiniband.h
@@ -0,0 +1,29 @@
1/*
2 * This software is available to you under a choice of one of two
3 * licenses. You may choose to be licensed under the terms of the GNU
4 * General Public License (GPL) Version 2, available at
5 * <http://www.fsf.org/copyleft/gpl.html>, or the OpenIB.org BSD
6 * license, available in the LICENSE.TXT file accompanying this
7 * software. These details are also available at
8 * <http://openib.org/license.html>.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
11 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
12 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
13 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
14 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
15 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
16 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17 * SOFTWARE.
18 *
19 * Copyright (c) 2004 Topspin Communications. All rights reserved.
20 *
21 * $Id$
22 */
23
24#ifndef _LINUX_IF_INFINIBAND_H
25#define _LINUX_IF_INFINIBAND_H
26
27#define INFINIBAND_ALEN 20 /* Octets in IPoIB HW addr */
28
29#endif /* _LINUX_IF_INFINIBAND_H */
diff --git a/include/linux/if_ltalk.h b/include/linux/if_ltalk.h
new file mode 100644
index 000000000000..e75e832b7ff0
--- /dev/null
+++ b/include/linux/if_ltalk.h
@@ -0,0 +1,12 @@
1#ifndef __LINUX_LTALK_H
2#define __LINUX_LTALK_H
3
4#define LTALK_HLEN 1
5#define LTALK_MTU 600
6#define LTALK_ALEN 1
7
8#ifdef __KERNEL__
9extern void ltalk_setup(struct net_device *);
10#endif
11
12#endif
diff --git a/include/linux/if_packet.h b/include/linux/if_packet.h
new file mode 100644
index 000000000000..b92558549d27
--- /dev/null
+++ b/include/linux/if_packet.h
@@ -0,0 +1,102 @@
1#ifndef __LINUX_IF_PACKET_H
2#define __LINUX_IF_PACKET_H
3
4struct sockaddr_pkt
5{
6 unsigned short spkt_family;
7 unsigned char spkt_device[14];
8 unsigned short spkt_protocol;
9};
10
11struct sockaddr_ll
12{
13 unsigned short sll_family;
14 unsigned short sll_protocol;
15 int sll_ifindex;
16 unsigned short sll_hatype;
17 unsigned char sll_pkttype;
18 unsigned char sll_halen;
19 unsigned char sll_addr[8];
20};
21
22/* Packet types */
23
24#define PACKET_HOST 0 /* To us */
25#define PACKET_BROADCAST 1 /* To all */
26#define PACKET_MULTICAST 2 /* To group */
27#define PACKET_OTHERHOST 3 /* To someone else */
28#define PACKET_OUTGOING 4 /* Outgoing of any type */
29/* These ones are invisible by user level */
30#define PACKET_LOOPBACK 5 /* MC/BRD frame looped back */
31#define PACKET_FASTROUTE 6 /* Fastrouted frame */
32
33/* Packet socket options */
34
35#define PACKET_ADD_MEMBERSHIP 1
36#define PACKET_DROP_MEMBERSHIP 2
37#define PACKET_RECV_OUTPUT 3
38/* Value 4 is still used by obsolete turbo-packet. */
39#define PACKET_RX_RING 5
40#define PACKET_STATISTICS 6
41#define PACKET_COPY_THRESH 7
42
43struct tpacket_stats
44{
45 unsigned int tp_packets;
46 unsigned int tp_drops;
47};
48
49struct tpacket_hdr
50{
51 unsigned long tp_status;
52#define TP_STATUS_KERNEL 0
53#define TP_STATUS_USER 1
54#define TP_STATUS_COPY 2
55#define TP_STATUS_LOSING 4
56#define TP_STATUS_CSUMNOTREADY 8
57 unsigned int tp_len;
58 unsigned int tp_snaplen;
59 unsigned short tp_mac;
60 unsigned short tp_net;
61 unsigned int tp_sec;
62 unsigned int tp_usec;
63};
64
65#define TPACKET_ALIGNMENT 16
66#define TPACKET_ALIGN(x) (((x)+TPACKET_ALIGNMENT-1)&~(TPACKET_ALIGNMENT-1))
67#define TPACKET_HDRLEN (TPACKET_ALIGN(sizeof(struct tpacket_hdr)) + sizeof(struct sockaddr_ll))
68
69/*
70 Frame structure:
71
72 - Start. Frame must be aligned to TPACKET_ALIGNMENT=16
73 - struct tpacket_hdr
74 - pad to TPACKET_ALIGNMENT=16
75 - struct sockaddr_ll
76 - Gap, chosen so that packet data (Start+tp_net) alignes to TPACKET_ALIGNMENT=16
77 - Start+tp_mac: [ Optional MAC header ]
78 - Start+tp_net: Packet data, aligned to TPACKET_ALIGNMENT=16.
79 - Pad to align to TPACKET_ALIGNMENT=16
80 */
81
82struct tpacket_req
83{
84 unsigned int tp_block_size; /* Minimal size of contiguous block */
85 unsigned int tp_block_nr; /* Number of blocks */
86 unsigned int tp_frame_size; /* Size of frame */
87 unsigned int tp_frame_nr; /* Total number of frames */
88};
89
90struct packet_mreq
91{
92 int mr_ifindex;
93 unsigned short mr_type;
94 unsigned short mr_alen;
95 unsigned char mr_address[8];
96};
97
98#define PACKET_MR_MULTICAST 0
99#define PACKET_MR_PROMISC 1
100#define PACKET_MR_ALLMULTI 2
101
102#endif
diff --git a/include/linux/if_plip.h b/include/linux/if_plip.h
new file mode 100644
index 000000000000..153a649915a2
--- /dev/null
+++ b/include/linux/if_plip.h
@@ -0,0 +1,28 @@
1/*
2 * NET3 PLIP tuning facilities for the new Niibe PLIP.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 *
9 */
10
11#ifndef _LINUX_IF_PLIP_H
12#define _LINUX_IF_PLIP_H
13
14#include <linux/sockios.h>
15
16#define SIOCDEVPLIP SIOCDEVPRIVATE
17
18struct plipconf
19{
20 unsigned short pcmd;
21 unsigned long nibble;
22 unsigned long trigger;
23};
24
25#define PLIP_GET_TIMEOUT 0x1
26#define PLIP_SET_TIMEOUT 0x2
27
28#endif
diff --git a/include/linux/if_ppp.h b/include/linux/if_ppp.h
new file mode 100644
index 000000000000..572aff7daa21
--- /dev/null
+++ b/include/linux/if_ppp.h
@@ -0,0 +1,155 @@
1/* $Id: if_ppp.h,v 1.21 2000/03/27 06:03:36 paulus Exp $ */
2
3/*
4 * if_ppp.h - Point-to-Point Protocol definitions.
5 *
6 * Copyright (c) 1989 Carnegie Mellon University.
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms are permitted
10 * provided that the above copyright notice and this paragraph are
11 * duplicated in all such forms and that any documentation,
12 * advertising materials, and other materials related to such
13 * distribution and use acknowledge that the software was developed
14 * by Carnegie Mellon University. The name of the
15 * University may not be used to endorse or promote products derived
16 * from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
19 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 */
22
23/*
24 * ==FILEVERSION 20000724==
25 *
26 * NOTE TO MAINTAINERS:
27 * If you modify this file at all, please set the above date.
28 * if_ppp.h is shipped with a PPP distribution as well as with the kernel;
29 * if everyone increases the FILEVERSION number above, then scripts
30 * can do the right thing when deciding whether to install a new if_ppp.h
31 * file. Don't change the format of that line otherwise, so the
32 * installation script can recognize it.
33 */
34
35#ifndef _IF_PPP_H_
36#define _IF_PPP_H_
37
38/*
39 * Packet sizes
40 */
41
42#define PPP_MTU 1500 /* Default MTU (size of Info field) */
43#define PPP_MAXMRU 65000 /* Largest MRU we allow */
44#define PROTO_IPX 0x002b /* protocol numbers */
45#define PROTO_DNA_RT 0x0027 /* DNA Routing */
46
47
48/*
49 * Bit definitions for flags.
50 */
51
52#define SC_COMP_PROT 0x00000001 /* protocol compression (output) */
53#define SC_COMP_AC 0x00000002 /* header compression (output) */
54#define SC_COMP_TCP 0x00000004 /* TCP (VJ) compression (output) */
55#define SC_NO_TCP_CCID 0x00000008 /* disable VJ connection-id comp. */
56#define SC_REJ_COMP_AC 0x00000010 /* reject adrs/ctrl comp. on input */
57#define SC_REJ_COMP_TCP 0x00000020 /* reject TCP (VJ) comp. on input */
58#define SC_CCP_OPEN 0x00000040 /* Look at CCP packets */
59#define SC_CCP_UP 0x00000080 /* May send/recv compressed packets */
60#define SC_ENABLE_IP 0x00000100 /* IP packets may be exchanged */
61#define SC_LOOP_TRAFFIC 0x00000200 /* send traffic to pppd */
62#define SC_MULTILINK 0x00000400 /* do multilink encapsulation */
63#define SC_MP_SHORTSEQ 0x00000800 /* use short MP sequence numbers */
64#define SC_COMP_RUN 0x00001000 /* compressor has been inited */
65#define SC_DECOMP_RUN 0x00002000 /* decompressor has been inited */
66#define SC_MP_XSHORTSEQ 0x00004000 /* transmit short MP seq numbers */
67#define SC_DEBUG 0x00010000 /* enable debug messages */
68#define SC_LOG_INPKT 0x00020000 /* log contents of good pkts recvd */
69#define SC_LOG_OUTPKT 0x00040000 /* log contents of pkts sent */
70#define SC_LOG_RAWIN 0x00080000 /* log all chars received */
71#define SC_LOG_FLUSH 0x00100000 /* log all chars flushed */
72#define SC_SYNC 0x00200000 /* synchronous serial mode */
73#define SC_MASK 0x0f200fff /* bits that user can change */
74
75/* state bits */
76#define SC_XMIT_BUSY 0x10000000 /* (used by isdn_ppp?) */
77#define SC_RCV_ODDP 0x08000000 /* have rcvd char with odd parity */
78#define SC_RCV_EVNP 0x04000000 /* have rcvd char with even parity */
79#define SC_RCV_B7_1 0x02000000 /* have rcvd char with bit 7 = 1 */
80#define SC_RCV_B7_0 0x01000000 /* have rcvd char with bit 7 = 0 */
81#define SC_DC_FERROR 0x00800000 /* fatal decomp error detected */
82#define SC_DC_ERROR 0x00400000 /* non-fatal decomp error detected */
83
84/*
85 * Ioctl definitions.
86 */
87
88struct npioctl {
89 int protocol; /* PPP protocol, e.g. PPP_IP */
90 enum NPmode mode;
91};
92
93/* Structure describing a CCP configuration option, for PPPIOCSCOMPRESS */
94struct ppp_option_data {
95 __u8 __user *ptr;
96 __u32 length;
97 int transmit;
98};
99
100struct ifpppstatsreq {
101 struct ifreq b;
102 struct ppp_stats stats; /* statistic information */
103};
104
105struct ifpppcstatsreq {
106 struct ifreq b;
107 struct ppp_comp_stats stats;
108};
109
110#define ifr__name b.ifr_ifrn.ifrn_name
111#define stats_ptr b.ifr_ifru.ifru_data
112
113/*
114 * Ioctl definitions.
115 */
116
117#define PPPIOCGFLAGS _IOR('t', 90, int) /* get configuration flags */
118#define PPPIOCSFLAGS _IOW('t', 89, int) /* set configuration flags */
119#define PPPIOCGASYNCMAP _IOR('t', 88, int) /* get async map */
120#define PPPIOCSASYNCMAP _IOW('t', 87, int) /* set async map */
121#define PPPIOCGUNIT _IOR('t', 86, int) /* get ppp unit number */
122#define PPPIOCGRASYNCMAP _IOR('t', 85, int) /* get receive async map */
123#define PPPIOCSRASYNCMAP _IOW('t', 84, int) /* set receive async map */
124#define PPPIOCGMRU _IOR('t', 83, int) /* get max receive unit */
125#define PPPIOCSMRU _IOW('t', 82, int) /* set max receive unit */
126#define PPPIOCSMAXCID _IOW('t', 81, int) /* set VJ max slot ID */
127#define PPPIOCGXASYNCMAP _IOR('t', 80, ext_accm) /* get extended ACCM */
128#define PPPIOCSXASYNCMAP _IOW('t', 79, ext_accm) /* set extended ACCM */
129#define PPPIOCXFERUNIT _IO('t', 78) /* transfer PPP unit */
130#define PPPIOCSCOMPRESS _IOW('t', 77, struct ppp_option_data)
131#define PPPIOCGNPMODE _IOWR('t', 76, struct npioctl) /* get NP mode */
132#define PPPIOCSNPMODE _IOW('t', 75, struct npioctl) /* set NP mode */
133#define PPPIOCSPASS _IOW('t', 71, struct sock_fprog) /* set pass filter */
134#define PPPIOCSACTIVE _IOW('t', 70, struct sock_fprog) /* set active filt */
135#define PPPIOCGDEBUG _IOR('t', 65, int) /* Read debug level */
136#define PPPIOCSDEBUG _IOW('t', 64, int) /* Set debug level */
137#define PPPIOCGIDLE _IOR('t', 63, struct ppp_idle) /* get idle time */
138#define PPPIOCNEWUNIT _IOWR('t', 62, int) /* create new ppp unit */
139#define PPPIOCATTACH _IOW('t', 61, int) /* attach to ppp unit */
140#define PPPIOCDETACH _IOW('t', 60, int) /* detach from ppp unit/chan */
141#define PPPIOCSMRRU _IOW('t', 59, int) /* set multilink MRU */
142#define PPPIOCCONNECT _IOW('t', 58, int) /* connect channel to unit */
143#define PPPIOCDISCONN _IO('t', 57) /* disconnect channel */
144#define PPPIOCATTCHAN _IOW('t', 56, int) /* attach to ppp channel */
145#define PPPIOCGCHAN _IOR('t', 55, int) /* get ppp channel number */
146
147#define SIOCGPPPSTATS (SIOCDEVPRIVATE + 0)
148#define SIOCGPPPVER (SIOCDEVPRIVATE + 1) /* NEVER change this!! */
149#define SIOCGPPPCSTATS (SIOCDEVPRIVATE + 2)
150
151#if !defined(ifr_mtu)
152#define ifr_mtu ifr_ifru.ifru_metric
153#endif
154
155#endif /* _IF_PPP_H_ */
diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
new file mode 100644
index 000000000000..e677f73f13dd
--- /dev/null
+++ b/include/linux/if_pppox.h
@@ -0,0 +1,175 @@
1/***************************************************************************
2 * Linux PPP over X - Generic PPP transport layer sockets
3 * Linux PPP over Ethernet (PPPoE) Socket Implementation (RFC 2516)
4 *
5 * This file supplies definitions required by the PPP over Ethernet driver
6 * (pppox.c). All version information wrt this file is located in pppox.c
7 *
8 * License:
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 *
14 */
15
16#ifndef __LINUX_IF_PPPOX_H
17#define __LINUX_IF_PPPOX_H
18
19
20#include <asm/types.h>
21#include <asm/byteorder.h>
22
23#ifdef __KERNEL__
24#include <linux/if_ether.h>
25#include <linux/if.h>
26#include <linux/netdevice.h>
27#include <asm/semaphore.h>
28#include <linux/ppp_channel.h>
29#endif /* __KERNEL__ */
30
31/* For user-space programs to pick up these definitions
32 * which they wouldn't get otherwise without defining __KERNEL__
33 */
34#ifndef AF_PPPOX
35#define AF_PPPOX 24
36#define PF_PPPOX AF_PPPOX
37#endif /* !(AF_PPPOX) */
38
39/************************************************************************
40 * PPPoE addressing definition
41 */
42typedef __u16 sid_t;
43struct pppoe_addr{
44 sid_t sid; /* Session identifier */
45 unsigned char remote[ETH_ALEN]; /* Remote address */
46 char dev[IFNAMSIZ]; /* Local device to use */
47};
48
49/************************************************************************
50 * Protocols supported by AF_PPPOX
51 */
52#define PX_PROTO_OE 0 /* Currently just PPPoE */
53#define PX_MAX_PROTO 1
54
55struct sockaddr_pppox {
56 sa_family_t sa_family; /* address family, AF_PPPOX */
57 unsigned int sa_protocol; /* protocol identifier */
58 union{
59 struct pppoe_addr pppoe;
60 }sa_addr;
61}__attribute__ ((packed));
62
63
64/*********************************************************************
65 *
66 * ioctl interface for defining forwarding of connections
67 *
68 ********************************************************************/
69
70#define PPPOEIOCSFWD _IOW(0xB1 ,0, size_t)
71#define PPPOEIOCDFWD _IO(0xB1 ,1)
72/*#define PPPOEIOCGFWD _IOWR(0xB1,2, size_t)*/
73
74/* Codes to identify message types */
75#define PADI_CODE 0x09
76#define PADO_CODE 0x07
77#define PADR_CODE 0x19
78#define PADS_CODE 0x65
79#define PADT_CODE 0xa7
80struct pppoe_tag {
81 __u16 tag_type;
82 __u16 tag_len;
83 char tag_data[0];
84} __attribute ((packed));
85
86/* Tag identifiers */
87#define PTT_EOL __constant_htons(0x0000)
88#define PTT_SRV_NAME __constant_htons(0x0101)
89#define PTT_AC_NAME __constant_htons(0x0102)
90#define PTT_HOST_UNIQ __constant_htons(0x0103)
91#define PTT_AC_COOKIE __constant_htons(0x0104)
92#define PTT_VENDOR __constant_htons(0x0105)
93#define PTT_RELAY_SID __constant_htons(0x0110)
94#define PTT_SRV_ERR __constant_htons(0x0201)
95#define PTT_SYS_ERR __constant_htons(0x0202)
96#define PTT_GEN_ERR __constant_htons(0x0203)
97
98struct pppoe_hdr {
99#if defined(__LITTLE_ENDIAN_BITFIELD)
100 __u8 ver : 4;
101 __u8 type : 4;
102#elif defined(__BIG_ENDIAN_BITFIELD)
103 __u8 type : 4;
104 __u8 ver : 4;
105#else
106#error "Please fix <asm/byteorder.h>"
107#endif
108 __u8 code;
109 __u16 sid;
110 __u16 length;
111 struct pppoe_tag tag[0];
112} __attribute__ ((packed));
113
114#ifdef __KERNEL__
115struct pppoe_opt {
116 struct net_device *dev; /* device associated with socket*/
117 struct pppoe_addr pa; /* what this socket is bound to*/
118 struct sockaddr_pppox relay; /* what socket data will be
119 relayed to (PPPoE relaying) */
120};
121
122#include <net/sock.h>
123
124struct pppox_sock {
125 /* struct sock must be the first member of pppox_sock */
126 struct sock sk;
127 struct ppp_channel chan;
128 struct pppox_sock *next; /* for hash table */
129 union {
130 struct pppoe_opt pppoe;
131 } proto;
132 unsigned short num;
133};
134#define pppoe_dev proto.pppoe.dev
135#define pppoe_pa proto.pppoe.pa
136#define pppoe_relay proto.pppoe.relay
137
138static inline struct pppox_sock *pppox_sk(struct sock *sk)
139{
140 return (struct pppox_sock *)sk;
141}
142
143static inline struct sock *sk_pppox(struct pppox_sock *po)
144{
145 return (struct sock *)po;
146}
147
148struct module;
149
150struct pppox_proto {
151 int (*create)(struct socket *sock);
152 int (*ioctl)(struct socket *sock, unsigned int cmd,
153 unsigned long arg);
154 struct module *owner;
155};
156
157extern int register_pppox_proto(int proto_num, struct pppox_proto *pp);
158extern void unregister_pppox_proto(int proto_num);
159extern void pppox_unbind_sock(struct sock *sk);/* delete ppp-channel binding */
160extern int pppox_channel_ioctl(struct ppp_channel *pc, unsigned int cmd,
161 unsigned long arg);
162
163/* PPPoX socket states */
164enum {
165 PPPOX_NONE = 0, /* initial state */
166 PPPOX_CONNECTED = 1, /* connection established ==TCP_ESTABLISHED */
167 PPPOX_BOUND = 2, /* bound to ppp device */
168 PPPOX_RELAY = 4, /* forwarding is enabled */
169 PPPOX_ZOMBIE = 8, /* dead, but still bound to ppp device */
170 PPPOX_DEAD = 16 /* dead, useless, please clean me up!*/
171};
172
173#endif /* __KERNEL__ */
174
175#endif /* !(__LINUX_IF_PPPOX_H) */
diff --git a/include/linux/if_shaper.h b/include/linux/if_shaper.h
new file mode 100644
index 000000000000..0485b256d043
--- /dev/null
+++ b/include/linux/if_shaper.h
@@ -0,0 +1,64 @@
1#ifndef __LINUX_SHAPER_H
2#define __LINUX_SHAPER_H
3
4#ifdef __KERNEL__
5
6#define SHAPER_QLEN 10
7/*
8 * This is a bit speed dependent (read it shouldn't be a constant!)
9 *
10 * 5 is about right for 28.8 upwards. Below that double for every
11 * halving of speed or so. - ie about 20 for 9600 baud.
12 */
13#define SHAPER_LATENCY (5*HZ)
14#define SHAPER_MAXSLIP 2
15#define SHAPER_BURST (HZ/50) /* Good for >128K then */
16
17struct shaper
18{
19 struct sk_buff_head sendq;
20 __u32 bytespertick;
21 __u32 bitspersec;
22 __u32 shapelatency;
23 __u32 shapeclock;
24 unsigned long recovery; /* Time we can next clock a packet out on
25 an empty queue */
26 unsigned long locked;
27 struct net_device_stats stats;
28 struct net_device *dev;
29 int (*hard_start_xmit) (struct sk_buff *skb,
30 struct net_device *dev);
31 int (*hard_header) (struct sk_buff *skb,
32 struct net_device *dev,
33 unsigned short type,
34 void *daddr,
35 void *saddr,
36 unsigned len);
37 int (*rebuild_header)(struct sk_buff *skb);
38 int (*hard_header_cache)(struct neighbour *neigh, struct hh_cache *hh);
39 void (*header_cache_update)(struct hh_cache *hh, struct net_device *dev, unsigned char * haddr);
40 struct net_device_stats* (*get_stats)(struct net_device *dev);
41 wait_queue_head_t wait_queue;
42 struct timer_list timer;
43};
44
45#endif
46
47#define SHAPER_SET_DEV 0x0001
48#define SHAPER_SET_SPEED 0x0002
49#define SHAPER_GET_DEV 0x0003
50#define SHAPER_GET_SPEED 0x0004
51
52struct shaperconf
53{
54 __u16 ss_cmd;
55 union
56 {
57 char ssu_name[14];
58 __u32 ssu_speed;
59 } ss_u;
60#define ss_speed ss_u.ssu_speed
61#define ss_name ss_u.ssu_name
62};
63
64#endif
diff --git a/include/linux/if_slip.h b/include/linux/if_slip.h
new file mode 100644
index 000000000000..1eb4e3a8397a
--- /dev/null
+++ b/include/linux/if_slip.h
@@ -0,0 +1,30 @@
1/*
2 * Swansea University Computer Society NET3
3 *
4 * This file declares the constants of special use with the SLIP/CSLIP/
5 * KISS TNC driver.
6 */
7
8#ifndef __LINUX_SLIP_H
9#define __LINUX_SLIP_H
10
11#define SL_MODE_SLIP 0
12#define SL_MODE_CSLIP 1
13#define SL_MODE_KISS 4
14
15#define SL_OPT_SIXBIT 2
16#define SL_OPT_ADAPTIVE 8
17
18/*
19 * VSV = ioctl for keepalive & outfill in SLIP driver
20 */
21
22#define SIOCSKEEPALIVE (SIOCDEVPRIVATE) /* Set keepalive timeout in sec */
23#define SIOCGKEEPALIVE (SIOCDEVPRIVATE+1) /* Get keepalive timeout */
24#define SIOCSOUTFILL (SIOCDEVPRIVATE+2) /* Set outfill timeout */
25#define SIOCGOUTFILL (SIOCDEVPRIVATE+3) /* Get outfill timeout */
26#define SIOCSLEASE (SIOCDEVPRIVATE+4) /* Set "leased" line type */
27#define SIOCGLEASE (SIOCDEVPRIVATE+5) /* Get line type */
28
29
30#endif
diff --git a/include/linux/if_strip.h b/include/linux/if_strip.h
new file mode 100644
index 000000000000..fb5c5c98442f
--- /dev/null
+++ b/include/linux/if_strip.h
@@ -0,0 +1,25 @@
1/*
2 * if_strip.h --
3 *
4 * Definitions for the STRIP interface
5 *
6 * Copyright 1996 The Board of Trustees of The Leland Stanford
7 * Junior University. All Rights Reserved.
8 *
9 * Permission to use, copy, modify, and distribute this
10 * software and its documentation for any purpose and without
11 * fee is hereby granted, provided that the above copyright
12 * notice appear in all copies. Stanford University
13 * makes no representations about the suitability of this
14 * software for any purpose. It is provided "as is" without
15 * express or implied warranty.
16 */
17
18#ifndef __LINUX_STRIP_H
19#define __LINUX_STRIP_H
20
21typedef struct {
22 __u8 c[6];
23} MetricomAddress;
24
25#endif
diff --git a/include/linux/if_tr.h b/include/linux/if_tr.h
new file mode 100644
index 000000000000..4fd451f81ccb
--- /dev/null
+++ b/include/linux/if_tr.h
@@ -0,0 +1,109 @@
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Global definitions for the Token-Ring IEEE 802.5 interface.
7 *
8 * Version: @(#)if_tr.h 0.0 07/11/94
9 *
10 * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
11 * Donald Becker, <becker@super.org>
12 * Peter De Schrijver, <stud11@cc4.kuleuven.ac.be>
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version
17 * 2 of the License, or (at your option) any later version.
18 */
19#ifndef _LINUX_IF_TR_H
20#define _LINUX_IF_TR_H
21
22
23/* IEEE 802.5 Token-Ring magic constants. The frame sizes omit the preamble
24 and FCS/CRC (frame check sequence). */
25#define TR_ALEN 6 /* Octets in one ethernet addr */
26#define TR_HLEN (sizeof(struct trh_hdr)+sizeof(struct trllc))
27#define AC 0x10
28#define LLC_FRAME 0x40
29#if 0
30#define ETH_HLEN 14 /* Total octets in header. */
31#define ETH_ZLEN 60 /* Min. octets in frame sans FCS */
32#define ETH_DATA_LEN 1500 /* Max. octets in payload */
33#define ETH_FRAME_LEN 1514 /* Max. octets in frame sans FCS */
34#endif
35
36
37/* LLC and SNAP constants */
38#define EXTENDED_SAP 0xAA
39#define UI_CMD 0x03
40
41/* This is an Token-Ring frame header. */
42struct trh_hdr {
43 __u8 ac; /* access control field */
44 __u8 fc; /* frame control field */
45 __u8 daddr[TR_ALEN]; /* destination address */
46 __u8 saddr[TR_ALEN]; /* source address */
47 __u16 rcf; /* route control field */
48 __u16 rseg[8]; /* routing registers */
49};
50
51#ifdef __KERNEL__
52#include <linux/skbuff.h>
53
54static inline struct trh_hdr *tr_hdr(const struct sk_buff *skb)
55{
56 return (struct trh_hdr *)skb->mac.raw;
57}
58#endif
59
60/* This is an Token-Ring LLC structure */
61struct trllc {
62 __u8 dsap; /* destination SAP */
63 __u8 ssap; /* source SAP */
64 __u8 llc; /* LLC control field */
65 __u8 protid[3]; /* protocol id */
66 __u16 ethertype; /* ether type field */
67};
68
69/* Token-Ring statistics collection data. */
70struct tr_statistics {
71 unsigned long rx_packets; /* total packets received */
72 unsigned long tx_packets; /* total packets transmitted */
73 unsigned long rx_bytes; /* total bytes received */
74 unsigned long tx_bytes; /* total bytes transmitted */
75 unsigned long rx_errors; /* bad packets received */
76 unsigned long tx_errors; /* packet transmit problems */
77 unsigned long rx_dropped; /* no space in linux buffers */
78 unsigned long tx_dropped; /* no space available in linux */
79 unsigned long multicast; /* multicast packets received */
80 unsigned long transmit_collision;
81
82 /* detailed Token-Ring errors. See IBM Token-Ring Network
83 Architecture for more info */
84
85 unsigned long line_errors;
86 unsigned long internal_errors;
87 unsigned long burst_errors;
88 unsigned long A_C_errors;
89 unsigned long abort_delimiters;
90 unsigned long lost_frames;
91 unsigned long recv_congest_count;
92 unsigned long frame_copied_errors;
93 unsigned long frequency_errors;
94 unsigned long token_errors;
95 unsigned long dummy1;
96};
97
98/* source routing stuff */
99
100#define TR_RII 0x80
101#define TR_RCF_DIR_BIT 0x80
102#define TR_RCF_LEN_MASK 0x1f00
103#define TR_RCF_BROADCAST 0x8000 /* all-routes broadcast */
104#define TR_RCF_LIMITED_BROADCAST 0xC000 /* single-route broadcast */
105#define TR_RCF_FRAME2K 0x20
106#define TR_RCF_BROADCAST_MASK 0xC000
107#define TR_MAXRIFLEN 18
108
109#endif /* _LINUX_IF_TR_H */
diff --git a/include/linux/if_tun.h b/include/linux/if_tun.h
new file mode 100644
index 000000000000..096a85a58ae5
--- /dev/null
+++ b/include/linux/if_tun.h
@@ -0,0 +1,93 @@
1/*
2 * Universal TUN/TAP device driver.
3 * Copyright (C) 1999-2000 Maxim Krasnyansky <max_mk@yahoo.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 as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * $Id: if_tun.h,v 1.2 2001/06/01 18:39:47 davem Exp $
16 */
17
18#ifndef __IF_TUN_H
19#define __IF_TUN_H
20
21/* Uncomment to enable debugging */
22/* #define TUN_DEBUG 1 */
23
24#ifdef __KERNEL__
25
26#ifdef TUN_DEBUG
27#define DBG if(tun->debug)printk
28#define DBG1 if(debug==2)printk
29#else
30#define DBG( a... )
31#define DBG1( a... )
32#endif
33
34struct tun_struct {
35 struct list_head list;
36 unsigned long flags;
37 int attached;
38 uid_t owner;
39
40 wait_queue_head_t read_wait;
41 struct sk_buff_head readq;
42
43 struct net_device *dev;
44 struct net_device_stats stats;
45
46 struct fasync_struct *fasync;
47
48 unsigned long if_flags;
49 u8 dev_addr[ETH_ALEN];
50 u32 chr_filter[2];
51 u32 net_filter[2];
52
53#ifdef TUN_DEBUG
54 int debug;
55#endif
56};
57
58#endif /* __KERNEL__ */
59
60/* Read queue size */
61#define TUN_READQ_SIZE 500
62
63/* TUN device flags */
64#define TUN_TUN_DEV 0x0001
65#define TUN_TAP_DEV 0x0002
66#define TUN_TYPE_MASK 0x000f
67
68#define TUN_FASYNC 0x0010
69#define TUN_NOCHECKSUM 0x0020
70#define TUN_NO_PI 0x0040
71#define TUN_ONE_QUEUE 0x0080
72#define TUN_PERSIST 0x0100
73
74/* Ioctl defines */
75#define TUNSETNOCSUM _IOW('T', 200, int)
76#define TUNSETDEBUG _IOW('T', 201, int)
77#define TUNSETIFF _IOW('T', 202, int)
78#define TUNSETPERSIST _IOW('T', 203, int)
79#define TUNSETOWNER _IOW('T', 204, int)
80
81/* TUNSETIFF ifr flags */
82#define IFF_TUN 0x0001
83#define IFF_TAP 0x0002
84#define IFF_NO_PI 0x1000
85#define IFF_ONE_QUEUE 0x2000
86
87struct tun_pi {
88 unsigned short flags;
89 unsigned short proto;
90};
91#define TUN_PKT_STRIP 0x0001
92
93#endif /* __IF_TUN_H */
diff --git a/include/linux/if_tunnel.h b/include/linux/if_tunnel.h
new file mode 100644
index 000000000000..bef9f8fd93b3
--- /dev/null
+++ b/include/linux/if_tunnel.h
@@ -0,0 +1,29 @@
1#ifndef _IF_TUNNEL_H_
2#define _IF_TUNNEL_H_
3
4#define SIOCGETTUNNEL (SIOCDEVPRIVATE + 0)
5#define SIOCADDTUNNEL (SIOCDEVPRIVATE + 1)
6#define SIOCDELTUNNEL (SIOCDEVPRIVATE + 2)
7#define SIOCCHGTUNNEL (SIOCDEVPRIVATE + 3)
8
9#define GRE_CSUM __constant_htons(0x8000)
10#define GRE_ROUTING __constant_htons(0x4000)
11#define GRE_KEY __constant_htons(0x2000)
12#define GRE_SEQ __constant_htons(0x1000)
13#define GRE_STRICT __constant_htons(0x0800)
14#define GRE_REC __constant_htons(0x0700)
15#define GRE_FLAGS __constant_htons(0x00F8)
16#define GRE_VERSION __constant_htons(0x0007)
17
18struct ip_tunnel_parm
19{
20 char name[IFNAMSIZ];
21 int link;
22 __u16 i_flags;
23 __u16 o_flags;
24 __u32 i_key;
25 __u32 o_key;
26 struct iphdr iph;
27};
28
29#endif /* _IF_TUNNEL_H_ */
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
new file mode 100644
index 000000000000..62a9d89dfbe2
--- /dev/null
+++ b/include/linux/if_vlan.h
@@ -0,0 +1,398 @@
1/*
2 * VLAN An implementation of 802.1Q VLAN tagging.
3 *
4 * Authors: Ben Greear <greearb@candelatech.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 */
12
13#ifndef _LINUX_IF_VLAN_H_
14#define _LINUX_IF_VLAN_H_
15
16#ifdef __KERNEL__
17
18/* externally defined structs */
19struct vlan_group;
20struct net_device;
21struct packet_type;
22struct vlan_collection;
23struct vlan_dev_info;
24struct hlist_node;
25
26#include <linux/proc_fs.h> /* for proc_dir_entry */
27#include <linux/netdevice.h>
28
29#define VLAN_HLEN 4 /* The additional bytes (on top of the Ethernet header)
30 * that VLAN requires.
31 */
32#define VLAN_ETH_ALEN 6 /* Octets in one ethernet addr */
33#define VLAN_ETH_HLEN 18 /* Total octets in header. */
34#define VLAN_ETH_ZLEN 64 /* Min. octets in frame sans FCS */
35
36/*
37 * According to 802.3ac, the packet can be 4 bytes longer. --Klika Jan
38 */
39#define VLAN_ETH_DATA_LEN 1500 /* Max. octets in payload */
40#define VLAN_ETH_FRAME_LEN 1518 /* Max. octets in frame sans FCS */
41
42struct vlan_ethhdr {
43 unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
44 unsigned char h_source[ETH_ALEN]; /* source ether addr */
45 unsigned short h_vlan_proto; /* Should always be 0x8100 */
46 unsigned short h_vlan_TCI; /* Encapsulates priority and VLAN ID */
47 unsigned short h_vlan_encapsulated_proto; /* packet type ID field (or len) */
48};
49
50#include <linux/skbuff.h>
51
52static inline struct vlan_ethhdr *vlan_eth_hdr(const struct sk_buff *skb)
53{
54 return (struct vlan_ethhdr *)skb->mac.raw;
55}
56
57struct vlan_hdr {
58 unsigned short h_vlan_TCI; /* Encapsulates priority and VLAN ID */
59 unsigned short h_vlan_encapsulated_proto; /* packet type ID field (or len) */
60};
61
62#define VLAN_VID_MASK 0xfff
63
64/* found in socket.c */
65extern void vlan_ioctl_set(int (*hook)(void __user *));
66
67#define VLAN_NAME "vlan"
68
69/* if this changes, algorithm will have to be reworked because this
70 * depends on completely exhausting the VLAN identifier space. Thus
71 * it gives constant time look-up, but in many cases it wastes memory.
72 */
73#define VLAN_GROUP_ARRAY_LEN 4096
74
75struct vlan_group {
76 int real_dev_ifindex; /* The ifindex of the ethernet(like) device the vlan is attached to. */
77 struct hlist_node hlist; /* linked list */
78 struct net_device *vlan_devices[VLAN_GROUP_ARRAY_LEN];
79 struct rcu_head rcu;
80};
81
82struct vlan_priority_tci_mapping {
83 unsigned long priority;
84 unsigned short vlan_qos; /* This should be shifted when first set, so we only do it
85 * at provisioning time.
86 * ((skb->priority << 13) & 0xE000)
87 */
88 struct vlan_priority_tci_mapping *next;
89};
90
91/* Holds information that makes sense if this device is a VLAN device. */
92struct vlan_dev_info {
93 /** This will be the mapping that correlates skb->priority to
94 * 3 bits of VLAN QOS tags...
95 */
96 unsigned long ingress_priority_map[8];
97 struct vlan_priority_tci_mapping *egress_priority_map[16]; /* hash table */
98
99 unsigned short vlan_id; /* The VLAN Identifier for this interface. */
100 unsigned short flags; /* (1 << 0) re_order_header This option will cause the
101 * VLAN code to move around the ethernet header on
102 * ingress to make the skb look **exactly** like it
103 * came in from an ethernet port. This destroys some of
104 * the VLAN information in the skb, but it fixes programs
105 * like DHCP that use packet-filtering and don't understand
106 * 802.1Q
107 */
108 struct dev_mc_list *old_mc_list; /* old multi-cast list for the VLAN interface..
109 * we save this so we can tell what changes were
110 * made, in order to feed the right changes down
111 * to the real hardware...
112 */
113 int old_allmulti; /* similar to above. */
114 int old_promiscuity; /* similar to above. */
115 struct net_device *real_dev; /* the underlying device/interface */
116 struct proc_dir_entry *dent; /* Holds the proc data */
117 unsigned long cnt_inc_headroom_on_tx; /* How many times did we have to grow the skb on TX. */
118 unsigned long cnt_encap_on_xmit; /* How many times did we have to encapsulate the skb on TX. */
119 struct net_device_stats dev_stats; /* Device stats (rx-bytes, tx-pkts, etc...) */
120};
121
122#define VLAN_DEV_INFO(x) ((struct vlan_dev_info *)(x->priv))
123
124/* inline functions */
125
126static inline struct net_device_stats *vlan_dev_get_stats(struct net_device *dev)
127{
128 return &(VLAN_DEV_INFO(dev)->dev_stats);
129}
130
131static inline __u32 vlan_get_ingress_priority(struct net_device *dev,
132 unsigned short vlan_tag)
133{
134 struct vlan_dev_info *vip = VLAN_DEV_INFO(dev);
135
136 return vip->ingress_priority_map[(vlan_tag >> 13) & 0x7];
137}
138
139/* VLAN tx hw acceleration helpers. */
140struct vlan_skb_tx_cookie {
141 u32 magic;
142 u32 vlan_tag;
143};
144
145#define VLAN_TX_COOKIE_MAGIC 0x564c414e /* "VLAN" in ascii. */
146#define VLAN_TX_SKB_CB(__skb) ((struct vlan_skb_tx_cookie *)&((__skb)->cb[0]))
147#define vlan_tx_tag_present(__skb) \
148 (VLAN_TX_SKB_CB(__skb)->magic == VLAN_TX_COOKIE_MAGIC)
149#define vlan_tx_tag_get(__skb) (VLAN_TX_SKB_CB(__skb)->vlan_tag)
150
151/* VLAN rx hw acceleration helper. This acts like netif_{rx,receive_skb}(). */
152static inline int __vlan_hwaccel_rx(struct sk_buff *skb,
153 struct vlan_group *grp,
154 unsigned short vlan_tag, int polling)
155{
156 struct net_device_stats *stats;
157
158 skb->real_dev = skb->dev;
159 skb->dev = grp->vlan_devices[vlan_tag & VLAN_VID_MASK];
160 if (skb->dev == NULL) {
161 dev_kfree_skb_any(skb);
162
163 /* Not NET_RX_DROP, this is not being dropped
164 * due to congestion.
165 */
166 return 0;
167 }
168
169 skb->dev->last_rx = jiffies;
170
171 stats = vlan_dev_get_stats(skb->dev);
172 stats->rx_packets++;
173 stats->rx_bytes += skb->len;
174
175 skb->priority = vlan_get_ingress_priority(skb->dev, vlan_tag);
176 switch (skb->pkt_type) {
177 case PACKET_BROADCAST:
178 break;
179
180 case PACKET_MULTICAST:
181 stats->multicast++;
182 break;
183
184 case PACKET_OTHERHOST:
185 /* Our lower layer thinks this is not local, let's make sure.
186 * This allows the VLAN to have a different MAC than the underlying
187 * device, and still route correctly.
188 */
189 if (!memcmp(eth_hdr(skb)->h_dest, skb->dev->dev_addr, ETH_ALEN))
190 skb->pkt_type = PACKET_HOST;
191 break;
192 };
193
194 return (polling ? netif_receive_skb(skb) : netif_rx(skb));
195}
196
197static inline int vlan_hwaccel_rx(struct sk_buff *skb,
198 struct vlan_group *grp,
199 unsigned short vlan_tag)
200{
201 return __vlan_hwaccel_rx(skb, grp, vlan_tag, 0);
202}
203
204static inline int vlan_hwaccel_receive_skb(struct sk_buff *skb,
205 struct vlan_group *grp,
206 unsigned short vlan_tag)
207{
208 return __vlan_hwaccel_rx(skb, grp, vlan_tag, 1);
209}
210
211/**
212 * __vlan_put_tag - regular VLAN tag inserting
213 * @skb: skbuff to tag
214 * @tag: VLAN tag to insert
215 *
216 * Inserts the VLAN tag into @skb as part of the payload
217 * Returns a VLAN tagged skb. If a new skb is created, @skb is freed.
218 *
219 * Following the skb_unshare() example, in case of error, the calling function
220 * doesn't have to worry about freeing the original skb.
221 */
222static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, unsigned short tag)
223{
224 struct vlan_ethhdr *veth;
225
226 if (skb_headroom(skb) < VLAN_HLEN) {
227 struct sk_buff *sk_tmp = skb;
228 skb = skb_realloc_headroom(sk_tmp, VLAN_HLEN);
229 kfree_skb(sk_tmp);
230 if (!skb) {
231 printk(KERN_ERR "vlan: failed to realloc headroom\n");
232 return NULL;
233 }
234 } else {
235 skb = skb_unshare(skb, GFP_ATOMIC);
236 if (!skb) {
237 printk(KERN_ERR "vlan: failed to unshare skbuff\n");
238 return NULL;
239 }
240 }
241
242 veth = (struct vlan_ethhdr *)skb_push(skb, VLAN_HLEN);
243
244 /* Move the mac addresses to the beginning of the new header. */
245 memmove(skb->data, skb->data + VLAN_HLEN, 2 * VLAN_ETH_ALEN);
246
247 /* first, the ethernet type */
248 veth->h_vlan_proto = __constant_htons(ETH_P_8021Q);
249
250 /* now, the tag */
251 veth->h_vlan_TCI = htons(tag);
252
253 skb->protocol = __constant_htons(ETH_P_8021Q);
254 skb->mac.raw -= VLAN_HLEN;
255 skb->nh.raw -= VLAN_HLEN;
256
257 return skb;
258}
259
260/**
261 * __vlan_hwaccel_put_tag - hardware accelerated VLAN inserting
262 * @skb: skbuff to tag
263 * @tag: VLAN tag to insert
264 *
265 * Puts the VLAN tag in @skb->cb[] and lets the device do the rest
266 */
267static inline struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb, unsigned short tag)
268{
269 struct vlan_skb_tx_cookie *cookie;
270
271 cookie = VLAN_TX_SKB_CB(skb);
272 cookie->magic = VLAN_TX_COOKIE_MAGIC;
273 cookie->vlan_tag = tag;
274
275 return skb;
276}
277
278#define HAVE_VLAN_PUT_TAG
279
280/**
281 * vlan_put_tag - inserts VLAN tag according to device features
282 * @skb: skbuff to tag
283 * @tag: VLAN tag to insert
284 *
285 * Assumes skb->dev is the target that will xmit this frame.
286 * Returns a VLAN tagged skb.
287 */
288static inline struct sk_buff *vlan_put_tag(struct sk_buff *skb, unsigned short tag)
289{
290 if (skb->dev->features & NETIF_F_HW_VLAN_TX) {
291 return __vlan_hwaccel_put_tag(skb, tag);
292 } else {
293 return __vlan_put_tag(skb, tag);
294 }
295}
296
297/**
298 * __vlan_get_tag - get the VLAN ID that is part of the payload
299 * @skb: skbuff to query
300 * @tag: buffer to store vlaue
301 *
302 * Returns error if the skb is not of VLAN type
303 */
304static inline int __vlan_get_tag(struct sk_buff *skb, unsigned short *tag)
305{
306 struct vlan_ethhdr *veth = (struct vlan_ethhdr *)skb->data;
307
308 if (veth->h_vlan_proto != __constant_htons(ETH_P_8021Q)) {
309 return -EINVAL;
310 }
311
312 *tag = ntohs(veth->h_vlan_TCI);
313
314 return 0;
315}
316
317/**
318 * __vlan_hwaccel_get_tag - get the VLAN ID that is in @skb->cb[]
319 * @skb: skbuff to query
320 * @tag: buffer to store vlaue
321 *
322 * Returns error if @skb->cb[] is not set correctly
323 */
324static inline int __vlan_hwaccel_get_tag(struct sk_buff *skb, unsigned short *tag)
325{
326 struct vlan_skb_tx_cookie *cookie;
327
328 cookie = VLAN_TX_SKB_CB(skb);
329 if (cookie->magic == VLAN_TX_COOKIE_MAGIC) {
330 *tag = cookie->vlan_tag;
331 return 0;
332 } else {
333 *tag = 0;
334 return -EINVAL;
335 }
336}
337
338#define HAVE_VLAN_GET_TAG
339
340/**
341 * vlan_get_tag - get the VLAN ID from the skb
342 * @skb: skbuff to query
343 * @tag: buffer to store vlaue
344 *
345 * Returns error if the skb is not VLAN tagged
346 */
347static inline int vlan_get_tag(struct sk_buff *skb, unsigned short *tag)
348{
349 if (skb->dev->features & NETIF_F_HW_VLAN_TX) {
350 return __vlan_hwaccel_get_tag(skb, tag);
351 } else {
352 return __vlan_get_tag(skb, tag);
353 }
354}
355
356#endif /* __KERNEL__ */
357
358/* VLAN IOCTLs are found in sockios.h */
359
360/* Passed in vlan_ioctl_args structure to determine behaviour. */
361enum vlan_ioctl_cmds {
362 ADD_VLAN_CMD,
363 DEL_VLAN_CMD,
364 SET_VLAN_INGRESS_PRIORITY_CMD,
365 SET_VLAN_EGRESS_PRIORITY_CMD,
366 GET_VLAN_INGRESS_PRIORITY_CMD,
367 GET_VLAN_EGRESS_PRIORITY_CMD,
368 SET_VLAN_NAME_TYPE_CMD,
369 SET_VLAN_FLAG_CMD,
370 GET_VLAN_REALDEV_NAME_CMD, /* If this works, you know it's a VLAN device, btw */
371 GET_VLAN_VID_CMD /* Get the VID of this VLAN (specified by name) */
372};
373
374enum vlan_name_types {
375 VLAN_NAME_TYPE_PLUS_VID, /* Name will look like: vlan0005 */
376 VLAN_NAME_TYPE_RAW_PLUS_VID, /* name will look like: eth1.0005 */
377 VLAN_NAME_TYPE_PLUS_VID_NO_PAD, /* Name will look like: vlan5 */
378 VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD, /* Name will look like: eth0.5 */
379 VLAN_NAME_TYPE_HIGHEST
380};
381
382struct vlan_ioctl_args {
383 int cmd; /* Should be one of the vlan_ioctl_cmds enum above. */
384 char device1[24];
385
386 union {
387 char device2[24];
388 int VID;
389 unsigned int skb_priority;
390 unsigned int name_type;
391 unsigned int bind_type;
392 unsigned int flag; /* Matches vlan_dev_info flags */
393 } u;
394
395 short vlan_qos;
396};
397
398#endif /* !(_LINUX_IF_VLAN_H_) */
diff --git a/include/linux/if_wanpipe.h b/include/linux/if_wanpipe.h
new file mode 100644
index 000000000000..e594ca6069e5
--- /dev/null
+++ b/include/linux/if_wanpipe.h
@@ -0,0 +1,124 @@
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/if_wanpipe_common.h b/include/linux/if_wanpipe_common.h
new file mode 100644
index 000000000000..f25fec8ee2ca
--- /dev/null
+++ b/include/linux/if_wanpipe_common.h
@@ -0,0 +1,60 @@
1/*****************************************************************************
2* if_wanipe_common.h Sangoma Driver/Socket common area definitions.
3*
4* Author: Nenad Corbic <ncorbic@sangoma.com>
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* Jan 13, 2000 Nenad Corbic Initial version
14*****************************************************************************/
15
16
17#ifndef _WANPIPE_SOCK_DRIVER_COMMON_H
18#define _WANPIPE_SOCK_DRIVER_COMMON_H
19
20#include <linux/version.h>
21
22typedef struct {
23 struct net_device *slave;
24 atomic_t packet_sent;
25 atomic_t receive_block;
26 atomic_t command;
27 atomic_t disconnect;
28 atomic_t driver_busy;
29 long common_critical;
30 struct timer_list *tx_timer;
31 struct sock *sk; /* Wanpipe Sock bind's here */
32 int (*func)(struct sk_buff *skb, struct net_device *dev,
33 struct sock *sk);
34
35 struct work_struct wanpipe_work; /* deferred keventd work */
36 unsigned char rw_bind; /* Sock bind state */
37 unsigned char usedby;
38 unsigned char state;
39 unsigned char svc;
40 unsigned short lcn;
41 void *mbox;
42} wanpipe_common_t;
43
44
45enum {
46 WANSOCK_UNCONFIGURED, /* link/channel is not configured */
47 WANSOCK_DISCONNECTED, /* link/channel is disconnected */
48 WANSOCK_CONNECTING, /* connection is in progress */
49 WANSOCK_CONNECTED, /* link/channel is operational */
50 WANSOCK_LIMIT, /* for verification only */
51 WANSOCK_DUALPORT, /* for Dual Port cards */
52 WANSOCK_DISCONNECTING,
53 WANSOCK_BINDED,
54 WANSOCK_BIND_LISTEN,
55 WANSOCK_LISTEN
56};
57
58#endif
59
60
diff --git a/include/linux/igmp.h b/include/linux/igmp.h
new file mode 100644
index 000000000000..390e760a96d3
--- /dev/null
+++ b/include/linux/igmp.h
@@ -0,0 +1,219 @@
1/*
2 * Linux NET3: Internet Group Management Protocol [IGMP]
3 *
4 * Authors:
5 * Alan Cox <Alan.Cox@linux.org>
6 *
7 * Extended to talk the BSD extended IGMP protocol of mrouted 3.6
8 *
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#ifndef _LINUX_IGMP_H
17#define _LINUX_IGMP_H
18
19#include <asm/byteorder.h>
20
21/*
22 * IGMP protocol structures
23 */
24
25/*
26 * Header in on cable format
27 */
28
29struct igmphdr
30{
31 __u8 type;
32 __u8 code; /* For newer IGMP */
33 __u16 csum;
34 __u32 group;
35};
36
37/* V3 group record types [grec_type] */
38#define IGMPV3_MODE_IS_INCLUDE 1
39#define IGMPV3_MODE_IS_EXCLUDE 2
40#define IGMPV3_CHANGE_TO_INCLUDE 3
41#define IGMPV3_CHANGE_TO_EXCLUDE 4
42#define IGMPV3_ALLOW_NEW_SOURCES 5
43#define IGMPV3_BLOCK_OLD_SOURCES 6
44
45struct igmpv3_grec {
46 __u8 grec_type;
47 __u8 grec_auxwords;
48 __u16 grec_nsrcs;
49 __u32 grec_mca;
50 __u32 grec_src[0];
51};
52
53struct igmpv3_report {
54 __u8 type;
55 __u8 resv1;
56 __u16 csum;
57 __u16 resv2;
58 __u16 ngrec;
59 struct igmpv3_grec grec[0];
60};
61
62struct igmpv3_query {
63 __u8 type;
64 __u8 code;
65 __u16 csum;
66 __u32 group;
67#if defined(__LITTLE_ENDIAN_BITFIELD)
68 __u8 qrv:3,
69 suppress:1,
70 resv:4;
71#elif defined(__BIG_ENDIAN_BITFIELD)
72 __u8 resv:4,
73 suppress:1,
74 qrv:3;
75#else
76#error "Please fix <asm/byteorder.h>"
77#endif
78 __u8 qqic;
79 __u16 nsrcs;
80 __u32 srcs[0];
81};
82
83#define IGMP_HOST_MEMBERSHIP_QUERY 0x11 /* From RFC1112 */
84#define IGMP_HOST_MEMBERSHIP_REPORT 0x12 /* Ditto */
85#define IGMP_DVMRP 0x13 /* DVMRP routing */
86#define IGMP_PIM 0x14 /* PIM routing */
87#define IGMP_TRACE 0x15
88#define IGMPV2_HOST_MEMBERSHIP_REPORT 0x16 /* V2 version of 0x11 */
89#define IGMP_HOST_LEAVE_MESSAGE 0x17
90#define IGMPV3_HOST_MEMBERSHIP_REPORT 0x22 /* V3 version of 0x11 */
91
92#define IGMP_MTRACE_RESP 0x1e
93#define IGMP_MTRACE 0x1f
94
95
96/*
97 * Use the BSD names for these for compatibility
98 */
99
100#define IGMP_DELAYING_MEMBER 0x01
101#define IGMP_IDLE_MEMBER 0x02
102#define IGMP_LAZY_MEMBER 0x03
103#define IGMP_SLEEPING_MEMBER 0x04
104#define IGMP_AWAKENING_MEMBER 0x05
105
106#define IGMP_MINLEN 8
107
108#define IGMP_MAX_HOST_REPORT_DELAY 10 /* max delay for response to */
109 /* query (in seconds) */
110
111#define IGMP_TIMER_SCALE 10 /* denotes that the igmphdr->timer field */
112 /* specifies time in 10th of seconds */
113
114#define IGMP_AGE_THRESHOLD 400 /* If this host don't hear any IGMP V1 */
115 /* message in this period of time, */
116 /* revert to IGMP v2 router. */
117
118#define IGMP_ALL_HOSTS htonl(0xE0000001L)
119#define IGMP_ALL_ROUTER htonl(0xE0000002L)
120#define IGMPV3_ALL_MCR htonl(0xE0000016L)
121#define IGMP_LOCAL_GROUP htonl(0xE0000000L)
122#define IGMP_LOCAL_GROUP_MASK htonl(0xFFFFFF00L)
123
124/*
125 * struct for keeping the multicast list in
126 */
127
128#ifdef __KERNEL__
129#include <linux/skbuff.h>
130#include <linux/in.h>
131
132struct ip_sf_socklist
133{
134 unsigned int sl_max;
135 unsigned int sl_count;
136 __u32 sl_addr[0];
137};
138
139#define IP_SFLSIZE(count) (sizeof(struct ip_sf_socklist) + \
140 (count) * sizeof(__u32))
141
142#define IP_SFBLOCK 10 /* allocate this many at once */
143
144/* ip_mc_socklist is real list now. Speed is not argument;
145 this list never used in fast path code
146 */
147
148struct ip_mc_socklist
149{
150 struct ip_mc_socklist *next;
151 int count;
152 struct ip_mreqn multi;
153 unsigned int sfmode; /* MCAST_{INCLUDE,EXCLUDE} */
154 struct ip_sf_socklist *sflist;
155};
156
157struct ip_sf_list
158{
159 struct ip_sf_list *sf_next;
160 __u32 sf_inaddr;
161 unsigned long sf_count[2]; /* include/exclude counts */
162 unsigned char sf_gsresp; /* include in g & s response? */
163 unsigned char sf_oldin; /* change state */
164 unsigned char sf_crcount; /* retrans. left to send */
165};
166
167struct ip_mc_list
168{
169 struct in_device *interface;
170 unsigned long multiaddr;
171 struct ip_sf_list *sources;
172 struct ip_sf_list *tomb;
173 unsigned int sfmode;
174 unsigned long sfcount[2];
175 struct ip_mc_list *next;
176 struct timer_list timer;
177 int users;
178 atomic_t refcnt;
179 spinlock_t lock;
180 char tm_running;
181 char reporter;
182 char unsolicit_count;
183 char loaded;
184 unsigned char gsquery; /* check source marks? */
185 unsigned char crcount;
186};
187
188/* V3 exponential field decoding */
189#define IGMPV3_MASK(value, nb) ((nb)>=32 ? (value) : ((1<<(nb))-1) & (value))
190#define IGMPV3_EXP(thresh, nbmant, nbexp, value) \
191 ((value) < (thresh) ? (value) : \
192 ((IGMPV3_MASK(value, nbmant) | (1<<(nbmant+nbexp))) << \
193 (IGMPV3_MASK((value) >> (nbmant), nbexp) + (nbexp))))
194
195#define IGMPV3_QQIC(value) IGMPV3_EXP(0x80, 4, 3, value)
196#define IGMPV3_MRC(value) IGMPV3_EXP(0x80, 4, 3, value)
197
198extern int ip_check_mc(struct in_device *dev, u32 mc_addr, u32 src_addr, u16 proto);
199extern int igmp_rcv(struct sk_buff *);
200extern int ip_mc_join_group(struct sock *sk, struct ip_mreqn *imr);
201extern int ip_mc_leave_group(struct sock *sk, struct ip_mreqn *imr);
202extern void ip_mc_drop_socket(struct sock *sk);
203extern int ip_mc_source(int add, int omode, struct sock *sk,
204 struct ip_mreq_source *mreqs, int ifindex);
205extern int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf,int ifindex);
206extern int ip_mc_msfget(struct sock *sk, struct ip_msfilter *msf,
207 struct ip_msfilter __user *optval, int __user *optlen);
208extern int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf,
209 struct group_filter __user *optval, int __user *optlen);
210extern int ip_mc_sf_allow(struct sock *sk, u32 local, u32 rmt, int dif);
211extern void ip_mr_init(void);
212extern void ip_mc_init_dev(struct in_device *);
213extern void ip_mc_destroy_dev(struct in_device *);
214extern void ip_mc_up(struct in_device *);
215extern void ip_mc_down(struct in_device *);
216extern void ip_mc_dec_group(struct in_device *in_dev, u32 addr);
217extern void ip_mc_inc_group(struct in_device *in_dev, u32 addr);
218#endif
219#endif
diff --git a/include/linux/in.h b/include/linux/in.h
new file mode 100644
index 000000000000..fb88c66d748d
--- /dev/null
+++ b/include/linux/in.h
@@ -0,0 +1,253 @@
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Definitions of the Internet Protocol.
7 *
8 * Version: @(#)in.h 1.0.1 04/21/93
9 *
10 * Authors: Original taken from the GNU Project <netinet/in.h> file.
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version
16 * 2 of the License, or (at your option) any later version.
17 */
18#ifndef _LINUX_IN_H
19#define _LINUX_IN_H
20
21#include <linux/types.h>
22#include <linux/socket.h>
23
24/* Standard well-defined IP protocols. */
25enum {
26 IPPROTO_IP = 0, /* Dummy protocol for TCP */
27 IPPROTO_ICMP = 1, /* Internet Control Message Protocol */
28 IPPROTO_IGMP = 2, /* Internet Group Management Protocol */
29 IPPROTO_IPIP = 4, /* IPIP tunnels (older KA9Q tunnels use 94) */
30 IPPROTO_TCP = 6, /* Transmission Control Protocol */
31 IPPROTO_EGP = 8, /* Exterior Gateway Protocol */
32 IPPROTO_PUP = 12, /* PUP protocol */
33 IPPROTO_UDP = 17, /* User Datagram Protocol */
34 IPPROTO_IDP = 22, /* XNS IDP protocol */
35 IPPROTO_RSVP = 46, /* RSVP protocol */
36 IPPROTO_GRE = 47, /* Cisco GRE tunnels (rfc 1701,1702) */
37
38 IPPROTO_IPV6 = 41, /* IPv6-in-IPv4 tunnelling */
39
40 IPPROTO_ESP = 50, /* Encapsulation Security Payload protocol */
41 IPPROTO_AH = 51, /* Authentication Header protocol */
42 IPPROTO_PIM = 103, /* Protocol Independent Multicast */
43
44 IPPROTO_COMP = 108, /* Compression Header protocol */
45 IPPROTO_SCTP = 132, /* Stream Control Transport Protocol */
46
47 IPPROTO_RAW = 255, /* Raw IP packets */
48 IPPROTO_MAX
49};
50
51
52/* Internet address. */
53struct in_addr {
54 __u32 s_addr;
55};
56
57#define IP_TOS 1
58#define IP_TTL 2
59#define IP_HDRINCL 3
60#define IP_OPTIONS 4
61#define IP_ROUTER_ALERT 5
62#define IP_RECVOPTS 6
63#define IP_RETOPTS 7
64#define IP_PKTINFO 8
65#define IP_PKTOPTIONS 9
66#define IP_MTU_DISCOVER 10
67#define IP_RECVERR 11
68#define IP_RECVTTL 12
69#define IP_RECVTOS 13
70#define IP_MTU 14
71#define IP_FREEBIND 15
72#define IP_IPSEC_POLICY 16
73#define IP_XFRM_POLICY 17
74
75/* BSD compatibility */
76#define IP_RECVRETOPTS IP_RETOPTS
77
78/* IP_MTU_DISCOVER values */
79#define IP_PMTUDISC_DONT 0 /* Never send DF frames */
80#define IP_PMTUDISC_WANT 1 /* Use per route hints */
81#define IP_PMTUDISC_DO 2 /* Always DF */
82
83#define IP_MULTICAST_IF 32
84#define IP_MULTICAST_TTL 33
85#define IP_MULTICAST_LOOP 34
86#define IP_ADD_MEMBERSHIP 35
87#define IP_DROP_MEMBERSHIP 36
88#define IP_UNBLOCK_SOURCE 37
89#define IP_BLOCK_SOURCE 38
90#define IP_ADD_SOURCE_MEMBERSHIP 39
91#define IP_DROP_SOURCE_MEMBERSHIP 40
92#define IP_MSFILTER 41
93#define MCAST_JOIN_GROUP 42
94#define MCAST_BLOCK_SOURCE 43
95#define MCAST_UNBLOCK_SOURCE 44
96#define MCAST_LEAVE_GROUP 45
97#define MCAST_JOIN_SOURCE_GROUP 46
98#define MCAST_LEAVE_SOURCE_GROUP 47
99#define MCAST_MSFILTER 48
100
101#define MCAST_EXCLUDE 0
102#define MCAST_INCLUDE 1
103
104/* These need to appear somewhere around here */
105#define IP_DEFAULT_MULTICAST_TTL 1
106#define IP_DEFAULT_MULTICAST_LOOP 1
107
108/* Request struct for multicast socket ops */
109
110struct ip_mreq
111{
112 struct in_addr imr_multiaddr; /* IP multicast address of group */
113 struct in_addr imr_interface; /* local IP address of interface */
114};
115
116struct ip_mreqn
117{
118 struct in_addr imr_multiaddr; /* IP multicast address of group */
119 struct in_addr imr_address; /* local IP address of interface */
120 int imr_ifindex; /* Interface index */
121};
122
123struct ip_mreq_source {
124 __u32 imr_multiaddr;
125 __u32 imr_interface;
126 __u32 imr_sourceaddr;
127};
128
129struct ip_msfilter {
130 __u32 imsf_multiaddr;
131 __u32 imsf_interface;
132 __u32 imsf_fmode;
133 __u32 imsf_numsrc;
134 __u32 imsf_slist[1];
135};
136
137#define IP_MSFILTER_SIZE(numsrc) \
138 (sizeof(struct ip_msfilter) - sizeof(__u32) \
139 + (numsrc) * sizeof(__u32))
140
141struct group_req
142{
143 __u32 gr_interface; /* interface index */
144 struct __kernel_sockaddr_storage gr_group; /* group address */
145};
146
147struct group_source_req
148{
149 __u32 gsr_interface; /* interface index */
150 struct __kernel_sockaddr_storage gsr_group; /* group address */
151 struct __kernel_sockaddr_storage gsr_source; /* source address */
152};
153
154struct group_filter
155{
156 __u32 gf_interface; /* interface index */
157 struct __kernel_sockaddr_storage gf_group; /* multicast address */
158 __u32 gf_fmode; /* filter mode */
159 __u32 gf_numsrc; /* number of sources */
160 struct __kernel_sockaddr_storage gf_slist[1]; /* interface index */
161};
162
163#define GROUP_FILTER_SIZE(numsrc) \
164 (sizeof(struct group_filter) - sizeof(struct __kernel_sockaddr_storage) \
165 + (numsrc) * sizeof(struct __kernel_sockaddr_storage))
166
167struct in_pktinfo
168{
169 int ipi_ifindex;
170 struct in_addr ipi_spec_dst;
171 struct in_addr ipi_addr;
172};
173
174/* Structure describing an Internet (IP) socket address. */
175#define __SOCK_SIZE__ 16 /* sizeof(struct sockaddr) */
176struct sockaddr_in {
177 sa_family_t sin_family; /* Address family */
178 unsigned short int sin_port; /* Port number */
179 struct in_addr sin_addr; /* Internet address */
180
181 /* Pad to size of `struct sockaddr'. */
182 unsigned char __pad[__SOCK_SIZE__ - sizeof(short int) -
183 sizeof(unsigned short int) - sizeof(struct in_addr)];
184};
185#define sin_zero __pad /* for BSD UNIX comp. -FvK */
186
187
188/*
189 * Definitions of the bits in an Internet address integer.
190 * On subnets, host and network parts are found according
191 * to the subnet mask, not these masks.
192 */
193#define IN_CLASSA(a) ((((long int) (a)) & 0x80000000) == 0)
194#define IN_CLASSA_NET 0xff000000
195#define IN_CLASSA_NSHIFT 24
196#define IN_CLASSA_HOST (0xffffffff & ~IN_CLASSA_NET)
197#define IN_CLASSA_MAX 128
198
199#define IN_CLASSB(a) ((((long int) (a)) & 0xc0000000) == 0x80000000)
200#define IN_CLASSB_NET 0xffff0000
201#define IN_CLASSB_NSHIFT 16
202#define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET)
203#define IN_CLASSB_MAX 65536
204
205#define IN_CLASSC(a) ((((long int) (a)) & 0xe0000000) == 0xc0000000)
206#define IN_CLASSC_NET 0xffffff00
207#define IN_CLASSC_NSHIFT 8
208#define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET)
209
210#define IN_CLASSD(a) ((((long int) (a)) & 0xf0000000) == 0xe0000000)
211#define IN_MULTICAST(a) IN_CLASSD(a)
212#define IN_MULTICAST_NET 0xF0000000
213
214#define IN_EXPERIMENTAL(a) ((((long int) (a)) & 0xf0000000) == 0xf0000000)
215#define IN_BADCLASS(a) IN_EXPERIMENTAL((a))
216
217/* Address to accept any incoming messages. */
218#define INADDR_ANY ((unsigned long int) 0x00000000)
219
220/* Address to send to all hosts. */
221#define INADDR_BROADCAST ((unsigned long int) 0xffffffff)
222
223/* Address indicating an error return. */
224#define INADDR_NONE ((unsigned long int) 0xffffffff)
225
226/* Network number for local host loopback. */
227#define IN_LOOPBACKNET 127
228
229/* Address to loopback in software to local host. */
230#define INADDR_LOOPBACK 0x7f000001 /* 127.0.0.1 */
231#define IN_LOOPBACK(a) ((((long int) (a)) & 0xff000000) == 0x7f000000)
232
233/* Defines for Multicast INADDR */
234#define INADDR_UNSPEC_GROUP 0xe0000000U /* 224.0.0.0 */
235#define INADDR_ALLHOSTS_GROUP 0xe0000001U /* 224.0.0.1 */
236#define INADDR_ALLRTRS_GROUP 0xe0000002U /* 224.0.0.2 */
237#define INADDR_MAX_LOCAL_GROUP 0xe00000ffU /* 224.0.0.255 */
238
239
240/* <asm/byteorder.h> contains the htonl type stuff.. */
241#include <asm/byteorder.h>
242
243#ifdef __KERNEL__
244/* Some random defines to make it easier in the kernel.. */
245#define LOOPBACK(x) (((x) & htonl(0xff000000)) == htonl(0x7f000000))
246#define MULTICAST(x) (((x) & htonl(0xf0000000)) == htonl(0xe0000000))
247#define BADCLASS(x) (((x) & htonl(0xf0000000)) == htonl(0xf0000000))
248#define ZERONET(x) (((x) & htonl(0xff000000)) == htonl(0x00000000))
249#define LOCAL_MCAST(x) (((x) & htonl(0xFFFFFF00)) == htonl(0xE0000000))
250
251#endif
252
253#endif /* _LINUX_IN_H */
diff --git a/include/linux/in6.h b/include/linux/in6.h
new file mode 100644
index 000000000000..f8256c582845
--- /dev/null
+++ b/include/linux/in6.h
@@ -0,0 +1,201 @@
1/*
2 * Types and definitions for AF_INET6
3 * Linux INET6 implementation
4 *
5 * Authors:
6 * Pedro Roque <roque@di.fc.ul.pt>
7 *
8 * Sources:
9 * IPv6 Program Interfaces for BSD Systems
10 * <draft-ietf-ipngwg-bsd-api-05.txt>
11 *
12 * Advanced Sockets API for IPv6
13 * <draft-stevens-advanced-api-00.txt>
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version
18 * 2 of the License, or (at your option) any later version.
19 */
20
21#ifndef _LINUX_IN6_H
22#define _LINUX_IN6_H
23
24#include <linux/types.h>
25
26/*
27 * IPv6 address structure
28 */
29
30struct in6_addr
31{
32 union
33 {
34 __u8 u6_addr8[16];
35 __u16 u6_addr16[8];
36 __u32 u6_addr32[4];
37 } in6_u;
38#define s6_addr in6_u.u6_addr8
39#define s6_addr16 in6_u.u6_addr16
40#define s6_addr32 in6_u.u6_addr32
41};
42
43/* IPv6 Wildcard Address (::) and Loopback Address (::1) defined in RFC2553
44 * NOTE: Be aware the IN6ADDR_* constants and in6addr_* externals are defined
45 * in network byte order, not in host byte order as are the IPv4 equivalents
46 */
47#if 0
48extern const struct in6_addr in6addr_any;
49#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
50#endif
51extern const struct in6_addr in6addr_loopback;
52#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
53
54struct sockaddr_in6 {
55 unsigned short int sin6_family; /* AF_INET6 */
56 __u16 sin6_port; /* Transport layer port # */
57 __u32 sin6_flowinfo; /* IPv6 flow information */
58 struct in6_addr sin6_addr; /* IPv6 address */
59 __u32 sin6_scope_id; /* scope id (new in RFC2553) */
60};
61
62struct ipv6_mreq {
63 /* IPv6 multicast address of group */
64 struct in6_addr ipv6mr_multiaddr;
65
66 /* local IPv6 address of interface */
67 int ipv6mr_ifindex;
68};
69
70#define ipv6mr_acaddr ipv6mr_multiaddr
71
72struct in6_flowlabel_req
73{
74 struct in6_addr flr_dst;
75 __u32 flr_label;
76 __u8 flr_action;
77 __u8 flr_share;
78 __u16 flr_flags;
79 __u16 flr_expires;
80 __u16 flr_linger;
81 __u32 __flr_pad;
82 /* Options in format of IPV6_PKTOPTIONS */
83};
84
85#define IPV6_FL_A_GET 0
86#define IPV6_FL_A_PUT 1
87#define IPV6_FL_A_RENEW 2
88
89#define IPV6_FL_F_CREATE 1
90#define IPV6_FL_F_EXCL 2
91
92#define IPV6_FL_S_NONE 0
93#define IPV6_FL_S_EXCL 1
94#define IPV6_FL_S_PROCESS 2
95#define IPV6_FL_S_USER 3
96#define IPV6_FL_S_ANY 255
97
98
99/*
100 * Bitmask constant declarations to help applications select out the
101 * flow label and priority fields.
102 *
103 * Note that this are in host byte order while the flowinfo field of
104 * sockaddr_in6 is in network byte order.
105 */
106
107#define IPV6_FLOWINFO_FLOWLABEL 0x000fffff
108#define IPV6_FLOWINFO_PRIORITY 0x0ff00000
109
110/* These defintions are obsolete */
111#define IPV6_PRIORITY_UNCHARACTERIZED 0x0000
112#define IPV6_PRIORITY_FILLER 0x0100
113#define IPV6_PRIORITY_UNATTENDED 0x0200
114#define IPV6_PRIORITY_RESERVED1 0x0300
115#define IPV6_PRIORITY_BULK 0x0400
116#define IPV6_PRIORITY_RESERVED2 0x0500
117#define IPV6_PRIORITY_INTERACTIVE 0x0600
118#define IPV6_PRIORITY_CONTROL 0x0700
119#define IPV6_PRIORITY_8 0x0800
120#define IPV6_PRIORITY_9 0x0900
121#define IPV6_PRIORITY_10 0x0a00
122#define IPV6_PRIORITY_11 0x0b00
123#define IPV6_PRIORITY_12 0x0c00
124#define IPV6_PRIORITY_13 0x0d00
125#define IPV6_PRIORITY_14 0x0e00
126#define IPV6_PRIORITY_15 0x0f00
127
128/*
129 * IPV6 extension headers
130 */
131#define IPPROTO_HOPOPTS 0 /* IPv6 hop-by-hop options */
132#define IPPROTO_ROUTING 43 /* IPv6 routing header */
133#define IPPROTO_FRAGMENT 44 /* IPv6 fragmentation header */
134#define IPPROTO_ICMPV6 58 /* ICMPv6 */
135#define IPPROTO_NONE 59 /* IPv6 no next header */
136#define IPPROTO_DSTOPTS 60 /* IPv6 destination options */
137
138/*
139 * IPv6 TLV options.
140 */
141#define IPV6_TLV_PAD0 0
142#define IPV6_TLV_PADN 1
143#define IPV6_TLV_ROUTERALERT 5
144#define IPV6_TLV_JUMBO 194
145
146/*
147 * IPV6 socket options
148 */
149
150#define IPV6_ADDRFORM 1
151#define IPV6_PKTINFO 2
152#define IPV6_HOPOPTS 3
153#define IPV6_DSTOPTS 4
154#define IPV6_RTHDR 5
155#define IPV6_PKTOPTIONS 6
156#define IPV6_CHECKSUM 7
157#define IPV6_HOPLIMIT 8
158#define IPV6_NEXTHOP 9
159#define IPV6_AUTHHDR 10
160#define IPV6_FLOWINFO 11
161
162#define IPV6_UNICAST_HOPS 16
163#define IPV6_MULTICAST_IF 17
164#define IPV6_MULTICAST_HOPS 18
165#define IPV6_MULTICAST_LOOP 19
166#define IPV6_ADD_MEMBERSHIP 20
167#define IPV6_DROP_MEMBERSHIP 21
168#define IPV6_ROUTER_ALERT 22
169#define IPV6_MTU_DISCOVER 23
170#define IPV6_MTU 24
171#define IPV6_RECVERR 25
172#define IPV6_V6ONLY 26
173#define IPV6_JOIN_ANYCAST 27
174#define IPV6_LEAVE_ANYCAST 28
175
176/* IPV6_MTU_DISCOVER values */
177#define IPV6_PMTUDISC_DONT 0
178#define IPV6_PMTUDISC_WANT 1
179#define IPV6_PMTUDISC_DO 2
180
181/* Flowlabel */
182#define IPV6_FLOWLABEL_MGR 32
183#define IPV6_FLOWINFO_SEND 33
184
185#define IPV6_IPSEC_POLICY 34
186#define IPV6_XFRM_POLICY 35
187
188/*
189 * Multicast:
190 * Following socket options are shared between IPv4 and IPv6.
191 *
192 * MCAST_JOIN_GROUP 42
193 * MCAST_BLOCK_SOURCE 43
194 * MCAST_UNBLOCK_SOURCE 44
195 * MCAST_LEAVE_GROUP 45
196 * MCAST_JOIN_SOURCE_GROUP 46
197 * MCAST_LEAVE_SOURCE_GROUP 47
198 * MCAST_MSFILTER 48
199 */
200
201#endif
diff --git a/include/linux/in_route.h b/include/linux/in_route.h
new file mode 100644
index 000000000000..61f25c30a2a0
--- /dev/null
+++ b/include/linux/in_route.h
@@ -0,0 +1,32 @@
1#ifndef _LINUX_IN_ROUTE_H
2#define _LINUX_IN_ROUTE_H
3
4/* IPv4 routing cache flags */
5
6#define RTCF_DEAD RTNH_F_DEAD
7#define RTCF_ONLINK RTNH_F_ONLINK
8
9/* Obsolete flag. About to be deleted */
10#define RTCF_NOPMTUDISC RTM_F_NOPMTUDISC
11
12#define RTCF_NOTIFY 0x00010000
13#define RTCF_DIRECTDST 0x00020000
14#define RTCF_REDIRECTED 0x00040000
15#define RTCF_TPROXY 0x00080000
16
17#define RTCF_FAST 0x00200000
18#define RTCF_MASQ 0x00400000
19#define RTCF_SNAT 0x00800000
20#define RTCF_DOREDIRECT 0x01000000
21#define RTCF_DIRECTSRC 0x04000000
22#define RTCF_DNAT 0x08000000
23#define RTCF_BROADCAST 0x10000000
24#define RTCF_MULTICAST 0x20000000
25#define RTCF_REJECT 0x40000000
26#define RTCF_LOCAL 0x80000000
27
28#define RTCF_NAT (RTCF_DNAT|RTCF_SNAT)
29
30#define RT_TOS(tos) ((tos)&IPTOS_TOS_MASK)
31
32#endif /* _LINUX_IN_ROUTE_H */
diff --git a/include/linux/inet.h b/include/linux/inet.h
new file mode 100644
index 000000000000..3b5e9fdff872
--- /dev/null
+++ b/include/linux/inet.h
@@ -0,0 +1,50 @@
1/*
2 * Swansea University Computer Society NET3
3 *
4 * This work is derived from NET2Debugged, which is in turn derived
5 * from NET2D which was written by:
6 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
7 *
8 * This work was derived from Ross Biro's inspirational work
9 * for the LINUX operating system. His version numbers were:
10 *
11 * $Id: Space.c,v 0.8.4.5 1992/12/12 19:25:04 bir7 Exp $
12 * $Id: arp.c,v 0.8.4.6 1993/01/28 22:30:00 bir7 Exp $
13 * $Id: arp.h,v 0.8.4.6 1993/01/28 22:30:00 bir7 Exp $
14 * $Id: dev.c,v 0.8.4.13 1993/01/23 18:00:11 bir7 Exp $
15 * $Id: dev.h,v 0.8.4.7 1993/01/23 18:00:11 bir7 Exp $
16 * $Id: eth.c,v 0.8.4.4 1993/01/22 23:21:38 bir7 Exp $
17 * $Id: eth.h,v 0.8.4.1 1992/11/10 00:17:18 bir7 Exp $
18 * $Id: icmp.c,v 0.8.4.9 1993/01/23 18:00:11 bir7 Exp $
19 * $Id: icmp.h,v 0.8.4.2 1992/11/15 14:55:30 bir7 Exp $
20 * $Id: ip.c,v 0.8.4.8 1992/12/12 19:25:04 bir7 Exp $
21 * $Id: ip.h,v 0.8.4.2 1993/01/23 18:00:11 bir7 Exp $
22 * $Id: loopback.c,v 0.8.4.8 1993/01/23 18:00:11 bir7 Exp $
23 * $Id: packet.c,v 0.8.4.7 1993/01/26 22:04:00 bir7 Exp $
24 * $Id: protocols.c,v 0.8.4.3 1992/11/15 14:55:30 bir7 Exp $
25 * $Id: raw.c,v 0.8.4.12 1993/01/26 22:04:00 bir7 Exp $
26 * $Id: sock.c,v 0.8.4.6 1993/01/28 22:30:00 bir7 Exp $
27 * $Id: sock.h,v 0.8.4.7 1993/01/26 22:04:00 bir7 Exp $
28 * $Id: tcp.c,v 0.8.4.16 1993/01/26 22:04:00 bir7 Exp $
29 * $Id: tcp.h,v 0.8.4.7 1993/01/22 22:58:08 bir7 Exp $
30 * $Id: timer.c,v 0.8.4.8 1993/01/23 18:00:11 bir7 Exp $
31 * $Id: timer.h,v 0.8.4.2 1993/01/23 18:00:11 bir7 Exp $
32 * $Id: udp.c,v 0.8.4.12 1993/01/26 22:04:00 bir7 Exp $
33 * $Id: udp.h,v 0.8.4.1 1992/11/10 00:17:18 bir7 Exp $
34 * $Id: we.c,v 0.8.4.10 1993/01/23 18:00:11 bir7 Exp $
35 * $Id: wereg.h,v 0.8.4.1 1992/11/10 00:17:18 bir7 Exp $
36 *
37 * This program is free software; you can redistribute it and/or
38 * modify it under the terms of the GNU General Public License
39 * as published by the Free Software Foundation; either version
40 * 2 of the License, or (at your option) any later version.
41 */
42#ifndef _LINUX_INET_H
43#define _LINUX_INET_H
44
45#ifdef __KERNEL__
46#include <linux/types.h>
47
48extern __u32 in_aton(const char *str);
49#endif
50#endif /* _LINUX_INET_H */
diff --git a/include/linux/inetdevice.h b/include/linux/inetdevice.h
new file mode 100644
index 000000000000..6fafb27877a7
--- /dev/null
+++ b/include/linux/inetdevice.h
@@ -0,0 +1,190 @@
1#ifndef _LINUX_INETDEVICE_H
2#define _LINUX_INETDEVICE_H
3
4#ifdef __KERNEL__
5
6#include <linux/if.h>
7#include <linux/netdevice.h>
8#include <linux/rcupdate.h>
9#include <linux/timer.h>
10
11struct ipv4_devconf
12{
13 int accept_redirects;
14 int send_redirects;
15 int secure_redirects;
16 int shared_media;
17 int accept_source_route;
18 int rp_filter;
19 int proxy_arp;
20 int bootp_relay;
21 int log_martians;
22 int forwarding;
23 int mc_forwarding;
24 int tag;
25 int arp_filter;
26 int arp_announce;
27 int arp_ignore;
28 int medium_id;
29 int no_xfrm;
30 int no_policy;
31 int force_igmp_version;
32 void *sysctl;
33};
34
35extern struct ipv4_devconf ipv4_devconf;
36
37struct in_device
38{
39 struct net_device *dev;
40 atomic_t refcnt;
41 int dead;
42 struct in_ifaddr *ifa_list; /* IP ifaddr chain */
43 rwlock_t mc_list_lock;
44 struct ip_mc_list *mc_list; /* IP multicast filter chain */
45 spinlock_t mc_tomb_lock;
46 struct ip_mc_list *mc_tomb;
47 unsigned long mr_v1_seen;
48 unsigned long mr_v2_seen;
49 unsigned long mr_maxdelay;
50 unsigned char mr_qrv;
51 unsigned char mr_gq_running;
52 unsigned char mr_ifc_count;
53 struct timer_list mr_gq_timer; /* general query timer */
54 struct timer_list mr_ifc_timer; /* interface change timer */
55
56 struct neigh_parms *arp_parms;
57 struct ipv4_devconf cnf;
58 struct rcu_head rcu_head;
59};
60
61#define IN_DEV_FORWARD(in_dev) ((in_dev)->cnf.forwarding)
62#define IN_DEV_MFORWARD(in_dev) (ipv4_devconf.mc_forwarding && (in_dev)->cnf.mc_forwarding)
63#define IN_DEV_RPFILTER(in_dev) (ipv4_devconf.rp_filter && (in_dev)->cnf.rp_filter)
64#define IN_DEV_SOURCE_ROUTE(in_dev) (ipv4_devconf.accept_source_route && (in_dev)->cnf.accept_source_route)
65#define IN_DEV_BOOTP_RELAY(in_dev) (ipv4_devconf.bootp_relay && (in_dev)->cnf.bootp_relay)
66
67#define IN_DEV_LOG_MARTIANS(in_dev) (ipv4_devconf.log_martians || (in_dev)->cnf.log_martians)
68#define IN_DEV_PROXY_ARP(in_dev) (ipv4_devconf.proxy_arp || (in_dev)->cnf.proxy_arp)
69#define IN_DEV_SHARED_MEDIA(in_dev) (ipv4_devconf.shared_media || (in_dev)->cnf.shared_media)
70#define IN_DEV_TX_REDIRECTS(in_dev) (ipv4_devconf.send_redirects || (in_dev)->cnf.send_redirects)
71#define IN_DEV_SEC_REDIRECTS(in_dev) (ipv4_devconf.secure_redirects || (in_dev)->cnf.secure_redirects)
72#define IN_DEV_IDTAG(in_dev) ((in_dev)->cnf.tag)
73#define IN_DEV_MEDIUM_ID(in_dev) ((in_dev)->cnf.medium_id)
74
75#define IN_DEV_RX_REDIRECTS(in_dev) \
76 ((IN_DEV_FORWARD(in_dev) && \
77 (ipv4_devconf.accept_redirects && (in_dev)->cnf.accept_redirects)) \
78 || (!IN_DEV_FORWARD(in_dev) && \
79 (ipv4_devconf.accept_redirects || (in_dev)->cnf.accept_redirects)))
80
81#define IN_DEV_ARPFILTER(in_dev) (ipv4_devconf.arp_filter || (in_dev)->cnf.arp_filter)
82#define IN_DEV_ARP_ANNOUNCE(in_dev) (max(ipv4_devconf.arp_announce, (in_dev)->cnf.arp_announce))
83#define IN_DEV_ARP_IGNORE(in_dev) (max(ipv4_devconf.arp_ignore, (in_dev)->cnf.arp_ignore))
84
85struct in_ifaddr
86{
87 struct in_ifaddr *ifa_next;
88 struct in_device *ifa_dev;
89 struct rcu_head rcu_head;
90 u32 ifa_local;
91 u32 ifa_address;
92 u32 ifa_mask;
93 u32 ifa_broadcast;
94 u32 ifa_anycast;
95 unsigned char ifa_scope;
96 unsigned char ifa_flags;
97 unsigned char ifa_prefixlen;
98 char ifa_label[IFNAMSIZ];
99};
100
101extern int register_inetaddr_notifier(struct notifier_block *nb);
102extern int unregister_inetaddr_notifier(struct notifier_block *nb);
103
104extern struct net_device *ip_dev_find(u32 addr);
105extern int inet_addr_onlink(struct in_device *in_dev, u32 a, u32 b);
106extern int devinet_ioctl(unsigned int cmd, void __user *);
107extern void devinet_init(void);
108extern struct in_device *inetdev_init(struct net_device *dev);
109extern struct in_device *inetdev_by_index(int);
110extern u32 inet_select_addr(const struct net_device *dev, u32 dst, int scope);
111extern u32 inet_confirm_addr(const struct net_device *dev, u32 dst, u32 local, int scope);
112extern struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, u32 prefix, u32 mask);
113extern void inet_forward_change(void);
114
115static __inline__ int inet_ifa_match(u32 addr, struct in_ifaddr *ifa)
116{
117 return !((addr^ifa->ifa_address)&ifa->ifa_mask);
118}
119
120/*
121 * Check if a mask is acceptable.
122 */
123
124static __inline__ int bad_mask(u32 mask, u32 addr)
125{
126 if (addr & (mask = ~mask))
127 return 1;
128 mask = ntohl(mask);
129 if (mask & (mask+1))
130 return 1;
131 return 0;
132}
133
134#define for_primary_ifa(in_dev) { struct in_ifaddr *ifa; \
135 for (ifa = (in_dev)->ifa_list; ifa && !(ifa->ifa_flags&IFA_F_SECONDARY); ifa = ifa->ifa_next)
136
137#define for_ifa(in_dev) { struct in_ifaddr *ifa; \
138 for (ifa = (in_dev)->ifa_list; ifa; ifa = ifa->ifa_next)
139
140
141#define endfor_ifa(in_dev) }
142
143static __inline__ struct in_device *
144in_dev_get(const struct net_device *dev)
145{
146 struct in_device *in_dev;
147
148 rcu_read_lock();
149 in_dev = dev->ip_ptr;
150 if (in_dev)
151 atomic_inc(&in_dev->refcnt);
152 rcu_read_unlock();
153 return in_dev;
154}
155
156static __inline__ struct in_device *
157__in_dev_get(const struct net_device *dev)
158{
159 return (struct in_device*)dev->ip_ptr;
160}
161
162extern void in_dev_finish_destroy(struct in_device *idev);
163
164static inline void in_dev_put(struct in_device *idev)
165{
166 if (atomic_dec_and_test(&idev->refcnt))
167 in_dev_finish_destroy(idev);
168}
169
170#define __in_dev_put(idev) atomic_dec(&(idev)->refcnt)
171#define in_dev_hold(idev) atomic_inc(&(idev)->refcnt)
172
173#endif /* __KERNEL__ */
174
175static __inline__ __u32 inet_make_mask(int logmask)
176{
177 if (logmask)
178 return htonl(~((1<<(32-logmask))-1));
179 return 0;
180}
181
182static __inline__ int inet_mask_len(__u32 mask)
183{
184 if (!(mask = ntohl(mask)))
185 return 0;
186 return 32 - ffz(~mask);
187}
188
189
190#endif /* _LINUX_INETDEVICE_H */
diff --git a/include/linux/init.h b/include/linux/init.h
new file mode 100644
index 000000000000..05c83e0521ca
--- /dev/null
+++ b/include/linux/init.h
@@ -0,0 +1,250 @@
1#ifndef _LINUX_INIT_H
2#define _LINUX_INIT_H
3
4#include <linux/config.h>
5#include <linux/compiler.h>
6
7/* These macros are used to mark some functions or
8 * initialized data (doesn't apply to uninitialized data)
9 * as `initialization' functions. The kernel can take this
10 * as hint that the function is used only during the initialization
11 * phase and free up used memory resources after
12 *
13 * Usage:
14 * For functions:
15 *
16 * You should add __init immediately before the function name, like:
17 *
18 * static void __init initme(int x, int y)
19 * {
20 * extern int z; z = x * y;
21 * }
22 *
23 * If the function has a prototype somewhere, you can also add
24 * __init between closing brace of the prototype and semicolon:
25 *
26 * extern int initialize_foobar_device(int, int, int) __init;
27 *
28 * For initialized data:
29 * You should insert __initdata between the variable name and equal
30 * sign followed by value, e.g.:
31 *
32 * static int init_variable __initdata = 0;
33 * static char linux_logo[] __initdata = { 0x32, 0x36, ... };
34 *
35 * Don't forget to initialize data not at file scope, i.e. within a function,
36 * as gcc otherwise puts the data into the bss section and not into the init
37 * section.
38 *
39 * Also note, that this data cannot be "const".
40 */
41
42/* These are for everybody (although not all archs will actually
43 discard it in modules) */
44#define __init __attribute__ ((__section__ (".init.text")))
45#define __initdata __attribute__ ((__section__ (".init.data")))
46#define __exitdata __attribute__ ((__section__(".exit.data")))
47#define __exit_call __attribute_used__ __attribute__ ((__section__ (".exitcall.exit")))
48
49#ifdef MODULE
50#define __exit __attribute__ ((__section__(".exit.text")))
51#else
52#define __exit __attribute_used__ __attribute__ ((__section__(".exit.text")))
53#endif
54
55/* For assembly routines */
56#define __INIT .section ".init.text","ax"
57#define __FINIT .previous
58#define __INITDATA .section ".init.data","aw"
59
60#ifndef __ASSEMBLY__
61/*
62 * Used for initialization calls..
63 */
64typedef int (*initcall_t)(void);
65typedef void (*exitcall_t)(void);
66
67extern initcall_t __con_initcall_start[], __con_initcall_end[];
68extern initcall_t __security_initcall_start[], __security_initcall_end[];
69
70/* Defined in init/main.c */
71extern char saved_command_line[];
72#endif
73
74#ifndef MODULE
75
76#ifndef __ASSEMBLY__
77
78/* initcalls are now grouped by functionality into separate
79 * subsections. Ordering inside the subsections is determined
80 * by link order.
81 * For backwards compatibility, initcall() puts the call in
82 * the device init subsection.
83 */
84
85#define __define_initcall(level,fn) \
86 static initcall_t __initcall_##fn __attribute_used__ \
87 __attribute__((__section__(".initcall" level ".init"))) = fn
88
89#define core_initcall(fn) __define_initcall("1",fn)
90#define postcore_initcall(fn) __define_initcall("2",fn)
91#define arch_initcall(fn) __define_initcall("3",fn)
92#define subsys_initcall(fn) __define_initcall("4",fn)
93#define fs_initcall(fn) __define_initcall("5",fn)
94#define device_initcall(fn) __define_initcall("6",fn)
95#define late_initcall(fn) __define_initcall("7",fn)
96
97#define __initcall(fn) device_initcall(fn)
98
99#define __exitcall(fn) \
100 static exitcall_t __exitcall_##fn __exit_call = fn
101
102#define console_initcall(fn) \
103 static initcall_t __initcall_##fn \
104 __attribute_used__ __attribute__((__section__(".con_initcall.init")))=fn
105
106#define security_initcall(fn) \
107 static initcall_t __initcall_##fn \
108 __attribute_used__ __attribute__((__section__(".security_initcall.init"))) = fn
109
110struct obs_kernel_param {
111 const char *str;
112 int (*setup_func)(char *);
113 int early;
114};
115
116/*
117 * Only for really core code. See moduleparam.h for the normal way.
118 *
119 * Force the alignment so the compiler doesn't space elements of the
120 * obs_kernel_param "array" too far apart in .init.setup.
121 */
122#define __setup_param(str, unique_id, fn, early) \
123 static char __setup_str_##unique_id[] __initdata = str; \
124 static struct obs_kernel_param __setup_##unique_id \
125 __attribute_used__ \
126 __attribute__((__section__(".init.setup"))) \
127 __attribute__((aligned((sizeof(long))))) \
128 = { __setup_str_##unique_id, fn, early }
129
130#define __setup_null_param(str, unique_id) \
131 __setup_param(str, unique_id, NULL, 0)
132
133#define __setup(str, fn) \
134 __setup_param(str, fn, fn, 0)
135
136#define __obsolete_setup(str) \
137 __setup_null_param(str, __LINE__)
138
139/* NOTE: fn is as per module_param, not __setup! Emits warning if fn
140 * returns non-zero. */
141#define early_param(str, fn) \
142 __setup_param(str, fn, fn, 1)
143
144/* Relies on saved_command_line being set */
145void __init parse_early_param(void);
146#endif /* __ASSEMBLY__ */
147
148/**
149 * module_init() - driver initialization entry point
150 * @x: function to be run at kernel boot time or module insertion
151 *
152 * module_init() will either be called during do_initcalls (if
153 * builtin) or at module insertion time (if a module). There can only
154 * be one per module.
155 */
156#define module_init(x) __initcall(x);
157
158/**
159 * module_exit() - driver exit entry point
160 * @x: function to be run when driver is removed
161 *
162 * module_exit() will wrap the driver clean-up code
163 * with cleanup_module() when used with rmmod when
164 * the driver is a module. If the driver is statically
165 * compiled into the kernel, module_exit() has no effect.
166 * There can only be one per module.
167 */
168#define module_exit(x) __exitcall(x);
169
170#else /* MODULE */
171
172/* Don't use these in modules, but some people do... */
173#define core_initcall(fn) module_init(fn)
174#define postcore_initcall(fn) module_init(fn)
175#define arch_initcall(fn) module_init(fn)
176#define subsys_initcall(fn) module_init(fn)
177#define fs_initcall(fn) module_init(fn)
178#define device_initcall(fn) module_init(fn)
179#define late_initcall(fn) module_init(fn)
180
181#define security_initcall(fn) module_init(fn)
182
183/* These macros create a dummy inline: gcc 2.9x does not count alias
184 as usage, hence the `unused function' warning when __init functions
185 are declared static. We use the dummy __*_module_inline functions
186 both to kill the warning and check the type of the init/cleanup
187 function. */
188
189/* Each module must use one module_init(), or one no_module_init */
190#define module_init(initfn) \
191 static inline initcall_t __inittest(void) \
192 { return initfn; } \
193 int init_module(void) __attribute__((alias(#initfn)));
194
195/* This is only required if you want to be unloadable. */
196#define module_exit(exitfn) \
197 static inline exitcall_t __exittest(void) \
198 { return exitfn; } \
199 void cleanup_module(void) __attribute__((alias(#exitfn)));
200
201#define __setup_param(str, unique_id, fn) /* nothing */
202#define __setup_null_param(str, unique_id) /* nothing */
203#define __setup(str, func) /* nothing */
204#define __obsolete_setup(str) /* nothing */
205#endif
206
207/* Data marked not to be saved by software_suspend() */
208#define __nosavedata __attribute__ ((__section__ (".data.nosave")))
209
210/* This means "can be init if no module support, otherwise module load
211 may call it." */
212#ifdef CONFIG_MODULES
213#define __init_or_module
214#define __initdata_or_module
215#else
216#define __init_or_module __init
217#define __initdata_or_module __initdata
218#endif /*CONFIG_MODULES*/
219
220#ifdef CONFIG_HOTPLUG
221#define __devinit
222#define __devinitdata
223#define __devexit
224#define __devexitdata
225#else
226#define __devinit __init
227#define __devinitdata __initdata
228#define __devexit __exit
229#define __devexitdata __exitdata
230#endif
231
232/* Functions marked as __devexit may be discarded at kernel link time, depending
233 on config options. Newer versions of binutils detect references from
234 retained sections to discarded sections and flag an error. Pointers to
235 __devexit functions must use __devexit_p(function_name), the wrapper will
236 insert either the function_name or NULL, depending on the config options.
237 */
238#if defined(MODULE) || defined(CONFIG_HOTPLUG)
239#define __devexit_p(x) x
240#else
241#define __devexit_p(x) NULL
242#endif
243
244#ifdef MODULE
245#define __exit_p(x) x
246#else
247#define __exit_p(x) NULL
248#endif
249
250#endif /* _LINUX_INIT_H */
diff --git a/include/linux/init_task.h b/include/linux/init_task.h
new file mode 100644
index 000000000000..a6a8c1a38d5e
--- /dev/null
+++ b/include/linux/init_task.h
@@ -0,0 +1,125 @@
1#ifndef _LINUX__INIT_TASK_H
2#define _LINUX__INIT_TASK_H
3
4#include <linux/file.h>
5
6#define INIT_FILES \
7{ \
8 .count = ATOMIC_INIT(1), \
9 .file_lock = SPIN_LOCK_UNLOCKED, \
10 .max_fds = NR_OPEN_DEFAULT, \
11 .max_fdset = __FD_SETSIZE, \
12 .next_fd = 0, \
13 .fd = &init_files.fd_array[0], \
14 .close_on_exec = &init_files.close_on_exec_init, \
15 .open_fds = &init_files.open_fds_init, \
16 .close_on_exec_init = { { 0, } }, \
17 .open_fds_init = { { 0, } }, \
18 .fd_array = { NULL, } \
19}
20
21#define INIT_KIOCTX(name, which_mm) \
22{ \
23 .users = ATOMIC_INIT(1), \
24 .dead = 0, \
25 .mm = &which_mm, \
26 .user_id = 0, \
27 .next = NULL, \
28 .wait = __WAIT_QUEUE_HEAD_INITIALIZER(name.wait), \
29 .ctx_lock = SPIN_LOCK_UNLOCKED, \
30 .reqs_active = 0U, \
31 .max_reqs = ~0U, \
32}
33
34#define INIT_MM(name) \
35{ \
36 .mm_rb = RB_ROOT, \
37 .pgd = swapper_pg_dir, \
38 .mm_users = ATOMIC_INIT(2), \
39 .mm_count = ATOMIC_INIT(1), \
40 .mmap_sem = __RWSEM_INITIALIZER(name.mmap_sem), \
41 .page_table_lock = SPIN_LOCK_UNLOCKED, \
42 .mmlist = LIST_HEAD_INIT(name.mmlist), \
43 .cpu_vm_mask = CPU_MASK_ALL, \
44 .default_kioctx = INIT_KIOCTX(name.default_kioctx, name), \
45}
46
47#define INIT_SIGNALS(sig) { \
48 .count = ATOMIC_INIT(1), \
49 .wait_chldexit = __WAIT_QUEUE_HEAD_INITIALIZER(sig.wait_chldexit),\
50 .shared_pending = { \
51 .list = LIST_HEAD_INIT(sig.shared_pending.list), \
52 .signal = {{0}}}, \
53 .posix_timers = LIST_HEAD_INIT(sig.posix_timers), \
54 .cpu_timers = INIT_CPU_TIMERS(sig.cpu_timers), \
55 .rlim = INIT_RLIMITS, \
56}
57
58#define INIT_SIGHAND(sighand) { \
59 .count = ATOMIC_INIT(1), \
60 .action = { { { .sa_handler = NULL, } }, }, \
61 .siglock = SPIN_LOCK_UNLOCKED, \
62}
63
64extern struct group_info init_groups;
65
66/*
67 * INIT_TASK is used to set up the first task table, touch at
68 * your own risk!. Base=0, limit=0x1fffff (=2MB)
69 */
70#define INIT_TASK(tsk) \
71{ \
72 .state = 0, \
73 .thread_info = &init_thread_info, \
74 .usage = ATOMIC_INIT(2), \
75 .flags = 0, \
76 .lock_depth = -1, \
77 .prio = MAX_PRIO-20, \
78 .static_prio = MAX_PRIO-20, \
79 .policy = SCHED_NORMAL, \
80 .cpus_allowed = CPU_MASK_ALL, \
81 .mm = NULL, \
82 .active_mm = &init_mm, \
83 .run_list = LIST_HEAD_INIT(tsk.run_list), \
84 .time_slice = HZ, \
85 .tasks = LIST_HEAD_INIT(tsk.tasks), \
86 .ptrace_children= LIST_HEAD_INIT(tsk.ptrace_children), \
87 .ptrace_list = LIST_HEAD_INIT(tsk.ptrace_list), \
88 .real_parent = &tsk, \
89 .parent = &tsk, \
90 .children = LIST_HEAD_INIT(tsk.children), \
91 .sibling = LIST_HEAD_INIT(tsk.sibling), \
92 .group_leader = &tsk, \
93 .group_info = &init_groups, \
94 .cap_effective = CAP_INIT_EFF_SET, \
95 .cap_inheritable = CAP_INIT_INH_SET, \
96 .cap_permitted = CAP_FULL_SET, \
97 .keep_capabilities = 0, \
98 .user = INIT_USER, \
99 .comm = "swapper", \
100 .thread = INIT_THREAD, \
101 .fs = &init_fs, \
102 .files = &init_files, \
103 .signal = &init_signals, \
104 .sighand = &init_sighand, \
105 .pending = { \
106 .list = LIST_HEAD_INIT(tsk.pending.list), \
107 .signal = {{0}}}, \
108 .blocked = {{0}}, \
109 .alloc_lock = SPIN_LOCK_UNLOCKED, \
110 .proc_lock = SPIN_LOCK_UNLOCKED, \
111 .switch_lock = SPIN_LOCK_UNLOCKED, \
112 .journal_info = NULL, \
113 .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \
114}
115
116
117#define INIT_CPU_TIMERS(cpu_timers) \
118{ \
119 LIST_HEAD_INIT(cpu_timers[0]), \
120 LIST_HEAD_INIT(cpu_timers[1]), \
121 LIST_HEAD_INIT(cpu_timers[2]), \
122}
123
124
125#endif
diff --git a/include/linux/initrd.h b/include/linux/initrd.h
new file mode 100644
index 000000000000..55289d261b4f
--- /dev/null
+++ b/include/linux/initrd.h
@@ -0,0 +1,20 @@
1
2#define INITRD_MINOR 250 /* shouldn't collide with /dev/ram* too soon ... */
3
4/* 1 = load ramdisk, 0 = don't load */
5extern int rd_doload;
6
7/* 1 = prompt for ramdisk, 0 = don't prompt */
8extern int rd_prompt;
9
10/* starting block # of image */
11extern int rd_image_start;
12
13/* 1 if it is not an error if initrd_start < memory_start */
14extern int initrd_below_start_ok;
15
16/* free_initrd_mem always gets called with the next two as arguments.. */
17extern unsigned long initrd_start, initrd_end;
18extern void free_initrd_mem(unsigned long, unsigned long);
19
20extern unsigned int real_root_dev;
diff --git a/include/linux/input.h b/include/linux/input.h
new file mode 100644
index 000000000000..b70df8fe60e6
--- /dev/null
+++ b/include/linux/input.h
@@ -0,0 +1,1016 @@
1#ifndef _INPUT_H
2#define _INPUT_H
3
4/*
5 * Copyright (c) 1999-2002 Vojtech Pavlik
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#ifdef __KERNEL__
13#include <linux/time.h>
14#include <linux/list.h>
15#else
16#include <sys/time.h>
17#include <sys/ioctl.h>
18#include <asm/types.h>
19#endif
20
21/*
22 * The event structure itself
23 */
24
25struct input_event {
26 struct timeval time;
27 __u16 type;
28 __u16 code;
29 __s32 value;
30};
31
32/*
33 * Protocol version.
34 */
35
36#define EV_VERSION 0x010000
37
38/*
39 * IOCTLs (0x00 - 0x7f)
40 */
41
42struct input_id {
43 __u16 bustype;
44 __u16 vendor;
45 __u16 product;
46 __u16 version;
47};
48
49struct input_absinfo {
50 __s32 value;
51 __s32 minimum;
52 __s32 maximum;
53 __s32 fuzz;
54 __s32 flat;
55};
56
57#define EVIOCGVERSION _IOR('E', 0x01, int) /* get driver version */
58#define EVIOCGID _IOR('E', 0x02, struct input_id) /* get device ID */
59#define EVIOCGKEYCODE _IOR('E', 0x04, int[2]) /* get keycode */
60#define EVIOCSKEYCODE _IOW('E', 0x04, int[2]) /* set keycode */
61
62#define EVIOCGNAME(len) _IOC(_IOC_READ, 'E', 0x06, len) /* get device name */
63#define EVIOCGPHYS(len) _IOC(_IOC_READ, 'E', 0x07, len) /* get physical location */
64#define EVIOCGUNIQ(len) _IOC(_IOC_READ, 'E', 0x08, len) /* get unique identifier */
65
66#define EVIOCGKEY(len) _IOC(_IOC_READ, 'E', 0x18, len) /* get global keystate */
67#define EVIOCGLED(len) _IOC(_IOC_READ, 'E', 0x19, len) /* get all LEDs */
68#define EVIOCGSND(len) _IOC(_IOC_READ, 'E', 0x1a, len) /* get all sounds status */
69
70#define EVIOCGBIT(ev,len) _IOC(_IOC_READ, 'E', 0x20 + ev, len) /* get event bits */
71#define EVIOCGABS(abs) _IOR('E', 0x40 + abs, struct input_absinfo) /* get abs value/limits */
72#define EVIOCSABS(abs) _IOW('E', 0xc0 + abs, struct input_absinfo) /* set abs value/limits */
73
74#define EVIOCSFF _IOC(_IOC_WRITE, 'E', 0x80, sizeof(struct ff_effect)) /* send a force effect to a force feedback device */
75#define EVIOCRMFF _IOW('E', 0x81, int) /* Erase a force effect */
76#define EVIOCGEFFECTS _IOR('E', 0x84, int) /* Report number of effects playable at the same time */
77
78#define EVIOCGRAB _IOW('E', 0x90, int) /* Grab/Release device */
79
80/*
81 * Event types
82 */
83
84#define EV_SYN 0x00
85#define EV_KEY 0x01
86#define EV_REL 0x02
87#define EV_ABS 0x03
88#define EV_MSC 0x04
89#define EV_LED 0x11
90#define EV_SND 0x12
91#define EV_REP 0x14
92#define EV_FF 0x15
93#define EV_PWR 0x16
94#define EV_FF_STATUS 0x17
95#define EV_MAX 0x1f
96
97/*
98 * Synchronization events.
99 */
100
101#define SYN_REPORT 0
102#define SYN_CONFIG 1
103
104/*
105 * Keys and buttons
106 */
107
108#define KEY_RESERVED 0
109#define KEY_ESC 1
110#define KEY_1 2
111#define KEY_2 3
112#define KEY_3 4
113#define KEY_4 5
114#define KEY_5 6
115#define KEY_6 7
116#define KEY_7 8
117#define KEY_8 9
118#define KEY_9 10
119#define KEY_0 11
120#define KEY_MINUS 12
121#define KEY_EQUAL 13
122#define KEY_BACKSPACE 14
123#define KEY_TAB 15
124#define KEY_Q 16
125#define KEY_W 17
126#define KEY_E 18
127#define KEY_R 19
128#define KEY_T 20
129#define KEY_Y 21
130#define KEY_U 22
131#define KEY_I 23
132#define KEY_O 24
133#define KEY_P 25
134#define KEY_LEFTBRACE 26
135#define KEY_RIGHTBRACE 27
136#define KEY_ENTER 28
137#define KEY_LEFTCTRL 29
138#define KEY_A 30
139#define KEY_S 31
140#define KEY_D 32
141#define KEY_F 33
142#define KEY_G 34
143#define KEY_H 35
144#define KEY_J 36
145#define KEY_K 37
146#define KEY_L 38
147#define KEY_SEMICOLON 39
148#define KEY_APOSTROPHE 40
149#define KEY_GRAVE 41
150#define KEY_LEFTSHIFT 42
151#define KEY_BACKSLASH 43
152#define KEY_Z 44
153#define KEY_X 45
154#define KEY_C 46
155#define KEY_V 47
156#define KEY_B 48
157#define KEY_N 49
158#define KEY_M 50
159#define KEY_COMMA 51
160#define KEY_DOT 52
161#define KEY_SLASH 53
162#define KEY_RIGHTSHIFT 54
163#define KEY_KPASTERISK 55
164#define KEY_LEFTALT 56
165#define KEY_SPACE 57
166#define KEY_CAPSLOCK 58
167#define KEY_F1 59
168#define KEY_F2 60
169#define KEY_F3 61
170#define KEY_F4 62
171#define KEY_F5 63
172#define KEY_F6 64
173#define KEY_F7 65
174#define KEY_F8 66
175#define KEY_F9 67
176#define KEY_F10 68
177#define KEY_NUMLOCK 69
178#define KEY_SCROLLLOCK 70
179#define KEY_KP7 71
180#define KEY_KP8 72
181#define KEY_KP9 73
182#define KEY_KPMINUS 74
183#define KEY_KP4 75
184#define KEY_KP5 76
185#define KEY_KP6 77
186#define KEY_KPPLUS 78
187#define KEY_KP1 79
188#define KEY_KP2 80
189#define KEY_KP3 81
190#define KEY_KP0 82
191#define KEY_KPDOT 83
192
193#define KEY_ZENKAKUHANKAKU 85
194#define KEY_102ND 86
195#define KEY_F11 87
196#define KEY_F12 88
197#define KEY_RO 89
198#define KEY_KATAKANA 90
199#define KEY_HIRAGANA 91
200#define KEY_HENKAN 92
201#define KEY_KATAKANAHIRAGANA 93
202#define KEY_MUHENKAN 94
203#define KEY_KPJPCOMMA 95
204#define KEY_KPENTER 96
205#define KEY_RIGHTCTRL 97
206#define KEY_KPSLASH 98
207#define KEY_SYSRQ 99
208#define KEY_RIGHTALT 100
209#define KEY_LINEFEED 101
210#define KEY_HOME 102
211#define KEY_UP 103
212#define KEY_PAGEUP 104
213#define KEY_LEFT 105
214#define KEY_RIGHT 106
215#define KEY_END 107
216#define KEY_DOWN 108
217#define KEY_PAGEDOWN 109
218#define KEY_INSERT 110
219#define KEY_DELETE 111
220#define KEY_MACRO 112
221#define KEY_MUTE 113
222#define KEY_VOLUMEDOWN 114
223#define KEY_VOLUMEUP 115
224#define KEY_POWER 116
225#define KEY_KPEQUAL 117
226#define KEY_KPPLUSMINUS 118
227#define KEY_PAUSE 119
228
229#define KEY_KPCOMMA 121
230#define KEY_HANGUEL 122
231#define KEY_HANJA 123
232#define KEY_YEN 124
233#define KEY_LEFTMETA 125
234#define KEY_RIGHTMETA 126
235#define KEY_COMPOSE 127
236
237#define KEY_STOP 128
238#define KEY_AGAIN 129
239#define KEY_PROPS 130
240#define KEY_UNDO 131
241#define KEY_FRONT 132
242#define KEY_COPY 133
243#define KEY_OPEN 134
244#define KEY_PASTE 135
245#define KEY_FIND 136
246#define KEY_CUT 137
247#define KEY_HELP 138
248#define KEY_MENU 139
249#define KEY_CALC 140
250#define KEY_SETUP 141
251#define KEY_SLEEP 142
252#define KEY_WAKEUP 143
253#define KEY_FILE 144
254#define KEY_SENDFILE 145
255#define KEY_DELETEFILE 146
256#define KEY_XFER 147
257#define KEY_PROG1 148
258#define KEY_PROG2 149
259#define KEY_WWW 150
260#define KEY_MSDOS 151
261#define KEY_COFFEE 152
262#define KEY_DIRECTION 153
263#define KEY_CYCLEWINDOWS 154
264#define KEY_MAIL 155
265#define KEY_BOOKMARKS 156
266#define KEY_COMPUTER 157
267#define KEY_BACK 158
268#define KEY_FORWARD 159
269#define KEY_CLOSECD 160
270#define KEY_EJECTCD 161
271#define KEY_EJECTCLOSECD 162
272#define KEY_NEXTSONG 163
273#define KEY_PLAYPAUSE 164
274#define KEY_PREVIOUSSONG 165
275#define KEY_STOPCD 166
276#define KEY_RECORD 167
277#define KEY_REWIND 168
278#define KEY_PHONE 169
279#define KEY_ISO 170
280#define KEY_CONFIG 171
281#define KEY_HOMEPAGE 172
282#define KEY_REFRESH 173
283#define KEY_EXIT 174
284#define KEY_MOVE 175
285#define KEY_EDIT 176
286#define KEY_SCROLLUP 177
287#define KEY_SCROLLDOWN 178
288#define KEY_KPLEFTPAREN 179
289#define KEY_KPRIGHTPAREN 180
290
291#define KEY_F13 183
292#define KEY_F14 184
293#define KEY_F15 185
294#define KEY_F16 186
295#define KEY_F17 187
296#define KEY_F18 188
297#define KEY_F19 189
298#define KEY_F20 190
299#define KEY_F21 191
300#define KEY_F22 192
301#define KEY_F23 193
302#define KEY_F24 194
303
304#define KEY_PLAYCD 200
305#define KEY_PAUSECD 201
306#define KEY_PROG3 202
307#define KEY_PROG4 203
308#define KEY_SUSPEND 205
309#define KEY_CLOSE 206
310#define KEY_PLAY 207
311#define KEY_FASTFORWARD 208
312#define KEY_BASSBOOST 209
313#define KEY_PRINT 210
314#define KEY_HP 211
315#define KEY_CAMERA 212
316#define KEY_SOUND 213
317#define KEY_QUESTION 214
318#define KEY_EMAIL 215
319#define KEY_CHAT 216
320#define KEY_SEARCH 217
321#define KEY_CONNECT 218
322#define KEY_FINANCE 219
323#define KEY_SPORT 220
324#define KEY_SHOP 221
325#define KEY_ALTERASE 222
326#define KEY_CANCEL 223
327#define KEY_BRIGHTNESSDOWN 224
328#define KEY_BRIGHTNESSUP 225
329#define KEY_MEDIA 226
330
331#define KEY_UNKNOWN 240
332
333#define BTN_MISC 0x100
334#define BTN_0 0x100
335#define BTN_1 0x101
336#define BTN_2 0x102
337#define BTN_3 0x103
338#define BTN_4 0x104
339#define BTN_5 0x105
340#define BTN_6 0x106
341#define BTN_7 0x107
342#define BTN_8 0x108
343#define BTN_9 0x109
344
345#define BTN_MOUSE 0x110
346#define BTN_LEFT 0x110
347#define BTN_RIGHT 0x111
348#define BTN_MIDDLE 0x112
349#define BTN_SIDE 0x113
350#define BTN_EXTRA 0x114
351#define BTN_FORWARD 0x115
352#define BTN_BACK 0x116
353#define BTN_TASK 0x117
354
355#define BTN_JOYSTICK 0x120
356#define BTN_TRIGGER 0x120
357#define BTN_THUMB 0x121
358#define BTN_THUMB2 0x122
359#define BTN_TOP 0x123
360#define BTN_TOP2 0x124
361#define BTN_PINKIE 0x125
362#define BTN_BASE 0x126
363#define BTN_BASE2 0x127
364#define BTN_BASE3 0x128
365#define BTN_BASE4 0x129
366#define BTN_BASE5 0x12a
367#define BTN_BASE6 0x12b
368#define BTN_DEAD 0x12f
369
370#define BTN_GAMEPAD 0x130
371#define BTN_A 0x130
372#define BTN_B 0x131
373#define BTN_C 0x132
374#define BTN_X 0x133
375#define BTN_Y 0x134
376#define BTN_Z 0x135
377#define BTN_TL 0x136
378#define BTN_TR 0x137
379#define BTN_TL2 0x138
380#define BTN_TR2 0x139
381#define BTN_SELECT 0x13a
382#define BTN_START 0x13b
383#define BTN_MODE 0x13c
384#define BTN_THUMBL 0x13d
385#define BTN_THUMBR 0x13e
386
387#define BTN_DIGI 0x140
388#define BTN_TOOL_PEN 0x140
389#define BTN_TOOL_RUBBER 0x141
390#define BTN_TOOL_BRUSH 0x142
391#define BTN_TOOL_PENCIL 0x143
392#define BTN_TOOL_AIRBRUSH 0x144
393#define BTN_TOOL_FINGER 0x145
394#define BTN_TOOL_MOUSE 0x146
395#define BTN_TOOL_LENS 0x147
396#define BTN_TOUCH 0x14a
397#define BTN_STYLUS 0x14b
398#define BTN_STYLUS2 0x14c
399#define BTN_TOOL_DOUBLETAP 0x14d
400#define BTN_TOOL_TRIPLETAP 0x14e
401
402#define BTN_WHEEL 0x150
403#define BTN_GEAR_DOWN 0x150
404#define BTN_GEAR_UP 0x151
405
406#define KEY_OK 0x160
407#define KEY_SELECT 0x161
408#define KEY_GOTO 0x162
409#define KEY_CLEAR 0x163
410#define KEY_POWER2 0x164
411#define KEY_OPTION 0x165
412#define KEY_INFO 0x166
413#define KEY_TIME 0x167
414#define KEY_VENDOR 0x168
415#define KEY_ARCHIVE 0x169
416#define KEY_PROGRAM 0x16a
417#define KEY_CHANNEL 0x16b
418#define KEY_FAVORITES 0x16c
419#define KEY_EPG 0x16d
420#define KEY_PVR 0x16e
421#define KEY_MHP 0x16f
422#define KEY_LANGUAGE 0x170
423#define KEY_TITLE 0x171
424#define KEY_SUBTITLE 0x172
425#define KEY_ANGLE 0x173
426#define KEY_ZOOM 0x174
427#define KEY_MODE 0x175
428#define KEY_KEYBOARD 0x176
429#define KEY_SCREEN 0x177
430#define KEY_PC 0x178
431#define KEY_TV 0x179
432#define KEY_TV2 0x17a
433#define KEY_VCR 0x17b
434#define KEY_VCR2 0x17c
435#define KEY_SAT 0x17d
436#define KEY_SAT2 0x17e
437#define KEY_CD 0x17f
438#define KEY_TAPE 0x180
439#define KEY_RADIO 0x181
440#define KEY_TUNER 0x182
441#define KEY_PLAYER 0x183
442#define KEY_TEXT 0x184
443#define KEY_DVD 0x185
444#define KEY_AUX 0x186
445#define KEY_MP3 0x187
446#define KEY_AUDIO 0x188
447#define KEY_VIDEO 0x189
448#define KEY_DIRECTORY 0x18a
449#define KEY_LIST 0x18b
450#define KEY_MEMO 0x18c
451#define KEY_CALENDAR 0x18d
452#define KEY_RED 0x18e
453#define KEY_GREEN 0x18f
454#define KEY_YELLOW 0x190
455#define KEY_BLUE 0x191
456#define KEY_CHANNELUP 0x192
457#define KEY_CHANNELDOWN 0x193
458#define KEY_FIRST 0x194
459#define KEY_LAST 0x195
460#define KEY_AB 0x196
461#define KEY_NEXT 0x197
462#define KEY_RESTART 0x198
463#define KEY_SLOW 0x199
464#define KEY_SHUFFLE 0x19a
465#define KEY_BREAK 0x19b
466#define KEY_PREVIOUS 0x19c
467#define KEY_DIGITS 0x19d
468#define KEY_TEEN 0x19e
469#define KEY_TWEN 0x19f
470
471#define KEY_DEL_EOL 0x1c0
472#define KEY_DEL_EOS 0x1c1
473#define KEY_INS_LINE 0x1c2
474#define KEY_DEL_LINE 0x1c3
475
476#define KEY_FN 0x1d0
477#define KEY_FN_ESC 0x1d1
478#define KEY_FN_F1 0x1d2
479#define KEY_FN_F2 0x1d3
480#define KEY_FN_F3 0x1d4
481#define KEY_FN_F4 0x1d5
482#define KEY_FN_F5 0x1d6
483#define KEY_FN_F6 0x1d7
484#define KEY_FN_F7 0x1d8
485#define KEY_FN_F8 0x1d9
486#define KEY_FN_F9 0x1da
487#define KEY_FN_F10 0x1db
488#define KEY_FN_F11 0x1dc
489#define KEY_FN_F12 0x1dd
490#define KEY_FN_1 0x1de
491#define KEY_FN_2 0x1df
492#define KEY_FN_D 0x1e0
493#define KEY_FN_E 0x1e1
494#define KEY_FN_F 0x1e2
495#define KEY_FN_S 0x1e3
496#define KEY_FN_B 0x1e4
497
498#define KEY_MAX 0x1ff
499
500/*
501 * Relative axes
502 */
503
504#define REL_X 0x00
505#define REL_Y 0x01
506#define REL_Z 0x02
507#define REL_RX 0x03
508#define REL_RY 0x04
509#define REL_RZ 0x05
510#define REL_HWHEEL 0x06
511#define REL_DIAL 0x07
512#define REL_WHEEL 0x08
513#define REL_MISC 0x09
514#define REL_MAX 0x0f
515
516/*
517 * Absolute axes
518 */
519
520#define ABS_X 0x00
521#define ABS_Y 0x01
522#define ABS_Z 0x02
523#define ABS_RX 0x03
524#define ABS_RY 0x04
525#define ABS_RZ 0x05
526#define ABS_THROTTLE 0x06
527#define ABS_RUDDER 0x07
528#define ABS_WHEEL 0x08
529#define ABS_GAS 0x09
530#define ABS_BRAKE 0x0a
531#define ABS_HAT0X 0x10
532#define ABS_HAT0Y 0x11
533#define ABS_HAT1X 0x12
534#define ABS_HAT1Y 0x13
535#define ABS_HAT2X 0x14
536#define ABS_HAT2Y 0x15
537#define ABS_HAT3X 0x16
538#define ABS_HAT3Y 0x17
539#define ABS_PRESSURE 0x18
540#define ABS_DISTANCE 0x19
541#define ABS_TILT_X 0x1a
542#define ABS_TILT_Y 0x1b
543#define ABS_TOOL_WIDTH 0x1c
544#define ABS_VOLUME 0x20
545#define ABS_MISC 0x28
546#define ABS_MAX 0x3f
547
548/*
549 * Misc events
550 */
551
552#define MSC_SERIAL 0x00
553#define MSC_PULSELED 0x01
554#define MSC_GESTURE 0x02
555#define MSC_RAW 0x03
556#define MSC_SCAN 0x04
557#define MSC_MAX 0x07
558
559/*
560 * LEDs
561 */
562
563#define LED_NUML 0x00
564#define LED_CAPSL 0x01
565#define LED_SCROLLL 0x02
566#define LED_COMPOSE 0x03
567#define LED_KANA 0x04
568#define LED_SLEEP 0x05
569#define LED_SUSPEND 0x06
570#define LED_MUTE 0x07
571#define LED_MISC 0x08
572#define LED_MAIL 0x09
573#define LED_CHARGING 0x0a
574#define LED_MAX 0x0f
575
576/*
577 * Autorepeat values
578 */
579
580#define REP_DELAY 0x00
581#define REP_PERIOD 0x01
582#define REP_MAX 0x01
583
584/*
585 * Sounds
586 */
587
588#define SND_CLICK 0x00
589#define SND_BELL 0x01
590#define SND_TONE 0x02
591#define SND_MAX 0x07
592
593/*
594 * IDs.
595 */
596
597#define ID_BUS 0
598#define ID_VENDOR 1
599#define ID_PRODUCT 2
600#define ID_VERSION 3
601
602#define BUS_PCI 0x01
603#define BUS_ISAPNP 0x02
604#define BUS_USB 0x03
605#define BUS_HIL 0x04
606#define BUS_BLUETOOTH 0x05
607
608#define BUS_ISA 0x10
609#define BUS_I8042 0x11
610#define BUS_XTKBD 0x12
611#define BUS_RS232 0x13
612#define BUS_GAMEPORT 0x14
613#define BUS_PARPORT 0x15
614#define BUS_AMIGA 0x16
615#define BUS_ADB 0x17
616#define BUS_I2C 0x18
617#define BUS_HOST 0x19
618
619/*
620 * Values describing the status of an effect
621 */
622#define FF_STATUS_STOPPED 0x00
623#define FF_STATUS_PLAYING 0x01
624#define FF_STATUS_MAX 0x01
625
626/*
627 * Structures used in ioctls to upload effects to a device
628 * The first structures are not passed directly by using ioctls.
629 * They are sub-structures of the actually sent structure (called ff_effect)
630 */
631
632struct ff_replay {
633 __u16 length; /* Duration of an effect in ms. All other times are also expressed in ms */
634 __u16 delay; /* Time to wait before to start playing an effect */
635};
636
637struct ff_trigger {
638 __u16 button; /* Number of button triggering an effect */
639 __u16 interval; /* Time to wait before an effect can be re-triggered (ms) */
640};
641
642struct ff_envelope {
643 __u16 attack_length; /* Duration of attack (ms) */
644 __u16 attack_level; /* Level at beginning of attack */
645 __u16 fade_length; /* Duration of fade (ms) */
646 __u16 fade_level; /* Level at end of fade */
647};
648
649/* FF_CONSTANT */
650struct ff_constant_effect {
651 __s16 level; /* Strength of effect. Negative values are OK */
652 struct ff_envelope envelope;
653};
654
655/* FF_RAMP */
656struct ff_ramp_effect {
657 __s16 start_level;
658 __s16 end_level;
659 struct ff_envelope envelope;
660};
661
662/* FF_SPRING of FF_FRICTION */
663struct ff_condition_effect {
664 __u16 right_saturation; /* Max level when joystick is on the right */
665 __u16 left_saturation; /* Max level when joystick in on the left */
666
667 __s16 right_coeff; /* Indicates how fast the force grows when the
668 joystick moves to the right */
669 __s16 left_coeff; /* Same for left side */
670
671 __u16 deadband; /* Size of area where no force is produced */
672 __s16 center; /* Position of dead zone */
673
674};
675
676/* FF_PERIODIC */
677struct ff_periodic_effect {
678 __u16 waveform; /* Kind of wave (sine, square...) */
679 __u16 period; /* in ms */
680 __s16 magnitude; /* Peak value */
681 __s16 offset; /* Mean value of wave (roughly) */
682 __u16 phase; /* 'Horizontal' shift */
683
684 struct ff_envelope envelope;
685
686/* Only used if waveform == FF_CUSTOM */
687 __u32 custom_len; /* Number of samples */
688 __s16 *custom_data; /* Buffer of samples */
689/* Note: the data pointed by custom_data is copied by the driver. You can
690 * therefore dispose of the memory after the upload/update */
691};
692
693/* FF_RUMBLE */
694/* Some rumble pads have two motors of different weight.
695 strong_magnitude represents the magnitude of the vibration generated
696 by the heavy motor.
697*/
698struct ff_rumble_effect {
699 __u16 strong_magnitude; /* Magnitude of the heavy motor */
700 __u16 weak_magnitude; /* Magnitude of the light one */
701};
702
703/*
704 * Structure sent through ioctl from the application to the driver
705 */
706struct ff_effect {
707 __u16 type;
708/* Following field denotes the unique id assigned to an effect.
709 * If user sets if to -1, a new effect is created, and its id is returned in the same field
710 * Else, the user sets it to the effect id it wants to update.
711 */
712 __s16 id;
713
714 __u16 direction; /* Direction. 0 deg -> 0x0000 (down)
715 90 deg -> 0x4000 (left)
716 180 deg -> 0x8000 (up)
717 270 deg -> 0xC000 (right)
718 */
719
720 struct ff_trigger trigger;
721 struct ff_replay replay;
722
723 union {
724 struct ff_constant_effect constant;
725 struct ff_ramp_effect ramp;
726 struct ff_periodic_effect periodic;
727 struct ff_condition_effect condition[2]; /* One for each axis */
728 struct ff_rumble_effect rumble;
729 } u;
730};
731
732/*
733 * Force feedback effect types
734 */
735
736#define FF_RUMBLE 0x50
737#define FF_PERIODIC 0x51
738#define FF_CONSTANT 0x52
739#define FF_SPRING 0x53
740#define FF_FRICTION 0x54
741#define FF_DAMPER 0x55
742#define FF_INERTIA 0x56
743#define FF_RAMP 0x57
744
745/*
746 * Force feedback periodic effect types
747 */
748
749#define FF_SQUARE 0x58
750#define FF_TRIANGLE 0x59
751#define FF_SINE 0x5a
752#define FF_SAW_UP 0x5b
753#define FF_SAW_DOWN 0x5c
754#define FF_CUSTOM 0x5d
755
756/*
757 * Set ff device properties
758 */
759
760#define FF_GAIN 0x60
761#define FF_AUTOCENTER 0x61
762
763#define FF_MAX 0x7f
764
765#ifdef __KERNEL__
766
767/*
768 * In-kernel definitions.
769 */
770
771#include <linux/fs.h>
772#include <linux/timer.h>
773
774#define NBITS(x) (((x)/BITS_PER_LONG)+1)
775#define BIT(x) (1UL<<((x)%BITS_PER_LONG))
776#define LONG(x) ((x)/BITS_PER_LONG)
777
778#define INPUT_KEYCODE(dev, scancode) ((dev->keycodesize == 1) ? ((u8*)dev->keycode)[scancode] : \
779 ((dev->keycodesize == 2) ? ((u16*)dev->keycode)[scancode] : (((u32*)dev->keycode)[scancode])))
780
781#define SET_INPUT_KEYCODE(dev, scancode, val) \
782 ({ unsigned __old; \
783 switch (dev->keycodesize) { \
784 case 1: { \
785 u8 *k = (u8 *)dev->keycode; \
786 __old = k[scancode]; \
787 k[scancode] = val; \
788 break; \
789 } \
790 case 2: { \
791 u16 *k = (u16 *)dev->keycode; \
792 __old = k[scancode]; \
793 k[scancode] = val; \
794 break; \
795 } \
796 default: { \
797 u32 *k = (u32 *)dev->keycode; \
798 __old = k[scancode]; \
799 k[scancode] = val; \
800 break; \
801 } \
802 } \
803 __old; })
804
805struct input_dev {
806
807 void *private;
808
809 char *name;
810 char *phys;
811 char *uniq;
812 struct input_id id;
813
814 unsigned long evbit[NBITS(EV_MAX)];
815 unsigned long keybit[NBITS(KEY_MAX)];
816 unsigned long relbit[NBITS(REL_MAX)];
817 unsigned long absbit[NBITS(ABS_MAX)];
818 unsigned long mscbit[NBITS(MSC_MAX)];
819 unsigned long ledbit[NBITS(LED_MAX)];
820 unsigned long sndbit[NBITS(SND_MAX)];
821 unsigned long ffbit[NBITS(FF_MAX)];
822 int ff_effects_max;
823
824 unsigned int keycodemax;
825 unsigned int keycodesize;
826 void *keycode;
827
828 unsigned int repeat_key;
829 struct timer_list timer;
830
831 struct pt_regs *regs;
832 int state;
833
834 int sync;
835
836 int abs[ABS_MAX + 1];
837 int rep[REP_MAX + 1];
838
839 unsigned long key[NBITS(KEY_MAX)];
840 unsigned long led[NBITS(LED_MAX)];
841 unsigned long snd[NBITS(SND_MAX)];
842
843 int absmax[ABS_MAX + 1];
844 int absmin[ABS_MAX + 1];
845 int absfuzz[ABS_MAX + 1];
846 int absflat[ABS_MAX + 1];
847
848 int (*open)(struct input_dev *dev);
849 void (*close)(struct input_dev *dev);
850 int (*accept)(struct input_dev *dev, struct file *file);
851 int (*flush)(struct input_dev *dev, struct file *file);
852 int (*event)(struct input_dev *dev, unsigned int type, unsigned int code, int value);
853 int (*upload_effect)(struct input_dev *dev, struct ff_effect *effect);
854 int (*erase_effect)(struct input_dev *dev, int effect_id);
855
856 struct input_handle *grab;
857 struct device *dev;
858
859 struct list_head h_list;
860 struct list_head node;
861};
862
863/*
864 * Structure for hotplug & device<->driver matching.
865 */
866
867#define INPUT_DEVICE_ID_MATCH_BUS 1
868#define INPUT_DEVICE_ID_MATCH_VENDOR 2
869#define INPUT_DEVICE_ID_MATCH_PRODUCT 4
870#define INPUT_DEVICE_ID_MATCH_VERSION 8
871
872#define INPUT_DEVICE_ID_MATCH_EVBIT 0x010
873#define INPUT_DEVICE_ID_MATCH_KEYBIT 0x020
874#define INPUT_DEVICE_ID_MATCH_RELBIT 0x040
875#define INPUT_DEVICE_ID_MATCH_ABSBIT 0x080
876#define INPUT_DEVICE_ID_MATCH_MSCIT 0x100
877#define INPUT_DEVICE_ID_MATCH_LEDBIT 0x200
878#define INPUT_DEVICE_ID_MATCH_SNDBIT 0x400
879#define INPUT_DEVICE_ID_MATCH_FFBIT 0x800
880
881#define INPUT_DEVICE_ID_MATCH_DEVICE\
882 (INPUT_DEVICE_ID_MATCH_BUS | INPUT_DEVICE_ID_MATCH_VENDOR | INPUT_DEVICE_ID_MATCH_PRODUCT)
883#define INPUT_DEVICE_ID_MATCH_DEVICE_AND_VERSION\
884 (INPUT_DEVICE_ID_MATCH_DEVICE | INPUT_DEVICE_ID_MATCH_VERSION)
885
886struct input_device_id {
887
888 unsigned long flags;
889
890 struct input_id id;
891
892 unsigned long evbit[NBITS(EV_MAX)];
893 unsigned long keybit[NBITS(KEY_MAX)];
894 unsigned long relbit[NBITS(REL_MAX)];
895 unsigned long absbit[NBITS(ABS_MAX)];
896 unsigned long mscbit[NBITS(MSC_MAX)];
897 unsigned long ledbit[NBITS(LED_MAX)];
898 unsigned long sndbit[NBITS(SND_MAX)];
899 unsigned long ffbit[NBITS(FF_MAX)];
900
901 unsigned long driver_info;
902};
903
904struct input_handle;
905
906struct input_handler {
907
908 void *private;
909
910 void (*event)(struct input_handle *handle, unsigned int type, unsigned int code, int value);
911 struct input_handle* (*connect)(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id);
912 void (*disconnect)(struct input_handle *handle);
913
914 struct file_operations *fops;
915 int minor;
916 char *name;
917
918 struct input_device_id *id_table;
919 struct input_device_id *blacklist;
920
921 struct list_head h_list;
922 struct list_head node;
923};
924
925struct input_handle {
926
927 void *private;
928
929 int open;
930 char *name;
931
932 struct input_dev *dev;
933 struct input_handler *handler;
934
935 struct list_head d_node;
936 struct list_head h_node;
937};
938
939#define to_dev(n) container_of(n,struct input_dev,node)
940#define to_handler(n) container_of(n,struct input_handler,node);
941#define to_handle(n) container_of(n,struct input_handle,d_node)
942#define to_handle_h(n) container_of(n,struct input_handle,h_node)
943
944static inline void init_input_dev(struct input_dev *dev)
945{
946 INIT_LIST_HEAD(&dev->h_list);
947 INIT_LIST_HEAD(&dev->node);
948}
949
950void input_register_device(struct input_dev *);
951void input_unregister_device(struct input_dev *);
952
953void input_register_handler(struct input_handler *);
954void input_unregister_handler(struct input_handler *);
955
956int input_grab_device(struct input_handle *);
957void input_release_device(struct input_handle *);
958
959int input_open_device(struct input_handle *);
960void input_close_device(struct input_handle *);
961
962int input_accept_process(struct input_handle *handle, struct file *file);
963int input_flush_device(struct input_handle* handle, struct file* file);
964
965void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value);
966
967static inline void input_report_key(struct input_dev *dev, unsigned int code, int value)
968{
969 input_event(dev, EV_KEY, code, !!value);
970}
971
972static inline void input_report_rel(struct input_dev *dev, unsigned int code, int value)
973{
974 input_event(dev, EV_REL, code, value);
975}
976
977static inline void input_report_abs(struct input_dev *dev, unsigned int code, int value)
978{
979 input_event(dev, EV_ABS, code, value);
980}
981
982static inline void input_report_ff(struct input_dev *dev, unsigned int code, int value)
983{
984 input_event(dev, EV_FF, code, value);
985}
986
987static inline void input_report_ff_status(struct input_dev *dev, unsigned int code, int value)
988{
989 input_event(dev, EV_FF_STATUS, code, value);
990}
991
992static inline void input_regs(struct input_dev *dev, struct pt_regs *regs)
993{
994 dev->regs = regs;
995}
996
997static inline void input_sync(struct input_dev *dev)
998{
999 input_event(dev, EV_SYN, SYN_REPORT, 0);
1000 dev->regs = NULL;
1001}
1002
1003static inline void input_set_abs_params(struct input_dev *dev, int axis, int min, int max, int fuzz, int flat)
1004{
1005 dev->absmin[axis] = min;
1006 dev->absmax[axis] = max;
1007 dev->absfuzz[axis] = fuzz;
1008 dev->absflat[axis] = flat;
1009
1010 dev->absbit[LONG(axis)] |= BIT(axis);
1011}
1012
1013extern struct class_simple *input_class;
1014
1015#endif
1016#endif
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
new file mode 100644
index 000000000000..d99e7aeb7d33
--- /dev/null
+++ b/include/linux/interrupt.h
@@ -0,0 +1,289 @@
1/* interrupt.h */
2#ifndef _LINUX_INTERRUPT_H
3#define _LINUX_INTERRUPT_H
4
5#include <linux/config.h>
6#include <linux/kernel.h>
7#include <linux/linkage.h>
8#include <linux/bitops.h>
9#include <linux/preempt.h>
10#include <linux/cpumask.h>
11#include <linux/hardirq.h>
12#include <asm/atomic.h>
13#include <asm/ptrace.h>
14#include <asm/system.h>
15
16/*
17 * For 2.4.x compatibility, 2.4.x can use
18 *
19 * typedef void irqreturn_t;
20 * #define IRQ_NONE
21 * #define IRQ_HANDLED
22 * #define IRQ_RETVAL(x)
23 *
24 * To mix old-style and new-style irq handler returns.
25 *
26 * IRQ_NONE means we didn't handle it.
27 * IRQ_HANDLED means that we did have a valid interrupt and handled it.
28 * IRQ_RETVAL(x) selects on the two depending on x being non-zero (for handled)
29 */
30typedef int irqreturn_t;
31
32#define IRQ_NONE (0)
33#define IRQ_HANDLED (1)
34#define IRQ_RETVAL(x) ((x) != 0)
35
36struct irqaction {
37 irqreturn_t (*handler)(int, void *, struct pt_regs *);
38 unsigned long flags;
39 cpumask_t mask;
40 const char *name;
41 void *dev_id;
42 struct irqaction *next;
43 int irq;
44 struct proc_dir_entry *dir;
45};
46
47extern irqreturn_t no_action(int cpl, void *dev_id, struct pt_regs *regs);
48extern int request_irq(unsigned int,
49 irqreturn_t (*handler)(int, void *, struct pt_regs *),
50 unsigned long, const char *, void *);
51extern void free_irq(unsigned int, void *);
52
53
54#ifdef CONFIG_GENERIC_HARDIRQS
55extern void disable_irq_nosync(unsigned int irq);
56extern void disable_irq(unsigned int irq);
57extern void enable_irq(unsigned int irq);
58#endif
59
60/*
61 * Temporary defines for UP kernels, until all code gets fixed.
62 */
63#ifndef CONFIG_SMP
64static inline void __deprecated cli(void)
65{
66 local_irq_disable();
67}
68static inline void __deprecated sti(void)
69{
70 local_irq_enable();
71}
72static inline void __deprecated save_flags(unsigned long *x)
73{
74 local_save_flags(*x);
75}
76#define save_flags(x) save_flags(&x);
77static inline void __deprecated restore_flags(unsigned long x)
78{
79 local_irq_restore(x);
80}
81
82static inline void __deprecated save_and_cli(unsigned long *x)
83{
84 local_irq_save(*x);
85}
86#define save_and_cli(x) save_and_cli(&x)
87#endif /* CONFIG_SMP */
88
89/* SoftIRQ primitives. */
90#define local_bh_disable() \
91 do { add_preempt_count(SOFTIRQ_OFFSET); barrier(); } while (0)
92#define __local_bh_enable() \
93 do { barrier(); sub_preempt_count(SOFTIRQ_OFFSET); } while (0)
94
95extern void local_bh_enable(void);
96
97/* PLEASE, avoid to allocate new softirqs, if you need not _really_ high
98 frequency threaded job scheduling. For almost all the purposes
99 tasklets are more than enough. F.e. all serial device BHs et
100 al. should be converted to tasklets, not to softirqs.
101 */
102
103enum
104{
105 HI_SOFTIRQ=0,
106 TIMER_SOFTIRQ,
107 NET_TX_SOFTIRQ,
108 NET_RX_SOFTIRQ,
109 SCSI_SOFTIRQ,
110 TASKLET_SOFTIRQ
111};
112
113/* softirq mask and active fields moved to irq_cpustat_t in
114 * asm/hardirq.h to get better cache usage. KAO
115 */
116
117struct softirq_action
118{
119 void (*action)(struct softirq_action *);
120 void *data;
121};
122
123asmlinkage void do_softirq(void);
124extern void open_softirq(int nr, void (*action)(struct softirq_action*), void *data);
125extern void softirq_init(void);
126#define __raise_softirq_irqoff(nr) do { local_softirq_pending() |= 1UL << (nr); } while (0)
127extern void FASTCALL(raise_softirq_irqoff(unsigned int nr));
128extern void FASTCALL(raise_softirq(unsigned int nr));
129
130
131/* Tasklets --- multithreaded analogue of BHs.
132
133 Main feature differing them of generic softirqs: tasklet
134 is running only on one CPU simultaneously.
135
136 Main feature differing them of BHs: different tasklets
137 may be run simultaneously on different CPUs.
138
139 Properties:
140 * If tasklet_schedule() is called, then tasklet is guaranteed
141 to be executed on some cpu at least once after this.
142 * If the tasklet is already scheduled, but its excecution is still not
143 started, it will be executed only once.
144 * If this tasklet is already running on another CPU (or schedule is called
145 from tasklet itself), it is rescheduled for later.
146 * Tasklet is strictly serialized wrt itself, but not
147 wrt another tasklets. If client needs some intertask synchronization,
148 he makes it with spinlocks.
149 */
150
151struct tasklet_struct
152{
153 struct tasklet_struct *next;
154 unsigned long state;
155 atomic_t count;
156 void (*func)(unsigned long);
157 unsigned long data;
158};
159
160#define DECLARE_TASKLET(name, func, data) \
161struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(0), func, data }
162
163#define DECLARE_TASKLET_DISABLED(name, func, data) \
164struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(1), func, data }
165
166
167enum
168{
169 TASKLET_STATE_SCHED, /* Tasklet is scheduled for execution */
170 TASKLET_STATE_RUN /* Tasklet is running (SMP only) */
171};
172
173#ifdef CONFIG_SMP
174static inline int tasklet_trylock(struct tasklet_struct *t)
175{
176 return !test_and_set_bit(TASKLET_STATE_RUN, &(t)->state);
177}
178
179static inline void tasklet_unlock(struct tasklet_struct *t)
180{
181 smp_mb__before_clear_bit();
182 clear_bit(TASKLET_STATE_RUN, &(t)->state);
183}
184
185static inline void tasklet_unlock_wait(struct tasklet_struct *t)
186{
187 while (test_bit(TASKLET_STATE_RUN, &(t)->state)) { barrier(); }
188}
189#else
190#define tasklet_trylock(t) 1
191#define tasklet_unlock_wait(t) do { } while (0)
192#define tasklet_unlock(t) do { } while (0)
193#endif
194
195extern void FASTCALL(__tasklet_schedule(struct tasklet_struct *t));
196
197static inline void tasklet_schedule(struct tasklet_struct *t)
198{
199 if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
200 __tasklet_schedule(t);
201}
202
203extern void FASTCALL(__tasklet_hi_schedule(struct tasklet_struct *t));
204
205static inline void tasklet_hi_schedule(struct tasklet_struct *t)
206{
207 if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
208 __tasklet_hi_schedule(t);
209}
210
211
212static inline void tasklet_disable_nosync(struct tasklet_struct *t)
213{
214 atomic_inc(&t->count);
215 smp_mb__after_atomic_inc();
216}
217
218static inline void tasklet_disable(struct tasklet_struct *t)
219{
220 tasklet_disable_nosync(t);
221 tasklet_unlock_wait(t);
222 smp_mb();
223}
224
225static inline void tasklet_enable(struct tasklet_struct *t)
226{
227 smp_mb__before_atomic_dec();
228 atomic_dec(&t->count);
229}
230
231static inline void tasklet_hi_enable(struct tasklet_struct *t)
232{
233 smp_mb__before_atomic_dec();
234 atomic_dec(&t->count);
235}
236
237extern void tasklet_kill(struct tasklet_struct *t);
238extern void tasklet_kill_immediate(struct tasklet_struct *t, unsigned int cpu);
239extern void tasklet_init(struct tasklet_struct *t,
240 void (*func)(unsigned long), unsigned long data);
241
242/*
243 * Autoprobing for irqs:
244 *
245 * probe_irq_on() and probe_irq_off() provide robust primitives
246 * for accurate IRQ probing during kernel initialization. They are
247 * reasonably simple to use, are not "fooled" by spurious interrupts,
248 * and, unlike other attempts at IRQ probing, they do not get hung on
249 * stuck interrupts (such as unused PS2 mouse interfaces on ASUS boards).
250 *
251 * For reasonably foolproof probing, use them as follows:
252 *
253 * 1. clear and/or mask the device's internal interrupt.
254 * 2. sti();
255 * 3. irqs = probe_irq_on(); // "take over" all unassigned idle IRQs
256 * 4. enable the device and cause it to trigger an interrupt.
257 * 5. wait for the device to interrupt, using non-intrusive polling or a delay.
258 * 6. irq = probe_irq_off(irqs); // get IRQ number, 0=none, negative=multiple
259 * 7. service the device to clear its pending interrupt.
260 * 8. loop again if paranoia is required.
261 *
262 * probe_irq_on() returns a mask of allocated irq's.
263 *
264 * probe_irq_off() takes the mask as a parameter,
265 * and returns the irq number which occurred,
266 * or zero if none occurred, or a negative irq number
267 * if more than one irq occurred.
268 */
269
270#if defined(CONFIG_GENERIC_HARDIRQS) && !defined(CONFIG_GENERIC_IRQ_PROBE)
271static inline unsigned long probe_irq_on(void)
272{
273 return 0;
274}
275static inline int probe_irq_off(unsigned long val)
276{
277 return 0;
278}
279static inline unsigned int probe_irq_mask(unsigned long val)
280{
281 return 0;
282}
283#else
284extern unsigned long probe_irq_on(void); /* returns 0 on failure */
285extern int probe_irq_off(unsigned long); /* returns 0 or negative on failure */
286extern unsigned int probe_irq_mask(unsigned long); /* returns mask of ISA interrupts */
287#endif
288
289#endif
diff --git a/include/linux/ioc4_common.h b/include/linux/ioc4_common.h
new file mode 100644
index 000000000000..b03bcc46df55
--- /dev/null
+++ b/include/linux/ioc4_common.h
@@ -0,0 +1,21 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved.
7 */
8
9#ifndef _LINUX_IOC4_COMMON_H
10#define _LINUX_IOC4_COMMON_H
11
12/* prototypes */
13
14int ioc4_serial_init(void);
15
16int ioc4_serial_attach_one(struct pci_dev *pdev, const struct
17 pci_device_id *pci_id);
18int ioc4_ide_attach_one(struct pci_dev *pdev, const struct
19 pci_device_id *pci_id);
20
21#endif /* _LINUX_IOC4_COMMON_H */
diff --git a/include/linux/ioctl.h b/include/linux/ioctl.h
new file mode 100644
index 000000000000..aa91eb3951ef
--- /dev/null
+++ b/include/linux/ioctl.h
@@ -0,0 +1,7 @@
1#ifndef _LINUX_IOCTL_H
2#define _LINUX_IOCTL_H
3
4#include <asm/ioctl.h>
5
6#endif /* _LINUX_IOCTL_H */
7
diff --git a/include/linux/ioctl32.h b/include/linux/ioctl32.h
new file mode 100644
index 000000000000..e1a641819428
--- /dev/null
+++ b/include/linux/ioctl32.h
@@ -0,0 +1,37 @@
1#ifndef IOCTL32_H
2#define IOCTL32_H 1
3
4struct file;
5
6typedef int (*ioctl_trans_handler_t)(unsigned int, unsigned int,
7 unsigned long, struct file *);
8
9struct ioctl_trans {
10 unsigned long cmd;
11 ioctl_trans_handler_t handler;
12 struct ioctl_trans *next;
13};
14
15/*
16 * Register an 32bit ioctl translation handler for ioctl cmd.
17 *
18 * handler == NULL: use 64bit ioctl handler.
19 * arguments to handler: fd: file descriptor
20 * cmd: ioctl command.
21 * arg: ioctl argument
22 * struct file *file: file descriptor pointer.
23 */
24
25#ifdef CONFIG_COMPAT
26extern int register_ioctl32_conversion(unsigned int cmd,
27 ioctl_trans_handler_t handler);
28extern int unregister_ioctl32_conversion(unsigned int cmd);
29
30#else
31
32#define register_ioctl32_conversion(cmd, handler) ({ 0; })
33#define unregister_ioctl32_conversion(cmd) ({ 0; })
34
35#endif
36
37#endif
diff --git a/include/linux/ioport.h b/include/linux/ioport.h
new file mode 100644
index 000000000000..18d010bee635
--- /dev/null
+++ b/include/linux/ioport.h
@@ -0,0 +1,127 @@
1/*
2 * ioport.h Definitions of routines for detecting, reserving and
3 * allocating system resources.
4 *
5 * Authors: Linus Torvalds
6 */
7
8#ifndef _LINUX_IOPORT_H
9#define _LINUX_IOPORT_H
10
11#include <linux/compiler.h>
12/*
13 * Resources are tree-like, allowing
14 * nesting etc..
15 */
16struct resource {
17 const char *name;
18 unsigned long start, end;
19 unsigned long flags;
20 struct resource *parent, *sibling, *child;
21};
22
23struct resource_list {
24 struct resource_list *next;
25 struct resource *res;
26 struct pci_dev *dev;
27};
28
29/*
30 * IO resources have these defined flags.
31 */
32#define IORESOURCE_BITS 0x000000ff /* Bus-specific bits */
33
34#define IORESOURCE_IO 0x00000100 /* Resource type */
35#define IORESOURCE_MEM 0x00000200
36#define IORESOURCE_IRQ 0x00000400
37#define IORESOURCE_DMA 0x00000800
38
39#define IORESOURCE_PREFETCH 0x00001000 /* No side effects */
40#define IORESOURCE_READONLY 0x00002000
41#define IORESOURCE_CACHEABLE 0x00004000
42#define IORESOURCE_RANGELENGTH 0x00008000
43#define IORESOURCE_SHADOWABLE 0x00010000
44#define IORESOURCE_BUS_HAS_VGA 0x00080000
45
46#define IORESOURCE_DISABLED 0x10000000
47#define IORESOURCE_UNSET 0x20000000
48#define IORESOURCE_AUTO 0x40000000
49#define IORESOURCE_BUSY 0x80000000 /* Driver has marked this resource busy */
50
51/* ISA PnP IRQ specific bits (IORESOURCE_BITS) */
52#define IORESOURCE_IRQ_HIGHEDGE (1<<0)
53#define IORESOURCE_IRQ_LOWEDGE (1<<1)
54#define IORESOURCE_IRQ_HIGHLEVEL (1<<2)
55#define IORESOURCE_IRQ_LOWLEVEL (1<<3)
56
57/* ISA PnP DMA specific bits (IORESOURCE_BITS) */
58#define IORESOURCE_DMA_TYPE_MASK (3<<0)
59#define IORESOURCE_DMA_8BIT (0<<0)
60#define IORESOURCE_DMA_8AND16BIT (1<<0)
61#define IORESOURCE_DMA_16BIT (2<<0)
62
63#define IORESOURCE_DMA_MASTER (1<<2)
64#define IORESOURCE_DMA_BYTE (1<<3)
65#define IORESOURCE_DMA_WORD (1<<4)
66
67#define IORESOURCE_DMA_SPEED_MASK (3<<6)
68#define IORESOURCE_DMA_COMPATIBLE (0<<6)
69#define IORESOURCE_DMA_TYPEA (1<<6)
70#define IORESOURCE_DMA_TYPEB (2<<6)
71#define IORESOURCE_DMA_TYPEF (3<<6)
72
73/* ISA PnP memory I/O specific bits (IORESOURCE_BITS) */
74#define IORESOURCE_MEM_WRITEABLE (1<<0) /* dup: IORESOURCE_READONLY */
75#define IORESOURCE_MEM_CACHEABLE (1<<1) /* dup: IORESOURCE_CACHEABLE */
76#define IORESOURCE_MEM_RANGELENGTH (1<<2) /* dup: IORESOURCE_RANGELENGTH */
77#define IORESOURCE_MEM_TYPE_MASK (3<<3)
78#define IORESOURCE_MEM_8BIT (0<<3)
79#define IORESOURCE_MEM_16BIT (1<<3)
80#define IORESOURCE_MEM_8AND16BIT (2<<3)
81#define IORESOURCE_MEM_32BIT (3<<3)
82#define IORESOURCE_MEM_SHADOWABLE (1<<5) /* dup: IORESOURCE_SHADOWABLE */
83#define IORESOURCE_MEM_EXPANSIONROM (1<<6)
84
85/* PCI ROM control bits (IORESOURCE_BITS) */
86#define IORESOURCE_ROM_ENABLE (1<<0) /* ROM is enabled, same as PCI_ROM_ADDRESS_ENABLE */
87#define IORESOURCE_ROM_SHADOW (1<<1) /* ROM is copy at C000:0 */
88#define IORESOURCE_ROM_COPY (1<<2) /* ROM is alloc'd copy, resource field overlaid */
89
90/* PC/ISA/whatever - the normal PC address spaces: IO and memory */
91extern struct resource ioport_resource;
92extern struct resource iomem_resource;
93
94extern int request_resource(struct resource *root, struct resource *new);
95extern struct resource * ____request_resource(struct resource *root, struct resource *new);
96extern int release_resource(struct resource *new);
97extern int insert_resource(struct resource *parent, struct resource *new);
98extern int allocate_resource(struct resource *root, struct resource *new,
99 unsigned long size,
100 unsigned long min, unsigned long max,
101 unsigned long align,
102 void (*alignf)(void *, struct resource *,
103 unsigned long, unsigned long),
104 void *alignf_data);
105int adjust_resource(struct resource *res, unsigned long start,
106 unsigned long size);
107
108/* Convenience shorthand with allocation */
109#define request_region(start,n,name) __request_region(&ioport_resource, (start), (n), (name))
110#define request_mem_region(start,n,name) __request_region(&iomem_resource, (start), (n), (name))
111#define rename_region(region, newname) do { (region)->name = (newname); } while (0)
112
113extern struct resource * __request_region(struct resource *, unsigned long start, unsigned long n, const char *name);
114
115/* Compatibility cruft */
116#define release_region(start,n) __release_region(&ioport_resource, (start), (n))
117#define check_mem_region(start,n) __check_region(&iomem_resource, (start), (n))
118#define release_mem_region(start,n) __release_region(&iomem_resource, (start), (n))
119
120extern int __check_region(struct resource *, unsigned long, unsigned long);
121extern void __release_region(struct resource *, unsigned long, unsigned long);
122
123static inline int __deprecated check_region(unsigned long s, unsigned long n)
124{
125 return __check_region(&ioport_resource, s, n);
126}
127#endif /* _LINUX_IOPORT_H */
diff --git a/include/linux/ip.h b/include/linux/ip.h
new file mode 100644
index 000000000000..8438c68591f9
--- /dev/null
+++ b/include/linux/ip.h
@@ -0,0 +1,221 @@
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Definitions for the IP protocol.
7 *
8 * Version: @(#)ip.h 1.0.2 04/28/93
9 *
10 * Authors: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version
15 * 2 of the License, or (at your option) any later version.
16 */
17#ifndef _LINUX_IP_H
18#define _LINUX_IP_H
19#include <asm/byteorder.h>
20
21#define IPTOS_TOS_MASK 0x1E
22#define IPTOS_TOS(tos) ((tos)&IPTOS_TOS_MASK)
23#define IPTOS_LOWDELAY 0x10
24#define IPTOS_THROUGHPUT 0x08
25#define IPTOS_RELIABILITY 0x04
26#define IPTOS_MINCOST 0x02
27
28#define IPTOS_PREC_MASK 0xE0
29#define IPTOS_PREC(tos) ((tos)&IPTOS_PREC_MASK)
30#define IPTOS_PREC_NETCONTROL 0xe0
31#define IPTOS_PREC_INTERNETCONTROL 0xc0
32#define IPTOS_PREC_CRITIC_ECP 0xa0
33#define IPTOS_PREC_FLASHOVERRIDE 0x80
34#define IPTOS_PREC_FLASH 0x60
35#define IPTOS_PREC_IMMEDIATE 0x40
36#define IPTOS_PREC_PRIORITY 0x20
37#define IPTOS_PREC_ROUTINE 0x00
38
39
40/* IP options */
41#define IPOPT_COPY 0x80
42#define IPOPT_CLASS_MASK 0x60
43#define IPOPT_NUMBER_MASK 0x1f
44
45#define IPOPT_COPIED(o) ((o)&IPOPT_COPY)
46#define IPOPT_CLASS(o) ((o)&IPOPT_CLASS_MASK)
47#define IPOPT_NUMBER(o) ((o)&IPOPT_NUMBER_MASK)
48
49#define IPOPT_CONTROL 0x00
50#define IPOPT_RESERVED1 0x20
51#define IPOPT_MEASUREMENT 0x40
52#define IPOPT_RESERVED2 0x60
53
54#define IPOPT_END (0 |IPOPT_CONTROL)
55#define IPOPT_NOOP (1 |IPOPT_CONTROL)
56#define IPOPT_SEC (2 |IPOPT_CONTROL|IPOPT_COPY)
57#define IPOPT_LSRR (3 |IPOPT_CONTROL|IPOPT_COPY)
58#define IPOPT_TIMESTAMP (4 |IPOPT_MEASUREMENT)
59#define IPOPT_RR (7 |IPOPT_CONTROL)
60#define IPOPT_SID (8 |IPOPT_CONTROL|IPOPT_COPY)
61#define IPOPT_SSRR (9 |IPOPT_CONTROL|IPOPT_COPY)
62#define IPOPT_RA (20|IPOPT_CONTROL|IPOPT_COPY)
63
64#define IPVERSION 4
65#define MAXTTL 255
66#define IPDEFTTL 64
67
68#define IPOPT_OPTVAL 0
69#define IPOPT_OLEN 1
70#define IPOPT_OFFSET 2
71#define IPOPT_MINOFF 4
72#define MAX_IPOPTLEN 40
73#define IPOPT_NOP IPOPT_NOOP
74#define IPOPT_EOL IPOPT_END
75#define IPOPT_TS IPOPT_TIMESTAMP
76
77#define IPOPT_TS_TSONLY 0 /* timestamps only */
78#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
79#define IPOPT_TS_PRESPEC 3 /* specified modules only */
80
81#ifdef __KERNEL__
82#include <linux/config.h>
83#include <linux/types.h>
84#include <net/sock.h>
85#include <linux/igmp.h>
86#include <net/flow.h>
87
88struct ip_options {
89 __u32 faddr; /* Saved first hop address */
90 unsigned char optlen;
91 unsigned char srr;
92 unsigned char rr;
93 unsigned char ts;
94 unsigned char is_setbyuser:1, /* Set by setsockopt? */
95 is_data:1, /* Options in __data, rather than skb */
96 is_strictroute:1, /* Strict source route */
97 srr_is_hit:1, /* Packet destination addr was our one */
98 is_changed:1, /* IP checksum more not valid */
99 rr_needaddr:1, /* Need to record addr of outgoing dev */
100 ts_needtime:1, /* Need to record timestamp */
101 ts_needaddr:1; /* Need to record addr of outgoing dev */
102 unsigned char router_alert;
103 unsigned char __pad1;
104 unsigned char __pad2;
105 unsigned char __data[0];
106};
107
108#define optlength(opt) (sizeof(struct ip_options) + opt->optlen)
109
110struct ipv6_pinfo;
111
112struct inet_sock {
113 /* sk and pinet6 has to be the first two members of inet_sock */
114 struct sock sk;
115#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
116 struct ipv6_pinfo *pinet6;
117#endif
118 /* Socket demultiplex comparisons on incoming packets. */
119 __u32 daddr; /* Foreign IPv4 addr */
120 __u32 rcv_saddr; /* Bound local IPv4 addr */
121 __u16 dport; /* Destination port */
122 __u16 num; /* Local port */
123 __u32 saddr; /* Sending source */
124 __s16 uc_ttl; /* Unicast TTL */
125 __u16 cmsg_flags;
126 struct ip_options *opt;
127 __u16 sport; /* Source port */
128 __u16 id; /* ID counter for DF pkts */
129 __u8 tos; /* TOS */
130 __u8 mc_ttl; /* Multicasting TTL */
131 __u8 pmtudisc;
132 unsigned recverr : 1,
133 freebind : 1,
134 hdrincl : 1,
135 mc_loop : 1;
136 int mc_index; /* Multicast device index */
137 __u32 mc_addr;
138 struct ip_mc_socklist *mc_list; /* Group array */
139 /*
140 * Following members are used to retain the infomation to build
141 * an ip header on each ip fragmentation while the socket is corked.
142 */
143 struct {
144 unsigned int flags;
145 unsigned int fragsize;
146 struct ip_options *opt;
147 struct rtable *rt;
148 int length; /* Total length of all frames */
149 u32 addr;
150 struct flowi fl;
151 } cork;
152};
153
154#define IPCORK_OPT 1 /* ip-options has been held in ipcork.opt */
155#define IPCORK_ALLFRAG 2 /* always fragment (for ipv6 for now) */
156
157static inline struct inet_sock *inet_sk(const struct sock *sk)
158{
159 return (struct inet_sock *)sk;
160}
161
162static inline void __inet_sk_copy_descendant(struct sock *sk_to,
163 const struct sock *sk_from,
164 const int ancestor_size)
165{
166 memcpy(inet_sk(sk_to) + 1, inet_sk(sk_from) + 1,
167 sk_from->sk_prot->obj_size - ancestor_size);
168}
169#if !(defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE))
170static inline void inet_sk_copy_descendant(struct sock *sk_to,
171 const struct sock *sk_from)
172{
173 __inet_sk_copy_descendant(sk_to, sk_from, sizeof(struct inet_sock));
174}
175#endif
176#endif
177
178struct iphdr {
179#if defined(__LITTLE_ENDIAN_BITFIELD)
180 __u8 ihl:4,
181 version:4;
182#elif defined (__BIG_ENDIAN_BITFIELD)
183 __u8 version:4,
184 ihl:4;
185#else
186#error "Please fix <asm/byteorder.h>"
187#endif
188 __u8 tos;
189 __u16 tot_len;
190 __u16 id;
191 __u16 frag_off;
192 __u8 ttl;
193 __u8 protocol;
194 __u16 check;
195 __u32 saddr;
196 __u32 daddr;
197 /*The options start here. */
198};
199
200struct ip_auth_hdr {
201 __u8 nexthdr;
202 __u8 hdrlen; /* This one is measured in 32 bit units! */
203 __u16 reserved;
204 __u32 spi;
205 __u32 seq_no; /* Sequence number */
206 __u8 auth_data[0]; /* Variable len but >=4. Mind the 64 bit alignment! */
207};
208
209struct ip_esp_hdr {
210 __u32 spi;
211 __u32 seq_no; /* Sequence number */
212 __u8 enc_data[0]; /* Variable len but >=8. Mind the 64 bit alignment! */
213};
214
215struct ip_comp_hdr {
216 __u8 nexthdr;
217 __u8 flags;
218 __u16 cpi;
219};
220
221#endif /* _LINUX_IP_H */
diff --git a/include/linux/ip6_tunnel.h b/include/linux/ip6_tunnel.h
new file mode 100644
index 000000000000..5c23aeb104ca
--- /dev/null
+++ b/include/linux/ip6_tunnel.h
@@ -0,0 +1,34 @@
1/*
2 * $Id$
3 */
4
5#ifndef _IP6_TUNNEL_H
6#define _IP6_TUNNEL_H
7
8#define IPV6_TLV_TNL_ENCAP_LIMIT 4
9#define IPV6_DEFAULT_TNL_ENCAP_LIMIT 4
10
11/* don't add encapsulation limit if one isn't present in inner packet */
12#define IP6_TNL_F_IGN_ENCAP_LIMIT 0x1
13/* copy the traffic class field from the inner packet */
14#define IP6_TNL_F_USE_ORIG_TCLASS 0x2
15/* copy the flowlabel from the inner packet */
16#define IP6_TNL_F_USE_ORIG_FLOWLABEL 0x4
17/* being used for Mobile IPv6 */
18#define IP6_TNL_F_MIP6_DEV 0x8
19/* copy DSCP from the outer packet */
20#define IP6_TNL_F_RCV_DSCP_COPY 0x10
21
22struct ip6_tnl_parm {
23 char name[IFNAMSIZ]; /* name of tunnel device */
24 int link; /* ifindex of underlying L2 interface */
25 __u8 proto; /* tunnel protocol */
26 __u8 encap_limit; /* encapsulation limit for tunnel */
27 __u8 hop_limit; /* hop limit for tunnel */
28 __u32 flowinfo; /* traffic class and flowlabel for tunnel */
29 __u32 flags; /* tunnel flags */
30 struct in6_addr laddr; /* local tunnel end-point address */
31 struct in6_addr raddr; /* remote tunnel end-point address */
32};
33
34#endif
diff --git a/include/linux/ip_mp_alg.h b/include/linux/ip_mp_alg.h
new file mode 100644
index 000000000000..e234e2008f5d
--- /dev/null
+++ b/include/linux/ip_mp_alg.h
@@ -0,0 +1,22 @@
1/* ip_mp_alg.h: IPV4 multipath algorithm support, user-visible values.
2 *
3 * Copyright (C) 2004, 2005 Einar Lueck <elueck@de.ibm.com>
4 * Copyright (C) 2005 David S. Miller <davem@davemloft.net>
5 */
6
7#ifndef _LINUX_IP_MP_ALG_H
8#define _LINUX_IP_MP_ALG_H
9
10enum ip_mp_alg {
11 IP_MP_ALG_NONE,
12 IP_MP_ALG_RR,
13 IP_MP_ALG_DRR,
14 IP_MP_ALG_RANDOM,
15 IP_MP_ALG_WRANDOM,
16 __IP_MP_ALG_MAX
17};
18
19#define IP_MP_ALG_MAX (__IP_MP_ALG_MAX - 1)
20
21#endif /* _LINUX_IP_MP_ALG_H */
22
diff --git a/include/linux/ipc.h b/include/linux/ipc.h
new file mode 100644
index 000000000000..b291189737e7
--- /dev/null
+++ b/include/linux/ipc.h
@@ -0,0 +1,75 @@
1#ifndef _LINUX_IPC_H
2#define _LINUX_IPC_H
3
4#include <linux/types.h>
5
6#define IPC_PRIVATE ((__kernel_key_t) 0)
7
8/* Obsolete, used only for backwards compatibility and libc5 compiles */
9struct ipc_perm
10{
11 __kernel_key_t key;
12 __kernel_uid_t uid;
13 __kernel_gid_t gid;
14 __kernel_uid_t cuid;
15 __kernel_gid_t cgid;
16 __kernel_mode_t mode;
17 unsigned short seq;
18};
19
20/* Include the definition of ipc64_perm */
21#include <asm/ipcbuf.h>
22
23/* resource get request flags */
24#define IPC_CREAT 00001000 /* create if key is nonexistent */
25#define IPC_EXCL 00002000 /* fail if key exists */
26#define IPC_NOWAIT 00004000 /* return error on wait */
27
28/* these fields are used by the DIPC package so the kernel as standard
29 should avoid using them if possible */
30
31#define IPC_DIPC 00010000 /* make it distributed */
32#define IPC_OWN 00020000 /* this machine is the DIPC owner */
33
34/*
35 * Control commands used with semctl, msgctl and shmctl
36 * see also specific commands in sem.h, msg.h and shm.h
37 */
38#define IPC_RMID 0 /* remove resource */
39#define IPC_SET 1 /* set ipc_perm options */
40#define IPC_STAT 2 /* get ipc_perm options */
41#define IPC_INFO 3 /* see ipcs */
42
43/*
44 * Version flags for semctl, msgctl, and shmctl commands
45 * These are passed as bitflags or-ed with the actual command
46 */
47#define IPC_OLD 0 /* Old version (no 32-bit UID support on many
48 architectures) */
49#define IPC_64 0x0100 /* New version (support 32-bit UIDs, bigger
50 message sizes, etc. */
51
52#ifdef __KERNEL__
53
54#define IPCMNI 32768 /* <= MAX_INT limit for ipc arrays (including sysctl changes) */
55
56/* used by in-kernel data structures */
57struct kern_ipc_perm
58{
59 spinlock_t lock;
60 int deleted;
61 key_t key;
62 uid_t uid;
63 gid_t gid;
64 uid_t cuid;
65 gid_t cgid;
66 mode_t mode;
67 unsigned long seq;
68 void *security;
69};
70
71#endif /* __KERNEL__ */
72
73#endif /* _LINUX_IPC_H */
74
75
diff --git a/include/linux/ipmi.h b/include/linux/ipmi.h
new file mode 100644
index 000000000000..2ec265e1045f
--- /dev/null
+++ b/include/linux/ipmi.h
@@ -0,0 +1,602 @@
1/*
2 * ipmi.h
3 *
4 * MontaVista IPMI interface
5 *
6 * Author: MontaVista Software, Inc.
7 * Corey Minyard <minyard@mvista.com>
8 * source@mvista.com
9 *
10 * Copyright 2002 MontaVista Software Inc.
11 *
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
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 *
17 *
18 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
19 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
24 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
26 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
27 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * You should have received a copy of the GNU General Public License along
30 * with this program; if not, write to the Free Software Foundation, Inc.,
31 * 675 Mass Ave, Cambridge, MA 02139, USA.
32 */
33
34#ifndef __LINUX_IPMI_H
35#define __LINUX_IPMI_H
36
37#include <linux/ipmi_msgdefs.h>
38
39/*
40 * This file describes an interface to an IPMI driver. You have to
41 * have a fairly good understanding of IPMI to use this, so go read
42 * the specs first before actually trying to do anything.
43 *
44 * With that said, this driver provides a multi-user interface to the
45 * IPMI driver, and it allows multiple IPMI physical interfaces below
46 * the driver. The physical interfaces bind as a lower layer on the
47 * driver. They appear as interfaces to the application using this
48 * interface.
49 *
50 * Multi-user means that multiple applications may use the driver,
51 * send commands, receive responses, etc. The driver keeps track of
52 * commands the user sends and tracks the responses. The responses
53 * will go back to the application that send the command. If the
54 * response doesn't come back in time, the driver will return a
55 * timeout error response to the application. Asynchronous events
56 * from the BMC event queue will go to all users bound to the driver.
57 * The incoming event queue in the BMC will automatically be flushed
58 * if it becomes full and it is queried once a second to see if
59 * anything is in it. Incoming commands to the driver will get
60 * delivered as commands.
61 *
62 * This driver provides two main interfaces: one for in-kernel
63 * applications and another for userland applications. The
64 * capabilities are basically the same for both interface, although
65 * the interfaces are somewhat different. The stuff in the
66 * #ifdef KERNEL below is the in-kernel interface. The userland
67 * interface is defined later in the file. */
68
69
70
71/*
72 * This is an overlay for all the address types, so it's easy to
73 * determine the actual address type. This is kind of like addresses
74 * work for sockets.
75 */
76#define IPMI_MAX_ADDR_SIZE 32
77struct ipmi_addr
78{
79 /* Try to take these from the "Channel Medium Type" table
80 in section 6.5 of the IPMI 1.5 manual. */
81 int addr_type;
82 short channel;
83 char data[IPMI_MAX_ADDR_SIZE];
84};
85
86/*
87 * When the address is not used, the type will be set to this value.
88 * The channel is the BMC's channel number for the channel (usually
89 * 0), or IPMC_BMC_CHANNEL if communicating directly with the BMC.
90 */
91#define IPMI_SYSTEM_INTERFACE_ADDR_TYPE 0x0c
92struct ipmi_system_interface_addr
93{
94 int addr_type;
95 short channel;
96 unsigned char lun;
97};
98
99/* An IPMB Address. */
100#define IPMI_IPMB_ADDR_TYPE 0x01
101/* Used for broadcast get device id as described in section 17.9 of the
102 IPMI 1.5 manual. */
103#define IPMI_IPMB_BROADCAST_ADDR_TYPE 0x41
104struct ipmi_ipmb_addr
105{
106 int addr_type;
107 short channel;
108 unsigned char slave_addr;
109 unsigned char lun;
110};
111
112/*
113 * A LAN Address. This is an address to/from a LAN interface bridged
114 * by the BMC, not an address actually out on the LAN.
115 *
116 * A concious decision was made here to deviate slightly from the IPMI
117 * spec. We do not use rqSWID and rsSWID like it shows in the
118 * message. Instead, we use remote_SWID and local_SWID. This means
119 * that any message (a request or response) from another device will
120 * always have exactly the same address. If you didn't do this,
121 * requests and responses from the same device would have different
122 * addresses, and that's not too cool.
123 *
124 * In this address, the remote_SWID is always the SWID the remote
125 * message came from, or the SWID we are sending the message to.
126 * local_SWID is always our SWID. Note that having our SWID in the
127 * message is a little weird, but this is required.
128 */
129#define IPMI_LAN_ADDR_TYPE 0x04
130struct ipmi_lan_addr
131{
132 int addr_type;
133 short channel;
134 unsigned char privilege;
135 unsigned char session_handle;
136 unsigned char remote_SWID;
137 unsigned char local_SWID;
138 unsigned char lun;
139};
140
141
142/*
143 * Channel for talking directly with the BMC. When using this
144 * channel, This is for the system interface address type only. FIXME
145 * - is this right, or should we use -1?
146 */
147#define IPMI_BMC_CHANNEL 0xf
148#define IPMI_NUM_CHANNELS 0x10
149
150
151/*
152 * A raw IPMI message without any addressing. This covers both
153 * commands and responses. The completion code is always the first
154 * byte of data in the response (as the spec shows the messages laid
155 * out).
156 */
157struct ipmi_msg
158{
159 unsigned char netfn;
160 unsigned char cmd;
161 unsigned short data_len;
162 unsigned char __user *data;
163};
164
165struct kernel_ipmi_msg
166{
167 unsigned char netfn;
168 unsigned char cmd;
169 unsigned short data_len;
170 unsigned char *data;
171};
172
173/*
174 * Various defines that are useful for IPMI applications.
175 */
176#define IPMI_INVALID_CMD_COMPLETION_CODE 0xC1
177#define IPMI_TIMEOUT_COMPLETION_CODE 0xC3
178#define IPMI_UNKNOWN_ERR_COMPLETION_CODE 0xff
179
180
181/*
182 * Receive types for messages coming from the receive interface. This
183 * is used for the receive in-kernel interface and in the receive
184 * IOCTL.
185 *
186 * The "IPMI_RESPONSE_RESPNOSE_TYPE" is a little strange sounding, but
187 * it allows you to get the message results when you send a response
188 * message.
189 */
190#define IPMI_RESPONSE_RECV_TYPE 1 /* A response to a command */
191#define IPMI_ASYNC_EVENT_RECV_TYPE 2 /* Something from the event queue */
192#define IPMI_CMD_RECV_TYPE 3 /* A command from somewhere else */
193#define IPMI_RESPONSE_RESPONSE_TYPE 4 /* The response for
194 a sent response, giving any
195 error status for sending the
196 response. When you send a
197 response message, this will
198 be returned. */
199/* Note that async events and received commands do not have a completion
200 code as the first byte of the incoming data, unlike a response. */
201
202
203
204#ifdef __KERNEL__
205
206/*
207 * The in-kernel interface.
208 */
209#include <linux/list.h>
210#include <linux/module.h>
211
212/* Opaque type for a IPMI message user. One of these is needed to
213 send and receive messages. */
214typedef struct ipmi_user *ipmi_user_t;
215
216/*
217 * Stuff coming from the receive interface comes as one of these.
218 * They are allocated, the receiver must free them with
219 * ipmi_free_recv_msg() when done with the message. The link is not
220 * used after the message is delivered, so the upper layer may use the
221 * link to build a linked list, if it likes.
222 */
223struct ipmi_recv_msg
224{
225 struct list_head link;
226
227 /* The type of message as defined in the "Receive Types"
228 defines above. */
229 int recv_type;
230
231 ipmi_user_t user;
232 struct ipmi_addr addr;
233 long msgid;
234 struct kernel_ipmi_msg msg;
235
236 /* The user_msg_data is the data supplied when a message was
237 sent, if this is a response to a sent message. If this is
238 not a response to a sent message, then user_msg_data will
239 be NULL. */
240 void *user_msg_data;
241
242 /* Call this when done with the message. It will presumably free
243 the message and do any other necessary cleanup. */
244 void (*done)(struct ipmi_recv_msg *msg);
245
246 /* Place-holder for the data, don't make any assumptions about
247 the size or existance of this, since it may change. */
248 unsigned char msg_data[IPMI_MAX_MSG_LENGTH];
249};
250
251/* Allocate and free the receive message. */
252static inline void ipmi_free_recv_msg(struct ipmi_recv_msg *msg)
253{
254 msg->done(msg);
255}
256
257struct ipmi_user_hndl
258{
259 /* Routine type to call when a message needs to be routed to
260 the upper layer. This will be called with some locks held,
261 the only IPMI routines that can be called are ipmi_request
262 and the alloc/free operations. The handler_data is the
263 variable supplied when the receive handler was registered. */
264 void (*ipmi_recv_hndl)(struct ipmi_recv_msg *msg,
265 void *user_msg_data);
266
267 /* Called when the interface detects a watchdog pre-timeout. If
268 this is NULL, it will be ignored for the user. */
269 void (*ipmi_watchdog_pretimeout)(void *handler_data);
270};
271
272/* Create a new user of the IPMI layer on the given interface number. */
273int ipmi_create_user(unsigned int if_num,
274 struct ipmi_user_hndl *handler,
275 void *handler_data,
276 ipmi_user_t *user);
277
278/* Destroy the given user of the IPMI layer. Note that after this
279 function returns, the system is guaranteed to not call any
280 callbacks for the user. Thus as long as you destroy all the users
281 before you unload a module, you will be safe. And if you destroy
282 the users before you destroy the callback structures, it should be
283 safe, too. */
284int ipmi_destroy_user(ipmi_user_t user);
285
286/* Get the IPMI version of the BMC we are talking to. */
287void ipmi_get_version(ipmi_user_t user,
288 unsigned char *major,
289 unsigned char *minor);
290
291/* Set and get the slave address and LUN that we will use for our
292 source messages. Note that this affects the interface, not just
293 this user, so it will affect all users of this interface. This is
294 so some initialization code can come in and do the OEM-specific
295 things it takes to determine your address (if not the BMC) and set
296 it for everyone else. */
297void ipmi_set_my_address(ipmi_user_t user,
298 unsigned char address);
299unsigned char ipmi_get_my_address(ipmi_user_t user);
300void ipmi_set_my_LUN(ipmi_user_t user,
301 unsigned char LUN);
302unsigned char ipmi_get_my_LUN(ipmi_user_t user);
303
304/*
305 * Like ipmi_request, but lets you specify the number of retries and
306 * the retry time. The retries is the number of times the message
307 * will be resent if no reply is received. If set to -1, the default
308 * value will be used. The retry time is the time in milliseconds
309 * between retries. If set to zero, the default value will be
310 * used.
311 *
312 * Don't use this unless you *really* have to. It's primarily for the
313 * IPMI over LAN converter; since the LAN stuff does its own retries,
314 * it makes no sense to do it here. However, this can be used if you
315 * have unusual requirements.
316 */
317int ipmi_request_settime(ipmi_user_t user,
318 struct ipmi_addr *addr,
319 long msgid,
320 struct kernel_ipmi_msg *msg,
321 void *user_msg_data,
322 int priority,
323 int max_retries,
324 unsigned int retry_time_ms);
325
326/*
327 * Like ipmi_request, but with messages supplied. This will not
328 * allocate any memory, and the messages may be statically allocated
329 * (just make sure to do the "done" handling on them). Note that this
330 * is primarily for the watchdog timer, since it should be able to
331 * send messages even if no memory is available. This is subject to
332 * change as the system changes, so don't use it unless you REALLY
333 * have to.
334 */
335int ipmi_request_supply_msgs(ipmi_user_t user,
336 struct ipmi_addr *addr,
337 long msgid,
338 struct kernel_ipmi_msg *msg,
339 void *user_msg_data,
340 void *supplied_smi,
341 struct ipmi_recv_msg *supplied_recv,
342 int priority);
343
344/*
345 * When commands come in to the SMS, the user can register to receive
346 * them. Only one user can be listening on a specific netfn/cmd pair
347 * at a time, you will get an EBUSY error if the command is already
348 * registered. If a command is received that does not have a user
349 * registered, the driver will automatically return the proper
350 * error.
351 */
352int ipmi_register_for_cmd(ipmi_user_t user,
353 unsigned char netfn,
354 unsigned char cmd);
355int ipmi_unregister_for_cmd(ipmi_user_t user,
356 unsigned char netfn,
357 unsigned char cmd);
358
359/*
360 * Allow run-to-completion mode to be set for the interface of
361 * a specific user.
362 */
363void ipmi_user_set_run_to_completion(ipmi_user_t user, int val);
364
365/*
366 * When the user is created, it will not receive IPMI events by
367 * default. The user must set this to TRUE to get incoming events.
368 * The first user that sets this to TRUE will receive all events that
369 * have been queued while no one was waiting for events.
370 */
371int ipmi_set_gets_events(ipmi_user_t user, int val);
372
373/*
374 * Called when a new SMI is registered. This will also be called on
375 * every existing interface when a new watcher is registered with
376 * ipmi_smi_watcher_register().
377 */
378struct ipmi_smi_watcher
379{
380 struct list_head link;
381
382 /* You must set the owner to the current module, if you are in
383 a module (generally just set it to "THIS_MODULE"). */
384 struct module *owner;
385
386 /* These two are called with read locks held for the interface
387 the watcher list. So you can add and remove users from the
388 IPMI interface, send messages, etc., but you cannot add
389 or remove SMI watchers or SMI interfaces. */
390 void (*new_smi)(int if_num);
391 void (*smi_gone)(int if_num);
392};
393
394int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher);
395int ipmi_smi_watcher_unregister(struct ipmi_smi_watcher *watcher);
396
397/* The following are various helper functions for dealing with IPMI
398 addresses. */
399
400/* Return the maximum length of an IPMI address given it's type. */
401unsigned int ipmi_addr_length(int addr_type);
402
403/* Validate that the given IPMI address is valid. */
404int ipmi_validate_addr(struct ipmi_addr *addr, int len);
405
406#endif /* __KERNEL__ */
407
408
409/*
410 * The userland interface
411 */
412
413/*
414 * The userland interface for the IPMI driver is a standard character
415 * device, with each instance of an interface registered as a minor
416 * number under the major character device.
417 *
418 * The read and write calls do not work, to get messages in and out
419 * requires ioctl calls because of the complexity of the data. select
420 * and poll do work, so you can wait for input using the file
421 * descriptor, you just can use read to get it.
422 *
423 * In general, you send a command down to the interface and receive
424 * responses back. You can use the msgid value to correlate commands
425 * and responses, the driver will take care of figuring out which
426 * incoming messages are for which command and find the proper msgid
427 * value to report. You will only receive reponses for commands you
428 * send. Asynchronous events, however, go to all open users, so you
429 * must be ready to handle these (or ignore them if you don't care).
430 *
431 * The address type depends upon the channel type. When talking
432 * directly to the BMC (IPMC_BMC_CHANNEL), the address is ignored
433 * (IPMI_UNUSED_ADDR_TYPE). When talking to an IPMB channel, you must
434 * supply a valid IPMB address with the addr_type set properly.
435 *
436 * When talking to normal channels, the driver takes care of the
437 * details of formatting and sending messages on that channel. You do
438 * not, for instance, have to format a send command, you just send
439 * whatever command you want to the channel, the driver will create
440 * the send command, automatically issue receive command and get even
441 * commands, and pass those up to the proper user.
442 */
443
444
445/* The magic IOCTL value for this interface. */
446#define IPMI_IOC_MAGIC 'i'
447
448
449/* Messages sent to the interface are this format. */
450struct ipmi_req
451{
452 unsigned char __user *addr; /* Address to send the message to. */
453 unsigned int addr_len;
454
455 long msgid; /* The sequence number for the message. This
456 exact value will be reported back in the
457 response to this request if it is a command.
458 If it is a response, this will be used as
459 the sequence value for the response. */
460
461 struct ipmi_msg msg;
462};
463/*
464 * Send a message to the interfaces. error values are:
465 * - EFAULT - an address supplied was invalid.
466 * - EINVAL - The address supplied was not valid, or the command
467 * was not allowed.
468 * - EMSGSIZE - The message to was too large.
469 * - ENOMEM - Buffers could not be allocated for the command.
470 */
471#define IPMICTL_SEND_COMMAND _IOR(IPMI_IOC_MAGIC, 13, \
472 struct ipmi_req)
473
474/* Messages sent to the interface with timing parameters are this
475 format. */
476struct ipmi_req_settime
477{
478 struct ipmi_req req;
479
480 /* See ipmi_request_settime() above for details on these
481 values. */
482 int retries;
483 unsigned int retry_time_ms;
484};
485/*
486 * Send a message to the interfaces with timing parameters. error values
487 * are:
488 * - EFAULT - an address supplied was invalid.
489 * - EINVAL - The address supplied was not valid, or the command
490 * was not allowed.
491 * - EMSGSIZE - The message to was too large.
492 * - ENOMEM - Buffers could not be allocated for the command.
493 */
494#define IPMICTL_SEND_COMMAND_SETTIME _IOR(IPMI_IOC_MAGIC, 21, \
495 struct ipmi_req_settime)
496
497/* Messages received from the interface are this format. */
498struct ipmi_recv
499{
500 int recv_type; /* Is this a command, response or an
501 asyncronous event. */
502
503 unsigned char __user *addr; /* Address the message was from is put
504 here. The caller must supply the
505 memory. */
506 unsigned int addr_len; /* The size of the address buffer.
507 The caller supplies the full buffer
508 length, this value is updated to
509 the actual message length when the
510 message is received. */
511
512 long msgid; /* The sequence number specified in the request
513 if this is a response. If this is a command,
514 this will be the sequence number from the
515 command. */
516
517 struct ipmi_msg msg; /* The data field must point to a buffer.
518 The data_size field must be set to the
519 size of the message buffer. The
520 caller supplies the full buffer
521 length, this value is updated to the
522 actual message length when the message
523 is received. */
524};
525
526/*
527 * Receive a message. error values:
528 * - EAGAIN - no messages in the queue.
529 * - EFAULT - an address supplied was invalid.
530 * - EINVAL - The address supplied was not valid.
531 * - EMSGSIZE - The message to was too large to fit into the message buffer,
532 * the message will be left in the buffer. */
533#define IPMICTL_RECEIVE_MSG _IOWR(IPMI_IOC_MAGIC, 12, \
534 struct ipmi_recv)
535
536/*
537 * Like RECEIVE_MSG, but if the message won't fit in the buffer, it
538 * will truncate the contents instead of leaving the data in the
539 * buffer.
540 */
541#define IPMICTL_RECEIVE_MSG_TRUNC _IOWR(IPMI_IOC_MAGIC, 11, \
542 struct ipmi_recv)
543
544/* Register to get commands from other entities on this interface. */
545struct ipmi_cmdspec
546{
547 unsigned char netfn;
548 unsigned char cmd;
549};
550
551/*
552 * Register to receive a specific command. error values:
553 * - EFAULT - an address supplied was invalid.
554 * - EBUSY - The netfn/cmd supplied was already in use.
555 * - ENOMEM - could not allocate memory for the entry.
556 */
557#define IPMICTL_REGISTER_FOR_CMD _IOR(IPMI_IOC_MAGIC, 14, \
558 struct ipmi_cmdspec)
559/*
560 * Unregister a regsitered command. error values:
561 * - EFAULT - an address supplied was invalid.
562 * - ENOENT - The netfn/cmd was not found registered for this user.
563 */
564#define IPMICTL_UNREGISTER_FOR_CMD _IOR(IPMI_IOC_MAGIC, 15, \
565 struct ipmi_cmdspec)
566
567/*
568 * Set whether this interface receives events. Note that the first
569 * user registered for events will get all pending events for the
570 * interface. error values:
571 * - EFAULT - an address supplied was invalid.
572 */
573#define IPMICTL_SET_GETS_EVENTS_CMD _IOR(IPMI_IOC_MAGIC, 16, int)
574
575/*
576 * Set and get the slave address and LUN that we will use for our
577 * source messages. Note that this affects the interface, not just
578 * this user, so it will affect all users of this interface. This is
579 * so some initialization code can come in and do the OEM-specific
580 * things it takes to determine your address (if not the BMC) and set
581 * it for everyone else. You should probably leave the LUN alone.
582 */
583#define IPMICTL_SET_MY_ADDRESS_CMD _IOR(IPMI_IOC_MAGIC, 17, unsigned int)
584#define IPMICTL_GET_MY_ADDRESS_CMD _IOR(IPMI_IOC_MAGIC, 18, unsigned int)
585#define IPMICTL_SET_MY_LUN_CMD _IOR(IPMI_IOC_MAGIC, 19, unsigned int)
586#define IPMICTL_GET_MY_LUN_CMD _IOR(IPMI_IOC_MAGIC, 20, unsigned int)
587
588/*
589 * Get/set the default timing values for an interface. You shouldn't
590 * generally mess with these.
591 */
592struct ipmi_timing_parms
593{
594 int retries;
595 unsigned int retry_time_ms;
596};
597#define IPMICTL_SET_TIMING_PARMS_CMD _IOR(IPMI_IOC_MAGIC, 22, \
598 struct ipmi_timing_parms)
599#define IPMICTL_GET_TIMING_PARMS_CMD _IOR(IPMI_IOC_MAGIC, 23, \
600 struct ipmi_timing_parms)
601
602#endif /* __LINUX_IPMI_H */
diff --git a/include/linux/ipmi_msgdefs.h b/include/linux/ipmi_msgdefs.h
new file mode 100644
index 000000000000..03bc64dc2ec1
--- /dev/null
+++ b/include/linux/ipmi_msgdefs.h
@@ -0,0 +1,101 @@
1/*
2 * ipmi_smi.h
3 *
4 * MontaVista IPMI system management interface
5 *
6 * Author: MontaVista Software, Inc.
7 * Corey Minyard <minyard@mvista.com>
8 * source@mvista.com
9 *
10 * Copyright 2002 MontaVista Software Inc.
11 *
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
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 *
17 *
18 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
19 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
24 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
26 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
27 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * You should have received a copy of the GNU General Public License along
30 * with this program; if not, write to the Free Software Foundation, Inc.,
31 * 675 Mass Ave, Cambridge, MA 02139, USA.
32 */
33
34#ifndef __LINUX_IPMI_MSGDEFS_H
35#define __LINUX_IPMI_MSGDEFS_H
36
37/* Various definitions for IPMI messages used by almost everything in
38 the IPMI stack. */
39
40/* NetFNs and commands used inside the IPMI stack. */
41
42#define IPMI_NETFN_SENSOR_EVENT_REQUEST 0x04
43#define IPMI_NETFN_SENSOR_EVENT_RESPONSE 0x05
44#define IPMI_GET_EVENT_RECEIVER_CMD 0x01
45
46#define IPMI_NETFN_APP_REQUEST 0x06
47#define IPMI_NETFN_APP_RESPONSE 0x07
48#define IPMI_GET_DEVICE_ID_CMD 0x01
49#define IPMI_CLEAR_MSG_FLAGS_CMD 0x30
50#define IPMI_GET_MSG_FLAGS_CMD 0x31
51#define IPMI_SEND_MSG_CMD 0x34
52#define IPMI_GET_MSG_CMD 0x33
53#define IPMI_SET_BMC_GLOBAL_ENABLES_CMD 0x2e
54#define IPMI_GET_BMC_GLOBAL_ENABLES_CMD 0x2f
55#define IPMI_READ_EVENT_MSG_BUFFER_CMD 0x35
56#define IPMI_GET_CHANNEL_INFO_CMD 0x42
57
58#define IPMI_NETFN_STORAGE_REQUEST 0x0a
59#define IPMI_NETFN_STORAGE_RESPONSE 0x0b
60#define IPMI_ADD_SEL_ENTRY_CMD 0x44
61
62/* The default slave address */
63#define IPMI_BMC_SLAVE_ADDR 0x20
64
65/* The BT interface on high-end HP systems supports up to 255 bytes in
66 * one transfer. Its "virtual" BMC supports some commands that are longer
67 * than 128 bytes. Use the full 256, plus NetFn/LUN, Cmd, cCode, plus
68 * some overhead. It would be nice to base this on the "BT Capabilities"
69 * but that's too hard to propagate to the rest of the driver. */
70#define IPMI_MAX_MSG_LENGTH 272 /* multiple of 16 */
71
72#define IPMI_CC_NO_ERROR 0x00
73#define IPMI_NODE_BUSY_ERR 0xc0
74#define IPMI_INVALID_COMMAND_ERR 0xc1
75#define IPMI_ERR_MSG_TRUNCATED 0xc6
76#define IPMI_LOST_ARBITRATION_ERR 0x81
77#define IPMI_ERR_UNSPECIFIED 0xff
78
79#define IPMI_CHANNEL_PROTOCOL_IPMB 1
80#define IPMI_CHANNEL_PROTOCOL_ICMB 2
81#define IPMI_CHANNEL_PROTOCOL_SMBUS 4
82#define IPMI_CHANNEL_PROTOCOL_KCS 5
83#define IPMI_CHANNEL_PROTOCOL_SMIC 6
84#define IPMI_CHANNEL_PROTOCOL_BT10 7
85#define IPMI_CHANNEL_PROTOCOL_BT15 8
86#define IPMI_CHANNEL_PROTOCOL_TMODE 9
87
88#define IPMI_CHANNEL_MEDIUM_IPMB 1
89#define IPMI_CHANNEL_MEDIUM_ICMB10 2
90#define IPMI_CHANNEL_MEDIUM_ICMB09 3
91#define IPMI_CHANNEL_MEDIUM_8023LAN 4
92#define IPMI_CHANNEL_MEDIUM_ASYNC 5
93#define IPMI_CHANNEL_MEDIUM_OTHER_LAN 6
94#define IPMI_CHANNEL_MEDIUM_PCI_SMBUS 7
95#define IPMI_CHANNEL_MEDIUM_SMBUS1 8
96#define IPMI_CHANNEL_MEDIUM_SMBUS2 9
97#define IPMI_CHANNEL_MEDIUM_USB1 10
98#define IPMI_CHANNEL_MEDIUM_USB2 11
99#define IPMI_CHANNEL_MEDIUM_SYSINTF 12
100
101#endif /* __LINUX_IPMI_MSGDEFS_H */
diff --git a/include/linux/ipmi_smi.h b/include/linux/ipmi_smi.h
new file mode 100644
index 000000000000..e36ee157ad67
--- /dev/null
+++ b/include/linux/ipmi_smi.h
@@ -0,0 +1,156 @@
1/*
2 * ipmi_smi.h
3 *
4 * MontaVista IPMI system management interface
5 *
6 * Author: MontaVista Software, Inc.
7 * Corey Minyard <minyard@mvista.com>
8 * source@mvista.com
9 *
10 * Copyright 2002 MontaVista Software Inc.
11 *
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
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 *
17 *
18 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
19 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
24 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
26 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
27 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * You should have received a copy of the GNU General Public License along
30 * with this program; if not, write to the Free Software Foundation, Inc.,
31 * 675 Mass Ave, Cambridge, MA 02139, USA.
32 */
33
34#ifndef __LINUX_IPMI_SMI_H
35#define __LINUX_IPMI_SMI_H
36
37#include <linux/ipmi_msgdefs.h>
38#include <linux/proc_fs.h>
39#include <linux/module.h>
40
41/* This files describes the interface for IPMI system management interface
42 drivers to bind into the IPMI message handler. */
43
44/* Structure for the low-level drivers. */
45typedef struct ipmi_smi *ipmi_smi_t;
46
47/*
48 * Messages to/from the lower layer. The smi interface will take one
49 * of these to send. After the send has occurred and a response has
50 * been received, it will report this same data structure back up to
51 * the upper layer. If an error occurs, it should fill in the
52 * response with an error code in the completion code location. When
53 * asynchronous data is received, one of these is allocated, the
54 * data_size is set to zero and the response holds the data from the
55 * get message or get event command that the interface initiated.
56 * Note that it is the interfaces responsibility to detect
57 * asynchronous data and messages and request them from the
58 * interface.
59 */
60struct ipmi_smi_msg
61{
62 struct list_head link;
63
64 long msgid;
65 void *user_data;
66
67 int data_size;
68 unsigned char data[IPMI_MAX_MSG_LENGTH];
69
70 int rsp_size;
71 unsigned char rsp[IPMI_MAX_MSG_LENGTH];
72
73 /* Will be called when the system is done with the message
74 (presumably to free it). */
75 void (*done)(struct ipmi_smi_msg *msg);
76};
77
78struct ipmi_smi_handlers
79{
80 struct module *owner;
81
82 /* Called to enqueue an SMI message to be sent. This
83 operation is not allowed to fail. If an error occurs, it
84 should report back the error in a received message. It may
85 do this in the current call context, since no write locks
86 are held when this is run. If the priority is > 0, the
87 message will go into a high-priority queue and be sent
88 first. Otherwise, it goes into a normal-priority queue. */
89 void (*sender)(void *send_info,
90 struct ipmi_smi_msg *msg,
91 int priority);
92
93 /* Called by the upper layer to request that we try to get
94 events from the BMC we are attached to. */
95 void (*request_events)(void *send_info);
96
97 /* Called when the interface should go into "run to
98 completion" mode. If this call sets the value to true, the
99 interface should make sure that all messages are flushed
100 out and that none are pending, and any new requests are run
101 to completion immediately. */
102 void (*set_run_to_completion)(void *send_info, int run_to_completion);
103
104 /* Called to poll for work to do. This is so upper layers can
105 poll for operations during things like crash dumps. */
106 void (*poll)(void *send_info);
107
108 /* Tell the handler that we are using it/not using it. The
109 message handler get the modules that this handler belongs
110 to; this function lets the SMI claim any modules that it
111 uses. These may be NULL if this is not required. */
112 int (*inc_usecount)(void *send_info);
113 void (*dec_usecount)(void *send_info);
114};
115
116/* Add a low-level interface to the IPMI driver. Note that if the
117 interface doesn't know its slave address, it should pass in zero. */
118int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
119 void *send_info,
120 unsigned char version_major,
121 unsigned char version_minor,
122 unsigned char slave_addr,
123 ipmi_smi_t *intf);
124
125/*
126 * Remove a low-level interface from the IPMI driver. This will
127 * return an error if the interface is still in use by a user.
128 */
129int ipmi_unregister_smi(ipmi_smi_t intf);
130
131/*
132 * The lower layer reports received messages through this interface.
133 * The data_size should be zero if this is an asyncronous message. If
134 * the lower layer gets an error sending a message, it should format
135 * an error response in the message response.
136 */
137void ipmi_smi_msg_received(ipmi_smi_t intf,
138 struct ipmi_smi_msg *msg);
139
140/* The lower layer received a watchdog pre-timeout on interface. */
141void ipmi_smi_watchdog_pretimeout(ipmi_smi_t intf);
142
143struct ipmi_smi_msg *ipmi_alloc_smi_msg(void);
144static inline void ipmi_free_smi_msg(struct ipmi_smi_msg *msg)
145{
146 msg->done(msg);
147}
148
149/* Allow the lower layer to add things to the proc filesystem
150 directory for this interface. Note that the entry will
151 automatically be dstroyed when the interface is destroyed. */
152int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name,
153 read_proc_t *read_proc, write_proc_t *write_proc,
154 void *data, struct module *owner);
155
156#endif /* __LINUX_IPMI_SMI_H */
diff --git a/include/linux/ipsec.h b/include/linux/ipsec.h
new file mode 100644
index 000000000000..d3c527616b5e
--- /dev/null
+++ b/include/linux/ipsec.h
@@ -0,0 +1,46 @@
1#ifndef _LINUX_IPSEC_H
2#define _LINUX_IPSEC_H
3
4/* The definitions, required to talk to KAME racoon IKE. */
5
6#include <linux/pfkeyv2.h>
7
8#define IPSEC_PORT_ANY 0
9#define IPSEC_ULPROTO_ANY 255
10#define IPSEC_PROTO_ANY 255
11
12enum {
13 IPSEC_MODE_ANY = 0, /* We do not support this for SA */
14 IPSEC_MODE_TRANSPORT = 1,
15 IPSEC_MODE_TUNNEL = 2
16};
17
18enum {
19 IPSEC_DIR_ANY = 0,
20 IPSEC_DIR_INBOUND = 1,
21 IPSEC_DIR_OUTBOUND = 2,
22 IPSEC_DIR_FWD = 3, /* It is our own */
23 IPSEC_DIR_MAX = 4,
24 IPSEC_DIR_INVALID = 5
25};
26
27enum {
28 IPSEC_POLICY_DISCARD = 0,
29 IPSEC_POLICY_NONE = 1,
30 IPSEC_POLICY_IPSEC = 2,
31 IPSEC_POLICY_ENTRUST = 3,
32 IPSEC_POLICY_BYPASS = 4
33};
34
35enum {
36 IPSEC_LEVEL_DEFAULT = 0,
37 IPSEC_LEVEL_USE = 1,
38 IPSEC_LEVEL_REQUIRE = 2,
39 IPSEC_LEVEL_UNIQUE = 3
40};
41
42#define IPSEC_MANUAL_REQID_MAX 0x3fff
43
44#define IPSEC_REPLAYWSIZE 32
45
46#endif /* _LINUX_IPSEC_H */
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
new file mode 100644
index 000000000000..ab0d0efbf240
--- /dev/null
+++ b/include/linux/ipv6.h
@@ -0,0 +1,316 @@
1#ifndef _IPV6_H
2#define _IPV6_H
3
4#include <linux/config.h>
5#include <linux/in6.h>
6#include <asm/byteorder.h>
7
8/* The latest drafts declared increase in minimal mtu up to 1280. */
9
10#define IPV6_MIN_MTU 1280
11
12/*
13 * Advanced API
14 * source interface/address selection, source routing, etc...
15 * *under construction*
16 */
17
18
19struct in6_pktinfo {
20 struct in6_addr ipi6_addr;
21 int ipi6_ifindex;
22};
23
24
25struct in6_ifreq {
26 struct in6_addr ifr6_addr;
27 __u32 ifr6_prefixlen;
28 int ifr6_ifindex;
29};
30
31#define IPV6_SRCRT_STRICT 0x01 /* this hop must be a neighbor */
32#define IPV6_SRCRT_TYPE_0 0 /* IPv6 type 0 Routing Header */
33
34/*
35 * routing header
36 */
37struct ipv6_rt_hdr {
38 __u8 nexthdr;
39 __u8 hdrlen;
40 __u8 type;
41 __u8 segments_left;
42
43 /*
44 * type specific data
45 * variable length field
46 */
47};
48
49
50struct ipv6_opt_hdr {
51 __u8 nexthdr;
52 __u8 hdrlen;
53 /*
54 * TLV encoded option data follows.
55 */
56};
57
58#define ipv6_destopt_hdr ipv6_opt_hdr
59#define ipv6_hopopt_hdr ipv6_opt_hdr
60
61#ifdef __KERNEL__
62#define ipv6_optlen(p) (((p)->hdrlen+1) << 3)
63#endif
64
65/*
66 * routing header type 0 (used in cmsghdr struct)
67 */
68
69struct rt0_hdr {
70 struct ipv6_rt_hdr rt_hdr;
71 __u32 bitmap; /* strict/loose bit map */
72 struct in6_addr addr[0];
73
74#define rt0_type rt_hdr.type
75};
76
77struct ipv6_auth_hdr {
78 __u8 nexthdr;
79 __u8 hdrlen; /* This one is measured in 32 bit units! */
80 __u16 reserved;
81 __u32 spi;
82 __u32 seq_no; /* Sequence number */
83 __u8 auth_data[0]; /* Length variable but >=4. Mind the 64 bit alignment! */
84};
85
86struct ipv6_esp_hdr {
87 __u32 spi;
88 __u32 seq_no; /* Sequence number */
89 __u8 enc_data[0]; /* Length variable but >=8. Mind the 64 bit alignment! */
90};
91
92struct ipv6_comp_hdr {
93 __u8 nexthdr;
94 __u8 flags;
95 __u16 cpi;
96};
97
98/*
99 * IPv6 fixed header
100 *
101 * BEWARE, it is incorrect. The first 4 bits of flow_lbl
102 * are glued to priority now, forming "class".
103 */
104
105struct ipv6hdr {
106#if defined(__LITTLE_ENDIAN_BITFIELD)
107 __u8 priority:4,
108 version:4;
109#elif defined(__BIG_ENDIAN_BITFIELD)
110 __u8 version:4,
111 priority:4;
112#else
113#error "Please fix <asm/byteorder.h>"
114#endif
115 __u8 flow_lbl[3];
116
117 __u16 payload_len;
118 __u8 nexthdr;
119 __u8 hop_limit;
120
121 struct in6_addr saddr;
122 struct in6_addr daddr;
123};
124
125/*
126 * This structure contains configuration options per IPv6 link.
127 */
128struct ipv6_devconf {
129 __s32 forwarding;
130 __s32 hop_limit;
131 __s32 mtu6;
132 __s32 accept_ra;
133 __s32 accept_redirects;
134 __s32 autoconf;
135 __s32 dad_transmits;
136 __s32 rtr_solicits;
137 __s32 rtr_solicit_interval;
138 __s32 rtr_solicit_delay;
139 __s32 force_mld_version;
140#ifdef CONFIG_IPV6_PRIVACY
141 __s32 use_tempaddr;
142 __s32 temp_valid_lft;
143 __s32 temp_prefered_lft;
144 __s32 regen_max_retry;
145 __s32 max_desync_factor;
146#endif
147 __s32 max_addresses;
148 void *sysctl;
149};
150
151/* index values for the variables in ipv6_devconf */
152enum {
153 DEVCONF_FORWARDING = 0,
154 DEVCONF_HOPLIMIT,
155 DEVCONF_MTU6,
156 DEVCONF_ACCEPT_RA,
157 DEVCONF_ACCEPT_REDIRECTS,
158 DEVCONF_AUTOCONF,
159 DEVCONF_DAD_TRANSMITS,
160 DEVCONF_RTR_SOLICITS,
161 DEVCONF_RTR_SOLICIT_INTERVAL,
162 DEVCONF_RTR_SOLICIT_DELAY,
163 DEVCONF_USE_TEMPADDR,
164 DEVCONF_TEMP_VALID_LFT,
165 DEVCONF_TEMP_PREFERED_LFT,
166 DEVCONF_REGEN_MAX_RETRY,
167 DEVCONF_MAX_DESYNC_FACTOR,
168 DEVCONF_MAX_ADDRESSES,
169 DEVCONF_FORCE_MLD_VERSION,
170 DEVCONF_MAX
171};
172
173#ifdef __KERNEL__
174#include <linux/in6.h> /* struct sockaddr_in6 */
175#include <linux/icmpv6.h>
176#include <net/if_inet6.h> /* struct ipv6_mc_socklist */
177#include <linux/tcp.h>
178#include <linux/udp.h>
179
180/*
181 This structure contains results of exthdrs parsing
182 as offsets from skb->nh.
183 */
184
185struct inet6_skb_parm {
186 int iif;
187 __u16 ra;
188 __u16 hop;
189 __u16 dst0;
190 __u16 srcrt;
191 __u16 dst1;
192};
193
194#define IP6CB(skb) ((struct inet6_skb_parm*)((skb)->cb))
195
196/**
197 * struct ipv6_pinfo - ipv6 private area
198 *
199 * In the struct sock hierarchy (tcp6_sock, upd6_sock, etc)
200 * this _must_ be the last member, so that inet6_sk_generic
201 * is able to calculate its offset from the base struct sock
202 * by using the struct proto->slab_obj_size member. -acme
203 */
204struct ipv6_pinfo {
205 struct in6_addr saddr;
206 struct in6_addr rcv_saddr;
207 struct in6_addr daddr;
208 struct in6_addr *daddr_cache;
209
210 __u32 flow_label;
211 __u32 frag_size;
212 __s16 hop_limit;
213 __s16 mcast_hops;
214 int mcast_oif;
215
216 /* pktoption flags */
217 union {
218 struct {
219 __u8 srcrt:2,
220 rxinfo:1,
221 rxhlim:1,
222 hopopts:1,
223 dstopts:1,
224 rxflow:1;
225 } bits;
226 __u8 all;
227 } rxopt;
228
229 /* sockopt flags */
230 __u8 mc_loop:1,
231 recverr:1,
232 sndflow:1,
233 pmtudisc:2,
234 ipv6only:1;
235
236 __u32 dst_cookie;
237
238 struct ipv6_mc_socklist *ipv6_mc_list;
239 struct ipv6_ac_socklist *ipv6_ac_list;
240 struct ipv6_fl_socklist *ipv6_fl_list;
241
242 struct ipv6_txoptions *opt;
243 struct sk_buff *pktoptions;
244 struct {
245 struct ipv6_txoptions *opt;
246 struct rt6_info *rt;
247 int hop_limit;
248 } cork;
249};
250
251/* WARNING: don't change the layout of the members in {raw,udp,tcp}6_sock! */
252struct raw6_sock {
253 /* inet_sock has to be the first member of raw6_sock */
254 struct inet_sock inet;
255 __u32 checksum; /* perform checksum */
256 __u32 offset; /* checksum offset */
257 struct icmp6_filter filter;
258 /* ipv6_pinfo has to be the last member of raw6_sock, see inet6_sk_generic */
259 struct ipv6_pinfo inet6;
260};
261
262struct udp6_sock {
263 struct udp_sock udp;
264 /* ipv6_pinfo has to be the last member of udp6_sock, see inet6_sk_generic */
265 struct ipv6_pinfo inet6;
266};
267
268struct tcp6_sock {
269 struct tcp_sock tcp;
270 /* ipv6_pinfo has to be the last member of tcp6_sock, see inet6_sk_generic */
271 struct ipv6_pinfo inet6;
272};
273
274#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
275static inline struct ipv6_pinfo * inet6_sk(const struct sock *__sk)
276{
277 return inet_sk(__sk)->pinet6;
278}
279
280static inline struct raw6_sock *raw6_sk(const struct sock *sk)
281{
282 return (struct raw6_sock *)sk;
283}
284
285static inline void inet_sk_copy_descendant(struct sock *sk_to,
286 const struct sock *sk_from)
287{
288 int ancestor_size = sizeof(struct inet_sock);
289
290 if (sk_from->sk_family == PF_INET6)
291 ancestor_size += sizeof(struct ipv6_pinfo);
292
293 __inet_sk_copy_descendant(sk_to, sk_from, ancestor_size);
294}
295
296#define __ipv6_only_sock(sk) (inet6_sk(sk)->ipv6only)
297#define ipv6_only_sock(sk) ((sk)->sk_family == PF_INET6 && __ipv6_only_sock(sk))
298#else
299#define __ipv6_only_sock(sk) 0
300#define ipv6_only_sock(sk) 0
301
302static inline struct ipv6_pinfo * inet6_sk(const struct sock *__sk)
303{
304 return NULL;
305}
306
307static inline struct raw6_sock *raw6_sk(const struct sock *sk)
308{
309 return NULL;
310}
311
312#endif
313
314#endif
315
316#endif
diff --git a/include/linux/ipv6_route.h b/include/linux/ipv6_route.h
new file mode 100644
index 000000000000..e2f935038013
--- /dev/null
+++ b/include/linux/ipv6_route.h
@@ -0,0 +1,49 @@
1/*
2 * Linux INET6 implementation
3 *
4 * Authors:
5 * Pedro Roque <roque@di.fc.ul.pt>
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 _LINUX_IPV6_ROUTE_H
14#define _LINUX_IPV6_ROUTE_H
15
16#define RTF_DEFAULT 0x00010000 /* default - learned via ND */
17#define RTF_ALLONLINK 0x00020000 /* (deprecated and will be removed)
18 fallback, no routers on link */
19#define RTF_ADDRCONF 0x00040000 /* addrconf route - RA */
20#define RTF_PREFIX_RT 0x00080000 /* A prefix only route - RA */
21
22#define RTF_NONEXTHOP 0x00200000 /* route with no nexthop */
23#define RTF_EXPIRES 0x00400000
24
25#define RTF_CACHE 0x01000000 /* cache entry */
26#define RTF_FLOW 0x02000000 /* flow significant route */
27#define RTF_POLICY 0x04000000 /* policy route */
28
29#define RTF_LOCAL 0x80000000
30
31struct in6_rtmsg {
32 struct in6_addr rtmsg_dst;
33 struct in6_addr rtmsg_src;
34 struct in6_addr rtmsg_gateway;
35 __u32 rtmsg_type;
36 __u16 rtmsg_dst_len;
37 __u16 rtmsg_src_len;
38 __u32 rtmsg_metric;
39 unsigned long rtmsg_info;
40 __u32 rtmsg_flags;
41 int rtmsg_ifindex;
42};
43
44#define RTMSG_NEWDEVICE 0x11
45#define RTMSG_DELDEVICE 0x12
46#define RTMSG_NEWROUTE 0x21
47#define RTMSG_DELROUTE 0x22
48
49#endif
diff --git a/include/linux/ipx.h b/include/linux/ipx.h
new file mode 100644
index 000000000000..4f29c60964c4
--- /dev/null
+++ b/include/linux/ipx.h
@@ -0,0 +1,74 @@
1#ifndef _IPX_H_
2#define _IPX_H_
3#include <linux/sockios.h>
4#include <linux/socket.h>
5#define IPX_NODE_LEN 6
6#define IPX_MTU 576
7
8struct sockaddr_ipx {
9 sa_family_t sipx_family;
10 __u16 sipx_port;
11 __u32 sipx_network;
12 unsigned char sipx_node[IPX_NODE_LEN];
13 __u8 sipx_type;
14 unsigned char sipx_zero; /* 16 byte fill */
15};
16
17/*
18 * So we can fit the extra info for SIOCSIFADDR into the address nicely
19 */
20#define sipx_special sipx_port
21#define sipx_action sipx_zero
22#define IPX_DLTITF 0
23#define IPX_CRTITF 1
24
25struct ipx_route_definition {
26 __u32 ipx_network;
27 __u32 ipx_router_network;
28 unsigned char ipx_router_node[IPX_NODE_LEN];
29};
30
31struct ipx_interface_definition {
32 __u32 ipx_network;
33 unsigned char ipx_device[16];
34 unsigned char ipx_dlink_type;
35#define IPX_FRAME_NONE 0
36#define IPX_FRAME_SNAP 1
37#define IPX_FRAME_8022 2
38#define IPX_FRAME_ETHERII 3
39#define IPX_FRAME_8023 4
40#define IPX_FRAME_TR_8022 5 /* obsolete */
41 unsigned char ipx_special;
42#define IPX_SPECIAL_NONE 0
43#define IPX_PRIMARY 1
44#define IPX_INTERNAL 2
45 unsigned char ipx_node[IPX_NODE_LEN];
46};
47
48struct ipx_config_data {
49 unsigned char ipxcfg_auto_select_primary;
50 unsigned char ipxcfg_auto_create_interfaces;
51};
52
53/*
54 * OLD Route Definition for backward compatibility.
55 */
56
57struct ipx_route_def {
58 __u32 ipx_network;
59 __u32 ipx_router_network;
60#define IPX_ROUTE_NO_ROUTER 0
61 unsigned char ipx_router_node[IPX_NODE_LEN];
62 unsigned char ipx_device[16];
63 unsigned short ipx_flags;
64#define IPX_RT_SNAP 8
65#define IPX_RT_8022 4
66#define IPX_RT_BLUEBOOK 2
67#define IPX_RT_ROUTED 1
68};
69
70#define SIOCAIPXITFCRT (SIOCPROTOPRIVATE)
71#define SIOCAIPXPRISLT (SIOCPROTOPRIVATE + 1)
72#define SIOCIPXCFGDATA (SIOCPROTOPRIVATE + 2)
73#define SIOCIPXNCPCONN (SIOCPROTOPRIVATE + 3)
74#endif /* _IPX_H_ */
diff --git a/include/linux/irda.h b/include/linux/irda.h
new file mode 100644
index 000000000000..95dee174cdc5
--- /dev/null
+++ b/include/linux/irda.h
@@ -0,0 +1,222 @@
1/*********************************************************************
2 *
3 * Filename: irda.h
4 * Version:
5 * Description:
6 * Status: Experimental.
7 * Author: Dag Brattli <dagb@cs.uit.no>
8 * Created at: Mon Mar 8 14:06:12 1999
9 * Modified at: Sat Dec 25 16:06:42 1999
10 * Modified by: Dag Brattli <dagb@cs.uit.no>
11 *
12 * Copyright (c) 1999 Dag Brattli, All Rights Reserved.
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
18 *
19 * Neither Dag Brattli nor University of Tromsø admit liability nor
20 * provide warranty for any of this software. This material is
21 * provided "AS-IS" and at no charge.
22 *
23 ********************************************************************/
24
25#ifndef KERNEL_IRDA_H
26#define KERNEL_IRDA_H
27
28/* Please do *not* add any #include in this file, this file is
29 * included as-is in user space.
30 * Please fix the calling file to properly included needed files before
31 * this one, or preferably to include <net/irda/irda.h> instead.
32 * Jean II */
33
34/* Hint bit positions for first hint byte */
35#define HINT_PNP 0x01
36#define HINT_PDA 0x02
37#define HINT_COMPUTER 0x04
38#define HINT_PRINTER 0x08
39#define HINT_MODEM 0x10
40#define HINT_FAX 0x20
41#define HINT_LAN 0x40
42#define HINT_EXTENSION 0x80
43
44/* Hint bit positions for second hint byte (first extension byte) */
45#define HINT_TELEPHONY 0x01
46#define HINT_FILE_SERVER 0x02
47#define HINT_COMM 0x04
48#define HINT_MESSAGE 0x08
49#define HINT_HTTP 0x10
50#define HINT_OBEX 0x20
51
52/* IrLMP character code values */
53#define CS_ASCII 0x00
54#define CS_ISO_8859_1 0x01
55#define CS_ISO_8859_2 0x02
56#define CS_ISO_8859_3 0x03
57#define CS_ISO_8859_4 0x04
58#define CS_ISO_8859_5 0x05
59#define CS_ISO_8859_6 0x06
60#define CS_ISO_8859_7 0x07
61#define CS_ISO_8859_8 0x08
62#define CS_ISO_8859_9 0x09
63#define CS_UNICODE 0xff
64
65/* These are the currently known dongles */
66typedef enum {
67 IRDA_TEKRAM_DONGLE = 0,
68 IRDA_ESI_DONGLE = 1,
69 IRDA_ACTISYS_DONGLE = 2,
70 IRDA_ACTISYS_PLUS_DONGLE = 3,
71 IRDA_GIRBIL_DONGLE = 4,
72 IRDA_LITELINK_DONGLE = 5,
73 IRDA_AIRPORT_DONGLE = 6,
74 IRDA_OLD_BELKIN_DONGLE = 7,
75 IRDA_EP7211_IR = 8,
76 IRDA_MCP2120_DONGLE = 9,
77 IRDA_ACT200L_DONGLE = 10,
78 IRDA_MA600_DONGLE = 11,
79} IRDA_DONGLE;
80
81/* Protocol types to be used for SOCK_DGRAM */
82enum {
83 IRDAPROTO_UNITDATA = 0,
84 IRDAPROTO_ULTRA = 1,
85 IRDAPROTO_MAX
86};
87
88#define SOL_IRLMP 266 /* Same as SOL_IRDA for now */
89#define SOL_IRTTP 266 /* Same as SOL_IRDA for now */
90
91#define IRLMP_ENUMDEVICES 1 /* Return discovery log */
92#define IRLMP_IAS_SET 2 /* Set an attribute in local IAS */
93#define IRLMP_IAS_QUERY 3 /* Query remote IAS for attribute */
94#define IRLMP_HINTS_SET 4 /* Set hint bits advertised */
95#define IRLMP_QOS_SET 5
96#define IRLMP_QOS_GET 6
97#define IRLMP_MAX_SDU_SIZE 7
98#define IRLMP_IAS_GET 8 /* Get an attribute from local IAS */
99#define IRLMP_IAS_DEL 9 /* Remove attribute from local IAS */
100#define IRLMP_HINT_MASK_SET 10 /* Set discovery filter */
101#define IRLMP_WAITDEVICE 11 /* Wait for a new discovery */
102
103#define IRTTP_MAX_SDU_SIZE IRLMP_MAX_SDU_SIZE /* Compatibility */
104
105#define IAS_MAX_STRING 256 /* See IrLMP 1.1, 4.3.3.2 */
106#define IAS_MAX_OCTET_STRING 1024 /* See IrLMP 1.1, 4.3.3.2 */
107#define IAS_MAX_CLASSNAME 60 /* See IrLMP 1.1, 4.3.1 */
108#define IAS_MAX_ATTRIBNAME 60 /* See IrLMP 1.1, 4.3.3.1 */
109#define IAS_MAX_ATTRIBNUMBER 256 /* See IrLMP 1.1, 4.3.3.1 */
110/* For user space backward compatibility - may be fixed in kernel 2.5.X
111 * Note : need 60+1 ('\0'), make it 64 for alignement - Jean II */
112#define IAS_EXPORT_CLASSNAME 64
113#define IAS_EXPORT_ATTRIBNAME 256
114
115/* Attribute type needed for struct irda_ias_set */
116#define IAS_MISSING 0
117#define IAS_INTEGER 1
118#define IAS_OCT_SEQ 2
119#define IAS_STRING 3
120
121#define LSAP_ANY 0xff
122
123struct sockaddr_irda {
124 sa_family_t sir_family; /* AF_IRDA */
125 __u8 sir_lsap_sel; /* LSAP selector */
126 __u32 sir_addr; /* Device address */
127 char sir_name[25]; /* Usually <service>:IrDA:TinyTP */
128};
129
130struct irda_device_info {
131 __u32 saddr; /* Address of local interface */
132 __u32 daddr; /* Address of remote device */
133 char info[22]; /* Description */
134 __u8 charset; /* Charset used for description */
135 __u8 hints[2]; /* Hint bits */
136};
137
138struct irda_device_list {
139 __u32 len;
140 struct irda_device_info dev[1];
141};
142
143struct irda_ias_set {
144 char irda_class_name[IAS_EXPORT_CLASSNAME];
145 char irda_attrib_name[IAS_EXPORT_ATTRIBNAME];
146 unsigned int irda_attrib_type;
147 union {
148 unsigned int irda_attrib_int;
149 struct {
150 unsigned short len;
151 __u8 octet_seq[IAS_MAX_OCTET_STRING];
152 } irda_attrib_octet_seq;
153 struct {
154 __u8 len;
155 __u8 charset;
156 __u8 string[IAS_MAX_STRING];
157 } irda_attrib_string;
158 } attribute;
159 __u32 daddr; /* Address of device (for some queries only) */
160};
161
162/* Some private IOCTL's (max 16) */
163#define SIOCSDONGLE (SIOCDEVPRIVATE + 0)
164#define SIOCGDONGLE (SIOCDEVPRIVATE + 1)
165#define SIOCSBANDWIDTH (SIOCDEVPRIVATE + 2)
166#define SIOCSMEDIABUSY (SIOCDEVPRIVATE + 3)
167#define SIOCGMEDIABUSY (SIOCDEVPRIVATE + 4)
168#define SIOCGRECEIVING (SIOCDEVPRIVATE + 5)
169#define SIOCSMODE (SIOCDEVPRIVATE + 6)
170#define SIOCGMODE (SIOCDEVPRIVATE + 7)
171#define SIOCSDTRRTS (SIOCDEVPRIVATE + 8)
172#define SIOCGQOS (SIOCDEVPRIVATE + 9)
173
174/* No reason to include <linux/if.h> just because of this one ;-) */
175#define IRNAMSIZ 16
176
177/* IrDA quality of service information (must not exceed 16 bytes) */
178struct if_irda_qos {
179 unsigned long baudrate;
180 unsigned short data_size;
181 unsigned short window_size;
182 unsigned short min_turn_time;
183 unsigned short max_turn_time;
184 unsigned char add_bofs;
185 unsigned char link_disc;
186};
187
188/* For setting RTS and DTR lines of a dongle */
189struct if_irda_line {
190 __u8 dtr;
191 __u8 rts;
192};
193
194/* IrDA interface configuration (data part must not exceed 16 bytes) */
195struct if_irda_req {
196 union {
197 char ifrn_name[IRNAMSIZ]; /* if name, e.g. "irda0" */
198 } ifr_ifrn;
199
200 /* Data part */
201 union {
202 struct if_irda_line ifru_line;
203 struct if_irda_qos ifru_qos;
204 unsigned short ifru_flags;
205 unsigned int ifru_receiving;
206 unsigned int ifru_mode;
207 unsigned int ifru_dongle;
208 } ifr_ifru;
209};
210
211#define ifr_baudrate ifr_ifru.ifru_qos.baudrate
212#define ifr_receiving ifr_ifru.ifru_receiving
213#define ifr_dongle ifr_ifru.ifru_dongle
214#define ifr_mode ifr_ifru.ifru_mode
215#define ifr_dtr ifr_ifru.ifru_line.dtr
216#define ifr_rts ifr_ifru.ifru_line.rts
217
218#endif /* KERNEL_IRDA_H */
219
220
221
222
diff --git a/include/linux/irq.h b/include/linux/irq.h
new file mode 100644
index 000000000000..c3ff4d101667
--- /dev/null
+++ b/include/linux/irq.h
@@ -0,0 +1,97 @@
1#ifndef __irq_h
2#define __irq_h
3
4/*
5 * Please do not include this file in generic code. There is currently
6 * no requirement for any architecture to implement anything held
7 * within this file.
8 *
9 * Thanks. --rmk
10 */
11
12#include <linux/config.h>
13
14#if !defined(CONFIG_ARCH_S390)
15
16#include <linux/linkage.h>
17#include <linux/cache.h>
18#include <linux/spinlock.h>
19#include <linux/cpumask.h>
20
21#include <asm/irq.h>
22#include <asm/ptrace.h>
23
24/*
25 * IRQ line status.
26 */
27#define IRQ_INPROGRESS 1 /* IRQ handler active - do not enter! */
28#define IRQ_DISABLED 2 /* IRQ disabled - do not enter! */
29#define IRQ_PENDING 4 /* IRQ pending - replay on enable */
30#define IRQ_REPLAY 8 /* IRQ has been replayed but not acked yet */
31#define IRQ_AUTODETECT 16 /* IRQ is being autodetected */
32#define IRQ_WAITING 32 /* IRQ not yet seen - for autodetection */
33#define IRQ_LEVEL 64 /* IRQ level triggered */
34#define IRQ_MASKED 128 /* IRQ masked - shouldn't be seen again */
35#define IRQ_PER_CPU 256 /* IRQ is per CPU */
36
37/*
38 * Interrupt controller descriptor. This is all we need
39 * to describe about the low-level hardware.
40 */
41struct hw_interrupt_type {
42 const char * typename;
43 unsigned int (*startup)(unsigned int irq);
44 void (*shutdown)(unsigned int irq);
45 void (*enable)(unsigned int irq);
46 void (*disable)(unsigned int irq);
47 void (*ack)(unsigned int irq);
48 void (*end)(unsigned int irq);
49 void (*set_affinity)(unsigned int irq, cpumask_t dest);
50};
51
52typedef struct hw_interrupt_type hw_irq_controller;
53
54/*
55 * This is the "IRQ descriptor", which contains various information
56 * about the irq, including what kind of hardware handling it has,
57 * whether it is disabled etc etc.
58 *
59 * Pad this out to 32 bytes for cache and indexing reasons.
60 */
61typedef struct irq_desc {
62 hw_irq_controller *handler;
63 void *handler_data;
64 struct irqaction *action; /* IRQ action list */
65 unsigned int status; /* IRQ status */
66 unsigned int depth; /* nested irq disables */
67 unsigned int irq_count; /* For detecting broken interrupts */
68 unsigned int irqs_unhandled;
69 spinlock_t lock;
70} ____cacheline_aligned irq_desc_t;
71
72extern irq_desc_t irq_desc [NR_IRQS];
73
74#include <asm/hw_irq.h> /* the arch dependent stuff */
75
76extern int setup_irq(unsigned int irq, struct irqaction * new);
77
78#ifdef CONFIG_GENERIC_HARDIRQS
79extern cpumask_t irq_affinity[NR_IRQS];
80extern int no_irq_affinity;
81extern int noirqdebug_setup(char *str);
82
83extern fastcall int handle_IRQ_event(unsigned int irq, struct pt_regs *regs,
84 struct irqaction *action);
85extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs);
86extern void note_interrupt(unsigned int irq, irq_desc_t *desc, int action_ret);
87extern void report_bad_irq(unsigned int irq, irq_desc_t *desc, int action_ret);
88extern int can_request_irq(unsigned int irq, unsigned long irqflags);
89
90extern void init_irq_proc(void);
91#endif
92
93extern hw_irq_controller no_irq_type; /* needed in every arch ? */
94
95#endif
96
97#endif /* __irq_h */
diff --git a/include/linux/irq_cpustat.h b/include/linux/irq_cpustat.h
new file mode 100644
index 000000000000..af93505ec2ec
--- /dev/null
+++ b/include/linux/irq_cpustat.h
@@ -0,0 +1,32 @@
1#ifndef __irq_cpustat_h
2#define __irq_cpustat_h
3
4/*
5 * Contains default mappings for irq_cpustat_t, used by almost every
6 * architecture. Some arch (like s390) have per cpu hardware pages and
7 * they define their own mappings for irq_stat.
8 *
9 * Keith Owens <kaos@ocs.com.au> July 2000.
10 */
11
12#include <linux/config.h>
13
14/*
15 * Simple wrappers reducing source bloat. Define all irq_stat fields
16 * here, even ones that are arch dependent. That way we get common
17 * definitions instead of differing sets for each arch.
18 */
19
20#ifndef __ARCH_IRQ_STAT
21extern irq_cpustat_t irq_stat[]; /* defined in asm/hardirq.h */
22#define __IRQ_STAT(cpu, member) (irq_stat[cpu].member)
23#endif
24
25 /* arch independent irq_stat fields */
26#define local_softirq_pending() \
27 __IRQ_STAT(smp_processor_id(), __softirq_pending)
28
29 /* arch dependent irq_stat fields */
30#define nmi_count(cpu) __IRQ_STAT((cpu), __nmi_count) /* i386 */
31
32#endif /* __irq_cpustat_h */
diff --git a/include/linux/isapnp.h b/include/linux/isapnp.h
new file mode 100644
index 000000000000..26c64c286f42
--- /dev/null
+++ b/include/linux/isapnp.h
@@ -0,0 +1,142 @@
1/*
2 * ISA Plug & Play support
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
4 *
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 */
21
22#ifndef LINUX_ISAPNP_H
23#define LINUX_ISAPNP_H
24
25#include <linux/config.h>
26#include <linux/errno.h>
27#include <linux/pnp.h>
28
29/*
30 * Configuration registers (TODO: change by specification)
31 */
32
33#define ISAPNP_CFG_ACTIVATE 0x30 /* byte */
34#define ISAPNP_CFG_MEM 0x40 /* 4 * dword */
35#define ISAPNP_CFG_PORT 0x60 /* 8 * word */
36#define ISAPNP_CFG_IRQ 0x70 /* 2 * word */
37#define ISAPNP_CFG_DMA 0x74 /* 2 * byte */
38
39/*
40 *
41 */
42
43#define ISAPNP_VENDOR(a,b,c) (((((a)-'A'+1)&0x3f)<<2)|\
44 ((((b)-'A'+1)&0x18)>>3)|((((b)-'A'+1)&7)<<13)|\
45 ((((c)-'A'+1)&0x1f)<<8))
46#define ISAPNP_DEVICE(x) ((((x)&0xf000)>>8)|\
47 (((x)&0x0f00)>>8)|\
48 (((x)&0x00f0)<<8)|\
49 (((x)&0x000f)<<8))
50#define ISAPNP_FUNCTION(x) ISAPNP_DEVICE(x)
51
52/*
53 *
54 */
55
56#ifdef __KERNEL__
57
58#define DEVICE_COUNT_COMPATIBLE 4
59
60#define ISAPNP_ANY_ID 0xffff
61#define ISAPNP_CARD_DEVS 8
62
63#define ISAPNP_CARD_ID(_va, _vb, _vc, _device) \
64 .card_vendor = ISAPNP_VENDOR(_va, _vb, _vc), .card_device = ISAPNP_DEVICE(_device)
65#define ISAPNP_CARD_END \
66 .card_vendor = 0, .card_device = 0
67#define ISAPNP_DEVICE_ID(_va, _vb, _vc, _function) \
68 { .vendor = ISAPNP_VENDOR(_va, _vb, _vc), .function = ISAPNP_FUNCTION(_function) }
69
70/* export used IDs outside module */
71#define ISAPNP_CARD_TABLE(name) \
72 MODULE_GENERIC_TABLE(isapnp_card, name)
73
74struct isapnp_card_id {
75 unsigned long driver_data; /* data private to the driver */
76 unsigned short card_vendor, card_device;
77 struct {
78 unsigned short vendor, function;
79 } devs[ISAPNP_CARD_DEVS]; /* logical devices */
80};
81
82#define ISAPNP_DEVICE_SINGLE(_cva, _cvb, _cvc, _cdevice, _dva, _dvb, _dvc, _dfunction) \
83 .card_vendor = ISAPNP_VENDOR(_cva, _cvb, _cvc), .card_device = ISAPNP_DEVICE(_cdevice), \
84 .vendor = ISAPNP_VENDOR(_dva, _dvb, _dvc), .function = ISAPNP_FUNCTION(_dfunction)
85#define ISAPNP_DEVICE_SINGLE_END \
86 .card_vendor = 0, .card_device = 0
87
88struct isapnp_device_id {
89 unsigned short card_vendor, card_device;
90 unsigned short vendor, function;
91 unsigned long driver_data; /* data private to the driver */
92};
93
94#if defined(CONFIG_ISAPNP) || (defined(CONFIG_ISAPNP_MODULE) && defined(MODULE))
95
96#define __ISAPNP__
97
98/* lowlevel configuration */
99int isapnp_present(void);
100int isapnp_cfg_begin(int csn, int device);
101int isapnp_cfg_end(void);
102unsigned char isapnp_read_byte(unsigned char idx);
103void isapnp_write_byte(unsigned char idx, unsigned char val);
104
105#ifdef CONFIG_PROC_FS
106int isapnp_proc_init(void);
107int isapnp_proc_done(void);
108#else
109static inline int isapnp_proc_init(void) { return 0; }
110static inline int isapnp_proc_done(void) { return 0; }
111#endif
112
113/* compat */
114struct pnp_card *pnp_find_card(unsigned short vendor,
115 unsigned short device,
116 struct pnp_card *from);
117struct pnp_dev *pnp_find_dev(struct pnp_card *card,
118 unsigned short vendor,
119 unsigned short function,
120 struct pnp_dev *from);
121
122#else /* !CONFIG_ISAPNP */
123
124/* lowlevel configuration */
125static inline int isapnp_present(void) { return 0; }
126static inline int isapnp_cfg_begin(int csn, int device) { return -ENODEV; }
127static inline int isapnp_cfg_end(void) { return -ENODEV; }
128static inline unsigned char isapnp_read_byte(unsigned char idx) { return 0xff; }
129static inline void isapnp_write_byte(unsigned char idx, unsigned char val) { ; }
130
131static inline struct pnp_card *pnp_find_card(unsigned short vendor,
132 unsigned short device,
133 struct pnp_card *from) { return NULL; }
134static inline struct pnp_dev *pnp_find_dev(struct pnp_card *card,
135 unsigned short vendor,
136 unsigned short function,
137 struct pnp_dev *from) { return NULL; }
138
139#endif /* CONFIG_ISAPNP */
140
141#endif /* __KERNEL__ */
142#endif /* LINUX_ISAPNP_H */
diff --git a/include/linux/isdn.h b/include/linux/isdn.h
new file mode 100644
index 000000000000..862083eb58ab
--- /dev/null
+++ b/include/linux/isdn.h
@@ -0,0 +1,638 @@
1/* $Id: isdn.h,v 1.125.2.3 2004/02/10 01:07:14 keil Exp $
2 *
3 * Main header for the Linux ISDN subsystem (linklevel).
4 *
5 * Copyright 1994,95,96 by Fritz Elfert (fritz@isdn4linux.de)
6 * Copyright 1995,96 by Thinking Objects Software GmbH Wuerzburg
7 * Copyright 1995,96 by Michael Hipp (Michael.Hipp@student.uni-tuebingen.de)
8 *
9 * This software may be used and distributed according to the terms
10 * of the GNU General Public License, incorporated herein by reference.
11 *
12 */
13
14#ifndef __ISDN_H__
15#define __ISDN_H__
16
17#include <linux/ioctl.h>
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
25#define ISDN_MAX_CHANNELS 64
26#endif
27
28/* New ioctl-codes */
29#define IIOCNETAIF _IO('I',1)
30#define IIOCNETDIF _IO('I',2)
31#define IIOCNETSCF _IO('I',3)
32#define IIOCNETGCF _IO('I',4)
33#define IIOCNETANM _IO('I',5)
34#define IIOCNETDNM _IO('I',6)
35#define IIOCNETGNM _IO('I',7)
36#define IIOCGETSET _IO('I',8) /* no longer supported */
37#define IIOCSETSET _IO('I',9) /* no longer supported */
38#define IIOCSETVER _IO('I',10)
39#define IIOCNETHUP _IO('I',11)
40#define IIOCSETGST _IO('I',12)
41#define IIOCSETBRJ _IO('I',13)
42#define IIOCSIGPRF _IO('I',14)
43#define IIOCGETPRF _IO('I',15)
44#define IIOCSETPRF _IO('I',16)
45#define IIOCGETMAP _IO('I',17)
46#define IIOCSETMAP _IO('I',18)
47#define IIOCNETASL _IO('I',19)
48#define IIOCNETDIL _IO('I',20)
49#define IIOCGETCPS _IO('I',21)
50#define IIOCGETDVR _IO('I',22)
51#define IIOCNETLCR _IO('I',23) /* dwabc ioctl for LCR from isdnlog */
52#define IIOCNETDWRSET _IO('I',24) /* dwabc ioctl to reset abc-values to default on a net-interface */
53
54#define IIOCNETALN _IO('I',32)
55#define IIOCNETDLN _IO('I',33)
56
57#define IIOCNETGPN _IO('I',34)
58
59#define IIOCDBGVAR _IO('I',127)
60
61#define IIOCDRVCTL _IO('I',128)
62
63/* cisco hdlck device private ioctls */
64#define SIOCGKEEPPERIOD (SIOCDEVPRIVATE + 0)
65#define SIOCSKEEPPERIOD (SIOCDEVPRIVATE + 1)
66#define SIOCGDEBSERINT (SIOCDEVPRIVATE + 2)
67#define SIOCSDEBSERINT (SIOCDEVPRIVATE + 3)
68
69/* Packet encapsulations for net-interfaces */
70#define ISDN_NET_ENCAP_ETHER 0
71#define ISDN_NET_ENCAP_RAWIP 1
72#define ISDN_NET_ENCAP_IPTYP 2
73#define ISDN_NET_ENCAP_CISCOHDLC 3 /* Without SLARP and keepalive */
74#define ISDN_NET_ENCAP_SYNCPPP 4
75#define ISDN_NET_ENCAP_UIHDLC 5
76#define ISDN_NET_ENCAP_CISCOHDLCK 6 /* With SLARP and keepalive */
77#define ISDN_NET_ENCAP_X25IFACE 7 /* Documentation/networking/x25-iface.txt*/
78#define ISDN_NET_ENCAP_MAX_ENCAP ISDN_NET_ENCAP_X25IFACE
79
80/* Facility which currently uses an ISDN-channel */
81#define ISDN_USAGE_NONE 0
82#define ISDN_USAGE_RAW 1
83#define ISDN_USAGE_MODEM 2
84#define ISDN_USAGE_NET 3
85#define ISDN_USAGE_VOICE 4
86#define ISDN_USAGE_FAX 5
87#define ISDN_USAGE_MASK 7 /* Mask to get plain usage */
88#define ISDN_USAGE_DISABLED 32 /* This bit is set, if channel is disabled */
89#define ISDN_USAGE_EXCLUSIVE 64 /* This bit is set, if channel is exclusive */
90#define ISDN_USAGE_OUTGOING 128 /* This bit is set, if channel is outgoing */
91
92#define ISDN_MODEM_NUMREG 24 /* Number of Modem-Registers */
93#define ISDN_LMSNLEN 255 /* Length of tty's Listen-MSN string */
94#define ISDN_CMSGLEN 50 /* Length of CONNECT-Message to add for Modem */
95
96#define ISDN_MSNLEN 32
97#define NET_DV 0x06 /* Data version for isdn_net_ioctl_cfg */
98#define TTY_DV 0x06 /* Data version for iprofd etc. */
99
100#define INF_DV 0x01 /* Data version for /dev/isdninfo */
101
102typedef struct {
103 char drvid[25];
104 unsigned long arg;
105} isdn_ioctl_struct;
106
107typedef struct {
108 char name[10];
109 char phone[ISDN_MSNLEN];
110 int outgoing;
111} isdn_net_ioctl_phone;
112
113typedef struct {
114 char name[10]; /* Name of interface */
115 char master[10]; /* Name of Master for Bundling */
116 char slave[10]; /* Name of Slave for Bundling */
117 char eaz[256]; /* EAZ/MSN */
118 char drvid[25]; /* DriverId for Bindings */
119 int onhtime; /* Hangup-Timeout */
120 int charge; /* Charge-Units */
121 int l2_proto; /* Layer-2 protocol */
122 int l3_proto; /* Layer-3 protocol */
123 int p_encap; /* Encapsulation */
124 int exclusive; /* Channel, if bound exclusive */
125 int dialmax; /* Dial Retry-Counter */
126 int slavedelay; /* Delay until slave starts up */
127 int cbdelay; /* Delay before Callback */
128 int chargehup; /* Flag: Charge-Hangup */
129 int ihup; /* Flag: Hangup-Timeout on incoming line */
130 int secure; /* Flag: Secure */
131 int callback; /* Flag: Callback */
132 int cbhup; /* Flag: Reject Call before Callback */
133 int pppbind; /* ippp device for bindings */
134 int chargeint; /* Use fixed charge interval length */
135 int triggercps; /* BogoCPS needed for triggering slave */
136 int dialtimeout; /* Dial-Timeout */
137 int dialwait; /* Time to wait after failed dial */
138 int dialmode; /* Flag: off / on / auto */
139} isdn_net_ioctl_cfg;
140
141#define ISDN_NET_DIALMODE_MASK 0xC0 /* bits for status */
142#define ISDN_NET_DM_OFF 0x00 /* this interface is stopped */
143#define ISDN_NET_DM_MANUAL 0x40 /* this interface is on (manual) */
144#define ISDN_NET_DM_AUTO 0x80 /* this interface is autodial */
145#define ISDN_NET_DIALMODE(x) ((&(x))->flags & ISDN_NET_DIALMODE_MASK)
146
147#ifdef __KERNEL__
148
149#include <linux/config.h>
150#include <linux/errno.h>
151#include <linux/fs.h>
152#include <linux/major.h>
153#include <asm/segment.h>
154#include <asm/io.h>
155#include <linux/kernel.h>
156#include <linux/signal.h>
157#include <linux/slab.h>
158#include <linux/timer.h>
159#include <linux/wait.h>
160#include <linux/tty.h>
161#include <linux/tty_flip.h>
162#include <linux/serial_reg.h>
163#include <linux/fcntl.h>
164#include <linux/types.h>
165#include <linux/interrupt.h>
166#include <linux/ip.h>
167#include <linux/in.h>
168#include <linux/netdevice.h>
169#include <linux/etherdevice.h>
170#include <linux/skbuff.h>
171#include <linux/tcp.h>
172
173#define ISDN_TTY_MAJOR 43
174#define ISDN_TTYAUX_MAJOR 44
175#define ISDN_MAJOR 45
176
177/* The minor-devicenumbers for Channel 0 and 1 are used as arguments for
178 * physical Channel-Mapping, so they MUST NOT be changed without changing
179 * the correspondent code in isdn.c
180 */
181
182#define ISDN_MINOR_B 0
183#define ISDN_MINOR_BMAX (ISDN_MAX_CHANNELS-1)
184#define ISDN_MINOR_CTRL 64
185#define ISDN_MINOR_CTRLMAX (64 + (ISDN_MAX_CHANNELS-1))
186#define ISDN_MINOR_PPP 128
187#define ISDN_MINOR_PPPMAX (128 + (ISDN_MAX_CHANNELS-1))
188#define ISDN_MINOR_STATUS 255
189
190#ifdef CONFIG_ISDN_PPP
191
192#ifdef CONFIG_ISDN_PPP_VJ
193# include <net/slhc_vj.h>
194#endif
195
196#include <linux/ppp_defs.h>
197#include <linux/if_ppp.h>
198
199#include <linux/isdn_ppp.h>
200#endif
201
202#ifdef CONFIG_ISDN_X25
203# include <linux/concap.h>
204#endif
205
206#include <linux/isdnif.h>
207
208#define ISDN_DRVIOCTL_MASK 0x7f /* Mask for Device-ioctl */
209
210/* Until now unused */
211#define ISDN_SERVICE_VOICE 1
212#define ISDN_SERVICE_AB 1<<1
213#define ISDN_SERVICE_X21 1<<2
214#define ISDN_SERVICE_G4 1<<3
215#define ISDN_SERVICE_BTX 1<<4
216#define ISDN_SERVICE_DFUE 1<<5
217#define ISDN_SERVICE_X25 1<<6
218#define ISDN_SERVICE_TTX 1<<7
219#define ISDN_SERVICE_MIXED 1<<8
220#define ISDN_SERVICE_FW 1<<9
221#define ISDN_SERVICE_GTEL 1<<10
222#define ISDN_SERVICE_BTXN 1<<11
223#define ISDN_SERVICE_BTEL 1<<12
224
225/* Macros checking plain usage */
226#define USG_NONE(x) ((x & ISDN_USAGE_MASK)==ISDN_USAGE_NONE)
227#define USG_RAW(x) ((x & ISDN_USAGE_MASK)==ISDN_USAGE_RAW)
228#define USG_MODEM(x) ((x & ISDN_USAGE_MASK)==ISDN_USAGE_MODEM)
229#define USG_VOICE(x) ((x & ISDN_USAGE_MASK)==ISDN_USAGE_VOICE)
230#define USG_NET(x) ((x & ISDN_USAGE_MASK)==ISDN_USAGE_NET)
231#define USG_FAX(x) ((x & ISDN_USAGE_MASK)==ISDN_USAGE_FAX)
232#define USG_OUTGOING(x) ((x & ISDN_USAGE_OUTGOING)==ISDN_USAGE_OUTGOING)
233#define USG_MODEMORVOICE(x) (((x & ISDN_USAGE_MASK)==ISDN_USAGE_MODEM) || \
234 ((x & ISDN_USAGE_MASK)==ISDN_USAGE_VOICE) )
235
236/* Timer-delays and scheduling-flags */
237#define ISDN_TIMER_RES 4 /* Main Timer-Resolution */
238#define ISDN_TIMER_02SEC (HZ/ISDN_TIMER_RES/5) /* Slow-Timer1 .2 sec */
239#define ISDN_TIMER_1SEC (HZ/ISDN_TIMER_RES) /* Slow-Timer2 1 sec */
240#define ISDN_TIMER_RINGING 5 /* tty RINGs = ISDN_TIMER_1SEC * this factor */
241#define ISDN_TIMER_KEEPINT 10 /* Cisco-Keepalive = ISDN_TIMER_1SEC * this factor */
242#define ISDN_TIMER_MODEMREAD 1
243#define ISDN_TIMER_MODEMPLUS 2
244#define ISDN_TIMER_MODEMRING 4
245#define ISDN_TIMER_MODEMXMIT 8
246#define ISDN_TIMER_NETDIAL 16
247#define ISDN_TIMER_NETHANGUP 32
248#define ISDN_TIMER_CARRIER 256 /* Wait for Carrier */
249#define ISDN_TIMER_FAST (ISDN_TIMER_MODEMREAD | ISDN_TIMER_MODEMPLUS | \
250 ISDN_TIMER_MODEMXMIT)
251#define ISDN_TIMER_SLOW (ISDN_TIMER_MODEMRING | ISDN_TIMER_NETHANGUP | \
252 ISDN_TIMER_NETDIAL | ISDN_TIMER_CARRIER)
253
254/* Timeout-Values for isdn_net_dial() */
255#define ISDN_TIMER_DTIMEOUT10 (10*HZ/(ISDN_TIMER_02SEC*(ISDN_TIMER_RES+1)))
256#define ISDN_TIMER_DTIMEOUT15 (15*HZ/(ISDN_TIMER_02SEC*(ISDN_TIMER_RES+1)))
257#define ISDN_TIMER_DTIMEOUT60 (60*HZ/(ISDN_TIMER_02SEC*(ISDN_TIMER_RES+1)))
258
259/* GLOBAL_FLAGS */
260#define ISDN_GLOBAL_STOPPED 1
261
262/*=================== Start of ip-over-ISDN stuff =========================*/
263
264/* Feature- and status-flags for a net-interface */
265#define ISDN_NET_CONNECTED 0x01 /* Bound to ISDN-Channel */
266#define ISDN_NET_SECURE 0x02 /* Accept calls from phonelist only */
267#define ISDN_NET_CALLBACK 0x04 /* activate callback */
268#define ISDN_NET_CBHUP 0x08 /* hangup before callback */
269#define ISDN_NET_CBOUT 0x10 /* remote machine does callback */
270
271#define ISDN_NET_MAGIC 0x49344C02 /* for paranoia-checking */
272
273/* Phone-list-element */
274typedef struct {
275 void *next;
276 char num[ISDN_MSNLEN];
277} isdn_net_phone;
278
279/*
280 Principles when extending structures for generic encapsulation protocol
281 ("concap") support:
282 - Stuff which is hardware specific (here i4l-specific) goes in
283 the netdev -> local structure (here: isdn_net_local)
284 - Stuff which is encapsulation protocol specific goes in the structure
285 which holds the linux device structure (here: isdn_net_device)
286*/
287
288/* Local interface-data */
289typedef struct isdn_net_local_s {
290 ulong magic;
291 char name[10]; /* Name of device */
292 struct net_device_stats stats; /* Ethernet Statistics */
293 int isdn_device; /* Index to isdn-device */
294 int isdn_channel; /* Index to isdn-channel */
295 int ppp_slot; /* PPPD device slot number */
296 int pre_device; /* Preselected isdn-device */
297 int pre_channel; /* Preselected isdn-channel */
298 int exclusive; /* If non-zero idx to reserved chan.*/
299 int flags; /* Connection-flags */
300 int dialretry; /* Counter for Dialout-retries */
301 int dialmax; /* Max. Number of Dial-retries */
302 int cbdelay; /* Delay before Callback starts */
303 int dtimer; /* Timeout-counter for dialing */
304 char msn[ISDN_MSNLEN]; /* MSNs/EAZs for this interface */
305 u_char cbhup; /* Flag: Reject Call before Callback*/
306 u_char dialstate; /* State for dialing */
307 u_char p_encap; /* Packet encapsulation */
308 /* 0 = Ethernet over ISDN */
309 /* 1 = RAW-IP */
310 /* 2 = IP with type field */
311 u_char l2_proto; /* Layer-2-protocol */
312 /* See ISDN_PROTO_L2..-constants in */
313 /* isdnif.h */
314 /* 0 = X75/LAPB with I-Frames */
315 /* 1 = X75/LAPB with UI-Frames */
316 /* 2 = X75/LAPB with BUI-Frames */
317 /* 3 = HDLC */
318 u_char l3_proto; /* Layer-3-protocol */
319 /* See ISDN_PROTO_L3..-constants in */
320 /* isdnif.h */
321 /* 0 = Transparent */
322 int huptimer; /* Timeout-counter for auto-hangup */
323 int charge; /* Counter for charging units */
324 ulong chargetime; /* Timer for Charging info */
325 int hupflags; /* Flags for charge-unit-hangup: */
326 /* bit0: chargeint is invalid */
327 /* bit1: Getting charge-interval */
328 /* bit2: Do charge-unit-hangup */
329 /* bit3: Do hangup even on incoming */
330 int outgoing; /* Flag: outgoing call */
331 int onhtime; /* Time to keep link up */
332 int chargeint; /* Interval between charge-infos */
333 int onum; /* Flag: at least 1 outgoing number */
334 int cps; /* current speed of this interface */
335 int transcount; /* byte-counter for cps-calculation */
336 int sqfull; /* Flag: netdev-queue overloaded */
337 ulong sqfull_stamp; /* Start-Time of overload */
338 ulong slavedelay; /* Dynamic bundling delaytime */
339 int triggercps; /* BogoCPS needed for trigger slave */
340 isdn_net_phone *phone[2]; /* List of remote-phonenumbers */
341 /* phone[0] = Incoming Numbers */
342 /* phone[1] = Outgoing Numbers */
343 isdn_net_phone *dial; /* Pointer to dialed number */
344 struct net_device *master; /* Ptr to Master device for slaves */
345 struct net_device *slave; /* Ptr to Slave device for masters */
346 struct isdn_net_local_s *next; /* Ptr to next link in bundle */
347 struct isdn_net_local_s *last; /* Ptr to last link in bundle */
348 struct isdn_net_dev_s *netdev; /* Ptr to netdev */
349 struct sk_buff_head super_tx_queue; /* List of supervisory frames to */
350 /* be transmitted asap */
351 atomic_t frame_cnt; /* number of frames currently */
352 /* queued in HL driver */
353 /* Ptr to orig. hard_header_cache */
354 spinlock_t xmit_lock; /* used to protect the xmit path of */
355 /* a particular channel (including */
356 /* the frame_cnt */
357
358 int (*org_hhc)(
359 struct neighbour *neigh,
360 struct hh_cache *hh);
361 /* Ptr to orig. header_cache_update */
362 void (*org_hcu)(struct hh_cache *,
363 struct net_device *,
364 unsigned char *);
365 int pppbind; /* ippp device for bindings */
366 int dialtimeout; /* How long shall we try on dialing? (jiffies) */
367 int dialwait; /* How long shall we wait after failed attempt? (jiffies) */
368 ulong dialstarted; /* jiffies of first dialing-attempt */
369 ulong dialwait_timer; /* jiffies of earliest next dialing-attempt */
370 int huptimeout; /* How long will the connection be up? (seconds) */
371#ifdef CONFIG_ISDN_X25
372 struct concap_device_ops *dops; /* callbacks used by encapsulator */
373#endif
374 /* use an own struct for that in later versions */
375 ulong cisco_myseq; /* Local keepalive seq. for Cisco */
376 ulong cisco_mineseen; /* returned keepalive seq. from remote */
377 ulong cisco_yourseq; /* Remote keepalive seq. for Cisco */
378 int cisco_keepalive_period; /* keepalive period */
379 ulong cisco_last_slarp_in; /* jiffie of last keepalive packet we received */
380 char cisco_line_state; /* state of line according to keepalive packets */
381 char cisco_debserint; /* debugging flag of cisco hdlc with slarp */
382 struct timer_list cisco_timer;
383 struct work_struct tqueue;
384} isdn_net_local;
385
386/* the interface itself */
387typedef struct isdn_net_dev_s {
388 isdn_net_local *local;
389 isdn_net_local *queue; /* circular list of all bundled
390 channels, which are currently
391 online */
392 spinlock_t queue_lock; /* lock to protect queue */
393 void *next; /* Pointer to next isdn-interface */
394 struct net_device dev; /* interface to upper levels */
395#ifdef CONFIG_ISDN_PPP
396 ippp_bundle * pb; /* pointer to the common bundle structure
397 * with the per-bundle data */
398#endif
399#ifdef CONFIG_ISDN_X25
400 struct concap_proto *cprot; /* connection oriented encapsulation protocol */
401#endif
402
403} isdn_net_dev;
404
405/*===================== End of ip-over-ISDN stuff ===========================*/
406
407/*======================= Start of ISDN-tty stuff ===========================*/
408
409#define ISDN_ASYNC_MAGIC 0x49344C01 /* for paranoia-checking */
410#define ISDN_ASYNC_INITIALIZED 0x80000000 /* port was initialized */
411#define ISDN_ASYNC_CALLOUT_ACTIVE 0x40000000 /* Call out device active */
412#define ISDN_ASYNC_NORMAL_ACTIVE 0x20000000 /* Normal device active */
413#define ISDN_ASYNC_CLOSING 0x08000000 /* Serial port is closing */
414#define ISDN_ASYNC_CTS_FLOW 0x04000000 /* Do CTS flow control */
415#define ISDN_ASYNC_CHECK_CD 0x02000000 /* i.e., CLOCAL */
416#define ISDN_ASYNC_HUP_NOTIFY 0x0001 /* Notify tty on hangups/closes */
417#define ISDN_ASYNC_SESSION_LOCKOUT 0x0100 /* Lock cua opens on session */
418#define ISDN_ASYNC_PGRP_LOCKOUT 0x0200 /* Lock cua opens on pgrp */
419#define ISDN_ASYNC_CALLOUT_NOHUP 0x0400 /* No hangup for cui */
420#define ISDN_ASYNC_SPLIT_TERMIOS 0x0008 /* Sep. termios for dialin/out */
421#define ISDN_SERIAL_XMIT_SIZE 1024 /* Default bufsize for write */
422#define ISDN_SERIAL_XMIT_MAX 4000 /* Maximum bufsize for write */
423#define ISDN_SERIAL_TYPE_NORMAL 1
424#define ISDN_SERIAL_TYPE_CALLOUT 2
425
426#ifdef CONFIG_ISDN_AUDIO
427/* For using sk_buffs with audio we need some private variables
428 * within each sk_buff. For this purpose, we declare a struct here,
429 * and put it always at the private skb->cb data array. A few macros help
430 * accessing the variables.
431 */
432typedef struct _isdn_audio_data {
433 unsigned short dle_count;
434 unsigned char lock;
435} isdn_audio_data_t;
436
437#define ISDN_AUDIO_SKB_DLECOUNT(skb) (((isdn_audio_data_t *)&skb->cb[0])->dle_count)
438#define ISDN_AUDIO_SKB_LOCK(skb) (((isdn_audio_data_t *)&skb->cb[0])->lock)
439#endif
440
441/* Private data of AT-command-interpreter */
442typedef struct atemu {
443 u_char profile[ISDN_MODEM_NUMREG]; /* Modem-Regs. Profile 0 */
444 u_char mdmreg[ISDN_MODEM_NUMREG]; /* Modem-Registers */
445 char pmsn[ISDN_MSNLEN]; /* EAZ/MSNs Profile 0 */
446 char msn[ISDN_MSNLEN]; /* EAZ/MSN */
447 char plmsn[ISDN_LMSNLEN]; /* Listening MSNs Profile 0 */
448 char lmsn[ISDN_LMSNLEN]; /* Listening MSNs */
449 char cpn[ISDN_MSNLEN]; /* CalledPartyNumber on incoming call */
450 char connmsg[ISDN_CMSGLEN]; /* CONNECT-Msg from HL-Driver */
451#ifdef CONFIG_ISDN_AUDIO
452 u_char vpar[10]; /* Voice-parameters */
453 int lastDLE; /* Flag for voice-coding: DLE seen */
454#endif
455 int mdmcmdl; /* Length of Modem-Commandbuffer */
456 int pluscount; /* Counter for +++ sequence */
457 u_long lastplus; /* Timestamp of last + */
458 int carrierwait; /* Seconds of carrier waiting */
459 char mdmcmd[255]; /* Modem-Commandbuffer */
460 unsigned int charge; /* Charge units of current connection */
461} atemu;
462
463/* Private data (similar to async_struct in <linux/serial.h>) */
464typedef struct modem_info {
465 int magic;
466 struct module *owner;
467 int flags; /* defined in tty.h */
468 int x_char; /* xon/xoff character */
469 int mcr; /* Modem control register */
470 int msr; /* Modem status register */
471 int lsr; /* Line status register */
472 int line;
473 int count; /* # of fd on device */
474 int blocked_open; /* # of blocked opens */
475 long session; /* Session of opening process */
476 long pgrp; /* pgrp of opening process */
477 int online; /* 1 = B-Channel is up, drop data */
478 /* 2 = B-Channel is up, deliver d.*/
479 int dialing; /* Dial in progress or ATA */
480 int rcvsched; /* Receive needs schedule */
481 int isdn_driver; /* Index to isdn-driver */
482 int isdn_channel; /* Index to isdn-channel */
483 int drv_index; /* Index to dev->usage */
484 int ncarrier; /* Flag: schedule NO CARRIER */
485 unsigned char last_cause[8]; /* Last cause message */
486 unsigned char last_num[ISDN_MSNLEN];
487 /* Last phone-number */
488 unsigned char last_l2; /* Last layer-2 protocol */
489 unsigned char last_si; /* Last service */
490 unsigned char last_lhup; /* Last hangup local? */
491 unsigned char last_dir; /* Last direction (in or out) */
492 struct timer_list nc_timer; /* Timer for delayed NO CARRIER */
493 int send_outstanding;/* # of outstanding send-requests */
494 int xmit_size; /* max. # of chars in xmit_buf */
495 int xmit_count; /* # of chars in xmit_buf */
496 unsigned char *xmit_buf; /* transmit buffer */
497 struct sk_buff_head xmit_queue; /* transmit queue */
498 atomic_t xmit_lock; /* Semaphore for isdn_tty_write */
499#ifdef CONFIG_ISDN_AUDIO
500 int vonline; /* Voice-channel status */
501 /* Bit 0 = recording */
502 /* Bit 1 = playback */
503 /* Bit 2 = playback, DLE-ETX seen */
504 struct sk_buff_head dtmf_queue; /* queue for dtmf results */
505 void *adpcms; /* state for adpcm decompression */
506 void *adpcmr; /* state for adpcm compression */
507 void *dtmf_state; /* state for dtmf decoder */
508 void *silence_state; /* state for silence detection */
509#endif
510#ifdef CONFIG_ISDN_TTY_FAX
511 struct T30_s *fax; /* T30 Fax Group 3 data/interface */
512 int faxonline; /* Fax-channel status */
513#endif
514 struct tty_struct *tty; /* Pointer to corresponding tty */
515 atemu emu; /* AT-emulator data */
516 struct termios normal_termios; /* For saving termios structs */
517 struct termios callout_termios;
518 wait_queue_head_t open_wait, close_wait;
519 struct semaphore write_sem;
520 spinlock_t readlock;
521} modem_info;
522
523#define ISDN_MODEM_WINSIZE 8
524
525/* Description of one ISDN-tty */
526typedef struct _isdn_modem {
527 int refcount; /* Number of opens */
528 struct tty_driver *tty_modem; /* tty-device */
529 struct tty_struct *modem_table[ISDN_MAX_CHANNELS]; /* ?? copied from Orig */
530 struct termios *modem_termios[ISDN_MAX_CHANNELS];
531 struct termios *modem_termios_locked[ISDN_MAX_CHANNELS];
532 modem_info info[ISDN_MAX_CHANNELS]; /* Private data */
533} isdn_modem_t;
534
535/*======================= End of ISDN-tty stuff ============================*/
536
537/*======================== Start of V.110 stuff ============================*/
538#define V110_BUFSIZE 1024
539
540typedef struct {
541 int nbytes; /* 1 Matrixbyte -> nbytes in stream */
542 int nbits; /* Number of used bits in streambyte */
543 unsigned char key; /* Bitmask in stream eg. 11 (nbits=2) */
544 int decodelen; /* Amount of data in decodebuf */
545 int SyncInit; /* Number of sync frames to send */
546 unsigned char *OnlineFrame; /* Precalculated V110 idle frame */
547 unsigned char *OfflineFrame; /* Precalculated V110 sync Frame */
548 int framelen; /* Length of frames */
549 int skbuser; /* Number of unacked userdata skbs */
550 int skbidle; /* Number of unacked idle/sync skbs */
551 int introducer; /* Local vars for decoder */
552 int dbit;
553 unsigned char b;
554 int skbres; /* space to reserve in outgoing skb */
555 int maxsize; /* maxbufsize of lowlevel driver */
556 unsigned char *encodebuf; /* temporary buffer for encoding */
557 unsigned char decodebuf[V110_BUFSIZE]; /* incomplete V110 matrices */
558} isdn_v110_stream;
559
560/*========================= End of V.110 stuff =============================*/
561
562/*======================= Start of general stuff ===========================*/
563
564typedef struct {
565 char *next;
566 char *private;
567} infostruct;
568
569#define DRV_FLAG_RUNNING 1
570#define DRV_FLAG_REJBUS 2
571#define DRV_FLAG_LOADED 4
572
573/* Description of hardware-level-driver */
574typedef struct _isdn_driver {
575 ulong online; /* Channel-Online flags */
576 ulong flags; /* Misc driver Flags */
577 int locks; /* Number of locks for this driver */
578 int channels; /* Number of channels */
579 wait_queue_head_t st_waitq; /* Wait-Queue for status-read's */
580 int maxbufsize; /* Maximum Buffersize supported */
581 unsigned long pktcount; /* Until now: unused */
582 int stavail; /* Chars avail on Status-device */
583 isdn_if *interface; /* Interface to driver */
584 int *rcverr; /* Error-counters for B-Ch.-receive */
585 int *rcvcount; /* Byte-counters for B-Ch.-receive */
586#ifdef CONFIG_ISDN_AUDIO
587 unsigned long DLEflag; /* Flags: Insert DLE at next read */
588#endif
589 struct sk_buff_head *rpqueue; /* Pointers to start of Rcv-Queue */
590 wait_queue_head_t *rcv_waitq; /* Wait-Queues for B-Channel-Reads */
591 wait_queue_head_t *snd_waitq; /* Wait-Queue for B-Channel-Send's */
592 char msn2eaz[10][ISDN_MSNLEN]; /* Mapping-Table MSN->EAZ */
593} isdn_driver_t;
594
595/* Main driver-data */
596typedef struct isdn_devt {
597 struct module *owner;
598 spinlock_t lock;
599 unsigned short flags; /* Bitmapped Flags: */
600 int drivers; /* Current number of drivers */
601 int channels; /* Current number of channels */
602 int net_verbose; /* Verbose-Flag */
603 int modempoll; /* Flag: tty-read active */
604 spinlock_t timerlock;
605 int tflags; /* Timer-Flags: */
606 /* see ISDN_TIMER_..defines */
607 int global_flags;
608 infostruct *infochain; /* List of open info-devs. */
609 wait_queue_head_t info_waitq; /* Wait-Queue for isdninfo */
610 struct timer_list timer; /* Misc.-function Timer */
611 int chanmap[ISDN_MAX_CHANNELS]; /* Map minor->device-channel */
612 int drvmap[ISDN_MAX_CHANNELS]; /* Map minor->driver-index */
613 int usage[ISDN_MAX_CHANNELS]; /* Used by tty/ip/voice */
614 char num[ISDN_MAX_CHANNELS][ISDN_MSNLEN];
615 /* Remote number of active ch.*/
616 int m_idx[ISDN_MAX_CHANNELS]; /* Index for mdm.... */
617 isdn_driver_t *drv[ISDN_MAX_DRIVERS]; /* Array of drivers */
618 isdn_net_dev *netdev; /* Linked list of net-if's */
619 char drvid[ISDN_MAX_DRIVERS][20];/* Driver-ID */
620 struct task_struct *profd; /* For iprofd */
621 isdn_modem_t mdm; /* tty-driver-data */
622 isdn_net_dev *rx_netdev[ISDN_MAX_CHANNELS]; /* rx netdev-pointers */
623 isdn_net_dev *st_netdev[ISDN_MAX_CHANNELS]; /* stat netdev-pointers */
624 ulong ibytes[ISDN_MAX_CHANNELS]; /* Statistics incoming bytes */
625 ulong obytes[ISDN_MAX_CHANNELS]; /* Statistics outgoing bytes */
626 int v110emu[ISDN_MAX_CHANNELS]; /* V.110 emulator-mode 0=none */
627 atomic_t v110use[ISDN_MAX_CHANNELS]; /* Usage-Semaphore for stream */
628 isdn_v110_stream *v110[ISDN_MAX_CHANNELS]; /* V.110 private data */
629 struct semaphore sem; /* serialize list access*/
630 unsigned long global_features;
631} isdn_dev;
632
633extern isdn_dev *dev;
634
635
636#endif /* __KERNEL__ */
637
638#endif /* __ISDN_H__ */
diff --git a/include/linux/isdn/capicmd.h b/include/linux/isdn/capicmd.h
new file mode 100644
index 000000000000..b58635f722da
--- /dev/null
+++ b/include/linux/isdn/capicmd.h
@@ -0,0 +1,115 @@
1/* $Id: capicmd.h,v 1.2.6.2 2001/09/23 22:24:33 kai Exp $
2 *
3 * CAPI 2.0 Interface for Linux
4 *
5 * Copyright 1997 by Carsten Paeth <calle@calle.de>
6 *
7 * This software may be used and distributed according to the terms
8 * of the GNU General Public License, incorporated herein by reference.
9 *
10 */
11
12#ifndef __CAPICMD_H__
13#define __CAPICMD_H__
14
15#define CAPI_MSG_BASELEN 8
16#define CAPI_DATA_B3_REQ_LEN (CAPI_MSG_BASELEN+4+4+2+2+2)
17#define CAPI_DATA_B3_RESP_LEN (CAPI_MSG_BASELEN+4+2)
18
19/*----- CAPI commands -----*/
20#define CAPI_ALERT 0x01
21#define CAPI_CONNECT 0x02
22#define CAPI_CONNECT_ACTIVE 0x03
23#define CAPI_CONNECT_B3_ACTIVE 0x83
24#define CAPI_CONNECT_B3 0x82
25#define CAPI_CONNECT_B3_T90_ACTIVE 0x88
26#define CAPI_DATA_B3 0x86
27#define CAPI_DISCONNECT_B3 0x84
28#define CAPI_DISCONNECT 0x04
29#define CAPI_FACILITY 0x80
30#define CAPI_INFO 0x08
31#define CAPI_LISTEN 0x05
32#define CAPI_MANUFACTURER 0xff
33#define CAPI_RESET_B3 0x87
34#define CAPI_SELECT_B_PROTOCOL 0x41
35
36/*----- CAPI subcommands -----*/
37
38#define CAPI_REQ 0x80
39#define CAPI_CONF 0x81
40#define CAPI_IND 0x82
41#define CAPI_RESP 0x83
42
43/*----- CAPI combined commands -----*/
44
45#define CAPICMD(cmd,subcmd) (((cmd)<<8)|(subcmd))
46
47#define CAPI_DISCONNECT_REQ CAPICMD(CAPI_DISCONNECT,CAPI_REQ)
48#define CAPI_DISCONNECT_CONF CAPICMD(CAPI_DISCONNECT,CAPI_CONF)
49#define CAPI_DISCONNECT_IND CAPICMD(CAPI_DISCONNECT,CAPI_IND)
50#define CAPI_DISCONNECT_RESP CAPICMD(CAPI_DISCONNECT,CAPI_RESP)
51
52#define CAPI_ALERT_REQ CAPICMD(CAPI_ALERT,CAPI_REQ)
53#define CAPI_ALERT_CONF CAPICMD(CAPI_ALERT,CAPI_CONF)
54
55#define CAPI_CONNECT_REQ CAPICMD(CAPI_CONNECT,CAPI_REQ)
56#define CAPI_CONNECT_CONF CAPICMD(CAPI_CONNECT,CAPI_CONF)
57#define CAPI_CONNECT_IND CAPICMD(CAPI_CONNECT,CAPI_IND)
58#define CAPI_CONNECT_RESP CAPICMD(CAPI_CONNECT,CAPI_RESP)
59
60#define CAPI_CONNECT_ACTIVE_REQ CAPICMD(CAPI_CONNECT_ACTIVE,CAPI_REQ)
61#define CAPI_CONNECT_ACTIVE_CONF CAPICMD(CAPI_CONNECT_ACTIVE,CAPI_CONF)
62#define CAPI_CONNECT_ACTIVE_IND CAPICMD(CAPI_CONNECT_ACTIVE,CAPI_IND)
63#define CAPI_CONNECT_ACTIVE_RESP CAPICMD(CAPI_CONNECT_ACTIVE,CAPI_RESP)
64
65#define CAPI_SELECT_B_PROTOCOL_REQ CAPICMD(CAPI_SELECT_B_PROTOCOL,CAPI_REQ)
66#define CAPI_SELECT_B_PROTOCOL_CONF CAPICMD(CAPI_SELECT_B_PROTOCOL,CAPI_CONF)
67
68#define CAPI_CONNECT_B3_ACTIVE_REQ CAPICMD(CAPI_CONNECT_B3_ACTIVE,CAPI_REQ)
69#define CAPI_CONNECT_B3_ACTIVE_CONF CAPICMD(CAPI_CONNECT_B3_ACTIVE,CAPI_CONF)
70#define CAPI_CONNECT_B3_ACTIVE_IND CAPICMD(CAPI_CONNECT_B3_ACTIVE,CAPI_IND)
71#define CAPI_CONNECT_B3_ACTIVE_RESP CAPICMD(CAPI_CONNECT_B3_ACTIVE,CAPI_RESP)
72
73#define CAPI_CONNECT_B3_REQ CAPICMD(CAPI_CONNECT_B3,CAPI_REQ)
74#define CAPI_CONNECT_B3_CONF CAPICMD(CAPI_CONNECT_B3,CAPI_CONF)
75#define CAPI_CONNECT_B3_IND CAPICMD(CAPI_CONNECT_B3,CAPI_IND)
76#define CAPI_CONNECT_B3_RESP CAPICMD(CAPI_CONNECT_B3,CAPI_RESP)
77
78
79#define CAPI_CONNECT_B3_T90_ACTIVE_IND CAPICMD(CAPI_CONNECT_B3_T90_ACTIVE,CAPI_IND)
80#define CAPI_CONNECT_B3_T90_ACTIVE_RESP CAPICMD(CAPI_CONNECT_B3_T90_ACTIVE,CAPI_RESP)
81
82#define CAPI_DATA_B3_REQ CAPICMD(CAPI_DATA_B3,CAPI_REQ)
83#define CAPI_DATA_B3_CONF CAPICMD(CAPI_DATA_B3,CAPI_CONF)
84#define CAPI_DATA_B3_IND CAPICMD(CAPI_DATA_B3,CAPI_IND)
85#define CAPI_DATA_B3_RESP CAPICMD(CAPI_DATA_B3,CAPI_RESP)
86
87#define CAPI_DISCONNECT_B3_REQ CAPICMD(CAPI_DISCONNECT_B3,CAPI_REQ)
88#define CAPI_DISCONNECT_B3_CONF CAPICMD(CAPI_DISCONNECT_B3,CAPI_CONF)
89#define CAPI_DISCONNECT_B3_IND CAPICMD(CAPI_DISCONNECT_B3,CAPI_IND)
90#define CAPI_DISCONNECT_B3_RESP CAPICMD(CAPI_DISCONNECT_B3,CAPI_RESP)
91
92#define CAPI_RESET_B3_REQ CAPICMD(CAPI_RESET_B3,CAPI_REQ)
93#define CAPI_RESET_B3_CONF CAPICMD(CAPI_RESET_B3,CAPI_CONF)
94#define CAPI_RESET_B3_IND CAPICMD(CAPI_RESET_B3,CAPI_IND)
95#define CAPI_RESET_B3_RESP CAPICMD(CAPI_RESET_B3,CAPI_RESP)
96
97#define CAPI_LISTEN_REQ CAPICMD(CAPI_LISTEN,CAPI_REQ)
98#define CAPI_LISTEN_CONF CAPICMD(CAPI_LISTEN,CAPI_CONF)
99
100#define CAPI_MANUFACTURER_REQ CAPICMD(CAPI_MANUFACTURER,CAPI_REQ)
101#define CAPI_MANUFACTURER_CONF CAPICMD(CAPI_MANUFACTURER,CAPI_CONF)
102#define CAPI_MANUFACTURER_IND CAPICMD(CAPI_MANUFACTURER,CAPI_IND)
103#define CAPI_MANUFACTURER_RESP CAPICMD(CAPI_MANUFACTURER,CAPI_RESP)
104
105#define CAPI_FACILITY_REQ CAPICMD(CAPI_FACILITY,CAPI_REQ)
106#define CAPI_FACILITY_CONF CAPICMD(CAPI_FACILITY,CAPI_CONF)
107#define CAPI_FACILITY_IND CAPICMD(CAPI_FACILITY,CAPI_IND)
108#define CAPI_FACILITY_RESP CAPICMD(CAPI_FACILITY,CAPI_RESP)
109
110#define CAPI_INFO_REQ CAPICMD(CAPI_INFO,CAPI_REQ)
111#define CAPI_INFO_CONF CAPICMD(CAPI_INFO,CAPI_CONF)
112#define CAPI_INFO_IND CAPICMD(CAPI_INFO,CAPI_IND)
113#define CAPI_INFO_RESP CAPICMD(CAPI_INFO,CAPI_RESP)
114
115#endif /* __CAPICMD_H__ */
diff --git a/include/linux/isdn/capilli.h b/include/linux/isdn/capilli.h
new file mode 100644
index 000000000000..35e9b0fd014b
--- /dev/null
+++ b/include/linux/isdn/capilli.h
@@ -0,0 +1,113 @@
1/* $Id: capilli.h,v 1.1.2.2 2004/01/16 21:09:27 keil Exp $
2 *
3 * Kernel CAPI 2.0 Driver Interface for Linux
4 *
5 * Copyright 1999 by Carsten Paeth <calle@calle.de>
6 *
7 * This software may be used and distributed according to the terms
8 * of the GNU General Public License, incorporated herein by reference.
9 *
10 */
11
12#ifndef __CAPILLI_H__
13#define __CAPILLI_H__
14
15#include <linux/kernel.h>
16#include <linux/list.h>
17#include <linux/capi.h>
18#include <linux/kernelcapi.h>
19
20typedef struct capiloaddatapart {
21 int user; /* data in userspace ? */
22 int len;
23 unsigned char *data;
24} capiloaddatapart;
25
26typedef struct capiloaddata {
27 capiloaddatapart firmware;
28 capiloaddatapart configuration;
29} capiloaddata;
30
31typedef struct capicardparams {
32 unsigned int port;
33 unsigned irq;
34 int cardtype;
35 int cardnr;
36 unsigned int membase;
37} capicardparams;
38
39struct capi_ctr {
40 /* filled in before calling attach_capi_ctr */
41 struct module *owner;
42 void *driverdata; /* driver specific */
43 char name[32]; /* name of controller */
44 char *driver_name; /* name of driver */
45 int (*load_firmware)(struct capi_ctr *, capiloaddata *);
46 void (*reset_ctr)(struct capi_ctr *);
47 void (*register_appl)(struct capi_ctr *, u16 appl,
48 capi_register_params *);
49 void (*release_appl)(struct capi_ctr *, u16 appl);
50 u16 (*send_message)(struct capi_ctr *, struct sk_buff *skb);
51
52 char *(*procinfo)(struct capi_ctr *);
53 int (*ctr_read_proc)(char *page, char **start, off_t off,
54 int count, int *eof, struct capi_ctr *card);
55
56 /* filled in before calling ready callback */
57 u8 manu[CAPI_MANUFACTURER_LEN]; /* CAPI_GET_MANUFACTURER */
58 capi_version version; /* CAPI_GET_VERSION */
59 capi_profile profile; /* CAPI_GET_PROFILE */
60 u8 serial[CAPI_SERIAL_LEN]; /* CAPI_GET_SERIAL */
61
62 /* management information for kcapi */
63
64 unsigned long nrecvctlpkt;
65 unsigned long nrecvdatapkt;
66 unsigned long nsentctlpkt;
67 unsigned long nsentdatapkt;
68
69 int cnr; /* controller number */
70 volatile unsigned short cardstate; /* controller state */
71 volatile int blocked; /* output blocked */
72 int traceflag; /* capi trace */
73
74 struct proc_dir_entry *procent;
75 char procfn[128];
76};
77
78int attach_capi_ctr(struct capi_ctr *);
79int detach_capi_ctr(struct capi_ctr *);
80
81void capi_ctr_ready(struct capi_ctr * card);
82void capi_ctr_reseted(struct capi_ctr * card);
83void capi_ctr_suspend_output(struct capi_ctr * card);
84void capi_ctr_resume_output(struct capi_ctr * card);
85void capi_ctr_handle_message(struct capi_ctr * card, u16 appl, struct sk_buff *skb);
86
87// ---------------------------------------------------------------------------
88// needed for AVM capi drivers
89
90struct capi_driver {
91 char name[32]; /* driver name */
92 char revision[32];
93
94 int (*add_card)(struct capi_driver *driver, capicardparams *data);
95
96 /* management information for kcapi */
97 struct list_head list;
98};
99
100void register_capi_driver(struct capi_driver *driver);
101void unregister_capi_driver(struct capi_driver *driver);
102
103// ---------------------------------------------------------------------------
104// library functions for use by hardware controller drivers
105
106void capilib_new_ncci(struct list_head *head, u16 applid, u32 ncci, u32 winsize);
107void capilib_free_ncci(struct list_head *head, u16 applid, u32 ncci);
108void capilib_release_appl(struct list_head *head, u16 applid);
109void capilib_release(struct list_head *head);
110void capilib_data_b3_conf(struct list_head *head, u16 applid, u32 ncci, u16 msgid);
111u16 capilib_data_b3_req(struct list_head *head, u16 applid, u32 ncci, u16 msgid);
112
113#endif /* __CAPILLI_H__ */
diff --git a/include/linux/isdn/capiutil.h b/include/linux/isdn/capiutil.h
new file mode 100644
index 000000000000..2e79f816703b
--- /dev/null
+++ b/include/linux/isdn/capiutil.h
@@ -0,0 +1,505 @@
1/* $Id: capiutil.h,v 1.5.6.2 2001/09/23 22:24:33 kai Exp $
2 *
3 * CAPI 2.0 defines & types
4 *
5 * From CAPI 2.0 Development Kit AVM 1995 (msg.c)
6 * Rewritten for Linux 1996 by Carsten Paeth <calle@calle.de>
7 *
8 * This software may be used and distributed according to the terms
9 * of the GNU General Public License, incorporated herein by reference.
10 *
11 */
12
13#ifndef __CAPIUTIL_H__
14#define __CAPIUTIL_H__
15
16#include <asm/types.h>
17
18#define CAPIMSG_BASELEN 8
19#define CAPIMSG_U8(m, off) (m[off])
20#define CAPIMSG_U16(m, off) (m[off]|(m[(off)+1]<<8))
21#define CAPIMSG_U32(m, off) (m[off]|(m[(off)+1]<<8)|(m[(off)+2]<<16)|(m[(off)+3]<<24))
22#define CAPIMSG_LEN(m) CAPIMSG_U16(m,0)
23#define CAPIMSG_APPID(m) CAPIMSG_U16(m,2)
24#define CAPIMSG_COMMAND(m) CAPIMSG_U8(m,4)
25#define CAPIMSG_SUBCOMMAND(m) CAPIMSG_U8(m,5)
26#define CAPIMSG_CMD(m) (((m[4])<<8)|(m[5]))
27#define CAPIMSG_MSGID(m) CAPIMSG_U16(m,6)
28#define CAPIMSG_CONTROLLER(m) (m[8] & 0x7f)
29#define CAPIMSG_CONTROL(m) CAPIMSG_U32(m, 8)
30#define CAPIMSG_NCCI(m) CAPIMSG_CONTROL(m)
31#define CAPIMSG_DATALEN(m) CAPIMSG_U16(m,16) /* DATA_B3_REQ */
32
33static inline void capimsg_setu8(void *m, int off, __u8 val)
34{
35 ((__u8 *)m)[off] = val;
36}
37
38static inline void capimsg_setu16(void *m, int off, __u16 val)
39{
40 ((__u8 *)m)[off] = val & 0xff;
41 ((__u8 *)m)[off+1] = (val >> 8) & 0xff;
42}
43
44static inline void capimsg_setu32(void *m, int off, __u32 val)
45{
46 ((__u8 *)m)[off] = val & 0xff;
47 ((__u8 *)m)[off+1] = (val >> 8) & 0xff;
48 ((__u8 *)m)[off+2] = (val >> 16) & 0xff;
49 ((__u8 *)m)[off+3] = (val >> 24) & 0xff;
50}
51
52#define CAPIMSG_SETLEN(m, len) capimsg_setu16(m, 0, len)
53#define CAPIMSG_SETAPPID(m, applid) capimsg_setu16(m, 2, applid)
54#define CAPIMSG_SETCOMMAND(m,cmd) capimsg_setu8(m, 4, cmd)
55#define CAPIMSG_SETSUBCOMMAND(m, cmd) capimsg_setu8(m, 5, cmd)
56#define CAPIMSG_SETMSGID(m, msgid) capimsg_setu16(m, 6, msgid)
57#define CAPIMSG_SETCONTROL(m, contr) capimsg_setu32(m, 8, contr)
58#define CAPIMSG_SETDATALEN(m, len) capimsg_setu16(m, 16, len)
59
60/*----- basic-type definitions -----*/
61
62typedef __u8 *_cstruct;
63
64typedef enum {
65 CAPI_COMPOSE,
66 CAPI_DEFAULT
67} _cmstruct;
68
69/*
70 The _cmsg structure contains all possible CAPI 2.0 parameter.
71 All parameters are stored here first. The function CAPI_CMSG_2_MESSAGE
72 assembles the parameter and builds CAPI2.0 conform messages.
73 CAPI_MESSAGE_2_CMSG disassembles CAPI 2.0 messages and stores the
74 parameter in the _cmsg structure
75 */
76
77typedef struct {
78 /* Header */
79 __u16 ApplId;
80 __u8 Command;
81 __u8 Subcommand;
82 __u16 Messagenumber;
83
84 /* Parameter */
85 union {
86 __u32 adrController;
87 __u32 adrPLCI;
88 __u32 adrNCCI;
89 } adr;
90
91 _cmstruct AdditionalInfo;
92 _cstruct B1configuration;
93 __u16 B1protocol;
94 _cstruct B2configuration;
95 __u16 B2protocol;
96 _cstruct B3configuration;
97 __u16 B3protocol;
98 _cstruct BC;
99 _cstruct BChannelinformation;
100 _cmstruct BProtocol;
101 _cstruct CalledPartyNumber;
102 _cstruct CalledPartySubaddress;
103 _cstruct CallingPartyNumber;
104 _cstruct CallingPartySubaddress;
105 __u32 CIPmask;
106 __u32 CIPmask2;
107 __u16 CIPValue;
108 __u32 Class;
109 _cstruct ConnectedNumber;
110 _cstruct ConnectedSubaddress;
111 __u32 Data;
112 __u16 DataHandle;
113 __u16 DataLength;
114 _cstruct FacilityConfirmationParameter;
115 _cstruct Facilitydataarray;
116 _cstruct FacilityIndicationParameter;
117 _cstruct FacilityRequestParameter;
118 __u16 FacilitySelector;
119 __u16 Flags;
120 __u32 Function;
121 _cstruct HLC;
122 __u16 Info;
123 _cstruct InfoElement;
124 __u32 InfoMask;
125 __u16 InfoNumber;
126 _cstruct Keypadfacility;
127 _cstruct LLC;
128 _cstruct ManuData;
129 __u32 ManuID;
130 _cstruct NCPI;
131 __u16 Reason;
132 __u16 Reason_B3;
133 __u16 Reject;
134 _cstruct Useruserdata;
135
136 /* intern */
137 unsigned l, p;
138 unsigned char *par;
139 __u8 *m;
140
141 /* buffer to construct message */
142 __u8 buf[180];
143
144} _cmsg;
145
146/*
147 * capi_cmsg2message() assembles the parameter from _cmsg to a CAPI 2.0
148 * conform message
149 */
150unsigned capi_cmsg2message(_cmsg * cmsg, __u8 * msg);
151
152/*
153 * capi_message2cmsg disassembles a CAPI message an writes the parameter
154 * into _cmsg for easy access
155 */
156unsigned capi_message2cmsg(_cmsg * cmsg, __u8 * msg);
157
158/*
159 * capi_cmsg_header() fills the _cmsg structure with default values, so only
160 * parameter with non default values must be changed before sending the
161 * message.
162 */
163unsigned capi_cmsg_header(_cmsg * cmsg, __u16 _ApplId,
164 __u8 _Command, __u8 _Subcommand,
165 __u16 _Messagenumber, __u32 _Controller);
166
167/*
168 * capi_info2str generated a readable string for Capi2.0 reasons.
169 */
170char *capi_info2str(__u16 reason);
171
172/*-----------------------------------------------------------------------*/
173
174/*
175 * Debugging / Tracing functions
176 */
177char *capi_cmd2str(__u8 cmd, __u8 subcmd);
178char *capi_cmsg2str(_cmsg * cmsg);
179char *capi_message2str(__u8 * msg);
180
181/*-----------------------------------------------------------------------*/
182
183static inline void capi_cmsg_answer(_cmsg * cmsg)
184{
185 cmsg->Subcommand |= 0x01;
186}
187
188/*-----------------------------------------------------------------------*/
189
190static inline void capi_fill_CONNECT_B3_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
191 __u32 adr,
192 _cstruct NCPI)
193{
194 capi_cmsg_header(cmsg, ApplId, 0x82, 0x80, Messagenumber, adr);
195 cmsg->NCPI = NCPI;
196}
197
198static inline void capi_fill_FACILITY_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
199 __u32 adr,
200 __u16 FacilitySelector,
201 _cstruct FacilityRequestParameter)
202{
203 capi_cmsg_header(cmsg, ApplId, 0x80, 0x80, Messagenumber, adr);
204 cmsg->FacilitySelector = FacilitySelector;
205 cmsg->FacilityRequestParameter = FacilityRequestParameter;
206}
207
208static inline void capi_fill_INFO_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
209 __u32 adr,
210 _cstruct CalledPartyNumber,
211 _cstruct BChannelinformation,
212 _cstruct Keypadfacility,
213 _cstruct Useruserdata,
214 _cstruct Facilitydataarray)
215{
216 capi_cmsg_header(cmsg, ApplId, 0x08, 0x80, Messagenumber, adr);
217 cmsg->CalledPartyNumber = CalledPartyNumber;
218 cmsg->BChannelinformation = BChannelinformation;
219 cmsg->Keypadfacility = Keypadfacility;
220 cmsg->Useruserdata = Useruserdata;
221 cmsg->Facilitydataarray = Facilitydataarray;
222}
223
224static inline void capi_fill_LISTEN_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
225 __u32 adr,
226 __u32 InfoMask,
227 __u32 CIPmask,
228 __u32 CIPmask2,
229 _cstruct CallingPartyNumber,
230 _cstruct CallingPartySubaddress)
231{
232 capi_cmsg_header(cmsg, ApplId, 0x05, 0x80, Messagenumber, adr);
233 cmsg->InfoMask = InfoMask;
234 cmsg->CIPmask = CIPmask;
235 cmsg->CIPmask2 = CIPmask2;
236 cmsg->CallingPartyNumber = CallingPartyNumber;
237 cmsg->CallingPartySubaddress = CallingPartySubaddress;
238}
239
240static inline void capi_fill_ALERT_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
241 __u32 adr,
242 _cstruct BChannelinformation,
243 _cstruct Keypadfacility,
244 _cstruct Useruserdata,
245 _cstruct Facilitydataarray)
246{
247 capi_cmsg_header(cmsg, ApplId, 0x01, 0x80, Messagenumber, adr);
248 cmsg->BChannelinformation = BChannelinformation;
249 cmsg->Keypadfacility = Keypadfacility;
250 cmsg->Useruserdata = Useruserdata;
251 cmsg->Facilitydataarray = Facilitydataarray;
252}
253
254static inline void capi_fill_CONNECT_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
255 __u32 adr,
256 __u16 CIPValue,
257 _cstruct CalledPartyNumber,
258 _cstruct CallingPartyNumber,
259 _cstruct CalledPartySubaddress,
260 _cstruct CallingPartySubaddress,
261 __u16 B1protocol,
262 __u16 B2protocol,
263 __u16 B3protocol,
264 _cstruct B1configuration,
265 _cstruct B2configuration,
266 _cstruct B3configuration,
267 _cstruct BC,
268 _cstruct LLC,
269 _cstruct HLC,
270 _cstruct BChannelinformation,
271 _cstruct Keypadfacility,
272 _cstruct Useruserdata,
273 _cstruct Facilitydataarray)
274{
275
276 capi_cmsg_header(cmsg, ApplId, 0x02, 0x80, Messagenumber, adr);
277 cmsg->CIPValue = CIPValue;
278 cmsg->CalledPartyNumber = CalledPartyNumber;
279 cmsg->CallingPartyNumber = CallingPartyNumber;
280 cmsg->CalledPartySubaddress = CalledPartySubaddress;
281 cmsg->CallingPartySubaddress = CallingPartySubaddress;
282 cmsg->B1protocol = B1protocol;
283 cmsg->B2protocol = B2protocol;
284 cmsg->B3protocol = B3protocol;
285 cmsg->B1configuration = B1configuration;
286 cmsg->B2configuration = B2configuration;
287 cmsg->B3configuration = B3configuration;
288 cmsg->BC = BC;
289 cmsg->LLC = LLC;
290 cmsg->HLC = HLC;
291 cmsg->BChannelinformation = BChannelinformation;
292 cmsg->Keypadfacility = Keypadfacility;
293 cmsg->Useruserdata = Useruserdata;
294 cmsg->Facilitydataarray = Facilitydataarray;
295}
296
297static inline void capi_fill_DATA_B3_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
298 __u32 adr,
299 __u32 Data,
300 __u16 DataLength,
301 __u16 DataHandle,
302 __u16 Flags)
303{
304
305 capi_cmsg_header(cmsg, ApplId, 0x86, 0x80, Messagenumber, adr);
306 cmsg->Data = Data;
307 cmsg->DataLength = DataLength;
308 cmsg->DataHandle = DataHandle;
309 cmsg->Flags = Flags;
310}
311
312static inline void capi_fill_DISCONNECT_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
313 __u32 adr,
314 _cstruct BChannelinformation,
315 _cstruct Keypadfacility,
316 _cstruct Useruserdata,
317 _cstruct Facilitydataarray)
318{
319
320 capi_cmsg_header(cmsg, ApplId, 0x04, 0x80, Messagenumber, adr);
321 cmsg->BChannelinformation = BChannelinformation;
322 cmsg->Keypadfacility = Keypadfacility;
323 cmsg->Useruserdata = Useruserdata;
324 cmsg->Facilitydataarray = Facilitydataarray;
325}
326
327static inline void capi_fill_DISCONNECT_B3_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
328 __u32 adr,
329 _cstruct NCPI)
330{
331
332 capi_cmsg_header(cmsg, ApplId, 0x84, 0x80, Messagenumber, adr);
333 cmsg->NCPI = NCPI;
334}
335
336static inline void capi_fill_MANUFACTURER_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
337 __u32 adr,
338 __u32 ManuID,
339 __u32 Class,
340 __u32 Function,
341 _cstruct ManuData)
342{
343
344 capi_cmsg_header(cmsg, ApplId, 0xff, 0x80, Messagenumber, adr);
345 cmsg->ManuID = ManuID;
346 cmsg->Class = Class;
347 cmsg->Function = Function;
348 cmsg->ManuData = ManuData;
349}
350
351static inline void capi_fill_RESET_B3_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
352 __u32 adr,
353 _cstruct NCPI)
354{
355
356 capi_cmsg_header(cmsg, ApplId, 0x87, 0x80, Messagenumber, adr);
357 cmsg->NCPI = NCPI;
358}
359
360static inline void capi_fill_SELECT_B_PROTOCOL_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
361 __u32 adr,
362 __u16 B1protocol,
363 __u16 B2protocol,
364 __u16 B3protocol,
365 _cstruct B1configuration,
366 _cstruct B2configuration,
367 _cstruct B3configuration)
368{
369
370 capi_cmsg_header(cmsg, ApplId, 0x41, 0x80, Messagenumber, adr);
371 cmsg->B1protocol = B1protocol;
372 cmsg->B2protocol = B2protocol;
373 cmsg->B3protocol = B3protocol;
374 cmsg->B1configuration = B1configuration;
375 cmsg->B2configuration = B2configuration;
376 cmsg->B3configuration = B3configuration;
377}
378
379static inline void capi_fill_CONNECT_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
380 __u32 adr,
381 __u16 Reject,
382 __u16 B1protocol,
383 __u16 B2protocol,
384 __u16 B3protocol,
385 _cstruct B1configuration,
386 _cstruct B2configuration,
387 _cstruct B3configuration,
388 _cstruct ConnectedNumber,
389 _cstruct ConnectedSubaddress,
390 _cstruct LLC,
391 _cstruct BChannelinformation,
392 _cstruct Keypadfacility,
393 _cstruct Useruserdata,
394 _cstruct Facilitydataarray)
395{
396 capi_cmsg_header(cmsg, ApplId, 0x02, 0x83, Messagenumber, adr);
397 cmsg->Reject = Reject;
398 cmsg->B1protocol = B1protocol;
399 cmsg->B2protocol = B2protocol;
400 cmsg->B3protocol = B3protocol;
401 cmsg->B1configuration = B1configuration;
402 cmsg->B2configuration = B2configuration;
403 cmsg->B3configuration = B3configuration;
404 cmsg->ConnectedNumber = ConnectedNumber;
405 cmsg->ConnectedSubaddress = ConnectedSubaddress;
406 cmsg->LLC = LLC;
407 cmsg->BChannelinformation = BChannelinformation;
408 cmsg->Keypadfacility = Keypadfacility;
409 cmsg->Useruserdata = Useruserdata;
410 cmsg->Facilitydataarray = Facilitydataarray;
411}
412
413static inline void capi_fill_CONNECT_ACTIVE_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
414 __u32 adr)
415{
416
417 capi_cmsg_header(cmsg, ApplId, 0x03, 0x83, Messagenumber, adr);
418}
419
420static inline void capi_fill_CONNECT_B3_ACTIVE_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
421 __u32 adr)
422{
423
424 capi_cmsg_header(cmsg, ApplId, 0x83, 0x83, Messagenumber, adr);
425}
426
427static inline void capi_fill_CONNECT_B3_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
428 __u32 adr,
429 __u16 Reject,
430 _cstruct NCPI)
431{
432 capi_cmsg_header(cmsg, ApplId, 0x82, 0x83, Messagenumber, adr);
433 cmsg->Reject = Reject;
434 cmsg->NCPI = NCPI;
435}
436
437static inline void capi_fill_CONNECT_B3_T90_ACTIVE_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
438 __u32 adr)
439{
440
441 capi_cmsg_header(cmsg, ApplId, 0x88, 0x83, Messagenumber, adr);
442}
443
444static inline void capi_fill_DATA_B3_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
445 __u32 adr,
446 __u16 DataHandle)
447{
448
449 capi_cmsg_header(cmsg, ApplId, 0x86, 0x83, Messagenumber, adr);
450 cmsg->DataHandle = DataHandle;
451}
452
453static inline void capi_fill_DISCONNECT_B3_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
454 __u32 adr)
455{
456
457 capi_cmsg_header(cmsg, ApplId, 0x84, 0x83, Messagenumber, adr);
458}
459
460static inline void capi_fill_DISCONNECT_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
461 __u32 adr)
462{
463
464 capi_cmsg_header(cmsg, ApplId, 0x04, 0x83, Messagenumber, adr);
465}
466
467static inline void capi_fill_FACILITY_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
468 __u32 adr,
469 __u16 FacilitySelector)
470{
471
472 capi_cmsg_header(cmsg, ApplId, 0x80, 0x83, Messagenumber, adr);
473 cmsg->FacilitySelector = FacilitySelector;
474}
475
476static inline void capi_fill_INFO_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
477 __u32 adr)
478{
479
480 capi_cmsg_header(cmsg, ApplId, 0x08, 0x83, Messagenumber, adr);
481}
482
483static inline void capi_fill_MANUFACTURER_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
484 __u32 adr,
485 __u32 ManuID,
486 __u32 Class,
487 __u32 Function,
488 _cstruct ManuData)
489{
490
491 capi_cmsg_header(cmsg, ApplId, 0xff, 0x83, Messagenumber, adr);
492 cmsg->ManuID = ManuID;
493 cmsg->Class = Class;
494 cmsg->Function = Function;
495 cmsg->ManuData = ManuData;
496}
497
498static inline void capi_fill_RESET_B3_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
499 __u32 adr)
500{
501
502 capi_cmsg_header(cmsg, ApplId, 0x87, 0x83, Messagenumber, adr);
503}
504
505#endif /* __CAPIUTIL_H__ */
diff --git a/include/linux/isdn/tpam.h b/include/linux/isdn/tpam.h
new file mode 100644
index 000000000000..9f65bea49d11
--- /dev/null
+++ b/include/linux/isdn/tpam.h
@@ -0,0 +1,56 @@
1/* $Id: tpam.h,v 1.1.2.1 2001/06/08 08:23:46 kai Exp $
2 *
3 * Turbo PAM ISDN driver for Linux. (Kernel Driver)
4 *
5 * Copyright 2001 Stelian Pop <stelian.pop@fr.alcove.com>, Alcôve
6 *
7 * For all support questions please contact: <support@auvertech.fr>
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, or (at your option)
12 * any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 */
24
25#ifndef _TPAM_H_
26#define _TPAM_H_
27
28#include <linux/types.h>
29#include <linux/pci.h>
30
31/* IOCTL commands */
32#define TPAM_CMD_DSPLOAD 0x0001
33#define TPAM_CMD_DSPSAVE 0x0002
34#define TPAM_CMD_DSPRUN 0x0003
35#define TPAM_CMD_LOOPMODEON 0x0004
36#define TPAM_CMD_LOOPMODEOFF 0x0005
37
38/* addresses of debug information zones on board */
39#define TPAM_TRAPAUDIT_REGISTER 0x005493e4
40#define TPAM_NCOAUDIT_REGISTER 0x00500000
41#define TPAM_MSGAUDIT_REGISTER 0x008E30F0
42
43/* length of debug information zones on board */
44#define TPAM_TRAPAUDIT_LENGTH 10000
45#define TPAM_NCOAUDIT_LENGTH 300000
46#define TPAM_NCOAUDIT_COUNT 30
47#define TPAM_MSGAUDIT_LENGTH 60000
48
49/* IOCTL load/save parameter */
50typedef struct tpam_dsp_ioctl {
51 __u32 address; /* address to load/save data */
52 __u32 data_len; /* size of data to be loaded/saved */
53 __u8 data[0]; /* data */
54} tpam_dsp_ioctl;
55
56#endif /* _TPAM_H_ */
diff --git a/include/linux/isdn_divertif.h b/include/linux/isdn_divertif.h
new file mode 100644
index 000000000000..0e7e44ce8301
--- /dev/null
+++ b/include/linux/isdn_divertif.h
@@ -0,0 +1,42 @@
1/* $Id: isdn_divertif.h,v 1.4.6.1 2001/09/23 22:25:05 kai Exp $
2 *
3 * Header for the diversion supplementary interface for i4l.
4 *
5 * Author Werner Cornelius (werner@titro.de)
6 * Copyright by Werner Cornelius (werner@titro.de)
7 *
8 * This software may be used and distributed according to the terms
9 * of the GNU General Public License, incorporated herein by reference.
10 *
11 */
12
13
14/***********************************************************/
15/* magic value is also used to control version information */
16/***********************************************************/
17#define DIVERT_IF_MAGIC 0x25873401
18#define DIVERT_CMD_REG 0x00 /* register command */
19#define DIVERT_CMD_REL 0x01 /* release command */
20#define DIVERT_NO_ERR 0x00 /* return value no error */
21#define DIVERT_CMD_ERR 0x01 /* invalid cmd */
22#define DIVERT_VER_ERR 0x02 /* magic/version invalid */
23#define DIVERT_REG_ERR 0x03 /* module already registered */
24#define DIVERT_REL_ERR 0x04 /* module not registered */
25#define DIVERT_REG_NAME isdn_register_divert
26
27/***************************************************************/
28/* structure exchanging data between isdn hl and divert module */
29/***************************************************************/
30typedef struct
31 { ulong if_magic; /* magic info and version */
32 int cmd; /* command */
33 int (*stat_callback)(isdn_ctrl *); /* supplied by divert module when calling */
34 int (*ll_cmd)(isdn_ctrl *); /* supplied by hl on return */
35 char * (*drv_to_name)(int); /* map a driver id to name, supplied by hl */
36 int (*name_to_drv)(char *); /* map a driver id to name, supplied by hl */
37 } isdn_divert_if;
38
39/*********************/
40/* function register */
41/*********************/
42extern int DIVERT_REG_NAME(isdn_divert_if *);
diff --git a/include/linux/isdn_ppp.h b/include/linux/isdn_ppp.h
new file mode 100644
index 000000000000..26b00a76e135
--- /dev/null
+++ b/include/linux/isdn_ppp.h
@@ -0,0 +1,249 @@
1/* Linux ISDN subsystem, sync PPP, interface to ipppd
2 *
3 * Copyright 1994-1999 by Fritz Elfert (fritz@isdn4linux.de)
4 * Copyright 1995,96 Thinking Objects Software GmbH Wuerzburg
5 * Copyright 1995,96 by Michael Hipp (Michael.Hipp@student.uni-tuebingen.de)
6 * Copyright 2000-2002 by Kai Germaschewski (kai@germaschewski.name)
7 *
8 * This software may be used and distributed according to the terms
9 * of the GNU General Public License, incorporated herein by reference.
10 *
11 */
12
13#ifndef _LINUX_ISDN_PPP_H
14#define _LINUX_ISDN_PPP_H
15
16#define CALLTYPE_INCOMING 0x1
17#define CALLTYPE_OUTGOING 0x2
18#define CALLTYPE_CALLBACK 0x4
19
20#define IPPP_VERSION "2.2.0"
21
22struct pppcallinfo
23{
24 int calltype;
25 unsigned char local_num[64];
26 unsigned char remote_num[64];
27 int charge_units;
28};
29
30#define PPPIOCGCALLINFO _IOWR('t',128,struct pppcallinfo)
31#define PPPIOCBUNDLE _IOW('t',129,int)
32#define PPPIOCGMPFLAGS _IOR('t',130,int)
33#define PPPIOCSMPFLAGS _IOW('t',131,int)
34#define PPPIOCSMPMTU _IOW('t',132,int)
35#define PPPIOCSMPMRU _IOW('t',133,int)
36#define PPPIOCGCOMPRESSORS _IOR('t',134,unsigned long [8])
37#define PPPIOCSCOMPRESSOR _IOW('t',135,int)
38#define PPPIOCGIFNAME _IOR('t',136, char [IFNAMSIZ] )
39
40
41#define SC_MP_PROT 0x00000200
42#define SC_REJ_MP_PROT 0x00000400
43#define SC_OUT_SHORT_SEQ 0x00000800
44#define SC_IN_SHORT_SEQ 0x00004000
45
46#define SC_DECOMP_ON 0x01
47#define SC_COMP_ON 0x02
48#define SC_DECOMP_DISCARD 0x04
49#define SC_COMP_DISCARD 0x08
50#define SC_LINK_DECOMP_ON 0x10
51#define SC_LINK_COMP_ON 0x20
52#define SC_LINK_DECOMP_DISCARD 0x40
53#define SC_LINK_COMP_DISCARD 0x80
54
55#define ISDN_PPP_COMP_MAX_OPTIONS 16
56
57#define IPPP_COMP_FLAG_XMIT 0x1
58#define IPPP_COMP_FLAG_LINK 0x2
59
60struct isdn_ppp_comp_data {
61 int num;
62 unsigned char options[ISDN_PPP_COMP_MAX_OPTIONS];
63 int optlen;
64 int flags;
65};
66
67#ifdef __KERNEL__
68
69
70#include <linux/config.h>
71
72#ifdef CONFIG_IPPP_FILTER
73#include <linux/filter.h>
74#endif
75
76#define DECOMP_ERR_NOMEM (-10)
77
78#define MP_END_FRAG 0x40
79#define MP_BEGIN_FRAG 0x80
80
81#define MP_MAX_QUEUE_LEN 16
82
83/*
84 * We need a way for the decompressor to influence the generation of CCP
85 * Reset-Requests in a variety of ways. The decompressor is already returning
86 * a lot of information (generated skb length, error conditions) so we use
87 * another parameter. This parameter is a pointer to a structure which is
88 * to be marked valid by the decompressor and only in this case is ever used.
89 * Furthermore, the only case where this data is used is when the decom-
90 * pressor returns DECOMP_ERROR.
91 *
92 * We use this same struct for the reset entry of the compressor to commu-
93 * nicate to its caller how to deal with sending of a Reset Ack. In this
94 * case, expra is not used, but other options still apply (suppressing
95 * sending with rsend, appending arbitrary data, etc).
96 */
97
98#define IPPP_RESET_MAXDATABYTES 32
99
100struct isdn_ppp_resetparams {
101 unsigned char valid:1; /* rw Is this structure filled at all ? */
102 unsigned char rsend:1; /* rw Should we send one at all ? */
103 unsigned char idval:1; /* rw Is the id field valid ? */
104 unsigned char dtval:1; /* rw Is the data field valid ? */
105 unsigned char expra:1; /* rw Is an Ack expected for this Req ? */
106 unsigned char id; /* wo Send CCP ResetReq with this id */
107 unsigned short maxdlen; /* ro Max bytes to be stored in data field */
108 unsigned short dlen; /* rw Bytes stored in data field */
109 unsigned char *data; /* wo Data for ResetReq info field */
110};
111
112/*
113 * this is an 'old friend' from ppp-comp.h under a new name
114 * check the original include for more information
115 */
116struct isdn_ppp_compressor {
117 struct isdn_ppp_compressor *next, *prev;
118 struct module *owner;
119 int num; /* CCP compression protocol number */
120
121 void *(*alloc) (struct isdn_ppp_comp_data *);
122 void (*free) (void *state);
123 int (*init) (void *state, struct isdn_ppp_comp_data *,
124 int unit,int debug);
125
126 /* The reset entry needs to get more exact information about the
127 ResetReq or ResetAck it was called with. The parameters are
128 obvious. If reset is called without a Req or Ack frame which
129 could be handed into it, code MUST be set to 0. Using rsparm,
130 the reset entry can control if and how a ResetAck is returned. */
131
132 void (*reset) (void *state, unsigned char code, unsigned char id,
133 unsigned char *data, unsigned len,
134 struct isdn_ppp_resetparams *rsparm);
135
136 int (*compress) (void *state, struct sk_buff *in,
137 struct sk_buff *skb_out, int proto);
138
139 int (*decompress) (void *state,struct sk_buff *in,
140 struct sk_buff *skb_out,
141 struct isdn_ppp_resetparams *rsparm);
142
143 void (*incomp) (void *state, struct sk_buff *in,int proto);
144 void (*stat) (void *state, struct compstat *stats);
145};
146
147extern int isdn_ppp_register_compressor(struct isdn_ppp_compressor *);
148extern int isdn_ppp_unregister_compressor(struct isdn_ppp_compressor *);
149extern int isdn_ppp_dial_slave(char *);
150extern int isdn_ppp_hangup_slave(char *);
151
152typedef struct {
153 unsigned long seqerrs;
154 unsigned long frame_drops;
155 unsigned long overflows;
156 unsigned long max_queue_len;
157} isdn_mppp_stats;
158
159typedef struct {
160 int mp_mrru; /* unused */
161 struct sk_buff * frags; /* fragments sl list -- use skb->next */
162 long frames; /* number of frames in the frame list */
163 unsigned int seq; /* last processed packet seq #: any packets
164 * with smaller seq # will be dropped
165 * unconditionally */
166 spinlock_t lock;
167 int ref_ct;
168 /* statistics */
169 isdn_mppp_stats stats;
170} ippp_bundle;
171
172#define NUM_RCV_BUFFS 64
173
174struct ippp_buf_queue {
175 struct ippp_buf_queue *next;
176 struct ippp_buf_queue *last;
177 char *buf; /* NULL here indicates end of queue */
178 int len;
179};
180
181/* The data structure for one CCP reset transaction */
182enum ippp_ccp_reset_states {
183 CCPResetIdle,
184 CCPResetSentReq,
185 CCPResetRcvdReq,
186 CCPResetSentAck,
187 CCPResetRcvdAck
188};
189
190struct ippp_ccp_reset_state {
191 enum ippp_ccp_reset_states state; /* State of this transaction */
192 struct ippp_struct *is; /* Backlink to device stuff */
193 unsigned char id; /* Backlink id index */
194 unsigned char ta:1; /* The timer is active (flag) */
195 unsigned char expra:1; /* We expect a ResetAck at all */
196 int dlen; /* Databytes stored in data */
197 struct timer_list timer; /* For timeouts/retries */
198 /* This is a hack but seems sufficient for the moment. We do not want
199 to have this be yet another allocation for some bytes, it is more
200 memory management overhead than the whole mess is worth. */
201 unsigned char data[IPPP_RESET_MAXDATABYTES];
202};
203
204/* The data structure keeping track of the currently outstanding CCP Reset
205 transactions. */
206struct ippp_ccp_reset {
207 struct ippp_ccp_reset_state *rs[256]; /* One per possible id */
208 unsigned char lastid; /* Last id allocated by the engine */
209};
210
211struct ippp_struct {
212 struct ippp_struct *next_link;
213 int state;
214 spinlock_t buflock;
215 struct ippp_buf_queue rq[NUM_RCV_BUFFS]; /* packet queue for isdn_ppp_read() */
216 struct ippp_buf_queue *first; /* pointer to (current) first packet */
217 struct ippp_buf_queue *last; /* pointer to (current) last used packet in queue */
218 wait_queue_head_t wq;
219 struct task_struct *tk;
220 unsigned int mpppcfg;
221 unsigned int pppcfg;
222 unsigned int mru;
223 unsigned int mpmru;
224 unsigned int mpmtu;
225 unsigned int maxcid;
226 struct isdn_net_local_s *lp;
227 int unit;
228 int minor;
229 unsigned int last_link_seqno;
230 long mp_seqno;
231#ifdef CONFIG_ISDN_PPP_VJ
232 unsigned char *cbuf;
233 struct slcompress *slcomp;
234#endif
235#ifdef CONFIG_IPPP_FILTER
236 struct sock_filter *pass_filter; /* filter for packets to pass */
237 struct sock_filter *active_filter; /* filter for pkts to reset idle */
238 unsigned pass_len, active_len;
239#endif
240 unsigned long debug;
241 struct isdn_ppp_compressor *compressor,*decompressor;
242 struct isdn_ppp_compressor *link_compressor,*link_decompressor;
243 void *decomp_stat,*comp_stat,*link_decomp_stat,*link_comp_stat;
244 struct ippp_ccp_reset *reset; /* Allocated on demand, may never be needed */
245 unsigned long compflags;
246};
247
248#endif /* __KERNEL__ */
249#endif /* _LINUX_ISDN_PPP_H */
diff --git a/include/linux/isdnif.h b/include/linux/isdnif.h
new file mode 100644
index 000000000000..7a4eacd77cb2
--- /dev/null
+++ b/include/linux/isdnif.h
@@ -0,0 +1,547 @@
1/* $Id: isdnif.h,v 1.43.2.2 2004/01/12 23:08:35 keil Exp $
2 *
3 * Linux ISDN subsystem
4 * Definition of the interface between the subsystem and its low-level drivers.
5 *
6 * Copyright 1994,95,96 by Fritz Elfert (fritz@isdn4linux.de)
7 * Copyright 1995,96 Thinking Objects Software GmbH Wuerzburg
8 *
9 * This software may be used and distributed according to the terms
10 * of the GNU General Public License, incorporated herein by reference.
11 *
12 */
13
14#ifndef __ISDNIF_H__
15#define __ISDNIF_H__
16
17
18/*
19 * Values for general protocol-selection
20 */
21#define ISDN_PTYPE_UNKNOWN 0 /* Protocol undefined */
22#define ISDN_PTYPE_1TR6 1 /* german 1TR6-protocol */
23#define ISDN_PTYPE_EURO 2 /* EDSS1-protocol */
24#define ISDN_PTYPE_LEASED 3 /* for leased lines */
25#define ISDN_PTYPE_NI1 4 /* US NI-1 protocol */
26#define ISDN_PTYPE_MAX 7 /* Max. 8 Protocols */
27
28/*
29 * Values for Layer-2-protocol-selection
30 */
31#define ISDN_PROTO_L2_X75I 0 /* X75/LAPB with I-Frames */
32#define ISDN_PROTO_L2_X75UI 1 /* X75/LAPB with UI-Frames */
33#define ISDN_PROTO_L2_X75BUI 2 /* X75/LAPB with UI-Frames */
34#define ISDN_PROTO_L2_HDLC 3 /* HDLC */
35#define ISDN_PROTO_L2_TRANS 4 /* Transparent (Voice) */
36#define ISDN_PROTO_L2_X25DTE 5 /* X25/LAPB DTE mode */
37#define ISDN_PROTO_L2_X25DCE 6 /* X25/LAPB DCE mode */
38#define ISDN_PROTO_L2_V11096 7 /* V.110 bitrate adaption 9600 Baud */
39#define ISDN_PROTO_L2_V11019 8 /* V.110 bitrate adaption 19200 Baud */
40#define ISDN_PROTO_L2_V11038 9 /* V.110 bitrate adaption 38400 Baud */
41#define ISDN_PROTO_L2_MODEM 10 /* Analog Modem on Board */
42#define ISDN_PROTO_L2_FAX 11 /* Fax Group 2/3 */
43#define ISDN_PROTO_L2_HDLC_56K 12 /* HDLC 56k */
44#define ISDN_PROTO_L2_MAX 15 /* Max. 16 Protocols */
45
46/*
47 * Values for Layer-3-protocol-selection
48 */
49#define ISDN_PROTO_L3_TRANS 0 /* Transparent */
50#define ISDN_PROTO_L3_TRANSDSP 1 /* Transparent with DSP */
51#define ISDN_PROTO_L3_FCLASS2 2 /* Fax Group 2/3 CLASS 2 */
52#define ISDN_PROTO_L3_FCLASS1 3 /* Fax Group 2/3 CLASS 1 */
53#define ISDN_PROTO_L3_MAX 7 /* Max. 8 Protocols */
54
55#ifdef __KERNEL__
56
57#include <linux/config.h>
58#include <linux/skbuff.h>
59
60/***************************************************************************/
61/* Extensions made by Werner Cornelius (werner@ikt.de) */
62/* */
63/* The proceed command holds a incoming call in a state to leave processes */
64/* enough time to check whether ist should be accepted. */
65/* The PROT_IO Command extends the interface to make protocol dependent */
66/* features available (call diversion, call waiting...). */
67/* */
68/* The PROT_IO Command is executed with the desired driver id and the arg */
69/* parameter coded as follows: */
70/* The lower 8 bits of arg contain the desired protocol from ISDN_PTYPE */
71/* definitions. The upper 24 bits represent the protocol specific cmd/stat.*/
72/* Any additional data is protocol and command specific. */
73/* This mechanism also applies to the statcallb callback STAT_PROT. */
74/* */
75/* This suggested extension permits an easy expansion of protocol specific */
76/* handling. Extensions may be added at any time without changing the HL */
77/* driver code and not getting conflicts without certifications. */
78/* The well known CAPI 2.0 interface handles such extensions in a similar */
79/* way. Perhaps a protocol specific module may be added and separately */
80/* loaded and linked to the basic isdn module for handling. */
81/***************************************************************************/
82
83/*****************/
84/* DSS1 commands */
85/*****************/
86#define DSS1_CMD_INVOKE ((0x00 << 8) | ISDN_PTYPE_EURO) /* invoke a supplementary service */
87#define DSS1_CMD_INVOKE_ABORT ((0x01 << 8) | ISDN_PTYPE_EURO) /* abort a invoke cmd */
88
89/*******************************/
90/* DSS1 Status callback values */
91/*******************************/
92#define DSS1_STAT_INVOKE_RES ((0x80 << 8) | ISDN_PTYPE_EURO) /* Result for invocation */
93#define DSS1_STAT_INVOKE_ERR ((0x81 << 8) | ISDN_PTYPE_EURO) /* Error Return for invocation */
94#define DSS1_STAT_INVOKE_BRD ((0x82 << 8) | ISDN_PTYPE_EURO) /* Deliver invoke broadcast info */
95
96
97/*********************************************************************/
98/* structures for DSS1 commands and callback */
99/* */
100/* An action is invoked by sending a DSS1_CMD_INVOKE. The ll_id, proc*/
101/* timeout, datalen and data fields must be set before calling. */
102/* */
103/* The return value is a positive hl_id value also delivered in the */
104/* hl_id field. A value of zero signals no more left hl_id capacitys.*/
105/* A negative return value signals errors in LL. So if the return */
106/* value is <= 0 no action in LL will be taken -> request ignored */
107/* */
108/* The timeout field must be filled with a positive value specifying */
109/* the amount of time the INVOKED process waits for a reaction from */
110/* the network. */
111/* If a response (either error or result) is received during this */
112/* intervall, a reporting callback is initiated and the process will */
113/* be deleted, the hl identifier will be freed. */
114/* If no response is received during the specified intervall, a error*/
115/* callback is initiated with timeout set to -1 and a datalen set */
116/* to 0. */
117/* If timeout is set to a value <= 0 during INVOCATION the process is*/
118/* immediately deleted after sending the data. No callback occurs ! */
119/* */
120/* A currently waiting process may be aborted with INVOKE_ABORT. No */
121/* callback will occur when a process has been aborted. */
122/* */
123/* Broadcast invoke frames from the network are reported via the */
124/* STAT_INVOKE_BRD callback. The ll_id is set to 0, the other fields */
125/* are supplied by the network and not by the HL. */
126/*********************************************************************/
127
128/*****************/
129/* NI1 commands */
130/*****************/
131#define NI1_CMD_INVOKE ((0x00 << 8) | ISDN_PTYPE_NI1) /* invoke a supplementary service */
132#define NI1_CMD_INVOKE_ABORT ((0x01 << 8) | ISDN_PTYPE_NI1) /* abort a invoke cmd */
133
134/*******************************/
135/* NI1 Status callback values */
136/*******************************/
137#define NI1_STAT_INVOKE_RES ((0x80 << 8) | ISDN_PTYPE_NI1) /* Result for invocation */
138#define NI1_STAT_INVOKE_ERR ((0x81 << 8) | ISDN_PTYPE_NI1) /* Error Return for invocation */
139#define NI1_STAT_INVOKE_BRD ((0x82 << 8) | ISDN_PTYPE_NI1) /* Deliver invoke broadcast info */
140
141typedef struct
142 { ulong ll_id; /* ID supplied by LL when executing */
143 /* a command and returned by HL for */
144 /* INVOKE_RES and INVOKE_ERR */
145 int hl_id; /* ID supplied by HL when called */
146 /* for executing a cmd and delivered */
147 /* for results and errors */
148 /* must be supplied by LL when aborting*/
149 int proc; /* invoke procedure used by CMD_INVOKE */
150 /* returned by callback and broadcast */
151 int timeout; /* timeout for INVOKE CMD in ms */
152 /* -1 in stat callback when timed out */
153 /* error value when error callback */
154 int datalen; /* length of cmd or stat data */
155 u_char *data;/* pointer to data delivered or send */
156 } isdn_cmd_stat;
157
158/*
159 * Commands from linklevel to lowlevel
160 *
161 */
162#define ISDN_CMD_IOCTL 0 /* Perform ioctl */
163#define ISDN_CMD_DIAL 1 /* Dial out */
164#define ISDN_CMD_ACCEPTD 2 /* Accept an incoming call on D-Chan. */
165#define ISDN_CMD_ACCEPTB 3 /* Request B-Channel connect. */
166#define ISDN_CMD_HANGUP 4 /* Hangup */
167#define ISDN_CMD_CLREAZ 5 /* Clear EAZ(s) of channel */
168#define ISDN_CMD_SETEAZ 6 /* Set EAZ(s) of channel */
169#define ISDN_CMD_GETEAZ 7 /* Get EAZ(s) of channel */
170#define ISDN_CMD_SETSIL 8 /* Set Service-Indicator-List of channel */
171#define ISDN_CMD_GETSIL 9 /* Get Service-Indicator-List of channel */
172#define ISDN_CMD_SETL2 10 /* Set B-Chan. Layer2-Parameter */
173#define ISDN_CMD_GETL2 11 /* Get B-Chan. Layer2-Parameter */
174#define ISDN_CMD_SETL3 12 /* Set B-Chan. Layer3-Parameter */
175#define ISDN_CMD_GETL3 13 /* Get B-Chan. Layer3-Parameter */
176// #define ISDN_CMD_LOCK 14 /* Signal usage by upper levels */
177// #define ISDN_CMD_UNLOCK 15 /* Release usage-lock */
178#define ISDN_CMD_SUSPEND 16 /* Suspend connection */
179#define ISDN_CMD_RESUME 17 /* Resume connection */
180#define ISDN_CMD_PROCEED 18 /* Proceed with call establishment */
181#define ISDN_CMD_ALERT 19 /* Alert after Proceeding */
182#define ISDN_CMD_REDIR 20 /* Redir a incoming call */
183#define ISDN_CMD_PROT_IO 21 /* Protocol specific commands */
184#define CAPI_PUT_MESSAGE 22 /* CAPI message send down or up */
185#define ISDN_CMD_FAXCMD 23 /* FAX commands to HL-driver */
186#define ISDN_CMD_AUDIO 24 /* DSP, DTMF, ... settings */
187
188/*
189 * Status-Values delivered from lowlevel to linklevel via
190 * statcallb().
191 *
192 */
193#define ISDN_STAT_STAVAIL 256 /* Raw status-data available */
194#define ISDN_STAT_ICALL 257 /* Incoming call detected */
195#define ISDN_STAT_RUN 258 /* Signal protocol-code is running */
196#define ISDN_STAT_STOP 259 /* Signal halt of protocol-code */
197#define ISDN_STAT_DCONN 260 /* Signal D-Channel connect */
198#define ISDN_STAT_BCONN 261 /* Signal B-Channel connect */
199#define ISDN_STAT_DHUP 262 /* Signal D-Channel disconnect */
200#define ISDN_STAT_BHUP 263 /* Signal B-Channel disconnect */
201#define ISDN_STAT_CINF 264 /* Charge-Info */
202#define ISDN_STAT_LOAD 265 /* Signal new lowlevel-driver is loaded */
203#define ISDN_STAT_UNLOAD 266 /* Signal unload of lowlevel-driver */
204#define ISDN_STAT_BSENT 267 /* Signal packet sent */
205#define ISDN_STAT_NODCH 268 /* Signal no D-Channel */
206#define ISDN_STAT_ADDCH 269 /* Add more Channels */
207#define ISDN_STAT_CAUSE 270 /* Cause-Message */
208#define ISDN_STAT_ICALLW 271 /* Incoming call without B-chan waiting */
209#define ISDN_STAT_REDIR 272 /* Redir result */
210#define ISDN_STAT_PROT 273 /* protocol IO specific callback */
211#define ISDN_STAT_DISPLAY 274 /* deliver a received display message */
212#define ISDN_STAT_L1ERR 275 /* Signal Layer-1 Error */
213#define ISDN_STAT_FAXIND 276 /* FAX indications from HL-driver */
214#define ISDN_STAT_AUDIO 277 /* DTMF, DSP indications */
215#define ISDN_STAT_DISCH 278 /* Disable/Enable channel usage */
216
217/*
218 * Audio commands
219 */
220#define ISDN_AUDIO_SETDD 0 /* Set DTMF detection */
221#define ISDN_AUDIO_DTMF 1 /* Rx/Tx DTMF */
222
223/*
224 * Values for errcode field
225 */
226#define ISDN_STAT_L1ERR_SEND 1
227#define ISDN_STAT_L1ERR_RECV 2
228
229/*
230 * Values for feature-field of interface-struct.
231 */
232/* Layer 2 */
233#define ISDN_FEATURE_L2_X75I (0x0001 << ISDN_PROTO_L2_X75I)
234#define ISDN_FEATURE_L2_X75UI (0x0001 << ISDN_PROTO_L2_X75UI)
235#define ISDN_FEATURE_L2_X75BUI (0x0001 << ISDN_PROTO_L2_X75BUI)
236#define ISDN_FEATURE_L2_HDLC (0x0001 << ISDN_PROTO_L2_HDLC)
237#define ISDN_FEATURE_L2_TRANS (0x0001 << ISDN_PROTO_L2_TRANS)
238#define ISDN_FEATURE_L2_X25DTE (0x0001 << ISDN_PROTO_L2_X25DTE)
239#define ISDN_FEATURE_L2_X25DCE (0x0001 << ISDN_PROTO_L2_X25DCE)
240#define ISDN_FEATURE_L2_V11096 (0x0001 << ISDN_PROTO_L2_V11096)
241#define ISDN_FEATURE_L2_V11019 (0x0001 << ISDN_PROTO_L2_V11019)
242#define ISDN_FEATURE_L2_V11038 (0x0001 << ISDN_PROTO_L2_V11038)
243#define ISDN_FEATURE_L2_MODEM (0x0001 << ISDN_PROTO_L2_MODEM)
244#define ISDN_FEATURE_L2_FAX (0x0001 << ISDN_PROTO_L2_FAX)
245#define ISDN_FEATURE_L2_HDLC_56K (0x0001 << ISDN_PROTO_L2_HDLC_56K)
246
247#define ISDN_FEATURE_L2_MASK (0x0FFFF) /* Max. 16 protocols */
248#define ISDN_FEATURE_L2_SHIFT (0)
249
250/* Layer 3 */
251#define ISDN_FEATURE_L3_TRANS (0x10000 << ISDN_PROTO_L3_TRANS)
252#define ISDN_FEATURE_L3_TRANSDSP (0x10000 << ISDN_PROTO_L3_TRANSDSP)
253#define ISDN_FEATURE_L3_FCLASS2 (0x10000 << ISDN_PROTO_L3_FCLASS2)
254#define ISDN_FEATURE_L3_FCLASS1 (0x10000 << ISDN_PROTO_L3_FCLASS1)
255
256#define ISDN_FEATURE_L3_MASK (0x0FF0000) /* Max. 8 Protocols */
257#define ISDN_FEATURE_L3_SHIFT (16)
258
259/* Signaling */
260#define ISDN_FEATURE_P_UNKNOWN (0x1000000 << ISDN_PTYPE_UNKNOWN)
261#define ISDN_FEATURE_P_1TR6 (0x1000000 << ISDN_PTYPE_1TR6)
262#define ISDN_FEATURE_P_EURO (0x1000000 << ISDN_PTYPE_EURO)
263#define ISDN_FEATURE_P_NI1 (0x1000000 << ISDN_PTYPE_NI1)
264
265#define ISDN_FEATURE_P_MASK (0x0FF000000) /* Max. 8 Protocols */
266#define ISDN_FEATURE_P_SHIFT (24)
267
268typedef struct setup_parm {
269 unsigned char phone[32]; /* Remote Phone-Number */
270 unsigned char eazmsn[32]; /* Local EAZ or MSN */
271 unsigned char si1; /* Service Indicator 1 */
272 unsigned char si2; /* Service Indicator 2 */
273 unsigned char plan; /* Numbering plan */
274 unsigned char screen; /* Screening info */
275} setup_parm;
276
277
278#ifdef CONFIG_ISDN_TTY_FAX
279/* T.30 Fax G3 */
280
281#define FAXIDLEN 21
282
283typedef struct T30_s {
284 /* session parameters */
285 __u8 resolution __attribute__ ((packed));
286 __u8 rate __attribute__ ((packed));
287 __u8 width __attribute__ ((packed));
288 __u8 length __attribute__ ((packed));
289 __u8 compression __attribute__ ((packed));
290 __u8 ecm __attribute__ ((packed));
291 __u8 binary __attribute__ ((packed));
292 __u8 scantime __attribute__ ((packed));
293 __u8 id[FAXIDLEN] __attribute__ ((packed));
294 /* additional parameters */
295 __u8 phase __attribute__ ((packed));
296 __u8 direction __attribute__ ((packed));
297 __u8 code __attribute__ ((packed));
298 __u8 badlin __attribute__ ((packed));
299 __u8 badmul __attribute__ ((packed));
300 __u8 bor __attribute__ ((packed));
301 __u8 fet __attribute__ ((packed));
302 __u8 pollid[FAXIDLEN] __attribute__ ((packed));
303 __u8 cq __attribute__ ((packed));
304 __u8 cr __attribute__ ((packed));
305 __u8 ctcrty __attribute__ ((packed));
306 __u8 minsp __attribute__ ((packed));
307 __u8 phcto __attribute__ ((packed));
308 __u8 rel __attribute__ ((packed));
309 __u8 nbc __attribute__ ((packed));
310 /* remote station parameters */
311 __u8 r_resolution __attribute__ ((packed));
312 __u8 r_rate __attribute__ ((packed));
313 __u8 r_width __attribute__ ((packed));
314 __u8 r_length __attribute__ ((packed));
315 __u8 r_compression __attribute__ ((packed));
316 __u8 r_ecm __attribute__ ((packed));
317 __u8 r_binary __attribute__ ((packed));
318 __u8 r_scantime __attribute__ ((packed));
319 __u8 r_id[FAXIDLEN] __attribute__ ((packed));
320 __u8 r_code __attribute__ ((packed));
321} T30_s;
322
323#define ISDN_TTY_FAX_CONN_IN 0
324#define ISDN_TTY_FAX_CONN_OUT 1
325
326#define ISDN_TTY_FAX_FCON 0
327#define ISDN_TTY_FAX_DIS 1
328#define ISDN_TTY_FAX_FTT 2
329#define ISDN_TTY_FAX_MCF 3
330#define ISDN_TTY_FAX_DCS 4
331#define ISDN_TTY_FAX_TRAIN_OK 5
332#define ISDN_TTY_FAX_EOP 6
333#define ISDN_TTY_FAX_EOM 7
334#define ISDN_TTY_FAX_MPS 8
335#define ISDN_TTY_FAX_DTC 9
336#define ISDN_TTY_FAX_RID 10
337#define ISDN_TTY_FAX_HNG 11
338#define ISDN_TTY_FAX_DT 12
339#define ISDN_TTY_FAX_FCON_I 13
340#define ISDN_TTY_FAX_DR 14
341#define ISDN_TTY_FAX_ET 15
342#define ISDN_TTY_FAX_CFR 16
343#define ISDN_TTY_FAX_PTS 17
344#define ISDN_TTY_FAX_SENT 18
345
346#define ISDN_FAX_PHASE_IDLE 0
347#define ISDN_FAX_PHASE_A 1
348#define ISDN_FAX_PHASE_B 2
349#define ISDN_FAX_PHASE_C 3
350#define ISDN_FAX_PHASE_D 4
351#define ISDN_FAX_PHASE_E 5
352
353#endif /* TTY_FAX */
354
355#define ISDN_FAX_CLASS1_FAE 0
356#define ISDN_FAX_CLASS1_FTS 1
357#define ISDN_FAX_CLASS1_FRS 2
358#define ISDN_FAX_CLASS1_FTM 3
359#define ISDN_FAX_CLASS1_FRM 4
360#define ISDN_FAX_CLASS1_FTH 5
361#define ISDN_FAX_CLASS1_FRH 6
362#define ISDN_FAX_CLASS1_CTRL 7
363
364#define ISDN_FAX_CLASS1_OK 0
365#define ISDN_FAX_CLASS1_CONNECT 1
366#define ISDN_FAX_CLASS1_NOCARR 2
367#define ISDN_FAX_CLASS1_ERROR 3
368#define ISDN_FAX_CLASS1_FCERROR 4
369#define ISDN_FAX_CLASS1_QUERY 5
370
371typedef struct {
372 __u8 cmd;
373 __u8 subcmd;
374 __u8 para[50];
375} aux_s;
376
377#define AT_COMMAND 0
378#define AT_EQ_VALUE 1
379#define AT_QUERY 2
380#define AT_EQ_QUERY 3
381
382/* CAPI structs */
383
384/* this is compatible to the old union size */
385#define MAX_CAPI_PARA_LEN 50
386
387typedef struct {
388 /* Header */
389 __u16 Length;
390 __u16 ApplId;
391 __u8 Command;
392 __u8 Subcommand;
393 __u16 Messagenumber;
394
395 /* Parameter */
396 union {
397 __u32 Controller;
398 __u32 PLCI;
399 __u32 NCCI;
400 } adr;
401 __u8 para[MAX_CAPI_PARA_LEN];
402} capi_msg;
403
404/*
405 * Structure for exchanging above infos
406 *
407 */
408typedef struct {
409 int driver; /* Lowlevel-Driver-ID */
410 int command; /* Command or Status (see above) */
411 ulong arg; /* Additional Data */
412 union {
413 ulong errcode; /* Type of error with STAT_L1ERR */
414 int length; /* Amount of bytes sent with STAT_BSENT */
415 u_char num[50]; /* Additional Data */
416 setup_parm setup;/* For SETUP msg */
417 capi_msg cmsg; /* For CAPI like messages */
418 char display[85];/* display message data */
419 isdn_cmd_stat isdn_io; /* ISDN IO-parameter/result */
420 aux_s aux; /* for modem commands/indications */
421#ifdef CONFIG_ISDN_TTY_FAX
422 T30_s *fax; /* Pointer to ttys fax struct */
423#endif
424 ulong userdata; /* User Data */
425 } parm;
426} isdn_ctrl;
427
428#define dss1_io isdn_io
429#define ni1_io isdn_io
430
431/*
432 * The interface-struct itself (initialized at load-time of lowlevel-driver)
433 *
434 * See Documentation/isdn/INTERFACE for a description, how the communication
435 * between the ISDN subsystem and its drivers is done.
436 *
437 */
438typedef struct {
439 struct module *owner;
440
441 /* Number of channels supported by this driver
442 */
443 int channels;
444
445 /*
446 * Maximum Size of transmit/receive-buffer this driver supports.
447 */
448 int maxbufsize;
449
450 /* Feature-Flags for this driver.
451 * See defines ISDN_FEATURE_... for Values
452 */
453 unsigned long features;
454
455 /*
456 * Needed for calculating
457 * dev->hard_header_len = linklayer header + hl_hdrlen;
458 * Drivers, not supporting sk_buff's should set this to 0.
459 */
460 unsigned short hl_hdrlen;
461
462 /*
463 * Receive-Callback using sk_buff's
464 * Parameters:
465 * int Driver-ID
466 * int local channel-number (0 ...)
467 * struct sk_buff *skb received Data
468 */
469 void (*rcvcallb_skb)(int, int, struct sk_buff *);
470
471 /* Status-Callback
472 * Parameters:
473 * isdn_ctrl*
474 * driver = Driver ID.
475 * command = One of above ISDN_STAT_... constants.
476 * arg = depending on status-type.
477 * num = depending on status-type.
478 */
479 int (*statcallb)(isdn_ctrl*);
480
481 /* Send command
482 * Parameters:
483 * isdn_ctrl*
484 * driver = Driver ID.
485 * command = One of above ISDN_CMD_... constants.
486 * arg = depending on command.
487 * num = depending on command.
488 */
489 int (*command)(isdn_ctrl*);
490
491 /*
492 * Send data using sk_buff's
493 * Parameters:
494 * int driverId
495 * int local channel-number (0...)
496 * int Flag: Need ACK for this packet.
497 * struct sk_buff *skb Data to send
498 */
499 int (*writebuf_skb) (int, int, int, struct sk_buff *);
500
501 /* Send raw D-Channel-Commands
502 * Parameters:
503 * u_char pointer data
504 * int length of data
505 * int driverId
506 * int local channel-number (0 ...)
507 */
508 int (*writecmd)(const u_char __user *, int, int, int);
509
510 /* Read raw Status replies
511 * u_char pointer data (volatile)
512 * int length of buffer
513 * int driverId
514 * int local channel-number (0 ...)
515 */
516 int (*readstat)(u_char __user *, int, int, int);
517
518 char id[20];
519} isdn_if;
520
521/*
522 * Function which must be called by lowlevel-driver at loadtime with
523 * the following fields of above struct set:
524 *
525 * channels Number of channels that will be supported.
526 * hl_hdrlen Space to preserve in sk_buff's when sending. Drivers, not
527 * supporting sk_buff's should set this to 0.
528 * command Address of Command-Handler.
529 * features Bitwise coded Features of this driver. (use ISDN_FEATURE_...)
530 * writebuf_skb Address of Skbuff-Send-Handler.
531 * writecmd " " D-Channel " which accepts raw D-Ch-Commands.
532 * readstat " " D-Channel " which delivers raw Status-Data.
533 *
534 * The linklevel-driver fills the following fields:
535 *
536 * channels Driver-ID assigned to this driver. (Must be used on all
537 * subsequent callbacks.
538 * rcvcallb_skb Address of handler for received Skbuff's.
539 * statcallb " " " for status-changes.
540 *
541 */
542extern int register_isdn(isdn_if*);
543#include <asm/uaccess.h>
544
545#endif /* __KERNEL__ */
546
547#endif /* __ISDNIF_H__ */
diff --git a/include/linux/isicom.h b/include/linux/isicom.h
new file mode 100644
index 000000000000..7c6eae7f6ed7
--- /dev/null
+++ b/include/linux/isicom.h
@@ -0,0 +1,131 @@
1#ifndef _LINUX_ISICOM_H
2#define _LINUX_ISICOM_H
3
4/*#define ISICOM_DEBUG*/
5/*#define ISICOM_DEBUG_DTR_RTS*/
6
7
8/*
9 * Firmware Loader definitions ...
10 */
11
12#define __MultiTech ('M'<<8)
13#define MIOCTL_LOAD_FIRMWARE (__MultiTech | 0x01)
14#define MIOCTL_READ_FIRMWARE (__MultiTech | 0x02)
15#define MIOCTL_XFER_CTRL (__MultiTech | 0x03)
16#define MIOCTL_RESET_CARD (__MultiTech | 0x04)
17
18#define DATA_SIZE 16
19
20typedef struct {
21 unsigned short exec_segment;
22 unsigned short exec_addr;
23} exec_record;
24
25typedef struct {
26 int board; /* Board to load */
27 unsigned short addr;
28 unsigned short count;
29} bin_header;
30
31typedef struct {
32 int board; /* Board to load */
33 unsigned short addr;
34 unsigned short count;
35 unsigned short segment;
36 unsigned char bin_data[DATA_SIZE];
37} bin_frame;
38
39#ifdef __KERNEL__
40
41#define YES 1
42#define NO 0
43
44#define ISILOAD_MISC_MINOR 155 /* /dev/isctl */
45#define ISILOAD_NAME "ISILoad"
46
47/*
48 * ISICOM Driver definitions ...
49 *
50 */
51
52#define ISICOM_NAME "ISICom"
53
54/*
55 * PCI definitions
56 */
57
58 #define DEVID_COUNT 9
59 #define VENDOR_ID 0x10b5
60
61/*
62 * These are now officially allocated numbers
63 */
64
65#define ISICOM_NMAJOR 112 /* normal */
66#define ISICOM_CMAJOR 113 /* callout */
67#define ISICOM_MAGIC (('M' << 8) | 'T')
68
69#define WAKEUP_CHARS 256 /* hard coded for now */
70#define TX_SIZE 254
71
72#define BOARD_COUNT 4
73#define PORT_COUNT (BOARD_COUNT*16)
74
75#define SERIAL_TYPE_NORMAL 1
76
77/* character sizes */
78
79#define ISICOM_CS5 0x0000
80#define ISICOM_CS6 0x0001
81#define ISICOM_CS7 0x0002
82#define ISICOM_CS8 0x0003
83
84/* stop bits */
85
86#define ISICOM_1SB 0x0000
87#define ISICOM_2SB 0x0004
88
89/* parity */
90
91#define ISICOM_NOPAR 0x0000
92#define ISICOM_ODPAR 0x0008
93#define ISICOM_EVPAR 0x0018
94
95/* flow control */
96
97#define ISICOM_CTSRTS 0x03
98#define ISICOM_INITIATE_XONXOFF 0x04
99#define ISICOM_RESPOND_XONXOFF 0x08
100
101#define InterruptTheCard(base) (outw(0,(base)+0xc))
102#define ClearInterrupt(base) (inw((base)+0x0a))
103
104#define BOARD(line) (((line) >> 4) & 0x3)
105
106 /* isi kill queue bitmap */
107
108#define ISICOM_KILLTX 0x01
109#define ISICOM_KILLRX 0x02
110
111 /* isi_board status bitmap */
112
113#define FIRMWARE_LOADED 0x0001
114#define BOARD_ACTIVE 0x0002
115
116 /* isi_port status bitmap */
117
118#define ISI_CTS 0x1000
119#define ISI_DSR 0x2000
120#define ISI_RI 0x4000
121#define ISI_DCD 0x8000
122#define ISI_DTR 0x0100
123#define ISI_RTS 0x0200
124
125
126#define ISI_TXOK 0x0001
127
128#endif /* __KERNEL__ */
129
130#endif /* ISICOM_H */
131
diff --git a/include/linux/iso_fs.h b/include/linux/iso_fs.h
new file mode 100644
index 000000000000..099039d4b10d
--- /dev/null
+++ b/include/linux/iso_fs.h
@@ -0,0 +1,312 @@
1
2#ifndef _ISOFS_FS_H
3#define _ISOFS_FS_H
4
5#include <linux/types.h>
6/*
7 * The isofs filesystem constants/structures
8 */
9
10/* This part borrowed from the bsd386 isofs */
11#define ISODCL(from, to) (to - from + 1)
12
13struct iso_volume_descriptor {
14 char type[ISODCL(1,1)]; /* 711 */
15 char id[ISODCL(2,6)];
16 char version[ISODCL(7,7)];
17 char data[ISODCL(8,2048)];
18};
19
20/* volume descriptor types */
21#define ISO_VD_PRIMARY 1
22#define ISO_VD_SUPPLEMENTARY 2
23#define ISO_VD_END 255
24
25#define ISO_STANDARD_ID "CD001"
26
27struct iso_primary_descriptor {
28 char type [ISODCL ( 1, 1)]; /* 711 */
29 char id [ISODCL ( 2, 6)];
30 char version [ISODCL ( 7, 7)]; /* 711 */
31 char unused1 [ISODCL ( 8, 8)];
32 char system_id [ISODCL ( 9, 40)]; /* achars */
33 char volume_id [ISODCL ( 41, 72)]; /* dchars */
34 char unused2 [ISODCL ( 73, 80)];
35 char volume_space_size [ISODCL ( 81, 88)]; /* 733 */
36 char unused3 [ISODCL ( 89, 120)];
37 char volume_set_size [ISODCL (121, 124)]; /* 723 */
38 char volume_sequence_number [ISODCL (125, 128)]; /* 723 */
39 char logical_block_size [ISODCL (129, 132)]; /* 723 */
40 char path_table_size [ISODCL (133, 140)]; /* 733 */
41 char type_l_path_table [ISODCL (141, 144)]; /* 731 */
42 char opt_type_l_path_table [ISODCL (145, 148)]; /* 731 */
43 char type_m_path_table [ISODCL (149, 152)]; /* 732 */
44 char opt_type_m_path_table [ISODCL (153, 156)]; /* 732 */
45 char root_directory_record [ISODCL (157, 190)]; /* 9.1 */
46 char volume_set_id [ISODCL (191, 318)]; /* dchars */
47 char publisher_id [ISODCL (319, 446)]; /* achars */
48 char preparer_id [ISODCL (447, 574)]; /* achars */
49 char application_id [ISODCL (575, 702)]; /* achars */
50 char copyright_file_id [ISODCL (703, 739)]; /* 7.5 dchars */
51 char abstract_file_id [ISODCL (740, 776)]; /* 7.5 dchars */
52 char bibliographic_file_id [ISODCL (777, 813)]; /* 7.5 dchars */
53 char creation_date [ISODCL (814, 830)]; /* 8.4.26.1 */
54 char modification_date [ISODCL (831, 847)]; /* 8.4.26.1 */
55 char expiration_date [ISODCL (848, 864)]; /* 8.4.26.1 */
56 char effective_date [ISODCL (865, 881)]; /* 8.4.26.1 */
57 char file_structure_version [ISODCL (882, 882)]; /* 711 */
58 char unused4 [ISODCL (883, 883)];
59 char application_data [ISODCL (884, 1395)];
60 char unused5 [ISODCL (1396, 2048)];
61};
62
63/* Almost the same as the primary descriptor but two fields are specified */
64struct iso_supplementary_descriptor {
65 char type [ISODCL ( 1, 1)]; /* 711 */
66 char id [ISODCL ( 2, 6)];
67 char version [ISODCL ( 7, 7)]; /* 711 */
68 char flags [ISODCL ( 8, 8)]; /* 853 */
69 char system_id [ISODCL ( 9, 40)]; /* achars */
70 char volume_id [ISODCL ( 41, 72)]; /* dchars */
71 char unused2 [ISODCL ( 73, 80)];
72 char volume_space_size [ISODCL ( 81, 88)]; /* 733 */
73 char escape [ISODCL ( 89, 120)]; /* 856 */
74 char volume_set_size [ISODCL (121, 124)]; /* 723 */
75 char volume_sequence_number [ISODCL (125, 128)]; /* 723 */
76 char logical_block_size [ISODCL (129, 132)]; /* 723 */
77 char path_table_size [ISODCL (133, 140)]; /* 733 */
78 char type_l_path_table [ISODCL (141, 144)]; /* 731 */
79 char opt_type_l_path_table [ISODCL (145, 148)]; /* 731 */
80 char type_m_path_table [ISODCL (149, 152)]; /* 732 */
81 char opt_type_m_path_table [ISODCL (153, 156)]; /* 732 */
82 char root_directory_record [ISODCL (157, 190)]; /* 9.1 */
83 char volume_set_id [ISODCL (191, 318)]; /* dchars */
84 char publisher_id [ISODCL (319, 446)]; /* achars */
85 char preparer_id [ISODCL (447, 574)]; /* achars */
86 char application_id [ISODCL (575, 702)]; /* achars */
87 char copyright_file_id [ISODCL (703, 739)]; /* 7.5 dchars */
88 char abstract_file_id [ISODCL (740, 776)]; /* 7.5 dchars */
89 char bibliographic_file_id [ISODCL (777, 813)]; /* 7.5 dchars */
90 char creation_date [ISODCL (814, 830)]; /* 8.4.26.1 */
91 char modification_date [ISODCL (831, 847)]; /* 8.4.26.1 */
92 char expiration_date [ISODCL (848, 864)]; /* 8.4.26.1 */
93 char effective_date [ISODCL (865, 881)]; /* 8.4.26.1 */
94 char file_structure_version [ISODCL (882, 882)]; /* 711 */
95 char unused4 [ISODCL (883, 883)];
96 char application_data [ISODCL (884, 1395)];
97 char unused5 [ISODCL (1396, 2048)];
98};
99
100
101#define HS_STANDARD_ID "CDROM"
102
103struct hs_volume_descriptor {
104 char foo [ISODCL ( 1, 8)]; /* 733 */
105 char type [ISODCL ( 9, 9)]; /* 711 */
106 char id [ISODCL ( 10, 14)];
107 char version [ISODCL ( 15, 15)]; /* 711 */
108 char data[ISODCL(16,2048)];
109};
110
111
112struct hs_primary_descriptor {
113 char foo [ISODCL ( 1, 8)]; /* 733 */
114 char type [ISODCL ( 9, 9)]; /* 711 */
115 char id [ISODCL ( 10, 14)];
116 char version [ISODCL ( 15, 15)]; /* 711 */
117 char unused1 [ISODCL ( 16, 16)]; /* 711 */
118 char system_id [ISODCL ( 17, 48)]; /* achars */
119 char volume_id [ISODCL ( 49, 80)]; /* dchars */
120 char unused2 [ISODCL ( 81, 88)]; /* 733 */
121 char volume_space_size [ISODCL ( 89, 96)]; /* 733 */
122 char unused3 [ISODCL ( 97, 128)]; /* 733 */
123 char volume_set_size [ISODCL (129, 132)]; /* 723 */
124 char volume_sequence_number [ISODCL (133, 136)]; /* 723 */
125 char logical_block_size [ISODCL (137, 140)]; /* 723 */
126 char path_table_size [ISODCL (141, 148)]; /* 733 */
127 char type_l_path_table [ISODCL (149, 152)]; /* 731 */
128 char unused4 [ISODCL (153, 180)]; /* 733 */
129 char root_directory_record [ISODCL (181, 214)]; /* 9.1 */
130};
131
132/* We use this to help us look up the parent inode numbers. */
133
134struct iso_path_table{
135 unsigned char name_len[2]; /* 721 */
136 char extent[4]; /* 731 */
137 char parent[2]; /* 721 */
138 char name[0];
139} __attribute__((packed));
140
141/* high sierra is identical to iso, except that the date is only 6 bytes, and
142 there is an extra reserved byte after the flags */
143
144struct iso_directory_record {
145 char length [ISODCL (1, 1)]; /* 711 */
146 char ext_attr_length [ISODCL (2, 2)]; /* 711 */
147 char extent [ISODCL (3, 10)]; /* 733 */
148 char size [ISODCL (11, 18)]; /* 733 */
149 char date [ISODCL (19, 25)]; /* 7 by 711 */
150 char flags [ISODCL (26, 26)];
151 char file_unit_size [ISODCL (27, 27)]; /* 711 */
152 char interleave [ISODCL (28, 28)]; /* 711 */
153 char volume_sequence_number [ISODCL (29, 32)]; /* 723 */
154 unsigned char name_len [ISODCL (33, 33)]; /* 711 */
155 char name [0];
156} __attribute__((packed));
157
158#define ISOFS_BLOCK_BITS 11
159#define ISOFS_BLOCK_SIZE 2048
160
161#define ISOFS_BUFFER_SIZE(INODE) ((INODE)->i_sb->s_blocksize)
162#define ISOFS_BUFFER_BITS(INODE) ((INODE)->i_sb->s_blocksize_bits)
163
164#define ISOFS_SUPER_MAGIC 0x9660
165
166#ifdef __KERNEL__
167/* Number conversion inlines, named after the section in ISO 9660
168 they correspond to. */
169
170#include <asm/byteorder.h>
171#include <asm/unaligned.h>
172#include <linux/iso_fs_i.h>
173#include <linux/iso_fs_sb.h>
174
175static inline struct isofs_sb_info *ISOFS_SB(struct super_block *sb)
176{
177 return sb->s_fs_info;
178}
179
180static inline struct iso_inode_info *ISOFS_I(struct inode *inode)
181{
182 return container_of(inode, struct iso_inode_info, vfs_inode);
183}
184
185static inline int isonum_711(char *p)
186{
187 return *(u8 *)p;
188}
189static inline int isonum_712(char *p)
190{
191 return *(s8 *)p;
192}
193static inline unsigned int isonum_721(char *p)
194{
195 return le16_to_cpu(get_unaligned((__le16 *)p));
196}
197static inline unsigned int isonum_722(char *p)
198{
199 return be16_to_cpu(get_unaligned((__le16 *)p));
200}
201static inline unsigned int isonum_723(char *p)
202{
203 /* Ignore bigendian datum due to broken mastering programs */
204 return le16_to_cpu(get_unaligned((__le16 *)p));
205}
206static inline unsigned int isonum_731(char *p)
207{
208 return le32_to_cpu(get_unaligned((__le32 *)p));
209}
210static inline unsigned int isonum_732(char *p)
211{
212 return be32_to_cpu(get_unaligned((__le32 *)p));
213}
214static inline unsigned int isonum_733(char *p)
215{
216 /* Ignore bigendian datum due to broken mastering programs */
217 return le32_to_cpu(get_unaligned((__le32 *)p));
218}
219extern int iso_date(char *, int);
220
221struct inode; /* To make gcc happy */
222
223extern int parse_rock_ridge_inode(struct iso_directory_record *, struct inode *);
224extern int get_rock_ridge_filename(struct iso_directory_record *, char *, struct inode *);
225extern int isofs_name_translate(struct iso_directory_record *, char *, struct inode *);
226
227int get_joliet_filename(struct iso_directory_record *, unsigned char *, struct inode *);
228int get_acorn_filename(struct iso_directory_record *, char *, struct inode *);
229
230extern struct dentry *isofs_lookup(struct inode *, struct dentry *, struct nameidata *);
231extern struct buffer_head *isofs_bread(struct inode *, sector_t);
232extern int isofs_get_blocks(struct inode *, sector_t, struct buffer_head **, unsigned long);
233
234extern struct inode *isofs_iget(struct super_block *sb,
235 unsigned long block,
236 unsigned long offset);
237
238/* Because the inode number is no longer relevant to finding the
239 * underlying meta-data for an inode, we are free to choose a more
240 * convenient 32-bit number as the inode number. The inode numbering
241 * scheme was recommended by Sergey Vlasov and Eric Lammerts. */
242static inline unsigned long isofs_get_ino(unsigned long block,
243 unsigned long offset,
244 unsigned long bufbits)
245{
246 return (block << (bufbits - 5)) | (offset >> 5);
247}
248
249/* Every directory can have many redundant directory entries scattered
250 * throughout the directory tree. First there is the directory entry
251 * with the name of the directory stored in the parent directory.
252 * Then, there is the "." directory entry stored in the directory
253 * itself. Finally, there are possibly many ".." directory entries
254 * stored in all the subdirectories.
255 *
256 * In order for the NFS get_parent() method to work and for the
257 * general consistency of the dcache, we need to make sure the
258 * "i_iget5_block" and "i_iget5_offset" all point to exactly one of
259 * the many redundant entries for each directory. We normalize the
260 * block and offset by always making them point to the "." directory.
261 *
262 * Notice that we do not use the entry for the directory with the name
263 * that is located in the parent directory. Even though choosing this
264 * first directory is more natural, it is much easier to find the "."
265 * entry in the NFS get_parent() method because it is implicitly
266 * encoded in the "extent + ext_attr_length" fields of _all_ the
267 * redundant entries for the directory. Thus, it can always be
268 * reached regardless of which directory entry you have in hand.
269 *
270 * This works because the "." entry is simply the first directory
271 * record when you start reading the file that holds all the directory
272 * records, and this file starts at "extent + ext_attr_length" blocks.
273 * Because the "." entry is always the first entry listed in the
274 * directories file, the normalized "offset" value is always 0.
275 *
276 * You should pass the directory entry in "de". On return, "block"
277 * and "offset" will hold normalized values. Only directories are
278 * affected making it safe to call even for non-directory file
279 * types. */
280static inline void
281isofs_normalize_block_and_offset(struct iso_directory_record* de,
282 unsigned long *block,
283 unsigned long *offset)
284{
285 /* Only directories are normalized. */
286 if (de->flags[0] & 2) {
287 *offset = 0;
288 *block = (unsigned long)isonum_733(de->extent)
289 + (unsigned long)isonum_711(de->ext_attr_length);
290 }
291}
292
293extern struct inode_operations isofs_dir_inode_operations;
294extern struct file_operations isofs_dir_operations;
295extern struct address_space_operations isofs_symlink_aops;
296extern struct export_operations isofs_export_ops;
297
298/* The following macros are used to check for memory leaks. */
299#ifdef LEAK_CHECK
300#define free_s leak_check_free_s
301#define malloc leak_check_malloc
302#define sb_bread leak_check_bread
303#define brelse leak_check_brelse
304extern void * leak_check_malloc(unsigned int size);
305extern void leak_check_free_s(void * obj, int size);
306extern struct buffer_head * leak_check_bread(struct super_block *sb, int block);
307extern void leak_check_brelse(struct buffer_head * bh);
308#endif /* LEAK_CHECK */
309
310#endif /* __KERNEL__ */
311
312#endif
diff --git a/include/linux/iso_fs_i.h b/include/linux/iso_fs_i.h
new file mode 100644
index 000000000000..59065e939eaa
--- /dev/null
+++ b/include/linux/iso_fs_i.h
@@ -0,0 +1,27 @@
1#ifndef _ISO_FS_I
2#define _ISO_FS_I
3
4#include <linux/fs.h>
5
6enum isofs_file_format {
7 isofs_file_normal = 0,
8 isofs_file_sparse = 1,
9 isofs_file_compressed = 2,
10};
11
12/*
13 * iso fs inode data in memory
14 */
15struct iso_inode_info {
16 unsigned long i_iget5_block;
17 unsigned long i_iget5_offset;
18 unsigned int i_first_extent;
19 unsigned char i_file_format;
20 unsigned char i_format_parm[3];
21 unsigned long i_next_section_block;
22 unsigned long i_next_section_offset;
23 off_t i_section_size;
24 struct inode vfs_inode;
25};
26
27#endif
diff --git a/include/linux/iso_fs_sb.h b/include/linux/iso_fs_sb.h
new file mode 100644
index 000000000000..043b97b55b8d
--- /dev/null
+++ b/include/linux/iso_fs_sb.h
@@ -0,0 +1,34 @@
1#ifndef _ISOFS_FS_SB
2#define _ISOFS_FS_SB
3
4/*
5 * iso9660 super-block data in memory
6 */
7struct isofs_sb_info {
8 unsigned long s_ninodes;
9 unsigned long s_nzones;
10 unsigned long s_firstdatazone;
11 unsigned long s_log_zone_size;
12 unsigned long s_max_size;
13
14 unsigned char s_high_sierra; /* A simple flag */
15 unsigned char s_mapping;
16 int s_rock_offset; /* offset of SUSP fields within SU area */
17 unsigned char s_rock;
18 unsigned char s_joliet_level;
19 unsigned char s_utf8;
20 unsigned char s_cruft; /* Broken disks with high
21 byte of length containing
22 junk */
23 unsigned char s_unhide;
24 unsigned char s_nosuid;
25 unsigned char s_nodev;
26 unsigned char s_nocompress;
27
28 mode_t s_mode;
29 gid_t s_gid;
30 uid_t s_uid;
31 struct nls_table *s_nls_iocharset; /* Native language support table */
32};
33
34#endif
diff --git a/include/linux/istallion.h b/include/linux/istallion.h
new file mode 100644
index 000000000000..5f4ee646c119
--- /dev/null
+++ b/include/linux/istallion.h
@@ -0,0 +1,132 @@
1/*****************************************************************************/
2
3/*
4 * istallion.h -- stallion intelligent multiport serial driver.
5 *
6 * Copyright (C) 1996-1998 Stallion Technologies
7 * Copyright (C) 1994-1996 Greg Ungerer.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24#include <linux/version.h>
25
26/*****************************************************************************/
27#ifndef _ISTALLION_H
28#define _ISTALLION_H
29/*****************************************************************************/
30
31/*
32 * Define important driver constants here.
33 */
34#define STL_MAXBRDS 4
35#define STL_MAXPANELS 4
36#define STL_MAXPORTS 64
37#define STL_MAXCHANS (STL_MAXPORTS + 1)
38#define STL_MAXDEVS (STL_MAXBRDS * STL_MAXPORTS)
39
40
41/*
42 * Define a set of structures to hold all the board/panel/port info
43 * for our ports. These will be dynamically allocated as required at
44 * driver initialization time.
45 */
46
47/*
48 * Port and board structures to hold status info about each object.
49 * The board structure contains pointers to structures for each port
50 * connected to it. Panels are not distinguished here, since
51 * communication with the slave board will always be on a per port
52 * basis.
53 */
54typedef struct {
55 unsigned long magic;
56 int portnr;
57 int panelnr;
58 int brdnr;
59 unsigned long state;
60 int devnr;
61 int flags;
62 int baud_base;
63 int custom_divisor;
64 int close_delay;
65 int closing_wait;
66 int refcount;
67 int openwaitcnt;
68 int rc;
69 int argsize;
70 void *argp;
71 unsigned int rxmarkmsk;
72 struct tty_struct *tty;
73 wait_queue_head_t open_wait;
74 wait_queue_head_t close_wait;
75 wait_queue_head_t raw_wait;
76 struct work_struct tqhangup;
77 asysigs_t asig;
78 unsigned long addr;
79 unsigned long rxoffset;
80 unsigned long txoffset;
81 unsigned long sigs;
82 unsigned long pflag;
83 unsigned int rxsize;
84 unsigned int txsize;
85 unsigned char reqbit;
86 unsigned char portidx;
87 unsigned char portbit;
88} stliport_t;
89
90/*
91 * Use a structure of function pointers to do board level operations.
92 * These include, enable/disable, paging shared memory, interrupting, etc.
93 */
94typedef struct stlibrd {
95 unsigned long magic;
96 int brdnr;
97 int brdtype;
98 int state;
99 int nrpanels;
100 int nrports;
101 int nrdevs;
102 unsigned int iobase;
103 int iosize;
104 unsigned long memaddr;
105 void *membase;
106 int memsize;
107 int pagesize;
108 int hostoffset;
109 int slaveoffset;
110 int bitsize;
111 int enabval;
112 int panels[STL_MAXPANELS];
113 int panelids[STL_MAXPANELS];
114 void (*init)(struct stlibrd *brdp);
115 void (*enable)(struct stlibrd *brdp);
116 void (*reenable)(struct stlibrd *brdp);
117 void (*disable)(struct stlibrd *brdp);
118 char *(*getmemptr)(struct stlibrd *brdp, unsigned long offset, int line);
119 void (*intr)(struct stlibrd *brdp);
120 void (*reset)(struct stlibrd *brdp);
121 stliport_t *ports[STL_MAXPORTS];
122} stlibrd_t;
123
124
125/*
126 * Define MAGIC numbers used for above structures.
127 */
128#define STLI_PORTMAGIC 0xe671c7a1
129#define STLI_BOARDMAGIC 0x4bc6c825
130
131/*****************************************************************************/
132#endif
diff --git a/include/linux/ite_gpio.h b/include/linux/ite_gpio.h
new file mode 100644
index 000000000000..b123a14292d3
--- /dev/null
+++ b/include/linux/ite_gpio.h
@@ -0,0 +1,66 @@
1/*
2 * FILE NAME ite_gpio.h
3 *
4 * BRIEF MODULE DESCRIPTION
5 * Generic gpio.
6 *
7 * Author: MontaVista Software, Inc. <source@mvista.com>
8 * Hai-Pao Fan <haipao@mvista.com>
9 *
10 * Copyright 2001 MontaVista Software Inc.
11 *
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
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 *
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
20 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * You should have received a copy of the GNU General Public License along
29 * with this program; if not, write to the Free Software Foundation, Inc.,
30 * 675 Mass Ave, Cambridge, MA 02139, USA.
31 */
32
33#ifndef __ITE_GPIO_H
34#define __ITE_GPIO_H
35
36#include <linux/ioctl.h>
37
38struct ite_gpio_ioctl_data {
39 __u32 device;
40 __u32 mask;
41 __u32 data;
42};
43
44#define ITE_GPIO_IOCTL_BASE 'Z'
45
46#define ITE_GPIO_IN _IOWR(ITE_GPIO_IOCTL_BASE, 0, struct ite_gpio_ioctl_data)
47#define ITE_GPIO_OUT _IOW (ITE_GPIO_IOCTL_BASE, 1, struct ite_gpio_ioctl_data)
48#define ITE_GPIO_INT_CTRL _IOW (ITE_GPIO_IOCTL_BASE, 2, struct ite_gpio_ioctl_data)
49#define ITE_GPIO_IN_STATUS _IOW (ITE_GPIO_IOCTL_BASE, 3, struct ite_gpio_ioctl_data)
50#define ITE_GPIO_OUT_STATUS _IOW (ITE_GPIO_IOCTL_BASE, 4, struct ite_gpio_ioctl_data)
51#define ITE_GPIO_GEN_CTRL _IOW (ITE_GPIO_IOCTL_BASE, 5, struct ite_gpio_ioctl_data)
52#define ITE_GPIO_INT_WAIT _IOW (ITE_GPIO_IOCTL_BASE, 6, struct ite_gpio_ioctl_data)
53
54#define ITE_GPIO_PORTA 0x01
55#define ITE_GPIO_PORTB 0x02
56#define ITE_GPIO_PORTC 0x04
57
58extern int ite_gpio_in(__u32 device, __u32 mask, volatile __u32 *data);
59extern int ite_gpio_out(__u32 device, __u32 mask, __u32 data);
60extern int ite_gpio_int_ctrl(__u32 device, __u32 mask, __u32 data);
61extern int ite_gpio_in_status(__u32 device, __u32 mask, volatile __u32 *data);
62extern int ite_gpio_out_status(__u32 device, __u32 mask, __u32 data);
63extern int ite_gpio_gen_ctrl(__u32 device, __u32 mask, __u32 data);
64extern int ite_gpio_int_wait(__u32 device, __u32 mask, __u32 data);
65
66#endif
diff --git a/include/linux/ixjuser.h b/include/linux/ixjuser.h
new file mode 100644
index 000000000000..88121166d715
--- /dev/null
+++ b/include/linux/ixjuser.h
@@ -0,0 +1,722 @@
1#ifndef __LINUX_IXJUSER_H
2#define __LINUX_IXJUSER_H
3
4/******************************************************************************
5 *
6 * ixjuser.h
7 *
8 * Device Driver for Quicknet Technologies, Inc.'s Telephony cards
9 * including the Internet PhoneJACK, Internet PhoneJACK Lite,
10 * Internet PhoneJACK PCI, Internet LineJACK, Internet PhoneCARD and
11 * SmartCABLE
12 *
13 * (c) Copyright 1999-2001 Quicknet Technologies, Inc.
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version
18 * 2 of the License, or (at your option) any later version.
19 *
20 * Author: Ed Okerson, <eokerson@quicknet.net>
21 *
22 * Contributors: Greg Herlein, <gherlein@quicknet.net>
23 * David W. Erhart, <derhart@quicknet.net>
24 * John Sellers, <jsellers@quicknet.net>
25 * Mike Preston, <mpreston@quicknet.net>
26 *
27 * More information about the hardware related to this driver can be found
28 * at our website: http://www.quicknet.net
29 *
30 * Fixes:
31 *
32 * IN NO EVENT SHALL QUICKNET TECHNOLOGIES, INC. BE LIABLE TO ANY PARTY FOR
33 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
34 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF QUICKNET
35 * TECHNOLOGIES, INC.HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 *
37 * QUICKNET TECHNOLOGIES, INC. SPECIFICALLY DISCLAIMS ANY WARRANTIES,
38 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
39 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
40 * ON AN "AS IS" BASIS, AND QUICKNET TECHNOLOGIES, INC. HAS NO OBLIGATION
41 * TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
42 *
43 *****************************************************************************/
44
45static char ixjuser_h_rcsid[] = "$Id: ixjuser.h,v 4.1 2001/08/05 00:17:37 craigs Exp $";
46
47#include <linux/telephony.h>
48
49
50/******************************************************************************
51*
52* IOCTL's used for the Quicknet Telephony Cards
53*
54* If you use the IXJCTL_TESTRAM command, the card must be power cycled to
55* reset the SRAM values before futher use.
56*
57******************************************************************************/
58
59#define IXJCTL_DSP_RESET _IO ('q', 0xC0)
60
61#define IXJCTL_RING PHONE_RING
62#define IXJCTL_HOOKSTATE PHONE_HOOKSTATE
63#define IXJCTL_MAXRINGS PHONE_MAXRINGS
64#define IXJCTL_RING_CADENCE PHONE_RING_CADENCE
65#define IXJCTL_RING_START PHONE_RING_START
66#define IXJCTL_RING_STOP PHONE_RING_STOP
67
68#define IXJCTL_CARDTYPE _IOR ('q', 0xC1, int)
69#define IXJCTL_SERIAL _IOR ('q', 0xC2, int)
70#define IXJCTL_DSP_TYPE _IOR ('q', 0xC3, int)
71#define IXJCTL_DSP_VERSION _IOR ('q', 0xC4, int)
72#define IXJCTL_VERSION _IOR ('q', 0xDA, char *)
73#define IXJCTL_DSP_IDLE _IO ('q', 0xC5)
74#define IXJCTL_TESTRAM _IO ('q', 0xC6)
75
76/******************************************************************************
77*
78* This group of IOCTLs deal with the record settings of the DSP
79*
80* The IXJCTL_REC_DEPTH command sets the internal buffer depth of the DSP.
81* Setting a lower depth reduces latency, but increases the demand of the
82* application to service the driver without frame loss. The DSP has 480
83* bytes of physical buffer memory for the record channel so the true
84* maximum limit is determined by how many frames will fit in the buffer.
85*
86* 1 uncompressed (480 byte) 16-bit linear frame.
87* 2 uncompressed (240 byte) 8-bit A-law/mu-law frames.
88* 15 TrueSpeech 8.5 frames.
89* 20 TrueSpeech 6.3,5.3,4.8 or 4.1 frames.
90*
91* The default in the driver is currently set to 2 frames.
92*
93* The IXJCTL_REC_VOLUME and IXJCTL_PLAY_VOLUME commands both use a Q8
94* number as a parameter, 0x100 scales the signal by 1.0, 0x200 scales the
95* signal by 2.0, 0x80 scales the signal by 0.5. No protection is given
96* against over-scaling, if the multiplication factor times the input
97* signal exceeds 16 bits, overflow distortion will occur. The default
98* setting is 0x100 (1.0).
99*
100* The IXJCTL_REC_LEVEL returns the average signal level (not r.m.s.) on
101* the most recently recorded frame as a 16 bit value.
102******************************************************************************/
103
104#define IXJCTL_REC_CODEC PHONE_REC_CODEC
105#define IXJCTL_REC_START PHONE_REC_START
106#define IXJCTL_REC_STOP PHONE_REC_STOP
107#define IXJCTL_REC_DEPTH PHONE_REC_DEPTH
108#define IXJCTL_FRAME PHONE_FRAME
109#define IXJCTL_REC_VOLUME PHONE_REC_VOLUME
110#define IXJCTL_REC_LEVEL PHONE_REC_LEVEL
111
112typedef enum {
113 f300_640 = 4, f300_500, f1100, f350, f400, f480, f440, f620, f20_50,
114 f133_200, f300, f300_420, f330, f300_425, f330_440, f340, f350_400,
115 f350_440, f350_450, f360, f380_420, f392, f400_425, f400_440, f400_450,
116 f420, f425, f425_450, f425_475, f435, f440_450, f440_480, f445, f450,
117 f452, f475, f480_620, f494, f500, f520, f523, f525, f540_660, f587,
118 f590, f600, f660, f700, f740, f750, f750_1450, f770, f800, f816, f850,
119 f857_1645, f900, f900_1300, f935_1215, f941_1477, f942, f950, f950_1400,
120 f975, f1000, f1020, f1050, f1100_1750, f1140, f1200, f1209, f1330, f1336,
121 lf1366, f1380, f1400, f1477, f1600, f1633_1638, f1800, f1860
122} IXJ_FILTER_FREQ;
123
124typedef struct {
125 unsigned int filter;
126 IXJ_FILTER_FREQ freq;
127 char enable;
128} IXJ_FILTER;
129
130typedef struct {
131 char enable;
132 char en_filter;
133 unsigned int filter;
134 unsigned int on1;
135 unsigned int off1;
136 unsigned int on2;
137 unsigned int off2;
138 unsigned int on3;
139 unsigned int off3;
140} IXJ_FILTER_CADENCE;
141
142#define IXJCTL_SET_FILTER _IOW ('q', 0xC7, IXJ_FILTER *)
143#define IXJCTL_SET_FILTER_RAW _IOW ('q', 0xDD, IXJ_FILTER_RAW *)
144#define IXJCTL_GET_FILTER_HIST _IOW ('q', 0xC8, int)
145#define IXJCTL_FILTER_CADENCE _IOW ('q', 0xD6, IXJ_FILTER_CADENCE *)
146#define IXJCTL_PLAY_CID _IO ('q', 0xD7)
147/******************************************************************************
148*
149* This IOCTL allows you to reassign values in the tone index table. The
150* tone table has 32 entries (0 - 31), but the driver only allows entries
151* 13 - 27 to be modified, entry 0 is reserved for silence and 1 - 12 are
152* the standard DTMF digits and 28 - 31 are the DTMF tones for A, B, C & D.
153* The positions used internally for Call Progress Tones are as follows:
154* Dial Tone - 25
155* Ring Back - 26
156* Busy Signal - 27
157*
158* The freq values are calculated as:
159* freq = cos(2 * PI * frequency / 8000)
160*
161* The most commonly needed values are already calculated and listed in the
162* enum IXJ_TONE_FREQ. Each tone index can have two frequencies with
163* different gains, if you are only using a single frequency set the unused
164* one to 0.
165*
166* The gain values range from 0 to 15 indicating +6dB to -24dB in 2dB
167* increments.
168*
169******************************************************************************/
170
171typedef enum {
172 hz20 = 0x7ffa,
173 hz50 = 0x7fe5,
174 hz133 = 0x7f4c,
175 hz200 = 0x7e6b,
176 hz261 = 0x7d50, /* .63 C1 */
177 hz277 = 0x7cfa, /* .18 CS1 */
178 hz293 = 0x7c9f, /* .66 D1 */
179 hz300 = 0x7c75,
180 hz311 = 0x7c32, /* .13 DS1 */
181 hz329 = 0x7bbf, /* .63 E1 */
182 hz330 = 0x7bb8,
183 hz340 = 0x7b75,
184 hz349 = 0x7b37, /* .23 F1 */
185 hz350 = 0x7b30,
186 hz360 = 0x7ae9,
187 hz369 = 0x7aa8, /* .99 FS1 */
188 hz380 = 0x7a56,
189 hz392 = 0x79fa, /* .00 G1 */
190 hz400 = 0x79bb,
191 hz415 = 0x7941, /* .30 GS1 */
192 hz420 = 0x7918,
193 hz425 = 0x78ee,
194 hz435 = 0x7899,
195 hz440 = 0x786d, /* .00 A1 */
196 hz445 = 0x7842,
197 hz450 = 0x7815,
198 hz452 = 0x7803,
199 hz466 = 0x7784, /* .16 AS1 */
200 hz475 = 0x7731,
201 hz480 = 0x7701,
202 hz493 = 0x7685, /* .88 B1 */
203 hz494 = 0x767b,
204 hz500 = 0x7640,
205 hz520 = 0x7578,
206 hz523 = 0x7559, /* .25 C2 */
207 hz525 = 0x7544,
208 hz540 = 0x74a7,
209 hz554 = 0x7411, /* .37 CS2 */
210 hz587 = 0x72a1, /* .33 D2 */
211 hz590 = 0x727f,
212 hz600 = 0x720b,
213 hz620 = 0x711e,
214 hz622 = 0x7106, /* .25 DS2 */
215 hz659 = 0x6f3b, /* .26 E2 */
216 hz660 = 0x6f2e,
217 hz698 = 0x6d3d, /* .46 F2 */
218 hz700 = 0x6d22,
219 hz739 = 0x6b09, /* .99 FS2 */
220 hz740 = 0x6afa,
221 hz750 = 0x6a6c,
222 hz770 = 0x694b,
223 hz783 = 0x688b, /* .99 G2 */
224 hz800 = 0x678d,
225 hz816 = 0x6698,
226 hz830 = 0x65bf, /* .61 GS2 */
227 hz850 = 0x6484,
228 hz857 = 0x6414,
229 hz880 = 0x629f, /* .00 A2 */
230 hz900 = 0x6154,
231 hz932 = 0x5f35, /* .33 AS2 */
232 hz935 = 0x5f01,
233 hz941 = 0x5e9a,
234 hz942 = 0x5e88,
235 hz950 = 0x5dfd,
236 hz975 = 0x5c44,
237 hz1000 = 0x5a81,
238 hz1020 = 0x5912,
239 hz1050 = 0x56e2,
240 hz1100 = 0x5320,
241 hz1140 = 0x5007,
242 hz1200 = 0x4b3b,
243 hz1209 = 0x4a80,
244 hz1215 = 0x4a02,
245 hz1250 = 0x471c,
246 hz1300 = 0x42e0,
247 hz1330 = 0x4049,
248 hz1336 = 0x3fc4,
249 hz1366 = 0x3d22,
250 hz1380 = 0x3be4,
251 hz1400 = 0x3a1b,
252 hz1450 = 0x3596,
253 hz1477 = 0x331c,
254 hz1500 = 0x30fb,
255 hz1600 = 0x278d,
256 hz1633 = 0x2462,
257 hz1638 = 0x23e7,
258 hz1645 = 0x233a,
259 hz1750 = 0x18f8,
260 hz1800 = 0x1405,
261 hz1860 = 0xe0b,
262 hz2100 = 0xf5f6,
263 hz2130 = 0xf2f5,
264 hz2450 = 0xd3b3,
265 hz2750 = 0xb8e4
266} IXJ_FREQ;
267
268typedef enum {
269 C1 = hz261,
270 CS1 = hz277,
271 D1 = hz293,
272 DS1 = hz311,
273 E1 = hz329,
274 F1 = hz349,
275 FS1 = hz369,
276 G1 = hz392,
277 GS1 = hz415,
278 A1 = hz440,
279 AS1 = hz466,
280 B1 = hz493,
281 C2 = hz523,
282 CS2 = hz554,
283 D2 = hz587,
284 DS2 = hz622,
285 E2 = hz659,
286 F2 = hz698,
287 FS2 = hz739,
288 G2 = hz783,
289 GS2 = hz830,
290 A2 = hz880,
291 AS2 = hz932,
292} IXJ_NOTE;
293
294typedef struct {
295 int tone_index;
296 int freq0;
297 int gain0;
298 int freq1;
299 int gain1;
300} IXJ_TONE;
301
302#define IXJCTL_INIT_TONE _IOW ('q', 0xC9, IXJ_TONE *)
303
304/******************************************************************************
305*
306* The IXJCTL_TONE_CADENCE ioctl defines tone sequences used for various
307* Call Progress Tones (CPT). This is accomplished by setting up an array of
308* IXJ_CADENCE_ELEMENT structures that sequentially define the states of
309* the tone sequence. The tone_on_time and tone_off time are in
310* 250 microsecond intervals. A pointer to this array is passed to the
311* driver as the ce element of an IXJ_CADENCE structure. The elements_used
312* must be set to the number of IXJ_CADENCE_ELEMENTS in the array. The
313* termination variable defines what to do at the end of a cadence, the
314* options are to play the cadence once and stop, to repeat the last
315* element of the cadence indefinitely, or to repeat the entire cadence
316* indefinitely. The ce variable is a pointer to the array of IXJ_TONE
317* structures. If the freq0 variable is non-zero, the tone table contents
318* for the tone_index are updated to the frequencies and gains defined. It
319* should be noted that DTMF tones cannot be reassigned, so if DTMF tone
320* table indexs are used in a cadence the frequency and gain variables will
321* be ignored.
322*
323* If the array elements contain frequency parameters the driver will
324* initialize the needed tone table elements and begin playing the tone,
325* there is no preset limit on the number of elements in the cadence. If
326* there is more than one frequency used in the cadence, sequential elements
327* of different frequencies MUST use different tone table indexes. Only one
328* cadence can be played at a time. It is possible to build complex
329* cadences with multiple frequencies using 2 tone table indexes by
330* alternating between them.
331*
332******************************************************************************/
333
334typedef struct {
335 int index;
336 int tone_on_time;
337 int tone_off_time;
338 int freq0;
339 int gain0;
340 int freq1;
341 int gain1;
342} IXJ_CADENCE_ELEMENT;
343
344typedef enum {
345 PLAY_ONCE,
346 REPEAT_LAST_ELEMENT,
347 REPEAT_ALL
348} IXJ_CADENCE_TERM;
349
350typedef struct {
351 int elements_used;
352 IXJ_CADENCE_TERM termination;
353 IXJ_CADENCE_ELEMENT __user *ce;
354} IXJ_CADENCE;
355
356#define IXJCTL_TONE_CADENCE _IOW ('q', 0xCA, IXJ_CADENCE *)
357/******************************************************************************
358*
359* This group of IOCTLs deal with the playback settings of the DSP
360*
361******************************************************************************/
362
363#define IXJCTL_PLAY_CODEC PHONE_PLAY_CODEC
364#define IXJCTL_PLAY_START PHONE_PLAY_START
365#define IXJCTL_PLAY_STOP PHONE_PLAY_STOP
366#define IXJCTL_PLAY_DEPTH PHONE_PLAY_DEPTH
367#define IXJCTL_PLAY_VOLUME PHONE_PLAY_VOLUME
368#define IXJCTL_PLAY_LEVEL PHONE_PLAY_LEVEL
369
370/******************************************************************************
371*
372* This group of IOCTLs deal with the Acoustic Echo Cancellation settings
373* of the DSP
374*
375* Issuing the IXJCTL_AEC_START command with a value of AEC_OFF has the
376* same effect as IXJCTL_AEC_STOP. This is to simplify slider bar
377* controls. IXJCTL_AEC_GET_LEVEL returns the current setting of the AEC.
378******************************************************************************/
379#define IXJCTL_AEC_START _IOW ('q', 0xCB, int)
380#define IXJCTL_AEC_STOP _IO ('q', 0xCC)
381#define IXJCTL_AEC_GET_LEVEL _IO ('q', 0xCD)
382
383#define AEC_OFF 0
384#define AEC_LOW 1
385#define AEC_MED 2
386#define AEC_HIGH 3
387#define AEC_AUTO 4
388#define AEC_AGC 5
389/******************************************************************************
390*
391* Call Progress Tones, DTMF, etc.
392* IXJCTL_DTMF_OOB determines if DTMF signaling is sent as Out-Of-Band
393* only. If you pass a 1, DTMF is suppressed from the audio stream.
394* Tone on and off times are in 250 microsecond intervals so
395* ioctl(ixj1, IXJCTL_SET_TONE_ON_TIME, 360);
396* will set the tone on time of board ixj1 to 360 * 250us = 90ms
397* the default values of tone on and off times is 840 or 210ms
398******************************************************************************/
399
400#define IXJCTL_DTMF_READY PHONE_DTMF_READY
401#define IXJCTL_GET_DTMF PHONE_GET_DTMF
402#define IXJCTL_GET_DTMF_ASCII PHONE_GET_DTMF_ASCII
403#define IXJCTL_DTMF_OOB PHONE_DTMF_OOB
404#define IXJCTL_EXCEPTION PHONE_EXCEPTION
405#define IXJCTL_PLAY_TONE PHONE_PLAY_TONE
406#define IXJCTL_SET_TONE_ON_TIME PHONE_SET_TONE_ON_TIME
407#define IXJCTL_SET_TONE_OFF_TIME PHONE_SET_TONE_OFF_TIME
408#define IXJCTL_GET_TONE_ON_TIME PHONE_GET_TONE_ON_TIME
409#define IXJCTL_GET_TONE_OFF_TIME PHONE_GET_TONE_OFF_TIME
410#define IXJCTL_GET_TONE_STATE PHONE_GET_TONE_STATE
411#define IXJCTL_BUSY PHONE_BUSY
412#define IXJCTL_RINGBACK PHONE_RINGBACK
413#define IXJCTL_DIALTONE PHONE_DIALTONE
414#define IXJCTL_CPT_STOP PHONE_CPT_STOP
415
416/******************************************************************************
417* LineJACK specific IOCTLs
418*
419* The lsb 4 bits of the LED argument represent the state of each of the 4
420* LED's on the LineJACK
421******************************************************************************/
422
423#define IXJCTL_SET_LED _IOW ('q', 0xCE, int)
424#define IXJCTL_MIXER _IOW ('q', 0xCF, int)
425
426/******************************************************************************
427*
428* The master volume controls use attenuation with 32 levels from 0 to -62dB
429* with steps of 2dB each, the defines should be OR'ed together then sent
430* as the parameter to the mixer command to change the mixer settings.
431*
432******************************************************************************/
433#define MIXER_MASTER_L 0x0000
434#define MIXER_MASTER_R 0x0100
435#define ATT00DB 0x00
436#define ATT02DB 0x01
437#define ATT04DB 0x02
438#define ATT06DB 0x03
439#define ATT08DB 0x04
440#define ATT10DB 0x05
441#define ATT12DB 0x06
442#define ATT14DB 0x07
443#define ATT16DB 0x08
444#define ATT18DB 0x09
445#define ATT20DB 0x0A
446#define ATT22DB 0x0B
447#define ATT24DB 0x0C
448#define ATT26DB 0x0D
449#define ATT28DB 0x0E
450#define ATT30DB 0x0F
451#define ATT32DB 0x10
452#define ATT34DB 0x11
453#define ATT36DB 0x12
454#define ATT38DB 0x13
455#define ATT40DB 0x14
456#define ATT42DB 0x15
457#define ATT44DB 0x16
458#define ATT46DB 0x17
459#define ATT48DB 0x18
460#define ATT50DB 0x19
461#define ATT52DB 0x1A
462#define ATT54DB 0x1B
463#define ATT56DB 0x1C
464#define ATT58DB 0x1D
465#define ATT60DB 0x1E
466#define ATT62DB 0x1F
467#define MASTER_MUTE 0x80
468
469/******************************************************************************
470*
471* The input volume controls use gain with 32 levels from +12dB to -50dB
472* with steps of 2dB each, the defines should be OR'ed together then sent
473* as the parameter to the mixer command to change the mixer settings.
474*
475******************************************************************************/
476#define MIXER_PORT_CD_L 0x0600
477#define MIXER_PORT_CD_R 0x0700
478#define MIXER_PORT_LINE_IN_L 0x0800
479#define MIXER_PORT_LINE_IN_R 0x0900
480#define MIXER_PORT_POTS_REC 0x0C00
481#define MIXER_PORT_MIC 0x0E00
482
483#define GAIN12DB 0x00
484#define GAIN10DB 0x01
485#define GAIN08DB 0x02
486#define GAIN06DB 0x03
487#define GAIN04DB 0x04
488#define GAIN02DB 0x05
489#define GAIN00DB 0x06
490#define GAIN_02DB 0x07
491#define GAIN_04DB 0x08
492#define GAIN_06DB 0x09
493#define GAIN_08DB 0x0A
494#define GAIN_10DB 0x0B
495#define GAIN_12DB 0x0C
496#define GAIN_14DB 0x0D
497#define GAIN_16DB 0x0E
498#define GAIN_18DB 0x0F
499#define GAIN_20DB 0x10
500#define GAIN_22DB 0x11
501#define GAIN_24DB 0x12
502#define GAIN_26DB 0x13
503#define GAIN_28DB 0x14
504#define GAIN_30DB 0x15
505#define GAIN_32DB 0x16
506#define GAIN_34DB 0x17
507#define GAIN_36DB 0x18
508#define GAIN_38DB 0x19
509#define GAIN_40DB 0x1A
510#define GAIN_42DB 0x1B
511#define GAIN_44DB 0x1C
512#define GAIN_46DB 0x1D
513#define GAIN_48DB 0x1E
514#define GAIN_50DB 0x1F
515#define INPUT_MUTE 0x80
516
517/******************************************************************************
518*
519* The POTS volume control use attenuation with 8 levels from 0dB to -28dB
520* with steps of 4dB each, the defines should be OR'ed together then sent
521* as the parameter to the mixer command to change the mixer settings.
522*
523******************************************************************************/
524#define MIXER_PORT_POTS_PLAY 0x0F00
525
526#define POTS_ATT_00DB 0x00
527#define POTS_ATT_04DB 0x01
528#define POTS_ATT_08DB 0x02
529#define POTS_ATT_12DB 0x03
530#define POTS_ATT_16DB 0x04
531#define POTS_ATT_20DB 0x05
532#define POTS_ATT_24DB 0x06
533#define POTS_ATT_28DB 0x07
534#define POTS_MUTE 0x80
535
536/******************************************************************************
537*
538* The DAA controls the interface to the PSTN port. The driver loads the
539* US coefficients by default, so if you live in a different country you
540* need to load the set for your countries phone system.
541*
542******************************************************************************/
543#define IXJCTL_DAA_COEFF_SET _IOW ('q', 0xD0, int)
544
545#define DAA_US 1 /*PITA 8kHz */
546#define DAA_UK 2 /*ISAR34 8kHz */
547#define DAA_FRANCE 3 /* */
548#define DAA_GERMANY 4
549#define DAA_AUSTRALIA 5
550#define DAA_JAPAN 6
551
552/******************************************************************************
553*
554* Use IXJCTL_PORT to set or query the port the card is set to. If the
555* argument is set to PORT_QUERY, the return value of the ioctl will
556* indicate which port is currently in use, otherwise it will change the
557* port.
558*
559******************************************************************************/
560#define IXJCTL_PORT _IOW ('q', 0xD1, int)
561
562#define PORT_QUERY 0
563#define PORT_POTS 1
564#define PORT_PSTN 2
565#define PORT_SPEAKER 3
566#define PORT_HANDSET 4
567
568#define IXJCTL_PSTN_SET_STATE PHONE_PSTN_SET_STATE
569#define IXJCTL_PSTN_GET_STATE PHONE_PSTN_GET_STATE
570
571#define PSTN_ON_HOOK 0
572#define PSTN_RINGING 1
573#define PSTN_OFF_HOOK 2
574#define PSTN_PULSE_DIAL 3
575
576/******************************************************************************
577*
578* The DAA Analog GAIN sets 2 parameters at one time, the receive gain (AGRR),
579* and the transmit gain (AGX). OR together the components and pass them
580* as the parameter to IXJCTL_DAA_AGAIN. The default setting is both at 0dB.
581*
582******************************************************************************/
583#define IXJCTL_DAA_AGAIN _IOW ('q', 0xD2, int)
584
585#define AGRR00DB 0x00 /* Analog gain in receive direction 0dB */
586#define AGRR3_5DB 0x10 /* Analog gain in receive direction 3.5dB */
587#define AGRR06DB 0x30 /* Analog gain in receive direction 6dB */
588
589#define AGX00DB 0x00 /* Analog gain in transmit direction 0dB */
590#define AGX_6DB 0x04 /* Analog gain in transmit direction -6dB */
591#define AGX3_5DB 0x08 /* Analog gain in transmit direction 3.5dB */
592#define AGX_2_5B 0x0C /* Analog gain in transmit direction -2.5dB */
593
594#define IXJCTL_PSTN_LINETEST _IO ('q', 0xD3)
595
596#define IXJCTL_CID _IOR ('q', 0xD4, PHONE_CID *)
597#define IXJCTL_VMWI _IOR ('q', 0xD8, int)
598#define IXJCTL_CIDCW _IOW ('q', 0xD9, PHONE_CID *)
599/******************************************************************************
600*
601* The wink duration is tunable with this ioctl. The default wink duration
602* is 320ms. You do not need to use this ioctl if you do not require a
603* different wink duration.
604*
605******************************************************************************/
606#define IXJCTL_WINK_DURATION PHONE_WINK_DURATION
607
608/******************************************************************************
609*
610* This ioctl will connect the POTS port to the PSTN port on the LineJACK
611* In order for this to work properly the port selection should be set to
612* the PSTN port with IXJCTL_PORT prior to calling this ioctl. This will
613* enable conference calls between PSTN callers and network callers.
614* Passing a 1 to this ioctl enables the POTS<->PSTN connection while
615* passing a 0 turns it back off.
616*
617******************************************************************************/
618#define IXJCTL_POTS_PSTN _IOW ('q', 0xD5, int)
619
620/******************************************************************************
621*
622* IOCTLs added by request.
623*
624* IXJCTL_HZ sets the value your Linux kernel uses for HZ as defined in
625* /usr/include/asm/param.h, this determines the fundamental
626* frequency of the clock ticks on your Linux system. The kernel
627* must be rebuilt if you change this value, also all modules you
628* use (except this one) must be recompiled. The default value
629* is 100, and you only need to use this IOCTL if you use some
630* other value.
631*
632*
633* IXJCTL_RATE sets the number of times per second that the driver polls
634* the DSP. This value cannot be larger than HZ. By
635* increasing both of these values, you may be able to reduce
636* latency because the max hang time that can exist between the
637* driver and the DSP will be reduced.
638*
639******************************************************************************/
640
641#define IXJCTL_HZ _IOW ('q', 0xE0, int)
642#define IXJCTL_RATE _IOW ('q', 0xE1, int)
643#define IXJCTL_FRAMES_READ _IOR ('q', 0xE2, unsigned long)
644#define IXJCTL_FRAMES_WRITTEN _IOR ('q', 0xE3, unsigned long)
645#define IXJCTL_READ_WAIT _IOR ('q', 0xE4, unsigned long)
646#define IXJCTL_WRITE_WAIT _IOR ('q', 0xE5, unsigned long)
647#define IXJCTL_DRYBUFFER_READ _IOR ('q', 0xE6, unsigned long)
648#define IXJCTL_DRYBUFFER_CLEAR _IO ('q', 0xE7)
649#define IXJCTL_DTMF_PRESCALE _IOW ('q', 0xE8, int)
650
651/******************************************************************************
652*
653* This ioctl allows the user application to control what events the driver
654* will send signals for, and what signals it will send for which event.
655* By default, if signaling is enabled, all events will send SIGIO when
656* they occur. To disable signals for an event set the signal to 0.
657*
658******************************************************************************/
659typedef enum {
660 SIG_DTMF_READY,
661 SIG_HOOKSTATE,
662 SIG_FLASH,
663 SIG_PSTN_RING,
664 SIG_CALLER_ID,
665 SIG_PSTN_WINK,
666 SIG_F0, SIG_F1, SIG_F2, SIG_F3,
667 SIG_FC0, SIG_FC1, SIG_FC2, SIG_FC3,
668 SIG_READ_READY = 33,
669 SIG_WRITE_READY = 34
670} IXJ_SIGEVENT;
671
672typedef struct {
673 unsigned int event;
674 int signal;
675} IXJ_SIGDEF;
676
677#define IXJCTL_SIGCTL _IOW ('q', 0xE9, IXJ_SIGDEF *)
678
679/******************************************************************************
680*
681* These ioctls allow the user application to change the gain in the
682* Smart Cable of the Internet Phone Card. Sending -1 as a value will cause
683* return value to be the current setting. Valid values to set are 0x00 - 0x1F
684*
685* 11111 = +12 dB
686* 10111 = 0 dB
687* 00000 = -34.5 dB
688*
689* IXJCTL_SC_RXG sets the Receive gain
690* IXJCTL_SC_TXG sets the Transmit gain
691*
692******************************************************************************/
693#define IXJCTL_SC_RXG _IOW ('q', 0xEA, int)
694#define IXJCTL_SC_TXG _IOW ('q', 0xEB, int)
695
696/******************************************************************************
697*
698* The intercom IOCTL's short the output from one card to the input of the
699* other and vice versa (actually done in the DSP read function). It is only
700* necessary to execute the IOCTL on one card, but it is necessary to have
701* both devices open to be able to detect hook switch changes. The record
702* codec and rate of each card must match the playback codec and rate of
703* the other card for this to work properly.
704*
705******************************************************************************/
706
707#define IXJCTL_INTERCOM_START _IOW ('q', 0xFD, int)
708#define IXJCTL_INTERCOM_STOP _IOW ('q', 0xFE, int)
709
710/******************************************************************************
711 *
712 * new structure for accessing raw filter information
713 *
714 ******************************************************************************/
715
716typedef struct {
717 unsigned int filter;
718 char enable;
719 unsigned int coeff[19];
720} IXJ_FILTER_RAW;
721
722#endif
diff --git a/include/linux/jbd.h b/include/linux/jbd.h
new file mode 100644
index 000000000000..593407e865b1
--- /dev/null
+++ b/include/linux/jbd.h
@@ -0,0 +1,1098 @@
1/*
2 * linux/include/linux/jbd.h
3 *
4 * Written by Stephen C. Tweedie <sct@redhat.com>
5 *
6 * Copyright 1998-2000 Red Hat, Inc --- 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 * Definitions for transaction data structures for the buffer cache
13 * filesystem journaling support.
14 */
15
16#ifndef _LINUX_JBD_H
17#define _LINUX_JBD_H
18
19#if defined(CONFIG_JBD) || defined(CONFIG_JBD_MODULE) || !defined(__KERNEL__)
20
21/* Allow this file to be included directly into e2fsprogs */
22#ifndef __KERNEL__
23#include "jfs_compat.h"
24#define JFS_DEBUG
25#define jfs_debug jbd_debug
26#else
27
28#include <linux/buffer_head.h>
29#include <linux/journal-head.h>
30#include <linux/stddef.h>
31#include <asm/semaphore.h>
32#endif
33
34#define journal_oom_retry 1
35
36/*
37 * Define JBD_PARANIOD_IOFAIL to cause a kernel BUG() if ext3 finds
38 * certain classes of error which can occur due to failed IOs. Under
39 * normal use we want ext3 to continue after such errors, because
40 * hardware _can_ fail, but for debugging purposes when running tests on
41 * known-good hardware we may want to trap these errors.
42 */
43#undef JBD_PARANOID_IOFAIL
44
45/*
46 * The default maximum commit age, in seconds.
47 */
48#define JBD_DEFAULT_MAX_COMMIT_AGE 5
49
50#ifdef CONFIG_JBD_DEBUG
51/*
52 * Define JBD_EXPENSIVE_CHECKING to enable more expensive internal
53 * consistency checks. By default we don't do this unless
54 * CONFIG_JBD_DEBUG is on.
55 */
56#define JBD_EXPENSIVE_CHECKING
57extern int journal_enable_debug;
58
59#define jbd_debug(n, f, a...) \
60 do { \
61 if ((n) <= journal_enable_debug) { \
62 printk (KERN_DEBUG "(%s, %d): %s: ", \
63 __FILE__, __LINE__, __FUNCTION__); \
64 printk (f, ## a); \
65 } \
66 } while (0)
67#else
68#define jbd_debug(f, a...) /**/
69#endif
70
71extern void * __jbd_kmalloc (const char *where, size_t size, int flags, int retry);
72#define jbd_kmalloc(size, flags) \
73 __jbd_kmalloc(__FUNCTION__, (size), (flags), journal_oom_retry)
74#define jbd_rep_kmalloc(size, flags) \
75 __jbd_kmalloc(__FUNCTION__, (size), (flags), 1)
76
77#define JFS_MIN_JOURNAL_BLOCKS 1024
78
79#ifdef __KERNEL__
80
81/**
82 * typedef handle_t - The handle_t type represents a single atomic update being performed by some process.
83 *
84 * All filesystem modifications made by the process go
85 * through this handle. Recursive operations (such as quota operations)
86 * are gathered into a single update.
87 *
88 * The buffer credits field is used to account for journaled buffers
89 * being modified by the running process. To ensure that there is
90 * enough log space for all outstanding operations, we need to limit the
91 * number of outstanding buffers possible at any time. When the
92 * operation completes, any buffer credits not used are credited back to
93 * the transaction, so that at all times we know how many buffers the
94 * outstanding updates on a transaction might possibly touch.
95 *
96 * This is an opaque datatype.
97 **/
98typedef struct handle_s handle_t; /* Atomic operation type */
99
100
101/**
102 * typedef journal_t - The journal_t maintains all of the journaling state information for a single filesystem.
103 *
104 * journal_t is linked to from the fs superblock structure.
105 *
106 * We use the journal_t to keep track of all outstanding transaction
107 * activity on the filesystem, and to manage the state of the log
108 * writing process.
109 *
110 * This is an opaque datatype.
111 **/
112typedef struct journal_s journal_t; /* Journal control structure */
113#endif
114
115/*
116 * Internal structures used by the logging mechanism:
117 */
118
119#define JFS_MAGIC_NUMBER 0xc03b3998U /* The first 4 bytes of /dev/random! */
120
121/*
122 * On-disk structures
123 */
124
125/*
126 * Descriptor block types:
127 */
128
129#define JFS_DESCRIPTOR_BLOCK 1
130#define JFS_COMMIT_BLOCK 2
131#define JFS_SUPERBLOCK_V1 3
132#define JFS_SUPERBLOCK_V2 4
133#define JFS_REVOKE_BLOCK 5
134
135/*
136 * Standard header for all descriptor blocks:
137 */
138typedef struct journal_header_s
139{
140 __be32 h_magic;
141 __be32 h_blocktype;
142 __be32 h_sequence;
143} journal_header_t;
144
145
146/*
147 * The block tag: used to describe a single buffer in the journal
148 */
149typedef struct journal_block_tag_s
150{
151 __be32 t_blocknr; /* The on-disk block number */
152 __be32 t_flags; /* See below */
153} journal_block_tag_t;
154
155/*
156 * The revoke descriptor: used on disk to describe a series of blocks to
157 * be revoked from the log
158 */
159typedef struct journal_revoke_header_s
160{
161 journal_header_t r_header;
162 __be32 r_count; /* Count of bytes used in the block */
163} journal_revoke_header_t;
164
165
166/* Definitions for the journal tag flags word: */
167#define JFS_FLAG_ESCAPE 1 /* on-disk block is escaped */
168#define JFS_FLAG_SAME_UUID 2 /* block has same uuid as previous */
169#define JFS_FLAG_DELETED 4 /* block deleted by this transaction */
170#define JFS_FLAG_LAST_TAG 8 /* last tag in this descriptor block */
171
172
173/*
174 * The journal superblock. All fields are in big-endian byte order.
175 */
176typedef struct journal_superblock_s
177{
178/* 0x0000 */
179 journal_header_t s_header;
180
181/* 0x000C */
182 /* Static information describing the journal */
183 __be32 s_blocksize; /* journal device blocksize */
184 __be32 s_maxlen; /* total blocks in journal file */
185 __be32 s_first; /* first block of log information */
186
187/* 0x0018 */
188 /* Dynamic information describing the current state of the log */
189 __be32 s_sequence; /* first commit ID expected in log */
190 __be32 s_start; /* blocknr of start of log */
191
192/* 0x0020 */
193 /* Error value, as set by journal_abort(). */
194 __be32 s_errno;
195
196/* 0x0024 */
197 /* Remaining fields are only valid in a version-2 superblock */
198 __be32 s_feature_compat; /* compatible feature set */
199 __be32 s_feature_incompat; /* incompatible feature set */
200 __be32 s_feature_ro_compat; /* readonly-compatible feature set */
201/* 0x0030 */
202 __u8 s_uuid[16]; /* 128-bit uuid for journal */
203
204/* 0x0040 */
205 __be32 s_nr_users; /* Nr of filesystems sharing log */
206
207 __be32 s_dynsuper; /* Blocknr of dynamic superblock copy*/
208
209/* 0x0048 */
210 __be32 s_max_transaction; /* Limit of journal blocks per trans.*/
211 __be32 s_max_trans_data; /* Limit of data blocks per trans. */
212
213/* 0x0050 */
214 __u32 s_padding[44];
215
216/* 0x0100 */
217 __u8 s_users[16*48]; /* ids of all fs'es sharing the log */
218/* 0x0400 */
219} journal_superblock_t;
220
221#define JFS_HAS_COMPAT_FEATURE(j,mask) \
222 ((j)->j_format_version >= 2 && \
223 ((j)->j_superblock->s_feature_compat & cpu_to_be32((mask))))
224#define JFS_HAS_RO_COMPAT_FEATURE(j,mask) \
225 ((j)->j_format_version >= 2 && \
226 ((j)->j_superblock->s_feature_ro_compat & cpu_to_be32((mask))))
227#define JFS_HAS_INCOMPAT_FEATURE(j,mask) \
228 ((j)->j_format_version >= 2 && \
229 ((j)->j_superblock->s_feature_incompat & cpu_to_be32((mask))))
230
231#define JFS_FEATURE_INCOMPAT_REVOKE 0x00000001
232
233/* Features known to this kernel version: */
234#define JFS_KNOWN_COMPAT_FEATURES 0
235#define JFS_KNOWN_ROCOMPAT_FEATURES 0
236#define JFS_KNOWN_INCOMPAT_FEATURES JFS_FEATURE_INCOMPAT_REVOKE
237
238#ifdef __KERNEL__
239
240#include <linux/fs.h>
241#include <linux/sched.h>
242#include <asm/bug.h>
243
244#define JBD_ASSERTIONS
245#ifdef JBD_ASSERTIONS
246#define J_ASSERT(assert) \
247do { \
248 if (!(assert)) { \
249 printk (KERN_EMERG \
250 "Assertion failure in %s() at %s:%d: \"%s\"\n", \
251 __FUNCTION__, __FILE__, __LINE__, # assert); \
252 BUG(); \
253 } \
254} while (0)
255
256#if defined(CONFIG_BUFFER_DEBUG)
257void buffer_assertion_failure(struct buffer_head *bh);
258#define J_ASSERT_BH(bh, expr) \
259 do { \
260 if (!(expr)) \
261 buffer_assertion_failure(bh); \
262 J_ASSERT(expr); \
263 } while (0)
264#define J_ASSERT_JH(jh, expr) J_ASSERT_BH(jh2bh(jh), expr)
265#else
266#define J_ASSERT_BH(bh, expr) J_ASSERT(expr)
267#define J_ASSERT_JH(jh, expr) J_ASSERT(expr)
268#endif
269
270#else
271#define J_ASSERT(assert) do { } while (0)
272#endif /* JBD_ASSERTIONS */
273
274#if defined(JBD_PARANOID_IOFAIL)
275#define J_EXPECT(expr, why...) J_ASSERT(expr)
276#define J_EXPECT_BH(bh, expr, why...) J_ASSERT_BH(bh, expr)
277#define J_EXPECT_JH(jh, expr, why...) J_ASSERT_JH(jh, expr)
278#else
279#define __journal_expect(expr, why...) \
280 ({ \
281 int val = (expr); \
282 if (!val) { \
283 printk(KERN_ERR \
284 "EXT3-fs unexpected failure: %s;\n",# expr); \
285 printk(KERN_ERR why "\n"); \
286 } \
287 val; \
288 })
289#define J_EXPECT(expr, why...) __journal_expect(expr, ## why)
290#define J_EXPECT_BH(bh, expr, why...) __journal_expect(expr, ## why)
291#define J_EXPECT_JH(jh, expr, why...) __journal_expect(expr, ## why)
292#endif
293
294enum jbd_state_bits {
295 BH_JBD /* Has an attached ext3 journal_head */
296 = BH_PrivateStart,
297 BH_JWrite, /* Being written to log (@@@ DEBUGGING) */
298 BH_Freed, /* Has been freed (truncated) */
299 BH_Revoked, /* Has been revoked from the log */
300 BH_RevokeValid, /* Revoked flag is valid */
301 BH_JBDDirty, /* Is dirty but journaled */
302 BH_State, /* Pins most journal_head state */
303 BH_JournalHead, /* Pins bh->b_private and jh->b_bh */
304 BH_Unshadow, /* Dummy bit, for BJ_Shadow wakeup filtering */
305};
306
307BUFFER_FNS(JBD, jbd)
308BUFFER_FNS(JWrite, jwrite)
309BUFFER_FNS(JBDDirty, jbddirty)
310TAS_BUFFER_FNS(JBDDirty, jbddirty)
311BUFFER_FNS(Revoked, revoked)
312TAS_BUFFER_FNS(Revoked, revoked)
313BUFFER_FNS(RevokeValid, revokevalid)
314TAS_BUFFER_FNS(RevokeValid, revokevalid)
315BUFFER_FNS(Freed, freed)
316
317static inline struct buffer_head *jh2bh(struct journal_head *jh)
318{
319 return jh->b_bh;
320}
321
322static inline struct journal_head *bh2jh(struct buffer_head *bh)
323{
324 return bh->b_private;
325}
326
327static inline void jbd_lock_bh_state(struct buffer_head *bh)
328{
329 bit_spin_lock(BH_State, &bh->b_state);
330}
331
332static inline int jbd_trylock_bh_state(struct buffer_head *bh)
333{
334 return bit_spin_trylock(BH_State, &bh->b_state);
335}
336
337static inline int jbd_is_locked_bh_state(struct buffer_head *bh)
338{
339 return bit_spin_is_locked(BH_State, &bh->b_state);
340}
341
342static inline void jbd_unlock_bh_state(struct buffer_head *bh)
343{
344 bit_spin_unlock(BH_State, &bh->b_state);
345}
346
347static inline void jbd_lock_bh_journal_head(struct buffer_head *bh)
348{
349 bit_spin_lock(BH_JournalHead, &bh->b_state);
350}
351
352static inline void jbd_unlock_bh_journal_head(struct buffer_head *bh)
353{
354 bit_spin_unlock(BH_JournalHead, &bh->b_state);
355}
356
357struct jbd_revoke_table_s;
358
359/**
360 * struct handle_s - The handle_s type is the concrete type associated with
361 * handle_t.
362 * @h_transaction: Which compound transaction is this update a part of?
363 * @h_buffer_credits: Number of remaining buffers we are allowed to dirty.
364 * @h_ref: Reference count on this handle
365 * @h_err: Field for caller's use to track errors through large fs operations
366 * @h_sync: flag for sync-on-close
367 * @h_jdata: flag to force data journaling
368 * @h_aborted: flag indicating fatal error on handle
369 **/
370
371/* Docbook can't yet cope with the bit fields, but will leave the documentation
372 * in so it can be fixed later.
373 */
374
375struct handle_s
376{
377 /* Which compound transaction is this update a part of? */
378 transaction_t *h_transaction;
379
380 /* Number of remaining buffers we are allowed to dirty: */
381 int h_buffer_credits;
382
383 /* Reference count on this handle */
384 int h_ref;
385
386 /* Field for caller's use to track errors through large fs */
387 /* operations */
388 int h_err;
389
390 /* Flags [no locking] */
391 unsigned int h_sync: 1; /* sync-on-close */
392 unsigned int h_jdata: 1; /* force data journaling */
393 unsigned int h_aborted: 1; /* fatal error on handle */
394};
395
396
397/* The transaction_t type is the guts of the journaling mechanism. It
398 * tracks a compound transaction through its various states:
399 *
400 * RUNNING: accepting new updates
401 * LOCKED: Updates still running but we don't accept new ones
402 * RUNDOWN: Updates are tidying up but have finished requesting
403 * new buffers to modify (state not used for now)
404 * FLUSH: All updates complete, but we are still writing to disk
405 * COMMIT: All data on disk, writing commit record
406 * FINISHED: We still have to keep the transaction for checkpointing.
407 *
408 * The transaction keeps track of all of the buffers modified by a
409 * running transaction, and all of the buffers committed but not yet
410 * flushed to home for finished transactions.
411 */
412
413/*
414 * Lock ranking:
415 *
416 * j_list_lock
417 * ->jbd_lock_bh_journal_head() (This is "innermost")
418 *
419 * j_state_lock
420 * ->jbd_lock_bh_state()
421 *
422 * jbd_lock_bh_state()
423 * ->j_list_lock
424 *
425 * j_state_lock
426 * ->t_handle_lock
427 *
428 * j_state_lock
429 * ->j_list_lock (journal_unmap_buffer)
430 *
431 */
432
433struct transaction_s
434{
435 /* Pointer to the journal for this transaction. [no locking] */
436 journal_t *t_journal;
437
438 /* Sequence number for this transaction [no locking] */
439 tid_t t_tid;
440
441 /*
442 * Transaction's current state
443 * [no locking - only kjournald alters this]
444 * FIXME: needs barriers
445 * KLUDGE: [use j_state_lock]
446 */
447 enum {
448 T_RUNNING,
449 T_LOCKED,
450 T_RUNDOWN,
451 T_FLUSH,
452 T_COMMIT,
453 T_FINISHED
454 } t_state;
455
456 /*
457 * Where in the log does this transaction's commit start? [no locking]
458 */
459 unsigned long t_log_start;
460
461 /* Number of buffers on the t_buffers list [j_list_lock] */
462 int t_nr_buffers;
463
464 /*
465 * Doubly-linked circular list of all buffers reserved but not yet
466 * modified by this transaction [j_list_lock]
467 */
468 struct journal_head *t_reserved_list;
469
470 /*
471 * Doubly-linked circular list of all buffers under writeout during
472 * commit [j_list_lock]
473 */
474 struct journal_head *t_locked_list;
475
476 /*
477 * Doubly-linked circular list of all metadata buffers owned by this
478 * transaction [j_list_lock]
479 */
480 struct journal_head *t_buffers;
481
482 /*
483 * Doubly-linked circular list of all data buffers still to be
484 * flushed before this transaction can be committed [j_list_lock]
485 */
486 struct journal_head *t_sync_datalist;
487
488 /*
489 * Doubly-linked circular list of all forget buffers (superseded
490 * buffers which we can un-checkpoint once this transaction commits)
491 * [j_list_lock]
492 */
493 struct journal_head *t_forget;
494
495 /*
496 * Doubly-linked circular list of all buffers still to be flushed before
497 * this transaction can be checkpointed. [j_list_lock]
498 */
499 struct journal_head *t_checkpoint_list;
500
501 /*
502 * Doubly-linked circular list of temporary buffers currently undergoing
503 * IO in the log [j_list_lock]
504 */
505 struct journal_head *t_iobuf_list;
506
507 /*
508 * Doubly-linked circular list of metadata buffers being shadowed by log
509 * IO. The IO buffers on the iobuf list and the shadow buffers on this
510 * list match each other one for one at all times. [j_list_lock]
511 */
512 struct journal_head *t_shadow_list;
513
514 /*
515 * Doubly-linked circular list of control buffers being written to the
516 * log. [j_list_lock]
517 */
518 struct journal_head *t_log_list;
519
520 /*
521 * Protects info related to handles
522 */
523 spinlock_t t_handle_lock;
524
525 /*
526 * Number of outstanding updates running on this transaction
527 * [t_handle_lock]
528 */
529 int t_updates;
530
531 /*
532 * Number of buffers reserved for use by all handles in this transaction
533 * handle but not yet modified. [t_handle_lock]
534 */
535 int t_outstanding_credits;
536
537 /*
538 * Forward and backward links for the circular list of all transactions
539 * awaiting checkpoint. [j_list_lock]
540 */
541 transaction_t *t_cpnext, *t_cpprev;
542
543 /*
544 * When will the transaction expire (become due for commit), in jiffies?
545 * [no locking]
546 */
547 unsigned long t_expires;
548
549 /*
550 * How many handles used this transaction? [t_handle_lock]
551 */
552 int t_handle_count;
553
554};
555
556/**
557 * struct journal_s - The journal_s type is the concrete type associated with
558 * journal_t.
559 * @j_flags: General journaling state flags
560 * @j_errno: Is there an outstanding uncleared error on the journal (from a
561 * prior abort)?
562 * @j_sb_buffer: First part of superblock buffer
563 * @j_superblock: Second part of superblock buffer
564 * @j_format_version: Version of the superblock format
565 * @j_state_lock: Protect the various scalars in the journal
566 * @j_barrier_count: Number of processes waiting to create a barrier lock
567 * @j_barrier: The barrier lock itself
568 * @j_running_transaction: The current running transaction..
569 * @j_committing_transaction: the transaction we are pushing to disk
570 * @j_checkpoint_transactions: a linked circular list of all transactions
571 * waiting for checkpointing
572 * @j_wait_transaction_locked: Wait queue for waiting for a locked transaction
573 * to start committing, or for a barrier lock to be released
574 * @j_wait_logspace: Wait queue for waiting for checkpointing to complete
575 * @j_wait_done_commit: Wait queue for waiting for commit to complete
576 * @j_wait_checkpoint: Wait queue to trigger checkpointing
577 * @j_wait_commit: Wait queue to trigger commit
578 * @j_wait_updates: Wait queue to wait for updates to complete
579 * @j_checkpoint_sem: Semaphore for locking against concurrent checkpoints
580 * @j_head: Journal head - identifies the first unused block in the journal
581 * @j_tail: Journal tail - identifies the oldest still-used block in the
582 * journal.
583 * @j_free: Journal free - how many free blocks are there in the journal?
584 * @j_first: The block number of the first usable block
585 * @j_last: The block number one beyond the last usable block
586 * @j_dev: Device where we store the journal
587 * @j_blocksize: blocksize for the location where we store the journal.
588 * @j_blk_offset: starting block offset for into the device where we store the
589 * journal
590 * @j_fs_dev: Device which holds the client fs. For internal journal this will
591 * be equal to j_dev
592 * @j_maxlen: Total maximum capacity of the journal region on disk.
593 * @j_list_lock: Protects the buffer lists and internal buffer state.
594 * @j_inode: Optional inode where we store the journal. If present, all journal
595 * block numbers are mapped into this inode via bmap().
596 * @j_tail_sequence: Sequence number of the oldest transaction in the log
597 * @j_transaction_sequence: Sequence number of the next transaction to grant
598 * @j_commit_sequence: Sequence number of the most recently committed
599 * transaction
600 * @j_commit_request: Sequence number of the most recent transaction wanting
601 * commit
602 * @j_uuid: Uuid of client object.
603 * @j_task: Pointer to the current commit thread for this journal
604 * @j_max_transaction_buffers: Maximum number of metadata buffers to allow in a
605 * single compound commit transaction
606 * @j_commit_interval: What is the maximum transaction lifetime before we begin
607 * a commit?
608 * @j_commit_timer: The timer used to wakeup the commit thread
609 * @j_revoke_lock: Protect the revoke table
610 * @j_revoke: The revoke table - maintains the list of revoked blocks in the
611 * current transaction.
612 * @j_revoke_table: alternate revoke tables for j_revoke
613 * @j_private: An opaque pointer to fs-private information.
614 */
615
616struct journal_s
617{
618 /* General journaling state flags [j_state_lock] */
619 unsigned long j_flags;
620
621 /*
622 * Is there an outstanding uncleared error on the journal (from a prior
623 * abort)? [j_state_lock]
624 */
625 int j_errno;
626
627 /* The superblock buffer */
628 struct buffer_head *j_sb_buffer;
629 journal_superblock_t *j_superblock;
630
631 /* Version of the superblock format */
632 int j_format_version;
633
634 /*
635 * Protect the various scalars in the journal
636 */
637 spinlock_t j_state_lock;
638
639 /*
640 * Number of processes waiting to create a barrier lock [j_state_lock]
641 */
642 int j_barrier_count;
643
644 /* The barrier lock itself */
645 struct semaphore j_barrier;
646
647 /*
648 * Transactions: The current running transaction...
649 * [j_state_lock] [caller holding open handle]
650 */
651 transaction_t *j_running_transaction;
652
653 /*
654 * the transaction we are pushing to disk
655 * [j_state_lock] [caller holding open handle]
656 */
657 transaction_t *j_committing_transaction;
658
659 /*
660 * ... and a linked circular list of all transactions waiting for
661 * checkpointing. [j_list_lock]
662 */
663 transaction_t *j_checkpoint_transactions;
664
665 /*
666 * Wait queue for waiting for a locked transaction to start committing,
667 * or for a barrier lock to be released
668 */
669 wait_queue_head_t j_wait_transaction_locked;
670
671 /* Wait queue for waiting for checkpointing to complete */
672 wait_queue_head_t j_wait_logspace;
673
674 /* Wait queue for waiting for commit to complete */
675 wait_queue_head_t j_wait_done_commit;
676
677 /* Wait queue to trigger checkpointing */
678 wait_queue_head_t j_wait_checkpoint;
679
680 /* Wait queue to trigger commit */
681 wait_queue_head_t j_wait_commit;
682
683 /* Wait queue to wait for updates to complete */
684 wait_queue_head_t j_wait_updates;
685
686 /* Semaphore for locking against concurrent checkpoints */
687 struct semaphore j_checkpoint_sem;
688
689 /*
690 * Journal head: identifies the first unused block in the journal.
691 * [j_state_lock]
692 */
693 unsigned long j_head;
694
695 /*
696 * Journal tail: identifies the oldest still-used block in the journal.
697 * [j_state_lock]
698 */
699 unsigned long j_tail;
700
701 /*
702 * Journal free: how many free blocks are there in the journal?
703 * [j_state_lock]
704 */
705 unsigned long j_free;
706
707 /*
708 * Journal start and end: the block numbers of the first usable block
709 * and one beyond the last usable block in the journal. [j_state_lock]
710 */
711 unsigned long j_first;
712 unsigned long j_last;
713
714 /*
715 * Device, blocksize and starting block offset for the location where we
716 * store the journal.
717 */
718 struct block_device *j_dev;
719 int j_blocksize;
720 unsigned int j_blk_offset;
721
722 /*
723 * Device which holds the client fs. For internal journal this will be
724 * equal to j_dev.
725 */
726 struct block_device *j_fs_dev;
727
728 /* Total maximum capacity of the journal region on disk. */
729 unsigned int j_maxlen;
730
731 /*
732 * Protects the buffer lists and internal buffer state.
733 */
734 spinlock_t j_list_lock;
735
736 /* Optional inode where we store the journal. If present, all */
737 /* journal block numbers are mapped into this inode via */
738 /* bmap(). */
739 struct inode *j_inode;
740
741 /*
742 * Sequence number of the oldest transaction in the log [j_state_lock]
743 */
744 tid_t j_tail_sequence;
745
746 /*
747 * Sequence number of the next transaction to grant [j_state_lock]
748 */
749 tid_t j_transaction_sequence;
750
751 /*
752 * Sequence number of the most recently committed transaction
753 * [j_state_lock].
754 */
755 tid_t j_commit_sequence;
756
757 /*
758 * Sequence number of the most recent transaction wanting commit
759 * [j_state_lock]
760 */
761 tid_t j_commit_request;
762
763 /*
764 * Journal uuid: identifies the object (filesystem, LVM volume etc)
765 * backed by this journal. This will eventually be replaced by an array
766 * of uuids, allowing us to index multiple devices within a single
767 * journal and to perform atomic updates across them.
768 */
769 __u8 j_uuid[16];
770
771 /* Pointer to the current commit thread for this journal */
772 struct task_struct *j_task;
773
774 /*
775 * Maximum number of metadata buffers to allow in a single compound
776 * commit transaction
777 */
778 int j_max_transaction_buffers;
779
780 /*
781 * What is the maximum transaction lifetime before we begin a commit?
782 */
783 unsigned long j_commit_interval;
784
785 /* The timer used to wakeup the commit thread: */
786 struct timer_list *j_commit_timer;
787
788 /*
789 * The revoke table: maintains the list of revoked blocks in the
790 * current transaction. [j_revoke_lock]
791 */
792 spinlock_t j_revoke_lock;
793 struct jbd_revoke_table_s *j_revoke;
794 struct jbd_revoke_table_s *j_revoke_table[2];
795
796 /*
797 * array of bhs for journal_commit_transaction
798 */
799 struct buffer_head **j_wbuf;
800 int j_wbufsize;
801
802 /*
803 * An opaque pointer to fs-private information. ext3 puts its
804 * superblock pointer here
805 */
806 void *j_private;
807};
808
809/*
810 * Journal flag definitions
811 */
812#define JFS_UNMOUNT 0x001 /* Journal thread is being destroyed */
813#define JFS_ABORT 0x002 /* Journaling has been aborted for errors. */
814#define JFS_ACK_ERR 0x004 /* The errno in the sb has been acked */
815#define JFS_FLUSHED 0x008 /* The journal superblock has been flushed */
816#define JFS_LOADED 0x010 /* The journal superblock has been loaded */
817#define JFS_BARRIER 0x020 /* Use IDE barriers */
818
819/*
820 * Function declarations for the journaling transaction and buffer
821 * management
822 */
823
824/* Filing buffers */
825extern void __journal_temp_unlink_buffer(struct journal_head *jh);
826extern void journal_unfile_buffer(journal_t *, struct journal_head *);
827extern void __journal_unfile_buffer(struct journal_head *);
828extern void __journal_refile_buffer(struct journal_head *);
829extern void journal_refile_buffer(journal_t *, struct journal_head *);
830extern void __journal_file_buffer(struct journal_head *, transaction_t *, int);
831extern void __journal_free_buffer(struct journal_head *bh);
832extern void journal_file_buffer(struct journal_head *, transaction_t *, int);
833extern void __journal_clean_data_list(transaction_t *transaction);
834
835/* Log buffer allocation */
836extern struct journal_head * journal_get_descriptor_buffer(journal_t *);
837int journal_next_log_block(journal_t *, unsigned long *);
838
839/* Commit management */
840extern void journal_commit_transaction(journal_t *);
841
842/* Checkpoint list management */
843int __journal_clean_checkpoint_list(journal_t *journal);
844void __journal_remove_checkpoint(struct journal_head *);
845void __journal_insert_checkpoint(struct journal_head *, transaction_t *);
846
847/* Buffer IO */
848extern int
849journal_write_metadata_buffer(transaction_t *transaction,
850 struct journal_head *jh_in,
851 struct journal_head **jh_out,
852 int blocknr);
853
854/* Transaction locking */
855extern void __wait_on_journal (journal_t *);
856
857/*
858 * Journal locking.
859 *
860 * We need to lock the journal during transaction state changes so that nobody
861 * ever tries to take a handle on the running transaction while we are in the
862 * middle of moving it to the commit phase. j_state_lock does this.
863 *
864 * Note that the locking is completely interrupt unsafe. We never touch
865 * journal structures from interrupts.
866 */
867
868static inline handle_t *journal_current_handle(void)
869{
870 return current->journal_info;
871}
872
873/* The journaling code user interface:
874 *
875 * Create and destroy handles
876 * Register buffer modifications against the current transaction.
877 */
878
879extern handle_t *journal_start(journal_t *, int nblocks);
880extern int journal_restart (handle_t *, int nblocks);
881extern int journal_extend (handle_t *, int nblocks);
882extern int journal_get_write_access(handle_t *, struct buffer_head *);
883extern int journal_get_create_access (handle_t *, struct buffer_head *);
884extern int journal_get_undo_access(handle_t *, struct buffer_head *);
885extern int journal_dirty_data (handle_t *, struct buffer_head *);
886extern int journal_dirty_metadata (handle_t *, struct buffer_head *);
887extern void journal_release_buffer (handle_t *, struct buffer_head *);
888extern int journal_forget (handle_t *, struct buffer_head *);
889extern void journal_sync_buffer (struct buffer_head *);
890extern int journal_invalidatepage(journal_t *,
891 struct page *, unsigned long);
892extern int journal_try_to_free_buffers(journal_t *, struct page *, int);
893extern int journal_stop(handle_t *);
894extern int journal_flush (journal_t *);
895extern void journal_lock_updates (journal_t *);
896extern void journal_unlock_updates (journal_t *);
897
898extern journal_t * journal_init_dev(struct block_device *bdev,
899 struct block_device *fs_dev,
900 int start, int len, int bsize);
901extern journal_t * journal_init_inode (struct inode *);
902extern int journal_update_format (journal_t *);
903extern int journal_check_used_features
904 (journal_t *, unsigned long, unsigned long, unsigned long);
905extern int journal_check_available_features
906 (journal_t *, unsigned long, unsigned long, unsigned long);
907extern int journal_set_features
908 (journal_t *, unsigned long, unsigned long, unsigned long);
909extern int journal_create (journal_t *);
910extern int journal_load (journal_t *journal);
911extern void journal_destroy (journal_t *);
912extern int journal_recover (journal_t *journal);
913extern int journal_wipe (journal_t *, int);
914extern int journal_skip_recovery (journal_t *);
915extern void journal_update_superblock (journal_t *, int);
916extern void __journal_abort_hard (journal_t *);
917extern void __journal_abort_soft (journal_t *, int);
918extern void journal_abort (journal_t *, int);
919extern int journal_errno (journal_t *);
920extern void journal_ack_err (journal_t *);
921extern int journal_clear_err (journal_t *);
922extern int journal_bmap(journal_t *, unsigned long, unsigned long *);
923extern int journal_force_commit(journal_t *);
924
925/*
926 * journal_head management
927 */
928struct journal_head *journal_add_journal_head(struct buffer_head *bh);
929struct journal_head *journal_grab_journal_head(struct buffer_head *bh);
930void journal_remove_journal_head(struct buffer_head *bh);
931void journal_put_journal_head(struct journal_head *jh);
932
933/*
934 * handle management
935 */
936extern kmem_cache_t *jbd_handle_cache;
937
938static inline handle_t *jbd_alloc_handle(unsigned int __nocast gfp_flags)
939{
940 return kmem_cache_alloc(jbd_handle_cache, gfp_flags);
941}
942
943static inline void jbd_free_handle(handle_t *handle)
944{
945 kmem_cache_free(jbd_handle_cache, handle);
946}
947
948/* Primary revoke support */
949#define JOURNAL_REVOKE_DEFAULT_HASH 256
950extern int journal_init_revoke(journal_t *, int);
951extern void journal_destroy_revoke_caches(void);
952extern int journal_init_revoke_caches(void);
953
954extern void journal_destroy_revoke(journal_t *);
955extern int journal_revoke (handle_t *,
956 unsigned long, struct buffer_head *);
957extern int journal_cancel_revoke(handle_t *, struct journal_head *);
958extern void journal_write_revoke_records(journal_t *, transaction_t *);
959
960/* Recovery revoke support */
961extern int journal_set_revoke(journal_t *, unsigned long, tid_t);
962extern int journal_test_revoke(journal_t *, unsigned long, tid_t);
963extern void journal_clear_revoke(journal_t *);
964extern void journal_brelse_array(struct buffer_head *b[], int n);
965extern void journal_switch_revoke_table(journal_t *journal);
966
967/*
968 * The log thread user interface:
969 *
970 * Request space in the current transaction, and force transaction commit
971 * transitions on demand.
972 */
973
974int __log_space_left(journal_t *); /* Called with journal locked */
975int log_start_commit(journal_t *journal, tid_t tid);
976int __log_start_commit(journal_t *journal, tid_t tid);
977int journal_start_commit(journal_t *journal, tid_t *tid);
978int journal_force_commit_nested(journal_t *journal);
979int log_wait_commit(journal_t *journal, tid_t tid);
980int log_do_checkpoint(journal_t *journal);
981
982void __log_wait_for_space(journal_t *journal);
983extern void __journal_drop_transaction(journal_t *, transaction_t *);
984extern int cleanup_journal_tail(journal_t *);
985
986/* Debugging code only: */
987
988#define jbd_ENOSYS() \
989do { \
990 printk (KERN_ERR "JBD unimplemented function %s\n", __FUNCTION__); \
991 current->state = TASK_UNINTERRUPTIBLE; \
992 schedule(); \
993} while (1)
994
995/*
996 * is_journal_abort
997 *
998 * Simple test wrapper function to test the JFS_ABORT state flag. This
999 * bit, when set, indicates that we have had a fatal error somewhere,
1000 * either inside the journaling layer or indicated to us by the client
1001 * (eg. ext3), and that we and should not commit any further
1002 * transactions.
1003 */
1004
1005static inline int is_journal_aborted(journal_t *journal)
1006{
1007 return journal->j_flags & JFS_ABORT;
1008}
1009
1010static inline int is_handle_aborted(handle_t *handle)
1011{
1012 if (handle->h_aborted)
1013 return 1;
1014 return is_journal_aborted(handle->h_transaction->t_journal);
1015}
1016
1017static inline void journal_abort_handle(handle_t *handle)
1018{
1019 handle->h_aborted = 1;
1020}
1021
1022#endif /* __KERNEL__ */
1023
1024/* Comparison functions for transaction IDs: perform comparisons using
1025 * modulo arithmetic so that they work over sequence number wraps. */
1026
1027static inline int tid_gt(tid_t x, tid_t y)
1028{
1029 int difference = (x - y);
1030 return (difference > 0);
1031}
1032
1033static inline int tid_geq(tid_t x, tid_t y)
1034{
1035 int difference = (x - y);
1036 return (difference >= 0);
1037}
1038
1039extern int journal_blocks_per_page(struct inode *inode);
1040
1041/*
1042 * Return the minimum number of blocks which must be free in the journal
1043 * before a new transaction may be started. Must be called under j_state_lock.
1044 */
1045static inline int jbd_space_needed(journal_t *journal)
1046{
1047 int nblocks = journal->j_max_transaction_buffers;
1048 if (journal->j_committing_transaction)
1049 nblocks += journal->j_committing_transaction->
1050 t_outstanding_credits;
1051 return nblocks;
1052}
1053
1054/*
1055 * Definitions which augment the buffer_head layer
1056 */
1057
1058/* journaling buffer types */
1059#define BJ_None 0 /* Not journaled */
1060#define BJ_SyncData 1 /* Normal data: flush before commit */
1061#define BJ_Metadata 2 /* Normal journaled metadata */
1062#define BJ_Forget 3 /* Buffer superseded by this transaction */
1063#define BJ_IO 4 /* Buffer is for temporary IO use */
1064#define BJ_Shadow 5 /* Buffer contents being shadowed to the log */
1065#define BJ_LogCtl 6 /* Buffer contains log descriptors */
1066#define BJ_Reserved 7 /* Buffer is reserved for access by journal */
1067#define BJ_Locked 8 /* Locked for I/O during commit */
1068#define BJ_Types 9
1069
1070extern int jbd_blocks_per_page(struct inode *inode);
1071
1072#ifdef __KERNEL__
1073
1074#define buffer_trace_init(bh) do {} while (0)
1075#define print_buffer_fields(bh) do {} while (0)
1076#define print_buffer_trace(bh) do {} while (0)
1077#define BUFFER_TRACE(bh, info) do {} while (0)
1078#define BUFFER_TRACE2(bh, bh2, info) do {} while (0)
1079#define JBUFFER_TRACE(jh, info) do {} while (0)
1080
1081#endif /* __KERNEL__ */
1082
1083#endif /* CONFIG_JBD || CONFIG_JBD_MODULE || !__KERNEL__ */
1084
1085/*
1086 * Compatibility no-ops which allow the kernel to compile without CONFIG_JBD
1087 * go here.
1088 */
1089
1090#if defined(__KERNEL__) && !(defined(CONFIG_JBD) || defined(CONFIG_JBD_MODULE))
1091
1092#define J_ASSERT(expr) do {} while (0)
1093#define J_ASSERT_BH(bh, expr) do {} while (0)
1094#define buffer_jbd(bh) 0
1095#define journal_buffer_journal_lru(bh) 0
1096
1097#endif /* defined(__KERNEL__) && !defined(CONFIG_JBD) */
1098#endif /* _LINUX_JBD_H */
diff --git a/include/linux/jffs.h b/include/linux/jffs.h
new file mode 100644
index 000000000000..92213215277f
--- /dev/null
+++ b/include/linux/jffs.h
@@ -0,0 +1,224 @@
1/*
2 * JFFS -- Journalling Flash File System, Linux implementation.
3 *
4 * Copyright (C) 1999, 2000 Axis Communications AB.
5 *
6 * Created by Finn Hakansson <finn@axis.com>.
7 *
8 * This is free software; you can redistribute it and/or modify it
9 * 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 * $Id: jffs.h,v 1.20 2001/09/18 21:33:37 dwmw2 Exp $
14 *
15 * Ported to Linux 2.3.x and MTD:
16 * Copyright (C) 2000 Alexander Larsson (alex@cendio.se), Cendio Systems AB
17 *
18 */
19
20#ifndef __LINUX_JFFS_H__
21#define __LINUX_JFFS_H__
22
23#include <linux/types.h>
24#include <linux/completion.h>
25
26#define JFFS_VERSION_STRING "1.0"
27
28/* This is a magic number that is used as an identification number for
29 this file system. It is written to the super_block structure. */
30#define JFFS_MAGIC_SB_BITMASK 0x07c0 /* 1984 */
31
32/* This is a magic number that every on-flash raw inode begins with. */
33#define JFFS_MAGIC_BITMASK 0x34383931 /* "1984" */
34
35/* These two bitmasks are the valid ones for the flash memories we have
36 for the moment. */
37#define JFFS_EMPTY_BITMASK 0xffffffff
38#define JFFS_DIRTY_BITMASK 0x00000000
39
40/* This is the inode number of the root node. */
41#define JFFS_MIN_INO 1
42
43/* How many slots in the file hash table should we have? */
44#define JFFS_HASH_SIZE 40
45
46/* Don't use more than 254 bytes as the maximum allowed length of a file's
47 name due to errors that could occur during the scanning of the flash
48 memory. In fact, a name length of 255 or 0xff, could be the result of
49 an uncompleted write. For instance, if a raw inode is written to the
50 flash memory and there is a power lossage just before the length of
51 the name is written, the length 255 would be interpreted as an illegal
52 value. */
53#define JFFS_MAX_NAME_LEN 254
54
55/* Commands for ioctl(). */
56#define JFFS_IOCTL_MAGIC 't'
57#define JFFS_PRINT_HASH _IO(JFFS_IOCTL_MAGIC, 90)
58#define JFFS_PRINT_TREE _IO(JFFS_IOCTL_MAGIC, 91)
59#define JFFS_GET_STATUS _IO(JFFS_IOCTL_MAGIC, 92)
60
61/* XXX: This is something that we should try to get rid of in the future. */
62#define JFFS_MODIFY_INODE 0x01
63#define JFFS_MODIFY_NAME 0x02
64#define JFFS_MODIFY_DATA 0x04
65#define JFFS_MODIFY_EXIST 0x08
66
67struct jffs_control;
68
69/* The JFFS raw inode structure: Used for storage on physical media. */
70/* Perhaps the uid, gid, atime, mtime and ctime members should have
71 more space due to future changes in the Linux kernel. Anyhow, since
72 a user of this filesystem probably have to fix a large number of
73 other things, we have decided to not be forward compatible. */
74struct jffs_raw_inode
75{
76 __u32 magic; /* A constant magic number. */
77 __u32 ino; /* Inode number. */
78 __u32 pino; /* Parent's inode number. */
79 __u32 version; /* Version number. */
80 __u32 mode; /* The file's type or mode. */
81 __u16 uid; /* The file's owner. */
82 __u16 gid; /* The file's group. */
83 __u32 atime; /* Last access time. */
84 __u32 mtime; /* Last modification time. */
85 __u32 ctime; /* Creation time. */
86 __u32 offset; /* Where to begin to write. */
87 __u32 dsize; /* Size of the node's data. */
88 __u32 rsize; /* How much are going to be replaced? */
89 __u8 nsize; /* Name length. */
90 __u8 nlink; /* Number of links. */
91 __u8 spare : 6; /* For future use. */
92 __u8 rename : 1; /* Rename to a name of an already existing file? */
93 __u8 deleted : 1; /* Has this file been deleted? */
94 __u8 accurate; /* The inode is obsolete if accurate == 0. */
95 __u32 dchksum; /* Checksum for the data. */
96 __u16 nchksum; /* Checksum for the name. */
97 __u16 chksum; /* Checksum for the raw inode. */
98};
99
100/* Define the offset of the accurate byte in struct jffs_raw_inode. */
101#define JFFS_RAW_INODE_ACCURATE_OFFSET (sizeof(struct jffs_raw_inode) \
102 - 2 * sizeof(__u32) - sizeof(__u8))
103
104/* Define the offset of the chksum member in struct jffs_raw_inode. */
105#define JFFS_RAW_INODE_CHKSUM_OFFSET (sizeof(struct jffs_raw_inode) \
106 - sizeof(__u16))
107
108/* Define the offset of the dchksum member in struct jffs_raw_inode. */
109#define JFFS_RAW_INODE_DCHKSUM_OFFSET (sizeof(struct jffs_raw_inode) \
110 - sizeof(__u16) - sizeof(__u16) \
111 - sizeof(__u32))
112
113
114/* The RAM representation of the node. The names of pointers to
115 jffs_nodes are very often just called `n' in the source code. */
116struct jffs_node
117{
118 __u32 ino; /* Inode number. */
119 __u32 version; /* Version number. */
120 __u32 data_offset; /* Logic location of the data to insert. */
121 __u32 data_size; /* The amount of data this node inserts. */
122 __u32 removed_size; /* The amount of data that this node removes. */
123 __u32 fm_offset; /* Physical location of the data in the actual
124 flash memory data chunk. */
125 __u8 name_size; /* Size of the name. */
126 struct jffs_fm *fm; /* Physical memory information. */
127 struct jffs_node *version_prev;
128 struct jffs_node *version_next;
129 struct jffs_node *range_prev;
130 struct jffs_node *range_next;
131};
132
133
134/* The RAM representation of a file (plain files, directories,
135 links, etc.). Pointers to jffs_files are normally named `f'
136 in the JFFS source code. */
137struct jffs_file
138{
139 __u32 ino; /* Inode number. */
140 __u32 pino; /* Parent's inode number. */
141 __u32 mode; /* file_type, mode */
142 __u16 uid; /* owner */
143 __u16 gid; /* group */
144 __u32 atime; /* Last access time. */
145 __u32 mtime; /* Last modification time. */
146 __u32 ctime; /* Creation time. */
147 __u8 nsize; /* Name length. */
148 __u8 nlink; /* Number of links. */
149 __u8 deleted; /* Has this file been deleted? */
150 char *name; /* The name of this file; NULL-terminated. */
151 __u32 size; /* The total size of the file's data. */
152 __u32 highest_version; /* The highest version number of this file. */
153 struct jffs_control *c;
154 struct jffs_file *parent; /* Reference to the parent directory. */
155 struct jffs_file *children; /* Always NULL for plain files. */
156 struct jffs_file *sibling_prev; /* Siblings in the same directory. */
157 struct jffs_file *sibling_next;
158 struct list_head hash; /* hash list. */
159 struct jffs_node *range_head; /* The final data. */
160 struct jffs_node *range_tail; /* The first data. */
161 struct jffs_node *version_head; /* The youngest node. */
162 struct jffs_node *version_tail; /* The oldest node. */
163};
164
165
166/* This is just a definition of a simple list used for keeping track of
167 files deleted due to a rename. This list is only used during the
168 mounting of the file system and only if there have been rename operations
169 earlier. */
170struct jffs_delete_list
171{
172 __u32 ino;
173 struct jffs_delete_list *next;
174};
175
176
177/* A struct for the overall file system control. Pointers to
178 jffs_control structs are named `c' in the source code. */
179struct jffs_control
180{
181 struct super_block *sb; /* Reference to the VFS super block. */
182 struct jffs_file *root; /* The root directory file. */
183 struct list_head *hash; /* Hash table for finding files by ino. */
184 struct jffs_fmcontrol *fmc; /* Flash memory control structure. */
185 __u32 hash_len; /* The size of the hash table. */
186 __u32 next_ino; /* Next inode number to use for new files. */
187 __u16 building_fs; /* Is the file system being built right now? */
188 struct jffs_delete_list *delete_list; /* Track deleted files. */
189 pid_t thread_pid; /* GC thread's PID */
190 struct task_struct *gc_task; /* GC task struct */
191 struct completion gc_thread_comp; /* GC thread exit mutex */
192 __u32 gc_minfree_threshold; /* GC trigger thresholds */
193 __u32 gc_maxdirty_threshold;
194};
195
196
197/* Used to inform about flash status. */
198struct jffs_flash_status
199{
200 __u32 size;
201 __u32 used;
202 __u32 dirty;
203 __u32 begin;
204 __u32 end;
205};
206
207/* This stuff could be used for finding memory leaks. */
208#define JFFS_MEMORY_DEBUG 0
209
210extern long no_jffs_node;
211#if defined(JFFS_MEMORY_DEBUG) && JFFS_MEMORY_DEBUG
212extern long no_jffs_control;
213extern long no_jffs_raw_inode;
214extern long no_jffs_node_ref;
215extern long no_jffs_fm;
216extern long no_jffs_fmcontrol;
217extern long no_hash;
218extern long no_name;
219#define DJM(x) x
220#else
221#define DJM(x)
222#endif
223
224#endif /* __LINUX_JFFS_H__ */
diff --git a/include/linux/jffs2.h b/include/linux/jffs2.h
new file mode 100644
index 000000000000..419fc953ac16
--- /dev/null
+++ b/include/linux/jffs2.h
@@ -0,0 +1,157 @@
1/*
2 * JFFS2 -- Journalling Flash File System, Version 2.
3 *
4 * Copyright (C) 2001-2003 Red Hat, Inc.
5 *
6 * Created by David Woodhouse <dwmw2@infradead.org>
7 *
8 * For licensing information, see the file 'LICENCE' in the
9 * jffs2 directory.
10 *
11 * $Id: jffs2.h,v 1.34 2004/11/16 20:36:14 dwmw2 Exp $
12 *
13 */
14
15#ifndef __LINUX_JFFS2_H__
16#define __LINUX_JFFS2_H__
17
18/* You must include something which defines the C99 uintXX_t types.
19 We don't do it from here because this file is used in too many
20 different environments. */
21
22#define JFFS2_SUPER_MAGIC 0x72b6
23
24/* Values we may expect to find in the 'magic' field */
25#define JFFS2_OLD_MAGIC_BITMASK 0x1984
26#define JFFS2_MAGIC_BITMASK 0x1985
27#define KSAMTIB_CIGAM_2SFFJ 0x8519 /* For detecting wrong-endian fs */
28#define JFFS2_EMPTY_BITMASK 0xffff
29#define JFFS2_DIRTY_BITMASK 0x0000
30
31/* We only allow a single char for length, and 0xFF is empty flash so
32 we don't want it confused with a real length. Hence max 254.
33*/
34#define JFFS2_MAX_NAME_LEN 254
35
36/* How small can we sensibly write nodes? */
37#define JFFS2_MIN_DATA_LEN 128
38
39#define JFFS2_COMPR_NONE 0x00
40#define JFFS2_COMPR_ZERO 0x01
41#define JFFS2_COMPR_RTIME 0x02
42#define JFFS2_COMPR_RUBINMIPS 0x03
43#define JFFS2_COMPR_COPY 0x04
44#define JFFS2_COMPR_DYNRUBIN 0x05
45#define JFFS2_COMPR_ZLIB 0x06
46#define JFFS2_COMPR_LZO 0x07
47#define JFFS2_COMPR_LZARI 0x08
48/* Compatibility flags. */
49#define JFFS2_COMPAT_MASK 0xc000 /* What do to if an unknown nodetype is found */
50#define JFFS2_NODE_ACCURATE 0x2000
51/* INCOMPAT: Fail to mount the filesystem */
52#define JFFS2_FEATURE_INCOMPAT 0xc000
53/* ROCOMPAT: Mount read-only */
54#define JFFS2_FEATURE_ROCOMPAT 0x8000
55/* RWCOMPAT_COPY: Mount read/write, and copy the node when it's GC'd */
56#define JFFS2_FEATURE_RWCOMPAT_COPY 0x4000
57/* RWCOMPAT_DELETE: Mount read/write, and delete the node when it's GC'd */
58#define JFFS2_FEATURE_RWCOMPAT_DELETE 0x0000
59
60#define JFFS2_NODETYPE_DIRENT (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 1)
61#define JFFS2_NODETYPE_INODE (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 2)
62#define JFFS2_NODETYPE_CLEANMARKER (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 3)
63#define JFFS2_NODETYPE_PADDING (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 4)
64
65// Maybe later...
66//#define JFFS2_NODETYPE_CHECKPOINT (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 3)
67//#define JFFS2_NODETYPE_OPTIONS (JFFS2_FEATURE_RWCOMPAT_COPY | JFFS2_NODE_ACCURATE | 4)
68
69
70#define JFFS2_INO_FLAG_PREREAD 1 /* Do read_inode() for this one at
71 mount time, don't wait for it to
72 happen later */
73#define JFFS2_INO_FLAG_USERCOMPR 2 /* User has requested a specific
74 compression type */
75
76
77/* These can go once we've made sure we've caught all uses without
78 byteswapping */
79
80typedef struct {
81 uint32_t v32;
82} __attribute__((packed)) jint32_t;
83
84typedef struct {
85 uint32_t m;
86} __attribute__((packed)) jmode_t;
87
88typedef struct {
89 uint16_t v16;
90} __attribute__((packed)) jint16_t;
91
92struct jffs2_unknown_node
93{
94 /* All start like this */
95 jint16_t magic;
96 jint16_t nodetype;
97 jint32_t totlen; /* So we can skip over nodes we don't grok */
98 jint32_t hdr_crc;
99} __attribute__((packed));
100
101struct jffs2_raw_dirent
102{
103 jint16_t magic;
104 jint16_t nodetype; /* == JFFS_NODETYPE_DIRENT */
105 jint32_t totlen;
106 jint32_t hdr_crc;
107 jint32_t pino;
108 jint32_t version;
109 jint32_t ino; /* == zero for unlink */
110 jint32_t mctime;
111 uint8_t nsize;
112 uint8_t type;
113 uint8_t unused[2];
114 jint32_t node_crc;
115 jint32_t name_crc;
116 uint8_t name[0];
117} __attribute__((packed));
118
119/* The JFFS2 raw inode structure: Used for storage on physical media. */
120/* The uid, gid, atime, mtime and ctime members could be longer, but
121 are left like this for space efficiency. If and when people decide
122 they really need them extended, it's simple enough to add support for
123 a new type of raw node.
124*/
125struct jffs2_raw_inode
126{
127 jint16_t magic; /* A constant magic number. */
128 jint16_t nodetype; /* == JFFS_NODETYPE_INODE */
129 jint32_t totlen; /* Total length of this node (inc data, etc.) */
130 jint32_t hdr_crc;
131 jint32_t ino; /* Inode number. */
132 jint32_t version; /* Version number. */
133 jmode_t mode; /* The file's type or mode. */
134 jint16_t uid; /* The file's owner. */
135 jint16_t gid; /* The file's group. */
136 jint32_t isize; /* Total resultant size of this inode (used for truncations) */
137 jint32_t atime; /* Last access time. */
138 jint32_t mtime; /* Last modification time. */
139 jint32_t ctime; /* Change time. */
140 jint32_t offset; /* Where to begin to write. */
141 jint32_t csize; /* (Compressed) data size */
142 jint32_t dsize; /* Size of the node's data. (after decompression) */
143 uint8_t compr; /* Compression algorithm used */
144 uint8_t usercompr; /* Compression algorithm requested by the user */
145 jint16_t flags; /* See JFFS2_INO_FLAG_* */
146 jint32_t data_crc; /* CRC for the (compressed) data. */
147 jint32_t node_crc; /* CRC for the raw inode (excluding data) */
148 uint8_t data[0];
149} __attribute__((packed));
150
151union jffs2_node_union {
152 struct jffs2_raw_inode i;
153 struct jffs2_raw_dirent d;
154 struct jffs2_unknown_node u;
155};
156
157#endif /* __LINUX_JFFS2_H__ */
diff --git a/include/linux/jffs2_fs_i.h b/include/linux/jffs2_fs_i.h
new file mode 100644
index 000000000000..6dbb1cce6646
--- /dev/null
+++ b/include/linux/jffs2_fs_i.h
@@ -0,0 +1,47 @@
1/* $Id: jffs2_fs_i.h,v 1.17 2004/11/11 23:51:27 dwmw2 Exp $ */
2
3#ifndef _JFFS2_FS_I
4#define _JFFS2_FS_I
5
6#include <linux/version.h>
7#include <linux/rbtree.h>
8#include <asm/semaphore.h>
9
10struct jffs2_inode_info {
11 /* We need an internal semaphore similar to inode->i_sem.
12 Unfortunately, we can't used the existing one, because
13 either the GC would deadlock, or we'd have to release it
14 before letting GC proceed. Or we'd have to put ugliness
15 into the GC code so it didn't attempt to obtain the i_sem
16 for the inode(s) which are already locked */
17 struct semaphore sem;
18
19 /* The highest (datanode) version number used for this ino */
20 uint32_t highest_version;
21
22 /* List of data fragments which make up the file */
23 struct rb_root fragtree;
24
25 /* There may be one datanode which isn't referenced by any of the
26 above fragments, if it contains a metadata update but no actual
27 data - or if this is a directory inode */
28 /* This also holds the _only_ dnode for symlinks/device nodes,
29 etc. */
30 struct jffs2_full_dnode *metadata;
31
32 /* Directory entries */
33 struct jffs2_full_dirent *dents;
34
35 /* Some stuff we just have to keep in-core at all times, for each inode. */
36 struct jffs2_inode_cache *inocache;
37
38 uint16_t flags;
39 uint8_t usercompr;
40#if !defined (__ECOS)
41#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,2)
42 struct inode vfs_inode;
43#endif
44#endif
45};
46
47#endif /* _JFFS2_FS_I */
diff --git a/include/linux/jffs2_fs_sb.h b/include/linux/jffs2_fs_sb.h
new file mode 100644
index 000000000000..4afc8d8c2e9e
--- /dev/null
+++ b/include/linux/jffs2_fs_sb.h
@@ -0,0 +1,118 @@
1/* $Id: jffs2_fs_sb.h,v 1.48 2004/11/20 10:41:12 dwmw2 Exp $ */
2
3#ifndef _JFFS2_FS_SB
4#define _JFFS2_FS_SB
5
6#include <linux/types.h>
7#include <linux/spinlock.h>
8#include <linux/workqueue.h>
9#include <linux/completion.h>
10#include <asm/semaphore.h>
11#include <linux/timer.h>
12#include <linux/wait.h>
13#include <linux/list.h>
14#include <linux/rwsem.h>
15
16#define JFFS2_SB_FLAG_RO 1
17#define JFFS2_SB_FLAG_MOUNTING 2
18
19struct jffs2_inodirty;
20
21/* A struct for the overall file system control. Pointers to
22 jffs2_sb_info structs are named `c' in the source code.
23 Nee jffs_control
24*/
25struct jffs2_sb_info {
26 struct mtd_info *mtd;
27
28 uint32_t highest_ino;
29 uint32_t checked_ino;
30
31 unsigned int flags;
32
33 struct task_struct *gc_task; /* GC task struct */
34 struct semaphore gc_thread_start; /* GC thread start mutex */
35 struct completion gc_thread_exit; /* GC thread exit completion port */
36
37 struct semaphore alloc_sem; /* Used to protect all the following
38 fields, and also to protect against
39 out-of-order writing of nodes. And GC. */
40 uint32_t cleanmarker_size; /* Size of an _inline_ CLEANMARKER
41 (i.e. zero for OOB CLEANMARKER */
42
43 uint32_t flash_size;
44 uint32_t used_size;
45 uint32_t dirty_size;
46 uint32_t wasted_size;
47 uint32_t free_size;
48 uint32_t erasing_size;
49 uint32_t bad_size;
50 uint32_t sector_size;
51 uint32_t unchecked_size;
52
53 uint32_t nr_free_blocks;
54 uint32_t nr_erasing_blocks;
55
56 /* Number of free blocks there must be before we... */
57 uint8_t resv_blocks_write; /* ... allow a normal filesystem write */
58 uint8_t resv_blocks_deletion; /* ... allow a normal filesystem deletion */
59 uint8_t resv_blocks_gctrigger; /* ... wake up the GC thread */
60 uint8_t resv_blocks_gcbad; /* ... pick a block from the bad_list to GC */
61 uint8_t resv_blocks_gcmerge; /* ... merge pages when garbage collecting */
62
63 uint32_t nospc_dirty_size;
64
65 uint32_t nr_blocks;
66 struct jffs2_eraseblock *blocks; /* The whole array of blocks. Used for getting blocks
67 * from the offset (blocks[ofs / sector_size]) */
68 struct jffs2_eraseblock *nextblock; /* The block we're currently filling */
69
70 struct jffs2_eraseblock *gcblock; /* The block we're currently garbage-collecting */
71
72 struct list_head clean_list; /* Blocks 100% full of clean data */
73 struct list_head very_dirty_list; /* Blocks with lots of dirty space */
74 struct list_head dirty_list; /* Blocks with some dirty space */
75 struct list_head erasable_list; /* Blocks which are completely dirty, and need erasing */
76 struct list_head erasable_pending_wbuf_list; /* Blocks which need erasing but only after the current wbuf is flushed */
77 struct list_head erasing_list; /* Blocks which are currently erasing */
78 struct list_head erase_pending_list; /* Blocks which need erasing now */
79 struct list_head erase_complete_list; /* Blocks which are erased and need the clean marker written to them */
80 struct list_head free_list; /* Blocks which are free and ready to be used */
81 struct list_head bad_list; /* Bad blocks. */
82 struct list_head bad_used_list; /* Bad blocks with valid data in. */
83
84 spinlock_t erase_completion_lock; /* Protect free_list and erasing_list
85 against erase completion handler */
86 wait_queue_head_t erase_wait; /* For waiting for erases to complete */
87
88 wait_queue_head_t inocache_wq;
89 struct jffs2_inode_cache **inocache_list;
90 spinlock_t inocache_lock;
91
92 /* Sem to allow jffs2_garbage_collect_deletion_dirent to
93 drop the erase_completion_lock while it's holding a pointer
94 to an obsoleted node. I don't like this. Alternatives welcomed. */
95 struct semaphore erase_free_sem;
96
97#if defined CONFIG_JFFS2_FS_NAND || defined CONFIG_JFFS2_FS_NOR_ECC
98 /* Write-behind buffer for NAND flash */
99 unsigned char *wbuf;
100 uint32_t wbuf_ofs;
101 uint32_t wbuf_len;
102 uint32_t wbuf_pagesize;
103 struct jffs2_inodirty *wbuf_inodes;
104
105 struct rw_semaphore wbuf_sem; /* Protects the write buffer */
106
107 /* Information about out-of-band area usage... */
108 struct nand_oobinfo *oobinfo;
109 uint32_t badblock_pos;
110 uint32_t fsdata_pos;
111 uint32_t fsdata_len;
112#endif
113
114 /* OS-private pointer for getting back to master superblock info */
115 void *os_priv;
116};
117
118#endif /* _JFFS2_FB_SB */
diff --git a/include/linux/jhash.h b/include/linux/jhash.h
new file mode 100644
index 000000000000..82c7ae412eec
--- /dev/null
+++ b/include/linux/jhash.h
@@ -0,0 +1,143 @@
1#ifndef _LINUX_JHASH_H
2#define _LINUX_JHASH_H
3
4/* jhash.h: Jenkins hash support.
5 *
6 * Copyright (C) 1996 Bob Jenkins (bob_jenkins@burtleburtle.net)
7 *
8 * http://burtleburtle.net/bob/hash/
9 *
10 * These are the credits from Bob's sources:
11 *
12 * lookup2.c, by Bob Jenkins, December 1996, Public Domain.
13 * hash(), hash2(), hash3, and mix() are externally useful functions.
14 * Routines to test the hash are included if SELF_TEST is defined.
15 * You can use this free for any purpose. It has no warranty.
16 *
17 * Copyright (C) 2003 David S. Miller (davem@redhat.com)
18 *
19 * I've modified Bob's hash to be useful in the Linux kernel, and
20 * any bugs present are surely my fault. -DaveM
21 */
22
23/* NOTE: Arguments are modified. */
24#define __jhash_mix(a, b, c) \
25{ \
26 a -= b; a -= c; a ^= (c>>13); \
27 b -= c; b -= a; b ^= (a<<8); \
28 c -= a; c -= b; c ^= (b>>13); \
29 a -= b; a -= c; a ^= (c>>12); \
30 b -= c; b -= a; b ^= (a<<16); \
31 c -= a; c -= b; c ^= (b>>5); \
32 a -= b; a -= c; a ^= (c>>3); \
33 b -= c; b -= a; b ^= (a<<10); \
34 c -= a; c -= b; c ^= (b>>15); \
35}
36
37/* The golden ration: an arbitrary value */
38#define JHASH_GOLDEN_RATIO 0x9e3779b9
39
40/* The most generic version, hashes an arbitrary sequence
41 * of bytes. No alignment or length assumptions are made about
42 * the input key.
43 */
44static inline u32 jhash(const void *key, u32 length, u32 initval)
45{
46 u32 a, b, c, len;
47 const u8 *k = key;
48
49 len = length;
50 a = b = JHASH_GOLDEN_RATIO;
51 c = initval;
52
53 while (len >= 12) {
54 a += (k[0] +((u32)k[1]<<8) +((u32)k[2]<<16) +((u32)k[3]<<24));
55 b += (k[4] +((u32)k[5]<<8) +((u32)k[6]<<16) +((u32)k[7]<<24));
56 c += (k[8] +((u32)k[9]<<8) +((u32)k[10]<<16)+((u32)k[11]<<24));
57
58 __jhash_mix(a,b,c);
59
60 k += 12;
61 len -= 12;
62 }
63
64 c += length;
65 switch (len) {
66 case 11: c += ((u32)k[10]<<24);
67 case 10: c += ((u32)k[9]<<16);
68 case 9 : c += ((u32)k[8]<<8);
69 case 8 : b += ((u32)k[7]<<24);
70 case 7 : b += ((u32)k[6]<<16);
71 case 6 : b += ((u32)k[5]<<8);
72 case 5 : b += k[4];
73 case 4 : a += ((u32)k[3]<<24);
74 case 3 : a += ((u32)k[2]<<16);
75 case 2 : a += ((u32)k[1]<<8);
76 case 1 : a += k[0];
77 };
78
79 __jhash_mix(a,b,c);
80
81 return c;
82}
83
84/* A special optimized version that handles 1 or more of u32s.
85 * The length parameter here is the number of u32s in the key.
86 */
87static inline u32 jhash2(u32 *k, u32 length, u32 initval)
88{
89 u32 a, b, c, len;
90
91 a = b = JHASH_GOLDEN_RATIO;
92 c = initval;
93 len = length;
94
95 while (len >= 3) {
96 a += k[0];
97 b += k[1];
98 c += k[2];
99 __jhash_mix(a, b, c);
100 k += 3; len -= 3;
101 }
102
103 c += length * 4;
104
105 switch (len) {
106 case 2 : b += k[1];
107 case 1 : a += k[0];
108 };
109
110 __jhash_mix(a,b,c);
111
112 return c;
113}
114
115
116/* A special ultra-optimized versions that knows they are hashing exactly
117 * 3, 2 or 1 word(s).
118 *
119 * NOTE: In partilar the "c += length; __jhash_mix(a,b,c);" normally
120 * done at the end is not done here.
121 */
122static inline u32 jhash_3words(u32 a, u32 b, u32 c, u32 initval)
123{
124 a += JHASH_GOLDEN_RATIO;
125 b += JHASH_GOLDEN_RATIO;
126 c += initval;
127
128 __jhash_mix(a, b, c);
129
130 return c;
131}
132
133static inline u32 jhash_2words(u32 a, u32 b, u32 initval)
134{
135 return jhash_3words(a, b, 0, initval);
136}
137
138static inline u32 jhash_1word(u32 a, u32 initval)
139{
140 return jhash_3words(a, 0, 0, initval);
141}
142
143#endif /* _LINUX_JHASH_H */
diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
new file mode 100644
index 000000000000..d7a2555a886c
--- /dev/null
+++ b/include/linux/jiffies.h
@@ -0,0 +1,450 @@
1#ifndef _LINUX_JIFFIES_H
2#define _LINUX_JIFFIES_H
3
4#include <linux/kernel.h>
5#include <linux/types.h>
6#include <linux/time.h>
7#include <linux/timex.h>
8#include <asm/param.h> /* for HZ */
9#include <asm/div64.h>
10
11#ifndef div_long_long_rem
12#define div_long_long_rem(dividend,divisor,remainder) \
13({ \
14 u64 result = dividend; \
15 *remainder = do_div(result,divisor); \
16 result; \
17})
18#endif
19
20/*
21 * The following defines establish the engineering parameters of the PLL
22 * model. The HZ variable establishes the timer interrupt frequency, 100 Hz
23 * for the SunOS kernel, 256 Hz for the Ultrix kernel and 1024 Hz for the
24 * OSF/1 kernel. The SHIFT_HZ define expresses the same value as the
25 * nearest power of two in order to avoid hardware multiply operations.
26 */
27#if HZ >= 12 && HZ < 24
28# define SHIFT_HZ 4
29#elif HZ >= 24 && HZ < 48
30# define SHIFT_HZ 5
31#elif HZ >= 48 && HZ < 96
32# define SHIFT_HZ 6
33#elif HZ >= 96 && HZ < 192
34# define SHIFT_HZ 7
35#elif HZ >= 192 && HZ < 384
36# define SHIFT_HZ 8
37#elif HZ >= 384 && HZ < 768
38# define SHIFT_HZ 9
39#elif HZ >= 768 && HZ < 1536
40# define SHIFT_HZ 10
41#else
42# error You lose.
43#endif
44
45/* LATCH is used in the interval timer and ftape setup. */
46#define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */
47
48/* Suppose we want to devide two numbers NOM and DEN: NOM/DEN, the we can
49 * improve accuracy by shifting LSH bits, hence calculating:
50 * (NOM << LSH) / DEN
51 * This however means trouble for large NOM, because (NOM << LSH) may no
52 * longer fit in 32 bits. The following way of calculating this gives us
53 * some slack, under the following conditions:
54 * - (NOM / DEN) fits in (32 - LSH) bits.
55 * - (NOM % DEN) fits in (32 - LSH) bits.
56 */
57#define SH_DIV(NOM,DEN,LSH) ( ((NOM / DEN) << LSH) \
58 + (((NOM % DEN) << LSH) + DEN / 2) / DEN)
59
60/* HZ is the requested value. ACTHZ is actual HZ ("<< 8" is for accuracy) */
61#define ACTHZ (SH_DIV (CLOCK_TICK_RATE, LATCH, 8))
62
63/* TICK_NSEC is the time between ticks in nsec assuming real ACTHZ */
64#define TICK_NSEC (SH_DIV (1000000UL * 1000, ACTHZ, 8))
65
66/* TICK_USEC is the time between ticks in usec assuming fake USER_HZ */
67#define TICK_USEC ((1000000UL + USER_HZ/2) / USER_HZ)
68
69/* TICK_USEC_TO_NSEC is the time between ticks in nsec assuming real ACTHZ and */
70/* a value TUSEC for TICK_USEC (can be set bij adjtimex) */
71#define TICK_USEC_TO_NSEC(TUSEC) (SH_DIV (TUSEC * USER_HZ * 1000, ACTHZ, 8))
72
73/* some arch's have a small-data section that can be accessed register-relative
74 * but that can only take up to, say, 4-byte variables. jiffies being part of
75 * an 8-byte variable may not be correctly accessed unless we force the issue
76 */
77#define __jiffy_data __attribute__((section(".data")))
78
79/*
80 * The 64-bit value is not volatile - you MUST NOT read it
81 * without sampling the sequence number in xtime_lock.
82 * get_jiffies_64() will do this for you as appropriate.
83 */
84extern u64 __jiffy_data jiffies_64;
85extern unsigned long volatile __jiffy_data jiffies;
86
87#if (BITS_PER_LONG < 64)
88u64 get_jiffies_64(void);
89#else
90static inline u64 get_jiffies_64(void)
91{
92 return (u64)jiffies;
93}
94#endif
95
96/*
97 * These inlines deal with timer wrapping correctly. You are
98 * strongly encouraged to use them
99 * 1. Because people otherwise forget
100 * 2. Because if the timer wrap changes in future you won't have to
101 * alter your driver code.
102 *
103 * time_after(a,b) returns true if the time a is after time b.
104 *
105 * Do this with "<0" and ">=0" to only test the sign of the result. A
106 * good compiler would generate better code (and a really good compiler
107 * wouldn't care). Gcc is currently neither.
108 */
109#define time_after(a,b) \
110 (typecheck(unsigned long, a) && \
111 typecheck(unsigned long, b) && \
112 ((long)(b) - (long)(a) < 0))
113#define time_before(a,b) time_after(b,a)
114
115#define time_after_eq(a,b) \
116 (typecheck(unsigned long, a) && \
117 typecheck(unsigned long, b) && \
118 ((long)(a) - (long)(b) >= 0))
119#define time_before_eq(a,b) time_after_eq(b,a)
120
121/*
122 * Have the 32 bit jiffies value wrap 5 minutes after boot
123 * so jiffies wrap bugs show up earlier.
124 */
125#define INITIAL_JIFFIES ((unsigned long)(unsigned int) (-300*HZ))
126
127/*
128 * Change timeval to jiffies, trying to avoid the
129 * most obvious overflows..
130 *
131 * And some not so obvious.
132 *
133 * Note that we don't want to return MAX_LONG, because
134 * for various timeout reasons we often end up having
135 * to wait "jiffies+1" in order to guarantee that we wait
136 * at _least_ "jiffies" - so "jiffies+1" had better still
137 * be positive.
138 */
139#define MAX_JIFFY_OFFSET ((~0UL >> 1)-1)
140
141/*
142 * We want to do realistic conversions of time so we need to use the same
143 * values the update wall clock code uses as the jiffies size. This value
144 * is: TICK_NSEC (which is defined in timex.h). This
145 * is a constant and is in nanoseconds. We will used scaled math
146 * with a set of scales defined here as SEC_JIFFIE_SC, USEC_JIFFIE_SC and
147 * NSEC_JIFFIE_SC. Note that these defines contain nothing but
148 * constants and so are computed at compile time. SHIFT_HZ (computed in
149 * timex.h) adjusts the scaling for different HZ values.
150
151 * Scaled math??? What is that?
152 *
153 * Scaled math is a way to do integer math on values that would,
154 * otherwise, either overflow, underflow, or cause undesired div
155 * instructions to appear in the execution path. In short, we "scale"
156 * up the operands so they take more bits (more precision, less
157 * underflow), do the desired operation and then "scale" the result back
158 * by the same amount. If we do the scaling by shifting we avoid the
159 * costly mpy and the dastardly div instructions.
160
161 * Suppose, for example, we want to convert from seconds to jiffies
162 * where jiffies is defined in nanoseconds as NSEC_PER_JIFFIE. The
163 * simple math is: jiff = (sec * NSEC_PER_SEC) / NSEC_PER_JIFFIE; We
164 * observe that (NSEC_PER_SEC / NSEC_PER_JIFFIE) is a constant which we
165 * might calculate at compile time, however, the result will only have
166 * about 3-4 bits of precision (less for smaller values of HZ).
167 *
168 * So, we scale as follows:
169 * jiff = (sec) * (NSEC_PER_SEC / NSEC_PER_JIFFIE);
170 * jiff = ((sec) * ((NSEC_PER_SEC * SCALE)/ NSEC_PER_JIFFIE)) / SCALE;
171 * Then we make SCALE a power of two so:
172 * jiff = ((sec) * ((NSEC_PER_SEC << SCALE)/ NSEC_PER_JIFFIE)) >> SCALE;
173 * Now we define:
174 * #define SEC_CONV = ((NSEC_PER_SEC << SCALE)/ NSEC_PER_JIFFIE))
175 * jiff = (sec * SEC_CONV) >> SCALE;
176 *
177 * Often the math we use will expand beyond 32-bits so we tell C how to
178 * do this and pass the 64-bit result of the mpy through the ">> SCALE"
179 * which should take the result back to 32-bits. We want this expansion
180 * to capture as much precision as possible. At the same time we don't
181 * want to overflow so we pick the SCALE to avoid this. In this file,
182 * that means using a different scale for each range of HZ values (as
183 * defined in timex.h).
184 *
185 * For those who want to know, gcc will give a 64-bit result from a "*"
186 * operator if the result is a long long AND at least one of the
187 * operands is cast to long long (usually just prior to the "*" so as
188 * not to confuse it into thinking it really has a 64-bit operand,
189 * which, buy the way, it can do, but it take more code and at least 2
190 * mpys).
191
192 * We also need to be aware that one second in nanoseconds is only a
193 * couple of bits away from overflowing a 32-bit word, so we MUST use
194 * 64-bits to get the full range time in nanoseconds.
195
196 */
197
198/*
199 * Here are the scales we will use. One for seconds, nanoseconds and
200 * microseconds.
201 *
202 * Within the limits of cpp we do a rough cut at the SEC_JIFFIE_SC and
203 * check if the sign bit is set. If not, we bump the shift count by 1.
204 * (Gets an extra bit of precision where we can use it.)
205 * We know it is set for HZ = 1024 and HZ = 100 not for 1000.
206 * Haven't tested others.
207
208 * Limits of cpp (for #if expressions) only long (no long long), but
209 * then we only need the most signicant bit.
210 */
211
212#define SEC_JIFFIE_SC (31 - SHIFT_HZ)
213#if !((((NSEC_PER_SEC << 2) / TICK_NSEC) << (SEC_JIFFIE_SC - 2)) & 0x80000000)
214#undef SEC_JIFFIE_SC
215#define SEC_JIFFIE_SC (32 - SHIFT_HZ)
216#endif
217#define NSEC_JIFFIE_SC (SEC_JIFFIE_SC + 29)
218#define USEC_JIFFIE_SC (SEC_JIFFIE_SC + 19)
219#define SEC_CONVERSION ((unsigned long)((((u64)NSEC_PER_SEC << SEC_JIFFIE_SC) +\
220 TICK_NSEC -1) / (u64)TICK_NSEC))
221
222#define NSEC_CONVERSION ((unsigned long)((((u64)1 << NSEC_JIFFIE_SC) +\
223 TICK_NSEC -1) / (u64)TICK_NSEC))
224#define USEC_CONVERSION \
225 ((unsigned long)((((u64)NSEC_PER_USEC << USEC_JIFFIE_SC) +\
226 TICK_NSEC -1) / (u64)TICK_NSEC))
227/*
228 * USEC_ROUND is used in the timeval to jiffie conversion. See there
229 * for more details. It is the scaled resolution rounding value. Note
230 * that it is a 64-bit value. Since, when it is applied, we are already
231 * in jiffies (albit scaled), it is nothing but the bits we will shift
232 * off.
233 */
234#define USEC_ROUND (u64)(((u64)1 << USEC_JIFFIE_SC) - 1)
235/*
236 * The maximum jiffie value is (MAX_INT >> 1). Here we translate that
237 * into seconds. The 64-bit case will overflow if we are not careful,
238 * so use the messy SH_DIV macro to do it. Still all constants.
239 */
240#if BITS_PER_LONG < 64
241# define MAX_SEC_IN_JIFFIES \
242 (long)((u64)((u64)MAX_JIFFY_OFFSET * TICK_NSEC) / NSEC_PER_SEC)
243#else /* take care of overflow on 64 bits machines */
244# define MAX_SEC_IN_JIFFIES \
245 (SH_DIV((MAX_JIFFY_OFFSET >> SEC_JIFFIE_SC) * TICK_NSEC, NSEC_PER_SEC, 1) - 1)
246
247#endif
248
249/*
250 * Convert jiffies to milliseconds and back.
251 *
252 * Avoid unnecessary multiplications/divisions in the
253 * two most common HZ cases:
254 */
255static inline unsigned int jiffies_to_msecs(const unsigned long j)
256{
257#if HZ <= 1000 && !(1000 % HZ)
258 return (1000 / HZ) * j;
259#elif HZ > 1000 && !(HZ % 1000)
260 return (j + (HZ / 1000) - 1)/(HZ / 1000);
261#else
262 return (j * 1000) / HZ;
263#endif
264}
265
266static inline unsigned int jiffies_to_usecs(const unsigned long j)
267{
268#if HZ <= 1000000 && !(1000000 % HZ)
269 return (1000000 / HZ) * j;
270#elif HZ > 1000000 && !(HZ % 1000000)
271 return (j + (HZ / 1000000) - 1)/(HZ / 1000000);
272#else
273 return (j * 1000000) / HZ;
274#endif
275}
276
277static inline unsigned long msecs_to_jiffies(const unsigned int m)
278{
279 if (m > jiffies_to_msecs(MAX_JIFFY_OFFSET))
280 return MAX_JIFFY_OFFSET;
281#if HZ <= 1000 && !(1000 % HZ)
282 return (m + (1000 / HZ) - 1) / (1000 / HZ);
283#elif HZ > 1000 && !(HZ % 1000)
284 return m * (HZ / 1000);
285#else
286 return (m * HZ + 999) / 1000;
287#endif
288}
289
290static inline unsigned long usecs_to_jiffies(const unsigned int u)
291{
292 if (u > jiffies_to_usecs(MAX_JIFFY_OFFSET))
293 return MAX_JIFFY_OFFSET;
294#if HZ <= 1000000 && !(1000000 % HZ)
295 return (u + (1000000 / HZ) - 1) / (1000000 / HZ);
296#elif HZ > 1000000 && !(HZ % 1000000)
297 return u * (HZ / 1000000);
298#else
299 return (u * HZ + 999999) / 1000000;
300#endif
301}
302
303/*
304 * The TICK_NSEC - 1 rounds up the value to the next resolution. Note
305 * that a remainder subtract here would not do the right thing as the
306 * resolution values don't fall on second boundries. I.e. the line:
307 * nsec -= nsec % TICK_NSEC; is NOT a correct resolution rounding.
308 *
309 * Rather, we just shift the bits off the right.
310 *
311 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
312 * value to a scaled second value.
313 */
314static __inline__ unsigned long
315timespec_to_jiffies(const struct timespec *value)
316{
317 unsigned long sec = value->tv_sec;
318 long nsec = value->tv_nsec + TICK_NSEC - 1;
319
320 if (sec >= MAX_SEC_IN_JIFFIES){
321 sec = MAX_SEC_IN_JIFFIES;
322 nsec = 0;
323 }
324 return (((u64)sec * SEC_CONVERSION) +
325 (((u64)nsec * NSEC_CONVERSION) >>
326 (NSEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC;
327
328}
329
330static __inline__ void
331jiffies_to_timespec(const unsigned long jiffies, struct timespec *value)
332{
333 /*
334 * Convert jiffies to nanoseconds and separate with
335 * one divide.
336 */
337 u64 nsec = (u64)jiffies * TICK_NSEC;
338 value->tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &value->tv_nsec);
339}
340
341/* Same for "timeval"
342 *
343 * Well, almost. The problem here is that the real system resolution is
344 * in nanoseconds and the value being converted is in micro seconds.
345 * Also for some machines (those that use HZ = 1024, in-particular),
346 * there is a LARGE error in the tick size in microseconds.
347
348 * The solution we use is to do the rounding AFTER we convert the
349 * microsecond part. Thus the USEC_ROUND, the bits to be shifted off.
350 * Instruction wise, this should cost only an additional add with carry
351 * instruction above the way it was done above.
352 */
353static __inline__ unsigned long
354timeval_to_jiffies(const struct timeval *value)
355{
356 unsigned long sec = value->tv_sec;
357 long usec = value->tv_usec;
358
359 if (sec >= MAX_SEC_IN_JIFFIES){
360 sec = MAX_SEC_IN_JIFFIES;
361 usec = 0;
362 }
363 return (((u64)sec * SEC_CONVERSION) +
364 (((u64)usec * USEC_CONVERSION + USEC_ROUND) >>
365 (USEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC;
366}
367
368static __inline__ void
369jiffies_to_timeval(const unsigned long jiffies, struct timeval *value)
370{
371 /*
372 * Convert jiffies to nanoseconds and separate with
373 * one divide.
374 */
375 u64 nsec = (u64)jiffies * TICK_NSEC;
376 value->tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &value->tv_usec);
377 value->tv_usec /= NSEC_PER_USEC;
378}
379
380/*
381 * Convert jiffies/jiffies_64 to clock_t and back.
382 */
383static inline clock_t jiffies_to_clock_t(long x)
384{
385#if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0
386 return x / (HZ / USER_HZ);
387#else
388 u64 tmp = (u64)x * TICK_NSEC;
389 do_div(tmp, (NSEC_PER_SEC / USER_HZ));
390 return (long)tmp;
391#endif
392}
393
394static inline unsigned long clock_t_to_jiffies(unsigned long x)
395{
396#if (HZ % USER_HZ)==0
397 if (x >= ~0UL / (HZ / USER_HZ))
398 return ~0UL;
399 return x * (HZ / USER_HZ);
400#else
401 u64 jif;
402
403 /* Don't worry about loss of precision here .. */
404 if (x >= ~0UL / HZ * USER_HZ)
405 return ~0UL;
406
407 /* .. but do try to contain it here */
408 jif = x * (u64) HZ;
409 do_div(jif, USER_HZ);
410 return jif;
411#endif
412}
413
414static inline u64 jiffies_64_to_clock_t(u64 x)
415{
416#if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0
417 do_div(x, HZ / USER_HZ);
418#else
419 /*
420 * There are better ways that don't overflow early,
421 * but even this doesn't overflow in hundreds of years
422 * in 64 bits, so..
423 */
424 x *= TICK_NSEC;
425 do_div(x, (NSEC_PER_SEC / USER_HZ));
426#endif
427 return x;
428}
429
430static inline u64 nsec_to_clock_t(u64 x)
431{
432#if (NSEC_PER_SEC % USER_HZ) == 0
433 do_div(x, (NSEC_PER_SEC / USER_HZ));
434#elif (USER_HZ % 512) == 0
435 x *= USER_HZ/512;
436 do_div(x, (NSEC_PER_SEC / 512));
437#else
438 /*
439 * max relative error 5.7e-8 (1.8s per year) for USER_HZ <= 1024,
440 * overflow after 64.99 years.
441 * exact for HZ=60, 72, 90, 120, 144, 180, 300, 600, 900, ...
442 */
443 x *= 9;
444 do_div(x, (unsigned long)((9ull * NSEC_PER_SEC + (USER_HZ/2))
445 / USER_HZ));
446#endif
447 return x;
448}
449
450#endif
diff --git a/include/linux/journal-head.h b/include/linux/journal-head.h
new file mode 100644
index 000000000000..8a62d1e84b9b
--- /dev/null
+++ b/include/linux/journal-head.h
@@ -0,0 +1,92 @@
1/*
2 * include/linux/journal-head.h
3 *
4 * buffer_head fields for JBD
5 *
6 * 27 May 2001 Andrew Morton <akpm@digeo.com>
7 * Created - pulled out of fs.h
8 */
9
10#ifndef JOURNAL_HEAD_H_INCLUDED
11#define JOURNAL_HEAD_H_INCLUDED
12
13typedef unsigned int tid_t; /* Unique transaction ID */
14typedef struct transaction_s transaction_t; /* Compound transaction type */
15struct buffer_head;
16
17struct journal_head {
18 /*
19 * Points back to our buffer_head. [jbd_lock_bh_journal_head()]
20 */
21 struct buffer_head *b_bh;
22
23 /*
24 * Reference count - see description in journal.c
25 * [jbd_lock_bh_journal_head()]
26 */
27 int b_jcount;
28
29 /*
30 * Journalling list for this buffer [jbd_lock_bh_state()]
31 */
32 unsigned b_jlist;
33
34 /*
35 * This flag signals the buffer has been modified by
36 * the currently running transaction
37 * [jbd_lock_bh_state()]
38 */
39 unsigned b_modified;
40
41 /*
42 * Copy of the buffer data frozen for writing to the log.
43 * [jbd_lock_bh_state()]
44 */
45 char *b_frozen_data;
46
47 /*
48 * Pointer to a saved copy of the buffer containing no uncommitted
49 * deallocation references, so that allocations can avoid overwriting
50 * uncommitted deletes. [jbd_lock_bh_state()]
51 */
52 char *b_committed_data;
53
54 /*
55 * Pointer to the compound transaction which owns this buffer's
56 * metadata: either the running transaction or the committing
57 * transaction (if there is one). Only applies to buffers on a
58 * transaction's data or metadata journaling list.
59 * [j_list_lock] [jbd_lock_bh_state()]
60 */
61 transaction_t *b_transaction;
62
63 /*
64 * Pointer to the running compound transaction which is currently
65 * modifying the buffer's metadata, if there was already a transaction
66 * committing it when the new transaction touched it.
67 * [t_list_lock] [jbd_lock_bh_state()]
68 */
69 transaction_t *b_next_transaction;
70
71 /*
72 * Doubly-linked list of buffers on a transaction's data, metadata or
73 * forget queue. [t_list_lock] [jbd_lock_bh_state()]
74 */
75 struct journal_head *b_tnext, *b_tprev;
76
77 /*
78 * Pointer to the compound transaction against which this buffer
79 * is checkpointed. Only dirty buffers can be checkpointed.
80 * [j_list_lock]
81 */
82 transaction_t *b_cp_transaction;
83
84 /*
85 * Doubly-linked list of buffers still remaining to be flushed
86 * before an old transaction can be checkpointed.
87 * [j_list_lock]
88 */
89 struct journal_head *b_cpnext, *b_cpprev;
90};
91
92#endif /* JOURNAL_HEAD_H_INCLUDED */
diff --git a/include/linux/joystick.h b/include/linux/joystick.h
new file mode 100644
index 000000000000..b7e0ab622cd7
--- /dev/null
+++ b/include/linux/joystick.h
@@ -0,0 +1,128 @@
1#ifndef _LINUX_JOYSTICK_H
2#define _LINUX_JOYSTICK_H
3
4/*
5 * $Id: joystick.h,v 1.3 2000/11/30 11:07:05 vojtech Exp $
6 *
7 * Copyright (C) 1996-2000 Vojtech Pavlik
8 *
9 * Sponsored by SuSE
10 */
11
12/*
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 *
27 * Should you need to contact me, the author, you can do so either by
28 * e-mail - mail your message to <vojtech@suse.cz>, or by paper mail:
29 * Vojtech Pavlik, Ucitelska 1576, Prague 8, 182 00 Czech Republic
30 */
31
32#include <asm/types.h>
33#include <linux/input.h>
34
35/*
36 * Version
37 */
38
39#define JS_VERSION 0x020100
40
41/*
42 * Types and constants for reading from /dev/js
43 */
44
45#define JS_EVENT_BUTTON 0x01 /* button pressed/released */
46#define JS_EVENT_AXIS 0x02 /* joystick moved */
47#define JS_EVENT_INIT 0x80 /* initial state of device */
48
49struct js_event {
50 __u32 time; /* event timestamp in milliseconds */
51 __s16 value; /* value */
52 __u8 type; /* event type */
53 __u8 number; /* axis/button number */
54};
55
56/*
57 * IOCTL commands for joystick driver
58 */
59
60#define JSIOCGVERSION _IOR('j', 0x01, __u32) /* get driver version */
61
62#define JSIOCGAXES _IOR('j', 0x11, __u8) /* get number of axes */
63#define JSIOCGBUTTONS _IOR('j', 0x12, __u8) /* get number of buttons */
64#define JSIOCGNAME(len) _IOC(_IOC_READ, 'j', 0x13, len) /* get identifier string */
65
66#define JSIOCSCORR _IOW('j', 0x21, struct js_corr) /* set correction values */
67#define JSIOCGCORR _IOR('j', 0x22, struct js_corr) /* get correction values */
68
69#define JSIOCSAXMAP _IOW('j', 0x31, __u8[ABS_MAX + 1]) /* set axis mapping */
70#define JSIOCGAXMAP _IOR('j', 0x32, __u8[ABS_MAX + 1]) /* get axis mapping */
71#define JSIOCSBTNMAP _IOW('j', 0x33, __u16[KEY_MAX - BTN_MISC + 1]) /* set button mapping */
72#define JSIOCGBTNMAP _IOR('j', 0x34, __u16[KEY_MAX - BTN_MISC + 1]) /* get button mapping */
73
74/*
75 * Types and constants for get/set correction
76 */
77
78#define JS_CORR_NONE 0x00 /* returns raw values */
79#define JS_CORR_BROKEN 0x01 /* broken line */
80
81struct js_corr {
82 __s32 coef[8];
83 __s16 prec;
84 __u16 type;
85};
86
87/*
88 * v0.x compatibility definitions
89 */
90
91#define JS_RETURN sizeof(struct JS_DATA_TYPE)
92#define JS_TRUE 1
93#define JS_FALSE 0
94#define JS_X_0 0x01
95#define JS_Y_0 0x02
96#define JS_X_1 0x04
97#define JS_Y_1 0x08
98#define JS_MAX 2
99
100#define JS_DEF_TIMEOUT 0x1300
101#define JS_DEF_CORR 0
102#define JS_DEF_TIMELIMIT 10L
103
104#define JS_SET_CAL 1
105#define JS_GET_CAL 2
106#define JS_SET_TIMEOUT 3
107#define JS_GET_TIMEOUT 4
108#define JS_SET_TIMELIMIT 5
109#define JS_GET_TIMELIMIT 6
110#define JS_GET_ALL 7
111#define JS_SET_ALL 8
112
113struct JS_DATA_TYPE {
114 int buttons;
115 int x;
116 int y;
117};
118
119struct JS_DATA_SAVE_TYPE {
120 int JS_TIMEOUT;
121 int BUSY;
122 long JS_EXPIRETIME;
123 long JS_TIMELIMIT;
124 struct JS_DATA_TYPE JS_SAVE;
125 struct JS_DATA_TYPE JS_CORR;
126};
127
128#endif /* _LINUX_JOYSTICK_H */
diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
new file mode 100644
index 000000000000..9bbd04092365
--- /dev/null
+++ b/include/linux/kallsyms.h
@@ -0,0 +1,67 @@
1/* Rewritten and vastly simplified by Rusty Russell for in-kernel
2 * module loader:
3 * Copyright 2002 Rusty Russell <rusty@rustcorp.com.au> IBM Corporation
4 */
5#ifndef _LINUX_KALLSYMS_H
6#define _LINUX_KALLSYMS_H
7
8#include <linux/config.h>
9
10#define KSYM_NAME_LEN 127
11
12#ifdef CONFIG_KALLSYMS
13/* Lookup the address for a symbol. Returns 0 if not found. */
14unsigned long kallsyms_lookup_name(const char *name);
15
16/* Lookup an address. modname is set to NULL if it's in the kernel. */
17const char *kallsyms_lookup(unsigned long addr,
18 unsigned long *symbolsize,
19 unsigned long *offset,
20 char **modname, char *namebuf);
21
22/* Replace "%s" in format with address, if found */
23extern void __print_symbol(const char *fmt, unsigned long address);
24
25#else /* !CONFIG_KALLSYMS */
26
27static inline unsigned long kallsyms_lookup_name(const char *name)
28{
29 return 0;
30}
31
32static inline const char *kallsyms_lookup(unsigned long addr,
33 unsigned long *symbolsize,
34 unsigned long *offset,
35 char **modname, char *namebuf)
36{
37 return NULL;
38}
39
40/* Stupid that this does nothing, but I didn't create this mess. */
41#define __print_symbol(fmt, addr)
42#endif /*CONFIG_KALLSYMS*/
43
44/* This macro allows us to keep printk typechecking */
45static void __check_printsym_format(const char *fmt, ...)
46__attribute__((format(printf,1,2)));
47static inline void __check_printsym_format(const char *fmt, ...)
48{
49}
50/* ia64 and ppc64 use function descriptors, which contain the real address */
51#if defined(CONFIG_IA64) || defined(CONFIG_PPC64)
52#define print_fn_descriptor_symbol(fmt, addr) \
53do { \
54 unsigned long *__faddr = (unsigned long*) addr; \
55 print_symbol(fmt, __faddr[0]); \
56} while (0)
57#else
58#define print_fn_descriptor_symbol(fmt, addr) print_symbol(fmt, addr)
59#endif
60
61#define print_symbol(fmt, addr) \
62do { \
63 __check_printsym_format(fmt, ""); \
64 __print_symbol(fmt, addr); \
65} while(0)
66
67#endif /*_LINUX_KALLSYMS_H*/
diff --git a/include/linux/kbd_diacr.h b/include/linux/kbd_diacr.h
new file mode 100644
index 000000000000..1c1a3ff0535b
--- /dev/null
+++ b/include/linux/kbd_diacr.h
@@ -0,0 +1,8 @@
1#ifndef _DIACR_H
2#define _DIACR_H
3#include <linux/kd.h>
4
5extern struct kbdiacr accent_table[];
6extern unsigned int accent_table_size;
7
8#endif /* _DIACR_H */
diff --git a/include/linux/kbd_kern.h b/include/linux/kbd_kern.h
new file mode 100644
index 000000000000..7428198111eb
--- /dev/null
+++ b/include/linux/kbd_kern.h
@@ -0,0 +1,157 @@
1#ifndef _KBD_KERN_H
2#define _KBD_KERN_H
3
4#include <linux/tty.h>
5#include <linux/interrupt.h>
6#include <linux/keyboard.h>
7
8extern struct tasklet_struct keyboard_tasklet;
9
10extern int shift_state;
11
12extern char *func_table[MAX_NR_FUNC];
13extern char func_buf[];
14extern char *funcbufptr;
15extern int funcbufsize, funcbufleft;
16
17/*
18 * kbd->xxx contains the VC-local things (flag settings etc..)
19 *
20 * Note: externally visible are LED_SCR, LED_NUM, LED_CAP defined in kd.h
21 * The code in KDGETLED / KDSETLED depends on the internal and
22 * external order being the same.
23 *
24 * Note: lockstate is used as index in the array key_map.
25 */
26struct kbd_struct {
27
28 unsigned char lockstate;
29/* 8 modifiers - the names do not have any meaning at all;
30 they can be associated to arbitrarily chosen keys */
31#define VC_SHIFTLOCK KG_SHIFT /* shift lock mode */
32#define VC_ALTGRLOCK KG_ALTGR /* altgr lock mode */
33#define VC_CTRLLOCK KG_CTRL /* control lock mode */
34#define VC_ALTLOCK KG_ALT /* alt lock mode */
35#define VC_SHIFTLLOCK KG_SHIFTL /* shiftl lock mode */
36#define VC_SHIFTRLOCK KG_SHIFTR /* shiftr lock mode */
37#define VC_CTRLLLOCK KG_CTRLL /* ctrll lock mode */
38#define VC_CTRLRLOCK KG_CTRLR /* ctrlr lock mode */
39 unsigned char slockstate; /* for `sticky' Shift, Ctrl, etc. */
40
41 unsigned char ledmode:2; /* one 2-bit value */
42#define LED_SHOW_FLAGS 0 /* traditional state */
43#define LED_SHOW_IOCTL 1 /* only change leds upon ioctl */
44#define LED_SHOW_MEM 2 /* `heartbeat': peek into memory */
45
46 unsigned char ledflagstate:4; /* flags, not lights */
47 unsigned char default_ledflagstate:4;
48#define VC_SCROLLOCK 0 /* scroll-lock mode */
49#define VC_NUMLOCK 1 /* numeric lock mode */
50#define VC_CAPSLOCK 2 /* capslock mode */
51#define VC_KANALOCK 3 /* kanalock mode */
52
53 unsigned char kbdmode:2; /* one 2-bit value */
54#define VC_XLATE 0 /* translate keycodes using keymap */
55#define VC_MEDIUMRAW 1 /* medium raw (keycode) mode */
56#define VC_RAW 2 /* raw (scancode) mode */
57#define VC_UNICODE 3 /* Unicode mode */
58
59 unsigned char modeflags:5;
60#define VC_APPLIC 0 /* application key mode */
61#define VC_CKMODE 1 /* cursor key mode */
62#define VC_REPEAT 2 /* keyboard repeat */
63#define VC_CRLF 3 /* 0 - enter sends CR, 1 - enter sends CRLF */
64#define VC_META 4 /* 0 - meta, 1 - meta=prefix with ESC */
65};
66
67extern struct kbd_struct kbd_table[];
68
69extern int kbd_init(void);
70
71extern unsigned char getledstate(void);
72extern void setledstate(struct kbd_struct *kbd, unsigned int led);
73
74extern int do_poke_blanked_console;
75
76extern void (*kbd_ledfunc)(unsigned int led);
77
78extern void set_console(int nr);
79extern void schedule_console_callback(void);
80
81static inline void set_leds(void)
82{
83 tasklet_schedule(&keyboard_tasklet);
84}
85
86static inline int vc_kbd_mode(struct kbd_struct * kbd, int flag)
87{
88 return ((kbd->modeflags >> flag) & 1);
89}
90
91static inline int vc_kbd_led(struct kbd_struct * kbd, int flag)
92{
93 return ((kbd->ledflagstate >> flag) & 1);
94}
95
96static inline void set_vc_kbd_mode(struct kbd_struct * kbd, int flag)
97{
98 kbd->modeflags |= 1 << flag;
99}
100
101static inline void set_vc_kbd_led(struct kbd_struct * kbd, int flag)
102{
103 kbd->ledflagstate |= 1 << flag;
104}
105
106static inline void clr_vc_kbd_mode(struct kbd_struct * kbd, int flag)
107{
108 kbd->modeflags &= ~(1 << flag);
109}
110
111static inline void clr_vc_kbd_led(struct kbd_struct * kbd, int flag)
112{
113 kbd->ledflagstate &= ~(1 << flag);
114}
115
116static inline void chg_vc_kbd_lock(struct kbd_struct * kbd, int flag)
117{
118 kbd->lockstate ^= 1 << flag;
119}
120
121static inline void chg_vc_kbd_slock(struct kbd_struct * kbd, int flag)
122{
123 kbd->slockstate ^= 1 << flag;
124}
125
126static inline void chg_vc_kbd_mode(struct kbd_struct * kbd, int flag)
127{
128 kbd->modeflags ^= 1 << flag;
129}
130
131static inline void chg_vc_kbd_led(struct kbd_struct * kbd, int flag)
132{
133 kbd->ledflagstate ^= 1 << flag;
134}
135
136#define U(x) ((x) ^ 0xf000)
137
138/* keyboard.c */
139
140struct console;
141
142int getkeycode(unsigned int scancode);
143int setkeycode(unsigned int scancode, unsigned int keycode);
144void compute_shiftstate(void);
145
146/* defkeymap.c */
147
148extern unsigned int keymap_count;
149
150/* console.c */
151
152static inline void con_schedule_flip(struct tty_struct *t)
153{
154 schedule_work(&t->flip.work);
155}
156
157#endif
diff --git a/include/linux/kd.h b/include/linux/kd.h
new file mode 100644
index 000000000000..28be4fbe9044
--- /dev/null
+++ b/include/linux/kd.h
@@ -0,0 +1,175 @@
1#ifndef _LINUX_KD_H
2#define _LINUX_KD_H
3#include <linux/types.h>
4#include <linux/compiler.h>
5
6/* 0x4B is 'K', to avoid collision with termios and vt */
7
8#define GIO_FONT 0x4B60 /* gets font in expanded form */
9#define PIO_FONT 0x4B61 /* use font in expanded form */
10
11#define GIO_FONTX 0x4B6B /* get font using struct consolefontdesc */
12#define PIO_FONTX 0x4B6C /* set font using struct consolefontdesc */
13struct consolefontdesc {
14 unsigned short charcount; /* characters in font (256 or 512) */
15 unsigned short charheight; /* scan lines per character (1-32) */
16 char __user *chardata; /* font data in expanded form */
17};
18
19#define PIO_FONTRESET 0x4B6D /* reset to default font */
20
21#define GIO_CMAP 0x4B70 /* gets colour palette on VGA+ */
22#define PIO_CMAP 0x4B71 /* sets colour palette on VGA+ */
23
24#define KIOCSOUND 0x4B2F /* start sound generation (0 for off) */
25#define KDMKTONE 0x4B30 /* generate tone */
26
27#define KDGETLED 0x4B31 /* return current led state */
28#define KDSETLED 0x4B32 /* set led state [lights, not flags] */
29#define LED_SCR 0x01 /* scroll lock led */
30#define LED_NUM 0x02 /* num lock led */
31#define LED_CAP 0x04 /* caps lock led */
32
33#define KDGKBTYPE 0x4B33 /* get keyboard type */
34#define KB_84 0x01
35#define KB_101 0x02 /* this is what we always answer */
36#define KB_OTHER 0x03
37
38#define KDADDIO 0x4B34 /* add i/o port as valid */
39#define KDDELIO 0x4B35 /* del i/o port as valid */
40#define KDENABIO 0x4B36 /* enable i/o to video board */
41#define KDDISABIO 0x4B37 /* disable i/o to video board */
42
43#define KDSETMODE 0x4B3A /* set text/graphics mode */
44#define KD_TEXT 0x00
45#define KD_GRAPHICS 0x01
46#define KD_TEXT0 0x02 /* obsolete */
47#define KD_TEXT1 0x03 /* obsolete */
48#define KDGETMODE 0x4B3B /* get current mode */
49
50#define KDMAPDISP 0x4B3C /* map display into address space */
51#define KDUNMAPDISP 0x4B3D /* unmap display from address space */
52
53typedef char scrnmap_t;
54#define E_TABSZ 256
55#define GIO_SCRNMAP 0x4B40 /* get screen mapping from kernel */
56#define PIO_SCRNMAP 0x4B41 /* put screen mapping table in kernel */
57#define GIO_UNISCRNMAP 0x4B69 /* get full Unicode screen mapping */
58#define PIO_UNISCRNMAP 0x4B6A /* set full Unicode screen mapping */
59
60#define GIO_UNIMAP 0x4B66 /* get unicode-to-font mapping from kernel */
61struct unipair {
62 unsigned short unicode;
63 unsigned short fontpos;
64};
65struct unimapdesc {
66 unsigned short entry_ct;
67 struct unipair __user *entries;
68};
69#define PIO_UNIMAP 0x4B67 /* put unicode-to-font mapping in kernel */
70#define PIO_UNIMAPCLR 0x4B68 /* clear table, possibly advise hash algorithm */
71struct unimapinit {
72 unsigned short advised_hashsize; /* 0 if no opinion */
73 unsigned short advised_hashstep; /* 0 if no opinion */
74 unsigned short advised_hashlevel; /* 0 if no opinion */
75};
76
77#define UNI_DIRECT_BASE 0xF000 /* start of Direct Font Region */
78#define UNI_DIRECT_MASK 0x01FF /* Direct Font Region bitmask */
79
80#define K_RAW 0x00
81#define K_XLATE 0x01
82#define K_MEDIUMRAW 0x02
83#define K_UNICODE 0x03
84#define KDGKBMODE 0x4B44 /* gets current keyboard mode */
85#define KDSKBMODE 0x4B45 /* sets current keyboard mode */
86
87#define K_METABIT 0x03
88#define K_ESCPREFIX 0x04
89#define KDGKBMETA 0x4B62 /* gets meta key handling mode */
90#define KDSKBMETA 0x4B63 /* sets meta key handling mode */
91
92#define K_SCROLLLOCK 0x01
93#define K_NUMLOCK 0x02
94#define K_CAPSLOCK 0x04
95#define KDGKBLED 0x4B64 /* get led flags (not lights) */
96#define KDSKBLED 0x4B65 /* set led flags (not lights) */
97
98struct kbentry {
99 unsigned char kb_table;
100 unsigned char kb_index;
101 unsigned short kb_value;
102};
103#define K_NORMTAB 0x00
104#define K_SHIFTTAB 0x01
105#define K_ALTTAB 0x02
106#define K_ALTSHIFTTAB 0x03
107
108#define KDGKBENT 0x4B46 /* gets one entry in translation table */
109#define KDSKBENT 0x4B47 /* sets one entry in translation table */
110
111struct kbsentry {
112 unsigned char kb_func;
113 unsigned char kb_string[512];
114};
115#define KDGKBSENT 0x4B48 /* gets one function key string entry */
116#define KDSKBSENT 0x4B49 /* sets one function key string entry */
117
118struct kbdiacr {
119 unsigned char diacr, base, result;
120};
121struct kbdiacrs {
122 unsigned int kb_cnt; /* number of entries in following array */
123 struct kbdiacr kbdiacr[256]; /* MAX_DIACR from keyboard.h */
124};
125#define KDGKBDIACR 0x4B4A /* read kernel accent table */
126#define KDSKBDIACR 0x4B4B /* write kernel accent table */
127
128struct kbkeycode {
129 unsigned int scancode, keycode;
130};
131#define KDGETKEYCODE 0x4B4C /* read kernel keycode table entry */
132#define KDSETKEYCODE 0x4B4D /* write kernel keycode table entry */
133
134#define KDSIGACCEPT 0x4B4E /* accept kbd generated signals */
135
136struct kbd_repeat {
137 int delay; /* in msec; <= 0: don't change */
138 int period; /* in msec; <= 0: don't change */
139 /* earlier this field was misnamed "rate" */
140};
141
142#define KDKBDREP 0x4B52 /* set keyboard delay/repeat rate;
143 * actually used values are returned */
144
145#define KDFONTOP 0x4B72 /* font operations */
146
147struct console_font_op {
148 unsigned int op; /* operation code KD_FONT_OP_* */
149 unsigned int flags; /* KD_FONT_FLAG_* */
150 unsigned int width, height; /* font size */
151 unsigned int charcount;
152 unsigned char __user *data; /* font data with height fixed to 32 */
153};
154
155struct console_font {
156 unsigned int width, height; /* font size */
157 unsigned int charcount;
158 unsigned char *data; /* font data with height fixed to 32 */
159};
160
161#define KD_FONT_OP_SET 0 /* Set font */
162#define KD_FONT_OP_GET 1 /* Get font */
163#define KD_FONT_OP_SET_DEFAULT 2 /* Set font to default, data points to name / NULL */
164#define KD_FONT_OP_COPY 3 /* Copy from another console */
165
166#define KD_FONT_FLAG_DONT_RECALC 1 /* Don't recalculate hw charcell size [compat] */
167#ifdef __KERNEL__
168#define KD_FONT_FLAG_OLD 0x80000000 /* Invoked via old interface [compat] */
169#endif
170
171/* note: 0x4B00-0x4B4E all have had a value at some time;
172 don't reuse for the time being */
173/* note: 0x4B60-0x4B6D, 0x4B70-0x4B72 used above */
174
175#endif /* _LINUX_KD_H */
diff --git a/include/linux/kdev_t.h b/include/linux/kdev_t.h
new file mode 100644
index 000000000000..bceea527dd37
--- /dev/null
+++ b/include/linux/kdev_t.h
@@ -0,0 +1,101 @@
1#ifndef _LINUX_KDEV_T_H
2#define _LINUX_KDEV_T_H
3#ifdef __KERNEL__
4#define MINORBITS 20
5#define MINORMASK ((1U << MINORBITS) - 1)
6
7#define MAJOR(dev) ((unsigned int) ((dev) >> MINORBITS))
8#define MINOR(dev) ((unsigned int) ((dev) & MINORMASK))
9#define MKDEV(ma,mi) (((ma) << MINORBITS) | (mi))
10
11#define print_dev_t(buffer, dev) \
12 sprintf((buffer), "%u:%u\n", MAJOR(dev), MINOR(dev))
13
14#define format_dev_t(buffer, dev) \
15 ({ \
16 sprintf(buffer, "%u:%u", MAJOR(dev), MINOR(dev)); \
17 buffer; \
18 })
19
20/* acceptable for old filesystems */
21static inline int old_valid_dev(dev_t dev)
22{
23 return MAJOR(dev) < 256 && MINOR(dev) < 256;
24}
25
26static inline u16 old_encode_dev(dev_t dev)
27{
28 return (MAJOR(dev) << 8) | MINOR(dev);
29}
30
31static inline dev_t old_decode_dev(u16 val)
32{
33 return MKDEV((val >> 8) & 255, val & 255);
34}
35
36static inline int new_valid_dev(dev_t dev)
37{
38 return 1;
39}
40
41static inline u32 new_encode_dev(dev_t dev)
42{
43 unsigned major = MAJOR(dev);
44 unsigned minor = MINOR(dev);
45 return (minor & 0xff) | (major << 8) | ((minor & ~0xff) << 12);
46}
47
48static inline dev_t new_decode_dev(u32 dev)
49{
50 unsigned major = (dev & 0xfff00) >> 8;
51 unsigned minor = (dev & 0xff) | ((dev >> 12) & 0xfff00);
52 return MKDEV(major, minor);
53}
54
55static inline int huge_valid_dev(dev_t dev)
56{
57 return 1;
58}
59
60static inline u64 huge_encode_dev(dev_t dev)
61{
62 return new_encode_dev(dev);
63}
64
65static inline dev_t huge_decode_dev(u64 dev)
66{
67 return new_decode_dev(dev);
68}
69
70static inline int sysv_valid_dev(dev_t dev)
71{
72 return MAJOR(dev) < (1<<14) && MINOR(dev) < (1<<18);
73}
74
75static inline u32 sysv_encode_dev(dev_t dev)
76{
77 return MINOR(dev) | (MAJOR(dev) << 18);
78}
79
80static inline unsigned sysv_major(u32 dev)
81{
82 return (dev >> 18) & 0x3fff;
83}
84
85static inline unsigned sysv_minor(u32 dev)
86{
87 return dev & 0x3ffff;
88}
89
90
91#else /* __KERNEL__ */
92
93/*
94Some programs want their definitions of MAJOR and MINOR and MKDEV
95from the kernel sources. These must be the externally visible ones.
96*/
97#define MAJOR(dev) ((dev)>>8)
98#define MINOR(dev) ((dev) & 0xff)
99#define MKDEV(ma,mi) ((ma)<<8 | (mi))
100#endif /* __KERNEL__ */
101#endif
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
new file mode 100644
index 000000000000..7c1cba4a5278
--- /dev/null
+++ b/include/linux/kernel.h
@@ -0,0 +1,307 @@
1#ifndef _LINUX_KERNEL_H
2#define _LINUX_KERNEL_H
3
4/*
5 * 'kernel.h' contains some often-used function prototypes etc
6 */
7
8#ifdef __KERNEL__
9
10#include <stdarg.h>
11#include <linux/linkage.h>
12#include <linux/stddef.h>
13#include <linux/types.h>
14#include <linux/compiler.h>
15#include <linux/bitops.h>
16#include <asm/byteorder.h>
17#include <asm/bug.h>
18
19extern const char linux_banner[];
20
21#define INT_MAX ((int)(~0U>>1))
22#define INT_MIN (-INT_MAX - 1)
23#define UINT_MAX (~0U)
24#define LONG_MAX ((long)(~0UL>>1))
25#define LONG_MIN (-LONG_MAX - 1)
26#define ULONG_MAX (~0UL)
27
28#define STACK_MAGIC 0xdeadbeef
29
30#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
31#define ALIGN(x,a) (((x)+(a)-1)&~((a)-1))
32
33#define KERN_EMERG "<0>" /* system is unusable */
34#define KERN_ALERT "<1>" /* action must be taken immediately */
35#define KERN_CRIT "<2>" /* critical conditions */
36#define KERN_ERR "<3>" /* error conditions */
37#define KERN_WARNING "<4>" /* warning conditions */
38#define KERN_NOTICE "<5>" /* normal but significant condition */
39#define KERN_INFO "<6>" /* informational */
40#define KERN_DEBUG "<7>" /* debug-level messages */
41
42extern int console_printk[];
43
44#define console_loglevel (console_printk[0])
45#define default_message_loglevel (console_printk[1])
46#define minimum_console_loglevel (console_printk[2])
47#define default_console_loglevel (console_printk[3])
48
49struct completion;
50
51/**
52 * might_sleep - annotation for functions that can sleep
53 *
54 * this macro will print a stack trace if it is executed in an atomic
55 * context (spinlock, irq-handler, ...).
56 *
57 * This is a useful debugging help to be able to catch problems early and not
58 * be biten later when the calling function happens to sleep when it is not
59 * supposed to.
60 */
61#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
62#define might_sleep() __might_sleep(__FILE__, __LINE__)
63#define might_sleep_if(cond) do { if (unlikely(cond)) might_sleep(); } while (0)
64void __might_sleep(char *file, int line);
65#else
66#define might_sleep() do {} while(0)
67#define might_sleep_if(cond) do {} while (0)
68#endif
69
70#define abs(x) ({ \
71 int __x = (x); \
72 (__x < 0) ? -__x : __x; \
73 })
74
75#define labs(x) ({ \
76 long __x = (x); \
77 (__x < 0) ? -__x : __x; \
78 })
79
80extern struct notifier_block *panic_notifier_list;
81extern long (*panic_blink)(long time);
82NORET_TYPE void panic(const char * fmt, ...)
83 __attribute__ ((NORET_AND format (printf, 1, 2)));
84fastcall NORET_TYPE void do_exit(long error_code)
85 ATTRIB_NORET;
86NORET_TYPE void complete_and_exit(struct completion *, long)
87 ATTRIB_NORET;
88extern unsigned long simple_strtoul(const char *,char **,unsigned int);
89extern long simple_strtol(const char *,char **,unsigned int);
90extern unsigned long long simple_strtoull(const char *,char **,unsigned int);
91extern long long simple_strtoll(const char *,char **,unsigned int);
92extern int sprintf(char * buf, const char * fmt, ...)
93 __attribute__ ((format (printf, 2, 3)));
94extern int vsprintf(char *buf, const char *, va_list)
95 __attribute__ ((format (printf, 2, 0)));
96extern int snprintf(char * buf, size_t size, const char * fmt, ...)
97 __attribute__ ((format (printf, 3, 4)));
98extern int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
99 __attribute__ ((format (printf, 3, 0)));
100extern int scnprintf(char * buf, size_t size, const char * fmt, ...)
101 __attribute__ ((format (printf, 3, 4)));
102extern int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
103 __attribute__ ((format (printf, 3, 0)));
104
105extern int sscanf(const char *, const char *, ...)
106 __attribute__ ((format (scanf, 2, 3)));
107extern int vsscanf(const char *, const char *, va_list)
108 __attribute__ ((format (scanf, 2, 0)));
109
110extern int get_option(char **str, int *pint);
111extern char *get_options(const char *str, int nints, int *ints);
112extern unsigned long long memparse(char *ptr, char **retptr);
113
114extern int __kernel_text_address(unsigned long addr);
115extern int kernel_text_address(unsigned long addr);
116extern int session_of_pgrp(int pgrp);
117
118asmlinkage int vprintk(const char *fmt, va_list args)
119 __attribute__ ((format (printf, 1, 0)));
120asmlinkage int printk(const char * fmt, ...)
121 __attribute__ ((format (printf, 1, 2)));
122
123unsigned long int_sqrt(unsigned long);
124
125static inline int __attribute_pure__ long_log2(unsigned long x)
126{
127 int r = 0;
128 for (x >>= 1; x > 0; x >>= 1)
129 r++;
130 return r;
131}
132
133static inline unsigned long __attribute_const__ roundup_pow_of_two(unsigned long x)
134{
135 return (1UL << fls(x - 1));
136}
137
138extern int printk_ratelimit(void);
139extern int __printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst);
140
141static inline void console_silent(void)
142{
143 console_loglevel = 0;
144}
145
146static inline void console_verbose(void)
147{
148 if (console_loglevel)
149 console_loglevel = 15;
150}
151
152extern void bust_spinlocks(int yes);
153extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in progress */
154extern int panic_timeout;
155extern int panic_on_oops;
156extern int tainted;
157extern const char *print_tainted(void);
158extern void add_taint(unsigned);
159
160/* Values used for system_state */
161extern enum system_states {
162 SYSTEM_BOOTING,
163 SYSTEM_RUNNING,
164 SYSTEM_HALT,
165 SYSTEM_POWER_OFF,
166 SYSTEM_RESTART,
167} system_state;
168
169#define TAINT_PROPRIETARY_MODULE (1<<0)
170#define TAINT_FORCED_MODULE (1<<1)
171#define TAINT_UNSAFE_SMP (1<<2)
172#define TAINT_FORCED_RMMOD (1<<3)
173#define TAINT_MACHINE_CHECK (1<<4)
174#define TAINT_BAD_PAGE (1<<5)
175
176extern void dump_stack(void);
177
178#ifdef DEBUG
179#define pr_debug(fmt,arg...) \
180 printk(KERN_DEBUG fmt,##arg)
181#else
182#define pr_debug(fmt,arg...) \
183 do { } while (0)
184#endif
185
186#define pr_info(fmt,arg...) \
187 printk(KERN_INFO fmt,##arg)
188
189/*
190 * Display an IP address in readable format.
191 */
192
193#define NIPQUAD(addr) \
194 ((unsigned char *)&addr)[0], \
195 ((unsigned char *)&addr)[1], \
196 ((unsigned char *)&addr)[2], \
197 ((unsigned char *)&addr)[3]
198
199#define NIP6(addr) \
200 ntohs((addr).s6_addr16[0]), \
201 ntohs((addr).s6_addr16[1]), \
202 ntohs((addr).s6_addr16[2]), \
203 ntohs((addr).s6_addr16[3]), \
204 ntohs((addr).s6_addr16[4]), \
205 ntohs((addr).s6_addr16[5]), \
206 ntohs((addr).s6_addr16[6]), \
207 ntohs((addr).s6_addr16[7])
208
209#if defined(__LITTLE_ENDIAN)
210#define HIPQUAD(addr) \
211 ((unsigned char *)&addr)[3], \
212 ((unsigned char *)&addr)[2], \
213 ((unsigned char *)&addr)[1], \
214 ((unsigned char *)&addr)[0]
215#elif defined(__BIG_ENDIAN)
216#define HIPQUAD NIPQUAD
217#else
218#error "Please fix asm/byteorder.h"
219#endif /* __LITTLE_ENDIAN */
220
221/*
222 * min()/max() macros that also do
223 * strict type-checking.. See the
224 * "unnecessary" pointer comparison.
225 */
226#define min(x,y) ({ \
227 typeof(x) _x = (x); \
228 typeof(y) _y = (y); \
229 (void) (&_x == &_y); \
230 _x < _y ? _x : _y; })
231
232#define max(x,y) ({ \
233 typeof(x) _x = (x); \
234 typeof(y) _y = (y); \
235 (void) (&_x == &_y); \
236 _x > _y ? _x : _y; })
237
238/*
239 * ..and if you can't take the strict
240 * types, you can specify one yourself.
241 *
242 * Or not use min/max at all, of course.
243 */
244#define min_t(type,x,y) \
245 ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
246#define max_t(type,x,y) \
247 ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
248
249
250/**
251 * container_of - cast a member of a structure out to the containing structure
252 *
253 * @ptr: the pointer to the member.
254 * @type: the type of the container struct this is embedded in.
255 * @member: the name of the member within the struct.
256 *
257 */
258#define container_of(ptr, type, member) ({ \
259 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
260 (type *)( (char *)__mptr - offsetof(type,member) );})
261
262/*
263 * Check at compile time that something is of a particular type.
264 * Always evaluates to 1 so you may use it easily in comparisons.
265 */
266#define typecheck(type,x) \
267({ type __dummy; \
268 typeof(x) __dummy2; \
269 (void)(&__dummy == &__dummy2); \
270 1; \
271})
272
273#endif /* __KERNEL__ */
274
275#define SI_LOAD_SHIFT 16
276struct sysinfo {
277 long uptime; /* Seconds since boot */
278 unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
279 unsigned long totalram; /* Total usable main memory size */
280 unsigned long freeram; /* Available memory size */
281 unsigned long sharedram; /* Amount of shared memory */
282 unsigned long bufferram; /* Memory used by buffers */
283 unsigned long totalswap; /* Total swap space size */
284 unsigned long freeswap; /* swap space still available */
285 unsigned short procs; /* Number of current processes */
286 unsigned short pad; /* explicit padding for m68k */
287 unsigned long totalhigh; /* Total high memory size */
288 unsigned long freehigh; /* Available high memory size */
289 unsigned int mem_unit; /* Memory unit size in bytes */
290 char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */
291};
292
293extern void BUILD_BUG(void);
294#define BUILD_BUG_ON(condition) do { if (condition) BUILD_BUG(); } while(0)
295
296#ifdef CONFIG_SYSCTL
297extern int randomize_va_space;
298#else
299#define randomize_va_space 1
300#endif
301
302/* Trap pasters of __FUNCTION__ at compile-time */
303#if __GNUC__ > 2 || __GNUC_MINOR__ >= 95
304#define __FUNCTION__ (__func__)
305#endif
306
307#endif
diff --git a/include/linux/kernel_stat.h b/include/linux/kernel_stat.h
new file mode 100644
index 000000000000..dba27749b428
--- /dev/null
+++ b/include/linux/kernel_stat.h
@@ -0,0 +1,59 @@
1#ifndef _LINUX_KERNEL_STAT_H
2#define _LINUX_KERNEL_STAT_H
3
4#include <linux/config.h>
5#include <asm/irq.h>
6#include <linux/smp.h>
7#include <linux/threads.h>
8#include <linux/percpu.h>
9#include <asm/cputime.h>
10
11/*
12 * 'kernel_stat.h' contains the definitions needed for doing
13 * some kernel statistics (CPU usage, context switches ...),
14 * used by rstatd/perfmeter
15 */
16
17struct cpu_usage_stat {
18 cputime64_t user;
19 cputime64_t nice;
20 cputime64_t system;
21 cputime64_t softirq;
22 cputime64_t irq;
23 cputime64_t idle;
24 cputime64_t iowait;
25 cputime64_t steal;
26};
27
28struct kernel_stat {
29 struct cpu_usage_stat cpustat;
30 unsigned int irqs[NR_IRQS];
31};
32
33DECLARE_PER_CPU(struct kernel_stat, kstat);
34
35#define kstat_cpu(cpu) per_cpu(kstat, cpu)
36/* Must have preemption disabled for this to be meaningful. */
37#define kstat_this_cpu __get_cpu_var(kstat)
38
39extern unsigned long long nr_context_switches(void);
40
41/*
42 * Number of interrupts per specific IRQ source, since bootup
43 */
44static inline int kstat_irqs(int irq)
45{
46 int i, sum=0;
47
48 for (i = 0; i < NR_CPUS; i++)
49 if (cpu_possible(i))
50 sum += kstat_cpu(i).irqs[irq];
51
52 return sum;
53}
54
55extern void account_user_time(struct task_struct *, cputime_t);
56extern void account_system_time(struct task_struct *, int, cputime_t);
57extern void account_steal_time(struct task_struct *, cputime_t);
58
59#endif /* _LINUX_KERNEL_STAT_H */
diff --git a/include/linux/kernelcapi.h b/include/linux/kernelcapi.h
new file mode 100644
index 000000000000..891bb2cf0aa8
--- /dev/null
+++ b/include/linux/kernelcapi.h
@@ -0,0 +1,161 @@
1/*
2 * $Id: kernelcapi.h,v 1.8.6.2 2001/02/07 11:31:31 kai Exp $
3 *
4 * Kernel CAPI 2.0 Interface for Linux
5 *
6 * (c) Copyright 1997 by Carsten Paeth (calle@calle.in-berlin.de)
7 *
8 */
9
10#ifndef __KERNELCAPI_H__
11#define __KERNELCAPI_H__
12
13#define CAPI_MAXAPPL 240 /* maximum number of applications */
14#define CAPI_MAXCONTR 32 /* maximum number of controller */
15#define CAPI_MAXDATAWINDOW 8
16
17
18typedef struct kcapi_flagdef {
19 int contr;
20 int flag;
21} kcapi_flagdef;
22
23typedef struct kcapi_carddef {
24 char driver[32];
25 unsigned int port;
26 unsigned irq;
27 unsigned int membase;
28 int cardnr;
29} kcapi_carddef;
30
31/* new ioctls >= 10 */
32#define KCAPI_CMD_TRACE 10
33#define KCAPI_CMD_ADDCARD 11 /* OBSOLETE */
34
35/*
36 * flag > 2 => trace also data
37 * flag & 1 => show trace
38 */
39#define KCAPI_TRACE_OFF 0
40#define KCAPI_TRACE_SHORT_NO_DATA 1
41#define KCAPI_TRACE_FULL_NO_DATA 2
42#define KCAPI_TRACE_SHORT 3
43#define KCAPI_TRACE_FULL 4
44
45
46#ifdef __KERNEL__
47
48#include <linux/list.h>
49#include <linux/skbuff.h>
50
51#define KCI_CONTRUP 0 /* arg: struct capi_profile */
52#define KCI_CONTRDOWN 1 /* arg: NULL */
53
54struct capi20_appl {
55 u16 applid;
56 capi_register_params rparam;
57 void (*recv_message)(struct capi20_appl *ap, struct sk_buff *skb);
58 void *private;
59
60 /* internal to kernelcapi.o */
61 unsigned long nrecvctlpkt;
62 unsigned long nrecvdatapkt;
63 unsigned long nsentctlpkt;
64 unsigned long nsentdatapkt;
65 struct semaphore recv_sem;
66 struct sk_buff_head recv_queue;
67 struct work_struct recv_work;
68 int release_in_progress;
69
70 /* ugly hack to allow for notification of added/removed
71 * controllers. The Right Way (tm) is known. XXX
72 */
73 void (*callback) (unsigned int cmd, __u32 contr, void *data);
74};
75
76u16 capi20_isinstalled(void);
77u16 capi20_register(struct capi20_appl *ap);
78u16 capi20_release(struct capi20_appl *ap);
79u16 capi20_put_message(struct capi20_appl *ap, struct sk_buff *skb);
80u16 capi20_get_manufacturer(u32 contr, u8 buf[CAPI_MANUFACTURER_LEN]);
81u16 capi20_get_version(u32 contr, struct capi_version *verp);
82u16 capi20_get_serial(u32 contr, u8 serial[CAPI_SERIAL_LEN]);
83u16 capi20_get_profile(u32 contr, struct capi_profile *profp);
84int capi20_manufacturer(unsigned int cmd, void __user *data);
85
86/* temporary hack XXX */
87void capi20_set_callback(struct capi20_appl *ap,
88 void (*callback) (unsigned int cmd, __u32 contr, void *data));
89
90
91
92#define CAPI_NOERROR 0x0000
93
94#define CAPI_TOOMANYAPPLS 0x1001
95#define CAPI_LOGBLKSIZETOSMALL 0x1002
96#define CAPI_BUFFEXECEEDS64K 0x1003
97#define CAPI_MSGBUFSIZETOOSMALL 0x1004
98#define CAPI_ANZLOGCONNNOTSUPPORTED 0x1005
99#define CAPI_REGRESERVED 0x1006
100#define CAPI_REGBUSY 0x1007
101#define CAPI_REGOSRESOURCEERR 0x1008
102#define CAPI_REGNOTINSTALLED 0x1009
103#define CAPI_REGCTRLERNOTSUPPORTEXTEQUIP 0x100a
104#define CAPI_REGCTRLERONLYSUPPORTEXTEQUIP 0x100b
105
106#define CAPI_ILLAPPNR 0x1101
107#define CAPI_ILLCMDORSUBCMDORMSGTOSMALL 0x1102
108#define CAPI_SENDQUEUEFULL 0x1103
109#define CAPI_RECEIVEQUEUEEMPTY 0x1104
110#define CAPI_RECEIVEOVERFLOW 0x1105
111#define CAPI_UNKNOWNNOTPAR 0x1106
112#define CAPI_MSGBUSY 0x1107
113#define CAPI_MSGOSRESOURCEERR 0x1108
114#define CAPI_MSGNOTINSTALLED 0x1109
115#define CAPI_MSGCTRLERNOTSUPPORTEXTEQUIP 0x110a
116#define CAPI_MSGCTRLERONLYSUPPORTEXTEQUIP 0x110b
117
118typedef enum {
119 CapiMessageNotSupportedInCurrentState = 0x2001,
120 CapiIllContrPlciNcci = 0x2002,
121 CapiNoPlciAvailable = 0x2003,
122 CapiNoNcciAvailable = 0x2004,
123 CapiNoListenResourcesAvailable = 0x2005,
124 CapiNoFaxResourcesAvailable = 0x2006,
125 CapiIllMessageParmCoding = 0x2007,
126} RESOURCE_CODING_PROBLEM;
127
128typedef enum {
129 CapiB1ProtocolNotSupported = 0x3001,
130 CapiB2ProtocolNotSupported = 0x3002,
131 CapiB3ProtocolNotSupported = 0x3003,
132 CapiB1ProtocolParameterNotSupported = 0x3004,
133 CapiB2ProtocolParameterNotSupported = 0x3005,
134 CapiB3ProtocolParameterNotSupported = 0x3006,
135 CapiBProtocolCombinationNotSupported = 0x3007,
136 CapiNcpiNotSupported = 0x3008,
137 CapiCipValueUnknown = 0x3009,
138 CapiFlagsNotSupported = 0x300a,
139 CapiFacilityNotSupported = 0x300b,
140 CapiDataLengthNotSupportedByCurrentProtocol = 0x300c,
141 CapiResetProcedureNotSupportedByCurrentProtocol = 0x300d,
142 CapiTeiAssignmentFailed = 0x300e,
143} REQUESTED_SERVICES_PROBLEM;
144
145typedef enum {
146 CapiSuccess = 0x0000,
147 CapiSupplementaryServiceNotSupported = 0x300e,
148 CapiRequestNotAllowedInThisState = 0x3010,
149} SUPPLEMENTARY_SERVICE_INFO;
150
151typedef enum {
152 CapiProtocolErrorLayer1 = 0x3301,
153 CapiProtocolErrorLayer2 = 0x3302,
154 CapiProtocolErrorLayer3 = 0x3303,
155 CapiTimeOut = 0x3303, // SuppServiceReason
156 CapiCallGivenToOtherApplication = 0x3304,
157} CAPI_REASON;
158
159#endif /* __KERNEL__ */
160
161#endif /* __KERNELCAPI_H__ */
diff --git a/include/linux/key-ui.h b/include/linux/key-ui.h
new file mode 100644
index 000000000000..60cc7b762e78
--- /dev/null
+++ b/include/linux/key-ui.h
@@ -0,0 +1,97 @@
1/* key-ui.h: key userspace interface stuff for use by keyfs
2 *
3 * Copyright (C) 2004 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
12#ifndef _LINUX_KEY_UI_H
13#define _LINUX_KEY_UI_H
14
15#include <linux/key.h>
16
17/* the key tree */
18extern struct rb_root key_serial_tree;
19extern spinlock_t key_serial_lock;
20
21/* required permissions */
22#define KEY_VIEW 0x01 /* require permission to view attributes */
23#define KEY_READ 0x02 /* require permission to read content */
24#define KEY_WRITE 0x04 /* require permission to update / modify */
25#define KEY_SEARCH 0x08 /* require permission to search (keyring) or find (key) */
26#define KEY_LINK 0x10 /* require permission to link */
27#define KEY_ALL 0x1f /* all the above permissions */
28
29/*
30 * the keyring payload contains a list of the keys to which the keyring is
31 * subscribed
32 */
33struct keyring_list {
34 unsigned maxkeys; /* max keys this list can hold */
35 unsigned nkeys; /* number of keys currently held */
36 struct key *keys[0];
37};
38
39
40/*
41 * check to see whether permission is granted to use a key in the desired way
42 */
43static inline int key_permission(const struct key *key, key_perm_t perm)
44{
45 key_perm_t kperm;
46
47 if (key->uid == current->fsuid)
48 kperm = key->perm >> 16;
49 else if (key->gid != -1 &&
50 key->perm & KEY_GRP_ALL &&
51 in_group_p(key->gid)
52 )
53 kperm = key->perm >> 8;
54 else
55 kperm = key->perm;
56
57 kperm = kperm & perm & KEY_ALL;
58
59 return kperm == perm;
60}
61
62/*
63 * check to see whether permission is granted to use a key in at least one of
64 * the desired ways
65 */
66static inline int key_any_permission(const struct key *key, key_perm_t perm)
67{
68 key_perm_t kperm;
69
70 if (key->uid == current->fsuid)
71 kperm = key->perm >> 16;
72 else if (key->gid != -1 &&
73 key->perm & KEY_GRP_ALL &&
74 in_group_p(key->gid)
75 )
76 kperm = key->perm >> 8;
77 else
78 kperm = key->perm;
79
80 kperm = kperm & perm & KEY_ALL;
81
82 return kperm != 0;
83}
84
85
86extern struct key *lookup_user_key(key_serial_t id, int create, int part,
87 key_perm_t perm);
88
89extern long join_session_keyring(const char *name);
90
91extern struct key_type *key_type_lookup(const char *type);
92extern void key_type_put(struct key_type *ktype);
93
94#define key_negative_timeout 60 /* default timeout on a negative key's existence */
95
96
97#endif /* _LINUX_KEY_UI_H */
diff --git a/include/linux/key.h b/include/linux/key.h
new file mode 100644
index 000000000000..6aa46d0e812f
--- /dev/null
+++ b/include/linux/key.h
@@ -0,0 +1,291 @@
1/* key.h: authentication token and access key management
2 *
3 * Copyright (C) 2004 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 *
12 * See Documentation/keys.txt for information on keys/keyrings.
13 */
14
15#ifndef _LINUX_KEY_H
16#define _LINUX_KEY_H
17
18#include <linux/types.h>
19#include <linux/list.h>
20#include <linux/rbtree.h>
21#include <linux/spinlock.h>
22#include <asm/atomic.h>
23
24#ifdef __KERNEL__
25
26/* key handle serial number */
27typedef int32_t key_serial_t;
28
29/* key handle permissions mask */
30typedef uint32_t key_perm_t;
31
32struct key;
33
34#ifdef CONFIG_KEYS
35
36#undef KEY_DEBUGGING
37
38#define KEY_USR_VIEW 0x00010000 /* user can view a key's attributes */
39#define KEY_USR_READ 0x00020000 /* user can read key payload / view keyring */
40#define KEY_USR_WRITE 0x00040000 /* user can update key payload / add link to keyring */
41#define KEY_USR_SEARCH 0x00080000 /* user can find a key in search / search a keyring */
42#define KEY_USR_LINK 0x00100000 /* user can create a link to a key/keyring */
43#define KEY_USR_ALL 0x001f0000
44
45#define KEY_GRP_VIEW 0x00000100 /* group permissions... */
46#define KEY_GRP_READ 0x00000200
47#define KEY_GRP_WRITE 0x00000400
48#define KEY_GRP_SEARCH 0x00000800
49#define KEY_GRP_LINK 0x00001000
50#define KEY_GRP_ALL 0x00001f00
51
52#define KEY_OTH_VIEW 0x00000001 /* third party permissions... */
53#define KEY_OTH_READ 0x00000002
54#define KEY_OTH_WRITE 0x00000004
55#define KEY_OTH_SEARCH 0x00000008
56#define KEY_OTH_LINK 0x00000010
57#define KEY_OTH_ALL 0x0000001f
58
59struct seq_file;
60struct user_struct;
61struct signal_struct;
62
63struct key_type;
64struct key_owner;
65struct keyring_list;
66struct keyring_name;
67
68/*****************************************************************************/
69/*
70 * authentication token / access credential / keyring
71 * - types of key include:
72 * - keyrings
73 * - disk encryption IDs
74 * - Kerberos TGTs and tickets
75 */
76struct key {
77 atomic_t usage; /* number of references */
78 key_serial_t serial; /* key serial number */
79 struct rb_node serial_node;
80 struct key_type *type; /* type of key */
81 rwlock_t lock; /* examination vs change lock */
82 struct rw_semaphore sem; /* change vs change sem */
83 struct key_user *user; /* owner of this key */
84 time_t expiry; /* time at which key expires (or 0) */
85 uid_t uid;
86 gid_t gid;
87 key_perm_t perm; /* access permissions */
88 unsigned short quotalen; /* length added to quota */
89 unsigned short datalen; /* payload data length */
90 unsigned short flags; /* status flags (change with lock writelocked) */
91#define KEY_FLAG_INSTANTIATED 0x00000001 /* set if key has been instantiated */
92#define KEY_FLAG_DEAD 0x00000002 /* set if key type has been deleted */
93#define KEY_FLAG_REVOKED 0x00000004 /* set if key had been revoked */
94#define KEY_FLAG_IN_QUOTA 0x00000008 /* set if key consumes quota */
95#define KEY_FLAG_USER_CONSTRUCT 0x00000010 /* set if key is being constructed in userspace */
96#define KEY_FLAG_NEGATIVE 0x00000020 /* set if key is negative */
97
98#ifdef KEY_DEBUGGING
99 unsigned magic;
100#define KEY_DEBUG_MAGIC 0x18273645u
101#define KEY_DEBUG_MAGIC_X 0xf8e9dacbu
102#endif
103
104 /* the description string
105 * - this is used to match a key against search criteria
106 * - this should be a printable string
107 * - eg: for krb5 AFS, this might be "afs@REDHAT.COM"
108 */
109 char *description;
110
111 /* type specific data
112 * - this is used by the keyring type to index the name
113 */
114 union {
115 struct list_head link;
116 } type_data;
117
118 /* key data
119 * - this is used to hold the data actually used in cryptography or
120 * whatever
121 */
122 union {
123 unsigned long value;
124 void *data;
125 struct keyring_list *subscriptions;
126 } payload;
127};
128
129/*****************************************************************************/
130/*
131 * kernel managed key type definition
132 */
133struct key_type {
134 /* name of the type */
135 const char *name;
136
137 /* default payload length for quota precalculation (optional)
138 * - this can be used instead of calling key_payload_reserve(), that
139 * function only needs to be called if the real datalen is different
140 */
141 size_t def_datalen;
142
143 /* instantiate a key of this type
144 * - this method should call key_payload_reserve() to determine if the
145 * user's quota will hold the payload
146 */
147 int (*instantiate)(struct key *key, const void *data, size_t datalen);
148
149 /* duplicate a key of this type (optional)
150 * - the source key will be locked against change
151 * - the new description will be attached
152 * - the quota will have been adjusted automatically from
153 * source->quotalen
154 */
155 int (*duplicate)(struct key *key, const struct key *source);
156
157 /* update a key of this type (optional)
158 * - this method should call key_payload_reserve() to recalculate the
159 * quota consumption
160 * - the key must be locked against read when modifying
161 */
162 int (*update)(struct key *key, const void *data, size_t datalen);
163
164 /* match a key against a description */
165 int (*match)(const struct key *key, const void *desc);
166
167 /* clear the data from a key (optional) */
168 void (*destroy)(struct key *key);
169
170 /* describe a key */
171 void (*describe)(const struct key *key, struct seq_file *p);
172
173 /* read a key's data (optional)
174 * - permission checks will be done by the caller
175 * - the key's semaphore will be readlocked by the caller
176 * - should return the amount of data that could be read, no matter how
177 * much is copied into the buffer
178 * - shouldn't do the copy if the buffer is NULL
179 */
180 long (*read)(const struct key *key, char __user *buffer, size_t buflen);
181
182 /* internal fields */
183 struct list_head link; /* link in types list */
184};
185
186extern struct key_type key_type_keyring;
187
188extern int register_key_type(struct key_type *ktype);
189extern void unregister_key_type(struct key_type *ktype);
190
191extern struct key *key_alloc(struct key_type *type,
192 const char *desc,
193 uid_t uid, gid_t gid, key_perm_t perm,
194 int not_in_quota);
195extern int key_payload_reserve(struct key *key, size_t datalen);
196extern int key_instantiate_and_link(struct key *key,
197 const void *data,
198 size_t datalen,
199 struct key *keyring);
200extern int key_negate_and_link(struct key *key,
201 unsigned timeout,
202 struct key *keyring);
203extern void key_revoke(struct key *key);
204extern void key_put(struct key *key);
205
206static inline struct key *key_get(struct key *key)
207{
208 if (key)
209 atomic_inc(&key->usage);
210 return key;
211}
212
213extern struct key *request_key(struct key_type *type,
214 const char *description,
215 const char *callout_info);
216
217extern int key_validate(struct key *key);
218
219extern struct key *key_create_or_update(struct key *keyring,
220 const char *type,
221 const char *description,
222 const void *payload,
223 size_t plen,
224 int not_in_quota);
225
226extern int key_update(struct key *key,
227 const void *payload,
228 size_t plen);
229
230extern int key_link(struct key *keyring,
231 struct key *key);
232
233extern int key_unlink(struct key *keyring,
234 struct key *key);
235
236extern struct key *keyring_alloc(const char *description, uid_t uid, gid_t gid,
237 int not_in_quota, struct key *dest);
238
239extern int keyring_clear(struct key *keyring);
240
241extern struct key *keyring_search(struct key *keyring,
242 struct key_type *type,
243 const char *description);
244
245extern struct key *search_process_keyrings(struct key_type *type,
246 const char *description);
247
248extern int keyring_add_key(struct key *keyring,
249 struct key *key);
250
251extern struct key *key_lookup(key_serial_t id);
252
253#define key_serial(key) ((key) ? (key)->serial : 0)
254
255/*
256 * the userspace interface
257 */
258extern struct key root_user_keyring, root_session_keyring;
259extern int alloc_uid_keyring(struct user_struct *user);
260extern void switch_uid_keyring(struct user_struct *new_user);
261extern int copy_keys(unsigned long clone_flags, struct task_struct *tsk);
262extern int copy_thread_group_keys(struct task_struct *tsk);
263extern void exit_keys(struct task_struct *tsk);
264extern void exit_thread_group_keys(struct signal_struct *tg);
265extern int suid_keys(struct task_struct *tsk);
266extern int exec_keys(struct task_struct *tsk);
267extern void key_fsuid_changed(struct task_struct *tsk);
268extern void key_fsgid_changed(struct task_struct *tsk);
269extern void key_init(void);
270
271#else /* CONFIG_KEYS */
272
273#define key_validate(k) 0
274#define key_serial(k) 0
275#define key_get(k) NULL
276#define key_put(k) do { } while(0)
277#define alloc_uid_keyring(u) 0
278#define switch_uid_keyring(u) do { } while(0)
279#define copy_keys(f,t) 0
280#define copy_thread_group_keys(t) 0
281#define exit_keys(t) do { } while(0)
282#define exit_thread_group_keys(tg) do { } while(0)
283#define suid_keys(t) do { } while(0)
284#define exec_keys(t) do { } while(0)
285#define key_fsuid_changed(t) do { } while(0)
286#define key_fsgid_changed(t) do { } while(0)
287#define key_init() do { } while(0)
288
289#endif /* CONFIG_KEYS */
290#endif /* __KERNEL__ */
291#endif /* _LINUX_KEY_H */
diff --git a/include/linux/keyboard.h b/include/linux/keyboard.h
new file mode 100644
index 000000000000..08488042d74a
--- /dev/null
+++ b/include/linux/keyboard.h
@@ -0,0 +1,431 @@
1#ifndef __LINUX_KEYBOARD_H
2#define __LINUX_KEYBOARD_H
3
4#include <linux/wait.h>
5
6#define KG_SHIFT 0
7#define KG_CTRL 2
8#define KG_ALT 3
9#define KG_ALTGR 1
10#define KG_SHIFTL 4
11#define KG_KANASHIFT 4
12#define KG_SHIFTR 5
13#define KG_CTRLL 6
14#define KG_CTRLR 7
15#define KG_CAPSSHIFT 8
16
17#define NR_SHIFT 9
18
19#define NR_KEYS 256
20#define MAX_NR_KEYMAPS 256
21/* This means 128Kb if all keymaps are allocated. Only the superuser
22 may increase the number of keymaps beyond MAX_NR_OF_USER_KEYMAPS. */
23#define MAX_NR_OF_USER_KEYMAPS 256 /* should be at least 7 */
24
25#ifdef __KERNEL__
26extern const int NR_TYPES;
27extern const int max_vals[];
28extern unsigned short *key_maps[MAX_NR_KEYMAPS];
29extern unsigned short plain_map[NR_KEYS];
30#endif
31
32#define MAX_NR_FUNC 256 /* max nr of strings assigned to keys */
33
34#define KT_LATIN 0 /* we depend on this being zero */
35#define KT_LETTER 11 /* symbol that can be acted upon by CapsLock */
36#define KT_FN 1
37#define KT_SPEC 2
38#define KT_PAD 3
39#define KT_DEAD 4
40#define KT_CONS 5
41#define KT_CUR 6
42#define KT_SHIFT 7
43#define KT_META 8
44#define KT_ASCII 9
45#define KT_LOCK 10
46#define KT_SLOCK 12
47
48#define K(t,v) (((t)<<8)|(v))
49#define KTYP(x) ((x) >> 8)
50#define KVAL(x) ((x) & 0xff)
51
52#define K_F1 K(KT_FN,0)
53#define K_F2 K(KT_FN,1)
54#define K_F3 K(KT_FN,2)
55#define K_F4 K(KT_FN,3)
56#define K_F5 K(KT_FN,4)
57#define K_F6 K(KT_FN,5)
58#define K_F7 K(KT_FN,6)
59#define K_F8 K(KT_FN,7)
60#define K_F9 K(KT_FN,8)
61#define K_F10 K(KT_FN,9)
62#define K_F11 K(KT_FN,10)
63#define K_F12 K(KT_FN,11)
64#define K_F13 K(KT_FN,12)
65#define K_F14 K(KT_FN,13)
66#define K_F15 K(KT_FN,14)
67#define K_F16 K(KT_FN,15)
68#define K_F17 K(KT_FN,16)
69#define K_F18 K(KT_FN,17)
70#define K_F19 K(KT_FN,18)
71#define K_F20 K(KT_FN,19)
72#define K_FIND K(KT_FN,20)
73#define K_INSERT K(KT_FN,21)
74#define K_REMOVE K(KT_FN,22)
75#define K_SELECT K(KT_FN,23)
76#define K_PGUP K(KT_FN,24) /* PGUP is a synonym for PRIOR */
77#define K_PGDN K(KT_FN,25) /* PGDN is a synonym for NEXT */
78#define K_MACRO K(KT_FN,26)
79#define K_HELP K(KT_FN,27)
80#define K_DO K(KT_FN,28)
81#define K_PAUSE K(KT_FN,29)
82#define K_F21 K(KT_FN,30)
83#define K_F22 K(KT_FN,31)
84#define K_F23 K(KT_FN,32)
85#define K_F24 K(KT_FN,33)
86#define K_F25 K(KT_FN,34)
87#define K_F26 K(KT_FN,35)
88#define K_F27 K(KT_FN,36)
89#define K_F28 K(KT_FN,37)
90#define K_F29 K(KT_FN,38)
91#define K_F30 K(KT_FN,39)
92#define K_F31 K(KT_FN,40)
93#define K_F32 K(KT_FN,41)
94#define K_F33 K(KT_FN,42)
95#define K_F34 K(KT_FN,43)
96#define K_F35 K(KT_FN,44)
97#define K_F36 K(KT_FN,45)
98#define K_F37 K(KT_FN,46)
99#define K_F38 K(KT_FN,47)
100#define K_F39 K(KT_FN,48)
101#define K_F40 K(KT_FN,49)
102#define K_F41 K(KT_FN,50)
103#define K_F42 K(KT_FN,51)
104#define K_F43 K(KT_FN,52)
105#define K_F44 K(KT_FN,53)
106#define K_F45 K(KT_FN,54)
107#define K_F46 K(KT_FN,55)
108#define K_F47 K(KT_FN,56)
109#define K_F48 K(KT_FN,57)
110#define K_F49 K(KT_FN,58)
111#define K_F50 K(KT_FN,59)
112#define K_F51 K(KT_FN,60)
113#define K_F52 K(KT_FN,61)
114#define K_F53 K(KT_FN,62)
115#define K_F54 K(KT_FN,63)
116#define K_F55 K(KT_FN,64)
117#define K_F56 K(KT_FN,65)
118#define K_F57 K(KT_FN,66)
119#define K_F58 K(KT_FN,67)
120#define K_F59 K(KT_FN,68)
121#define K_F60 K(KT_FN,69)
122#define K_F61 K(KT_FN,70)
123#define K_F62 K(KT_FN,71)
124#define K_F63 K(KT_FN,72)
125#define K_F64 K(KT_FN,73)
126#define K_F65 K(KT_FN,74)
127#define K_F66 K(KT_FN,75)
128#define K_F67 K(KT_FN,76)
129#define K_F68 K(KT_FN,77)
130#define K_F69 K(KT_FN,78)
131#define K_F70 K(KT_FN,79)
132#define K_F71 K(KT_FN,80)
133#define K_F72 K(KT_FN,81)
134#define K_F73 K(KT_FN,82)
135#define K_F74 K(KT_FN,83)
136#define K_F75 K(KT_FN,84)
137#define K_F76 K(KT_FN,85)
138#define K_F77 K(KT_FN,86)
139#define K_F78 K(KT_FN,87)
140#define K_F79 K(KT_FN,88)
141#define K_F80 K(KT_FN,89)
142#define K_F81 K(KT_FN,90)
143#define K_F82 K(KT_FN,91)
144#define K_F83 K(KT_FN,92)
145#define K_F84 K(KT_FN,93)
146#define K_F85 K(KT_FN,94)
147#define K_F86 K(KT_FN,95)
148#define K_F87 K(KT_FN,96)
149#define K_F88 K(KT_FN,97)
150#define K_F89 K(KT_FN,98)
151#define K_F90 K(KT_FN,99)
152#define K_F91 K(KT_FN,100)
153#define K_F92 K(KT_FN,101)
154#define K_F93 K(KT_FN,102)
155#define K_F94 K(KT_FN,103)
156#define K_F95 K(KT_FN,104)
157#define K_F96 K(KT_FN,105)
158#define K_F97 K(KT_FN,106)
159#define K_F98 K(KT_FN,107)
160#define K_F99 K(KT_FN,108)
161#define K_F100 K(KT_FN,109)
162#define K_F101 K(KT_FN,110)
163#define K_F102 K(KT_FN,111)
164#define K_F103 K(KT_FN,112)
165#define K_F104 K(KT_FN,113)
166#define K_F105 K(KT_FN,114)
167#define K_F106 K(KT_FN,115)
168#define K_F107 K(KT_FN,116)
169#define K_F108 K(KT_FN,117)
170#define K_F109 K(KT_FN,118)
171#define K_F110 K(KT_FN,119)
172#define K_F111 K(KT_FN,120)
173#define K_F112 K(KT_FN,121)
174#define K_F113 K(KT_FN,122)
175#define K_F114 K(KT_FN,123)
176#define K_F115 K(KT_FN,124)
177#define K_F116 K(KT_FN,125)
178#define K_F117 K(KT_FN,126)
179#define K_F118 K(KT_FN,127)
180#define K_F119 K(KT_FN,128)
181#define K_F120 K(KT_FN,129)
182#define K_F121 K(KT_FN,130)
183#define K_F122 K(KT_FN,131)
184#define K_F123 K(KT_FN,132)
185#define K_F124 K(KT_FN,133)
186#define K_F125 K(KT_FN,134)
187#define K_F126 K(KT_FN,135)
188#define K_F127 K(KT_FN,136)
189#define K_F128 K(KT_FN,137)
190#define K_F129 K(KT_FN,138)
191#define K_F130 K(KT_FN,139)
192#define K_F131 K(KT_FN,140)
193#define K_F132 K(KT_FN,141)
194#define K_F133 K(KT_FN,142)
195#define K_F134 K(KT_FN,143)
196#define K_F135 K(KT_FN,144)
197#define K_F136 K(KT_FN,145)
198#define K_F137 K(KT_FN,146)
199#define K_F138 K(KT_FN,147)
200#define K_F139 K(KT_FN,148)
201#define K_F140 K(KT_FN,149)
202#define K_F141 K(KT_FN,150)
203#define K_F142 K(KT_FN,151)
204#define K_F143 K(KT_FN,152)
205#define K_F144 K(KT_FN,153)
206#define K_F145 K(KT_FN,154)
207#define K_F146 K(KT_FN,155)
208#define K_F147 K(KT_FN,156)
209#define K_F148 K(KT_FN,157)
210#define K_F149 K(KT_FN,158)
211#define K_F150 K(KT_FN,159)
212#define K_F151 K(KT_FN,160)
213#define K_F152 K(KT_FN,161)
214#define K_F153 K(KT_FN,162)
215#define K_F154 K(KT_FN,163)
216#define K_F155 K(KT_FN,164)
217#define K_F156 K(KT_FN,165)
218#define K_F157 K(KT_FN,166)
219#define K_F158 K(KT_FN,167)
220#define K_F159 K(KT_FN,168)
221#define K_F160 K(KT_FN,169)
222#define K_F161 K(KT_FN,170)
223#define K_F162 K(KT_FN,171)
224#define K_F163 K(KT_FN,172)
225#define K_F164 K(KT_FN,173)
226#define K_F165 K(KT_FN,174)
227#define K_F166 K(KT_FN,175)
228#define K_F167 K(KT_FN,176)
229#define K_F168 K(KT_FN,177)
230#define K_F169 K(KT_FN,178)
231#define K_F170 K(KT_FN,179)
232#define K_F171 K(KT_FN,180)
233#define K_F172 K(KT_FN,181)
234#define K_F173 K(KT_FN,182)
235#define K_F174 K(KT_FN,183)
236#define K_F175 K(KT_FN,184)
237#define K_F176 K(KT_FN,185)
238#define K_F177 K(KT_FN,186)
239#define K_F178 K(KT_FN,187)
240#define K_F179 K(KT_FN,188)
241#define K_F180 K(KT_FN,189)
242#define K_F181 K(KT_FN,190)
243#define K_F182 K(KT_FN,191)
244#define K_F183 K(KT_FN,192)
245#define K_F184 K(KT_FN,193)
246#define K_F185 K(KT_FN,194)
247#define K_F186 K(KT_FN,195)
248#define K_F187 K(KT_FN,196)
249#define K_F188 K(KT_FN,197)
250#define K_F189 K(KT_FN,198)
251#define K_F190 K(KT_FN,199)
252#define K_F191 K(KT_FN,200)
253#define K_F192 K(KT_FN,201)
254#define K_F193 K(KT_FN,202)
255#define K_F194 K(KT_FN,203)
256#define K_F195 K(KT_FN,204)
257#define K_F196 K(KT_FN,205)
258#define K_F197 K(KT_FN,206)
259#define K_F198 K(KT_FN,207)
260#define K_F199 K(KT_FN,208)
261#define K_F200 K(KT_FN,209)
262#define K_F201 K(KT_FN,210)
263#define K_F202 K(KT_FN,211)
264#define K_F203 K(KT_FN,212)
265#define K_F204 K(KT_FN,213)
266#define K_F205 K(KT_FN,214)
267#define K_F206 K(KT_FN,215)
268#define K_F207 K(KT_FN,216)
269#define K_F208 K(KT_FN,217)
270#define K_F209 K(KT_FN,218)
271#define K_F210 K(KT_FN,219)
272#define K_F211 K(KT_FN,220)
273#define K_F212 K(KT_FN,221)
274#define K_F213 K(KT_FN,222)
275#define K_F214 K(KT_FN,223)
276#define K_F215 K(KT_FN,224)
277#define K_F216 K(KT_FN,225)
278#define K_F217 K(KT_FN,226)
279#define K_F218 K(KT_FN,227)
280#define K_F219 K(KT_FN,228)
281#define K_F220 K(KT_FN,229)
282#define K_F221 K(KT_FN,230)
283#define K_F222 K(KT_FN,231)
284#define K_F223 K(KT_FN,232)
285#define K_F224 K(KT_FN,233)
286#define K_F225 K(KT_FN,234)
287#define K_F226 K(KT_FN,235)
288#define K_F227 K(KT_FN,236)
289#define K_F228 K(KT_FN,237)
290#define K_F229 K(KT_FN,238)
291#define K_F230 K(KT_FN,239)
292#define K_F231 K(KT_FN,240)
293#define K_F232 K(KT_FN,241)
294#define K_F233 K(KT_FN,242)
295#define K_F234 K(KT_FN,243)
296#define K_F235 K(KT_FN,244)
297#define K_F236 K(KT_FN,245)
298#define K_F237 K(KT_FN,246)
299#define K_F238 K(KT_FN,247)
300#define K_F239 K(KT_FN,248)
301#define K_F240 K(KT_FN,249)
302#define K_F241 K(KT_FN,250)
303#define K_F242 K(KT_FN,251)
304#define K_F243 K(KT_FN,252)
305#define K_F244 K(KT_FN,253)
306#define K_F245 K(KT_FN,254)
307#define K_UNDO K(KT_FN,255)
308
309
310#define K_HOLE K(KT_SPEC,0)
311#define K_ENTER K(KT_SPEC,1)
312#define K_SH_REGS K(KT_SPEC,2)
313#define K_SH_MEM K(KT_SPEC,3)
314#define K_SH_STAT K(KT_SPEC,4)
315#define K_BREAK K(KT_SPEC,5)
316#define K_CONS K(KT_SPEC,6)
317#define K_CAPS K(KT_SPEC,7)
318#define K_NUM K(KT_SPEC,8)
319#define K_HOLD K(KT_SPEC,9)
320#define K_SCROLLFORW K(KT_SPEC,10)
321#define K_SCROLLBACK K(KT_SPEC,11)
322#define K_BOOT K(KT_SPEC,12)
323#define K_CAPSON K(KT_SPEC,13)
324#define K_COMPOSE K(KT_SPEC,14)
325#define K_SAK K(KT_SPEC,15)
326#define K_DECRCONSOLE K(KT_SPEC,16)
327#define K_INCRCONSOLE K(KT_SPEC,17)
328#define K_SPAWNCONSOLE K(KT_SPEC,18)
329#define K_BARENUMLOCK K(KT_SPEC,19)
330
331#define K_ALLOCATED K(KT_SPEC,126) /* dynamically allocated keymap */
332#define K_NOSUCHMAP K(KT_SPEC,127) /* returned by KDGKBENT */
333
334#define K_P0 K(KT_PAD,0)
335#define K_P1 K(KT_PAD,1)
336#define K_P2 K(KT_PAD,2)
337#define K_P3 K(KT_PAD,3)
338#define K_P4 K(KT_PAD,4)
339#define K_P5 K(KT_PAD,5)
340#define K_P6 K(KT_PAD,6)
341#define K_P7 K(KT_PAD,7)
342#define K_P8 K(KT_PAD,8)
343#define K_P9 K(KT_PAD,9)
344#define K_PPLUS K(KT_PAD,10) /* key-pad plus */
345#define K_PMINUS K(KT_PAD,11) /* key-pad minus */
346#define K_PSTAR K(KT_PAD,12) /* key-pad asterisk (star) */
347#define K_PSLASH K(KT_PAD,13) /* key-pad slash */
348#define K_PENTER K(KT_PAD,14) /* key-pad enter */
349#define K_PCOMMA K(KT_PAD,15) /* key-pad comma: kludge... */
350#define K_PDOT K(KT_PAD,16) /* key-pad dot (period): kludge... */
351#define K_PPLUSMINUS K(KT_PAD,17) /* key-pad plus/minus */
352#define K_PPARENL K(KT_PAD,18) /* key-pad left parenthesis */
353#define K_PPARENR K(KT_PAD,19) /* key-pad right parenthesis */
354
355#define NR_PAD 20
356
357#define K_DGRAVE K(KT_DEAD,0)
358#define K_DACUTE K(KT_DEAD,1)
359#define K_DCIRCM K(KT_DEAD,2)
360#define K_DTILDE K(KT_DEAD,3)
361#define K_DDIERE K(KT_DEAD,4)
362#define K_DCEDIL K(KT_DEAD,5)
363
364#define NR_DEAD 6
365
366#define K_DOWN K(KT_CUR,0)
367#define K_LEFT K(KT_CUR,1)
368#define K_RIGHT K(KT_CUR,2)
369#define K_UP K(KT_CUR,3)
370
371#define K_SHIFT K(KT_SHIFT,KG_SHIFT)
372#define K_CTRL K(KT_SHIFT,KG_CTRL)
373#define K_ALT K(KT_SHIFT,KG_ALT)
374#define K_ALTGR K(KT_SHIFT,KG_ALTGR)
375#define K_SHIFTL K(KT_SHIFT,KG_SHIFTL)
376#define K_SHIFTR K(KT_SHIFT,KG_SHIFTR)
377#define K_CTRLL K(KT_SHIFT,KG_CTRLL)
378#define K_CTRLR K(KT_SHIFT,KG_CTRLR)
379#define K_CAPSSHIFT K(KT_SHIFT,KG_CAPSSHIFT)
380
381#define K_ASC0 K(KT_ASCII,0)
382#define K_ASC1 K(KT_ASCII,1)
383#define K_ASC2 K(KT_ASCII,2)
384#define K_ASC3 K(KT_ASCII,3)
385#define K_ASC4 K(KT_ASCII,4)
386#define K_ASC5 K(KT_ASCII,5)
387#define K_ASC6 K(KT_ASCII,6)
388#define K_ASC7 K(KT_ASCII,7)
389#define K_ASC8 K(KT_ASCII,8)
390#define K_ASC9 K(KT_ASCII,9)
391#define K_HEX0 K(KT_ASCII,10)
392#define K_HEX1 K(KT_ASCII,11)
393#define K_HEX2 K(KT_ASCII,12)
394#define K_HEX3 K(KT_ASCII,13)
395#define K_HEX4 K(KT_ASCII,14)
396#define K_HEX5 K(KT_ASCII,15)
397#define K_HEX6 K(KT_ASCII,16)
398#define K_HEX7 K(KT_ASCII,17)
399#define K_HEX8 K(KT_ASCII,18)
400#define K_HEX9 K(KT_ASCII,19)
401#define K_HEXa K(KT_ASCII,20)
402#define K_HEXb K(KT_ASCII,21)
403#define K_HEXc K(KT_ASCII,22)
404#define K_HEXd K(KT_ASCII,23)
405#define K_HEXe K(KT_ASCII,24)
406#define K_HEXf K(KT_ASCII,25)
407
408#define NR_ASCII 26
409
410#define K_SHIFTLOCK K(KT_LOCK,KG_SHIFT)
411#define K_CTRLLOCK K(KT_LOCK,KG_CTRL)
412#define K_ALTLOCK K(KT_LOCK,KG_ALT)
413#define K_ALTGRLOCK K(KT_LOCK,KG_ALTGR)
414#define K_SHIFTLLOCK K(KT_LOCK,KG_SHIFTL)
415#define K_SHIFTRLOCK K(KT_LOCK,KG_SHIFTR)
416#define K_CTRLLLOCK K(KT_LOCK,KG_CTRLL)
417#define K_CTRLRLOCK K(KT_LOCK,KG_CTRLR)
418
419#define K_SHIFT_SLOCK K(KT_SLOCK,KG_SHIFT)
420#define K_CTRL_SLOCK K(KT_SLOCK,KG_CTRL)
421#define K_ALT_SLOCK K(KT_SLOCK,KG_ALT)
422#define K_ALTGR_SLOCK K(KT_SLOCK,KG_ALTGR)
423#define K_SHIFTL_SLOCK K(KT_SLOCK,KG_SHIFTL)
424#define K_SHIFTR_SLOCK K(KT_SLOCK,KG_SHIFTR)
425#define K_CTRLL_SLOCK K(KT_SLOCK,KG_CTRLL)
426#define K_CTRLR_SLOCK K(KT_SLOCK,KG_CTRLR)
427
428#define NR_LOCK 8
429
430#define MAX_DIACR 256
431#endif
diff --git a/include/linux/keyctl.h b/include/linux/keyctl.h
new file mode 100644
index 000000000000..381dedc370a3
--- /dev/null
+++ b/include/linux/keyctl.h
@@ -0,0 +1,39 @@
1/* keyctl.h: keyctl command IDs
2 *
3 * Copyright (C) 2004 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
12#ifndef _LINUX_KEYCTL_H
13#define _LINUX_KEYCTL_H
14
15/* special process keyring shortcut IDs */
16#define KEY_SPEC_THREAD_KEYRING -1 /* - key ID for thread-specific keyring */
17#define KEY_SPEC_PROCESS_KEYRING -2 /* - key ID for process-specific keyring */
18#define KEY_SPEC_SESSION_KEYRING -3 /* - key ID for session-specific keyring */
19#define KEY_SPEC_USER_KEYRING -4 /* - key ID for UID-specific keyring */
20#define KEY_SPEC_USER_SESSION_KEYRING -5 /* - key ID for UID-session keyring */
21#define KEY_SPEC_GROUP_KEYRING -6 /* - key ID for GID-specific keyring */
22
23/* keyctl commands */
24#define KEYCTL_GET_KEYRING_ID 0 /* ask for a keyring's ID */
25#define KEYCTL_JOIN_SESSION_KEYRING 1 /* join or start named session keyring */
26#define KEYCTL_UPDATE 2 /* update a key */
27#define KEYCTL_REVOKE 3 /* revoke a key */
28#define KEYCTL_CHOWN 4 /* set ownership of a key */
29#define KEYCTL_SETPERM 5 /* set perms on a key */
30#define KEYCTL_DESCRIBE 6 /* describe a key */
31#define KEYCTL_CLEAR 7 /* clear contents of a keyring */
32#define KEYCTL_LINK 8 /* link a key into a keyring */
33#define KEYCTL_UNLINK 9 /* unlink a key from a keyring */
34#define KEYCTL_SEARCH 10 /* search for a key in a keyring */
35#define KEYCTL_READ 11 /* read a key or keyring's contents */
36#define KEYCTL_INSTANTIATE 12 /* instantiate a partially constructed key */
37#define KEYCTL_NEGATE 13 /* negate a partially constructed key */
38
39#endif /* _LINUX_KEYCTL_H */
diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h
new file mode 100644
index 000000000000..c27cd428d269
--- /dev/null
+++ b/include/linux/kfifo.h
@@ -0,0 +1,157 @@
1/*
2 * A simple kernel FIFO implementation.
3 *
4 * Copyright (C) 2004 Stelian Pop <stelian@popies.net>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 */
21#ifndef _LINUX_KFIFO_H
22#define _LINUX_KFIFO_H
23
24#ifdef __KERNEL__
25
26#include <linux/kernel.h>
27#include <linux/spinlock.h>
28
29struct kfifo {
30 unsigned char *buffer; /* the buffer holding the data */
31 unsigned int size; /* the size of the allocated buffer */
32 unsigned int in; /* data is added at offset (in % size) */
33 unsigned int out; /* data is extracted from off. (out % size) */
34 spinlock_t *lock; /* protects concurrent modifications */
35};
36
37extern struct kfifo *kfifo_init(unsigned char *buffer, unsigned int size,
38 unsigned int __nocast gfp_mask, spinlock_t *lock);
39extern struct kfifo *kfifo_alloc(unsigned int size, unsigned int __nocast gfp_mask,
40 spinlock_t *lock);
41extern void kfifo_free(struct kfifo *fifo);
42extern unsigned int __kfifo_put(struct kfifo *fifo,
43 unsigned char *buffer, unsigned int len);
44extern unsigned int __kfifo_get(struct kfifo *fifo,
45 unsigned char *buffer, unsigned int len);
46
47/**
48 * __kfifo_reset - removes the entire FIFO contents, no locking version
49 * @fifo: the fifo to be emptied.
50 */
51static inline void __kfifo_reset(struct kfifo *fifo)
52{
53 fifo->in = fifo->out = 0;
54}
55
56/**
57 * kfifo_reset - removes the entire FIFO contents
58 * @fifo: the fifo to be emptied.
59 */
60static inline void kfifo_reset(struct kfifo *fifo)
61{
62 unsigned long flags;
63
64 spin_lock_irqsave(fifo->lock, flags);
65
66 __kfifo_reset(fifo);
67
68 spin_unlock_irqrestore(fifo->lock, flags);
69}
70
71/**
72 * kfifo_put - puts some data into the FIFO
73 * @fifo: the fifo to be used.
74 * @buffer: the data to be added.
75 * @len: the length of the data to be added.
76 *
77 * This function copies at most 'len' bytes from the 'buffer' into
78 * the FIFO depending on the free space, and returns the number of
79 * bytes copied.
80 */
81static inline unsigned int kfifo_put(struct kfifo *fifo,
82 unsigned char *buffer, unsigned int len)
83{
84 unsigned long flags;
85 unsigned int ret;
86
87 spin_lock_irqsave(fifo->lock, flags);
88
89 ret = __kfifo_put(fifo, buffer, len);
90
91 spin_unlock_irqrestore(fifo->lock, flags);
92
93 return ret;
94}
95
96/**
97 * kfifo_get - gets some data from the FIFO
98 * @fifo: the fifo to be used.
99 * @buffer: where the data must be copied.
100 * @len: the size of the destination buffer.
101 *
102 * This function copies at most 'len' bytes from the FIFO into the
103 * 'buffer' and returns the number of copied bytes.
104 */
105static inline unsigned int kfifo_get(struct kfifo *fifo,
106 unsigned char *buffer, unsigned int len)
107{
108 unsigned long flags;
109 unsigned int ret;
110
111 spin_lock_irqsave(fifo->lock, flags);
112
113 ret = __kfifo_get(fifo, buffer, len);
114
115 /*
116 * optimization: if the FIFO is empty, set the indices to 0
117 * so we don't wrap the next time
118 */
119 if (fifo->in == fifo->out)
120 fifo->in = fifo->out = 0;
121
122 spin_unlock_irqrestore(fifo->lock, flags);
123
124 return ret;
125}
126
127/**
128 * __kfifo_len - returns the number of bytes available in the FIFO, no locking version
129 * @fifo: the fifo to be used.
130 */
131static inline unsigned int __kfifo_len(struct kfifo *fifo)
132{
133 return fifo->in - fifo->out;
134}
135
136/**
137 * kfifo_len - returns the number of bytes available in the FIFO
138 * @fifo: the fifo to be used.
139 */
140static inline unsigned int kfifo_len(struct kfifo *fifo)
141{
142 unsigned long flags;
143 unsigned int ret;
144
145 spin_lock_irqsave(fifo->lock, flags);
146
147 ret = __kfifo_len(fifo);
148
149 spin_unlock_irqrestore(fifo->lock, flags);
150
151 return ret;
152}
153
154#else
155#warning "don't include kernel headers in userspace"
156#endif /* __KERNEL__ */
157#endif
diff --git a/include/linux/kmalloc_sizes.h b/include/linux/kmalloc_sizes.h
new file mode 100644
index 000000000000..d82d4c05c12d
--- /dev/null
+++ b/include/linux/kmalloc_sizes.h
@@ -0,0 +1,33 @@
1#if (PAGE_SIZE == 4096)
2 CACHE(32)
3#endif
4 CACHE(64)
5#if L1_CACHE_BYTES < 64
6 CACHE(96)
7#endif
8 CACHE(128)
9#if L1_CACHE_BYTES < 128
10 CACHE(192)
11#endif
12 CACHE(256)
13 CACHE(512)
14 CACHE(1024)
15 CACHE(2048)
16 CACHE(4096)
17 CACHE(8192)
18 CACHE(16384)
19 CACHE(32768)
20 CACHE(65536)
21 CACHE(131072)
22#ifndef CONFIG_MMU
23 CACHE(262144)
24 CACHE(524288)
25 CACHE(1048576)
26#ifdef CONFIG_LARGE_ALLOCS
27 CACHE(2097152)
28 CACHE(4194304)
29 CACHE(8388608)
30 CACHE(16777216)
31 CACHE(33554432)
32#endif /* CONFIG_LARGE_ALLOCS */
33#endif /* CONFIG_MMU */
diff --git a/include/linux/kmod.h b/include/linux/kmod.h
new file mode 100644
index 000000000000..95d0e4b0814d
--- /dev/null
+++ b/include/linux/kmod.h
@@ -0,0 +1,40 @@
1#ifndef __LINUX_KMOD_H__
2#define __LINUX_KMOD_H__
3
4/*
5 * include/linux/kmod.h
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#include <linux/config.h>
23#include <linux/errno.h>
24#include <linux/compiler.h>
25
26#define KMOD_PATH_LEN 256
27
28#ifdef CONFIG_KMOD
29/* modprobe exit status on success, -ve on error. Return value
30 * usually useless though. */
31extern int request_module(const char * name, ...) __attribute__ ((format (printf, 1, 2)));
32#else
33static inline int request_module(const char * name, ...) { return -ENOSYS; }
34#endif
35
36#define try_then_request_module(x, mod...) ((x) ?: (request_module(mod), (x)))
37extern int call_usermodehelper(char *path, char *argv[], char *envp[], int wait);
38extern void usermodehelper_init(void);
39
40#endif /* __LINUX_KMOD_H__ */
diff --git a/include/linux/kobj_map.h b/include/linux/kobj_map.h
new file mode 100644
index 000000000000..b6cc10bf8dfc
--- /dev/null
+++ b/include/linux/kobj_map.h
@@ -0,0 +1,12 @@
1#ifdef __KERNEL__
2
3typedef struct kobject *kobj_probe_t(dev_t, int *, void *);
4struct kobj_map;
5
6int kobj_map(struct kobj_map *, dev_t, unsigned long, struct module *,
7 kobj_probe_t *, int (*)(dev_t, void *), void *);
8void kobj_unmap(struct kobj_map *, dev_t, unsigned long);
9struct kobject *kobj_lookup(struct kobj_map *, dev_t, int *);
10struct kobj_map *kobj_map_init(kobj_probe_t *, struct semaphore *);
11
12#endif
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
new file mode 100644
index 000000000000..765d660d3bea
--- /dev/null
+++ b/include/linux/kobject.h
@@ -0,0 +1,259 @@
1/*
2 * kobject.h - generic kernel object infrastructure.
3 *
4 * Copyright (c) 2002-2003 Patrick Mochel
5 * Copyright (c) 2002-2003 Open Source Development Labs
6 *
7 * This file is released under the GPLv2.
8 *
9 *
10 * Please read Documentation/kobject.txt before using the kobject
11 * interface, ESPECIALLY the parts about reference counts and object
12 * destructors.
13 */
14
15#ifndef _KOBJECT_H_
16#define _KOBJECT_H_
17
18#ifdef __KERNEL__
19
20#include <linux/types.h>
21#include <linux/list.h>
22#include <linux/sysfs.h>
23#include <linux/spinlock.h>
24#include <linux/rwsem.h>
25#include <linux/kref.h>
26#include <linux/kobject_uevent.h>
27#include <linux/kernel.h>
28#include <asm/atomic.h>
29
30#define KOBJ_NAME_LEN 20
31
32/* counter to tag the hotplug event, read only except for the kobject core */
33extern u64 hotplug_seqnum;
34
35struct kobject {
36 char * k_name;
37 char name[KOBJ_NAME_LEN];
38 struct kref kref;
39 struct list_head entry;
40 struct kobject * parent;
41 struct kset * kset;
42 struct kobj_type * ktype;
43 struct dentry * dentry;
44};
45
46extern int kobject_set_name(struct kobject *, const char *, ...)
47 __attribute__((format(printf,2,3)));
48
49static inline char * kobject_name(struct kobject * kobj)
50{
51 return kobj->k_name;
52}
53
54extern void kobject_init(struct kobject *);
55extern void kobject_cleanup(struct kobject *);
56
57extern int kobject_add(struct kobject *);
58extern void kobject_del(struct kobject *);
59
60extern int kobject_rename(struct kobject *, char *new_name);
61
62extern int kobject_register(struct kobject *);
63extern void kobject_unregister(struct kobject *);
64
65extern struct kobject * kobject_get(struct kobject *);
66extern void kobject_put(struct kobject *);
67
68extern char * kobject_get_path(struct kobject *, int);
69
70struct kobj_type {
71 void (*release)(struct kobject *);
72 struct sysfs_ops * sysfs_ops;
73 struct attribute ** default_attrs;
74};
75
76
77/**
78 * kset - a set of kobjects of a specific type, belonging
79 * to a specific subsystem.
80 *
81 * All kobjects of a kset should be embedded in an identical
82 * type. This type may have a descriptor, which the kset points
83 * to. This allows there to exist sets of objects of the same
84 * type in different subsystems.
85 *
86 * A subsystem does not have to be a list of only one type
87 * of object; multiple ksets can belong to one subsystem. All
88 * ksets of a subsystem share the subsystem's lock.
89 *
90 * Each kset can support hotplugging; if it does, it will be given
91 * the opportunity to filter out specific kobjects from being
92 * reported, as well as to add its own "data" elements to the
93 * environment being passed to the hotplug helper.
94 */
95struct kset_hotplug_ops {
96 int (*filter)(struct kset *kset, struct kobject *kobj);
97 char *(*name)(struct kset *kset, struct kobject *kobj);
98 int (*hotplug)(struct kset *kset, struct kobject *kobj, char **envp,
99 int num_envp, char *buffer, int buffer_size);
100};
101
102struct kset {
103 struct subsystem * subsys;
104 struct kobj_type * ktype;
105 struct list_head list;
106 spinlock_t list_lock;
107 struct kobject kobj;
108 struct kset_hotplug_ops * hotplug_ops;
109};
110
111
112extern void kset_init(struct kset * k);
113extern int kset_add(struct kset * k);
114extern int kset_register(struct kset * k);
115extern void kset_unregister(struct kset * k);
116
117static inline struct kset * to_kset(struct kobject * kobj)
118{
119 return kobj ? container_of(kobj,struct kset,kobj) : NULL;
120}
121
122static inline struct kset * kset_get(struct kset * k)
123{
124 return k ? to_kset(kobject_get(&k->kobj)) : NULL;
125}
126
127static inline void kset_put(struct kset * k)
128{
129 kobject_put(&k->kobj);
130}
131
132static inline struct kobj_type * get_ktype(struct kobject * k)
133{
134 if (k->kset && k->kset->ktype)
135 return k->kset->ktype;
136 else
137 return k->ktype;
138}
139
140extern struct kobject * kset_find_obj(struct kset *, const char *);
141
142
143/**
144 * Use this when initializing an embedded kset with no other
145 * fields to initialize.
146 */
147#define set_kset_name(str) .kset = { .kobj = { .name = str } }
148
149
150
151struct subsystem {
152 struct kset kset;
153 struct rw_semaphore rwsem;
154};
155
156#define decl_subsys(_name,_type,_hotplug_ops) \
157struct subsystem _name##_subsys = { \
158 .kset = { \
159 .kobj = { .name = __stringify(_name) }, \
160 .ktype = _type, \
161 .hotplug_ops =_hotplug_ops, \
162 } \
163}
164#define decl_subsys_name(_varname,_name,_type,_hotplug_ops) \
165struct subsystem _varname##_subsys = { \
166 .kset = { \
167 .kobj = { .name = __stringify(_name) }, \
168 .ktype = _type, \
169 .hotplug_ops =_hotplug_ops, \
170 } \
171}
172
173/* The global /sys/kernel/ subsystem for people to chain off of */
174extern struct subsystem kernel_subsys;
175
176/**
177 * Helpers for setting the kset of registered objects.
178 * Often, a registered object belongs to a kset embedded in a
179 * subsystem. These do no magic, just make the resulting code
180 * easier to follow.
181 */
182
183/**
184 * kobj_set_kset_s(obj,subsys) - set kset for embedded kobject.
185 * @obj: ptr to some object type.
186 * @subsys: a subsystem object (not a ptr).
187 *
188 * Can be used for any object type with an embedded ->kobj.
189 */
190
191#define kobj_set_kset_s(obj,subsys) \
192 (obj)->kobj.kset = &(subsys).kset
193
194/**
195 * kset_set_kset_s(obj,subsys) - set kset for embedded kset.
196 * @obj: ptr to some object type.
197 * @subsys: a subsystem object (not a ptr).
198 *
199 * Can be used for any object type with an embedded ->kset.
200 * Sets the kset of @obj's embedded kobject (via its embedded
201 * kset) to @subsys.kset. This makes @obj a member of that
202 * kset.
203 */
204
205#define kset_set_kset_s(obj,subsys) \
206 (obj)->kset.kobj.kset = &(subsys).kset
207
208/**
209 * subsys_set_kset(obj,subsys) - set kset for subsystem
210 * @obj: ptr to some object type.
211 * @subsys: a subsystem object (not a ptr).
212 *
213 * Can be used for any object type with an embedded ->subsys.
214 * Sets the kset of @obj's kobject to @subsys.kset. This makes
215 * the object a member of that kset.
216 */
217
218#define subsys_set_kset(obj,_subsys) \
219 (obj)->subsys.kset.kobj.kset = &(_subsys).kset
220
221extern void subsystem_init(struct subsystem *);
222extern int subsystem_register(struct subsystem *);
223extern void subsystem_unregister(struct subsystem *);
224
225static inline struct subsystem * subsys_get(struct subsystem * s)
226{
227 return s ? container_of(kset_get(&s->kset),struct subsystem,kset) : NULL;
228}
229
230static inline void subsys_put(struct subsystem * s)
231{
232 kset_put(&s->kset);
233}
234
235struct subsys_attribute {
236 struct attribute attr;
237 ssize_t (*show)(struct subsystem *, char *);
238 ssize_t (*store)(struct subsystem *, const char *, size_t);
239};
240
241extern int subsys_create_file(struct subsystem * , struct subsys_attribute *);
242extern void subsys_remove_file(struct subsystem * , struct subsys_attribute *);
243
244#ifdef CONFIG_HOTPLUG
245void kobject_hotplug(struct kobject *kobj, enum kobject_action action);
246int add_hotplug_env_var(char **envp, int num_envp, int *cur_index,
247 char *buffer, int buffer_size, int *cur_len,
248 const char *format, ...)
249 __attribute__((format (printf, 7, 8)));
250#else
251static inline void kobject_hotplug(struct kobject *kobj, enum kobject_action action) { }
252static inline int add_hotplug_env_var(char **envp, int num_envp, int *cur_index,
253 char *buffer, int buffer_size, int *cur_len,
254 const char *format, ...)
255{ return 0; }
256#endif
257
258#endif /* __KERNEL__ */
259#endif /* _KOBJECT_H_ */
diff --git a/include/linux/kobject_uevent.h b/include/linux/kobject_uevent.h
new file mode 100644
index 000000000000..aa664fe7e561
--- /dev/null
+++ b/include/linux/kobject_uevent.h
@@ -0,0 +1,57 @@
1/*
2 * kobject_uevent.h - list of kobject user events that can be generated
3 *
4 * Copyright (C) 2004 IBM Corp.
5 * Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.com>
6 *
7 * This file is released under the GPLv2.
8 *
9 */
10
11#ifndef _KOBJECT_EVENT_H_
12#define _KOBJECT_EVENT_H_
13
14#define HOTPLUG_PATH_LEN 256
15
16/* path to the hotplug userspace helper executed on an event */
17extern char hotplug_path[];
18
19/*
20 * If you add an action here, you must also add the proper string to the
21 * lib/kobject_uevent.c file.
22 */
23typedef int __bitwise kobject_action_t;
24enum kobject_action {
25 KOBJ_ADD = (__force kobject_action_t) 0x01, /* add event, for hotplug */
26 KOBJ_REMOVE = (__force kobject_action_t) 0x02, /* remove event, for hotplug */
27 KOBJ_CHANGE = (__force kobject_action_t) 0x03, /* a sysfs attribute file has changed */
28 KOBJ_MOUNT = (__force kobject_action_t) 0x04, /* mount event for block devices */
29 KOBJ_UMOUNT = (__force kobject_action_t) 0x05, /* umount event for block devices */
30 KOBJ_OFFLINE = (__force kobject_action_t) 0x06, /* offline event for hotplug devices */
31 KOBJ_ONLINE = (__force kobject_action_t) 0x07, /* online event for hotplug devices */
32};
33
34
35#ifdef CONFIG_KOBJECT_UEVENT
36int kobject_uevent(struct kobject *kobj,
37 enum kobject_action action,
38 struct attribute *attr);
39int kobject_uevent_atomic(struct kobject *kobj,
40 enum kobject_action action,
41 struct attribute *attr);
42#else
43static inline int kobject_uevent(struct kobject *kobj,
44 enum kobject_action action,
45 struct attribute *attr)
46{
47 return 0;
48}
49static inline int kobject_uevent_atomic(struct kobject *kobj,
50 enum kobject_action action,
51 struct attribute *attr)
52{
53 return 0;
54}
55#endif
56
57#endif
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
new file mode 100644
index 000000000000..f20c163de4f5
--- /dev/null
+++ b/include/linux/kprobes.h
@@ -0,0 +1,136 @@
1#ifndef _LINUX_KPROBES_H
2#define _LINUX_KPROBES_H
3/*
4 * Kernel Probes (KProbes)
5 * include/linux/kprobes.h
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 *
21 * Copyright (C) IBM Corporation, 2002, 2004
22 *
23 * 2002-Oct Created by Vamsi Krishna S <vamsi_krishna@in.ibm.com> Kernel
24 * Probes initial implementation ( includes suggestions from
25 * Rusty Russell).
26 * 2004-July Suparna Bhattacharya <suparna@in.ibm.com> added jumper probes
27 * interface to access function arguments.
28 */
29#include <linux/config.h>
30#include <linux/list.h>
31#include <linux/notifier.h>
32#include <linux/smp.h>
33#include <asm/kprobes.h>
34
35struct kprobe;
36struct pt_regs;
37typedef int (*kprobe_pre_handler_t) (struct kprobe *, struct pt_regs *);
38typedef int (*kprobe_break_handler_t) (struct kprobe *, struct pt_regs *);
39typedef void (*kprobe_post_handler_t) (struct kprobe *, struct pt_regs *,
40 unsigned long flags);
41typedef int (*kprobe_fault_handler_t) (struct kprobe *, struct pt_regs *,
42 int trapnr);
43struct kprobe {
44 struct hlist_node hlist;
45
46 /* location of the probe point */
47 kprobe_opcode_t *addr;
48
49 /* Called before addr is executed. */
50 kprobe_pre_handler_t pre_handler;
51
52 /* Called after addr is executed, unless... */
53 kprobe_post_handler_t post_handler;
54
55 /* ... called if executing addr causes a fault (eg. page fault).
56 * Return 1 if it handled fault, otherwise kernel will see it. */
57 kprobe_fault_handler_t fault_handler;
58
59 /* ... called if breakpoint trap occurs in probe handler.
60 * Return 1 if it handled break, otherwise kernel will see it. */
61 kprobe_break_handler_t break_handler;
62
63 /* Saved opcode (which has been replaced with breakpoint) */
64 kprobe_opcode_t opcode;
65
66 /* copy of the original instruction */
67 struct arch_specific_insn ainsn;
68};
69
70/*
71 * Special probe type that uses setjmp-longjmp type tricks to resume
72 * execution at a specified entry with a matching prototype corresponding
73 * to the probed function - a trick to enable arguments to become
74 * accessible seamlessly by probe handling logic.
75 * Note:
76 * Because of the way compilers allocate stack space for local variables
77 * etc upfront, regardless of sub-scopes within a function, this mirroring
78 * principle currently works only for probes placed on function entry points.
79 */
80struct jprobe {
81 struct kprobe kp;
82 kprobe_opcode_t *entry; /* probe handling code to jump to */
83};
84
85#ifdef CONFIG_KPROBES
86/* Locks kprobe: irq must be disabled */
87void lock_kprobes(void);
88void unlock_kprobes(void);
89
90/* kprobe running now on this CPU? */
91static inline int kprobe_running(void)
92{
93 extern unsigned int kprobe_cpu;
94 return kprobe_cpu == smp_processor_id();
95}
96
97extern int arch_prepare_kprobe(struct kprobe *p);
98extern void arch_copy_kprobe(struct kprobe *p);
99extern void arch_remove_kprobe(struct kprobe *p);
100extern void show_registers(struct pt_regs *regs);
101
102/* Get the kprobe at this addr (if any). Must have called lock_kprobes */
103struct kprobe *get_kprobe(void *addr);
104
105int register_kprobe(struct kprobe *p);
106void unregister_kprobe(struct kprobe *p);
107int setjmp_pre_handler(struct kprobe *, struct pt_regs *);
108int longjmp_break_handler(struct kprobe *, struct pt_regs *);
109int register_jprobe(struct jprobe *p);
110void unregister_jprobe(struct jprobe *p);
111void jprobe_return(void);
112
113#else
114static inline int kprobe_running(void)
115{
116 return 0;
117}
118static inline int register_kprobe(struct kprobe *p)
119{
120 return -ENOSYS;
121}
122static inline void unregister_kprobe(struct kprobe *p)
123{
124}
125static inline int register_jprobe(struct jprobe *p)
126{
127 return -ENOSYS;
128}
129static inline void unregister_jprobe(struct jprobe *p)
130{
131}
132static inline void jprobe_return(void)
133{
134}
135#endif
136#endif /* _LINUX_KPROBES_H */
diff --git a/include/linux/kref.h b/include/linux/kref.h
new file mode 100644
index 000000000000..6fee3539893f
--- /dev/null
+++ b/include/linux/kref.h
@@ -0,0 +1,32 @@
1/*
2 * kref.c - library routines for handling generic reference counted objects
3 *
4 * Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.com>
5 * Copyright (C) 2004 IBM Corp.
6 *
7 * based on kobject.h which was:
8 * Copyright (C) 2002-2003 Patrick Mochel <mochel@osdl.org>
9 * Copyright (C) 2002-2003 Open Source Development Labs
10 *
11 * This file is released under the GPLv2.
12 *
13 */
14
15#ifndef _KREF_H_
16#define _KREF_H_
17
18#ifdef __KERNEL__
19
20#include <linux/types.h>
21#include <asm/atomic.h>
22
23struct kref {
24 atomic_t refcount;
25};
26
27void kref_init(struct kref *kref);
28void kref_get(struct kref *kref);
29int kref_put(struct kref *kref, void (*release) (struct kref *kref));
30
31#endif /* __KERNEL__ */
32#endif /* _KREF_H_ */
diff --git a/include/linux/kthread.h b/include/linux/kthread.h
new file mode 100644
index 000000000000..3fa786448db3
--- /dev/null
+++ b/include/linux/kthread.h
@@ -0,0 +1,81 @@
1#ifndef _LINUX_KTHREAD_H
2#define _LINUX_KTHREAD_H
3/* Simple interface for creating and stopping kernel threads without mess. */
4#include <linux/err.h>
5#include <linux/sched.h>
6
7/**
8 * kthread_create: create a kthread.
9 * @threadfn: the function to run until signal_pending(current).
10 * @data: data ptr for @threadfn.
11 * @namefmt: printf-style name for the thread.
12 *
13 * Description: This helper function creates and names a kernel
14 * thread. The thread will be stopped: use wake_up_process() to start
15 * it. See also kthread_run(), kthread_create_on_cpu().
16 *
17 * When woken, the thread will run @threadfn() with @data as its
18 * argument. @threadfn can either call do_exit() directly if it is a
19 * standalone thread for which noone will call kthread_stop(), or
20 * return when 'kthread_should_stop()' is true (which means
21 * kthread_stop() has been called). The return value should be zero
22 * or a negative error number: it will be passed to kthread_stop().
23 *
24 * Returns a task_struct or ERR_PTR(-ENOMEM).
25 */
26struct task_struct *kthread_create(int (*threadfn)(void *data),
27 void *data,
28 const char namefmt[], ...);
29
30/**
31 * kthread_run: create and wake a thread.
32 * @threadfn: the function to run until signal_pending(current).
33 * @data: data ptr for @threadfn.
34 * @namefmt: printf-style name for the thread.
35 *
36 * Description: Convenient wrapper for kthread_create() followed by
37 * wake_up_process(). Returns the kthread, or ERR_PTR(-ENOMEM). */
38#define kthread_run(threadfn, data, namefmt, ...) \
39({ \
40 struct task_struct *__k \
41 = kthread_create(threadfn, data, namefmt, ## __VA_ARGS__); \
42 if (!IS_ERR(__k)) \
43 wake_up_process(__k); \
44 __k; \
45})
46
47/**
48 * kthread_bind: bind a just-created kthread to a cpu.
49 * @k: thread created by kthread_create().
50 * @cpu: cpu (might not be online, must be possible) for @k to run on.
51 *
52 * Description: This function is equivalent to set_cpus_allowed(),
53 * except that @cpu doesn't need to be online, and the thread must be
54 * stopped (ie. just returned from kthread_create().
55 */
56void kthread_bind(struct task_struct *k, unsigned int cpu);
57
58/**
59 * kthread_stop: stop a thread created by kthread_create().
60 * @k: thread created by kthread_create().
61 *
62 * Sets kthread_should_stop() for @k to return true, wakes it, and
63 * waits for it to exit. Your threadfn() must not call do_exit()
64 * itself if you use this function! This can also be called after
65 * kthread_create() instead of calling wake_up_process(): the thread
66 * will exit without calling threadfn().
67 *
68 * Returns the result of threadfn(), or -EINTR if wake_up_process()
69 * was never called. */
70int kthread_stop(struct task_struct *k);
71
72/**
73 * kthread_should_stop: should this kthread return now?
74 *
75 * When someone calls kthread_stop on your kthread, it will be woken
76 * and this will return true. You should then return, and your return
77 * value will be passed through to kthread_stop().
78 */
79int kthread_should_stop(void);
80
81#endif /* _LINUX_KTHREAD_H */
diff --git a/include/linux/lapb.h b/include/linux/lapb.h
new file mode 100644
index 000000000000..ce709e1885cc
--- /dev/null
+++ b/include/linux/lapb.h
@@ -0,0 +1,56 @@
1/*
2 * These are the public elements of the Linux LAPB module.
3 */
4
5#ifndef LAPB_KERNEL_H
6#define LAPB_KERNEL_H
7
8#define LAPB_OK 0
9#define LAPB_BADTOKEN 1
10#define LAPB_INVALUE 2
11#define LAPB_CONNECTED 3
12#define LAPB_NOTCONNECTED 4
13#define LAPB_REFUSED 5
14#define LAPB_TIMEDOUT 6
15#define LAPB_NOMEM 7
16
17#define LAPB_STANDARD 0x00
18#define LAPB_EXTENDED 0x01
19
20#define LAPB_SLP 0x00
21#define LAPB_MLP 0x02
22
23#define LAPB_DTE 0x00
24#define LAPB_DCE 0x04
25
26struct lapb_register_struct {
27 void (*connect_confirmation)(struct net_device *dev, int reason);
28 void (*connect_indication)(struct net_device *dev, int reason);
29 void (*disconnect_confirmation)(struct net_device *dev, int reason);
30 void (*disconnect_indication)(struct net_device *dev, int reason);
31 int (*data_indication)(struct net_device *dev, struct sk_buff *skb);
32 void (*data_transmit)(struct net_device *dev, struct sk_buff *skb);
33};
34
35struct lapb_parms_struct {
36 unsigned int t1;
37 unsigned int t1timer;
38 unsigned int t2;
39 unsigned int t2timer;
40 unsigned int n2;
41 unsigned int n2count;
42 unsigned int window;
43 unsigned int state;
44 unsigned int mode;
45};
46
47extern int lapb_register(struct net_device *dev, struct lapb_register_struct *callbacks);
48extern int lapb_unregister(struct net_device *dev);
49extern int lapb_getparms(struct net_device *dev, struct lapb_parms_struct *parms);
50extern int lapb_setparms(struct net_device *dev, struct lapb_parms_struct *parms);
51extern int lapb_connect_request(struct net_device *dev);
52extern int lapb_disconnect_request(struct net_device *dev);
53extern int lapb_data_request(struct net_device *dev, struct sk_buff *skb);
54extern int lapb_data_received(struct net_device *dev, struct sk_buff *skb);
55
56#endif
diff --git a/include/linux/lcd.h b/include/linux/lcd.h
new file mode 100644
index 000000000000..d739b2e7eac2
--- /dev/null
+++ b/include/linux/lcd.h
@@ -0,0 +1,56 @@
1/*
2 * LCD Lowlevel Control Abstraction
3 *
4 * Copyright (C) 2003,2004 Hewlett-Packard Company
5 *
6 */
7
8#ifndef _LINUX_LCD_H
9#define _LINUX_LCD_H
10
11#include <linux/device.h>
12#include <linux/notifier.h>
13
14struct lcd_device;
15struct fb_info;
16
17/* This structure defines all the properties of a LCD flat panel. */
18struct lcd_properties {
19 /* Owner module */
20 struct module *owner;
21 /* Get the LCD panel power status (0: full on, 1..3: controller
22 power on, flat panel power off, 4: full off), see FB_BLANK_XXX */
23 int (*get_power)(struct lcd_device *);
24 /* Enable or disable power to the LCD (0: on; 4: off, see FB_BLANK_XXX) */
25 int (*set_power)(struct lcd_device *, int power);
26 /* The maximum value for contrast (read-only) */
27 int max_contrast;
28 /* Get the current contrast setting (0-max_contrast) */
29 int (*get_contrast)(struct lcd_device *);
30 /* Set LCD panel contrast */
31 int (*set_contrast)(struct lcd_device *, int contrast);
32 /* Check if given framebuffer device is the one LCD is bound to;
33 return 0 if not, !=0 if it is. If NULL, lcd always matches the fb. */
34 int (*check_fb)(struct fb_info *);
35};
36
37struct lcd_device {
38 /* This protects the 'props' field. If 'props' is NULL, the driver that
39 registered this device has been unloaded, and if class_get_devdata()
40 points to something in the body of that driver, it is also invalid. */
41 struct semaphore sem;
42 /* If this is NULL, the backing module is unloaded */
43 struct lcd_properties *props;
44 /* The framebuffer notifier block */
45 struct notifier_block fb_notif;
46 /* The class device structure */
47 struct class_device class_dev;
48};
49
50extern struct lcd_device *lcd_device_register(const char *name,
51 void *devdata, struct lcd_properties *lp);
52extern void lcd_device_unregister(struct lcd_device *ld);
53
54#define to_lcd_device(obj) container_of(obj, struct lcd_device, class_dev)
55
56#endif
diff --git a/include/linux/libata.h b/include/linux/libata.h
new file mode 100644
index 000000000000..505160ab472b
--- /dev/null
+++ b/include/linux/libata.h
@@ -0,0 +1,599 @@
1/*
2 Copyright 2003-2004 Red Hat, Inc. All rights reserved.
3 Copyright 2003-2004 Jeff Garzik
4
5 The contents of this file are subject to the Open
6 Software License version 1.1 that can be found at
7 http://www.opensource.org/licenses/osl-1.1.txt and is included herein
8 by reference.
9
10 Alternatively, the contents of this file may be used under the terms
11 of the GNU General Public License version 2 (the "GPL") as distributed
12 in the kernel source COPYING file, in which case the provisions of
13 the GPL are applicable instead of the above. If you wish to allow
14 the use of your version of this file only under the terms of the
15 GPL and not to allow others to use your version of this file under
16 the OSL, indicate your decision by deleting the provisions above and
17 replace them with the notice and other provisions required by the GPL.
18 If you do not delete the provisions above, a recipient may use your
19 version of this file under either the OSL or the GPL.
20
21 */
22
23#ifndef __LINUX_LIBATA_H__
24#define __LINUX_LIBATA_H__
25
26#include <linux/delay.h>
27#include <linux/interrupt.h>
28#include <linux/pci.h>
29#include <asm/io.h>
30#include <linux/ata.h>
31#include <linux/workqueue.h>
32
33/*
34 * compile-time options
35 */
36#undef ATA_DEBUG /* debugging output */
37#undef ATA_VERBOSE_DEBUG /* yet more debugging output */
38#undef ATA_IRQ_TRAP /* define to ack screaming irqs */
39#undef ATA_NDEBUG /* define to disable quick runtime checks */
40#undef ATA_ENABLE_ATAPI /* define to enable ATAPI support */
41#undef ATA_ENABLE_PATA /* define to enable PATA support in some
42 * low-level drivers */
43#undef ATAPI_ENABLE_DMADIR /* enables ATAPI DMADIR bridge support */
44
45
46/* note: prints function name for you */
47#ifdef ATA_DEBUG
48#define DPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args)
49#ifdef ATA_VERBOSE_DEBUG
50#define VPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args)
51#else
52#define VPRINTK(fmt, args...)
53#endif /* ATA_VERBOSE_DEBUG */
54#else
55#define DPRINTK(fmt, args...)
56#define VPRINTK(fmt, args...)
57#endif /* ATA_DEBUG */
58
59#ifdef ATA_NDEBUG
60#define assert(expr)
61#else
62#define assert(expr) \
63 if(unlikely(!(expr))) { \
64 printk(KERN_ERR "Assertion failed! %s,%s,%s,line=%d\n", \
65 #expr,__FILE__,__FUNCTION__,__LINE__); \
66 }
67#endif
68
69/* defines only for the constants which don't work well as enums */
70#define ATA_TAG_POISON 0xfafbfcfdU
71
72/* move to PCI layer? */
73static inline struct device *pci_dev_to_dev(struct pci_dev *pdev)
74{
75 return &pdev->dev;
76}
77
78enum {
79 /* various global constants */
80 LIBATA_MAX_PRD = ATA_MAX_PRD / 2,
81 ATA_MAX_PORTS = 8,
82 ATA_DEF_QUEUE = 1,
83 ATA_MAX_QUEUE = 1,
84 ATA_MAX_SECTORS = 200, /* FIXME */
85 ATA_MAX_BUS = 2,
86 ATA_DEF_BUSY_WAIT = 10000,
87 ATA_SHORT_PAUSE = (HZ >> 6) + 1,
88
89 ATA_SHT_EMULATED = 1,
90 ATA_SHT_CMD_PER_LUN = 1,
91 ATA_SHT_THIS_ID = -1,
92 ATA_SHT_USE_CLUSTERING = 0,
93
94 /* struct ata_device stuff */
95 ATA_DFLAG_LBA48 = (1 << 0), /* device supports LBA48 */
96 ATA_DFLAG_PIO = (1 << 1), /* device currently in PIO mode */
97 ATA_DFLAG_LOCK_SECTORS = (1 << 2), /* don't adjust max_sectors */
98
99 ATA_DEV_UNKNOWN = 0, /* unknown device */
100 ATA_DEV_ATA = 1, /* ATA device */
101 ATA_DEV_ATA_UNSUP = 2, /* ATA device (unsupported) */
102 ATA_DEV_ATAPI = 3, /* ATAPI device */
103 ATA_DEV_ATAPI_UNSUP = 4, /* ATAPI device (unsupported) */
104 ATA_DEV_NONE = 5, /* no device */
105
106 /* struct ata_port flags */
107 ATA_FLAG_SLAVE_POSS = (1 << 1), /* host supports slave dev */
108 /* (doesn't imply presence) */
109 ATA_FLAG_PORT_DISABLED = (1 << 2), /* port is disabled, ignore it */
110 ATA_FLAG_SATA = (1 << 3),
111 ATA_FLAG_NO_LEGACY = (1 << 4), /* no legacy mode check */
112 ATA_FLAG_SRST = (1 << 5), /* use ATA SRST, not E.D.D. */
113 ATA_FLAG_MMIO = (1 << 6), /* use MMIO, not PIO */
114 ATA_FLAG_SATA_RESET = (1 << 7), /* use COMRESET */
115 ATA_FLAG_PIO_DMA = (1 << 8), /* PIO cmds via DMA */
116
117 ATA_QCFLAG_ACTIVE = (1 << 1), /* cmd not yet ack'd to scsi lyer */
118 ATA_QCFLAG_SG = (1 << 3), /* have s/g table? */
119 ATA_QCFLAG_SINGLE = (1 << 4), /* no s/g, just a single buffer */
120 ATA_QCFLAG_DMAMAP = ATA_QCFLAG_SG | ATA_QCFLAG_SINGLE,
121
122 /* various lengths of time */
123 ATA_TMOUT_EDD = 5 * HZ, /* hueristic */
124 ATA_TMOUT_PIO = 30 * HZ,
125 ATA_TMOUT_BOOT = 30 * HZ, /* hueristic */
126 ATA_TMOUT_BOOT_QUICK = 7 * HZ, /* hueristic */
127 ATA_TMOUT_CDB = 30 * HZ,
128 ATA_TMOUT_CDB_QUICK = 5 * HZ,
129
130 /* ATA bus states */
131 BUS_UNKNOWN = 0,
132 BUS_DMA = 1,
133 BUS_IDLE = 2,
134 BUS_NOINTR = 3,
135 BUS_NODATA = 4,
136 BUS_TIMER = 5,
137 BUS_PIO = 6,
138 BUS_EDD = 7,
139 BUS_IDENTIFY = 8,
140 BUS_PACKET = 9,
141
142 /* SATA port states */
143 PORT_UNKNOWN = 0,
144 PORT_ENABLED = 1,
145 PORT_DISABLED = 2,
146
147 /* encoding various smaller bitmaps into a single
148 * unsigned long bitmap
149 */
150 ATA_SHIFT_UDMA = 0,
151 ATA_SHIFT_MWDMA = 8,
152 ATA_SHIFT_PIO = 11,
153};
154
155enum pio_task_states {
156 PIO_ST_UNKNOWN,
157 PIO_ST_IDLE,
158 PIO_ST_POLL,
159 PIO_ST_TMOUT,
160 PIO_ST,
161 PIO_ST_LAST,
162 PIO_ST_LAST_POLL,
163 PIO_ST_ERR,
164};
165
166/* forward declarations */
167struct scsi_device;
168struct ata_port_operations;
169struct ata_port;
170struct ata_queued_cmd;
171
172/* typedefs */
173typedef int (*ata_qc_cb_t) (struct ata_queued_cmd *qc, u8 drv_stat);
174
175struct ata_ioports {
176 unsigned long cmd_addr;
177 unsigned long data_addr;
178 unsigned long error_addr;
179 unsigned long feature_addr;
180 unsigned long nsect_addr;
181 unsigned long lbal_addr;
182 unsigned long lbam_addr;
183 unsigned long lbah_addr;
184 unsigned long device_addr;
185 unsigned long status_addr;
186 unsigned long command_addr;
187 unsigned long altstatus_addr;
188 unsigned long ctl_addr;
189 unsigned long bmdma_addr;
190 unsigned long scr_addr;
191};
192
193struct ata_probe_ent {
194 struct list_head node;
195 struct device *dev;
196 struct ata_port_operations *port_ops;
197 Scsi_Host_Template *sht;
198 struct ata_ioports port[ATA_MAX_PORTS];
199 unsigned int n_ports;
200 unsigned int hard_port_no;
201 unsigned int pio_mask;
202 unsigned int mwdma_mask;
203 unsigned int udma_mask;
204 unsigned int legacy_mode;
205 unsigned long irq;
206 unsigned int irq_flags;
207 unsigned long host_flags;
208 void __iomem *mmio_base;
209 void *private_data;
210};
211
212struct ata_host_set {
213 spinlock_t lock;
214 struct device *dev;
215 unsigned long irq;
216 void __iomem *mmio_base;
217 unsigned int n_ports;
218 void *private_data;
219 struct ata_port_operations *ops;
220 struct ata_port * ports[0];
221};
222
223struct ata_queued_cmd {
224 struct ata_port *ap;
225 struct ata_device *dev;
226
227 struct scsi_cmnd *scsicmd;
228 void (*scsidone)(struct scsi_cmnd *);
229
230 struct ata_taskfile tf;
231 u8 cdb[ATAPI_CDB_LEN];
232
233 unsigned long flags; /* ATA_QCFLAG_xxx */
234 unsigned int tag;
235 unsigned int n_elem;
236
237 int dma_dir;
238
239 unsigned int nsect;
240 unsigned int cursect;
241
242 unsigned int nbytes;
243 unsigned int curbytes;
244
245 unsigned int cursg;
246 unsigned int cursg_ofs;
247
248 struct scatterlist sgent;
249 void *buf_virt;
250
251 struct scatterlist *sg;
252
253 ata_qc_cb_t complete_fn;
254
255 struct completion *waiting;
256
257 void *private_data;
258};
259
260struct ata_host_stats {
261 unsigned long unhandled_irq;
262 unsigned long idle_irq;
263 unsigned long rw_reqbuf;
264};
265
266struct ata_device {
267 u64 n_sectors; /* size of device, if ATA */
268 unsigned long flags; /* ATA_DFLAG_xxx */
269 unsigned int class; /* ATA_DEV_xxx */
270 unsigned int devno; /* 0 or 1 */
271 u16 id[ATA_ID_WORDS]; /* IDENTIFY xxx DEVICE data */
272 u8 pio_mode;
273 u8 dma_mode;
274 u8 xfer_mode;
275 unsigned int xfer_shift; /* ATA_SHIFT_xxx */
276
277 /* cache info about current transfer mode */
278 u8 xfer_protocol; /* taskfile xfer protocol */
279 u8 read_cmd; /* opcode to use on read */
280 u8 write_cmd; /* opcode to use on write */
281};
282
283struct ata_port {
284 struct Scsi_Host *host; /* our co-allocated scsi host */
285 struct ata_port_operations *ops;
286 unsigned long flags; /* ATA_FLAG_xxx */
287 unsigned int id; /* unique id req'd by scsi midlyr */
288 unsigned int port_no; /* unique port #; from zero */
289 unsigned int hard_port_no; /* hardware port #; from zero */
290
291 struct ata_prd *prd; /* our SG list */
292 dma_addr_t prd_dma; /* and its DMA mapping */
293
294 struct ata_ioports ioaddr; /* ATA cmd/ctl/dma register blocks */
295
296 u8 ctl; /* cache of ATA control register */
297 u8 last_ctl; /* Cache last written value */
298 unsigned int bus_state;
299 unsigned int port_state;
300 unsigned int pio_mask;
301 unsigned int mwdma_mask;
302 unsigned int udma_mask;
303 unsigned int cbl; /* cable type; ATA_CBL_xxx */
304 unsigned int cdb_len;
305
306 struct ata_device device[ATA_MAX_DEVICES];
307
308 struct ata_queued_cmd qcmd[ATA_MAX_QUEUE];
309 unsigned long qactive;
310 unsigned int active_tag;
311
312 struct ata_host_stats stats;
313 struct ata_host_set *host_set;
314
315 struct work_struct packet_task;
316
317 struct work_struct pio_task;
318 unsigned int pio_task_state;
319 unsigned long pio_task_timeout;
320
321 void *private_data;
322};
323
324struct ata_port_operations {
325 void (*port_disable) (struct ata_port *);
326
327 void (*dev_config) (struct ata_port *, struct ata_device *);
328
329 void (*set_piomode) (struct ata_port *, struct ata_device *);
330 void (*set_dmamode) (struct ata_port *, struct ata_device *);
331
332 void (*tf_load) (struct ata_port *ap, struct ata_taskfile *tf);
333 void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf);
334
335 void (*exec_command)(struct ata_port *ap, struct ata_taskfile *tf);
336 u8 (*check_status)(struct ata_port *ap);
337 u8 (*check_altstatus)(struct ata_port *ap);
338 u8 (*check_err)(struct ata_port *ap);
339 void (*dev_select)(struct ata_port *ap, unsigned int device);
340
341 void (*phy_reset) (struct ata_port *ap);
342 void (*post_set_mode) (struct ata_port *ap);
343
344 int (*check_atapi_dma) (struct ata_queued_cmd *qc);
345
346 void (*bmdma_setup) (struct ata_queued_cmd *qc);
347 void (*bmdma_start) (struct ata_queued_cmd *qc);
348
349 void (*qc_prep) (struct ata_queued_cmd *qc);
350 int (*qc_issue) (struct ata_queued_cmd *qc);
351
352 void (*eng_timeout) (struct ata_port *ap);
353
354 irqreturn_t (*irq_handler)(int, void *, struct pt_regs *);
355 void (*irq_clear) (struct ata_port *);
356
357 u32 (*scr_read) (struct ata_port *ap, unsigned int sc_reg);
358 void (*scr_write) (struct ata_port *ap, unsigned int sc_reg,
359 u32 val);
360
361 int (*port_start) (struct ata_port *ap);
362 void (*port_stop) (struct ata_port *ap);
363
364 void (*host_stop) (struct ata_host_set *host_set);
365
366 void (*bmdma_stop) (struct ata_port *ap);
367 u8 (*bmdma_status) (struct ata_port *ap);
368};
369
370struct ata_port_info {
371 Scsi_Host_Template *sht;
372 unsigned long host_flags;
373 unsigned long pio_mask;
374 unsigned long mwdma_mask;
375 unsigned long udma_mask;
376 struct ata_port_operations *port_ops;
377};
378
379
380extern void ata_port_probe(struct ata_port *);
381extern void __sata_phy_reset(struct ata_port *ap);
382extern void sata_phy_reset(struct ata_port *ap);
383extern void ata_bus_reset(struct ata_port *ap);
384extern void ata_port_disable(struct ata_port *);
385extern void ata_std_ports(struct ata_ioports *ioaddr);
386#ifdef CONFIG_PCI
387extern int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
388 unsigned int n_ports);
389extern void ata_pci_remove_one (struct pci_dev *pdev);
390#endif /* CONFIG_PCI */
391extern int ata_device_add(struct ata_probe_ent *ent);
392extern int ata_scsi_detect(Scsi_Host_Template *sht);
393extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg);
394extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *));
395extern int ata_scsi_error(struct Scsi_Host *host);
396extern int ata_scsi_release(struct Scsi_Host *host);
397extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc);
398/*
399 * Default driver ops implementations
400 */
401extern void ata_tf_load(struct ata_port *ap, struct ata_taskfile *tf);
402extern void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
403extern void ata_tf_to_fis(struct ata_taskfile *tf, u8 *fis, u8 pmp);
404extern void ata_tf_from_fis(u8 *fis, struct ata_taskfile *tf);
405extern void ata_noop_dev_select (struct ata_port *ap, unsigned int device);
406extern void ata_std_dev_select (struct ata_port *ap, unsigned int device);
407extern u8 ata_check_status(struct ata_port *ap);
408extern u8 ata_altstatus(struct ata_port *ap);
409extern u8 ata_chk_err(struct ata_port *ap);
410extern void ata_exec_command(struct ata_port *ap, struct ata_taskfile *tf);
411extern int ata_port_start (struct ata_port *ap);
412extern void ata_port_stop (struct ata_port *ap);
413extern irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs);
414extern void ata_qc_prep(struct ata_queued_cmd *qc);
415extern int ata_qc_issue_prot(struct ata_queued_cmd *qc);
416extern void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf,
417 unsigned int buflen);
418extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg,
419 unsigned int n_elem);
420extern unsigned int ata_dev_classify(struct ata_taskfile *tf);
421extern void ata_dev_id_string(u16 *id, unsigned char *s,
422 unsigned int ofs, unsigned int len);
423extern void ata_bmdma_setup (struct ata_queued_cmd *qc);
424extern void ata_bmdma_start (struct ata_queued_cmd *qc);
425extern void ata_bmdma_stop(struct ata_port *ap);
426extern u8 ata_bmdma_status(struct ata_port *ap);
427extern void ata_bmdma_irq_clear(struct ata_port *ap);
428extern void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat);
429extern void ata_eng_timeout(struct ata_port *ap);
430extern void ata_scsi_simulate(u16 *id, struct scsi_cmnd *cmd,
431 void (*done)(struct scsi_cmnd *));
432extern int ata_std_bios_param(struct scsi_device *sdev,
433 struct block_device *bdev,
434 sector_t capacity, int geom[]);
435extern int ata_scsi_slave_config(struct scsi_device *sdev);
436
437
438#ifdef CONFIG_PCI
439struct pci_bits {
440 unsigned int reg; /* PCI config register to read */
441 unsigned int width; /* 1 (8 bit), 2 (16 bit), 4 (32 bit) */
442 unsigned long mask;
443 unsigned long val;
444};
445
446extern struct ata_probe_ent *
447ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port);
448extern int pci_test_config_bits(struct pci_dev *pdev, struct pci_bits *bits);
449
450#endif /* CONFIG_PCI */
451
452
453static inline unsigned int ata_tag_valid(unsigned int tag)
454{
455 return (tag < ATA_MAX_QUEUE) ? 1 : 0;
456}
457
458static inline unsigned int ata_dev_present(struct ata_device *dev)
459{
460 return ((dev->class == ATA_DEV_ATA) ||
461 (dev->class == ATA_DEV_ATAPI));
462}
463
464static inline u8 ata_chk_status(struct ata_port *ap)
465{
466 return ap->ops->check_status(ap);
467}
468
469static inline void ata_pause(struct ata_port *ap)
470{
471 ata_altstatus(ap);
472 ndelay(400);
473}
474
475static inline u8 ata_busy_wait(struct ata_port *ap, unsigned int bits,
476 unsigned int max)
477{
478 u8 status;
479
480 do {
481 udelay(10);
482 status = ata_chk_status(ap);
483 max--;
484 } while ((status & bits) && (max > 0));
485
486 return status;
487}
488
489static inline u8 ata_wait_idle(struct ata_port *ap)
490{
491 u8 status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000);
492
493 if (status & (ATA_BUSY | ATA_DRQ)) {
494 unsigned long l = ap->ioaddr.status_addr;
495 printk(KERN_WARNING
496 "ATA: abnormal status 0x%X on port 0x%lX\n",
497 status, l);
498 }
499
500 return status;
501}
502
503static inline void ata_qc_set_polling(struct ata_queued_cmd *qc)
504{
505 qc->tf.ctl |= ATA_NIEN;
506}
507
508static inline struct ata_queued_cmd *ata_qc_from_tag (struct ata_port *ap,
509 unsigned int tag)
510{
511 if (likely(ata_tag_valid(tag)))
512 return &ap->qcmd[tag];
513 return NULL;
514}
515
516static inline void ata_tf_init(struct ata_port *ap, struct ata_taskfile *tf, unsigned int device)
517{
518 memset(tf, 0, sizeof(*tf));
519
520 tf->ctl = ap->ctl;
521 if (device == 0)
522 tf->device = ATA_DEVICE_OBS;
523 else
524 tf->device = ATA_DEVICE_OBS | ATA_DEV1;
525}
526
527static inline u8 ata_irq_on(struct ata_port *ap)
528{
529 struct ata_ioports *ioaddr = &ap->ioaddr;
530 u8 tmp;
531
532 ap->ctl &= ~ATA_NIEN;
533 ap->last_ctl = ap->ctl;
534
535 if (ap->flags & ATA_FLAG_MMIO)
536 writeb(ap->ctl, (void __iomem *) ioaddr->ctl_addr);
537 else
538 outb(ap->ctl, ioaddr->ctl_addr);
539 tmp = ata_wait_idle(ap);
540
541 ap->ops->irq_clear(ap);
542
543 return tmp;
544}
545
546static inline u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq)
547{
548 unsigned int bits = chk_drq ? ATA_BUSY | ATA_DRQ : ATA_BUSY;
549 u8 host_stat, post_stat, status;
550
551 status = ata_busy_wait(ap, bits, 1000);
552 if (status & bits)
553 DPRINTK("abnormal status 0x%X\n", status);
554
555 /* get controller status; clear intr, err bits */
556 if (ap->flags & ATA_FLAG_MMIO) {
557 void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr;
558 host_stat = readb(mmio + ATA_DMA_STATUS);
559 writeb(host_stat | ATA_DMA_INTR | ATA_DMA_ERR,
560 mmio + ATA_DMA_STATUS);
561
562 post_stat = readb(mmio + ATA_DMA_STATUS);
563 } else {
564 host_stat = inb(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
565 outb(host_stat | ATA_DMA_INTR | ATA_DMA_ERR,
566 ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
567
568 post_stat = inb(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
569 }
570
571 VPRINTK("irq ack: host_stat 0x%X, new host_stat 0x%X, drv_stat 0x%X\n",
572 host_stat, post_stat, status);
573
574 return status;
575}
576
577static inline u32 scr_read(struct ata_port *ap, unsigned int reg)
578{
579 return ap->ops->scr_read(ap, reg);
580}
581
582static inline void scr_write(struct ata_port *ap, unsigned int reg, u32 val)
583{
584 ap->ops->scr_write(ap, reg, val);
585}
586
587static inline unsigned int sata_dev_present(struct ata_port *ap)
588{
589 return ((scr_read(ap, SCR_STATUS) & 0xf) == 0x3) ? 1 : 0;
590}
591
592static inline int ata_try_flush_cache(struct ata_device *dev)
593{
594 return ata_id_wcache_enabled(dev->id) ||
595 ata_id_has_flush(dev->id) ||
596 ata_id_has_flush_ext(dev->id);
597}
598
599#endif /* __LINUX_LIBATA_H__ */
diff --git a/include/linux/libps2.h b/include/linux/libps2.h
new file mode 100644
index 000000000000..923bdbc6d9e4
--- /dev/null
+++ b/include/linux/libps2.h
@@ -0,0 +1,50 @@
1#ifndef _LIBPS2_H
2#define _LIBPS2_H
3
4/*
5 * Copyright (C) 1999-2002 Vojtech Pavlik
6 * Copyright (C) 2004 Dmitry Torokhov
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 version 2 as published by
10 * the Free Software Foundation.
11 */
12
13
14#define PS2_CMD_GETID 0x02f2
15#define PS2_CMD_RESET_BAT 0x02ff
16
17#define PS2_RET_BAT 0xaa
18#define PS2_RET_ID 0x00
19#define PS2_RET_ACK 0xfa
20#define PS2_RET_NAK 0xfe
21
22#define PS2_FLAG_ACK 1 /* Waiting for ACK/NAK */
23#define PS2_FLAG_CMD 2 /* Waiting for command to finish */
24#define PS2_FLAG_CMD1 4 /* Waiting for the first byte of command response */
25#define PS2_FLAG_WAITID 8 /* Command execiting is GET ID */
26
27struct ps2dev {
28 struct serio *serio;
29
30 /* Ensures that only one command is executing at a time */
31 struct semaphore cmd_sem;
32
33 /* Used to signal completion from interrupt handler */
34 wait_queue_head_t wait;
35
36 unsigned long flags;
37 unsigned char cmdbuf[6];
38 unsigned char cmdcnt;
39 unsigned char nak;
40};
41
42void ps2_init(struct ps2dev *ps2dev, struct serio *serio);
43int ps2_sendbyte(struct ps2dev *ps2dev, unsigned char byte, int timeout);
44int ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command);
45int ps2_schedule_command(struct ps2dev *ps2dev, unsigned char *param, int command);
46int ps2_handle_ack(struct ps2dev *ps2dev, unsigned char data);
47int ps2_handle_response(struct ps2dev *ps2dev, unsigned char data);
48void ps2_cmd_aborted(struct ps2dev *ps2dev);
49
50#endif /* _LIBPS2_H */
diff --git a/include/linux/limits.h b/include/linux/limits.h
new file mode 100644
index 000000000000..eaf2e099f125
--- /dev/null
+++ b/include/linux/limits.h
@@ -0,0 +1,22 @@
1#ifndef _LINUX_LIMITS_H
2#define _LINUX_LIMITS_H
3
4#define NR_OPEN 1024
5
6#define NGROUPS_MAX 65536 /* supplemental group IDs are available */
7#define ARG_MAX 131072 /* # bytes of args + environ for exec() */
8#define CHILD_MAX 999 /* no limit :-) */
9#define OPEN_MAX 256 /* # open files a process may have */
10#define LINK_MAX 127 /* # links a file may have */
11#define MAX_CANON 255 /* size of the canonical input queue */
12#define MAX_INPUT 255 /* size of the type-ahead buffer */
13#define NAME_MAX 255 /* # chars in a file name */
14#define PATH_MAX 4096 /* # chars in a path name including nul */
15#define PIPE_BUF 4096 /* # bytes in atomic write to a pipe */
16#define XATTR_NAME_MAX 255 /* # chars in an extended attribute name */
17#define XATTR_SIZE_MAX 65536 /* size of an extended attribute value (64k) */
18#define XATTR_LIST_MAX 65536 /* size of extended attribute namelist (64k) */
19
20#define RTSIG_MAX 32
21
22#endif
diff --git a/include/linux/linkage.h b/include/linux/linkage.h
new file mode 100644
index 000000000000..338f7795d8a0
--- /dev/null
+++ b/include/linux/linkage.h
@@ -0,0 +1,47 @@
1#ifndef _LINUX_LINKAGE_H
2#define _LINUX_LINKAGE_H
3
4#include <linux/config.h>
5#include <asm/linkage.h>
6
7#ifdef __cplusplus
8#define CPP_ASMLINKAGE extern "C"
9#else
10#define CPP_ASMLINKAGE
11#endif
12
13#ifndef asmlinkage
14#define asmlinkage CPP_ASMLINKAGE
15#endif
16
17#ifndef prevent_tail_call
18# define prevent_tail_call(ret) do { } while (0)
19#endif
20
21#ifndef __ALIGN
22#define __ALIGN .align 4,0x90
23#define __ALIGN_STR ".align 4,0x90"
24#endif
25
26#ifdef __ASSEMBLY__
27
28#define ALIGN __ALIGN
29#define ALIGN_STR __ALIGN_STR
30
31#define ENTRY(name) \
32 .globl name; \
33 ALIGN; \
34 name:
35
36#endif
37
38#define NORET_TYPE /**/
39#define ATTRIB_NORET __attribute__((noreturn))
40#define NORET_AND noreturn,
41
42#ifndef FASTCALL
43#define FASTCALL(x) x
44#define fastcall
45#endif
46
47#endif
diff --git a/include/linux/linux_logo.h b/include/linux/linux_logo.h
new file mode 100644
index 000000000000..9c01bde5bf1b
--- /dev/null
+++ b/include/linux/linux_logo.h
@@ -0,0 +1,37 @@
1#ifndef _LINUX_LINUX_LOGO_H
2#define _LINUX_LINUX_LOGO_H
3
4/*
5 * Linux logo to be displayed on boot
6 *
7 * Copyright (C) 1996 Larry Ewing (lewing@isc.tamu.edu)
8 * Copyright (C) 1996,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
9 * Copyright (C) 2001 Greg Banks <gnb@alphalink.com.au>
10 * Copyright (C) 2001 Jan-Benedict Glaw <jbglaw@lug-owl.de>
11 * Copyright (C) 2003 Geert Uytterhoeven <geert@linux-m68k.org>
12 *
13 * Serial_console ascii image can be any size,
14 * but should contain %s to display the version
15 */
16
17#include <linux/init.h>
18
19
20#define LINUX_LOGO_MONO 1 /* monochrome black/white */
21#define LINUX_LOGO_VGA16 2 /* 16 colors VGA text palette */
22#define LINUX_LOGO_CLUT224 3 /* 224 colors */
23#define LINUX_LOGO_GRAY256 4 /* 256 levels grayscale */
24
25
26struct linux_logo {
27 int type; /* one of LINUX_LOGO_* */
28 unsigned int width;
29 unsigned int height;
30 unsigned int clutsize; /* LINUX_LOGO_CLUT224 only */
31 const unsigned char *clut; /* LINUX_LOGO_CLUT224 only */
32 const unsigned char *data;
33};
34
35extern const struct linux_logo *fb_find_logo(int depth);
36
37#endif /* _LINUX_LINUX_LOGO_H */
diff --git a/include/linux/list.h b/include/linux/list.h
new file mode 100644
index 000000000000..dd7cd54fa831
--- /dev/null
+++ b/include/linux/list.h
@@ -0,0 +1,707 @@
1#ifndef _LINUX_LIST_H
2#define _LINUX_LIST_H
3
4#ifdef __KERNEL__
5
6#include <linux/stddef.h>
7#include <linux/prefetch.h>
8#include <asm/system.h>
9
10/*
11 * These are non-NULL pointers that will result in page faults
12 * under normal circumstances, used to verify that nobody uses
13 * non-initialized list entries.
14 */
15#define LIST_POISON1 ((void *) 0x00100100)
16#define LIST_POISON2 ((void *) 0x00200200)
17
18/*
19 * Simple doubly linked list implementation.
20 *
21 * Some of the internal functions ("__xxx") are useful when
22 * manipulating whole lists rather than single entries, as
23 * sometimes we already know the next/prev entries and we can
24 * generate better code by using them directly rather than
25 * using the generic single-entry routines.
26 */
27
28struct list_head {
29 struct list_head *next, *prev;
30};
31
32#define LIST_HEAD_INIT(name) { &(name), &(name) }
33
34#define LIST_HEAD(name) \
35 struct list_head name = LIST_HEAD_INIT(name)
36
37#define INIT_LIST_HEAD(ptr) do { \
38 (ptr)->next = (ptr); (ptr)->prev = (ptr); \
39} while (0)
40
41/*
42 * Insert a new entry between two known consecutive entries.
43 *
44 * This is only for internal list manipulation where we know
45 * the prev/next entries already!
46 */
47static inline void __list_add(struct list_head *new,
48 struct list_head *prev,
49 struct list_head *next)
50{
51 next->prev = new;
52 new->next = next;
53 new->prev = prev;
54 prev->next = new;
55}
56
57/**
58 * list_add - add a new entry
59 * @new: new entry to be added
60 * @head: list head to add it after
61 *
62 * Insert a new entry after the specified head.
63 * This is good for implementing stacks.
64 */
65static inline void list_add(struct list_head *new, struct list_head *head)
66{
67 __list_add(new, head, head->next);
68}
69
70/**
71 * list_add_tail - add a new entry
72 * @new: new entry to be added
73 * @head: list head to add it before
74 *
75 * Insert a new entry before the specified head.
76 * This is useful for implementing queues.
77 */
78static inline void list_add_tail(struct list_head *new, struct list_head *head)
79{
80 __list_add(new, head->prev, head);
81}
82
83/*
84 * Insert a new entry between two known consecutive entries.
85 *
86 * This is only for internal list manipulation where we know
87 * the prev/next entries already!
88 */
89static inline void __list_add_rcu(struct list_head * new,
90 struct list_head * prev, struct list_head * next)
91{
92 new->next = next;
93 new->prev = prev;
94 smp_wmb();
95 next->prev = new;
96 prev->next = new;
97}
98
99/**
100 * list_add_rcu - add a new entry to rcu-protected list
101 * @new: new entry to be added
102 * @head: list head to add it after
103 *
104 * Insert a new entry after the specified head.
105 * This is good for implementing stacks.
106 *
107 * The caller must take whatever precautions are necessary
108 * (such as holding appropriate locks) to avoid racing
109 * with another list-mutation primitive, such as list_add_rcu()
110 * or list_del_rcu(), running on this same list.
111 * However, it is perfectly legal to run concurrently with
112 * the _rcu list-traversal primitives, such as
113 * list_for_each_entry_rcu().
114 */
115static inline void list_add_rcu(struct list_head *new, struct list_head *head)
116{
117 __list_add_rcu(new, head, head->next);
118}
119
120/**
121 * list_add_tail_rcu - add a new entry to rcu-protected list
122 * @new: new entry to be added
123 * @head: list head to add it before
124 *
125 * Insert a new entry before the specified head.
126 * This is useful for implementing queues.
127 *
128 * The caller must take whatever precautions are necessary
129 * (such as holding appropriate locks) to avoid racing
130 * with another list-mutation primitive, such as list_add_tail_rcu()
131 * or list_del_rcu(), running on this same list.
132 * However, it is perfectly legal to run concurrently with
133 * the _rcu list-traversal primitives, such as
134 * list_for_each_entry_rcu().
135 */
136static inline void list_add_tail_rcu(struct list_head *new,
137 struct list_head *head)
138{
139 __list_add_rcu(new, head->prev, head);
140}
141
142/*
143 * Delete a list entry by making the prev/next entries
144 * point to each other.
145 *
146 * This is only for internal list manipulation where we know
147 * the prev/next entries already!
148 */
149static inline void __list_del(struct list_head * prev, struct list_head * next)
150{
151 next->prev = prev;
152 prev->next = next;
153}
154
155/**
156 * list_del - deletes entry from list.
157 * @entry: the element to delete from the list.
158 * Note: list_empty on entry does not return true after this, the entry is
159 * in an undefined state.
160 */
161static inline void list_del(struct list_head *entry)
162{
163 __list_del(entry->prev, entry->next);
164 entry->next = LIST_POISON1;
165 entry->prev = LIST_POISON2;
166}
167
168/**
169 * list_del_rcu - deletes entry from list without re-initialization
170 * @entry: the element to delete from the list.
171 *
172 * Note: list_empty on entry does not return true after this,
173 * the entry is in an undefined state. It is useful for RCU based
174 * lockfree traversal.
175 *
176 * In particular, it means that we can not poison the forward
177 * pointers that may still be used for walking the list.
178 *
179 * The caller must take whatever precautions are necessary
180 * (such as holding appropriate locks) to avoid racing
181 * with another list-mutation primitive, such as list_del_rcu()
182 * or list_add_rcu(), running on this same list.
183 * However, it is perfectly legal to run concurrently with
184 * the _rcu list-traversal primitives, such as
185 * list_for_each_entry_rcu().
186 *
187 * Note that the caller is not permitted to immediately free
188 * the newly deleted entry. Instead, either synchronize_kernel()
189 * or call_rcu() must be used to defer freeing until an RCU
190 * grace period has elapsed.
191 */
192static inline void list_del_rcu(struct list_head *entry)
193{
194 __list_del(entry->prev, entry->next);
195 entry->prev = LIST_POISON2;
196}
197
198/*
199 * list_replace_rcu - replace old entry by new one
200 * @old : the element to be replaced
201 * @new : the new element to insert
202 *
203 * The old entry will be replaced with the new entry atomically.
204 */
205static inline void list_replace_rcu(struct list_head *old, struct list_head *new){
206 new->next = old->next;
207 new->prev = old->prev;
208 smp_wmb();
209 new->next->prev = new;
210 new->prev->next = new;
211}
212
213/**
214 * list_del_init - deletes entry from list and reinitialize it.
215 * @entry: the element to delete from the list.
216 */
217static inline void list_del_init(struct list_head *entry)
218{
219 __list_del(entry->prev, entry->next);
220 INIT_LIST_HEAD(entry);
221}
222
223/**
224 * list_move - delete from one list and add as another's head
225 * @list: the entry to move
226 * @head: the head that will precede our entry
227 */
228static inline void list_move(struct list_head *list, struct list_head *head)
229{
230 __list_del(list->prev, list->next);
231 list_add(list, head);
232}
233
234/**
235 * list_move_tail - delete from one list and add as another's tail
236 * @list: the entry to move
237 * @head: the head that will follow our entry
238 */
239static inline void list_move_tail(struct list_head *list,
240 struct list_head *head)
241{
242 __list_del(list->prev, list->next);
243 list_add_tail(list, head);
244}
245
246/**
247 * list_empty - tests whether a list is empty
248 * @head: the list to test.
249 */
250static inline int list_empty(const struct list_head *head)
251{
252 return head->next == head;
253}
254
255/**
256 * list_empty_careful - tests whether a list is
257 * empty _and_ checks that no other CPU might be
258 * in the process of still modifying either member
259 *
260 * NOTE: using list_empty_careful() without synchronization
261 * can only be safe if the only activity that can happen
262 * to the list entry is list_del_init(). Eg. it cannot be used
263 * if another CPU could re-list_add() it.
264 *
265 * @head: the list to test.
266 */
267static inline int list_empty_careful(const struct list_head *head)
268{
269 struct list_head *next = head->next;
270 return (next == head) && (next == head->prev);
271}
272
273static inline void __list_splice(struct list_head *list,
274 struct list_head *head)
275{
276 struct list_head *first = list->next;
277 struct list_head *last = list->prev;
278 struct list_head *at = head->next;
279
280 first->prev = head;
281 head->next = first;
282
283 last->next = at;
284 at->prev = last;
285}
286
287/**
288 * list_splice - join two lists
289 * @list: the new list to add.
290 * @head: the place to add it in the first list.
291 */
292static inline void list_splice(struct list_head *list, struct list_head *head)
293{
294 if (!list_empty(list))
295 __list_splice(list, head);
296}
297
298/**
299 * list_splice_init - join two lists and reinitialise the emptied list.
300 * @list: the new list to add.
301 * @head: the place to add it in the first list.
302 *
303 * The list at @list is reinitialised
304 */
305static inline void list_splice_init(struct list_head *list,
306 struct list_head *head)
307{
308 if (!list_empty(list)) {
309 __list_splice(list, head);
310 INIT_LIST_HEAD(list);
311 }
312}
313
314/**
315 * list_entry - get the struct for this entry
316 * @ptr: the &struct list_head pointer.
317 * @type: the type of the struct this is embedded in.
318 * @member: the name of the list_struct within the struct.
319 */
320#define list_entry(ptr, type, member) \
321 container_of(ptr, type, member)
322
323/**
324 * list_for_each - iterate over a list
325 * @pos: the &struct list_head to use as a loop counter.
326 * @head: the head for your list.
327 */
328#define list_for_each(pos, head) \
329 for (pos = (head)->next; prefetch(pos->next), pos != (head); \
330 pos = pos->next)
331
332/**
333 * __list_for_each - iterate over a list
334 * @pos: the &struct list_head to use as a loop counter.
335 * @head: the head for your list.
336 *
337 * This variant differs from list_for_each() in that it's the
338 * simplest possible list iteration code, no prefetching is done.
339 * Use this for code that knows the list to be very short (empty
340 * or 1 entry) most of the time.
341 */
342#define __list_for_each(pos, head) \
343 for (pos = (head)->next; pos != (head); pos = pos->next)
344
345/**
346 * list_for_each_prev - iterate over a list backwards
347 * @pos: the &struct list_head to use as a loop counter.
348 * @head: the head for your list.
349 */
350#define list_for_each_prev(pos, head) \
351 for (pos = (head)->prev; prefetch(pos->prev), pos != (head); \
352 pos = pos->prev)
353
354/**
355 * list_for_each_safe - iterate over a list safe against removal of list entry
356 * @pos: the &struct list_head to use as a loop counter.
357 * @n: another &struct list_head to use as temporary storage
358 * @head: the head for your list.
359 */
360#define list_for_each_safe(pos, n, head) \
361 for (pos = (head)->next, n = pos->next; pos != (head); \
362 pos = n, n = pos->next)
363
364/**
365 * list_for_each_entry - iterate over list of given type
366 * @pos: the type * to use as a loop counter.
367 * @head: the head for your list.
368 * @member: the name of the list_struct within the struct.
369 */
370#define list_for_each_entry(pos, head, member) \
371 for (pos = list_entry((head)->next, typeof(*pos), member); \
372 prefetch(pos->member.next), &pos->member != (head); \
373 pos = list_entry(pos->member.next, typeof(*pos), member))
374
375/**
376 * list_for_each_entry_reverse - iterate backwards over list of given type.
377 * @pos: the type * to use as a loop counter.
378 * @head: the head for your list.
379 * @member: the name of the list_struct within the struct.
380 */
381#define list_for_each_entry_reverse(pos, head, member) \
382 for (pos = list_entry((head)->prev, typeof(*pos), member); \
383 prefetch(pos->member.prev), &pos->member != (head); \
384 pos = list_entry(pos->member.prev, typeof(*pos), member))
385
386/**
387 * list_prepare_entry - prepare a pos entry for use as a start point in
388 * list_for_each_entry_continue
389 * @pos: the type * to use as a start point
390 * @head: the head of the list
391 * @member: the name of the list_struct within the struct.
392 */
393#define list_prepare_entry(pos, head, member) \
394 ((pos) ? : list_entry(head, typeof(*pos), member))
395
396/**
397 * list_for_each_entry_continue - iterate over list of given type
398 * continuing after existing point
399 * @pos: the type * to use as a loop counter.
400 * @head: the head for your list.
401 * @member: the name of the list_struct within the struct.
402 */
403#define list_for_each_entry_continue(pos, head, member) \
404 for (pos = list_entry(pos->member.next, typeof(*pos), member); \
405 prefetch(pos->member.next), &pos->member != (head); \
406 pos = list_entry(pos->member.next, typeof(*pos), member))
407
408/**
409 * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
410 * @pos: the type * to use as a loop counter.
411 * @n: another type * to use as temporary storage
412 * @head: the head for your list.
413 * @member: the name of the list_struct within the struct.
414 */
415#define list_for_each_entry_safe(pos, n, head, member) \
416 for (pos = list_entry((head)->next, typeof(*pos), member), \
417 n = list_entry(pos->member.next, typeof(*pos), member); \
418 &pos->member != (head); \
419 pos = n, n = list_entry(n->member.next, typeof(*n), member))
420
421/**
422 * list_for_each_rcu - iterate over an rcu-protected list
423 * @pos: the &struct list_head to use as a loop counter.
424 * @head: the head for your list.
425 *
426 * This list-traversal primitive may safely run concurrently with
427 * the _rcu list-mutation primitives such as list_add_rcu()
428 * as long as the traversal is guarded by rcu_read_lock().
429 */
430#define list_for_each_rcu(pos, head) \
431 for (pos = (head)->next; prefetch(pos->next), pos != (head); \
432 pos = rcu_dereference(pos->next))
433
434#define __list_for_each_rcu(pos, head) \
435 for (pos = (head)->next; pos != (head); \
436 pos = rcu_dereference(pos->next))
437
438/**
439 * list_for_each_safe_rcu - iterate over an rcu-protected list safe
440 * against removal of list entry
441 * @pos: the &struct list_head to use as a loop counter.
442 * @n: another &struct list_head to use as temporary storage
443 * @head: the head for your list.
444 *
445 * This list-traversal primitive may safely run concurrently with
446 * the _rcu list-mutation primitives such as list_add_rcu()
447 * as long as the traversal is guarded by rcu_read_lock().
448 */
449#define list_for_each_safe_rcu(pos, n, head) \
450 for (pos = (head)->next, n = pos->next; pos != (head); \
451 pos = rcu_dereference(n), n = pos->next)
452
453/**
454 * list_for_each_entry_rcu - iterate over rcu list of given type
455 * @pos: the type * to use as a loop counter.
456 * @head: the head for your list.
457 * @member: the name of the list_struct within the struct.
458 *
459 * This list-traversal primitive may safely run concurrently with
460 * the _rcu list-mutation primitives such as list_add_rcu()
461 * as long as the traversal is guarded by rcu_read_lock().
462 */
463#define list_for_each_entry_rcu(pos, head, member) \
464 for (pos = list_entry((head)->next, typeof(*pos), member); \
465 prefetch(pos->member.next), &pos->member != (head); \
466 pos = rcu_dereference(list_entry(pos->member.next, \
467 typeof(*pos), member)))
468
469
470/**
471 * list_for_each_continue_rcu - iterate over an rcu-protected list
472 * continuing after existing point.
473 * @pos: the &struct list_head to use as a loop counter.
474 * @head: the head for your list.
475 *
476 * This list-traversal primitive may safely run concurrently with
477 * the _rcu list-mutation primitives such as list_add_rcu()
478 * as long as the traversal is guarded by rcu_read_lock().
479 */
480#define list_for_each_continue_rcu(pos, head) \
481 for ((pos) = (pos)->next; prefetch((pos)->next), (pos) != (head); \
482 (pos) = rcu_dereference((pos)->next))
483
484/*
485 * Double linked lists with a single pointer list head.
486 * Mostly useful for hash tables where the two pointer list head is
487 * too wasteful.
488 * You lose the ability to access the tail in O(1).
489 */
490
491struct hlist_head {
492 struct hlist_node *first;
493};
494
495struct hlist_node {
496 struct hlist_node *next, **pprev;
497};
498
499#define HLIST_HEAD_INIT { .first = NULL }
500#define HLIST_HEAD(name) struct hlist_head name = { .first = NULL }
501#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)
502#define INIT_HLIST_NODE(ptr) ((ptr)->next = NULL, (ptr)->pprev = NULL)
503
504static inline int hlist_unhashed(const struct hlist_node *h)
505{
506 return !h->pprev;
507}
508
509static inline int hlist_empty(const struct hlist_head *h)
510{
511 return !h->first;
512}
513
514static inline void __hlist_del(struct hlist_node *n)
515{
516 struct hlist_node *next = n->next;
517 struct hlist_node **pprev = n->pprev;
518 *pprev = next;
519 if (next)
520 next->pprev = pprev;
521}
522
523static inline void hlist_del(struct hlist_node *n)
524{
525 __hlist_del(n);
526 n->next = LIST_POISON1;
527 n->pprev = LIST_POISON2;
528}
529
530/**
531 * hlist_del_rcu - deletes entry from hash list without re-initialization
532 * @n: the element to delete from the hash list.
533 *
534 * Note: list_unhashed() on entry does not return true after this,
535 * the entry is in an undefined state. It is useful for RCU based
536 * lockfree traversal.
537 *
538 * In particular, it means that we can not poison the forward
539 * pointers that may still be used for walking the hash list.
540 *
541 * The caller must take whatever precautions are necessary
542 * (such as holding appropriate locks) to avoid racing
543 * with another list-mutation primitive, such as hlist_add_head_rcu()
544 * or hlist_del_rcu(), running on this same list.
545 * However, it is perfectly legal to run concurrently with
546 * the _rcu list-traversal primitives, such as
547 * hlist_for_each_entry().
548 */
549static inline void hlist_del_rcu(struct hlist_node *n)
550{
551 __hlist_del(n);
552 n->pprev = LIST_POISON2;
553}
554
555static inline void hlist_del_init(struct hlist_node *n)
556{
557 if (n->pprev) {
558 __hlist_del(n);
559 INIT_HLIST_NODE(n);
560 }
561}
562
563static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
564{
565 struct hlist_node *first = h->first;
566 n->next = first;
567 if (first)
568 first->pprev = &n->next;
569 h->first = n;
570 n->pprev = &h->first;
571}
572
573
574/**
575 * hlist_add_head_rcu - adds the specified element to the specified hlist,
576 * while permitting racing traversals.
577 * @n: the element to add to the hash list.
578 * @h: the list to add to.
579 *
580 * The caller must take whatever precautions are necessary
581 * (such as holding appropriate locks) to avoid racing
582 * with another list-mutation primitive, such as hlist_add_head_rcu()
583 * or hlist_del_rcu(), running on this same list.
584 * However, it is perfectly legal to run concurrently with
585 * the _rcu list-traversal primitives, such as
586 * hlist_for_each_rcu(), used to prevent memory-consistency
587 * problems on Alpha CPUs. Regardless of the type of CPU, the
588 * list-traversal primitive must be guarded by rcu_read_lock().
589 */
590static inline void hlist_add_head_rcu(struct hlist_node *n,
591 struct hlist_head *h)
592{
593 struct hlist_node *first = h->first;
594 n->next = first;
595 n->pprev = &h->first;
596 smp_wmb();
597 if (first)
598 first->pprev = &n->next;
599 h->first = n;
600}
601
602/* next must be != NULL */
603static inline void hlist_add_before(struct hlist_node *n,
604 struct hlist_node *next)
605{
606 n->pprev = next->pprev;
607 n->next = next;
608 next->pprev = &n->next;
609 *(n->pprev) = n;
610}
611
612static inline void hlist_add_after(struct hlist_node *n,
613 struct hlist_node *next)
614{
615 next->next = n->next;
616 n->next = next;
617 next->pprev = &n->next;
618
619 if(next->next)
620 next->next->pprev = &next->next;
621}
622
623#define hlist_entry(ptr, type, member) container_of(ptr,type,member)
624
625#define hlist_for_each(pos, head) \
626 for (pos = (head)->first; pos && ({ prefetch(pos->next); 1; }); \
627 pos = pos->next)
628
629#define hlist_for_each_safe(pos, n, head) \
630 for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \
631 pos = n)
632
633#define hlist_for_each_rcu(pos, head) \
634 for ((pos) = (head)->first; pos && ({ prefetch((pos)->next); 1; }); \
635 (pos) = rcu_dereference((pos)->next))
636
637/**
638 * hlist_for_each_entry - iterate over list of given type
639 * @tpos: the type * to use as a loop counter.
640 * @pos: the &struct hlist_node to use as a loop counter.
641 * @head: the head for your list.
642 * @member: the name of the hlist_node within the struct.
643 */
644#define hlist_for_each_entry(tpos, pos, head, member) \
645 for (pos = (head)->first; \
646 pos && ({ prefetch(pos->next); 1;}) && \
647 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
648 pos = pos->next)
649
650/**
651 * hlist_for_each_entry_continue - iterate over a hlist continuing after existing point
652 * @tpos: the type * to use as a loop counter.
653 * @pos: the &struct hlist_node to use as a loop counter.
654 * @member: the name of the hlist_node within the struct.
655 */
656#define hlist_for_each_entry_continue(tpos, pos, member) \
657 for (pos = (pos)->next; \
658 pos && ({ prefetch(pos->next); 1;}) && \
659 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
660 pos = pos->next)
661
662/**
663 * hlist_for_each_entry_from - iterate over a hlist continuing from existing point
664 * @tpos: the type * to use as a loop counter.
665 * @pos: the &struct hlist_node to use as a loop counter.
666 * @member: the name of the hlist_node within the struct.
667 */
668#define hlist_for_each_entry_from(tpos, pos, member) \
669 for (; pos && ({ prefetch(pos->next); 1;}) && \
670 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
671 pos = pos->next)
672
673/**
674 * hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry
675 * @tpos: the type * to use as a loop counter.
676 * @pos: the &struct hlist_node to use as a loop counter.
677 * @n: another &struct hlist_node to use as temporary storage
678 * @head: the head for your list.
679 * @member: the name of the hlist_node within the struct.
680 */
681#define hlist_for_each_entry_safe(tpos, pos, n, head, member) \
682 for (pos = (head)->first; \
683 pos && ({ n = pos->next; 1; }) && \
684 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
685 pos = n)
686
687/**
688 * hlist_for_each_entry_rcu - iterate over rcu list of given type
689 * @pos: the type * to use as a loop counter.
690 * @pos: the &struct hlist_node to use as a loop counter.
691 * @head: the head for your list.
692 * @member: the name of the hlist_node within the struct.
693 *
694 * This list-traversal primitive may safely run concurrently with
695 * the _rcu list-mutation primitives such as hlist_add_rcu()
696 * as long as the traversal is guarded by rcu_read_lock().
697 */
698#define hlist_for_each_entry_rcu(tpos, pos, head, member) \
699 for (pos = (head)->first; \
700 pos && ({ prefetch(pos->next); 1;}) && \
701 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
702 pos = rcu_dereference(pos->next))
703
704#else
705#warning "don't include kernel headers in userspace"
706#endif /* __KERNEL__ */
707#endif
diff --git a/include/linux/llc.h b/include/linux/llc.h
new file mode 100644
index 000000000000..09f2e6d0e9eb
--- /dev/null
+++ b/include/linux/llc.h
@@ -0,0 +1,80 @@
1#ifndef __LINUX_LLC_H
2#define __LINUX_LLC_H
3/*
4 * IEEE 802.2 User Interface SAPs for Linux, data structures and indicators.
5 *
6 * Copyright (c) 2001 by Jay Schulist <jschlst@samba.org>
7 *
8 * This program can be redistributed or modified under the terms of the
9 * GNU General Public License as published by the Free Software Foundation.
10 * This program is distributed without any warranty or implied warranty
11 * of merchantability or fitness for a particular purpose.
12 *
13 * See the GNU General Public License for more details.
14 */
15#define __LLC_SOCK_SIZE__ 16 /* sizeof(sockaddr_llc), word align. */
16struct sockaddr_llc {
17 sa_family_t sllc_family; /* AF_LLC */
18 sa_family_t sllc_arphrd; /* ARPHRD_ETHER */
19 unsigned char sllc_test;
20 unsigned char sllc_xid;
21 unsigned char sllc_ua; /* UA data, only for SOCK_STREAM. */
22 unsigned char sllc_sap;
23 unsigned char sllc_mac[IFHWADDRLEN];
24 unsigned char __pad[__LLC_SOCK_SIZE__ - sizeof(sa_family_t) * 2 -
25 sizeof(unsigned char) * 4 - IFHWADDRLEN];
26};
27
28/* sockopt definitions. */
29enum llc_sockopts {
30 LLC_OPT_UNKNOWN = 0,
31 LLC_OPT_RETRY, /* max retrans attempts. */
32 LLC_OPT_SIZE, /* max PDU size (octets). */
33 LLC_OPT_ACK_TMR_EXP, /* ack expire time (secs). */
34 LLC_OPT_P_TMR_EXP, /* pf cycle expire time (secs). */
35 LLC_OPT_REJ_TMR_EXP, /* rej sent expire time (secs). */
36 LLC_OPT_BUSY_TMR_EXP, /* busy state expire time (secs). */
37 LLC_OPT_TX_WIN, /* tx window size. */
38 LLC_OPT_RX_WIN, /* rx window size. */
39 LLC_OPT_MAX
40};
41
42#define LLC_OPT_MAX_RETRY 100
43#define LLC_OPT_MAX_SIZE 4196
44#define LLC_OPT_MAX_WIN 127
45#define LLC_OPT_MAX_ACK_TMR_EXP 60
46#define LLC_OPT_MAX_P_TMR_EXP 60
47#define LLC_OPT_MAX_REJ_TMR_EXP 60
48#define LLC_OPT_MAX_BUSY_TMR_EXP 60
49
50/* LLC SAP types. */
51#define LLC_SAP_NULL 0x00 /* NULL SAP. */
52#define LLC_SAP_LLC 0x02 /* LLC Sublayer Managment. */
53#define LLC_SAP_SNA 0x04 /* SNA Path Control. */
54#define LLC_SAP_PNM 0x0E /* Proway Network Managment. */
55#define LLC_SAP_IP 0x06 /* TCP/IP. */
56#define LLC_SAP_BSPAN 0x42 /* Bridge Spanning Tree Proto */
57#define LLC_SAP_MMS 0x4E /* Manufacturing Message Srv. */
58#define LLC_SAP_8208 0x7E /* ISO 8208 */
59#define LLC_SAP_3COM 0x80 /* 3COM. */
60#define LLC_SAP_PRO 0x8E /* Proway Active Station List */
61#define LLC_SAP_SNAP 0xAA /* SNAP. */
62#define LLC_SAP_BANYAN 0xBC /* Banyan. */
63#define LLC_SAP_IPX 0xE0 /* IPX/SPX. */
64#define LLC_SAP_NETBEUI 0xF0 /* NetBEUI. */
65#define LLC_SAP_LANMGR 0xF4 /* LanManager. */
66#define LLC_SAP_IMPL 0xF8 /* IMPL */
67#define LLC_SAP_DISC 0xFC /* Discovery */
68#define LLC_SAP_OSI 0xFE /* OSI Network Layers. */
69#define LLC_SAP_LAR 0xDC /* LAN Address Resolution */
70#define LLC_SAP_RM 0xD4 /* Resource Management */
71#define LLC_SAP_GLOBAL 0xFF /* Global SAP. */
72
73#ifdef __KERNEL__
74#define LLC_SAP_DYN_START 0xC0
75#define LLC_SAP_DYN_STOP 0xDE
76#define LLC_SAP_DYN_TRIES 4
77
78#define llc_ui_skb_cb(__skb) ((struct sockaddr_llc *)&((__skb)->cb[0]))
79#endif /* __KERNEL__ */
80#endif /* __LINUX_LLC_H */
diff --git a/include/linux/lockd/bind.h b/include/linux/lockd/bind.h
new file mode 100644
index 000000000000..b054debef2e0
--- /dev/null
+++ b/include/linux/lockd/bind.h
@@ -0,0 +1,36 @@
1/*
2 * linux/include/linux/lockd/bind.h
3 *
4 * This is the part of lockd visible to nfsd and the nfs client.
5 *
6 * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
7 */
8
9#ifndef LINUX_LOCKD_BIND_H
10#define LINUX_LOCKD_BIND_H
11
12#include <linux/lockd/nlm.h>
13
14/* Dummy declarations */
15struct svc_rqst;
16
17/*
18 * This is the set of functions for lockd->nfsd communication
19 */
20struct nlmsvc_binding {
21 u32 (*fopen)(struct svc_rqst *,
22 struct nfs_fh *,
23 struct file **);
24 void (*fclose)(struct file *);
25};
26
27extern struct nlmsvc_binding * nlmsvc_ops;
28
29/*
30 * Functions exported by the lockd module
31 */
32extern int nlmclnt_proc(struct inode *, int, struct file_lock *);
33extern int lockd_up(void);
34extern void lockd_down(void);
35
36#endif /* LINUX_LOCKD_BIND_H */
diff --git a/include/linux/lockd/debug.h b/include/linux/lockd/debug.h
new file mode 100644
index 000000000000..34b2b7f33c3b
--- /dev/null
+++ b/include/linux/lockd/debug.h
@@ -0,0 +1,57 @@
1/*
2 * linux/include/linux/lockd/debug.h
3 *
4 * Debugging stuff.
5 *
6 * Copyright (C) 1996 Olaf Kirch <okir@monad.swb.de>
7 */
8
9#ifndef LINUX_LOCKD_DEBUG_H
10#define LINUX_LOCKD_DEBUG_H
11
12#ifdef __KERNEL__
13
14#include <linux/sunrpc/debug.h>
15
16/*
17 * Enable lockd debugging.
18 * Requires RPC_DEBUG.
19 */
20#ifdef RPC_DEBUG
21# define LOCKD_DEBUG 1
22#endif
23
24#undef ifdebug
25#if defined(RPC_DEBUG) && defined(LOCKD_DEBUG)
26# define ifdebug(flag) if (unlikely(nlm_debug & NLMDBG_##flag))
27#else
28# define ifdebug(flag) if (0)
29#endif
30
31#endif /* __KERNEL__ */
32
33/*
34 * Debug flags
35 */
36#define NLMDBG_SVC 0x0001
37#define NLMDBG_CLIENT 0x0002
38#define NLMDBG_CLNTLOCK 0x0004
39#define NLMDBG_SVCLOCK 0x0008
40#define NLMDBG_MONITOR 0x0010
41#define NLMDBG_CLNTSUBS 0x0020
42#define NLMDBG_SVCSUBS 0x0040
43#define NLMDBG_HOSTCACHE 0x0080
44#define NLMDBG_XDR 0x0100
45#define NLMDBG_ALL 0x7fff
46
47
48/*
49 * Support for printing NLM cookies in dprintk()
50 */
51#ifdef RPC_DEBUG
52struct nlm_cookie;
53/* Call this function with the BKL held (it uses a static buffer) */
54extern const char *nlmdbg_cookie2a(const struct nlm_cookie *);
55#endif
56
57#endif /* LINUX_LOCKD_DEBUG_H */
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
new file mode 100644
index 000000000000..0d9d22578212
--- /dev/null
+++ b/include/linux/lockd/lockd.h
@@ -0,0 +1,224 @@
1/*
2 * linux/include/linux/lockd/lockd.h
3 *
4 * General-purpose lockd include file.
5 *
6 * Copyright (C) 1996 Olaf Kirch <okir@monad.swb.de>
7 */
8
9#ifndef LINUX_LOCKD_LOCKD_H
10#define LINUX_LOCKD_LOCKD_H
11
12#ifdef __KERNEL__
13
14#include <linux/config.h>
15#include <linux/in.h>
16#include <linux/fs.h>
17#include <linux/utsname.h>
18#include <linux/nfsd/nfsfh.h>
19#include <linux/lockd/bind.h>
20#include <linux/lockd/xdr.h>
21#ifdef CONFIG_LOCKD_V4
22#include <linux/lockd/xdr4.h>
23#endif
24#include <linux/lockd/debug.h>
25
26/*
27 * Version string
28 */
29#define LOCKD_VERSION "0.5"
30
31/*
32 * Default timeout for RPC calls (seconds)
33 */
34#define LOCKD_DFLT_TIMEO 10
35
36/*
37 * Lockd host handle (used both by the client and server personality).
38 */
39struct nlm_host {
40 struct nlm_host * h_next; /* linked list (hash table) */
41 struct sockaddr_in h_addr; /* peer address */
42 struct rpc_clnt * h_rpcclnt; /* RPC client to talk to peer */
43 char h_name[20]; /* remote hostname */
44 u32 h_version; /* interface version */
45 unsigned short h_proto; /* transport proto */
46 unsigned short h_reclaiming : 1,
47 h_server : 1, /* server side, not client side */
48 h_inuse : 1,
49 h_killed : 1,
50 h_monitored : 1;
51 wait_queue_head_t h_gracewait; /* wait while reclaiming */
52 u32 h_state; /* pseudo-state counter */
53 u32 h_nsmstate; /* true remote NSM state */
54 u32 h_pidcount; /* Pseudopids */
55 atomic_t h_count; /* reference count */
56 struct semaphore h_sema; /* mutex for pmap binding */
57 unsigned long h_nextrebind; /* next portmap call */
58 unsigned long h_expires; /* eligible for GC */
59 struct list_head h_lockowners; /* Lockowners for the client */
60 spinlock_t h_lock;
61};
62
63/*
64 * Map an fl_owner_t into a unique 32-bit "pid"
65 */
66struct nlm_lockowner {
67 struct list_head list;
68 atomic_t count;
69
70 struct nlm_host *host;
71 fl_owner_t owner;
72 uint32_t pid;
73};
74
75/*
76 * Memory chunk for NLM client RPC request.
77 */
78#define NLMCLNT_OHSIZE (sizeof(system_utsname.nodename)+10)
79struct nlm_rqst {
80 unsigned int a_flags; /* initial RPC task flags */
81 struct nlm_host * a_host; /* host handle */
82 struct nlm_args a_args; /* arguments */
83 struct nlm_res a_res; /* result */
84 char a_owner[NLMCLNT_OHSIZE];
85};
86
87/*
88 * This struct describes a file held open by lockd on behalf of
89 * an NFS client.
90 */
91struct nlm_file {
92 struct nlm_file * f_next; /* linked list */
93 struct nfs_fh f_handle; /* NFS file handle */
94 struct file * f_file; /* VFS file pointer */
95 struct nlm_share * f_shares; /* DOS shares */
96 struct nlm_block * f_blocks; /* blocked locks */
97 unsigned int f_locks; /* guesstimate # of locks */
98 unsigned int f_count; /* reference count */
99 struct semaphore f_sema; /* avoid concurrent access */
100 int f_hash; /* hash of f_handle */
101};
102
103/*
104 * This is a server block (i.e. a lock requested by some client which
105 * couldn't be granted because of a conflicting lock).
106 */
107#define NLM_NEVER (~(unsigned long) 0)
108struct nlm_block {
109 struct nlm_block * b_next; /* linked list (all blocks) */
110 struct nlm_block * b_fnext; /* linked list (per file) */
111 struct nlm_rqst b_call; /* RPC args & callback info */
112 struct svc_serv * b_daemon; /* NLM service */
113 struct nlm_host * b_host; /* host handle for RPC clnt */
114 unsigned long b_when; /* next re-xmit */
115 unsigned int b_id; /* block id */
116 unsigned char b_queued; /* re-queued */
117 unsigned char b_granted; /* VFS granted lock */
118 unsigned char b_incall; /* doing callback */
119 unsigned char b_done; /* callback complete */
120 struct nlm_file * b_file; /* file in question */
121};
122
123/*
124 * Valid actions for nlmsvc_traverse_files
125 */
126#define NLM_ACT_CHECK 0 /* check for locks */
127#define NLM_ACT_MARK 1 /* mark & sweep */
128#define NLM_ACT_UNLOCK 2 /* release all locks */
129
130/*
131 * Global variables
132 */
133extern struct rpc_program nlm_program;
134extern struct svc_procedure nlmsvc_procedures[];
135#ifdef CONFIG_LOCKD_V4
136extern struct svc_procedure nlmsvc_procedures4[];
137#endif
138extern int nlmsvc_grace_period;
139extern unsigned long nlmsvc_timeout;
140
141/*
142 * Lockd client functions
143 */
144struct nlm_rqst * nlmclnt_alloc_call(void);
145int nlmclnt_block(struct nlm_host *, struct file_lock *, u32 *);
146int nlmclnt_cancel(struct nlm_host *, struct file_lock *);
147u32 nlmclnt_grant(struct nlm_lock *);
148void nlmclnt_recovery(struct nlm_host *, u32);
149int nlmclnt_reclaim(struct nlm_host *, struct file_lock *);
150int nlmclnt_setgrantargs(struct nlm_rqst *, struct nlm_lock *);
151void nlmclnt_freegrantargs(struct nlm_rqst *);
152
153/*
154 * Host cache
155 */
156struct nlm_host * nlmclnt_lookup_host(struct sockaddr_in *, int, int);
157struct nlm_host * nlmsvc_lookup_host(struct svc_rqst *);
158struct nlm_host * nlm_lookup_host(int server, struct sockaddr_in *, int, int);
159struct rpc_clnt * nlm_bind_host(struct nlm_host *);
160void nlm_rebind_host(struct nlm_host *);
161struct nlm_host * nlm_get_host(struct nlm_host *);
162void nlm_release_host(struct nlm_host *);
163void nlm_shutdown_hosts(void);
164extern struct nlm_host *nlm_find_client(void);
165
166
167/*
168 * Server-side lock handling
169 */
170int nlmsvc_async_call(struct nlm_rqst *, u32, rpc_action);
171u32 nlmsvc_lock(struct svc_rqst *, struct nlm_file *,
172 struct nlm_lock *, int, struct nlm_cookie *);
173u32 nlmsvc_unlock(struct nlm_file *, struct nlm_lock *);
174u32 nlmsvc_testlock(struct nlm_file *, struct nlm_lock *,
175 struct nlm_lock *);
176u32 nlmsvc_cancel_blocked(struct nlm_file *, struct nlm_lock *);
177unsigned long nlmsvc_retry_blocked(void);
178int nlmsvc_traverse_blocks(struct nlm_host *, struct nlm_file *,
179 int action);
180void nlmsvc_grant_reply(struct svc_rqst *, struct nlm_cookie *, u32);
181
182/*
183 * File handling for the server personality
184 */
185u32 nlm_lookup_file(struct svc_rqst *, struct nlm_file **,
186 struct nfs_fh *);
187void nlm_release_file(struct nlm_file *);
188void nlmsvc_mark_resources(void);
189void nlmsvc_free_host_resources(struct nlm_host *);
190void nlmsvc_invalidate_all(void);
191
192static __inline__ struct inode *
193nlmsvc_file_inode(struct nlm_file *file)
194{
195 return file->f_file->f_dentry->d_inode;
196}
197
198/*
199 * Compare two host addresses (needs modifying for ipv6)
200 */
201static __inline__ int
202nlm_cmp_addr(struct sockaddr_in *sin1, struct sockaddr_in *sin2)
203{
204 return sin1->sin_addr.s_addr == sin2->sin_addr.s_addr;
205}
206
207/*
208 * Compare two NLM locks.
209 * When the second lock is of type F_UNLCK, this acts like a wildcard.
210 */
211static __inline__ int
212nlm_compare_locks(struct file_lock *fl1, struct file_lock *fl2)
213{
214 return fl1->fl_pid == fl2->fl_pid
215 && fl1->fl_start == fl2->fl_start
216 && fl1->fl_end == fl2->fl_end
217 &&(fl1->fl_type == fl2->fl_type || fl2->fl_type == F_UNLCK);
218}
219
220extern struct lock_manager_operations nlmsvc_lock_operations;
221
222#endif /* __KERNEL__ */
223
224#endif /* LINUX_LOCKD_LOCKD_H */
diff --git a/include/linux/lockd/nlm.h b/include/linux/lockd/nlm.h
new file mode 100644
index 000000000000..869b630cba24
--- /dev/null
+++ b/include/linux/lockd/nlm.h
@@ -0,0 +1,58 @@
1/*
2 * linux/include/linux/lockd/nlm.h
3 *
4 * Declarations for the Network Lock Manager protocol.
5 *
6 * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
7 */
8
9#ifndef LINUX_LOCKD_NLM_H
10#define LINUX_LOCKD_NLM_H
11
12#include <linux/config.h>
13
14/* Maximum file offset in file_lock.fl_end */
15# define NLM_OFFSET_MAX ((s32) 0x7fffffff)
16# define NLM4_OFFSET_MAX ((s64) ((~(u64)0) >> 1))
17
18/* Return states for NLM */
19enum {
20 NLM_LCK_GRANTED = 0,
21 NLM_LCK_DENIED = 1,
22 NLM_LCK_DENIED_NOLOCKS = 2,
23 NLM_LCK_BLOCKED = 3,
24 NLM_LCK_DENIED_GRACE_PERIOD = 4,
25#ifdef CONFIG_LOCKD_V4
26 NLM_DEADLCK = 5,
27 NLM_ROFS = 6,
28 NLM_STALE_FH = 7,
29 NLM_FBIG = 8,
30 NLM_FAILED = 9,
31#endif
32};
33
34#define NLM_PROGRAM 100021
35
36#define NLMPROC_NULL 0
37#define NLMPROC_TEST 1
38#define NLMPROC_LOCK 2
39#define NLMPROC_CANCEL 3
40#define NLMPROC_UNLOCK 4
41#define NLMPROC_GRANTED 5
42#define NLMPROC_TEST_MSG 6
43#define NLMPROC_LOCK_MSG 7
44#define NLMPROC_CANCEL_MSG 8
45#define NLMPROC_UNLOCK_MSG 9
46#define NLMPROC_GRANTED_MSG 10
47#define NLMPROC_TEST_RES 11
48#define NLMPROC_LOCK_RES 12
49#define NLMPROC_CANCEL_RES 13
50#define NLMPROC_UNLOCK_RES 14
51#define NLMPROC_GRANTED_RES 15
52#define NLMPROC_NSM_NOTIFY 16 /* statd callback */
53#define NLMPROC_SHARE 20
54#define NLMPROC_UNSHARE 21
55#define NLMPROC_NM_LOCK 22
56#define NLMPROC_FREE_ALL 23
57
58#endif /* LINUX_LOCKD_NLM_H */
diff --git a/include/linux/lockd/share.h b/include/linux/lockd/share.h
new file mode 100644
index 000000000000..5d8aa325f140
--- /dev/null
+++ b/include/linux/lockd/share.h
@@ -0,0 +1,30 @@
1/*
2 * linux/include/linux/lockd/share.h
3 *
4 * DOS share management for lockd.
5 *
6 * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
7 */
8
9#ifndef LINUX_LOCKD_SHARE_H
10#define LINUX_LOCKD_SHARE_H
11
12/*
13 * DOS share for a specific file
14 */
15struct nlm_share {
16 struct nlm_share * s_next; /* linked list */
17 struct nlm_host * s_host; /* client host */
18 struct nlm_file * s_file; /* shared file */
19 struct xdr_netobj s_owner; /* owner handle */
20 u32 s_access; /* access mode */
21 u32 s_mode; /* deny mode */
22};
23
24u32 nlmsvc_share_file(struct nlm_host *, struct nlm_file *,
25 struct nlm_args *);
26u32 nlmsvc_unshare_file(struct nlm_host *, struct nlm_file *,
27 struct nlm_args *);
28int nlmsvc_traverse_shares(struct nlm_host *, struct nlm_file *, int);
29
30#endif /* LINUX_LOCKD_SHARE_H */
diff --git a/include/linux/lockd/sm_inter.h b/include/linux/lockd/sm_inter.h
new file mode 100644
index 000000000000..1080bb6ae315
--- /dev/null
+++ b/include/linux/lockd/sm_inter.h
@@ -0,0 +1,46 @@
1/*
2 * linux/include/linux/lockd/sm_inter.h
3 *
4 * Declarations for the kernel statd client.
5 *
6 * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
7 */
8
9#ifndef LINUX_LOCKD_SM_INTER_H
10#define LINUX_LOCKD_SM_INTER_H
11
12#define SM_PROGRAM 100024
13#define SM_VERSION 1
14#define SM_STAT 1
15#define SM_MON 2
16#define SM_UNMON 3
17#define SM_UNMON_ALL 4
18#define SM_SIMU_CRASH 5
19#define SM_NOTIFY 6
20
21#define SM_MAXSTRLEN 1024
22
23/*
24 * Arguments for all calls to statd
25 */
26struct nsm_args {
27 u32 addr; /* remote address */
28 u32 prog; /* RPC callback info */
29 u32 vers;
30 u32 proc;
31 u32 proto; /* protocol (udp/tcp) plus server/client flag */
32};
33
34/*
35 * Result returned by statd
36 */
37struct nsm_res {
38 u32 status;
39 u32 state;
40};
41
42int nsm_monitor(struct nlm_host *);
43int nsm_unmonitor(struct nlm_host *);
44extern u32 nsm_local_state;
45
46#endif /* LINUX_LOCKD_SM_INTER_H */
diff --git a/include/linux/lockd/xdr.h b/include/linux/lockd/xdr.h
new file mode 100644
index 000000000000..d7a5cc4cfa97
--- /dev/null
+++ b/include/linux/lockd/xdr.h
@@ -0,0 +1,108 @@
1/*
2 * linux/include/linux/lockd/xdr.h
3 *
4 * XDR types for the NLM protocol
5 *
6 * Copyright (C) 1996 Olaf Kirch <okir@monad.swb.de>
7 */
8
9#ifndef LOCKD_XDR_H
10#define LOCKD_XDR_H
11
12#include <linux/fs.h>
13#include <linux/nfs.h>
14#include <linux/sunrpc/xdr.h>
15
16#define NLM_MAXCOOKIELEN 32
17#define NLM_MAXSTRLEN 1024
18
19#define nlm_granted __constant_htonl(NLM_LCK_GRANTED)
20#define nlm_lck_denied __constant_htonl(NLM_LCK_DENIED)
21#define nlm_lck_denied_nolocks __constant_htonl(NLM_LCK_DENIED_NOLOCKS)
22#define nlm_lck_blocked __constant_htonl(NLM_LCK_BLOCKED)
23#define nlm_lck_denied_grace_period __constant_htonl(NLM_LCK_DENIED_GRACE_PERIOD)
24
25/* Lock info passed via NLM */
26struct nlm_lock {
27 char * caller;
28 int len; /* length of "caller" */
29 struct nfs_fh fh;
30 struct xdr_netobj oh;
31 struct file_lock fl;
32};
33
34/*
35 * NLM cookies. Technically they can be 1K, but Linux only uses 8 bytes.
36 * FreeBSD uses 16, Apple Mac OS X 10.3 uses 20. Therefore we set it to
37 * 32 bytes.
38 */
39
40struct nlm_cookie
41{
42 unsigned char data[NLM_MAXCOOKIELEN];
43 unsigned int len;
44};
45
46/*
47 * Generic lockd arguments for all but sm_notify
48 */
49struct nlm_args {
50 struct nlm_cookie cookie;
51 struct nlm_lock lock;
52 u32 block;
53 u32 reclaim;
54 u32 state;
55 u32 monitor;
56 u32 fsm_access;
57 u32 fsm_mode;
58};
59
60typedef struct nlm_args nlm_args;
61
62/*
63 * Generic lockd result
64 */
65struct nlm_res {
66 struct nlm_cookie cookie;
67 u32 status;
68 struct nlm_lock lock;
69};
70
71/*
72 * statd callback when client has rebooted
73 */
74struct nlm_reboot {
75 char * mon;
76 int len;
77 u32 state;
78 u32 addr;
79 u32 vers;
80 u32 proto;
81};
82
83/*
84 * Contents of statd callback when monitored host rebooted
85 */
86#define NLMSVC_XDRSIZE sizeof(struct nlm_args)
87
88int nlmsvc_decode_testargs(struct svc_rqst *, u32 *, struct nlm_args *);
89int nlmsvc_encode_testres(struct svc_rqst *, u32 *, struct nlm_res *);
90int nlmsvc_decode_lockargs(struct svc_rqst *, u32 *, struct nlm_args *);
91int nlmsvc_decode_cancargs(struct svc_rqst *, u32 *, struct nlm_args *);
92int nlmsvc_decode_unlockargs(struct svc_rqst *, u32 *, struct nlm_args *);
93int nlmsvc_encode_res(struct svc_rqst *, u32 *, struct nlm_res *);
94int nlmsvc_decode_res(struct svc_rqst *, u32 *, struct nlm_res *);
95int nlmsvc_encode_void(struct svc_rqst *, u32 *, void *);
96int nlmsvc_decode_void(struct svc_rqst *, u32 *, void *);
97int nlmsvc_decode_shareargs(struct svc_rqst *, u32 *, struct nlm_args *);
98int nlmsvc_encode_shareres(struct svc_rqst *, u32 *, struct nlm_res *);
99int nlmsvc_decode_notify(struct svc_rqst *, u32 *, struct nlm_args *);
100int nlmsvc_decode_reboot(struct svc_rqst *, u32 *, struct nlm_reboot *);
101/*
102int nlmclt_encode_testargs(struct rpc_rqst *, u32 *, struct nlm_args *);
103int nlmclt_encode_lockargs(struct rpc_rqst *, u32 *, struct nlm_args *);
104int nlmclt_encode_cancargs(struct rpc_rqst *, u32 *, struct nlm_args *);
105int nlmclt_encode_unlockargs(struct rpc_rqst *, u32 *, struct nlm_args *);
106 */
107
108#endif /* LOCKD_XDR_H */
diff --git a/include/linux/lockd/xdr4.h b/include/linux/lockd/xdr4.h
new file mode 100644
index 000000000000..cee36e7c0548
--- /dev/null
+++ b/include/linux/lockd/xdr4.h
@@ -0,0 +1,46 @@
1/*
2 * linux/include/linux/lockd/xdr.h
3 *
4 * XDR types for the NLM protocol
5 *
6 * Copyright (C) 1996 Olaf Kirch <okir@monad.swb.de>
7 */
8
9#ifndef LOCKD_XDR4_H
10#define LOCKD_XDR4_H
11
12#include <linux/fs.h>
13#include <linux/nfs.h>
14#include <linux/sunrpc/xdr.h>
15#include <linux/lockd/xdr.h>
16
17/* error codes new to NLMv4 */
18#define nlm4_deadlock __constant_htonl(NLM_DEADLCK)
19#define nlm4_rofs __constant_htonl(NLM_ROFS)
20#define nlm4_stale_fh __constant_htonl(NLM_STALE_FH)
21#define nlm4_fbig __constant_htonl(NLM_FBIG)
22#define nlm4_failed __constant_htonl(NLM_FAILED)
23
24
25
26int nlm4svc_decode_testargs(struct svc_rqst *, u32 *, struct nlm_args *);
27int nlm4svc_encode_testres(struct svc_rqst *, u32 *, struct nlm_res *);
28int nlm4svc_decode_lockargs(struct svc_rqst *, u32 *, struct nlm_args *);
29int nlm4svc_decode_cancargs(struct svc_rqst *, u32 *, struct nlm_args *);
30int nlm4svc_decode_unlockargs(struct svc_rqst *, u32 *, struct nlm_args *);
31int nlm4svc_encode_res(struct svc_rqst *, u32 *, struct nlm_res *);
32int nlm4svc_decode_res(struct svc_rqst *, u32 *, struct nlm_res *);
33int nlm4svc_encode_void(struct svc_rqst *, u32 *, void *);
34int nlm4svc_decode_void(struct svc_rqst *, u32 *, void *);
35int nlm4svc_decode_shareargs(struct svc_rqst *, u32 *, struct nlm_args *);
36int nlm4svc_encode_shareres(struct svc_rqst *, u32 *, struct nlm_res *);
37int nlm4svc_decode_notify(struct svc_rqst *, u32 *, struct nlm_args *);
38int nlm4svc_decode_reboot(struct svc_rqst *, u32 *, struct nlm_reboot *);
39/*
40int nlmclt_encode_testargs(struct rpc_rqst *, u32 *, struct nlm_args *);
41int nlmclt_encode_lockargs(struct rpc_rqst *, u32 *, struct nlm_args *);
42int nlmclt_encode_cancargs(struct rpc_rqst *, u32 *, struct nlm_args *);
43int nlmclt_encode_unlockargs(struct rpc_rqst *, u32 *, struct nlm_args *);
44 */
45
46#endif /* LOCKD_XDR4_H */
diff --git a/include/linux/loop.h b/include/linux/loop.h
new file mode 100644
index 000000000000..8220d9c9da00
--- /dev/null
+++ b/include/linux/loop.h
@@ -0,0 +1,161 @@
1#ifndef _LINUX_LOOP_H
2#define _LINUX_LOOP_H
3
4/*
5 * include/linux/loop.h
6 *
7 * Written by Theodore Ts'o, 3/29/93.
8 *
9 * Copyright 1993 by Theodore Ts'o. Redistribution of this file is
10 * permitted under the GNU General Public License.
11 */
12
13#define LO_NAME_SIZE 64
14#define LO_KEY_SIZE 32
15
16#ifdef __KERNEL__
17#include <linux/bio.h>
18#include <linux/blkdev.h>
19#include <linux/spinlock.h>
20
21/* Possible states of device */
22enum {
23 Lo_unbound,
24 Lo_bound,
25 Lo_rundown,
26};
27
28struct loop_func_table;
29
30struct loop_device {
31 int lo_number;
32 int lo_refcnt;
33 loff_t lo_offset;
34 loff_t lo_sizelimit;
35 int lo_flags;
36 int (*transfer)(struct loop_device *, int cmd,
37 struct page *raw_page, unsigned raw_off,
38 struct page *loop_page, unsigned loop_off,
39 int size, sector_t real_block);
40 char lo_file_name[LO_NAME_SIZE];
41 char lo_crypt_name[LO_NAME_SIZE];
42 char lo_encrypt_key[LO_KEY_SIZE];
43 int lo_encrypt_key_size;
44 struct loop_func_table *lo_encryption;
45 __u32 lo_init[2];
46 uid_t lo_key_owner; /* Who set the key */
47 int (*ioctl)(struct loop_device *, int cmd,
48 unsigned long arg);
49
50 struct file * lo_backing_file;
51 struct block_device *lo_device;
52 unsigned lo_blocksize;
53 void *key_data;
54
55 int old_gfp_mask;
56
57 spinlock_t lo_lock;
58 struct bio *lo_bio;
59 struct bio *lo_biotail;
60 int lo_state;
61 struct semaphore lo_sem;
62 struct semaphore lo_ctl_mutex;
63 struct semaphore lo_bh_mutex;
64 atomic_t lo_pending;
65
66 request_queue_t *lo_queue;
67};
68
69#endif /* __KERNEL__ */
70
71/*
72 * Loop flags
73 */
74enum {
75 LO_FLAGS_READ_ONLY = 1,
76 LO_FLAGS_USE_AOPS = 2,
77};
78
79#include <asm/posix_types.h> /* for __kernel_old_dev_t */
80#include <asm/types.h> /* for __u64 */
81
82/* Backwards compatibility version */
83struct loop_info {
84 int lo_number; /* ioctl r/o */
85 __kernel_old_dev_t lo_device; /* ioctl r/o */
86 unsigned long lo_inode; /* ioctl r/o */
87 __kernel_old_dev_t lo_rdevice; /* ioctl r/o */
88 int lo_offset;
89 int lo_encrypt_type;
90 int lo_encrypt_key_size; /* ioctl w/o */
91 int lo_flags; /* ioctl r/o */
92 char lo_name[LO_NAME_SIZE];
93 unsigned char lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
94 unsigned long lo_init[2];
95 char reserved[4];
96};
97
98struct loop_info64 {
99 __u64 lo_device; /* ioctl r/o */
100 __u64 lo_inode; /* ioctl r/o */
101 __u64 lo_rdevice; /* ioctl r/o */
102 __u64 lo_offset;
103 __u64 lo_sizelimit;/* bytes, 0 == max available */
104 __u32 lo_number; /* ioctl r/o */
105 __u32 lo_encrypt_type;
106 __u32 lo_encrypt_key_size; /* ioctl w/o */
107 __u32 lo_flags; /* ioctl r/o */
108 __u8 lo_file_name[LO_NAME_SIZE];
109 __u8 lo_crypt_name[LO_NAME_SIZE];
110 __u8 lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
111 __u64 lo_init[2];
112};
113
114/*
115 * Loop filter types
116 */
117
118#define LO_CRYPT_NONE 0
119#define LO_CRYPT_XOR 1
120#define LO_CRYPT_DES 2
121#define LO_CRYPT_FISH2 3 /* Twofish encryption */
122#define LO_CRYPT_BLOW 4
123#define LO_CRYPT_CAST128 5
124#define LO_CRYPT_IDEA 6
125#define LO_CRYPT_DUMMY 9
126#define LO_CRYPT_SKIPJACK 10
127#define LO_CRYPT_CRYPTOAPI 18
128#define MAX_LO_CRYPT 20
129
130#ifdef __KERNEL__
131/* Support for loadable transfer modules */
132struct loop_func_table {
133 int number; /* filter type */
134 int (*transfer)(struct loop_device *lo, int cmd,
135 struct page *raw_page, unsigned raw_off,
136 struct page *loop_page, unsigned loop_off,
137 int size, sector_t real_block);
138 int (*init)(struct loop_device *, const struct loop_info64 *);
139 /* release is called from loop_unregister_transfer or clr_fd */
140 int (*release)(struct loop_device *);
141 int (*ioctl)(struct loop_device *, int cmd, unsigned long arg);
142 struct module *owner;
143};
144
145int loop_register_transfer(struct loop_func_table *funcs);
146int loop_unregister_transfer(int number);
147
148#endif
149/*
150 * IOCTL commands --- we will commandeer 0x4C ('L')
151 */
152
153#define LOOP_SET_FD 0x4C00
154#define LOOP_CLR_FD 0x4C01
155#define LOOP_SET_STATUS 0x4C02
156#define LOOP_GET_STATUS 0x4C03
157#define LOOP_SET_STATUS64 0x4C04
158#define LOOP_GET_STATUS64 0x4C05
159#define LOOP_CHANGE_FD 0x4C06
160
161#endif
diff --git a/include/linux/lp.h b/include/linux/lp.h
new file mode 100644
index 000000000000..7059b6b9878a
--- /dev/null
+++ b/include/linux/lp.h
@@ -0,0 +1,191 @@
1#ifndef _LINUX_LP_H
2#define _LINUX_LP_H
3
4/*
5 * usr/include/linux/lp.h c.1991-1992 James Wiegand
6 * many modifications copyright (C) 1992 Michael K. Johnson
7 * Interrupt support added 1993 Nigel Gamble
8 * Removed 8255 status defines from inside __KERNEL__ Marcelo Tosatti
9 */
10
11/*
12 * Per POSIX guidelines, this module reserves the LP and lp prefixes
13 * These are the lp_table[minor].flags flags...
14 */
15#define LP_EXIST 0x0001
16#define LP_SELEC 0x0002
17#define LP_BUSY 0x0004
18#define LP_BUSY_BIT_POS 2
19#define LP_OFFL 0x0008
20#define LP_NOPA 0x0010
21#define LP_ERR 0x0020
22#define LP_ABORT 0x0040
23#define LP_CAREFUL 0x0080 /* obsoleted -arca */
24#define LP_ABORTOPEN 0x0100
25
26#define LP_TRUST_IRQ_ 0x0200 /* obsolete */
27#define LP_NO_REVERSE 0x0400 /* No reverse mode available. */
28#define LP_DATA_AVAIL 0x0800 /* Data is available. */
29
30/*
31 * bit defines for 8255 status port
32 * base + 1
33 * accessed with LP_S(minor), which gets the byte...
34 */
35#define LP_PBUSY 0x80 /* inverted input, active high */
36#define LP_PACK 0x40 /* unchanged input, active low */
37#define LP_POUTPA 0x20 /* unchanged input, active high */
38#define LP_PSELECD 0x10 /* unchanged input, active high */
39#define LP_PERRORP 0x08 /* unchanged input, active low */
40
41/* timeout for each character. This is relative to bus cycles -- it
42 * is the count in a busy loop. THIS IS THE VALUE TO CHANGE if you
43 * have extremely slow printing, or if the machine seems to slow down
44 * a lot when you print. If you have slow printing, increase this
45 * number and recompile, and if your system gets bogged down, decrease
46 * this number. This can be changed with the tunelp(8) command as well.
47 */
48
49#define LP_INIT_CHAR 1000
50
51/* The parallel port specs apparently say that there needs to be
52 * a .5usec wait before and after the strobe.
53 */
54
55#define LP_INIT_WAIT 1
56
57/* This is the amount of time that the driver waits for the printer to
58 * catch up when the printer's buffer appears to be filled. If you
59 * want to tune this and have a fast printer (i.e. HPIIIP), decrease
60 * this number, and if you have a slow printer, increase this number.
61 * This is in hundredths of a second, the default 2 being .05 second.
62 * Or use the tunelp(8) command, which is especially nice if you want
63 * change back and forth between character and graphics printing, which
64 * are wildly different...
65 */
66
67#define LP_INIT_TIME 2
68
69/* IOCTL numbers */
70#define LPCHAR 0x0601 /* corresponds to LP_INIT_CHAR */
71#define LPTIME 0x0602 /* corresponds to LP_INIT_TIME */
72#define LPABORT 0x0604 /* call with TRUE arg to abort on error,
73 FALSE to retry. Default is retry. */
74#define LPSETIRQ 0x0605 /* call with new IRQ number,
75 or 0 for polling (no IRQ) */
76#define LPGETIRQ 0x0606 /* get the current IRQ number */
77#define LPWAIT 0x0608 /* corresponds to LP_INIT_WAIT */
78/* NOTE: LPCAREFUL is obsoleted and it' s always the default right now -arca */
79#define LPCAREFUL 0x0609 /* call with TRUE arg to require out-of-paper, off-
80 line, and error indicators good on all writes,
81 FALSE to ignore them. Default is ignore. */
82#define LPABORTOPEN 0x060a /* call with TRUE arg to abort open() on error,
83 FALSE to ignore error. Default is ignore. */
84#define LPGETSTATUS 0x060b /* return LP_S(minor) */
85#define LPRESET 0x060c /* reset printer */
86#ifdef LP_STATS
87#define LPGETSTATS 0x060d /* get statistics (struct lp_stats) */
88#endif
89#define LPGETFLAGS 0x060e /* get status flags */
90#define LPSETTIMEOUT 0x060f /* set parport timeout */
91
92/* timeout for printk'ing a timeout, in jiffies (100ths of a second).
93 This is also used for re-checking error conditions if LP_ABORT is
94 not set. This is the default behavior. */
95
96#define LP_TIMEOUT_INTERRUPT (60 * HZ)
97#define LP_TIMEOUT_POLLED (10 * HZ)
98
99#ifdef __KERNEL__
100
101#include <linux/wait.h>
102#include <asm/semaphore.h>
103
104/* Magic numbers for defining port-device mappings */
105#define LP_PARPORT_UNSPEC -4
106#define LP_PARPORT_AUTO -3
107#define LP_PARPORT_OFF -2
108#define LP_PARPORT_NONE -1
109
110#define LP_F(minor) lp_table[(minor)].flags /* flags for busy, etc. */
111#define LP_CHAR(minor) lp_table[(minor)].chars /* busy timeout */
112#define LP_TIME(minor) lp_table[(minor)].time /* wait time */
113#define LP_WAIT(minor) lp_table[(minor)].wait /* strobe wait */
114#define LP_IRQ(minor) lp_table[(minor)].dev->port->irq /* interrupt # */
115 /* PARPORT_IRQ_NONE means polled */
116#ifdef LP_STATS
117#define LP_STAT(minor) lp_table[(minor)].stats /* statistics area */
118#endif
119#define LP_BUFFER_SIZE PAGE_SIZE
120
121#define LP_BASE(x) lp_table[(x)].dev->port->base
122
123#ifdef LP_STATS
124struct lp_stats {
125 unsigned long chars;
126 unsigned long sleeps;
127 unsigned int maxrun;
128 unsigned int maxwait;
129 unsigned int meanwait;
130 unsigned int mdev;
131};
132#endif
133
134struct lp_struct {
135 struct pardevice *dev;
136 unsigned long flags;
137 unsigned int chars;
138 unsigned int time;
139 unsigned int wait;
140 char *lp_buffer;
141#ifdef LP_STATS
142 unsigned int lastcall;
143 unsigned int runchars;
144 struct lp_stats stats;
145#endif
146 wait_queue_head_t waitq;
147 unsigned int last_error;
148 struct semaphore port_mutex;
149 wait_queue_head_t dataq;
150 long timeout;
151 unsigned int best_mode;
152 unsigned int current_mode;
153 unsigned long bits;
154};
155
156/*
157 * The following constants describe the various signals of the printer port
158 * hardware. Note that the hardware inverts some signals and that some
159 * signals are active low. An example is LP_STROBE, which must be programmed
160 * with 1 for being active and 0 for being inactive, because the strobe signal
161 * gets inverted, but it is also active low.
162 */
163
164
165/*
166 * defines for 8255 control port
167 * base + 2
168 * accessed with LP_C(minor)
169 */
170#define LP_PINTEN 0x10 /* high to read data in or-ed with data out */
171#define LP_PSELECP 0x08 /* inverted output, active low */
172#define LP_PINITP 0x04 /* unchanged output, active low */
173#define LP_PAUTOLF 0x02 /* inverted output, active low */
174#define LP_PSTROBE 0x01 /* short high output on raising edge */
175
176/*
177 * the value written to ports to test existence. PC-style ports will
178 * return the value written. AT-style ports will return 0. so why not
179 * make them the same ?
180 */
181#define LP_DUMMY 0x00
182
183/*
184 * This is the port delay time, in microseconds.
185 * It is used only in the lp_init() and lp_reset() routine.
186 */
187#define LP_DELAY 50
188
189#endif
190
191#endif
diff --git a/include/linux/major.h b/include/linux/major.h
new file mode 100644
index 000000000000..4b62c42b842c
--- /dev/null
+++ b/include/linux/major.h
@@ -0,0 +1,167 @@
1#ifndef _LINUX_MAJOR_H
2#define _LINUX_MAJOR_H
3
4/*
5 * This file has definitions for major device numbers.
6 * For the device number assignments, see Documentation/devices.txt.
7 */
8
9#define UNNAMED_MAJOR 0
10#define MEM_MAJOR 1
11#define RAMDISK_MAJOR 1
12#define FLOPPY_MAJOR 2
13#define PTY_MASTER_MAJOR 2
14#define IDE0_MAJOR 3
15#define HD_MAJOR IDE0_MAJOR
16#define PTY_SLAVE_MAJOR 3
17#define TTY_MAJOR 4
18#define TTYAUX_MAJOR 5
19#define LP_MAJOR 6
20#define VCS_MAJOR 7
21#define LOOP_MAJOR 7
22#define SCSI_DISK0_MAJOR 8
23#define SCSI_TAPE_MAJOR 9
24#define MD_MAJOR 9
25#define MISC_MAJOR 10
26#define SCSI_CDROM_MAJOR 11
27#define MUX_MAJOR 11 /* PA-RISC only */
28#define XT_DISK_MAJOR 13
29#define INPUT_MAJOR 13
30#define SOUND_MAJOR 14
31#define CDU31A_CDROM_MAJOR 15
32#define JOYSTICK_MAJOR 15
33#define GOLDSTAR_CDROM_MAJOR 16
34#define OPTICS_CDROM_MAJOR 17
35#define SANYO_CDROM_MAJOR 18
36#define CYCLADES_MAJOR 19
37#define CYCLADESAUX_MAJOR 20
38#define MITSUMI_X_CDROM_MAJOR 20
39#define MFM_ACORN_MAJOR 21 /* ARM Linux /dev/mfm */
40#define SCSI_GENERIC_MAJOR 21
41#define IDE1_MAJOR 22
42#define DIGICU_MAJOR 22
43#define DIGI_MAJOR 23
44#define MITSUMI_CDROM_MAJOR 23
45#define CDU535_CDROM_MAJOR 24
46#define STL_SERIALMAJOR 24
47#define MATSUSHITA_CDROM_MAJOR 25
48#define STL_CALLOUTMAJOR 25
49#define MATSUSHITA_CDROM2_MAJOR 26
50#define QIC117_TAPE_MAJOR 27
51#define MATSUSHITA_CDROM3_MAJOR 27
52#define MATSUSHITA_CDROM4_MAJOR 28
53#define STL_SIOMEMMAJOR 28
54#define ACSI_MAJOR 28
55#define AZTECH_CDROM_MAJOR 29
56#define GRAPHDEV_MAJOR 29 /* SparcLinux & Linux/68k /dev/fb */
57#define CM206_CDROM_MAJOR 32
58#define IDE2_MAJOR 33
59#define IDE3_MAJOR 34
60#define Z8530_MAJOR 34
61#define XPRAM_MAJOR 35 /* Expanded storage on S/390: "slow ram"*/
62#define NETLINK_MAJOR 36
63#define PS2ESDI_MAJOR 36
64#define IDETAPE_MAJOR 37
65#define Z2RAM_MAJOR 37
66#define APBLOCK_MAJOR 38 /* AP1000 Block device */
67#define DDV_MAJOR 39 /* AP1000 DDV block device */
68#define NBD_MAJOR 43 /* Network block device */
69#define RISCOM8_NORMAL_MAJOR 48
70#define DAC960_MAJOR 48 /* 48..55 */
71#define RISCOM8_CALLOUT_MAJOR 49
72#define MKISS_MAJOR 55
73#define DSP56K_MAJOR 55 /* DSP56001 processor device */
74
75#define IDE4_MAJOR 56
76#define IDE5_MAJOR 57
77
78#define SCSI_DISK1_MAJOR 65
79#define SCSI_DISK2_MAJOR 66
80#define SCSI_DISK3_MAJOR 67
81#define SCSI_DISK4_MAJOR 68
82#define SCSI_DISK5_MAJOR 69
83#define SCSI_DISK6_MAJOR 70
84#define SCSI_DISK7_MAJOR 71
85
86#define COMPAQ_SMART2_MAJOR 72
87#define COMPAQ_SMART2_MAJOR1 73
88#define COMPAQ_SMART2_MAJOR2 74
89#define COMPAQ_SMART2_MAJOR3 75
90#define COMPAQ_SMART2_MAJOR4 76
91#define COMPAQ_SMART2_MAJOR5 77
92#define COMPAQ_SMART2_MAJOR6 78
93#define COMPAQ_SMART2_MAJOR7 79
94
95#define SPECIALIX_NORMAL_MAJOR 75
96#define SPECIALIX_CALLOUT_MAJOR 76
97
98#define AURORA_MAJOR 79
99
100#define I2O_MAJOR 80 /* 80->87 */
101
102#define SHMIQ_MAJOR 85 /* Linux/mips, SGI /dev/shmiq */
103
104#define IDE6_MAJOR 88
105#define IDE7_MAJOR 89
106#define IDE8_MAJOR 90
107#define IDE9_MAJOR 91
108
109#define DASD_MAJOR 94
110
111#define MDISK_MAJOR 95
112
113#define UBD_MAJOR 98
114
115#define JSFD_MAJOR 99
116
117#define PHONE_MAJOR 100
118
119#define COMPAQ_CISS_MAJOR 104
120#define COMPAQ_CISS_MAJOR1 105
121#define COMPAQ_CISS_MAJOR2 106
122#define COMPAQ_CISS_MAJOR3 107
123#define COMPAQ_CISS_MAJOR4 108
124#define COMPAQ_CISS_MAJOR5 109
125#define COMPAQ_CISS_MAJOR6 110
126#define COMPAQ_CISS_MAJOR7 111
127
128#define VIODASD_MAJOR 112
129#define VIOCD_MAJOR 113
130
131#define ATARAID_MAJOR 114
132
133#define SCSI_DISK8_MAJOR 128
134#define SCSI_DISK9_MAJOR 129
135#define SCSI_DISK10_MAJOR 130
136#define SCSI_DISK11_MAJOR 131
137#define SCSI_DISK12_MAJOR 132
138#define SCSI_DISK13_MAJOR 133
139#define SCSI_DISK14_MAJOR 134
140#define SCSI_DISK15_MAJOR 135
141
142#define UNIX98_PTY_MASTER_MAJOR 128
143#define UNIX98_PTY_MAJOR_COUNT 8
144#define UNIX98_PTY_SLAVE_MAJOR (UNIX98_PTY_MASTER_MAJOR+UNIX98_PTY_MAJOR_COUNT)
145
146#define RTF_MAJOR 150
147#define RAW_MAJOR 162
148
149#define USB_ACM_MAJOR 166
150#define USB_ACM_AUX_MAJOR 167
151#define USB_CHAR_MAJOR 180
152
153#define VXVM_MAJOR 199 /* VERITAS volume i/o driver */
154#define VXSPEC_MAJOR 200 /* VERITAS volume config driver */
155#define VXDMP_MAJOR 201 /* VERITAS volume multipath driver */
156
157#define MSR_MAJOR 202
158#define CPUID_MAJOR 203
159
160#define OSST_MAJOR 206 /* OnStream-SCx0 SCSI tape */
161
162#define IBM_TTY3270_MAJOR 227
163#define IBM_FS3270_MAJOR 228
164
165#define VIOTAPE_MAJOR 230
166
167#endif
diff --git a/include/linux/matroxfb.h b/include/linux/matroxfb.h
new file mode 100644
index 000000000000..ae5b09493062
--- /dev/null
+++ b/include/linux/matroxfb.h
@@ -0,0 +1,43 @@
1#ifndef __LINUX_MATROXFB_H__
2#define __LINUX_MATROXFB_H__
3
4#include <asm/ioctl.h>
5#include <asm/types.h>
6#include <linux/videodev2.h>
7
8struct matroxioc_output_mode {
9 __u32 output; /* which output */
10#define MATROXFB_OUTPUT_PRIMARY 0x0000
11#define MATROXFB_OUTPUT_SECONDARY 0x0001
12#define MATROXFB_OUTPUT_DFP 0x0002
13 __u32 mode; /* which mode */
14#define MATROXFB_OUTPUT_MODE_PAL 0x0001
15#define MATROXFB_OUTPUT_MODE_NTSC 0x0002
16#define MATROXFB_OUTPUT_MODE_MONITOR 0x0080
17};
18#define MATROXFB_SET_OUTPUT_MODE _IOW('n',0xFA,size_t)
19#define MATROXFB_GET_OUTPUT_MODE _IOWR('n',0xFA,size_t)
20
21/* bitfield */
22#define MATROXFB_OUTPUT_CONN_PRIMARY (1 << MATROXFB_OUTPUT_PRIMARY)
23#define MATROXFB_OUTPUT_CONN_SECONDARY (1 << MATROXFB_OUTPUT_SECONDARY)
24#define MATROXFB_OUTPUT_CONN_DFP (1 << MATROXFB_OUTPUT_DFP)
25/* connect these outputs to this framebuffer */
26#define MATROXFB_SET_OUTPUT_CONNECTION _IOW('n',0xF8,size_t)
27/* which outputs are connected to this framebuffer */
28#define MATROXFB_GET_OUTPUT_CONNECTION _IOR('n',0xF8,size_t)
29/* which outputs are available for this framebuffer */
30#define MATROXFB_GET_AVAILABLE_OUTPUTS _IOR('n',0xF9,size_t)
31/* which outputs exist on this framebuffer */
32#define MATROXFB_GET_ALL_OUTPUTS _IOR('n',0xFB,size_t)
33
34enum matroxfb_ctrl_id {
35 MATROXFB_CID_TESTOUT = V4L2_CID_PRIVATE_BASE,
36 MATROXFB_CID_DEFLICKER,
37 MATROXFB_CID_LAST
38};
39
40#define FBIO_WAITFORVSYNC _IOW('F', 0x20, u_int32_t)
41
42#endif
43
diff --git a/include/linux/mbcache.h b/include/linux/mbcache.h
new file mode 100644
index 000000000000..8e5a10410a30
--- /dev/null
+++ b/include/linux/mbcache.h
@@ -0,0 +1,52 @@
1/*
2 File: linux/mbcache.h
3
4 (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
5*/
6
7/* Hardwire the number of additional indexes */
8#define MB_CACHE_INDEXES_COUNT 1
9
10struct mb_cache_entry {
11 struct list_head e_lru_list;
12 struct mb_cache *e_cache;
13 unsigned short e_used;
14 unsigned short e_queued;
15 struct block_device *e_bdev;
16 sector_t e_block;
17 struct list_head e_block_list;
18 struct {
19 struct list_head o_list;
20 unsigned int o_key;
21 } e_indexes[0];
22};
23
24struct mb_cache_op {
25 int (*free)(struct mb_cache_entry *, int);
26};
27
28/* Functions on caches */
29
30struct mb_cache * mb_cache_create(const char *, struct mb_cache_op *, size_t,
31 int, int);
32void mb_cache_shrink(struct mb_cache *, struct block_device *);
33void mb_cache_destroy(struct mb_cache *);
34
35/* Functions on cache entries */
36
37struct mb_cache_entry *mb_cache_entry_alloc(struct mb_cache *);
38int mb_cache_entry_insert(struct mb_cache_entry *, struct block_device *,
39 sector_t, unsigned int[]);
40void mb_cache_entry_release(struct mb_cache_entry *);
41void mb_cache_entry_free(struct mb_cache_entry *);
42struct mb_cache_entry *mb_cache_entry_get(struct mb_cache *,
43 struct block_device *,
44 sector_t);
45#if !defined(MB_CACHE_INDEXES_COUNT) || (MB_CACHE_INDEXES_COUNT > 0)
46struct mb_cache_entry *mb_cache_entry_find_first(struct mb_cache *cache, int,
47 struct block_device *,
48 unsigned int);
49struct mb_cache_entry *mb_cache_entry_find_next(struct mb_cache_entry *, int,
50 struct block_device *,
51 unsigned int);
52#endif
diff --git a/include/linux/mc146818rtc.h b/include/linux/mc146818rtc.h
new file mode 100644
index 000000000000..bbc93ae217e1
--- /dev/null
+++ b/include/linux/mc146818rtc.h
@@ -0,0 +1,92 @@
1/* mc146818rtc.h - register definitions for the Real-Time-Clock / CMOS RAM
2 * Copyright Torsten Duwe <duwe@informatik.uni-erlangen.de> 1993
3 * derived from Data Sheet, Copyright Motorola 1984 (!).
4 * It was written to be part of the Linux operating system.
5 */
6/* permission is hereby granted to copy, modify and redistribute this code
7 * in terms of the GNU Library General Public License, Version 2 or later,
8 * at your option.
9 */
10
11#ifndef _MC146818RTC_H
12#define _MC146818RTC_H
13
14#include <asm/io.h>
15#include <linux/rtc.h> /* get the user-level API */
16#include <asm/mc146818rtc.h> /* register access macros */
17
18#ifdef __KERNEL__
19#include <linux/spinlock.h> /* spinlock_t */
20extern spinlock_t rtc_lock; /* serialize CMOS RAM access */
21#endif
22
23/**********************************************************************
24 * register summary
25 **********************************************************************/
26#define RTC_SECONDS 0
27#define RTC_SECONDS_ALARM 1
28#define RTC_MINUTES 2
29#define RTC_MINUTES_ALARM 3
30#define RTC_HOURS 4
31#define RTC_HOURS_ALARM 5
32/* RTC_*_alarm is always true if 2 MSBs are set */
33# define RTC_ALARM_DONT_CARE 0xC0
34
35#define RTC_DAY_OF_WEEK 6
36#define RTC_DAY_OF_MONTH 7
37#define RTC_MONTH 8
38#define RTC_YEAR 9
39
40/* control registers - Moto names
41 */
42#define RTC_REG_A 10
43#define RTC_REG_B 11
44#define RTC_REG_C 12
45#define RTC_REG_D 13
46
47/**********************************************************************
48 * register details
49 **********************************************************************/
50#define RTC_FREQ_SELECT RTC_REG_A
51
52/* update-in-progress - set to "1" 244 microsecs before RTC goes off the bus,
53 * reset after update (may take 1.984ms @ 32768Hz RefClock) is complete,
54 * totalling to a max high interval of 2.228 ms.
55 */
56# define RTC_UIP 0x80
57# define RTC_DIV_CTL 0x70
58 /* divider control: refclock values 4.194 / 1.049 MHz / 32.768 kHz */
59# define RTC_REF_CLCK_4MHZ 0x00
60# define RTC_REF_CLCK_1MHZ 0x10
61# define RTC_REF_CLCK_32KHZ 0x20
62 /* 2 values for divider stage reset, others for "testing purposes only" */
63# define RTC_DIV_RESET1 0x60
64# define RTC_DIV_RESET2 0x70
65 /* Periodic intr. / Square wave rate select. 0=none, 1=32.8kHz,... 15=2Hz */
66# define RTC_RATE_SELECT 0x0F
67
68/**********************************************************************/
69#define RTC_CONTROL RTC_REG_B
70# define RTC_SET 0x80 /* disable updates for clock setting */
71# define RTC_PIE 0x40 /* periodic interrupt enable */
72# define RTC_AIE 0x20 /* alarm interrupt enable */
73# define RTC_UIE 0x10 /* update-finished interrupt enable */
74# define RTC_SQWE 0x08 /* enable square-wave output */
75# define RTC_DM_BINARY 0x04 /* all time/date values are BCD if clear */
76# define RTC_24H 0x02 /* 24 hour mode - else hours bit 7 means pm */
77# define RTC_DST_EN 0x01 /* auto switch DST - works f. USA only */
78
79/**********************************************************************/
80#define RTC_INTR_FLAGS RTC_REG_C
81/* caution - cleared by read */
82# define RTC_IRQF 0x80 /* any of the following 3 is active */
83# define RTC_PF 0x40
84# define RTC_AF 0x20
85# define RTC_UF 0x10
86
87/**********************************************************************/
88#define RTC_VALID RTC_REG_D
89# define RTC_VRT 0x80 /* valid RAM and time */
90/**********************************************************************/
91
92#endif /* _MC146818RTC_H */
diff --git a/include/linux/mc6821.h b/include/linux/mc6821.h
new file mode 100644
index 000000000000..28e301e295da
--- /dev/null
+++ b/include/linux/mc6821.h
@@ -0,0 +1,51 @@
1#ifndef _MC6821_H_
2#define _MC6821_H_
3
4/*
5 * This file describes the memery mapping of the MC6821 PIA.
6 * The unions describe overlayed registers. Which of them is used is
7 * determined by bit 2 of the corresponding control register.
8 * this files expects the PIA_REG_PADWIDTH to be defined the numeric
9 * value of the register spacing.
10 *
11 * Data came from MFC-31-Developer Kit (from Ralph Seidel,
12 * zodiac@darkness.gun.de) and Motorola Data Sheet (from
13 * Richard Hirst, srh@gpt.co.uk)
14 *
15 * 6.11.95 copyright Joerg Dorchain (dorchain@mpi-sb.mpg.de)
16 *
17 */
18
19#ifndef PIA_REG_PADWIDTH
20#define PIA_REG_PADWIDTH 255
21#endif
22
23struct pia {
24 union {
25 volatile u_char pra;
26 volatile u_char ddra;
27 } ua;
28 u_char pad1[PIA_REG_PADWIDTH];
29 volatile u_char cra;
30 u_char pad2[PIA_REG_PADWIDTH];
31 union {
32 volatile u_char prb;
33 volatile u_char ddrb;
34 } ub;
35 u_char pad3[PIA_REG_PADWIDTH];
36 volatile u_char crb;
37 u_char pad4[PIA_REG_PADWIDTH];
38};
39
40#define ppra ua.pra
41#define pddra ua.ddra
42#define pprb ub.prb
43#define pddrb ub.ddrb
44
45#define PIA_C1_ENABLE_IRQ (1<<0)
46#define PIA_C1_LOW_TO_HIGH (1<<1)
47#define PIA_DDR (1<<2)
48#define PIA_IRQ2 (1<<6)
49#define PIA_IRQ1 (1<<7)
50
51#endif
diff --git a/include/linux/mca-legacy.h b/include/linux/mca-legacy.h
new file mode 100644
index 000000000000..f2bb770e530a
--- /dev/null
+++ b/include/linux/mca-legacy.h
@@ -0,0 +1,67 @@
1/* -*- mode: c; c-basic-offset: 8 -*- */
2
3/* This is the function prototypes for the old legacy MCA interface
4 *
5 * Please move your driver to the new sysfs based one instead */
6
7#ifndef _LINUX_MCA_LEGACY_H
8#define _LINUX_MCA_LEGACY_H
9
10#include <linux/mca.h>
11
12#warning "MCA legacy - please move your driver to the new sysfs api"
13
14/* MCA_NOTFOUND is an error condition. The other two indicate
15 * motherboard POS registers contain the adapter. They might be
16 * returned by the mca_find_adapter() function, and can be used as
17 * arguments to mca_read_stored_pos(). I'm not going to allow direct
18 * access to the motherboard registers until we run across an adapter
19 * that requires it. We don't know enough about them to know if it's
20 * safe.
21 *
22 * See Documentation/mca.txt or one of the existing drivers for
23 * more information.
24 */
25#define MCA_NOTFOUND (-1)
26
27
28
29/* Returns the slot of the first enabled adapter matching id. User can
30 * specify a starting slot beyond zero, to deal with detecting multiple
31 * devices. Returns MCA_NOTFOUND if id not found. Also checks the
32 * integrated adapters.
33 */
34extern int mca_find_adapter(int id, int start);
35extern int mca_find_unused_adapter(int id, int start);
36
37extern int mca_is_adapter_used(int slot);
38extern int mca_mark_as_used(int slot);
39extern void mca_mark_as_unused(int slot);
40
41/* gets a byte out of POS register (stored in memory) */
42extern unsigned char mca_read_stored_pos(int slot, int reg);
43
44/* This can be expanded later. Right now, it gives us a way of
45 * getting meaningful information into the MCA_info structure,
46 * so we can have a more interesting /proc/mca.
47 */
48extern void mca_set_adapter_name(int slot, char* name);
49
50/* These routines actually mess with the hardware POS registers. They
51 * temporarily disable the device (and interrupts), so make sure you know
52 * what you're doing if you use them. Furthermore, writing to a POS may
53 * result in two devices trying to share a resource, which in turn can
54 * result in multiple devices sharing memory spaces, IRQs, or even trashing
55 * hardware. YOU HAVE BEEN WARNED.
56 *
57 * You can only access slots with this. Motherboard registers are off
58 * limits.
59 */
60
61/* read a byte from the specified POS register. */
62extern unsigned char mca_read_pos(int slot, int reg);
63
64/* write a byte to the specified POS register. */
65extern void mca_write_pos(int slot, int reg, unsigned char byte);
66
67#endif
diff --git a/include/linux/mca.h b/include/linux/mca.h
new file mode 100644
index 000000000000..5cff2923092b
--- /dev/null
+++ b/include/linux/mca.h
@@ -0,0 +1,146 @@
1/*
2 * Header for Microchannel Architecture Bus
3 * Written by Martin Kolinek, February 1996
4 */
5
6#ifndef _LINUX_MCA_H
7#define _LINUX_MCA_H
8
9#include <linux/device.h>
10
11#ifdef CONFIG_MCA
12#include <asm/mca.h>
13
14extern int MCA_bus;
15#else
16#define MCA_bus 0
17#endif
18
19/* This sets up an information callback for /proc/mca/slot?. The
20 * function is called with the buffer, slot, and device pointer (or
21 * some equally informative context information, or nothing, if you
22 * prefer), and is expected to put useful information into the
23 * buffer. The adapter name, id, and POS registers get printed
24 * before this is called though, so don't do it again.
25 *
26 * This should be called with a NULL procfn when a module
27 * unregisters, thus preventing kernel crashes and other such
28 * nastiness.
29 */
30typedef int (*MCA_ProcFn)(char* buf, int slot, void* dev);
31
32/* Should only be called by the NMI interrupt handler, this will do some
33 * fancy stuff to figure out what might have generated a NMI.
34 */
35extern void mca_handle_nmi(void);
36
37enum MCA_AdapterStatus {
38 MCA_ADAPTER_NORMAL = 0,
39 MCA_ADAPTER_NONE = 1,
40 MCA_ADAPTER_DISABLED = 2,
41 MCA_ADAPTER_ERROR = 3
42};
43
44struct mca_device {
45 u64 dma_mask;
46 int pos_id;
47 int slot;
48
49 /* index into id_table, set by the bus match routine */
50 int index;
51
52 /* is there a driver installed? 0 - No, 1 - Yes */
53 int driver_loaded;
54 /* POS registers */
55 unsigned char pos[8];
56 /* if a pseudo adapter of the motherboard, this is the motherboard
57 * register value to use for setup cycles */
58 short pos_register;
59
60 enum MCA_AdapterStatus status;
61#ifdef CONFIG_MCA_PROC_FS
62 /* name of the proc/mca file */
63 char procname[8];
64 /* /proc info callback */
65 MCA_ProcFn procfn;
66 /* device/context info for proc callback */
67 void *proc_dev;
68#endif
69 struct device dev;
70 char name[32];
71};
72#define to_mca_device(mdev) container_of(mdev, struct mca_device, dev)
73
74struct mca_bus_accessor_functions {
75 unsigned char (*mca_read_pos)(struct mca_device *, int reg);
76 void (*mca_write_pos)(struct mca_device *, int reg,
77 unsigned char byte);
78 int (*mca_transform_irq)(struct mca_device *, int irq);
79 int (*mca_transform_ioport)(struct mca_device *,
80 int region);
81 void * (*mca_transform_memory)(struct mca_device *,
82 void *memory);
83};
84
85struct mca_bus {
86 u64 default_dma_mask;
87 int number;
88 struct mca_bus_accessor_functions f;
89 struct device dev;
90 char name[32];
91};
92#define to_mca_bus(mdev) container_of(mdev, struct mca_bus, dev)
93
94struct mca_driver {
95 const short *id_table;
96 void *driver_data;
97 struct device_driver driver;
98};
99#define to_mca_driver(mdriver) container_of(mdriver, struct mca_driver, driver)
100
101/* Ongoing supported API functions */
102extern struct mca_device *mca_find_device_by_slot(int slot);
103extern int mca_system_init(void);
104extern struct mca_bus *mca_attach_bus(int);
105
106extern unsigned char mca_device_read_stored_pos(struct mca_device *mca_dev,
107 int reg);
108extern unsigned char mca_device_read_pos(struct mca_device *mca_dev, int reg);
109extern void mca_device_write_pos(struct mca_device *mca_dev, int reg,
110 unsigned char byte);
111extern int mca_device_transform_irq(struct mca_device *mca_dev, int irq);
112extern int mca_device_transform_ioport(struct mca_device *mca_dev, int port);
113extern void *mca_device_transform_memory(struct mca_device *mca_dev,
114 void *mem);
115extern int mca_device_claimed(struct mca_device *mca_dev);
116extern void mca_device_set_claim(struct mca_device *mca_dev, int val);
117extern void mca_device_set_name(struct mca_device *mca_dev, const char *name);
118static inline char *mca_device_get_name(struct mca_device *mca_dev)
119{
120 return mca_dev ? mca_dev->name : NULL;
121}
122
123extern enum MCA_AdapterStatus mca_device_status(struct mca_device *mca_dev);
124
125extern struct bus_type mca_bus_type;
126
127extern int mca_register_driver(struct mca_driver *drv);
128extern void mca_unregister_driver(struct mca_driver *drv);
129
130/* WARNING: only called by the boot time device setup */
131extern int mca_register_device(int bus, struct mca_device *mca_dev);
132
133#ifdef CONFIG_MCA_PROC_FS
134extern void mca_do_proc_init(void);
135extern void mca_set_adapter_procfn(int slot, MCA_ProcFn, void* dev);
136#else
137static inline void mca_do_proc_init(void)
138{
139}
140
141static inline void mca_set_adapter_procfn(int slot, MCA_ProcFn fn, void* dev)
142{
143}
144#endif
145
146#endif /* _LINUX_MCA_H */
diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
new file mode 100644
index 000000000000..8480aef10e62
--- /dev/null
+++ b/include/linux/mempolicy.h
@@ -0,0 +1,229 @@
1#ifndef _LINUX_MEMPOLICY_H
2#define _LINUX_MEMPOLICY_H 1
3
4#include <linux/errno.h>
5
6/*
7 * NUMA memory policies for Linux.
8 * Copyright 2003,2004 Andi Kleen SuSE Labs
9 */
10
11/* Policies */
12#define MPOL_DEFAULT 0
13#define MPOL_PREFERRED 1
14#define MPOL_BIND 2
15#define MPOL_INTERLEAVE 3
16
17#define MPOL_MAX MPOL_INTERLEAVE
18
19/* Flags for get_mem_policy */
20#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 */
22
23/* Flags for mbind */
24#define MPOL_MF_STRICT (1<<0) /* Verify existing pages in the mapping */
25
26#ifdef __KERNEL__
27
28#include <linux/config.h>
29#include <linux/mmzone.h>
30#include <linux/bitmap.h>
31#include <linux/slab.h>
32#include <linux/rbtree.h>
33#include <linux/spinlock.h>
34
35struct vm_area_struct;
36
37#ifdef CONFIG_NUMA
38
39/*
40 * Describe a memory policy.
41 *
42 * A mempolicy can be either associated with a process or with a VMA.
43 * For VMA related allocations the VMA policy is preferred, otherwise
44 * the process policy is used. Interrupts ignore the memory policy
45 * of the current process.
46 *
47 * Locking policy for interlave:
48 * In process context there is no locking because only the process accesses
49 * its own state. All vma manipulation is somewhat protected by a down_read on
50 * mmap_sem. For allocating in the interleave policy the page_table_lock
51 * must be also aquired to protect il_next.
52 *
53 * Freeing policy:
54 * When policy is MPOL_BIND v.zonelist is kmalloc'ed and must be kfree'd.
55 * All other policies don't have any external state. mpol_free() handles this.
56 *
57 * Copying policy objects:
58 * For MPOL_BIND the zonelist must be always duplicated. mpol_clone() does this.
59 */
60struct mempolicy {
61 atomic_t refcnt;
62 short policy; /* See MPOL_* above */
63 union {
64 struct zonelist *zonelist; /* bind */
65 short preferred_node; /* preferred */
66 DECLARE_BITMAP(nodes, MAX_NUMNODES); /* interleave */
67 /* undefined for default */
68 } v;
69};
70
71/*
72 * Support for managing mempolicy data objects (clone, copy, destroy)
73 * The default fast path of a NULL MPOL_DEFAULT policy is always inlined.
74 */
75
76extern void __mpol_free(struct mempolicy *pol);
77static inline void mpol_free(struct mempolicy *pol)
78{
79 if (pol)
80 __mpol_free(pol);
81}
82
83extern struct mempolicy *__mpol_copy(struct mempolicy *pol);
84static inline struct mempolicy *mpol_copy(struct mempolicy *pol)
85{
86 if (pol)
87 pol = __mpol_copy(pol);
88 return pol;
89}
90
91#define vma_policy(vma) ((vma)->vm_policy)
92#define vma_set_policy(vma, pol) ((vma)->vm_policy = (pol))
93
94static inline void mpol_get(struct mempolicy *pol)
95{
96 if (pol)
97 atomic_inc(&pol->refcnt);
98}
99
100extern int __mpol_equal(struct mempolicy *a, struct mempolicy *b);
101static inline int mpol_equal(struct mempolicy *a, struct mempolicy *b)
102{
103 if (a == b)
104 return 1;
105 return __mpol_equal(a, b);
106}
107#define vma_mpol_equal(a,b) mpol_equal(vma_policy(a), vma_policy(b))
108
109/* Could later add inheritance of the process policy here. */
110
111#define mpol_set_vma_default(vma) ((vma)->vm_policy = NULL)
112
113/*
114 * Hugetlb policy. i386 hugetlb so far works with node numbers
115 * instead of zone lists, so give it special interfaces for now.
116 */
117extern int mpol_first_node(struct vm_area_struct *vma, unsigned long addr);
118extern int mpol_node_valid(int nid, struct vm_area_struct *vma,
119 unsigned long addr);
120
121/*
122 * Tree of shared policies for a shared memory region.
123 * Maintain the policies in a pseudo mm that contains vmas. The vmas
124 * carry the policy. As a special twist the pseudo mm is indexed in pages, not
125 * bytes, so that we can work with shared memory segments bigger than
126 * unsigned long.
127 */
128
129struct sp_node {
130 struct rb_node nd;
131 unsigned long start, end;
132 struct mempolicy *policy;
133};
134
135struct shared_policy {
136 struct rb_root root;
137 spinlock_t lock;
138};
139
140static inline void mpol_shared_policy_init(struct shared_policy *info)
141{
142 info->root = RB_ROOT;
143 spin_lock_init(&info->lock);
144}
145
146int mpol_set_shared_policy(struct shared_policy *info,
147 struct vm_area_struct *vma,
148 struct mempolicy *new);
149void mpol_free_shared_policy(struct shared_policy *p);
150struct mempolicy *mpol_shared_policy_lookup(struct shared_policy *sp,
151 unsigned long idx);
152
153extern void numa_default_policy(void);
154extern void numa_policy_init(void);
155
156#else
157
158struct mempolicy {};
159
160static inline int mpol_equal(struct mempolicy *a, struct mempolicy *b)
161{
162 return 1;
163}
164#define vma_mpol_equal(a,b) 1
165
166#define mpol_set_vma_default(vma) do {} while(0)
167
168static inline void mpol_free(struct mempolicy *p)
169{
170}
171
172static inline void mpol_get(struct mempolicy *pol)
173{
174}
175
176static inline struct mempolicy *mpol_copy(struct mempolicy *old)
177{
178 return NULL;
179}
180
181static inline int mpol_first_node(struct vm_area_struct *vma, unsigned long a)
182{
183 return numa_node_id();
184}
185
186static inline int
187mpol_node_valid(int nid, struct vm_area_struct *vma, unsigned long a)
188{
189 return 1;
190}
191
192struct shared_policy {};
193
194static inline int mpol_set_shared_policy(struct shared_policy *info,
195 struct vm_area_struct *vma,
196 struct mempolicy *new)
197{
198 return -EINVAL;
199}
200
201static inline void mpol_shared_policy_init(struct shared_policy *info)
202{
203}
204
205static inline void mpol_free_shared_policy(struct shared_policy *p)
206{
207}
208
209static inline struct mempolicy *
210mpol_shared_policy_lookup(struct shared_policy *sp, unsigned long idx)
211{
212 return NULL;
213}
214
215#define vma_policy(vma) NULL
216#define vma_set_policy(vma, pol) do {} while(0)
217
218static inline void numa_policy_init(void)
219{
220}
221
222static inline void numa_default_policy(void)
223{
224}
225
226#endif /* CONFIG_NUMA */
227#endif /* __KERNEL__ */
228
229#endif
diff --git a/include/linux/mempool.h b/include/linux/mempool.h
new file mode 100644
index 000000000000..4a36edf1c974
--- /dev/null
+++ b/include/linux/mempool.h
@@ -0,0 +1,37 @@
1/*
2 * memory buffer pool support
3 */
4#ifndef _LINUX_MEMPOOL_H
5#define _LINUX_MEMPOOL_H
6
7#include <linux/wait.h>
8
9typedef void * (mempool_alloc_t)(unsigned int __nocast gfp_mask, void *pool_data);
10typedef void (mempool_free_t)(void *element, void *pool_data);
11
12typedef struct mempool_s {
13 spinlock_t lock;
14 int min_nr; /* nr of elements at *elements */
15 int curr_nr; /* Current nr of elements at *elements */
16 void **elements;
17
18 void *pool_data;
19 mempool_alloc_t *alloc;
20 mempool_free_t *free;
21 wait_queue_head_t wait;
22} mempool_t;
23extern mempool_t * mempool_create(int min_nr, mempool_alloc_t *alloc_fn,
24 mempool_free_t *free_fn, void *pool_data);
25extern int mempool_resize(mempool_t *pool, int new_min_nr, unsigned int __nocast gfp_mask);
26extern void mempool_destroy(mempool_t *pool);
27extern void * mempool_alloc(mempool_t *pool, unsigned int __nocast gfp_mask);
28extern void mempool_free(void *element, mempool_t *pool);
29
30/*
31 * A mempool_alloc_t and mempool_free_t that get the memory from
32 * a slab that is passed in through pool_data.
33 */
34void *mempool_alloc_slab(unsigned int __nocast gfp_mask, void *pool_data);
35void mempool_free_slab(void *element, void *pool_data);
36
37#endif /* _LINUX_MEMPOOL_H */
diff --git a/include/linux/meye.h b/include/linux/meye.h
new file mode 100644
index 000000000000..11ec45e9a132
--- /dev/null
+++ b/include/linux/meye.h
@@ -0,0 +1,66 @@
1/*
2 * Motion Eye video4linux driver for Sony Vaio PictureBook
3 *
4 * Copyright (C) 2001-2003 Stelian Pop <stelian@popies.net>
5 *
6 * Copyright (C) 2001-2002 Alcôve <www.alcove.com>
7 *
8 * Copyright (C) 2000 Andrew Tridgell <tridge@valinux.com>
9 *
10 * Earlier work by Werner Almesberger, Paul `Rusty' Russell and Paul Mackerras.
11 *
12 * Some parts borrowed from various video4linux drivers, especially
13 * bttv-driver.c and zoran.c, see original files for credits.
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 */
29
30#ifndef _MEYE_H_
31#define _MEYE_H_
32
33/****************************************************************************/
34/* Private API for handling mjpeg capture / playback. */
35/****************************************************************************/
36
37struct meye_params {
38 unsigned char subsample;
39 unsigned char quality;
40 unsigned char sharpness;
41 unsigned char agc;
42 unsigned char picture;
43 unsigned char framerate;
44};
45
46/* query the extended parameters */
47#define MEYEIOC_G_PARAMS _IOR ('v', BASE_VIDIOCPRIVATE+0, struct meye_params)
48/* set the extended parameters */
49#define MEYEIOC_S_PARAMS _IOW ('v', BASE_VIDIOCPRIVATE+1, struct meye_params)
50/* queue a buffer for mjpeg capture */
51#define MEYEIOC_QBUF_CAPT _IOW ('v', BASE_VIDIOCPRIVATE+2, int)
52/* sync a previously queued mjpeg buffer */
53#define MEYEIOC_SYNC _IOWR('v', BASE_VIDIOCPRIVATE+3, int)
54/* get a still uncompressed snapshot */
55#define MEYEIOC_STILLCAPT _IO ('v', BASE_VIDIOCPRIVATE+4)
56/* get a jpeg compressed snapshot */
57#define MEYEIOC_STILLJCAPT _IOR ('v', BASE_VIDIOCPRIVATE+5, int)
58
59/* V4L2 private controls */
60#define V4L2_CID_AGC V4L2_CID_PRIVATE_BASE
61#define V4L2_CID_SHARPNESS (V4L2_CID_PRIVATE_BASE + 1)
62#define V4L2_CID_PICTURE (V4L2_CID_PRIVATE_BASE + 2)
63#define V4L2_CID_JPEGQUAL (V4L2_CID_PRIVATE_BASE + 3)
64#define V4L2_CID_FRAMERATE (V4L2_CID_PRIVATE_BASE + 4)
65
66#endif
diff --git a/include/linux/mii.h b/include/linux/mii.h
new file mode 100644
index 000000000000..20971fe78a8d
--- /dev/null
+++ b/include/linux/mii.h
@@ -0,0 +1,223 @@
1/*
2 * linux/mii.h: definitions for MII-compatible transceivers
3 * Originally drivers/net/sunhme.h.
4 *
5 * Copyright (C) 1996, 1999, 2001 David S. Miller (davem@redhat.com)
6 */
7
8#ifndef __LINUX_MII_H__
9#define __LINUX_MII_H__
10
11#include <linux/types.h>
12#include <linux/if.h>
13
14/* Generic MII registers. */
15
16#define MII_BMCR 0x00 /* Basic mode control register */
17#define MII_BMSR 0x01 /* Basic mode status register */
18#define MII_PHYSID1 0x02 /* PHYS ID 1 */
19#define MII_PHYSID2 0x03 /* PHYS ID 2 */
20#define MII_ADVERTISE 0x04 /* Advertisement control reg */
21#define MII_LPA 0x05 /* Link partner ability reg */
22#define MII_EXPANSION 0x06 /* Expansion register */
23#define MII_CTRL1000 0x09 /* 1000BASE-T control */
24#define MII_STAT1000 0x0a /* 1000BASE-T status */
25#define MII_DCOUNTER 0x12 /* Disconnect counter */
26#define MII_FCSCOUNTER 0x13 /* False carrier counter */
27#define MII_NWAYTEST 0x14 /* N-way auto-neg test reg */
28#define MII_RERRCOUNTER 0x15 /* Receive error counter */
29#define MII_SREVISION 0x16 /* Silicon revision */
30#define MII_RESV1 0x17 /* Reserved... */
31#define MII_LBRERROR 0x18 /* Lpback, rx, bypass error */
32#define MII_PHYADDR 0x19 /* PHY address */
33#define MII_RESV2 0x1a /* Reserved... */
34#define MII_TPISTATUS 0x1b /* TPI status for 10mbps */
35#define MII_NCONFIG 0x1c /* Network interface config */
36
37/* Basic mode control register. */
38#define BMCR_RESV 0x003f /* Unused... */
39#define BMCR_SPEED1000 0x0040 /* MSB of Speed (1000) */
40#define BMCR_CTST 0x0080 /* Collision test */
41#define BMCR_FULLDPLX 0x0100 /* Full duplex */
42#define BMCR_ANRESTART 0x0200 /* Auto negotiation restart */
43#define BMCR_ISOLATE 0x0400 /* Disconnect DP83840 from MII */
44#define BMCR_PDOWN 0x0800 /* Powerdown the DP83840 */
45#define BMCR_ANENABLE 0x1000 /* Enable auto negotiation */
46#define BMCR_SPEED100 0x2000 /* Select 100Mbps */
47#define BMCR_LOOPBACK 0x4000 /* TXD loopback bits */
48#define BMCR_RESET 0x8000 /* Reset the DP83840 */
49
50/* Basic mode status register. */
51#define BMSR_ERCAP 0x0001 /* Ext-reg capability */
52#define BMSR_JCD 0x0002 /* Jabber detected */
53#define BMSR_LSTATUS 0x0004 /* Link status */
54#define BMSR_ANEGCAPABLE 0x0008 /* Able to do auto-negotiation */
55#define BMSR_RFAULT 0x0010 /* Remote fault detected */
56#define BMSR_ANEGCOMPLETE 0x0020 /* Auto-negotiation complete */
57#define BMSR_RESV 0x07c0 /* Unused... */
58#define BMSR_10HALF 0x0800 /* Can do 10mbps, half-duplex */
59#define BMSR_10FULL 0x1000 /* Can do 10mbps, full-duplex */
60#define BMSR_100HALF 0x2000 /* Can do 100mbps, half-duplex */
61#define BMSR_100FULL 0x4000 /* Can do 100mbps, full-duplex */
62#define BMSR_100BASE4 0x8000 /* Can do 100mbps, 4k packets */
63
64/* Advertisement control register. */
65#define ADVERTISE_SLCT 0x001f /* Selector bits */
66#define ADVERTISE_CSMA 0x0001 /* Only selector supported */
67#define ADVERTISE_10HALF 0x0020 /* Try for 10mbps half-duplex */
68#define ADVERTISE_10FULL 0x0040 /* Try for 10mbps full-duplex */
69#define ADVERTISE_100HALF 0x0080 /* Try for 100mbps half-duplex */
70#define ADVERTISE_100FULL 0x0100 /* Try for 100mbps full-duplex */
71#define ADVERTISE_100BASE4 0x0200 /* Try for 100mbps 4k packets */
72#define ADVERTISE_PAUSE_CAP 0x0400 /* Try for pause */
73#define ADVERTISE_PAUSE_ASYM 0x0800 /* Try for asymetric pause */
74#define ADVERTISE_RESV 0x1000 /* Unused... */
75#define ADVERTISE_RFAULT 0x2000 /* Say we can detect faults */
76#define ADVERTISE_LPACK 0x4000 /* Ack link partners response */
77#define ADVERTISE_NPAGE 0x8000 /* Next page bit */
78
79#define ADVERTISE_FULL (ADVERTISE_100FULL | ADVERTISE_10FULL | \
80 ADVERTISE_CSMA)
81#define ADVERTISE_ALL (ADVERTISE_10HALF | ADVERTISE_10FULL | \
82 ADVERTISE_100HALF | ADVERTISE_100FULL)
83
84/* Link partner ability register. */
85#define LPA_SLCT 0x001f /* Same as advertise selector */
86#define LPA_10HALF 0x0020 /* Can do 10mbps half-duplex */
87#define LPA_10FULL 0x0040 /* Can do 10mbps full-duplex */
88#define LPA_100HALF 0x0080 /* Can do 100mbps half-duplex */
89#define LPA_100FULL 0x0100 /* Can do 100mbps full-duplex */
90#define LPA_100BASE4 0x0200 /* Can do 100mbps 4k packets */
91#define LPA_PAUSE_CAP 0x0400 /* Can pause */
92#define LPA_PAUSE_ASYM 0x0800 /* Can pause asymetrically */
93#define LPA_RESV 0x1000 /* Unused... */
94#define LPA_RFAULT 0x2000 /* Link partner faulted */
95#define LPA_LPACK 0x4000 /* Link partner acked us */
96#define LPA_NPAGE 0x8000 /* Next page bit */
97
98#define LPA_DUPLEX (LPA_10FULL | LPA_100FULL)
99#define LPA_100 (LPA_100FULL | LPA_100HALF | LPA_100BASE4)
100
101/* Expansion register for auto-negotiation. */
102#define EXPANSION_NWAY 0x0001 /* Can do N-way auto-nego */
103#define EXPANSION_LCWP 0x0002 /* Got new RX page code word */
104#define EXPANSION_ENABLENPAGE 0x0004 /* This enables npage words */
105#define EXPANSION_NPCAPABLE 0x0008 /* Link partner supports npage */
106#define EXPANSION_MFAULTS 0x0010 /* Multiple faults detected */
107#define EXPANSION_RESV 0xffe0 /* Unused... */
108
109/* N-way test register. */
110#define NWAYTEST_RESV1 0x00ff /* Unused... */
111#define NWAYTEST_LOOPBACK 0x0100 /* Enable loopback for N-way */
112#define NWAYTEST_RESV2 0xfe00 /* Unused... */
113
114/* 1000BASE-T Control register */
115#define ADVERTISE_1000FULL 0x0200 /* Advertise 1000BASE-T full duplex */
116#define ADVERTISE_1000HALF 0x0100 /* Advertise 1000BASE-T half duplex */
117
118/* 1000BASE-T Status register */
119#define LPA_1000LOCALRXOK 0x2000 /* Link partner local receiver status */
120#define LPA_1000REMRXOK 0x1000 /* Link partner remote receiver status */
121#define LPA_1000FULL 0x0800 /* Link partner 1000BASE-T full duplex */
122#define LPA_1000HALF 0x0400 /* Link partner 1000BASE-T half duplex */
123
124struct mii_if_info {
125 int phy_id;
126 int advertising;
127 int phy_id_mask;
128 int reg_num_mask;
129
130 unsigned int full_duplex : 1; /* is full duplex? */
131 unsigned int force_media : 1; /* is autoneg. disabled? */
132 unsigned int supports_gmii : 1; /* are GMII registers supported? */
133
134 struct net_device *dev;
135 int (*mdio_read) (struct net_device *dev, int phy_id, int location);
136 void (*mdio_write) (struct net_device *dev, int phy_id, int location, int val);
137};
138
139struct ethtool_cmd;
140struct mii_ioctl_data;
141
142extern int mii_link_ok (struct mii_if_info *mii);
143extern int mii_nway_restart (struct mii_if_info *mii);
144extern int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd);
145extern int mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd);
146extern void mii_check_link (struct mii_if_info *mii);
147extern unsigned int mii_check_media (struct mii_if_info *mii,
148 unsigned int ok_to_print,
149 unsigned int init_media);
150extern int generic_mii_ioctl(struct mii_if_info *mii_if,
151 struct mii_ioctl_data *mii_data, int cmd,
152 unsigned int *duplex_changed);
153
154
155
156/* This structure is used in all SIOCxMIIxxx ioctl calls */
157struct mii_ioctl_data {
158 u16 phy_id;
159 u16 reg_num;
160 u16 val_in;
161 u16 val_out;
162};
163
164
165static inline struct mii_ioctl_data *if_mii(struct ifreq *rq)
166{
167 return (struct mii_ioctl_data *) &rq->ifr_ifru;
168}
169
170
171/**
172 * mii_nway_result
173 * @negotiated: value of MII ANAR and'd with ANLPAR
174 *
175 * Given a set of MII abilities, check each bit and returns the
176 * currently supported media, in the priority order defined by
177 * IEEE 802.3u. We use LPA_xxx constants but note this is not the
178 * value of LPA solely, as described above.
179 *
180 * The one exception to IEEE 802.3u is that 100baseT4 is placed
181 * between 100T-full and 100T-half. If your phy does not support
182 * 100T4 this is fine. If your phy places 100T4 elsewhere in the
183 * priority order, you will need to roll your own function.
184 */
185static inline unsigned int mii_nway_result (unsigned int negotiated)
186{
187 unsigned int ret;
188
189 if (negotiated & LPA_100FULL)
190 ret = LPA_100FULL;
191 else if (negotiated & LPA_100BASE4)
192 ret = LPA_100BASE4;
193 else if (negotiated & LPA_100HALF)
194 ret = LPA_100HALF;
195 else if (negotiated & LPA_10FULL)
196 ret = LPA_10FULL;
197 else
198 ret = LPA_10HALF;
199
200 return ret;
201}
202
203/**
204 * mii_duplex
205 * @duplex_lock: Non-zero if duplex is locked at full
206 * @negotiated: value of MII ANAR and'd with ANLPAR
207 *
208 * A small helper function for a common case. Returns one
209 * if the media is operating or locked at full duplex, and
210 * returns zero otherwise.
211 */
212static inline unsigned int mii_duplex (unsigned int duplex_lock,
213 unsigned int negotiated)
214{
215 if (duplex_lock)
216 return 1;
217 if (mii_nway_result(negotiated) & LPA_DUPLEX)
218 return 1;
219 return 0;
220}
221
222
223#endif /* __LINUX_MII_H__ */
diff --git a/include/linux/minix_fs.h b/include/linux/minix_fs.h
new file mode 100644
index 000000000000..1ecc3cc8cef5
--- /dev/null
+++ b/include/linux/minix_fs.h
@@ -0,0 +1,85 @@
1#ifndef _LINUX_MINIX_FS_H
2#define _LINUX_MINIX_FS_H
3
4/*
5 * The minix filesystem constants/structures
6 */
7
8/*
9 * Thanks to Kees J Bot for sending me the definitions of the new
10 * minix filesystem (aka V2) with bigger inodes and 32-bit block
11 * pointers.
12 */
13
14#define MINIX_ROOT_INO 1
15
16/* Not the same as the bogus LINK_MAX in <linux/limits.h>. Oh well. */
17#define MINIX_LINK_MAX 250
18#define MINIX2_LINK_MAX 65530
19
20#define MINIX_I_MAP_SLOTS 8
21#define MINIX_Z_MAP_SLOTS 64
22#define MINIX_SUPER_MAGIC 0x137F /* original minix fs */
23#define MINIX_SUPER_MAGIC2 0x138F /* minix fs, 30 char names */
24#define MINIX2_SUPER_MAGIC 0x2468 /* minix V2 fs */
25#define MINIX2_SUPER_MAGIC2 0x2478 /* minix V2 fs, 30 char names */
26#define MINIX_VALID_FS 0x0001 /* Clean fs. */
27#define MINIX_ERROR_FS 0x0002 /* fs has errors. */
28
29#define MINIX_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix_inode)))
30#define MINIX2_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix2_inode)))
31
32/*
33 * This is the original minix inode layout on disk.
34 * Note the 8-bit gid and atime and ctime.
35 */
36struct minix_inode {
37 __u16 i_mode;
38 __u16 i_uid;
39 __u32 i_size;
40 __u32 i_time;
41 __u8 i_gid;
42 __u8 i_nlinks;
43 __u16 i_zone[9];
44};
45
46/*
47 * The new minix inode has all the time entries, as well as
48 * long block numbers and a third indirect block (7+1+1+1
49 * instead of 7+1+1). Also, some previously 8-bit values are
50 * now 16-bit. The inode is now 64 bytes instead of 32.
51 */
52struct minix2_inode {
53 __u16 i_mode;
54 __u16 i_nlinks;
55 __u16 i_uid;
56 __u16 i_gid;
57 __u32 i_size;
58 __u32 i_atime;
59 __u32 i_mtime;
60 __u32 i_ctime;
61 __u32 i_zone[10];
62};
63
64/*
65 * minix super-block data on disk
66 */
67struct minix_super_block {
68 __u16 s_ninodes;
69 __u16 s_nzones;
70 __u16 s_imap_blocks;
71 __u16 s_zmap_blocks;
72 __u16 s_firstdatazone;
73 __u16 s_log_zone_size;
74 __u32 s_max_size;
75 __u16 s_magic;
76 __u16 s_state;
77 __u32 s_zones;
78};
79
80struct minix_dir_entry {
81 __u16 inode;
82 char name[0];
83};
84
85#endif
diff --git a/include/linux/miscdevice.h b/include/linux/miscdevice.h
new file mode 100644
index 000000000000..14ceebfc1efa
--- /dev/null
+++ b/include/linux/miscdevice.h
@@ -0,0 +1,52 @@
1#ifndef _LINUX_MISCDEVICE_H
2#define _LINUX_MISCDEVICE_H
3#include <linux/module.h>
4#include <linux/major.h>
5
6#define PSMOUSE_MINOR 1
7#define MS_BUSMOUSE_MINOR 2
8#define ATIXL_BUSMOUSE_MINOR 3
9/*#define AMIGAMOUSE_MINOR 4 FIXME OBSOLETE */
10#define ATARIMOUSE_MINOR 5
11#define SUN_MOUSE_MINOR 6
12#define APOLLO_MOUSE_MINOR 7
13#define PC110PAD_MINOR 9
14/*#define ADB_MOUSE_MINOR 10 FIXME OBSOLETE */
15#define WATCHDOG_MINOR 130 /* Watchdog timer */
16#define TEMP_MINOR 131 /* Temperature Sensor */
17#define RTC_MINOR 135
18#define EFI_RTC_MINOR 136 /* EFI Time services */
19#define SUN_OPENPROM_MINOR 139
20#define DMAPI_MINOR 140 /* DMAPI */
21#define NVRAM_MINOR 144
22#define SGI_MMTIMER 153
23#define STORE_QUEUE_MINOR 155
24#define I2O_MINOR 166
25#define MICROCODE_MINOR 184
26#define MWAVE_MINOR 219 /* ACP/Mwave Modem */
27#define MPT_MINOR 220
28#define MISC_DYNAMIC_MINOR 255
29
30#define TUN_MINOR 200
31#define HPET_MINOR 228
32
33struct device;
34struct class_device;
35
36struct miscdevice {
37 int minor;
38 const char *name;
39 struct file_operations *fops;
40 struct list_head list;
41 struct device *dev;
42 struct class_device *class;
43 char devfs_name[64];
44};
45
46extern int misc_register(struct miscdevice * misc);
47extern int misc_deregister(struct miscdevice * misc);
48
49#define MODULE_ALIAS_MISCDEV(minor) \
50 MODULE_ALIAS("char-major-" __stringify(MISC_MAJOR) \
51 "-" __stringify(minor))
52#endif
diff --git a/include/linux/mm.h b/include/linux/mm.h
new file mode 100644
index 000000000000..6a931374d6c4
--- /dev/null
+++ b/include/linux/mm.h
@@ -0,0 +1,861 @@
1#ifndef _LINUX_MM_H
2#define _LINUX_MM_H
3
4#include <linux/sched.h>
5#include <linux/errno.h>
6
7#ifdef __KERNEL__
8
9#include <linux/config.h>
10#include <linux/gfp.h>
11#include <linux/list.h>
12#include <linux/mmzone.h>
13#include <linux/rbtree.h>
14#include <linux/prio_tree.h>
15#include <linux/fs.h>
16
17struct mempolicy;
18struct anon_vma;
19
20#ifndef CONFIG_DISCONTIGMEM /* Don't use mapnrs, do it properly */
21extern unsigned long max_mapnr;
22#endif
23
24extern unsigned long num_physpages;
25extern void * high_memory;
26extern unsigned long vmalloc_earlyreserve;
27extern int page_cluster;
28
29#ifdef CONFIG_SYSCTL
30extern int sysctl_legacy_va_layout;
31#else
32#define sysctl_legacy_va_layout 0
33#endif
34
35#include <asm/page.h>
36#include <asm/pgtable.h>
37#include <asm/processor.h>
38#include <asm/atomic.h>
39
40#ifndef MM_VM_SIZE
41#define MM_VM_SIZE(mm) ((TASK_SIZE + PGDIR_SIZE - 1) & PGDIR_MASK)
42#endif
43
44#define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n))
45
46/*
47 * Linux kernel virtual memory manager primitives.
48 * The idea being to have a "virtual" mm in the same way
49 * we have a virtual fs - giving a cleaner interface to the
50 * mm details, and allowing different kinds of memory mappings
51 * (from shared memory to executable loading to arbitrary
52 * mmap() functions).
53 */
54
55/*
56 * This struct defines a memory VMM memory area. There is one of these
57 * per VM-area/task. A VM area is any part of the process virtual memory
58 * space that has a special rule for the page-fault handlers (ie a shared
59 * library, the executable area etc).
60 */
61struct vm_area_struct {
62 struct mm_struct * vm_mm; /* The address space we belong to. */
63 unsigned long vm_start; /* Our start address within vm_mm. */
64 unsigned long vm_end; /* The first byte after our end address
65 within vm_mm. */
66
67 /* linked list of VM areas per task, sorted by address */
68 struct vm_area_struct *vm_next;
69
70 pgprot_t vm_page_prot; /* Access permissions of this VMA. */
71 unsigned long vm_flags; /* Flags, listed below. */
72
73 struct rb_node vm_rb;
74
75 /*
76 * For areas with an address space and backing store,
77 * linkage into the address_space->i_mmap prio tree, or
78 * linkage to the list of like vmas hanging off its node, or
79 * linkage of vma in the address_space->i_mmap_nonlinear list.
80 */
81 union {
82 struct {
83 struct list_head list;
84 void *parent; /* aligns with prio_tree_node parent */
85 struct vm_area_struct *head;
86 } vm_set;
87
88 struct raw_prio_tree_node prio_tree_node;
89 } shared;
90
91 /*
92 * A file's MAP_PRIVATE vma can be in both i_mmap tree and anon_vma
93 * list, after a COW of one of the file pages. A MAP_SHARED vma
94 * can only be in the i_mmap tree. An anonymous MAP_PRIVATE, stack
95 * or brk vma (with NULL file) can only be in an anon_vma list.
96 */
97 struct list_head anon_vma_node; /* Serialized by anon_vma->lock */
98 struct anon_vma *anon_vma; /* Serialized by page_table_lock */
99
100 /* Function pointers to deal with this struct. */
101 struct vm_operations_struct * vm_ops;
102
103 /* Information about our backing store: */
104 unsigned long vm_pgoff; /* Offset (within vm_file) in PAGE_SIZE
105 units, *not* PAGE_CACHE_SIZE */
106 struct file * vm_file; /* File we map to (can be NULL). */
107 void * vm_private_data; /* was vm_pte (shared mem) */
108 unsigned long vm_truncate_count;/* truncate_count or restart_addr */
109
110#ifndef CONFIG_MMU
111 atomic_t vm_usage; /* refcount (VMAs shared if !MMU) */
112#endif
113#ifdef CONFIG_NUMA
114 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
115#endif
116};
117
118/*
119 * This struct defines the per-mm list of VMAs for uClinux. If CONFIG_MMU is
120 * disabled, then there's a single shared list of VMAs maintained by the
121 * system, and mm's subscribe to these individually
122 */
123struct vm_list_struct {
124 struct vm_list_struct *next;
125 struct vm_area_struct *vma;
126};
127
128#ifndef CONFIG_MMU
129extern struct rb_root nommu_vma_tree;
130extern struct rw_semaphore nommu_vma_sem;
131
132extern unsigned int kobjsize(const void *objp);
133#endif
134
135/*
136 * vm_flags..
137 */
138#define VM_READ 0x00000001 /* currently active flags */
139#define VM_WRITE 0x00000002
140#define VM_EXEC 0x00000004
141#define VM_SHARED 0x00000008
142
143#define VM_MAYREAD 0x00000010 /* limits for mprotect() etc */
144#define VM_MAYWRITE 0x00000020
145#define VM_MAYEXEC 0x00000040
146#define VM_MAYSHARE 0x00000080
147
148#define VM_GROWSDOWN 0x00000100 /* general info on the segment */
149#define VM_GROWSUP 0x00000200
150#define VM_SHM 0x00000400 /* shared memory area, don't swap out */
151#define VM_DENYWRITE 0x00000800 /* ETXTBSY on write attempts.. */
152
153#define VM_EXECUTABLE 0x00001000
154#define VM_LOCKED 0x00002000
155#define VM_IO 0x00004000 /* Memory mapped I/O or similar */
156
157 /* Used by sys_madvise() */
158#define VM_SEQ_READ 0x00008000 /* App will access data sequentially */
159#define VM_RAND_READ 0x00010000 /* App will not benefit from clustered reads */
160
161#define VM_DONTCOPY 0x00020000 /* Do not copy this vma on fork */
162#define VM_DONTEXPAND 0x00040000 /* Cannot expand with mremap() */
163#define VM_RESERVED 0x00080000 /* Don't unmap it from swap_out */
164#define VM_ACCOUNT 0x00100000 /* Is a VM accounted object */
165#define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
166#define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
167#define VM_MAPPED_COPY 0x01000000 /* T if mapped copy of data (nommu mmap) */
168
169#ifndef VM_STACK_DEFAULT_FLAGS /* arch can override this */
170#define VM_STACK_DEFAULT_FLAGS VM_DATA_DEFAULT_FLAGS
171#endif
172
173#ifdef CONFIG_STACK_GROWSUP
174#define VM_STACK_FLAGS (VM_GROWSUP | VM_STACK_DEFAULT_FLAGS | VM_ACCOUNT)
175#else
176#define VM_STACK_FLAGS (VM_GROWSDOWN | VM_STACK_DEFAULT_FLAGS | VM_ACCOUNT)
177#endif
178
179#define VM_READHINTMASK (VM_SEQ_READ | VM_RAND_READ)
180#define VM_ClearReadHint(v) (v)->vm_flags &= ~VM_READHINTMASK
181#define VM_NormalReadHint(v) (!((v)->vm_flags & VM_READHINTMASK))
182#define VM_SequentialReadHint(v) ((v)->vm_flags & VM_SEQ_READ)
183#define VM_RandomReadHint(v) ((v)->vm_flags & VM_RAND_READ)
184
185/*
186 * mapping from the currently active vm_flags protection bits (the
187 * low four bits) to a page protection mask..
188 */
189extern pgprot_t protection_map[16];
190
191
192/*
193 * These are the virtual MM functions - opening of an area, closing and
194 * unmapping it (needed to keep files on disk up-to-date etc), pointer
195 * to the functions called when a no-page or a wp-page exception occurs.
196 */
197struct vm_operations_struct {
198 void (*open)(struct vm_area_struct * area);
199 void (*close)(struct vm_area_struct * area);
200 struct page * (*nopage)(struct vm_area_struct * area, unsigned long address, int *type);
201 int (*populate)(struct vm_area_struct * area, unsigned long address, unsigned long len, pgprot_t prot, unsigned long pgoff, int nonblock);
202#ifdef CONFIG_NUMA
203 int (*set_policy)(struct vm_area_struct *vma, struct mempolicy *new);
204 struct mempolicy *(*get_policy)(struct vm_area_struct *vma,
205 unsigned long addr);
206#endif
207};
208
209struct mmu_gather;
210struct inode;
211
212#ifdef ARCH_HAS_ATOMIC_UNSIGNED
213typedef unsigned page_flags_t;
214#else
215typedef unsigned long page_flags_t;
216#endif
217
218/*
219 * Each physical page in the system has a struct page associated with
220 * it to keep track of whatever it is we are using the page for at the
221 * moment. Note that we have no way to track which tasks are using
222 * a page.
223 */
224struct page {
225 page_flags_t flags; /* Atomic flags, some possibly
226 * updated asynchronously */
227 atomic_t _count; /* Usage count, see below. */
228 atomic_t _mapcount; /* Count of ptes mapped in mms,
229 * to show when page is mapped
230 * & limit reverse map searches.
231 */
232 unsigned long private; /* Mapping-private opaque data:
233 * usually used for buffer_heads
234 * if PagePrivate set; used for
235 * swp_entry_t if PageSwapCache
236 * When page is free, this indicates
237 * order in the buddy system.
238 */
239 struct address_space *mapping; /* If low bit clear, points to
240 * inode address_space, or NULL.
241 * If page mapped as anonymous
242 * memory, low bit is set, and
243 * it points to anon_vma object:
244 * see PAGE_MAPPING_ANON below.
245 */
246 pgoff_t index; /* Our offset within mapping. */
247 struct list_head lru; /* Pageout list, eg. active_list
248 * protected by zone->lru_lock !
249 */
250 /*
251 * On machines where all RAM is mapped into kernel address space,
252 * we can simply calculate the virtual address. On machines with
253 * highmem some memory is mapped into kernel virtual memory
254 * dynamically, so we need a place to store that address.
255 * Note that this field could be 16 bits on x86 ... ;)
256 *
257 * Architectures with slow multiplication can define
258 * WANT_PAGE_VIRTUAL in asm/page.h
259 */
260#if defined(WANT_PAGE_VIRTUAL)
261 void *virtual; /* Kernel virtual address (NULL if
262 not kmapped, ie. highmem) */
263#endif /* WANT_PAGE_VIRTUAL */
264};
265
266/*
267 * FIXME: take this include out, include page-flags.h in
268 * files which need it (119 of them)
269 */
270#include <linux/page-flags.h>
271
272/*
273 * Methods to modify the page usage count.
274 *
275 * What counts for a page usage:
276 * - cache mapping (page->mapping)
277 * - private data (page->private)
278 * - page mapped in a task's page tables, each mapping
279 * is counted separately
280 *
281 * Also, many kernel routines increase the page count before a critical
282 * routine so they can be sure the page doesn't go away from under them.
283 *
284 * Since 2.6.6 (approx), a free page has ->_count = -1. This is so that we
285 * can use atomic_add_negative(-1, page->_count) to detect when the page
286 * becomes free and so that we can also use atomic_inc_and_test to atomically
287 * detect when we just tried to grab a ref on a page which some other CPU has
288 * already deemed to be freeable.
289 *
290 * NO code should make assumptions about this internal detail! Use the provided
291 * macros which retain the old rules: page_count(page) == 0 is a free page.
292 */
293
294/*
295 * Drop a ref, return true if the logical refcount fell to zero (the page has
296 * no users)
297 */
298#define put_page_testzero(p) \
299 ({ \
300 BUG_ON(page_count(p) == 0); \
301 atomic_add_negative(-1, &(p)->_count); \
302 })
303
304/*
305 * Grab a ref, return true if the page previously had a logical refcount of
306 * zero. ie: returns true if we just grabbed an already-deemed-to-be-free page
307 */
308#define get_page_testone(p) atomic_inc_and_test(&(p)->_count)
309
310#define set_page_count(p,v) atomic_set(&(p)->_count, v - 1)
311#define __put_page(p) atomic_dec(&(p)->_count)
312
313extern void FASTCALL(__page_cache_release(struct page *));
314
315#ifdef CONFIG_HUGETLB_PAGE
316
317static inline int page_count(struct page *p)
318{
319 if (PageCompound(p))
320 p = (struct page *)p->private;
321 return atomic_read(&(p)->_count) + 1;
322}
323
324static inline void get_page(struct page *page)
325{
326 if (unlikely(PageCompound(page)))
327 page = (struct page *)page->private;
328 atomic_inc(&page->_count);
329}
330
331void put_page(struct page *page);
332
333#else /* CONFIG_HUGETLB_PAGE */
334
335#define page_count(p) (atomic_read(&(p)->_count) + 1)
336
337static inline void get_page(struct page *page)
338{
339 atomic_inc(&page->_count);
340}
341
342static inline void put_page(struct page *page)
343{
344 if (!PageReserved(page) && put_page_testzero(page))
345 __page_cache_release(page);
346}
347
348#endif /* CONFIG_HUGETLB_PAGE */
349
350/*
351 * Multiple processes may "see" the same page. E.g. for untouched
352 * mappings of /dev/null, all processes see the same page full of
353 * zeroes, and text pages of executables and shared libraries have
354 * only one copy in memory, at most, normally.
355 *
356 * For the non-reserved pages, page_count(page) denotes a reference count.
357 * page_count() == 0 means the page is free.
358 * page_count() == 1 means the page is used for exactly one purpose
359 * (e.g. a private data page of one process).
360 *
361 * A page may be used for kmalloc() or anyone else who does a
362 * __get_free_page(). In this case the page_count() is at least 1, and
363 * all other fields are unused but should be 0 or NULL. The
364 * management of this page is the responsibility of the one who uses
365 * it.
366 *
367 * The other pages (we may call them "process pages") are completely
368 * managed by the Linux memory manager: I/O, buffers, swapping etc.
369 * The following discussion applies only to them.
370 *
371 * A page may belong to an inode's memory mapping. In this case,
372 * page->mapping is the pointer to the inode, and page->index is the
373 * file offset of the page, in units of PAGE_CACHE_SIZE.
374 *
375 * A page contains an opaque `private' member, which belongs to the
376 * page's address_space. Usually, this is the address of a circular
377 * list of the page's disk buffers.
378 *
379 * For pages belonging to inodes, the page_count() is the number of
380 * attaches, plus 1 if `private' contains something, plus one for
381 * the page cache itself.
382 *
383 * All pages belonging to an inode are in these doubly linked lists:
384 * mapping->clean_pages, mapping->dirty_pages and mapping->locked_pages;
385 * using the page->list list_head. These fields are also used for
386 * freelist managemet (when page_count()==0).
387 *
388 * There is also a per-mapping radix tree mapping index to the page
389 * in memory if present. The tree is rooted at mapping->root.
390 *
391 * All process pages can do I/O:
392 * - inode pages may need to be read from disk,
393 * - inode pages which have been modified and are MAP_SHARED may need
394 * to be written to disk,
395 * - private pages which have been modified may need to be swapped out
396 * to swap space and (later) to be read back into memory.
397 */
398
399/*
400 * The zone field is never updated after free_area_init_core()
401 * sets it, so none of the operations on it need to be atomic.
402 * We'll have up to (MAX_NUMNODES * MAX_NR_ZONES) zones total,
403 * so we use (MAX_NODES_SHIFT + MAX_ZONES_SHIFT) here to get enough bits.
404 */
405#define NODEZONE_SHIFT (sizeof(page_flags_t)*8 - MAX_NODES_SHIFT - MAX_ZONES_SHIFT)
406#define NODEZONE(node, zone) ((node << ZONES_SHIFT) | zone)
407
408static inline unsigned long page_zonenum(struct page *page)
409{
410 return (page->flags >> NODEZONE_SHIFT) & (~(~0UL << ZONES_SHIFT));
411}
412static inline unsigned long page_to_nid(struct page *page)
413{
414 return (page->flags >> (NODEZONE_SHIFT + ZONES_SHIFT));
415}
416
417struct zone;
418extern struct zone *zone_table[];
419
420static inline struct zone *page_zone(struct page *page)
421{
422 return zone_table[page->flags >> NODEZONE_SHIFT];
423}
424
425static inline void set_page_zone(struct page *page, unsigned long nodezone_num)
426{
427 page->flags &= ~(~0UL << NODEZONE_SHIFT);
428 page->flags |= nodezone_num << NODEZONE_SHIFT;
429}
430
431#ifndef CONFIG_DISCONTIGMEM
432/* The array of struct pages - for discontigmem use pgdat->lmem_map */
433extern struct page *mem_map;
434#endif
435
436static inline void *lowmem_page_address(struct page *page)
437{
438 return __va(page_to_pfn(page) << PAGE_SHIFT);
439}
440
441#if defined(CONFIG_HIGHMEM) && !defined(WANT_PAGE_VIRTUAL)
442#define HASHED_PAGE_VIRTUAL
443#endif
444
445#if defined(WANT_PAGE_VIRTUAL)
446#define page_address(page) ((page)->virtual)
447#define set_page_address(page, address) \
448 do { \
449 (page)->virtual = (address); \
450 } while(0)
451#define page_address_init() do { } while(0)
452#endif
453
454#if defined(HASHED_PAGE_VIRTUAL)
455void *page_address(struct page *page);
456void set_page_address(struct page *page, void *virtual);
457void page_address_init(void);
458#endif
459
460#if !defined(HASHED_PAGE_VIRTUAL) && !defined(WANT_PAGE_VIRTUAL)
461#define page_address(page) lowmem_page_address(page)
462#define set_page_address(page, address) do { } while(0)
463#define page_address_init() do { } while(0)
464#endif
465
466/*
467 * On an anonymous page mapped into a user virtual memory area,
468 * page->mapping points to its anon_vma, not to a struct address_space;
469 * with the PAGE_MAPPING_ANON bit set to distinguish it.
470 *
471 * Please note that, confusingly, "page_mapping" refers to the inode
472 * address_space which maps the page from disk; whereas "page_mapped"
473 * refers to user virtual address space into which the page is mapped.
474 */
475#define PAGE_MAPPING_ANON 1
476
477extern struct address_space swapper_space;
478static inline struct address_space *page_mapping(struct page *page)
479{
480 struct address_space *mapping = page->mapping;
481
482 if (unlikely(PageSwapCache(page)))
483 mapping = &swapper_space;
484 else if (unlikely((unsigned long)mapping & PAGE_MAPPING_ANON))
485 mapping = NULL;
486 return mapping;
487}
488
489static inline int PageAnon(struct page *page)
490{
491 return ((unsigned long)page->mapping & PAGE_MAPPING_ANON) != 0;
492}
493
494/*
495 * Return the pagecache index of the passed page. Regular pagecache pages
496 * use ->index whereas swapcache pages use ->private
497 */
498static inline pgoff_t page_index(struct page *page)
499{
500 if (unlikely(PageSwapCache(page)))
501 return page->private;
502 return page->index;
503}
504
505/*
506 * The atomic page->_mapcount, like _count, starts from -1:
507 * so that transitions both from it and to it can be tracked,
508 * using atomic_inc_and_test and atomic_add_negative(-1).
509 */
510static inline void reset_page_mapcount(struct page *page)
511{
512 atomic_set(&(page)->_mapcount, -1);
513}
514
515static inline int page_mapcount(struct page *page)
516{
517 return atomic_read(&(page)->_mapcount) + 1;
518}
519
520/*
521 * Return true if this page is mapped into pagetables.
522 */
523static inline int page_mapped(struct page *page)
524{
525 return atomic_read(&(page)->_mapcount) >= 0;
526}
527
528/*
529 * Error return values for the *_nopage functions
530 */
531#define NOPAGE_SIGBUS (NULL)
532#define NOPAGE_OOM ((struct page *) (-1))
533
534/*
535 * Different kinds of faults, as returned by handle_mm_fault().
536 * Used to decide whether a process gets delivered SIGBUS or
537 * just gets major/minor fault counters bumped up.
538 */
539#define VM_FAULT_OOM (-1)
540#define VM_FAULT_SIGBUS 0
541#define VM_FAULT_MINOR 1
542#define VM_FAULT_MAJOR 2
543
544#define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK)
545
546extern void show_free_areas(void);
547
548#ifdef CONFIG_SHMEM
549struct page *shmem_nopage(struct vm_area_struct *vma,
550 unsigned long address, int *type);
551int shmem_set_policy(struct vm_area_struct *vma, struct mempolicy *new);
552struct mempolicy *shmem_get_policy(struct vm_area_struct *vma,
553 unsigned long addr);
554int shmem_lock(struct file *file, int lock, struct user_struct *user);
555#else
556#define shmem_nopage filemap_nopage
557#define shmem_lock(a, b, c) ({0;}) /* always in memory, no need to lock */
558#define shmem_set_policy(a, b) (0)
559#define shmem_get_policy(a, b) (NULL)
560#endif
561struct file *shmem_file_setup(char *name, loff_t size, unsigned long flags);
562
563int shmem_zero_setup(struct vm_area_struct *);
564
565static inline int can_do_mlock(void)
566{
567 if (capable(CAP_IPC_LOCK))
568 return 1;
569 if (current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur != 0)
570 return 1;
571 return 0;
572}
573extern int user_shm_lock(size_t, struct user_struct *);
574extern void user_shm_unlock(size_t, struct user_struct *);
575
576/*
577 * Parameter block passed down to zap_pte_range in exceptional cases.
578 */
579struct zap_details {
580 struct vm_area_struct *nonlinear_vma; /* Check page->index if set */
581 struct address_space *check_mapping; /* Check page->mapping if set */
582 pgoff_t first_index; /* Lowest page->index to unmap */
583 pgoff_t last_index; /* Highest page->index to unmap */
584 spinlock_t *i_mmap_lock; /* For unmap_mapping_range: */
585 unsigned long break_addr; /* Where unmap_vmas stopped */
586 unsigned long truncate_count; /* Compare vm_truncate_count */
587};
588
589void zap_page_range(struct vm_area_struct *vma, unsigned long address,
590 unsigned long size, struct zap_details *);
591int unmap_vmas(struct mmu_gather **tlbp, struct mm_struct *mm,
592 struct vm_area_struct *start_vma, unsigned long start_addr,
593 unsigned long end_addr, unsigned long *nr_accounted,
594 struct zap_details *);
595void clear_page_range(struct mmu_gather *tlb, unsigned long addr, unsigned long end);
596int copy_page_range(struct mm_struct *dst, struct mm_struct *src,
597 struct vm_area_struct *vma);
598int zeromap_page_range(struct vm_area_struct *vma, unsigned long from,
599 unsigned long size, pgprot_t prot);
600void unmap_mapping_range(struct address_space *mapping,
601 loff_t const holebegin, loff_t const holelen, int even_cows);
602
603static inline void unmap_shared_mapping_range(struct address_space *mapping,
604 loff_t const holebegin, loff_t const holelen)
605{
606 unmap_mapping_range(mapping, holebegin, holelen, 0);
607}
608
609extern int vmtruncate(struct inode * inode, loff_t offset);
610extern pud_t *FASTCALL(__pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address));
611extern pmd_t *FASTCALL(__pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address));
612extern pte_t *FASTCALL(pte_alloc_kernel(struct mm_struct *mm, pmd_t *pmd, unsigned long address));
613extern pte_t *FASTCALL(pte_alloc_map(struct mm_struct *mm, pmd_t *pmd, unsigned long address));
614extern int install_page(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, struct page *page, pgprot_t prot);
615extern int install_file_pte(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, unsigned long pgoff, pgprot_t prot);
616extern int handle_mm_fault(struct mm_struct *mm,struct vm_area_struct *vma, unsigned long address, int write_access);
617extern int make_pages_present(unsigned long addr, unsigned long end);
618extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
619void install_arg_page(struct vm_area_struct *, struct page *, unsigned long);
620
621int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, unsigned long start,
622 int len, int write, int force, struct page **pages, struct vm_area_struct **vmas);
623
624int __set_page_dirty_buffers(struct page *page);
625int __set_page_dirty_nobuffers(struct page *page);
626int redirty_page_for_writepage(struct writeback_control *wbc,
627 struct page *page);
628int FASTCALL(set_page_dirty(struct page *page));
629int set_page_dirty_lock(struct page *page);
630int clear_page_dirty_for_io(struct page *page);
631
632extern unsigned long do_mremap(unsigned long addr,
633 unsigned long old_len, unsigned long new_len,
634 unsigned long flags, unsigned long new_addr);
635
636/*
637 * Prototype to add a shrinker callback for ageable caches.
638 *
639 * These functions are passed a count `nr_to_scan' and a gfpmask. They should
640 * scan `nr_to_scan' objects, attempting to free them.
641 *
642 * The callback must the number of objects which remain in the cache.
643 *
644 * The callback will be passes nr_to_scan == 0 when the VM is querying the
645 * cache size, so a fastpath for that case is appropriate.
646 */
647typedef int (*shrinker_t)(int nr_to_scan, unsigned int gfp_mask);
648
649/*
650 * Add an aging callback. The int is the number of 'seeks' it takes
651 * to recreate one of the objects that these functions age.
652 */
653
654#define DEFAULT_SEEKS 2
655struct shrinker;
656extern struct shrinker *set_shrinker(int, shrinker_t);
657extern void remove_shrinker(struct shrinker *shrinker);
658
659/*
660 * On a two-level or three-level page table, this ends up being trivial. Thus
661 * the inlining and the symmetry break with pte_alloc_map() that does all
662 * of this out-of-line.
663 */
664/*
665 * The following ifdef needed to get the 4level-fixup.h header to work.
666 * Remove it when 4level-fixup.h has been removed.
667 */
668#ifdef CONFIG_MMU
669#ifndef __ARCH_HAS_4LEVEL_HACK
670static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
671{
672 if (pgd_none(*pgd))
673 return __pud_alloc(mm, pgd, address);
674 return pud_offset(pgd, address);
675}
676
677static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
678{
679 if (pud_none(*pud))
680 return __pmd_alloc(mm, pud, address);
681 return pmd_offset(pud, address);
682}
683#endif
684#endif /* CONFIG_MMU */
685
686extern void free_area_init(unsigned long * zones_size);
687extern void free_area_init_node(int nid, pg_data_t *pgdat,
688 unsigned long * zones_size, unsigned long zone_start_pfn,
689 unsigned long *zholes_size);
690extern void memmap_init_zone(unsigned long, int, unsigned long, unsigned long);
691extern void mem_init(void);
692extern void show_mem(void);
693extern void si_meminfo(struct sysinfo * val);
694extern void si_meminfo_node(struct sysinfo *val, int nid);
695
696/* prio_tree.c */
697void vma_prio_tree_add(struct vm_area_struct *, struct vm_area_struct *old);
698void vma_prio_tree_insert(struct vm_area_struct *, struct prio_tree_root *);
699void vma_prio_tree_remove(struct vm_area_struct *, struct prio_tree_root *);
700struct vm_area_struct *vma_prio_tree_next(struct vm_area_struct *vma,
701 struct prio_tree_iter *iter);
702
703#define vma_prio_tree_foreach(vma, iter, root, begin, end) \
704 for (prio_tree_iter_init(iter, root, begin, end), vma = NULL; \
705 (vma = vma_prio_tree_next(vma, iter)); )
706
707static inline void vma_nonlinear_insert(struct vm_area_struct *vma,
708 struct list_head *list)
709{
710 vma->shared.vm_set.parent = NULL;
711 list_add_tail(&vma->shared.vm_set.list, list);
712}
713
714/* mmap.c */
715extern int __vm_enough_memory(long pages, int cap_sys_admin);
716extern void vma_adjust(struct vm_area_struct *vma, unsigned long start,
717 unsigned long end, pgoff_t pgoff, struct vm_area_struct *insert);
718extern struct vm_area_struct *vma_merge(struct mm_struct *,
719 struct vm_area_struct *prev, unsigned long addr, unsigned long end,
720 unsigned long vm_flags, struct anon_vma *, struct file *, pgoff_t,
721 struct mempolicy *);
722extern struct anon_vma *find_mergeable_anon_vma(struct vm_area_struct *);
723extern int split_vma(struct mm_struct *,
724 struct vm_area_struct *, unsigned long addr, int new_below);
725extern int insert_vm_struct(struct mm_struct *, struct vm_area_struct *);
726extern void __vma_link_rb(struct mm_struct *, struct vm_area_struct *,
727 struct rb_node **, struct rb_node *);
728extern struct vm_area_struct *copy_vma(struct vm_area_struct **,
729 unsigned long addr, unsigned long len, pgoff_t pgoff);
730extern void exit_mmap(struct mm_struct *);
731
732extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
733
734extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
735 unsigned long len, unsigned long prot,
736 unsigned long flag, unsigned long pgoff);
737
738static inline unsigned long do_mmap(struct file *file, unsigned long addr,
739 unsigned long len, unsigned long prot,
740 unsigned long flag, unsigned long offset)
741{
742 unsigned long ret = -EINVAL;
743 if ((offset + PAGE_ALIGN(len)) < offset)
744 goto out;
745 if (!(offset & ~PAGE_MASK))
746 ret = do_mmap_pgoff(file, addr, len, prot, flag, offset >> PAGE_SHIFT);
747out:
748 return ret;
749}
750
751extern int do_munmap(struct mm_struct *, unsigned long, size_t);
752
753extern unsigned long do_brk(unsigned long, unsigned long);
754
755/* filemap.c */
756extern unsigned long page_unuse(struct page *);
757extern void truncate_inode_pages(struct address_space *, loff_t);
758
759/* generic vm_area_ops exported for stackable file systems */
760extern struct page *filemap_nopage(struct vm_area_struct *, unsigned long, int *);
761extern int filemap_populate(struct vm_area_struct *, unsigned long,
762 unsigned long, pgprot_t, unsigned long, int);
763
764/* mm/page-writeback.c */
765int write_one_page(struct page *page, int wait);
766
767/* readahead.c */
768#define VM_MAX_READAHEAD 128 /* kbytes */
769#define VM_MIN_READAHEAD 16 /* kbytes (includes current page) */
770#define VM_MAX_CACHE_HIT 256 /* max pages in a row in cache before
771 * turning readahead off */
772
773int do_page_cache_readahead(struct address_space *mapping, struct file *filp,
774 unsigned long offset, unsigned long nr_to_read);
775int force_page_cache_readahead(struct address_space *mapping, struct file *filp,
776 unsigned long offset, unsigned long nr_to_read);
777unsigned long page_cache_readahead(struct address_space *mapping,
778 struct file_ra_state *ra,
779 struct file *filp,
780 unsigned long offset,
781 unsigned long size);
782void handle_ra_miss(struct address_space *mapping,
783 struct file_ra_state *ra, pgoff_t offset);
784unsigned long max_sane_readahead(unsigned long nr);
785
786/* Do stack extension */
787extern int expand_stack(struct vm_area_struct * vma, unsigned long address);
788
789/* Look up the first VMA which satisfies addr < vm_end, NULL if none. */
790extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long addr);
791extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
792 struct vm_area_struct **pprev);
793
794/* Look up the first VMA which intersects the interval start_addr..end_addr-1,
795 NULL if none. Assume start_addr < end_addr. */
796static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
797{
798 struct vm_area_struct * vma = find_vma(mm,start_addr);
799
800 if (vma && end_addr <= vma->vm_start)
801 vma = NULL;
802 return vma;
803}
804
805static inline unsigned long vma_pages(struct vm_area_struct *vma)
806{
807 return (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
808}
809
810extern struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr);
811
812extern struct page * vmalloc_to_page(void *addr);
813extern unsigned long vmalloc_to_pfn(void *addr);
814extern struct page * follow_page(struct mm_struct *mm, unsigned long address,
815 int write);
816extern int check_user_page_readable(struct mm_struct *mm, unsigned long address);
817int remap_pfn_range(struct vm_area_struct *, unsigned long,
818 unsigned long, unsigned long, pgprot_t);
819
820#ifdef CONFIG_PROC_FS
821void __vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
822#else
823static inline void __vm_stat_account(struct mm_struct *mm,
824 unsigned long flags, struct file *file, long pages)
825{
826}
827#endif /* CONFIG_PROC_FS */
828
829static inline void vm_stat_account(struct vm_area_struct *vma)
830{
831 __vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file,
832 vma_pages(vma));
833}
834
835static inline void vm_stat_unaccount(struct vm_area_struct *vma)
836{
837 __vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file,
838 -vma_pages(vma));
839}
840
841/* update per process rss and vm hiwater data */
842extern void update_mem_hiwater(struct task_struct *tsk);
843
844#ifndef CONFIG_DEBUG_PAGEALLOC
845static inline void
846kernel_map_pages(struct page *page, int numpages, int enable)
847{
848}
849#endif
850
851extern struct vm_area_struct *get_gate_vma(struct task_struct *tsk);
852#ifdef __HAVE_ARCH_GATE_AREA
853int in_gate_area_no_task(unsigned long addr);
854int in_gate_area(struct task_struct *task, unsigned long addr);
855#else
856int in_gate_area_no_task(unsigned long addr);
857#define in_gate_area(task, addr) ({(void)task; in_gate_area_no_task(addr);})
858#endif /* __HAVE_ARCH_GATE_AREA */
859
860#endif /* __KERNEL__ */
861#endif /* _LINUX_MM_H */
diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h
new file mode 100644
index 000000000000..47762ca695a5
--- /dev/null
+++ b/include/linux/mm_inline.h
@@ -0,0 +1,40 @@
1
2static inline void
3add_page_to_active_list(struct zone *zone, struct page *page)
4{
5 list_add(&page->lru, &zone->active_list);
6 zone->nr_active++;
7}
8
9static inline void
10add_page_to_inactive_list(struct zone *zone, struct page *page)
11{
12 list_add(&page->lru, &zone->inactive_list);
13 zone->nr_inactive++;
14}
15
16static inline void
17del_page_from_active_list(struct zone *zone, struct page *page)
18{
19 list_del(&page->lru);
20 zone->nr_active--;
21}
22
23static inline void
24del_page_from_inactive_list(struct zone *zone, struct page *page)
25{
26 list_del(&page->lru);
27 zone->nr_inactive--;
28}
29
30static inline void
31del_page_from_lru(struct zone *zone, struct page *page)
32{
33 list_del(&page->lru);
34 if (PageActive(page)) {
35 ClearPageActive(page);
36 zone->nr_active--;
37 } else {
38 zone->nr_inactive--;
39 }
40}
diff --git a/include/linux/mman.h b/include/linux/mman.h
new file mode 100644
index 000000000000..18a5689ef748
--- /dev/null
+++ b/include/linux/mman.h
@@ -0,0 +1,67 @@
1#ifndef _LINUX_MMAN_H
2#define _LINUX_MMAN_H
3
4#include <linux/config.h>
5#include <linux/mm.h>
6
7#include <asm/atomic.h>
8#include <asm/mman.h>
9
10#define MREMAP_MAYMOVE 1
11#define MREMAP_FIXED 2
12
13#define OVERCOMMIT_GUESS 0
14#define OVERCOMMIT_ALWAYS 1
15#define OVERCOMMIT_NEVER 2
16extern int sysctl_overcommit_memory;
17extern int sysctl_overcommit_ratio;
18extern atomic_t vm_committed_space;
19
20#ifdef CONFIG_SMP
21extern void vm_acct_memory(long pages);
22#else
23static inline void vm_acct_memory(long pages)
24{
25 atomic_add(pages, &vm_committed_space);
26}
27#endif
28
29static inline void vm_unacct_memory(long pages)
30{
31 vm_acct_memory(-pages);
32}
33
34/*
35 * Optimisation macro. It is equivalent to:
36 * (x & bit1) ? bit2 : 0
37 * but this version is faster.
38 * ("bit1" and "bit2" must be single bits)
39 */
40#define _calc_vm_trans(x, bit1, bit2) \
41 ((bit1) <= (bit2) ? ((x) & (bit1)) * ((bit2) / (bit1)) \
42 : ((x) & (bit1)) / ((bit1) / (bit2)))
43
44/*
45 * Combine the mmap "prot" argument into "vm_flags" used internally.
46 */
47static inline unsigned long
48calc_vm_prot_bits(unsigned long prot)
49{
50 return _calc_vm_trans(prot, PROT_READ, VM_READ ) |
51 _calc_vm_trans(prot, PROT_WRITE, VM_WRITE) |
52 _calc_vm_trans(prot, PROT_EXEC, VM_EXEC );
53}
54
55/*
56 * Combine the mmap "flags" argument into "vm_flags" used internally.
57 */
58static inline unsigned long
59calc_vm_flag_bits(unsigned long flags)
60{
61 return _calc_vm_trans(flags, MAP_GROWSDOWN, VM_GROWSDOWN ) |
62 _calc_vm_trans(flags, MAP_DENYWRITE, VM_DENYWRITE ) |
63 _calc_vm_trans(flags, MAP_EXECUTABLE, VM_EXECUTABLE) |
64 _calc_vm_trans(flags, MAP_LOCKED, VM_LOCKED );
65}
66
67#endif /* _LINUX_MMAN_H */
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
new file mode 100644
index 000000000000..aefedf04b9bb
--- /dev/null
+++ b/include/linux/mmc/card.h
@@ -0,0 +1,92 @@
1/*
2 * linux/include/linux/mmc/card.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 * Card driver specific definitions.
9 */
10#ifndef LINUX_MMC_CARD_H
11#define LINUX_MMC_CARD_H
12
13#include <linux/mmc/mmc.h>
14
15struct mmc_cid {
16 unsigned int manfid;
17 char prod_name[8];
18 unsigned int serial;
19 unsigned short oemid;
20 unsigned short year;
21 unsigned char hwrev;
22 unsigned char fwrev;
23 unsigned char month;
24};
25
26struct mmc_csd {
27 unsigned char mmca_vsn;
28 unsigned short cmdclass;
29 unsigned short tacc_clks;
30 unsigned int tacc_ns;
31 unsigned int max_dtr;
32 unsigned int read_blkbits;
33 unsigned int capacity;
34};
35
36struct mmc_host;
37
38/*
39 * MMC device
40 */
41struct mmc_card {
42 struct list_head node; /* node in hosts devices list */
43 struct mmc_host *host; /* the host this device belongs to */
44 struct device dev; /* the device */
45 unsigned int rca; /* relative card address of device */
46 unsigned int state; /* (our) card state */
47#define MMC_STATE_PRESENT (1<<0) /* present in sysfs */
48#define MMC_STATE_DEAD (1<<1) /* device no longer in stack */
49#define MMC_STATE_BAD (1<<2) /* unrecognised device */
50 u32 raw_cid[4]; /* raw card CID */
51 u32 raw_csd[4]; /* raw card CSD */
52 struct mmc_cid cid; /* card identification */
53 struct mmc_csd csd; /* card specific */
54};
55
56#define mmc_card_present(c) ((c)->state & MMC_STATE_PRESENT)
57#define mmc_card_dead(c) ((c)->state & MMC_STATE_DEAD)
58#define mmc_card_bad(c) ((c)->state & MMC_STATE_BAD)
59
60#define mmc_card_set_present(c) ((c)->state |= MMC_STATE_PRESENT)
61#define mmc_card_set_dead(c) ((c)->state |= MMC_STATE_DEAD)
62#define mmc_card_set_bad(c) ((c)->state |= MMC_STATE_BAD)
63
64#define mmc_card_name(c) ((c)->cid.prod_name)
65#define mmc_card_id(c) ((c)->dev.bus_id)
66
67#define mmc_list_to_card(l) container_of(l, struct mmc_card, node)
68#define mmc_get_drvdata(c) dev_get_drvdata(&(c)->dev)
69#define mmc_set_drvdata(c,d) dev_set_drvdata(&(c)->dev, d)
70
71/*
72 * MMC device driver (e.g., Flash card, I/O card...)
73 */
74struct mmc_driver {
75 struct device_driver drv;
76 int (*probe)(struct mmc_card *);
77 void (*remove)(struct mmc_card *);
78 int (*suspend)(struct mmc_card *, pm_message_t);
79 int (*resume)(struct mmc_card *);
80};
81
82extern int mmc_register_driver(struct mmc_driver *);
83extern void mmc_unregister_driver(struct mmc_driver *);
84
85static inline int mmc_card_claim_host(struct mmc_card *card)
86{
87 return __mmc_claim_host(card->host, card);
88}
89
90#define mmc_card_release_host(c) mmc_release_host((c)->host)
91
92#endif
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
new file mode 100644
index 000000000000..f67686cef62a
--- /dev/null
+++ b/include/linux/mmc/host.h
@@ -0,0 +1,108 @@
1/*
2 * linux/include/linux/mmc/host.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 * Host driver specific definitions.
9 */
10#ifndef LINUX_MMC_HOST_H
11#define LINUX_MMC_HOST_H
12
13#include <linux/mmc/mmc.h>
14
15struct mmc_ios {
16 unsigned int clock; /* clock rate */
17 unsigned short vdd;
18
19#define MMC_VDD_150 0
20#define MMC_VDD_155 1
21#define MMC_VDD_160 2
22#define MMC_VDD_165 3
23#define MMC_VDD_170 4
24#define MMC_VDD_180 5
25#define MMC_VDD_190 6
26#define MMC_VDD_200 7
27#define MMC_VDD_210 8
28#define MMC_VDD_220 9
29#define MMC_VDD_230 10
30#define MMC_VDD_240 11
31#define MMC_VDD_250 12
32#define MMC_VDD_260 13
33#define MMC_VDD_270 14
34#define MMC_VDD_280 15
35#define MMC_VDD_290 16
36#define MMC_VDD_300 17
37#define MMC_VDD_310 18
38#define MMC_VDD_320 19
39#define MMC_VDD_330 20
40#define MMC_VDD_340 21
41#define MMC_VDD_350 22
42#define MMC_VDD_360 23
43
44 unsigned char bus_mode; /* command output mode */
45
46#define MMC_BUSMODE_OPENDRAIN 1
47#define MMC_BUSMODE_PUSHPULL 2
48
49 unsigned char power_mode; /* power supply mode */
50
51#define MMC_POWER_OFF 0
52#define MMC_POWER_UP 1
53#define MMC_POWER_ON 2
54};
55
56struct mmc_host_ops {
57 void (*request)(struct mmc_host *host, struct mmc_request *req);
58 void (*set_ios)(struct mmc_host *host, struct mmc_ios *ios);
59};
60
61struct mmc_card;
62struct device;
63
64struct mmc_host {
65 struct device *dev;
66 struct mmc_host_ops *ops;
67 unsigned int f_min;
68 unsigned int f_max;
69 u32 ocr_avail;
70 char host_name[8];
71
72 /* host specific block data */
73 unsigned int max_seg_size; /* see blk_queue_max_segment_size */
74 unsigned short max_hw_segs; /* see blk_queue_max_hw_segments */
75 unsigned short max_phys_segs; /* see blk_queue_max_phys_segments */
76 unsigned short max_sectors; /* see blk_queue_max_sectors */
77 unsigned short unused;
78
79 /* private data */
80 struct mmc_ios ios; /* current io bus settings */
81 u32 ocr; /* the current OCR setting */
82
83 struct list_head cards; /* devices attached to this host */
84
85 wait_queue_head_t wq;
86 spinlock_t lock; /* card_busy lock */
87 struct mmc_card *card_busy; /* the MMC card claiming host */
88 struct mmc_card *card_selected; /* the selected MMC card */
89
90 struct work_struct detect;
91};
92
93extern struct mmc_host *mmc_alloc_host(int extra, struct device *);
94extern int mmc_add_host(struct mmc_host *);
95extern void mmc_remove_host(struct mmc_host *);
96extern void mmc_free_host(struct mmc_host *);
97
98#define mmc_priv(x) ((void *)((x) + 1))
99#define mmc_dev(x) ((x)->dev)
100
101extern int mmc_suspend_host(struct mmc_host *, u32);
102extern int mmc_resume_host(struct mmc_host *);
103
104extern void mmc_detect_change(struct mmc_host *);
105extern void mmc_request_done(struct mmc_host *, struct mmc_request *);
106
107#endif
108
diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
new file mode 100644
index 000000000000..0d35d4ffb360
--- /dev/null
+++ b/include/linux/mmc/mmc.h
@@ -0,0 +1,101 @@
1/*
2 * linux/include/linux/mmc/mmc.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#ifndef MMC_H
9#define MMC_H
10
11#include <linux/list.h>
12#include <linux/interrupt.h>
13#include <linux/device.h>
14
15struct request;
16struct mmc_data;
17struct mmc_request;
18
19struct mmc_command {
20 u32 opcode;
21 u32 arg;
22 u32 resp[4];
23 unsigned int flags; /* expected response type */
24#define MMC_RSP_NONE (0 << 0)
25#define MMC_RSP_SHORT (1 << 0)
26#define MMC_RSP_LONG (2 << 0)
27#define MMC_RSP_MASK (3 << 0)
28#define MMC_RSP_CRC (1 << 3) /* expect valid crc */
29#define MMC_RSP_BUSY (1 << 4) /* card may send busy */
30
31/*
32 * These are the response types, and correspond to valid bit
33 * patterns of the above flags. One additional valid pattern
34 * is all zeros, which means we don't expect a response.
35 */
36#define MMC_RSP_R1 (MMC_RSP_SHORT|MMC_RSP_CRC)
37#define MMC_RSP_R1B (MMC_RSP_SHORT|MMC_RSP_CRC|MMC_RSP_BUSY)
38#define MMC_RSP_R2 (MMC_RSP_LONG|MMC_RSP_CRC)
39#define MMC_RSP_R3 (MMC_RSP_SHORT)
40#define MMC_RSP_R6 (MMC_RSP_SHORT|MMC_RSP_CRC)
41
42 unsigned int retries; /* max number of retries */
43 unsigned int error; /* command error */
44
45#define MMC_ERR_NONE 0
46#define MMC_ERR_TIMEOUT 1
47#define MMC_ERR_BADCRC 2
48#define MMC_ERR_FIFO 3
49#define MMC_ERR_FAILED 4
50#define MMC_ERR_INVALID 5
51
52 struct mmc_data *data; /* data segment associated with cmd */
53 struct mmc_request *mrq; /* assoicated request */
54};
55
56struct mmc_data {
57 unsigned int timeout_ns; /* data timeout (in ns, max 80ms) */
58 unsigned int timeout_clks; /* data timeout (in clocks) */
59 unsigned int blksz_bits; /* data block size */
60 unsigned int blocks; /* number of blocks */
61 unsigned int error; /* data error */
62 unsigned int flags;
63
64#define MMC_DATA_WRITE (1 << 8)
65#define MMC_DATA_READ (1 << 9)
66#define MMC_DATA_STREAM (1 << 10)
67
68 unsigned int bytes_xfered;
69
70 struct mmc_command *stop; /* stop command */
71 struct mmc_request *mrq; /* assoicated request */
72
73 unsigned int sg_len; /* size of scatter list */
74 struct scatterlist *sg; /* I/O scatter list */
75};
76
77struct mmc_request {
78 struct mmc_command *cmd;
79 struct mmc_data *data;
80 struct mmc_command *stop;
81
82 void *done_data; /* completion data */
83 void (*done)(struct mmc_request *);/* completion function */
84};
85
86struct mmc_host;
87struct mmc_card;
88
89extern int mmc_wait_for_req(struct mmc_host *, struct mmc_request *);
90extern int mmc_wait_for_cmd(struct mmc_host *, struct mmc_command *, int);
91
92extern int __mmc_claim_host(struct mmc_host *host, struct mmc_card *card);
93
94static inline void mmc_claim_host(struct mmc_host *host)
95{
96 __mmc_claim_host(host, (struct mmc_card *)-1);
97}
98
99extern void mmc_release_host(struct mmc_host *host);
100
101#endif
diff --git a/include/linux/mmc/protocol.h b/include/linux/mmc/protocol.h
new file mode 100644
index 000000000000..7b904c5102f6
--- /dev/null
+++ b/include/linux/mmc/protocol.h
@@ -0,0 +1,213 @@
1/*
2 * Header for MultiMediaCard (MMC)
3 *
4 * Copyright 2002 Hewlett-Packard Company
5 *
6 * Use consistent with the GNU GPL is permitted,
7 * provided that this copyright notice is
8 * preserved in its entirety in all copies and derived works.
9 *
10 * HEWLETT-PACKARD COMPANY MAKES NO WARRANTIES, EXPRESSED OR IMPLIED,
11 * AS TO THE USEFULNESS OR CORRECTNESS OF THIS CODE OR ITS
12 * FITNESS FOR ANY PARTICULAR PURPOSE.
13 *
14 * Many thanks to Alessandro Rubini and Jonathan Corbet!
15 *
16 * Based strongly on code by:
17 *
18 * Author: Yong-iL Joh <tolkien@mizi.com>
19 * Date : $Date: 2002/06/18 12:37:30 $
20 *
21 * Author: Andrew Christian
22 * 15 May 2002
23 */
24
25#ifndef MMC_MMC_PROTOCOL_H
26#define MMC_MMC_PROTOCOL_H
27
28/* Standard MMC commands (3.1) type argument response */
29 /* class 1 */
30#define MMC_GO_IDLE_STATE 0 /* bc */
31#define MMC_SEND_OP_COND 1 /* bcr [31:0] OCR R3 */
32#define MMC_ALL_SEND_CID 2 /* bcr R2 */
33#define MMC_SET_RELATIVE_ADDR 3 /* ac [31:16] RCA R1 */
34#define MMC_SET_DSR 4 /* bc [31:16] RCA */
35#define MMC_SELECT_CARD 7 /* ac [31:16] RCA R1 */
36#define MMC_SEND_CSD 9 /* ac [31:16] RCA R2 */
37#define MMC_SEND_CID 10 /* ac [31:16] RCA R2 */
38#define MMC_READ_DAT_UNTIL_STOP 11 /* adtc [31:0] dadr R1 */
39#define MMC_STOP_TRANSMISSION 12 /* ac R1b */
40#define MMC_SEND_STATUS 13 /* ac [31:16] RCA R1 */
41#define MMC_GO_INACTIVE_STATE 15 /* ac [31:16] RCA */
42
43 /* class 2 */
44#define MMC_SET_BLOCKLEN 16 /* ac [31:0] block len R1 */
45#define MMC_READ_SINGLE_BLOCK 17 /* adtc [31:0] data addr R1 */
46#define MMC_READ_MULTIPLE_BLOCK 18 /* adtc [31:0] data addr R1 */
47
48 /* class 3 */
49#define MMC_WRITE_DAT_UNTIL_STOP 20 /* adtc [31:0] data addr R1 */
50
51 /* class 4 */
52#define MMC_SET_BLOCK_COUNT 23 /* adtc [31:0] data addr R1 */
53#define MMC_WRITE_BLOCK 24 /* adtc [31:0] data addr R1 */
54#define MMC_WRITE_MULTIPLE_BLOCK 25 /* adtc R1 */
55#define MMC_PROGRAM_CID 26 /* adtc R1 */
56#define MMC_PROGRAM_CSD 27 /* adtc R1 */
57
58 /* class 6 */
59#define MMC_SET_WRITE_PROT 28 /* ac [31:0] data addr R1b */
60#define MMC_CLR_WRITE_PROT 29 /* ac [31:0] data addr R1b */
61#define MMC_SEND_WRITE_PROT 30 /* adtc [31:0] wpdata addr R1 */
62
63 /* class 5 */
64#define MMC_ERASE_GROUP_START 35 /* ac [31:0] data addr R1 */
65#define MMC_ERASE_GROUP_END 36 /* ac [31:0] data addr R1 */
66#define MMC_ERASE 37 /* ac R1b */
67
68 /* class 9 */
69#define MMC_FAST_IO 39 /* ac <Complex> R4 */
70#define MMC_GO_IRQ_STATE 40 /* bcr R5 */
71
72 /* class 7 */
73#define MMC_LOCK_UNLOCK 42 /* adtc R1b */
74
75 /* class 8 */
76#define MMC_APP_CMD 55 /* ac [31:16] RCA R1 */
77#define MMC_GEN_CMD 56 /* adtc [0] RD/WR R1b */
78
79/* SD commands type argument response */
80 /* class 8 */
81/* This is basically the same command as for MMC with some quirks. */
82#define SD_SEND_RELATIVE_ADDR 3 /* ac R6 */
83
84 /* Application commands */
85#define SD_APP_SET_BUS_WIDTH 6 /* ac [1:0] bus width R1 */
86#define SD_APP_OP_COND 41 /* bcr [31:0] OCR R3 */
87#define SD_APP_SEND_SCR 51 /* adtc R1 */
88
89/*
90 MMC status in R1
91 Type
92 e : error bit
93 s : status bit
94 r : detected and set for the actual command response
95 x : detected and set during command execution. the host must poll
96 the card by sending status command in order to read these bits.
97 Clear condition
98 a : according to the card state
99 b : always related to the previous command. Reception of
100 a valid command will clear it (with a delay of one command)
101 c : clear by read
102 */
103
104#define R1_OUT_OF_RANGE (1 << 31) /* er, c */
105#define R1_ADDRESS_ERROR (1 << 30) /* erx, c */
106#define R1_BLOCK_LEN_ERROR (1 << 29) /* er, c */
107#define R1_ERASE_SEQ_ERROR (1 << 28) /* er, c */
108#define R1_ERASE_PARAM (1 << 27) /* ex, c */
109#define R1_WP_VIOLATION (1 << 26) /* erx, c */
110#define R1_CARD_IS_LOCKED (1 << 25) /* sx, a */
111#define R1_LOCK_UNLOCK_FAILED (1 << 24) /* erx, c */
112#define R1_COM_CRC_ERROR (1 << 23) /* er, b */
113#define R1_ILLEGAL_COMMAND (1 << 22) /* er, b */
114#define R1_CARD_ECC_FAILED (1 << 21) /* ex, c */
115#define R1_CC_ERROR (1 << 20) /* erx, c */
116#define R1_ERROR (1 << 19) /* erx, c */
117#define R1_UNDERRUN (1 << 18) /* ex, c */
118#define R1_OVERRUN (1 << 17) /* ex, c */
119#define R1_CID_CSD_OVERWRITE (1 << 16) /* erx, c, CID/CSD overwrite */
120#define R1_WP_ERASE_SKIP (1 << 15) /* sx, c */
121#define R1_CARD_ECC_DISABLED (1 << 14) /* sx, a */
122#define R1_ERASE_RESET (1 << 13) /* sr, c */
123#define R1_STATUS(x) (x & 0xFFFFE000)
124#define R1_CURRENT_STATE(x) ((x & 0x00001E00) >> 9) /* sx, b (4 bits) */
125#define R1_READY_FOR_DATA (1 << 8) /* sx, a */
126#define R1_APP_CMD (1 << 5) /* sr, c */
127
128/* These are unpacked versions of the actual responses */
129
130struct _mmc_csd {
131 u8 csd_structure;
132 u8 spec_vers;
133 u8 taac;
134 u8 nsac;
135 u8 tran_speed;
136 u16 ccc;
137 u8 read_bl_len;
138 u8 read_bl_partial;
139 u8 write_blk_misalign;
140 u8 read_blk_misalign;
141 u8 dsr_imp;
142 u16 c_size;
143 u8 vdd_r_curr_min;
144 u8 vdd_r_curr_max;
145 u8 vdd_w_curr_min;
146 u8 vdd_w_curr_max;
147 u8 c_size_mult;
148 union {
149 struct { /* MMC system specification version 3.1 */
150 u8 erase_grp_size;
151 u8 erase_grp_mult;
152 } v31;
153 struct { /* MMC system specification version 2.2 */
154 u8 sector_size;
155 u8 erase_grp_size;
156 } v22;
157 } erase;
158 u8 wp_grp_size;
159 u8 wp_grp_enable;
160 u8 default_ecc;
161 u8 r2w_factor;
162 u8 write_bl_len;
163 u8 write_bl_partial;
164 u8 file_format_grp;
165 u8 copy;
166 u8 perm_write_protect;
167 u8 tmp_write_protect;
168 u8 file_format;
169 u8 ecc;
170};
171
172#define MMC_VDD_145_150 0x00000001 /* VDD voltage 1.45 - 1.50 */
173#define MMC_VDD_150_155 0x00000002 /* VDD voltage 1.50 - 1.55 */
174#define MMC_VDD_155_160 0x00000004 /* VDD voltage 1.55 - 1.60 */
175#define MMC_VDD_160_165 0x00000008 /* VDD voltage 1.60 - 1.65 */
176#define MMC_VDD_165_170 0x00000010 /* VDD voltage 1.65 - 1.70 */
177#define MMC_VDD_17_18 0x00000020 /* VDD voltage 1.7 - 1.8 */
178#define MMC_VDD_18_19 0x00000040 /* VDD voltage 1.8 - 1.9 */
179#define MMC_VDD_19_20 0x00000080 /* VDD voltage 1.9 - 2.0 */
180#define MMC_VDD_20_21 0x00000100 /* VDD voltage 2.0 ~ 2.1 */
181#define MMC_VDD_21_22 0x00000200 /* VDD voltage 2.1 ~ 2.2 */
182#define MMC_VDD_22_23 0x00000400 /* VDD voltage 2.2 ~ 2.3 */
183#define MMC_VDD_23_24 0x00000800 /* VDD voltage 2.3 ~ 2.4 */
184#define MMC_VDD_24_25 0x00001000 /* VDD voltage 2.4 ~ 2.5 */
185#define MMC_VDD_25_26 0x00002000 /* VDD voltage 2.5 ~ 2.6 */
186#define MMC_VDD_26_27 0x00004000 /* VDD voltage 2.6 ~ 2.7 */
187#define MMC_VDD_27_28 0x00008000 /* VDD voltage 2.7 ~ 2.8 */
188#define MMC_VDD_28_29 0x00010000 /* VDD voltage 2.8 ~ 2.9 */
189#define MMC_VDD_29_30 0x00020000 /* VDD voltage 2.9 ~ 3.0 */
190#define MMC_VDD_30_31 0x00040000 /* VDD voltage 3.0 ~ 3.1 */
191#define MMC_VDD_31_32 0x00080000 /* VDD voltage 3.1 ~ 3.2 */
192#define MMC_VDD_32_33 0x00100000 /* VDD voltage 3.2 ~ 3.3 */
193#define MMC_VDD_33_34 0x00200000 /* VDD voltage 3.3 ~ 3.4 */
194#define MMC_VDD_34_35 0x00400000 /* VDD voltage 3.4 ~ 3.5 */
195#define MMC_VDD_35_36 0x00800000 /* VDD voltage 3.5 ~ 3.6 */
196#define MMC_CARD_BUSY 0x80000000 /* Card Power up status bit */
197
198
199/*
200 * CSD field definitions
201 */
202
203#define CSD_STRUCT_VER_1_0 0 /* Valid for system specification 1.0 - 1.2 */
204#define CSD_STRUCT_VER_1_1 1 /* Valid for system specification 1.4 - 2.2 */
205#define CSD_STRUCT_VER_1_2 2 /* Valid for system specification 3.1 */
206
207#define CSD_SPEC_VER_0 0 /* Implements system specification 1.0 - 1.2 */
208#define CSD_SPEC_VER_1 1 /* Implements system specification 1.4 */
209#define CSD_SPEC_VER_2 2 /* Implements system specification 2.0 - 2.2 */
210#define CSD_SPEC_VER_3 3 /* Implements system specification 3.1 */
211
212#endif /* MMC_MMC_PROTOCOL_H */
213
diff --git a/include/linux/mmtimer.h b/include/linux/mmtimer.h
new file mode 100644
index 000000000000..884cabf16088
--- /dev/null
+++ b/include/linux/mmtimer.h
@@ -0,0 +1,56 @@
1/*
2 * Intel Multimedia Timer device interface
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-2004 Silicon Graphics, Inc. All rights reserved.
9 *
10 * This file should define an interface compatible with the IA-PC Multimedia
11 * Timers Draft Specification (rev. 0.97) from Intel. Note that some
12 * hardware may not be able to safely export its registers to userspace,
13 * so the ioctl interface should support all necessary functionality.
14 *
15 * 11/01/01 - jbarnes - initial revision
16 * 9/10/04 - Christoph Lameter - remove interrupt support
17 * 9/17/04 - jbarnes - remove test program, move some #defines to the driver
18 */
19
20#ifndef _LINUX_MMTIMER_H
21#define _LINUX_MMTIMER_H
22
23/*
24 * Breakdown of the ioctl's available. An 'optional' next to the command
25 * indicates that supporting this command is optional, while 'required'
26 * commands must be implemented if conformance is desired.
27 *
28 * MMTIMER_GETOFFSET - optional
29 * Should return the offset (relative to the start of the page where the
30 * registers are mapped) for the counter in question.
31 *
32 * MMTIMER_GETRES - required
33 * The resolution of the clock in femto (10^-15) seconds
34 *
35 * MMTIMER_GETFREQ - required
36 * Frequency of the clock in Hz
37 *
38 * MMTIMER_GETBITS - required
39 * Number of bits in the clock's counter
40 *
41 * MMTIMER_MMAPAVAIL - required
42 * Returns nonzero if the registers can be mmap'd into userspace, 0 otherwise
43 *
44 * MMTIMER_GETCOUNTER - required
45 * Gets the current value in the counter
46 */
47#define MMTIMER_IOCTL_BASE 'm'
48
49#define MMTIMER_GETOFFSET _IO(MMTIMER_IOCTL_BASE, 0)
50#define MMTIMER_GETRES _IOR(MMTIMER_IOCTL_BASE, 1, unsigned long)
51#define MMTIMER_GETFREQ _IOR(MMTIMER_IOCTL_BASE, 2, unsigned long)
52#define MMTIMER_GETBITS _IO(MMTIMER_IOCTL_BASE, 4)
53#define MMTIMER_MMAPAVAIL _IO(MMTIMER_IOCTL_BASE, 6)
54#define MMTIMER_GETCOUNTER _IOR(MMTIMER_IOCTL_BASE, 9, unsigned long)
55
56#endif /* _LINUX_MMTIMER_H */
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
new file mode 100644
index 000000000000..e530c6c092f1
--- /dev/null
+++ b/include/linux/mmzone.h
@@ -0,0 +1,426 @@
1#ifndef _LINUX_MMZONE_H
2#define _LINUX_MMZONE_H
3
4#ifdef __KERNEL__
5#ifndef __ASSEMBLY__
6
7#include <linux/config.h>
8#include <linux/spinlock.h>
9#include <linux/list.h>
10#include <linux/wait.h>
11#include <linux/cache.h>
12#include <linux/threads.h>
13#include <linux/numa.h>
14#include <linux/init.h>
15#include <asm/atomic.h>
16
17/* Free memory management - zoned buddy allocator. */
18#ifndef CONFIG_FORCE_MAX_ZONEORDER
19#define MAX_ORDER 11
20#else
21#define MAX_ORDER CONFIG_FORCE_MAX_ZONEORDER
22#endif
23
24struct free_area {
25 struct list_head free_list;
26 unsigned long nr_free;
27};
28
29struct pglist_data;
30
31/*
32 * zone->lock and zone->lru_lock are two of the hottest locks in the kernel.
33 * So add a wild amount of padding here to ensure that they fall into separate
34 * cachelines. There are very few zone structures in the machine, so space
35 * consumption is not a concern here.
36 */
37#if defined(CONFIG_SMP)
38struct zone_padding {
39 char x[0];
40} ____cacheline_maxaligned_in_smp;
41#define ZONE_PADDING(name) struct zone_padding name;
42#else
43#define ZONE_PADDING(name)
44#endif
45
46struct per_cpu_pages {
47 int count; /* number of pages in the list */
48 int low; /* low watermark, refill needed */
49 int high; /* high watermark, emptying needed */
50 int batch; /* chunk size for buddy add/remove */
51 struct list_head list; /* the list of pages */
52};
53
54struct per_cpu_pageset {
55 struct per_cpu_pages pcp[2]; /* 0: hot. 1: cold */
56#ifdef CONFIG_NUMA
57 unsigned long numa_hit; /* allocated in intended node */
58 unsigned long numa_miss; /* allocated in non intended node */
59 unsigned long numa_foreign; /* was intended here, hit elsewhere */
60 unsigned long interleave_hit; /* interleaver prefered this zone */
61 unsigned long local_node; /* allocation from local node */
62 unsigned long other_node; /* allocation from other node */
63#endif
64} ____cacheline_aligned_in_smp;
65
66#define ZONE_DMA 0
67#define ZONE_NORMAL 1
68#define ZONE_HIGHMEM 2
69
70#define MAX_NR_ZONES 3 /* Sync this with ZONES_SHIFT */
71#define ZONES_SHIFT 2 /* ceil(log2(MAX_NR_ZONES)) */
72
73
74/*
75 * When a memory allocation must conform to specific limitations (such
76 * as being suitable for DMA) the caller will pass in hints to the
77 * allocator in the gfp_mask, in the zone modifier bits. These bits
78 * are used to select a priority ordered list of memory zones which
79 * match the requested limits. GFP_ZONEMASK defines which bits within
80 * the gfp_mask should be considered as zone modifiers. Each valid
81 * combination of the zone modifier bits has a corresponding list
82 * of zones (in node_zonelists). Thus for two zone modifiers there
83 * will be a maximum of 4 (2 ** 2) zonelists, for 3 modifiers there will
84 * be 8 (2 ** 3) zonelists. GFP_ZONETYPES defines the number of possible
85 * combinations of zone modifiers in "zone modifier space".
86 */
87#define GFP_ZONEMASK 0x03
88/*
89 * As an optimisation any zone modifier bits which are only valid when
90 * no other zone modifier bits are set (loners) should be placed in
91 * the highest order bits of this field. This allows us to reduce the
92 * extent of the zonelists thus saving space. For example in the case
93 * of three zone modifier bits, we could require up to eight zonelists.
94 * If the left most zone modifier is a "loner" then the highest valid
95 * zonelist would be four allowing us to allocate only five zonelists.
96 * Use the first form when the left most bit is not a "loner", otherwise
97 * use the second.
98 */
99/* #define GFP_ZONETYPES (GFP_ZONEMASK + 1) */ /* Non-loner */
100#define GFP_ZONETYPES ((GFP_ZONEMASK + 1) / 2 + 1) /* Loner */
101
102/*
103 * On machines where it is needed (eg PCs) we divide physical memory
104 * into multiple physical zones. On a PC we have 3 zones:
105 *
106 * ZONE_DMA < 16 MB ISA DMA capable memory
107 * ZONE_NORMAL 16-896 MB direct mapped by the kernel
108 * ZONE_HIGHMEM > 896 MB only page cache and user processes
109 */
110
111struct zone {
112 /* Fields commonly accessed by the page allocator */
113 unsigned long free_pages;
114 unsigned long pages_min, pages_low, pages_high;
115 /*
116 * We don't know if the memory that we're going to allocate will be freeable
117 * or/and it will be released eventually, so to avoid totally wasting several
118 * GB of ram we must reserve some of the lower zone memory (otherwise we risk
119 * to run OOM on the lower zones despite there's tons of freeable ram
120 * on the higher zones). This array is recalculated at runtime if the
121 * sysctl_lowmem_reserve_ratio sysctl changes.
122 */
123 unsigned long lowmem_reserve[MAX_NR_ZONES];
124
125 struct per_cpu_pageset pageset[NR_CPUS];
126
127 /*
128 * free areas of different sizes
129 */
130 spinlock_t lock;
131 struct free_area free_area[MAX_ORDER];
132
133
134 ZONE_PADDING(_pad1_)
135
136 /* Fields commonly accessed by the page reclaim scanner */
137 spinlock_t lru_lock;
138 struct list_head active_list;
139 struct list_head inactive_list;
140 unsigned long nr_scan_active;
141 unsigned long nr_scan_inactive;
142 unsigned long nr_active;
143 unsigned long nr_inactive;
144 unsigned long pages_scanned; /* since last reclaim */
145 int all_unreclaimable; /* All pages pinned */
146
147 /*
148 * prev_priority holds the scanning priority for this zone. It is
149 * defined as the scanning priority at which we achieved our reclaim
150 * target at the previous try_to_free_pages() or balance_pgdat()
151 * invokation.
152 *
153 * We use prev_priority as a measure of how much stress page reclaim is
154 * under - it drives the swappiness decision: whether to unmap mapped
155 * pages.
156 *
157 * temp_priority is used to remember the scanning priority at which
158 * this zone was successfully refilled to free_pages == pages_high.
159 *
160 * Access to both these fields is quite racy even on uniprocessor. But
161 * it is expected to average out OK.
162 */
163 int temp_priority;
164 int prev_priority;
165
166
167 ZONE_PADDING(_pad2_)
168 /* Rarely used or read-mostly fields */
169
170 /*
171 * wait_table -- the array holding the hash table
172 * wait_table_size -- the size of the hash table array
173 * wait_table_bits -- wait_table_size == (1 << wait_table_bits)
174 *
175 * The purpose of all these is to keep track of the people
176 * waiting for a page to become available and make them
177 * runnable again when possible. The trouble is that this
178 * consumes a lot of space, especially when so few things
179 * wait on pages at a given time. So instead of using
180 * per-page waitqueues, we use a waitqueue hash table.
181 *
182 * The bucket discipline is to sleep on the same queue when
183 * colliding and wake all in that wait queue when removing.
184 * When something wakes, it must check to be sure its page is
185 * truly available, a la thundering herd. The cost of a
186 * collision is great, but given the expected load of the
187 * table, they should be so rare as to be outweighed by the
188 * benefits from the saved space.
189 *
190 * __wait_on_page_locked() and unlock_page() in mm/filemap.c, are the
191 * primary users of these fields, and in mm/page_alloc.c
192 * free_area_init_core() performs the initialization of them.
193 */
194 wait_queue_head_t * wait_table;
195 unsigned long wait_table_size;
196 unsigned long wait_table_bits;
197
198 /*
199 * Discontig memory support fields.
200 */
201 struct pglist_data *zone_pgdat;
202 struct page *zone_mem_map;
203 /* zone_start_pfn == zone_start_paddr >> PAGE_SHIFT */
204 unsigned long zone_start_pfn;
205
206 unsigned long spanned_pages; /* total size, including holes */
207 unsigned long present_pages; /* amount of memory (excluding holes) */
208
209 /*
210 * rarely used fields:
211 */
212 char *name;
213} ____cacheline_maxaligned_in_smp;
214
215
216/*
217 * The "priority" of VM scanning is how much of the queues we will scan in one
218 * go. A value of 12 for DEF_PRIORITY implies that we will scan 1/4096th of the
219 * queues ("queue_length >> 12") during an aging round.
220 */
221#define DEF_PRIORITY 12
222
223/*
224 * One allocation request operates on a zonelist. A zonelist
225 * is a list of zones, the first one is the 'goal' of the
226 * allocation, the other zones are fallback zones, in decreasing
227 * priority.
228 *
229 * Right now a zonelist takes up less than a cacheline. We never
230 * modify it apart from boot-up, and only a few indices are used,
231 * so despite the zonelist table being relatively big, the cache
232 * footprint of this construct is very small.
233 */
234struct zonelist {
235 struct zone *zones[MAX_NUMNODES * MAX_NR_ZONES + 1]; // NULL delimited
236};
237
238
239/*
240 * The pg_data_t structure is used in machines with CONFIG_DISCONTIGMEM
241 * (mostly NUMA machines?) to denote a higher-level memory zone than the
242 * zone denotes.
243 *
244 * On NUMA machines, each NUMA node would have a pg_data_t to describe
245 * it's memory layout.
246 *
247 * Memory statistics and page replacement data structures are maintained on a
248 * per-zone basis.
249 */
250struct bootmem_data;
251typedef struct pglist_data {
252 struct zone node_zones[MAX_NR_ZONES];
253 struct zonelist node_zonelists[GFP_ZONETYPES];
254 int nr_zones;
255 struct page *node_mem_map;
256 struct bootmem_data *bdata;
257 unsigned long node_start_pfn;
258 unsigned long node_present_pages; /* total number of physical pages */
259 unsigned long node_spanned_pages; /* total size of physical page
260 range, including holes */
261 int node_id;
262 struct pglist_data *pgdat_next;
263 wait_queue_head_t kswapd_wait;
264 struct task_struct *kswapd;
265 int kswapd_max_order;
266} pg_data_t;
267
268#define node_present_pages(nid) (NODE_DATA(nid)->node_present_pages)
269#define node_spanned_pages(nid) (NODE_DATA(nid)->node_spanned_pages)
270
271extern struct pglist_data *pgdat_list;
272
273void __get_zone_counts(unsigned long *active, unsigned long *inactive,
274 unsigned long *free, struct pglist_data *pgdat);
275void get_zone_counts(unsigned long *active, unsigned long *inactive,
276 unsigned long *free);
277void build_all_zonelists(void);
278void wakeup_kswapd(struct zone *zone, int order);
279int zone_watermark_ok(struct zone *z, int order, unsigned long mark,
280 int alloc_type, int can_try_harder, int gfp_high);
281
282#ifdef CONFIG_HAVE_MEMORY_PRESENT
283void memory_present(int nid, unsigned long start, unsigned long end);
284#else
285static inline void memory_present(int nid, unsigned long start, unsigned long end) {}
286#endif
287
288#ifdef CONFIG_NEED_NODE_MEMMAP_SIZE
289unsigned long __init node_memmap_size_bytes(int, unsigned long, unsigned long);
290#endif
291
292/*
293 * zone_idx() returns 0 for the ZONE_DMA zone, 1 for the ZONE_NORMAL zone, etc.
294 */
295#define zone_idx(zone) ((zone) - (zone)->zone_pgdat->node_zones)
296
297/**
298 * for_each_pgdat - helper macro to iterate over all nodes
299 * @pgdat - pointer to a pg_data_t variable
300 *
301 * Meant to help with common loops of the form
302 * pgdat = pgdat_list;
303 * while(pgdat) {
304 * ...
305 * pgdat = pgdat->pgdat_next;
306 * }
307 */
308#define for_each_pgdat(pgdat) \
309 for (pgdat = pgdat_list; pgdat; pgdat = pgdat->pgdat_next)
310
311/*
312 * next_zone - helper magic for for_each_zone()
313 * Thanks to William Lee Irwin III for this piece of ingenuity.
314 */
315static inline struct zone *next_zone(struct zone *zone)
316{
317 pg_data_t *pgdat = zone->zone_pgdat;
318
319 if (zone < pgdat->node_zones + MAX_NR_ZONES - 1)
320 zone++;
321 else if (pgdat->pgdat_next) {
322 pgdat = pgdat->pgdat_next;
323 zone = pgdat->node_zones;
324 } else
325 zone = NULL;
326
327 return zone;
328}
329
330/**
331 * for_each_zone - helper macro to iterate over all memory zones
332 * @zone - pointer to struct zone variable
333 *
334 * The user only needs to declare the zone variable, for_each_zone
335 * fills it in. This basically means for_each_zone() is an
336 * easier to read version of this piece of code:
337 *
338 * for (pgdat = pgdat_list; pgdat; pgdat = pgdat->node_next)
339 * for (i = 0; i < MAX_NR_ZONES; ++i) {
340 * struct zone * z = pgdat->node_zones + i;
341 * ...
342 * }
343 * }
344 */
345#define for_each_zone(zone) \
346 for (zone = pgdat_list->node_zones; zone; zone = next_zone(zone))
347
348static inline int is_highmem_idx(int idx)
349{
350 return (idx == ZONE_HIGHMEM);
351}
352
353static inline int is_normal_idx(int idx)
354{
355 return (idx == ZONE_NORMAL);
356}
357/**
358 * is_highmem - helper function to quickly check if a struct zone is a
359 * highmem zone or not. This is an attempt to keep references
360 * to ZONE_{DMA/NORMAL/HIGHMEM/etc} in general code to a minimum.
361 * @zone - pointer to struct zone variable
362 */
363static inline int is_highmem(struct zone *zone)
364{
365 return zone == zone->zone_pgdat->node_zones + ZONE_HIGHMEM;
366}
367
368static inline int is_normal(struct zone *zone)
369{
370 return zone == zone->zone_pgdat->node_zones + ZONE_NORMAL;
371}
372
373/* These two functions are used to setup the per zone pages min values */
374struct ctl_table;
375struct file;
376int min_free_kbytes_sysctl_handler(struct ctl_table *, int, struct file *,
377 void __user *, size_t *, loff_t *);
378extern int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES-1];
379int lowmem_reserve_ratio_sysctl_handler(struct ctl_table *, int, struct file *,
380 void __user *, size_t *, loff_t *);
381
382#include <linux/topology.h>
383/* Returns the number of the current Node. */
384#define numa_node_id() (cpu_to_node(_smp_processor_id()))
385
386#ifndef CONFIG_DISCONTIGMEM
387
388extern struct pglist_data contig_page_data;
389#define NODE_DATA(nid) (&contig_page_data)
390#define NODE_MEM_MAP(nid) mem_map
391#define MAX_NODES_SHIFT 1
392#define pfn_to_nid(pfn) (0)
393
394#else /* CONFIG_DISCONTIGMEM */
395
396#include <asm/mmzone.h>
397
398#if BITS_PER_LONG == 32 || defined(ARCH_HAS_ATOMIC_UNSIGNED)
399/*
400 * with 32 bit page->flags field, we reserve 8 bits for node/zone info.
401 * there are 3 zones (2 bits) and this leaves 8-2=6 bits for nodes.
402 */
403#define MAX_NODES_SHIFT 6
404#elif BITS_PER_LONG == 64
405/*
406 * with 64 bit flags field, there's plenty of room.
407 */
408#define MAX_NODES_SHIFT 10
409#endif
410
411#endif /* !CONFIG_DISCONTIGMEM */
412
413#if NODES_SHIFT > MAX_NODES_SHIFT
414#error NODES_SHIFT > MAX_NODES_SHIFT
415#endif
416
417/* There are currently 3 zones: DMA, Normal & Highmem, thus we need 2 bits */
418#define MAX_ZONES_SHIFT 2
419
420#if ZONES_SHIFT > MAX_ZONES_SHIFT
421#error ZONES_SHIFT > MAX_ZONES_SHIFT
422#endif
423
424#endif /* !__ASSEMBLY__ */
425#endif /* __KERNEL__ */
426#endif /* _LINUX_MMZONE_H */
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
new file mode 100644
index 000000000000..d6eb7b2efc04
--- /dev/null
+++ b/include/linux/mod_devicetable.h
@@ -0,0 +1,178 @@
1/*
2 * Device tables which are exported to userspace via
3 * scripts/table2alias.c. You must keep that file in sync with this
4 * header.
5 */
6
7#ifndef LINUX_MOD_DEVICETABLE_H
8#define LINUX_MOD_DEVICETABLE_H
9
10#ifdef __KERNEL__
11#include <linux/types.h>
12typedef unsigned long kernel_ulong_t;
13#endif
14
15#define PCI_ANY_ID (~0)
16
17struct pci_device_id {
18 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
19 __u32 subvendor, subdevice; /* Subsystem ID's or PCI_ANY_ID */
20 __u32 class, class_mask; /* (class,subclass,prog-if) triplet */
21 kernel_ulong_t driver_data; /* Data private to the driver */
22};
23
24
25#define IEEE1394_MATCH_VENDOR_ID 0x0001
26#define IEEE1394_MATCH_MODEL_ID 0x0002
27#define IEEE1394_MATCH_SPECIFIER_ID 0x0004
28#define IEEE1394_MATCH_VERSION 0x0008
29
30struct ieee1394_device_id {
31 __u32 match_flags;
32 __u32 vendor_id;
33 __u32 model_id;
34 __u32 specifier_id;
35 __u32 version;
36 kernel_ulong_t driver_data;
37};
38
39
40/*
41 * Device table entry for "new style" table-driven USB drivers.
42 * User mode code can read these tables to choose which modules to load.
43 * Declare the table as a MODULE_DEVICE_TABLE.
44 *
45 * A probe() parameter will point to a matching entry from this table.
46 * Use the driver_info field for each match to hold information tied
47 * to that match: device quirks, etc.
48 *
49 * Terminate the driver's table with an all-zeroes entry.
50 * Use the flag values to control which fields are compared.
51 */
52
53/**
54 * struct usb_device_id - identifies USB devices for probing and hotplugging
55 * @match_flags: Bit mask controlling of the other fields are used to match
56 * against new devices. Any field except for driver_info may be used,
57 * although some only make sense in conjunction with other fields.
58 * This is usually set by a USB_DEVICE_*() macro, which sets all
59 * other fields in this structure except for driver_info.
60 * @idVendor: USB vendor ID for a device; numbers are assigned
61 * by the USB forum to its members.
62 * @idProduct: Vendor-assigned product ID.
63 * @bcdDevice_lo: Low end of range of vendor-assigned product version numbers.
64 * This is also used to identify individual product versions, for
65 * a range consisting of a single device.
66 * @bcdDevice_hi: High end of version number range. The range of product
67 * versions is inclusive.
68 * @bDeviceClass: Class of device; numbers are assigned
69 * by the USB forum. Products may choose to implement classes,
70 * or be vendor-specific. Device classes specify behavior of all
71 * the interfaces on a devices.
72 * @bDeviceSubClass: Subclass of device; associated with bDeviceClass.
73 * @bDeviceProtocol: Protocol of device; associated with bDeviceClass.
74 * @bInterfaceClass: Class of interface; numbers are assigned
75 * by the USB forum. Products may choose to implement classes,
76 * or be vendor-specific. Interface classes specify behavior only
77 * of a given interface; other interfaces may support other classes.
78 * @bInterfaceSubClass: Subclass of interface; associated with bInterfaceClass.
79 * @bInterfaceProtocol: Protocol of interface; associated with bInterfaceClass.
80 * @driver_info: Holds information used by the driver. Usually it holds
81 * a pointer to a descriptor understood by the driver, or perhaps
82 * device flags.
83 *
84 * In most cases, drivers will create a table of device IDs by using
85 * USB_DEVICE(), or similar macros designed for that purpose.
86 * They will then export it to userspace using MODULE_DEVICE_TABLE(),
87 * and provide it to the USB core through their usb_driver structure.
88 *
89 * See the usb_match_id() function for information about how matches are
90 * performed. Briefly, you will normally use one of several macros to help
91 * construct these entries. Each entry you provide will either identify
92 * one or more specific products, or will identify a class of products
93 * which have agreed to behave the same. You should put the more specific
94 * matches towards the beginning of your table, so that driver_info can
95 * record quirks of specific products.
96 */
97struct usb_device_id {
98 /* which fields to match against? */
99 __u16 match_flags;
100
101 /* Used for product specific matches; range is inclusive */
102 __u16 idVendor;
103 __u16 idProduct;
104 __u16 bcdDevice_lo;
105 __u16 bcdDevice_hi;
106
107 /* Used for device class matches */
108 __u8 bDeviceClass;
109 __u8 bDeviceSubClass;
110 __u8 bDeviceProtocol;
111
112 /* Used for interface class matches */
113 __u8 bInterfaceClass;
114 __u8 bInterfaceSubClass;
115 __u8 bInterfaceProtocol;
116
117 /* not matched against */
118 kernel_ulong_t driver_info;
119};
120
121/* Some useful macros to use to create struct usb_device_id */
122#define USB_DEVICE_ID_MATCH_VENDOR 0x0001
123#define USB_DEVICE_ID_MATCH_PRODUCT 0x0002
124#define USB_DEVICE_ID_MATCH_DEV_LO 0x0004
125#define USB_DEVICE_ID_MATCH_DEV_HI 0x0008
126#define USB_DEVICE_ID_MATCH_DEV_CLASS 0x0010
127#define USB_DEVICE_ID_MATCH_DEV_SUBCLASS 0x0020
128#define USB_DEVICE_ID_MATCH_DEV_PROTOCOL 0x0040
129#define USB_DEVICE_ID_MATCH_INT_CLASS 0x0080
130#define USB_DEVICE_ID_MATCH_INT_SUBCLASS 0x0100
131#define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
132
133/* s390 CCW devices */
134struct ccw_device_id {
135 __u16 match_flags; /* which fields to match against */
136
137 __u16 cu_type; /* control unit type */
138 __u16 dev_type; /* device type */
139 __u8 cu_model; /* control unit model */
140 __u8 dev_model; /* device model */
141
142 kernel_ulong_t driver_info;
143};
144
145#define CCW_DEVICE_ID_MATCH_CU_TYPE 0x01
146#define CCW_DEVICE_ID_MATCH_CU_MODEL 0x02
147#define CCW_DEVICE_ID_MATCH_DEVICE_TYPE 0x04
148#define CCW_DEVICE_ID_MATCH_DEVICE_MODEL 0x08
149
150
151#define PNP_ID_LEN 8
152#define PNP_MAX_DEVICES 8
153
154struct pnp_device_id {
155 __u8 id[PNP_ID_LEN];
156 kernel_ulong_t driver_data;
157};
158
159struct pnp_card_device_id {
160 __u8 id[PNP_ID_LEN];
161 kernel_ulong_t driver_data;
162 struct {
163 __u8 id[PNP_ID_LEN];
164 } devs[PNP_MAX_DEVICES];
165};
166
167
168#define SERIO_ANY 0xff
169
170struct serio_device_id {
171 __u8 type;
172 __u8 extra;
173 __u8 id;
174 __u8 proto;
175};
176
177
178#endif /* LINUX_MOD_DEVICETABLE_H */
diff --git a/include/linux/module.h b/include/linux/module.h
new file mode 100644
index 000000000000..0e432a0f4aee
--- /dev/null
+++ b/include/linux/module.h
@@ -0,0 +1,570 @@
1#ifndef _LINUX_MODULE_H
2#define _LINUX_MODULE_H
3/*
4 * Dynamic loading of modules into the kernel.
5 *
6 * Rewritten by Richard Henderson <rth@tamu.edu> Dec 1996
7 * Rewritten again by Rusty Russell, 2002
8 */
9#include <linux/config.h>
10#include <linux/sched.h>
11#include <linux/spinlock.h>
12#include <linux/list.h>
13#include <linux/stat.h>
14#include <linux/compiler.h>
15#include <linux/cache.h>
16#include <linux/kmod.h>
17#include <linux/elf.h>
18#include <linux/stringify.h>
19#include <linux/kobject.h>
20#include <linux/moduleparam.h>
21#include <asm/local.h>
22
23#include <asm/module.h>
24
25/* Not Yet Implemented */
26#define MODULE_SUPPORTED_DEVICE(name)
27
28/* v850 toolchain uses a `_' prefix for all user symbols */
29#ifndef MODULE_SYMBOL_PREFIX
30#define MODULE_SYMBOL_PREFIX ""
31#endif
32
33#define MODULE_NAME_LEN (64 - sizeof(unsigned long))
34
35struct kernel_symbol
36{
37 unsigned long value;
38 const char *name;
39};
40
41struct modversion_info
42{
43 unsigned long crc;
44 char name[MODULE_NAME_LEN];
45};
46
47struct module;
48
49struct module_attribute {
50 struct attribute attr;
51 ssize_t (*show)(struct module_attribute *, struct module *, char *);
52 ssize_t (*store)(struct module_attribute *, struct module *,
53 const char *, size_t count);
54};
55
56struct module_kobject
57{
58 struct kobject kobj;
59 struct module *mod;
60};
61
62/* These are either module local, or the kernel's dummy ones. */
63extern int init_module(void);
64extern void cleanup_module(void);
65
66/* Archs provide a method of finding the correct exception table. */
67struct exception_table_entry;
68
69const struct exception_table_entry *
70search_extable(const struct exception_table_entry *first,
71 const struct exception_table_entry *last,
72 unsigned long value);
73void sort_extable(struct exception_table_entry *start,
74 struct exception_table_entry *finish);
75void sort_main_extable(void);
76
77extern struct subsystem module_subsys;
78
79#ifdef MODULE
80#define MODULE_GENERIC_TABLE(gtype,name) \
81extern const struct gtype##_id __mod_##gtype##_table \
82 __attribute__ ((unused, alias(__stringify(name))))
83
84extern struct module __this_module;
85#define THIS_MODULE (&__this_module)
86#else /* !MODULE */
87#define MODULE_GENERIC_TABLE(gtype,name)
88#define THIS_MODULE ((struct module *)0)
89#endif
90
91/* Generic info of form tag = "info" */
92#define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info)
93
94/* For userspace: you can also call me... */
95#define MODULE_ALIAS(_alias) MODULE_INFO(alias, _alias)
96
97/*
98 * The following license idents are currently accepted as indicating free
99 * software modules
100 *
101 * "GPL" [GNU Public License v2 or later]
102 * "GPL v2" [GNU Public License v2]
103 * "GPL and additional rights" [GNU Public License v2 rights and more]
104 * "Dual BSD/GPL" [GNU Public License v2
105 * or BSD license choice]
106 * "Dual MPL/GPL" [GNU Public License v2
107 * or Mozilla license choice]
108 *
109 * The following other idents are available
110 *
111 * "Proprietary" [Non free products]
112 *
113 * There are dual licensed components, but when running with Linux it is the
114 * GPL that is relevant so this is a non issue. Similarly LGPL linked with GPL
115 * is a GPL combined work.
116 *
117 * This exists for several reasons
118 * 1. So modinfo can show license info for users wanting to vet their setup
119 * is free
120 * 2. So the community can ignore bug reports including proprietary modules
121 * 3. So vendors can do likewise based on their own policies
122 */
123#define MODULE_LICENSE(_license) MODULE_INFO(license, _license)
124
125/* Author, ideally of form NAME <EMAIL>[, NAME <EMAIL>]*[ and NAME <EMAIL>] */
126#define MODULE_AUTHOR(_author) MODULE_INFO(author, _author)
127
128/* What your module does. */
129#define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description)
130
131/* One for each parameter, describing how to use it. Some files do
132 multiple of these per line, so can't just use MODULE_INFO. */
133#define MODULE_PARM_DESC(_parm, desc) \
134 __MODULE_INFO(parm, _parm, #_parm ":" desc)
135
136#define MODULE_DEVICE_TABLE(type,name) \
137 MODULE_GENERIC_TABLE(type##_device,name)
138
139/* Version of form [<epoch>:]<version>[-<extra-version>].
140 Or for CVS/RCS ID version, everything but the number is stripped.
141 <epoch>: A (small) unsigned integer which allows you to start versions
142 anew. If not mentioned, it's zero. eg. "2:1.0" is after
143 "1:2.0".
144 <version>: The <version> may contain only alphanumerics and the
145 character `.'. Ordered by numeric sort for numeric parts,
146 ascii sort for ascii parts (as per RPM or DEB algorithm).
147 <extraversion>: Like <version>, but inserted for local
148 customizations, eg "rh3" or "rusty1".
149
150 Using this automatically adds a checksum of the .c files and the
151 local headers in "srcversion".
152*/
153#define MODULE_VERSION(_version) MODULE_INFO(version, _version)
154
155/* Given an address, look for it in the exception tables */
156const struct exception_table_entry *search_exception_tables(unsigned long add);
157
158struct notifier_block;
159
160#ifdef CONFIG_MODULES
161
162/* Get/put a kernel symbol (calls must be symmetric) */
163void *__symbol_get(const char *symbol);
164void *__symbol_get_gpl(const char *symbol);
165#define symbol_get(x) ((typeof(&x))(__symbol_get(MODULE_SYMBOL_PREFIX #x)))
166
167#ifndef __GENKSYMS__
168#ifdef CONFIG_MODVERSIONS
169/* Mark the CRC weak since genksyms apparently decides not to
170 * generate a checksums for some symbols */
171#define __CRC_SYMBOL(sym, sec) \
172 extern void *__crc_##sym __attribute__((weak)); \
173 static const unsigned long __kcrctab_##sym \
174 __attribute_used__ \
175 __attribute__((section("__kcrctab" sec), unused)) \
176 = (unsigned long) &__crc_##sym;
177#else
178#define __CRC_SYMBOL(sym, sec)
179#endif
180
181/* For every exported symbol, place a struct in the __ksymtab section */
182#define __EXPORT_SYMBOL(sym, sec) \
183 __CRC_SYMBOL(sym, sec) \
184 static const char __kstrtab_##sym[] \
185 __attribute__((section("__ksymtab_strings"))) \
186 = MODULE_SYMBOL_PREFIX #sym; \
187 static const struct kernel_symbol __ksymtab_##sym \
188 __attribute_used__ \
189 __attribute__((section("__ksymtab" sec), unused)) \
190 = { (unsigned long)&sym, __kstrtab_##sym }
191
192#define EXPORT_SYMBOL(sym) \
193 __EXPORT_SYMBOL(sym, "")
194
195#define EXPORT_SYMBOL_GPL(sym) \
196 __EXPORT_SYMBOL(sym, "_gpl")
197
198#endif
199
200struct module_ref
201{
202 local_t count;
203} ____cacheline_aligned;
204
205enum module_state
206{
207 MODULE_STATE_LIVE,
208 MODULE_STATE_COMING,
209 MODULE_STATE_GOING,
210};
211
212/* Similar stuff for section attributes. */
213#define MODULE_SECT_NAME_LEN 32
214struct module_sect_attr
215{
216 struct module_attribute mattr;
217 char name[MODULE_SECT_NAME_LEN];
218 unsigned long address;
219};
220
221struct module_sect_attrs
222{
223 struct attribute_group grp;
224 struct module_sect_attr attrs[0];
225};
226
227struct module_param_attrs;
228
229struct module
230{
231 enum module_state state;
232
233 /* Member of list of modules */
234 struct list_head list;
235
236 /* Unique handle for this module */
237 char name[MODULE_NAME_LEN];
238
239 /* Sysfs stuff. */
240 struct module_kobject mkobj;
241 struct module_param_attrs *param_attrs;
242
243 /* Exported symbols */
244 const struct kernel_symbol *syms;
245 unsigned int num_syms;
246 const unsigned long *crcs;
247
248 /* GPL-only exported symbols. */
249 const struct kernel_symbol *gpl_syms;
250 unsigned int num_gpl_syms;
251 const unsigned long *gpl_crcs;
252
253 /* Exception table */
254 unsigned int num_exentries;
255 const struct exception_table_entry *extable;
256
257 /* Startup function. */
258 int (*init)(void);
259
260 /* If this is non-NULL, vfree after init() returns */
261 void *module_init;
262
263 /* Here is the actual code + data, vfree'd on unload. */
264 void *module_core;
265
266 /* Here are the sizes of the init and core sections */
267 unsigned long init_size, core_size;
268
269 /* The size of the executable code in each section. */
270 unsigned long init_text_size, core_text_size;
271
272 /* Arch-specific module values */
273 struct mod_arch_specific arch;
274
275 /* Am I unsafe to unload? */
276 int unsafe;
277
278 /* Am I GPL-compatible */
279 int license_gplok;
280
281#ifdef CONFIG_MODULE_UNLOAD
282 /* Reference counts */
283 struct module_ref ref[NR_CPUS];
284
285 /* What modules depend on me? */
286 struct list_head modules_which_use_me;
287
288 /* Who is waiting for us to be unloaded */
289 struct task_struct *waiter;
290
291 /* Destruction function. */
292 void (*exit)(void);
293#endif
294
295#ifdef CONFIG_KALLSYMS
296 /* We keep the symbol and string tables for kallsyms. */
297 Elf_Sym *symtab;
298 unsigned long num_symtab;
299 char *strtab;
300
301 /* Section attributes */
302 struct module_sect_attrs *sect_attrs;
303#endif
304
305 /* Per-cpu data. */
306 void *percpu;
307
308 /* The command line arguments (may be mangled). People like
309 keeping pointers to this stuff */
310 char *args;
311};
312
313/* FIXME: It'd be nice to isolate modules during init, too, so they
314 aren't used before they (may) fail. But presently too much code
315 (IDE & SCSI) require entry into the module during init.*/
316static inline int module_is_live(struct module *mod)
317{
318 return mod->state != MODULE_STATE_GOING;
319}
320
321/* Is this address in a module? (second is with no locks, for oops) */
322struct module *module_text_address(unsigned long addr);
323struct module *__module_text_address(unsigned long addr);
324
325/* Returns module and fills in value, defined and namebuf, or NULL if
326 symnum out of range. */
327struct module *module_get_kallsym(unsigned int symnum,
328 unsigned long *value,
329 char *type,
330 char namebuf[128]);
331
332/* Look for this name: can be of form module:name. */
333unsigned long module_kallsyms_lookup_name(const char *name);
334
335int is_exported(const char *name, const struct module *mod);
336
337extern void __module_put_and_exit(struct module *mod, long code)
338 __attribute__((noreturn));
339#define module_put_and_exit(code) __module_put_and_exit(THIS_MODULE, code);
340
341#ifdef CONFIG_MODULE_UNLOAD
342unsigned int module_refcount(struct module *mod);
343void __symbol_put(const char *symbol);
344#define symbol_put(x) __symbol_put(MODULE_SYMBOL_PREFIX #x)
345void symbol_put_addr(void *addr);
346
347/* Sometimes we know we already have a refcount, and it's easier not
348 to handle the error case (which only happens with rmmod --wait). */
349static inline void __module_get(struct module *module)
350{
351 if (module) {
352 BUG_ON(module_refcount(module) == 0);
353 local_inc(&module->ref[get_cpu()].count);
354 put_cpu();
355 }
356}
357
358static inline int try_module_get(struct module *module)
359{
360 int ret = 1;
361
362 if (module) {
363 unsigned int cpu = get_cpu();
364 if (likely(module_is_live(module)))
365 local_inc(&module->ref[cpu].count);
366 else
367 ret = 0;
368 put_cpu();
369 }
370 return ret;
371}
372
373static inline void module_put(struct module *module)
374{
375 if (module) {
376 unsigned int cpu = get_cpu();
377 local_dec(&module->ref[cpu].count);
378 /* Maybe they're waiting for us to drop reference? */
379 if (unlikely(!module_is_live(module)))
380 wake_up_process(module->waiter);
381 put_cpu();
382 }
383}
384
385#else /*!CONFIG_MODULE_UNLOAD*/
386static inline int try_module_get(struct module *module)
387{
388 return !module || module_is_live(module);
389}
390static inline void module_put(struct module *module)
391{
392}
393static inline void __module_get(struct module *module)
394{
395}
396#define symbol_put(x) do { } while(0)
397#define symbol_put_addr(p) do { } while(0)
398
399#endif /* CONFIG_MODULE_UNLOAD */
400
401/* This is a #define so the string doesn't get put in every .o file */
402#define module_name(mod) \
403({ \
404 struct module *__mod = (mod); \
405 __mod ? __mod->name : "kernel"; \
406})
407
408#define __unsafe(mod) \
409do { \
410 if (mod && !(mod)->unsafe) { \
411 printk(KERN_WARNING \
412 "Module %s cannot be unloaded due to unsafe usage in" \
413 " %s:%u\n", (mod)->name, __FILE__, __LINE__); \
414 (mod)->unsafe = 1; \
415 } \
416} while(0)
417
418/* For kallsyms to ask for address resolution. NULL means not found. */
419const char *module_address_lookup(unsigned long addr,
420 unsigned long *symbolsize,
421 unsigned long *offset,
422 char **modname);
423
424/* For extable.c to search modules' exception tables. */
425const struct exception_table_entry *search_module_extables(unsigned long addr);
426
427int register_module_notifier(struct notifier_block * nb);
428int unregister_module_notifier(struct notifier_block * nb);
429
430extern void print_modules(void);
431
432struct device_driver;
433void module_add_driver(struct module *, struct device_driver *);
434void module_remove_driver(struct device_driver *);
435
436#else /* !CONFIG_MODULES... */
437#define EXPORT_SYMBOL(sym)
438#define EXPORT_SYMBOL_GPL(sym)
439
440/* Given an address, look for it in the exception tables. */
441static inline const struct exception_table_entry *
442search_module_extables(unsigned long addr)
443{
444 return NULL;
445}
446
447/* Is this address in a module? */
448static inline struct module *module_text_address(unsigned long addr)
449{
450 return NULL;
451}
452
453/* Is this address in a module? (don't take a lock, we're oopsing) */
454static inline struct module *__module_text_address(unsigned long addr)
455{
456 return NULL;
457}
458
459/* Get/put a kernel symbol (calls should be symmetric) */
460#define symbol_get(x) ({ extern typeof(x) x __attribute__((weak)); &(x); })
461#define symbol_put(x) do { } while(0)
462#define symbol_put_addr(x) do { } while(0)
463
464static inline void __module_get(struct module *module)
465{
466}
467
468static inline int try_module_get(struct module *module)
469{
470 return 1;
471}
472
473static inline void module_put(struct module *module)
474{
475}
476
477#define module_name(mod) "kernel"
478
479#define __unsafe(mod)
480
481/* For kallsyms to ask for address resolution. NULL means not found. */
482static inline const char *module_address_lookup(unsigned long addr,
483 unsigned long *symbolsize,
484 unsigned long *offset,
485 char **modname)
486{
487 return NULL;
488}
489
490static inline struct module *module_get_kallsym(unsigned int symnum,
491 unsigned long *value,
492 char *type,
493 char namebuf[128])
494{
495 return NULL;
496}
497
498static inline unsigned long module_kallsyms_lookup_name(const char *name)
499{
500 return 0;
501}
502
503static inline int is_exported(const char *name, const struct module *mod)
504{
505 return 0;
506}
507
508static inline int register_module_notifier(struct notifier_block * nb)
509{
510 /* no events will happen anyway, so this can always succeed */
511 return 0;
512}
513
514static inline int unregister_module_notifier(struct notifier_block * nb)
515{
516 return 0;
517}
518
519#define module_put_and_exit(code) do_exit(code)
520
521static inline void print_modules(void)
522{
523}
524
525struct device_driver;
526struct module;
527
528static inline void module_add_driver(struct module *module, struct device_driver *driver)
529{
530}
531
532static inline void module_remove_driver(struct device_driver *driver)
533{
534}
535
536#endif /* CONFIG_MODULES */
537
538#define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x)
539
540/* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */
541
542struct obsolete_modparm {
543 char name[64];
544 char type[64-sizeof(void *)];
545 void *addr;
546};
547
548static inline void MODULE_PARM_(void) { }
549#ifdef MODULE
550/* DEPRECATED: Do not use. */
551#define MODULE_PARM(var,type) \
552struct obsolete_modparm __parm_##var __attribute__((section("__obsparm"))) = \
553{ __stringify(var), type, &MODULE_PARM_ }; \
554__MODULE_PARM_TYPE(var, type);
555#else
556#define MODULE_PARM(var,type) static void __attribute__((__unused__)) *__parm_##var = &MODULE_PARM_;
557#endif
558
559#define __MODULE_STRING(x) __stringify(x)
560
561/* Use symbol_get and symbol_put instead. You'll thank me. */
562#define HAVE_INTER_MODULE
563extern void __deprecated inter_module_register(const char *,
564 struct module *, const void *);
565extern void __deprecated inter_module_unregister(const char *);
566extern const void * __deprecated inter_module_get_request(const char *,
567 const char *);
568extern void __deprecated inter_module_put(const char *);
569
570#endif /* _LINUX_MODULE_H */
diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
new file mode 100644
index 000000000000..eb1033957486
--- /dev/null
+++ b/include/linux/moduleloader.h
@@ -0,0 +1,47 @@
1#ifndef _LINUX_MODULELOADER_H
2#define _LINUX_MODULELOADER_H
3/* The stuff needed for archs to support modules. */
4
5#include <linux/module.h>
6#include <linux/elf.h>
7
8/* These must be implemented by the specific architecture */
9
10/* Adjust arch-specific sections. Return 0 on success. */
11int module_frob_arch_sections(Elf_Ehdr *hdr,
12 Elf_Shdr *sechdrs,
13 char *secstrings,
14 struct module *mod);
15
16/* Allocator used for allocating struct module, core sections and init
17 sections. Returns NULL on failure. */
18void *module_alloc(unsigned long size);
19
20/* Free memory returned from module_alloc. */
21void module_free(struct module *mod, void *module_region);
22
23/* Apply the given relocation to the (simplified) ELF. Return -error
24 or 0. */
25int apply_relocate(Elf_Shdr *sechdrs,
26 const char *strtab,
27 unsigned int symindex,
28 unsigned int relsec,
29 struct module *mod);
30
31/* Apply the given add relocation to the (simplified) ELF. Return
32 -error or 0 */
33int apply_relocate_add(Elf_Shdr *sechdrs,
34 const char *strtab,
35 unsigned int symindex,
36 unsigned int relsec,
37 struct module *mod);
38
39/* Any final processing of module before access. Return -error or 0. */
40int module_finalize(const Elf_Ehdr *hdr,
41 const Elf_Shdr *sechdrs,
42 struct module *mod);
43
44/* Any cleanup needed when module leaves. */
45void module_arch_cleanup(struct module *mod);
46
47#endif
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
new file mode 100644
index 000000000000..368ec8e45bd0
--- /dev/null
+++ b/include/linux/moduleparam.h
@@ -0,0 +1,182 @@
1#ifndef _LINUX_MODULE_PARAMS_H
2#define _LINUX_MODULE_PARAMS_H
3/* (C) Copyright 2001, 2002 Rusty Russell IBM Corporation */
4#include <linux/init.h>
5#include <linux/stringify.h>
6#include <linux/kernel.h>
7
8/* You can override this manually, but generally this should match the
9 module name. */
10#ifdef MODULE
11#define MODULE_PARAM_PREFIX /* empty */
12#else
13#define MODULE_PARAM_PREFIX __stringify(KBUILD_MODNAME) "."
14#endif
15
16#ifdef MODULE
17#define ___module_cat(a,b) __mod_ ## a ## b
18#define __module_cat(a,b) ___module_cat(a,b)
19#define __MODULE_INFO(tag, name, info) \
20static const char __module_cat(name,__LINE__)[] \
21 __attribute_used__ \
22 __attribute__((section(".modinfo"),unused)) = __stringify(tag) "=" info
23#else /* !MODULE */
24#define __MODULE_INFO(tag, name, info)
25#endif
26#define __MODULE_PARM_TYPE(name, _type) \
27 __MODULE_INFO(parmtype, name##type, #name ":" _type)
28
29struct kernel_param;
30
31/* Returns 0, or -errno. arg is in kp->arg. */
32typedef int (*param_set_fn)(const char *val, struct kernel_param *kp);
33/* Returns length written or -errno. Buffer is 4k (ie. be short!) */
34typedef int (*param_get_fn)(char *buffer, struct kernel_param *kp);
35
36struct kernel_param {
37 const char *name;
38 unsigned int perm;
39 param_set_fn set;
40 param_get_fn get;
41 void *arg;
42};
43
44/* Special one for strings we want to copy into */
45struct kparam_string {
46 unsigned int maxlen;
47 char *string;
48};
49
50/* Special one for arrays */
51struct kparam_array
52{
53 unsigned int max;
54 unsigned int *num;
55 param_set_fn set;
56 param_get_fn get;
57 unsigned int elemsize;
58 void *elem;
59};
60
61/* This is the fundamental function for registering boot/module
62 parameters. perm sets the visibility in driverfs: 000 means it's
63 not there, read bits mean it's readable, write bits mean it's
64 writable. */
65#define __module_param_call(prefix, name, set, get, arg, perm) \
66 static char __param_str_##name[] = prefix #name; \
67 static struct kernel_param const __param_##name \
68 __attribute_used__ \
69 __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \
70 = { __param_str_##name, perm, set, get, arg }
71
72#define module_param_call(name, set, get, arg, perm) \
73 __module_param_call(MODULE_PARAM_PREFIX, name, set, get, arg, perm)
74
75/* Helper functions: type is byte, short, ushort, int, uint, long,
76 ulong, charp, bool or invbool, or XXX if you define param_get_XXX,
77 param_set_XXX and param_check_XXX. */
78#define module_param_named(name, value, type, perm) \
79 param_check_##type(name, &(value)); \
80 module_param_call(name, param_set_##type, param_get_##type, &value, perm); \
81 __MODULE_PARM_TYPE(name, #type)
82
83#define module_param(name, type, perm) \
84 module_param_named(name, name, type, perm)
85
86/* Actually copy string: maxlen param is usually sizeof(string). */
87#define module_param_string(name, string, len, perm) \
88 static struct kparam_string __param_string_##name \
89 = { len, string }; \
90 module_param_call(name, param_set_copystring, param_get_string, \
91 &__param_string_##name, perm); \
92 __MODULE_PARM_TYPE(name, "string")
93
94/* Called on module insert or kernel boot */
95extern int parse_args(const char *name,
96 char *args,
97 struct kernel_param *params,
98 unsigned num,
99 int (*unknown)(char *param, char *val));
100
101/* All the helper functions */
102/* The macros to do compile-time type checking stolen from Jakub
103 Jelinek, who IIRC came up with this idea for the 2.4 module init code. */
104#define __param_check(name, p, type) \
105 static inline type *__check_##name(void) { return(p); }
106
107extern int param_set_byte(const char *val, struct kernel_param *kp);
108extern int param_get_byte(char *buffer, struct kernel_param *kp);
109#define param_check_byte(name, p) __param_check(name, p, unsigned char)
110
111extern int param_set_short(const char *val, struct kernel_param *kp);
112extern int param_get_short(char *buffer, struct kernel_param *kp);
113#define param_check_short(name, p) __param_check(name, p, short)
114
115extern int param_set_ushort(const char *val, struct kernel_param *kp);
116extern int param_get_ushort(char *buffer, struct kernel_param *kp);
117#define param_check_ushort(name, p) __param_check(name, p, unsigned short)
118
119extern int param_set_int(const char *val, struct kernel_param *kp);
120extern int param_get_int(char *buffer, struct kernel_param *kp);
121#define param_check_int(name, p) __param_check(name, p, int)
122
123extern int param_set_uint(const char *val, struct kernel_param *kp);
124extern int param_get_uint(char *buffer, struct kernel_param *kp);
125#define param_check_uint(name, p) __param_check(name, p, unsigned int)
126
127extern int param_set_long(const char *val, struct kernel_param *kp);
128extern int param_get_long(char *buffer, struct kernel_param *kp);
129#define param_check_long(name, p) __param_check(name, p, long)
130
131extern int param_set_ulong(const char *val, struct kernel_param *kp);
132extern int param_get_ulong(char *buffer, struct kernel_param *kp);
133#define param_check_ulong(name, p) __param_check(name, p, unsigned long)
134
135extern int param_set_charp(const char *val, struct kernel_param *kp);
136extern int param_get_charp(char *buffer, struct kernel_param *kp);
137#define param_check_charp(name, p) __param_check(name, p, char *)
138
139extern int param_set_bool(const char *val, struct kernel_param *kp);
140extern int param_get_bool(char *buffer, struct kernel_param *kp);
141#define param_check_bool(name, p) __param_check(name, p, int)
142
143extern int param_set_invbool(const char *val, struct kernel_param *kp);
144extern int param_get_invbool(char *buffer, struct kernel_param *kp);
145#define param_check_invbool(name, p) __param_check(name, p, int)
146
147/* Comma-separated array: *nump is set to number they actually specified. */
148#define module_param_array_named(name, array, type, nump, perm) \
149 static struct kparam_array __param_arr_##name \
150 = { ARRAY_SIZE(array), nump, param_set_##type, param_get_##type,\
151 sizeof(array[0]), array }; \
152 module_param_call(name, param_array_set, param_array_get, \
153 &__param_arr_##name, perm); \
154 __MODULE_PARM_TYPE(name, "array of " #type)
155
156#define module_param_array(name, type, nump, perm) \
157 module_param_array_named(name, name, type, nump, perm)
158
159extern int param_array_set(const char *val, struct kernel_param *kp);
160extern int param_array_get(char *buffer, struct kernel_param *kp);
161
162extern int param_set_copystring(const char *val, struct kernel_param *kp);
163extern int param_get_string(char *buffer, struct kernel_param *kp);
164
165int param_array(const char *name,
166 const char *val,
167 unsigned int min, unsigned int max,
168 void *elem, int elemsize,
169 int (*set)(const char *, struct kernel_param *kp),
170 int *num);
171
172/* for exporting parameters in /sys/parameters */
173
174struct module;
175
176extern int module_param_sysfs_setup(struct module *mod,
177 struct kernel_param *kparam,
178 unsigned int num_params);
179
180extern void module_param_sysfs_remove(struct module *mod);
181
182#endif /* _LINUX_MODULE_PARAMS_H */
diff --git a/include/linux/mount.h b/include/linux/mount.h
new file mode 100644
index 000000000000..8b8d3b9beefd
--- /dev/null
+++ b/include/linux/mount.h
@@ -0,0 +1,81 @@
1/*
2 *
3 * Definitions for mount interface. This describes the in the kernel build
4 * linkedlist with mounted filesystems.
5 *
6 * Author: Marco van Wieringen <mvw@planets.elm.net>
7 *
8 * Version: $Id: mount.h,v 2.0 1996/11/17 16:48:14 mvw Exp mvw $
9 *
10 */
11#ifndef _LINUX_MOUNT_H
12#define _LINUX_MOUNT_H
13#ifdef __KERNEL__
14
15#include <linux/list.h>
16#include <linux/spinlock.h>
17#include <asm/atomic.h>
18
19#define MNT_NOSUID 1
20#define MNT_NODEV 2
21#define MNT_NOEXEC 4
22
23struct vfsmount
24{
25 struct list_head mnt_hash;
26 struct vfsmount *mnt_parent; /* fs we are mounted on */
27 struct dentry *mnt_mountpoint; /* dentry of mountpoint */
28 struct dentry *mnt_root; /* root of the mounted tree */
29 struct super_block *mnt_sb; /* pointer to superblock */
30 struct list_head mnt_mounts; /* list of children, anchored here */
31 struct list_head mnt_child; /* and going through their mnt_child */
32 atomic_t mnt_count;
33 int mnt_flags;
34 int mnt_expiry_mark; /* true if marked for expiry */
35 char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */
36 struct list_head mnt_list;
37 struct list_head mnt_fslink; /* link in fs-specific expiry list */
38 struct namespace *mnt_namespace; /* containing namespace */
39};
40
41static inline struct vfsmount *mntget(struct vfsmount *mnt)
42{
43 if (mnt)
44 atomic_inc(&mnt->mnt_count);
45 return mnt;
46}
47
48extern void __mntput(struct vfsmount *mnt);
49
50static inline void _mntput(struct vfsmount *mnt)
51{
52 if (mnt) {
53 if (atomic_dec_and_test(&mnt->mnt_count))
54 __mntput(mnt);
55 }
56}
57
58static inline void mntput(struct vfsmount *mnt)
59{
60 if (mnt) {
61 mnt->mnt_expiry_mark = 0;
62 _mntput(mnt);
63 }
64}
65
66extern void free_vfsmnt(struct vfsmount *mnt);
67extern struct vfsmount *alloc_vfsmnt(const char *name);
68extern struct vfsmount *do_kern_mount(const char *fstype, int flags,
69 const char *name, void *data);
70
71struct nameidata;
72
73extern int do_add_mount(struct vfsmount *newmnt, struct nameidata *nd,
74 int mnt_flags, struct list_head *fslist);
75
76extern void mark_mounts_for_expiry(struct list_head *mounts);
77
78extern spinlock_t vfsmount_lock;
79
80#endif
81#endif /* _LINUX_MOUNT_H */
diff --git a/include/linux/mpage.h b/include/linux/mpage.h
new file mode 100644
index 000000000000..dea1b0083661
--- /dev/null
+++ b/include/linux/mpage.h
@@ -0,0 +1,31 @@
1/*
2 * include/linux/mpage.h
3 *
4 * Contains declarations related to preparing and submitting BIOS which contain
5 * multiple pagecache pages.
6 */
7
8/*
9 * (And no, it doesn't do the #ifdef __MPAGE_H thing, and it doesn't do
10 * nested includes. Get it right in the .c file).
11 */
12
13struct writeback_control;
14typedef int (writepage_t)(struct page *page, struct writeback_control *wbc);
15
16int mpage_readpages(struct address_space *mapping, struct list_head *pages,
17 unsigned nr_pages, get_block_t get_block);
18int mpage_readpage(struct page *page, get_block_t get_block);
19int mpage_writepages(struct address_space *mapping,
20 struct writeback_control *wbc, get_block_t get_block);
21int mpage_writepage(struct page *page, get_block_t *get_block,
22 struct writeback_control *wbc);
23int __mpage_writepages(struct address_space *mapping,
24 struct writeback_control *wbc, get_block_t get_block,
25 writepage_t writepage);
26
27static inline int
28generic_writepages(struct address_space *mapping, struct writeback_control *wbc)
29{
30 return mpage_writepages(mapping, wbc, NULL);
31}
diff --git a/include/linux/mqueue.h b/include/linux/mqueue.h
new file mode 100644
index 000000000000..8db9d75541a6
--- /dev/null
+++ b/include/linux/mqueue.h
@@ -0,0 +1,55 @@
1/* Copyright (C) 2003 Krzysztof Benedyczak & Michal Wronski
2
3 This program is free software; you can redistribute it and/or
4 modify it under the terms of the GNU Lesser General Public
5 License as published by the Free Software Foundation; either
6 version 2.1 of the License, or (at your option) any later version.
7
8 It is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Lesser General Public License for more details.
12
13 You should have received a copy of the GNU Lesser General Public
14 License along with this software; if not, write to the Free
15 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
16 02111-1307 USA. */
17
18#ifndef _LINUX_MQUEUE_H
19#define _LINUX_MQUEUE_H
20
21#include <linux/types.h>
22
23#define MQ_PRIO_MAX 32768
24/* per-uid limit of kernel memory used by mqueue, in bytes */
25#define MQ_BYTES_MAX 819200
26
27struct mq_attr {
28 long mq_flags; /* message queue flags */
29 long mq_maxmsg; /* maximum number of messages */
30 long mq_msgsize; /* maximum message size */
31 long mq_curmsgs; /* number of messages currently queued */
32 long __reserved[4]; /* ignored for input, zeroed for output */
33};
34
35/*
36 * SIGEV_THREAD implementation:
37 * SIGEV_THREAD must be implemented in user space. If SIGEV_THREAD is passed
38 * to mq_notify, then
39 * - sigev_signo must be the file descriptor of an AF_NETLINK socket. It's not
40 * necessary that the socket is bound.
41 * - sigev_value.sival_ptr must point to a cookie that is NOTIFY_COOKIE_LEN
42 * bytes long.
43 * If the notification is triggered, then the cookie is sent to the netlink
44 * socket. The last byte of the cookie is replaced with the NOTIFY_?? codes:
45 * NOTIFY_WOKENUP if the notification got triggered, NOTIFY_REMOVED if it was
46 * removed, either due to a close() on the message queue fd or due to a
47 * mq_notify() that removed the notification.
48 */
49#define NOTIFY_NONE 0
50#define NOTIFY_WOKENUP 1
51#define NOTIFY_REMOVED 2
52
53#define NOTIFY_COOKIE_LEN 32
54
55#endif
diff --git a/include/linux/mroute.h b/include/linux/mroute.h
new file mode 100644
index 000000000000..e05d54a90743
--- /dev/null
+++ b/include/linux/mroute.h
@@ -0,0 +1,226 @@
1#ifndef __LINUX_MROUTE_H
2#define __LINUX_MROUTE_H
3
4#include <linux/sockios.h>
5#include <linux/in.h>
6
7/*
8 * Based on the MROUTING 3.5 defines primarily to keep
9 * source compatibility with BSD.
10 *
11 * See the mrouted 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 MRT_BASE 200
19#define MRT_INIT (MRT_BASE) /* Activate the kernel mroute code */
20#define MRT_DONE (MRT_BASE+1) /* Shutdown the kernel mroute */
21#define MRT_ADD_VIF (MRT_BASE+2) /* Add a virtual interface */
22#define MRT_DEL_VIF (MRT_BASE+3) /* Delete a virtual interface */
23#define MRT_ADD_MFC (MRT_BASE+4) /* Add a multicast forwarding entry */
24#define MRT_DEL_MFC (MRT_BASE+5) /* Delete a multicast forwarding entry */
25#define MRT_VERSION (MRT_BASE+6) /* Get the kernel multicast version */
26#define MRT_ASSERT (MRT_BASE+7) /* Activate PIM assert mode */
27#define MRT_PIM (MRT_BASE+8) /* enable PIM code */
28
29#define SIOCGETVIFCNT SIOCPROTOPRIVATE /* IP protocol privates */
30#define SIOCGETSGCNT (SIOCPROTOPRIVATE+1)
31#define SIOCGETRPF (SIOCPROTOPRIVATE+2)
32
33#define MAXVIFS 32
34typedef unsigned long vifbitmap_t; /* User mode code depends on this lot */
35typedef unsigned short vifi_t;
36#define ALL_VIFS ((vifi_t)(-1))
37
38/*
39 * Same idea as select
40 */
41
42#define VIFM_SET(n,m) ((m)|=(1<<(n)))
43#define VIFM_CLR(n,m) ((m)&=~(1<<(n)))
44#define VIFM_ISSET(n,m) ((m)&(1<<(n)))
45#define VIFM_CLRALL(m) ((m)=0)
46#define VIFM_COPY(mfrom,mto) ((mto)=(mfrom))
47#define VIFM_SAME(m1,m2) ((m1)==(m2))
48
49/*
50 * Passed by mrouted for an MRT_ADD_VIF - again we use the
51 * mrouted 3.6 structures for compatibility
52 */
53
54struct vifctl {
55 vifi_t vifc_vifi; /* Index of VIF */
56 unsigned char vifc_flags; /* VIFF_ flags */
57 unsigned char vifc_threshold; /* ttl limit */
58 unsigned int vifc_rate_limit; /* Rate limiter values (NI) */
59 struct in_addr vifc_lcl_addr; /* Our address */
60 struct in_addr vifc_rmt_addr; /* IPIP tunnel addr */
61};
62
63#define VIFF_TUNNEL 0x1 /* IPIP tunnel */
64#define VIFF_SRCRT 0x2 /* NI */
65#define VIFF_REGISTER 0x4 /* register vif */
66
67/*
68 * Cache manipulation structures for mrouted and PIMd
69 */
70
71struct mfcctl
72{
73 struct in_addr mfcc_origin; /* Origin of mcast */
74 struct in_addr mfcc_mcastgrp; /* Group in question */
75 vifi_t mfcc_parent; /* Where it arrived */
76 unsigned char mfcc_ttls[MAXVIFS]; /* Where it is going */
77 unsigned int mfcc_pkt_cnt; /* pkt count for src-grp */
78 unsigned int mfcc_byte_cnt;
79 unsigned int mfcc_wrong_if;
80 int mfcc_expire;
81};
82
83/*
84 * Group count retrieval for mrouted
85 */
86
87struct sioc_sg_req
88{
89 struct in_addr src;
90 struct in_addr grp;
91 unsigned long pktcnt;
92 unsigned long bytecnt;
93 unsigned long wrong_if;
94};
95
96/*
97 * To get vif packet counts
98 */
99
100struct sioc_vif_req
101{
102 vifi_t vifi; /* Which iface */
103 unsigned long icount; /* In packets */
104 unsigned long ocount; /* Out packets */
105 unsigned long ibytes; /* In bytes */
106 unsigned long obytes; /* Out bytes */
107};
108
109/*
110 * This is the format the mroute daemon expects to see IGMP control
111 * data. Magically happens to be like an IP packet as per the original
112 */
113
114struct igmpmsg
115{
116 __u32 unused1,unused2;
117 unsigned char im_msgtype; /* What is this */
118 unsigned char im_mbz; /* Must be zero */
119 unsigned char im_vif; /* Interface (this ought to be a vifi_t!) */
120 unsigned char unused3;
121 struct in_addr im_src,im_dst;
122};
123
124/*
125 * That's all usermode folks
126 */
127
128#ifdef __KERNEL__
129#include <net/sock.h>
130
131extern int ip_mroute_setsockopt(struct sock *, int, char __user *, int);
132extern int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
133extern int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg);
134extern void ip_mr_init(void);
135
136
137struct vif_device
138{
139 struct net_device *dev; /* Device we are using */
140 unsigned long bytes_in,bytes_out;
141 unsigned long pkt_in,pkt_out; /* Statistics */
142 unsigned long rate_limit; /* Traffic shaping (NI) */
143 unsigned char threshold; /* TTL threshold */
144 unsigned short flags; /* Control flags */
145 __u32 local,remote; /* Addresses(remote for tunnels)*/
146 int link; /* Physical interface index */
147};
148
149#define VIFF_STATIC 0x8000
150
151struct mfc_cache
152{
153 struct mfc_cache *next; /* Next entry on cache line */
154 __u32 mfc_mcastgrp; /* Group the entry belongs to */
155 __u32 mfc_origin; /* Source of packet */
156 vifi_t mfc_parent; /* Source interface */
157 int mfc_flags; /* Flags on line */
158
159 union {
160 struct {
161 unsigned long expires;
162 struct sk_buff_head unresolved; /* Unresolved buffers */
163 } unres;
164 struct {
165 unsigned long last_assert;
166 int minvif;
167 int maxvif;
168 unsigned long bytes;
169 unsigned long pkt;
170 unsigned long wrong_if;
171 unsigned char ttls[MAXVIFS]; /* TTL thresholds */
172 } res;
173 } mfc_un;
174};
175
176#define MFC_STATIC 1
177#define MFC_NOTIFY 2
178
179#define MFC_LINES 64
180
181#ifdef __BIG_ENDIAN
182#define MFC_HASH(a,b) ((((a)>>24)^((b)>>26))&(MFC_LINES-1))
183#else
184#define MFC_HASH(a,b) (((a)^((b)>>2))&(MFC_LINES-1))
185#endif
186
187#endif
188
189
190#define MFC_ASSERT_THRESH (3*HZ) /* Maximal freq. of asserts */
191
192/*
193 * Pseudo messages used by mrouted
194 */
195
196#define IGMPMSG_NOCACHE 1 /* Kern cache fill request to mrouted */
197#define IGMPMSG_WRONGVIF 2 /* For PIM assert processing (unused) */
198#define IGMPMSG_WHOLEPKT 3 /* For PIM Register processing */
199
200#ifdef __KERNEL__
201
202#define PIM_V1_VERSION __constant_htonl(0x10000000)
203#define PIM_V1_REGISTER 1
204
205#define PIM_VERSION 2
206#define PIM_REGISTER 1
207
208#define PIM_NULL_REGISTER __constant_htonl(0x40000000)
209
210/* PIMv2 register message header layout (ietf-draft-idmr-pimvsm-v2-00.ps */
211
212struct pimreghdr
213{
214 __u8 type;
215 __u8 reserved;
216 __u16 csum;
217 __u32 flags;
218};
219
220extern int pim_rcv_v1(struct sk_buff *);
221
222struct rtmsg;
223extern int ipmr_get_route(struct sk_buff *skb, struct rtmsg *rtm, int nowait);
224#endif
225
226#endif
diff --git a/include/linux/msdos_fs.h b/include/linux/msdos_fs.h
new file mode 100644
index 000000000000..9a3d27257984
--- /dev/null
+++ b/include/linux/msdos_fs.h
@@ -0,0 +1,412 @@
1#ifndef _LINUX_MSDOS_FS_H
2#define _LINUX_MSDOS_FS_H
3
4/*
5 * The MS-DOS filesystem constants/structures
6 */
7#include <asm/byteorder.h>
8
9#define SECTOR_SIZE 512 /* sector size (bytes) */
10#define SECTOR_BITS 9 /* log2(SECTOR_SIZE) */
11#define MSDOS_DPB (MSDOS_DPS) /* dir entries per block */
12#define MSDOS_DPB_BITS 4 /* log2(MSDOS_DPB) */
13#define MSDOS_DPS (SECTOR_SIZE / sizeof(struct msdos_dir_entry))
14#define MSDOS_DPS_BITS 4 /* log2(MSDOS_DPS) */
15#define CF_LE_W(v) le16_to_cpu(v)
16#define CF_LE_L(v) le32_to_cpu(v)
17#define CT_LE_W(v) cpu_to_le16(v)
18#define CT_LE_L(v) cpu_to_le32(v)
19
20
21#define MSDOS_SUPER_MAGIC 0x4d44 /* MD */
22
23#define MSDOS_ROOT_INO 1 /* == MINIX_ROOT_INO */
24#define MSDOS_DIR_BITS 5 /* log2(sizeof(struct msdos_dir_entry)) */
25
26/* directory limit */
27#define FAT_MAX_DIR_ENTRIES (65536)
28#define FAT_MAX_DIR_SIZE (FAT_MAX_DIR_ENTRIES << MSDOS_DIR_BITS)
29
30#define ATTR_NONE 0 /* no attribute bits */
31#define ATTR_RO 1 /* read-only */
32#define ATTR_HIDDEN 2 /* hidden */
33#define ATTR_SYS 4 /* system */
34#define ATTR_VOLUME 8 /* volume label */
35#define ATTR_DIR 16 /* directory */
36#define ATTR_ARCH 32 /* archived */
37
38/* attribute bits that are copied "as is" */
39#define ATTR_UNUSED (ATTR_VOLUME | ATTR_ARCH | ATTR_SYS | ATTR_HIDDEN)
40/* bits that are used by the Windows 95/Windows NT extended FAT */
41#define ATTR_EXT (ATTR_RO | ATTR_HIDDEN | ATTR_SYS | ATTR_VOLUME)
42
43#define CASE_LOWER_BASE 8 /* base is lower case */
44#define CASE_LOWER_EXT 16 /* extension is lower case */
45
46#define DELETED_FLAG 0xe5 /* marks file as deleted when in name[0] */
47#define IS_FREE(n) (!*(n) || *(n) == DELETED_FLAG)
48
49/* valid file mode bits */
50#define MSDOS_VALID_MODE (S_IFREG | S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO)
51/* Convert attribute bits and a mask to the UNIX mode. */
52#define MSDOS_MKMODE(a, m) (m & (a & ATTR_RO ? S_IRUGO|S_IXUGO : S_IRWXUGO))
53
54#define MSDOS_NAME 11 /* maximum name length */
55#define MSDOS_LONGNAME 256 /* maximum name length */
56#define MSDOS_SLOTS 21 /* max # of slots for short and long names */
57#define MSDOS_DOT ". " /* ".", padded to MSDOS_NAME chars */
58#define MSDOS_DOTDOT ".. " /* "..", padded to MSDOS_NAME chars */
59
60/* media of boot sector */
61#define FAT_VALID_MEDIA(x) ((0xF8 <= (x) && (x) <= 0xFF) || (x) == 0xF0)
62#define FAT_FIRST_ENT(s, x) ((MSDOS_SB(s)->fat_bits == 32 ? 0x0FFFFF00 : \
63 MSDOS_SB(s)->fat_bits == 16 ? 0xFF00 : 0xF00) | (x))
64
65/* start of data cluster's entry (number of reserved clusters) */
66#define FAT_START_ENT 2
67
68/* maximum number of clusters */
69#define MAX_FAT12 0xFF4
70#define MAX_FAT16 0xFFF4
71#define MAX_FAT32 0x0FFFFFF6
72#define MAX_FAT(s) (MSDOS_SB(s)->fat_bits == 32 ? MAX_FAT32 : \
73 MSDOS_SB(s)->fat_bits == 16 ? MAX_FAT16 : MAX_FAT12)
74
75/* bad cluster mark */
76#define BAD_FAT12 0xFF7
77#define BAD_FAT16 0xFFF7
78#define BAD_FAT32 0x0FFFFFF7
79
80/* standard EOF */
81#define EOF_FAT12 0xFFF
82#define EOF_FAT16 0xFFFF
83#define EOF_FAT32 0x0FFFFFFF
84
85#define FAT_ENT_FREE (0)
86#define FAT_ENT_BAD (BAD_FAT32)
87#define FAT_ENT_EOF (EOF_FAT32)
88
89#define FAT_FSINFO_SIG1 0x41615252
90#define FAT_FSINFO_SIG2 0x61417272
91#define IS_FSINFO(x) (le32_to_cpu((x)->signature1) == FAT_FSINFO_SIG1 \
92 && le32_to_cpu((x)->signature2) == FAT_FSINFO_SIG2)
93
94/*
95 * ioctl commands
96 */
97#define VFAT_IOCTL_READDIR_BOTH _IOR('r', 1, struct dirent [2])
98#define VFAT_IOCTL_READDIR_SHORT _IOR('r', 2, struct dirent [2])
99/* <linux/videotext.h> has used 0x72 ('r') in collision, so skip a few */
100#define FAT_IOCTL_GET_ATTRIBUTES _IOR('r', 0x10, __u32)
101#define FAT_IOCTL_SET_ATTRIBUTES _IOW('r', 0x11, __u32)
102
103/*
104 * vfat shortname flags
105 */
106#define VFAT_SFN_DISPLAY_LOWER 0x0001 /* convert to lowercase for display */
107#define VFAT_SFN_DISPLAY_WIN95 0x0002 /* emulate win95 rule for display */
108#define VFAT_SFN_DISPLAY_WINNT 0x0004 /* emulate winnt rule for display */
109#define VFAT_SFN_CREATE_WIN95 0x0100 /* emulate win95 rule for create */
110#define VFAT_SFN_CREATE_WINNT 0x0200 /* emulate winnt rule for create */
111
112struct fat_boot_sector {
113 __u8 ignored[3]; /* Boot strap short or near jump */
114 __u8 system_id[8]; /* Name - can be used to special case
115 partition manager volumes */
116 __u8 sector_size[2]; /* bytes per logical sector */
117 __u8 sec_per_clus; /* sectors/cluster */
118 __le16 reserved; /* reserved sectors */
119 __u8 fats; /* number of FATs */
120 __u8 dir_entries[2]; /* root directory entries */
121 __u8 sectors[2]; /* number of sectors */
122 __u8 media; /* media code */
123 __le16 fat_length; /* sectors/FAT */
124 __le16 secs_track; /* sectors per track */
125 __le16 heads; /* number of heads */
126 __le32 hidden; /* hidden sectors (unused) */
127 __le32 total_sect; /* number of sectors (if sectors == 0) */
128
129 /* The following fields are only used by FAT32 */
130 __le32 fat32_length; /* sectors/FAT */
131 __le16 flags; /* bit 8: fat mirroring, low 4: active fat */
132 __u8 version[2]; /* major, minor filesystem version */
133 __le32 root_cluster; /* first cluster in root directory */
134 __le16 info_sector; /* filesystem info sector */
135 __le16 backup_boot; /* backup boot sector */
136 __le16 reserved2[6]; /* Unused */
137};
138
139struct fat_boot_fsinfo {
140 __le32 signature1; /* 0x41615252L */
141 __le32 reserved1[120]; /* Nothing as far as I can tell */
142 __le32 signature2; /* 0x61417272L */
143 __le32 free_clusters; /* Free cluster count. -1 if unknown */
144 __le32 next_cluster; /* Most recently allocated cluster */
145 __le32 reserved2[4];
146};
147
148struct msdos_dir_entry {
149 __u8 name[8],ext[3]; /* name and extension */
150 __u8 attr; /* attribute bits */
151 __u8 lcase; /* Case for base and extension */
152 __u8 ctime_cs; /* Creation time, centiseconds (0-199) */
153 __le16 ctime; /* Creation time */
154 __le16 cdate; /* Creation date */
155 __le16 adate; /* Last access date */
156 __le16 starthi; /* High 16 bits of cluster in FAT32 */
157 __le16 time,date,start;/* time, date and first cluster */
158 __le32 size; /* file size (in bytes) */
159};
160
161/* Up to 13 characters of the name */
162struct msdos_dir_slot {
163 __u8 id; /* sequence number for slot */
164 __u8 name0_4[10]; /* first 5 characters in name */
165 __u8 attr; /* attribute byte */
166 __u8 reserved; /* always 0 */
167 __u8 alias_checksum; /* checksum for 8.3 alias */
168 __u8 name5_10[12]; /* 6 more characters in name */
169 __le16 start; /* starting cluster number, 0 in long slots */
170 __u8 name11_12[4]; /* last 2 characters in name */
171};
172
173struct fat_slot_info {
174 loff_t i_pos; /* on-disk position of directory entry */
175 loff_t slot_off; /* offset for slot or de start */
176 int nr_slots; /* number of slots + 1(de) in filename */
177 struct msdos_dir_entry *de;
178 struct buffer_head *bh;
179};
180
181#ifdef __KERNEL__
182
183#include <linux/buffer_head.h>
184#include <linux/string.h>
185#include <linux/nls.h>
186#include <linux/fs.h>
187
188struct fat_mount_options {
189 uid_t fs_uid;
190 gid_t fs_gid;
191 unsigned short fs_fmask;
192 unsigned short fs_dmask;
193 unsigned short codepage; /* Codepage for shortname conversions */
194 char *iocharset; /* Charset used for filename input/display */
195 unsigned short shortname; /* flags for shortname display/create rule */
196 unsigned char name_check; /* r = relaxed, n = normal, s = strict */
197 unsigned quiet:1, /* set = fake successful chmods and chowns */
198 showexec:1, /* set = only set x bit for com/exe/bat */
199 sys_immutable:1, /* set = system files are immutable */
200 dotsOK:1, /* set = hidden and system files are named '.filename' */
201 isvfat:1, /* 0=no vfat long filename support, 1=vfat support */
202 utf8:1, /* Use of UTF8 character set (Default) */
203 unicode_xlate:1, /* create escape sequences for unhandled Unicode */
204 numtail:1, /* Does first alias have a numeric '~1' type tail? */
205 atari:1, /* Use Atari GEMDOS variation of MS-DOS fs */
206 nocase:1; /* Does this need case conversion? 0=need case conversion*/
207};
208
209#define FAT_HASH_BITS 8
210#define FAT_HASH_SIZE (1UL << FAT_HASH_BITS)
211#define FAT_HASH_MASK (FAT_HASH_SIZE-1)
212
213/*
214 * MS-DOS file system in-core superblock data
215 */
216struct msdos_sb_info {
217 unsigned short sec_per_clus; /* sectors/cluster */
218 unsigned short cluster_bits; /* log2(cluster_size) */
219 unsigned int cluster_size; /* cluster size */
220 unsigned char fats,fat_bits; /* number of FATs, FAT bits (12 or 16) */
221 unsigned short fat_start;
222 unsigned long fat_length; /* FAT start & length (sec.) */
223 unsigned long dir_start;
224 unsigned short dir_entries; /* root dir start & entries */
225 unsigned long data_start; /* first data sector */
226 unsigned long max_cluster; /* maximum cluster number */
227 unsigned long root_cluster; /* first cluster of the root directory */
228 unsigned long fsinfo_sector; /* sector number of FAT32 fsinfo */
229 struct semaphore fat_lock;
230 unsigned int prev_free; /* previously allocated cluster number */
231 unsigned int free_clusters; /* -1 if undefined */
232 struct fat_mount_options options;
233 struct nls_table *nls_disk; /* Codepage used on disk */
234 struct nls_table *nls_io; /* Charset used for input and display */
235 void *dir_ops; /* Opaque; default directory operations */
236 int dir_per_block; /* dir entries per block */
237 int dir_per_block_bits; /* log2(dir_per_block) */
238
239 int fatent_shift;
240 struct fatent_operations *fatent_ops;
241
242 spinlock_t inode_hash_lock;
243 struct hlist_head inode_hashtable[FAT_HASH_SIZE];
244};
245
246#define FAT_CACHE_VALID 0 /* special case for valid cache */
247
248/*
249 * MS-DOS file system inode data in memory
250 */
251struct msdos_inode_info {
252 spinlock_t cache_lru_lock;
253 struct list_head cache_lru;
254 int nr_caches;
255 /* for avoiding the race between fat_free() and fat_get_cluster() */
256 unsigned int cache_valid_id;
257
258 loff_t mmu_private;
259 int i_start; /* first cluster or 0 */
260 int i_logstart; /* logical first cluster */
261 int i_attrs; /* unused attribute bits */
262 loff_t i_pos; /* on-disk position of directory entry or 0 */
263 struct hlist_node i_fat_hash; /* hash by i_location */
264 struct inode vfs_inode;
265};
266
267static inline struct msdos_sb_info *MSDOS_SB(struct super_block *sb)
268{
269 return sb->s_fs_info;
270}
271
272static inline struct msdos_inode_info *MSDOS_I(struct inode *inode)
273{
274 return container_of(inode, struct msdos_inode_info, vfs_inode);
275}
276
277/* Return the FAT attribute byte for this inode */
278static inline u8 fat_attr(struct inode *inode)
279{
280 return ((inode->i_mode & S_IWUGO) ? ATTR_NONE : ATTR_RO) |
281 (S_ISDIR(inode->i_mode) ? ATTR_DIR : ATTR_NONE) |
282 MSDOS_I(inode)->i_attrs;
283}
284
285static inline sector_t fat_clus_to_blknr(struct msdos_sb_info *sbi, int clus)
286{
287 return ((sector_t)clus - FAT_START_ENT) * sbi->sec_per_clus
288 + sbi->data_start;
289}
290
291static inline void fat16_towchar(wchar_t *dst, const __u8 *src, size_t len)
292{
293#ifdef __BIG_ENDIAN
294 while (len--) {
295 *dst++ = src[0] | (src[1] << 8);
296 src += 2;
297 }
298#else
299 memcpy(dst, src, len * 2);
300#endif
301}
302
303static inline void fatwchar_to16(__u8 *dst, const wchar_t *src, size_t len)
304{
305#ifdef __BIG_ENDIAN
306 while (len--) {
307 dst[0] = *src & 0x00FF;
308 dst[1] = (*src & 0xFF00) >> 8;
309 dst += 2;
310 src++;
311 }
312#else
313 memcpy(dst, src, len * 2);
314#endif
315}
316
317/* fat/cache.c */
318extern void fat_cache_inval_inode(struct inode *inode);
319extern int fat_get_cluster(struct inode *inode, int cluster,
320 int *fclus, int *dclus);
321extern int fat_bmap(struct inode *inode, sector_t sector, sector_t *phys);
322
323/* fat/dir.c */
324extern struct file_operations fat_dir_operations;
325extern int fat_search_long(struct inode *inode, const unsigned char *name,
326 int name_len, struct fat_slot_info *sinfo);
327extern int fat_dir_empty(struct inode *dir);
328extern int fat_subdirs(struct inode *dir);
329extern int fat_scan(struct inode *dir, const unsigned char *name,
330 struct fat_slot_info *sinfo);
331extern int fat_get_dotdot_entry(struct inode *dir, struct buffer_head **bh,
332 struct msdos_dir_entry **de, loff_t *i_pos);
333extern int fat_alloc_new_dir(struct inode *dir, struct timespec *ts);
334extern int fat_add_entries(struct inode *dir, void *slots, int nr_slots,
335 struct fat_slot_info *sinfo);
336extern int fat_remove_entries(struct inode *dir, struct fat_slot_info *sinfo);
337
338/* fat/fatent.c */
339struct fat_entry {
340 int entry;
341 union {
342 u8 *ent12_p[2];
343 __le16 *ent16_p;
344 __le32 *ent32_p;
345 } u;
346 int nr_bhs;
347 struct buffer_head *bhs[2];
348};
349
350static inline void fatent_init(struct fat_entry *fatent)
351{
352 fatent->nr_bhs = 0;
353 fatent->entry = 0;
354 fatent->u.ent32_p = NULL;
355 fatent->bhs[0] = fatent->bhs[1] = NULL;
356}
357
358static inline void fatent_set_entry(struct fat_entry *fatent, int entry)
359{
360 fatent->entry = entry;
361 fatent->u.ent32_p = NULL;
362}
363
364static inline void fatent_brelse(struct fat_entry *fatent)
365{
366 int i;
367 fatent->u.ent32_p = NULL;
368 for (i = 0; i < fatent->nr_bhs; i++)
369 brelse(fatent->bhs[i]);
370 fatent->nr_bhs = 0;
371 fatent->bhs[0] = fatent->bhs[1] = NULL;
372}
373
374extern void fat_ent_access_init(struct super_block *sb);
375extern int fat_ent_read(struct inode *inode, struct fat_entry *fatent,
376 int entry);
377extern int fat_ent_write(struct inode *inode, struct fat_entry *fatent,
378 int new, int wait);
379extern int fat_alloc_clusters(struct inode *inode, int *cluster,
380 int nr_cluster);
381extern int fat_free_clusters(struct inode *inode, int cluster);
382extern int fat_count_free_clusters(struct super_block *sb);
383
384/* fat/file.c */
385extern int fat_generic_ioctl(struct inode *inode, struct file *filp,
386 unsigned int cmd, unsigned long arg);
387extern struct file_operations fat_file_operations;
388extern struct inode_operations fat_file_inode_operations;
389extern int fat_notify_change(struct dentry * dentry, struct iattr * attr);
390extern void fat_truncate(struct inode *inode);
391
392/* fat/inode.c */
393extern void fat_attach(struct inode *inode, loff_t i_pos);
394extern void fat_detach(struct inode *inode);
395extern struct inode *fat_iget(struct super_block *sb, loff_t i_pos);
396extern struct inode *fat_build_inode(struct super_block *sb,
397 struct msdos_dir_entry *de, loff_t i_pos);
398extern int fat_sync_inode(struct inode *inode);
399extern int fat_fill_super(struct super_block *sb, void *data, int silent,
400 struct inode_operations *fs_dir_inode_ops, int isvfat);
401
402/* fat/misc.c */
403extern void fat_fs_panic(struct super_block *s, const char *fmt, ...);
404extern void fat_clusters_flush(struct super_block *sb);
405extern int fat_chain_add(struct inode *inode, int new_dclus, int nr_cluster);
406extern int date_dos2unix(unsigned short time, unsigned short date);
407extern void fat_date_unix2dos(int unix_date, __le16 *time, __le16 *date);
408extern int fat_sync_bhs(struct buffer_head **bhs, int nr_bhs);
409
410#endif /* __KERNEL__ */
411
412#endif
diff --git a/include/linux/msg.h b/include/linux/msg.h
new file mode 100644
index 000000000000..2c4c6aa643ff
--- /dev/null
+++ b/include/linux/msg.h
@@ -0,0 +1,96 @@
1#ifndef _LINUX_MSG_H
2#define _LINUX_MSG_H
3
4#include <linux/ipc.h>
5#include <linux/list.h>
6
7/* ipcs ctl commands */
8#define MSG_STAT 11
9#define MSG_INFO 12
10
11/* msgrcv options */
12#define MSG_NOERROR 010000 /* no error if message is too big */
13#define MSG_EXCEPT 020000 /* recv any msg except of specified type.*/
14
15/* Obsolete, used only for backwards compatibility and libc5 compiles */
16struct msqid_ds {
17 struct ipc_perm msg_perm;
18 struct msg *msg_first; /* first message on queue,unused */
19 struct msg *msg_last; /* last message in queue,unused */
20 __kernel_time_t msg_stime; /* last msgsnd time */
21 __kernel_time_t msg_rtime; /* last msgrcv time */
22 __kernel_time_t msg_ctime; /* last change time */
23 unsigned long msg_lcbytes; /* Reuse junk fields for 32 bit */
24 unsigned long msg_lqbytes; /* ditto */
25 unsigned short msg_cbytes; /* current number of bytes on queue */
26 unsigned short msg_qnum; /* number of messages in queue */
27 unsigned short msg_qbytes; /* max number of bytes on queue */
28 __kernel_ipc_pid_t msg_lspid; /* pid of last msgsnd */
29 __kernel_ipc_pid_t msg_lrpid; /* last receive pid */
30};
31
32/* Include the definition of msqid64_ds */
33#include <asm/msgbuf.h>
34
35/* message buffer for msgsnd and msgrcv calls */
36struct msgbuf {
37 long mtype; /* type of message */
38 char mtext[1]; /* message text */
39};
40
41/* buffer for msgctl calls IPC_INFO, MSG_INFO */
42struct msginfo {
43 int msgpool;
44 int msgmap;
45 int msgmax;
46 int msgmnb;
47 int msgmni;
48 int msgssz;
49 int msgtql;
50 unsigned short msgseg;
51};
52
53#define MSGMNI 16 /* <= IPCMNI */ /* max # of msg queue identifiers */
54#define MSGMAX 8192 /* <= INT_MAX */ /* max size of message (bytes) */
55#define MSGMNB 16384 /* <= INT_MAX */ /* default max size of a message queue */
56
57/* unused */
58#define MSGPOOL (MSGMNI*MSGMNB/1024) /* size in kilobytes of message pool */
59#define MSGTQL MSGMNB /* number of system message headers */
60#define MSGMAP MSGMNB /* number of entries in message map */
61#define MSGSSZ 16 /* message segment size */
62#define __MSGSEG ((MSGPOOL*1024)/ MSGSSZ) /* max no. of segments */
63#define MSGSEG (__MSGSEG <= 0xffff ? __MSGSEG : 0xffff)
64
65#ifdef __KERNEL__
66
67/* one msg_msg structure for each message */
68struct msg_msg {
69 struct list_head m_list;
70 long m_type;
71 int m_ts; /* message text size */
72 struct msg_msgseg* next;
73 void *security;
74 /* the actual message follows immediately */
75};
76
77/* one msq_queue structure for each present queue on the system */
78struct msg_queue {
79 struct kern_ipc_perm q_perm;
80 time_t q_stime; /* last msgsnd time */
81 time_t q_rtime; /* last msgrcv time */
82 time_t q_ctime; /* last change time */
83 unsigned long q_cbytes; /* current number of bytes on queue */
84 unsigned long q_qnum; /* number of messages in queue */
85 unsigned long q_qbytes; /* max number of bytes on queue */
86 pid_t q_lspid; /* pid of last msgsnd */
87 pid_t q_lrpid; /* last receive pid */
88
89 struct list_head q_messages;
90 struct list_head q_receivers;
91 struct list_head q_senders;
92};
93
94#endif /* __KERNEL__ */
95
96#endif /* _LINUX_MSG_H */
diff --git a/include/linux/mtd/blktrans.h b/include/linux/mtd/blktrans.h
new file mode 100644
index 000000000000..4ebc2e5a16e2
--- /dev/null
+++ b/include/linux/mtd/blktrans.h
@@ -0,0 +1,72 @@
1/*
2 * $Id: blktrans.h,v 1.5 2003/06/23 12:00:08 dwmw2 Exp $
3 *
4 * (C) 2003 David Woodhouse <dwmw2@infradead.org>
5 *
6 * Interface to Linux block layer for MTD 'translation layers'.
7 *
8 */
9
10#ifndef __MTD_TRANS_H__
11#define __MTD_TRANS_H__
12
13#include <asm/semaphore.h>
14
15struct hd_geometry;
16struct mtd_info;
17struct mtd_blktrans_ops;
18struct file;
19struct inode;
20
21struct mtd_blktrans_dev {
22 struct mtd_blktrans_ops *tr;
23 struct list_head list;
24 struct mtd_info *mtd;
25 struct semaphore sem;
26 int devnum;
27 int blksize;
28 unsigned long size;
29 int readonly;
30 void *blkcore_priv; /* gendisk in 2.5, devfs_handle in 2.4 */
31};
32
33struct blkcore_priv; /* Differs for 2.4 and 2.5 kernels; private */
34
35struct mtd_blktrans_ops {
36 char *name;
37 int major;
38 int part_bits;
39
40 /* Access functions */
41 int (*readsect)(struct mtd_blktrans_dev *dev,
42 unsigned long block, char *buffer);
43 int (*writesect)(struct mtd_blktrans_dev *dev,
44 unsigned long block, char *buffer);
45
46 /* Block layer ioctls */
47 int (*getgeo)(struct mtd_blktrans_dev *dev, struct hd_geometry *geo);
48 int (*flush)(struct mtd_blktrans_dev *dev);
49
50 /* Called with mtd_table_mutex held; no race with add/remove */
51 int (*open)(struct mtd_blktrans_dev *dev);
52 int (*release)(struct mtd_blktrans_dev *dev);
53
54 /* Called on {de,}registration and on subsequent addition/removal
55 of devices, with mtd_table_mutex held. */
56 void (*add_mtd)(struct mtd_blktrans_ops *tr, struct mtd_info *mtd);
57 void (*remove_dev)(struct mtd_blktrans_dev *dev);
58
59 struct list_head devs;
60 struct list_head list;
61 struct module *owner;
62
63 struct mtd_blkcore_priv *blkcore_priv;
64};
65
66extern int register_mtd_blktrans(struct mtd_blktrans_ops *tr);
67extern int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr);
68extern int add_mtd_blktrans_dev(struct mtd_blktrans_dev *dev);
69extern int del_mtd_blktrans_dev(struct mtd_blktrans_dev *dev);
70
71
72#endif /* __MTD_TRANS_H__ */
diff --git a/include/linux/mtd/cfi.h b/include/linux/mtd/cfi.h
new file mode 100644
index 000000000000..2ed8c585021e
--- /dev/null
+++ b/include/linux/mtd/cfi.h
@@ -0,0 +1,394 @@
1
2/* Common Flash Interface structures
3 * See http://support.intel.com/design/flash/technote/index.htm
4 * $Id: cfi.h,v 1.50 2004/11/20 12:46:51 dwmw2 Exp $
5 */
6
7#ifndef __MTD_CFI_H__
8#define __MTD_CFI_H__
9
10#include <linux/config.h>
11#include <linux/version.h>
12#include <linux/delay.h>
13#include <linux/types.h>
14#include <linux/interrupt.h>
15#include <linux/mtd/flashchip.h>
16#include <linux/mtd/map.h>
17#include <linux/mtd/cfi_endian.h>
18
19#ifdef CONFIG_MTD_CFI_I1
20#define cfi_interleave(cfi) 1
21#define cfi_interleave_is_1(cfi) (cfi_interleave(cfi) == 1)
22#else
23#define cfi_interleave_is_1(cfi) (0)
24#endif
25
26#ifdef CONFIG_MTD_CFI_I2
27# ifdef cfi_interleave
28# undef cfi_interleave
29# define cfi_interleave(cfi) ((cfi)->interleave)
30# else
31# define cfi_interleave(cfi) 2
32# endif
33#define cfi_interleave_is_2(cfi) (cfi_interleave(cfi) == 2)
34#else
35#define cfi_interleave_is_2(cfi) (0)
36#endif
37
38#ifdef CONFIG_MTD_CFI_I4
39# ifdef cfi_interleave
40# undef cfi_interleave
41# define cfi_interleave(cfi) ((cfi)->interleave)
42# else
43# define cfi_interleave(cfi) 4
44# endif
45#define cfi_interleave_is_4(cfi) (cfi_interleave(cfi) == 4)
46#else
47#define cfi_interleave_is_4(cfi) (0)
48#endif
49
50#ifdef CONFIG_MTD_CFI_I8
51# ifdef cfi_interleave
52# undef cfi_interleave
53# define cfi_interleave(cfi) ((cfi)->interleave)
54# else
55# define cfi_interleave(cfi) 8
56# endif
57#define cfi_interleave_is_8(cfi) (cfi_interleave(cfi) == 8)
58#else
59#define cfi_interleave_is_8(cfi) (0)
60#endif
61
62static inline int cfi_interleave_supported(int i)
63{
64 switch (i) {
65#ifdef CONFIG_MTD_CFI_I1
66 case 1:
67#endif
68#ifdef CONFIG_MTD_CFI_I2
69 case 2:
70#endif
71#ifdef CONFIG_MTD_CFI_I4
72 case 4:
73#endif
74#ifdef CONFIG_MTD_CFI_I8
75 case 8:
76#endif
77 return 1;
78
79 default:
80 return 0;
81 }
82}
83
84
85/* NB: these values must represents the number of bytes needed to meet the
86 * device type (x8, x16, x32). Eg. a 32 bit device is 4 x 8 bytes.
87 * These numbers are used in calculations.
88 */
89#define CFI_DEVICETYPE_X8 (8 / 8)
90#define CFI_DEVICETYPE_X16 (16 / 8)
91#define CFI_DEVICETYPE_X32 (32 / 8)
92#define CFI_DEVICETYPE_X64 (64 / 8)
93
94/* NB: We keep these structures in memory in HOST byteorder, except
95 * where individually noted.
96 */
97
98/* Basic Query Structure */
99struct cfi_ident {
100 uint8_t qry[3];
101 uint16_t P_ID;
102 uint16_t P_ADR;
103 uint16_t A_ID;
104 uint16_t A_ADR;
105 uint8_t VccMin;
106 uint8_t VccMax;
107 uint8_t VppMin;
108 uint8_t VppMax;
109 uint8_t WordWriteTimeoutTyp;
110 uint8_t BufWriteTimeoutTyp;
111 uint8_t BlockEraseTimeoutTyp;
112 uint8_t ChipEraseTimeoutTyp;
113 uint8_t WordWriteTimeoutMax;
114 uint8_t BufWriteTimeoutMax;
115 uint8_t BlockEraseTimeoutMax;
116 uint8_t ChipEraseTimeoutMax;
117 uint8_t DevSize;
118 uint16_t InterfaceDesc;
119 uint16_t MaxBufWriteSize;
120 uint8_t NumEraseRegions;
121 uint32_t EraseRegionInfo[0]; /* Not host ordered */
122} __attribute__((packed));
123
124/* Extended Query Structure for both PRI and ALT */
125
126struct cfi_extquery {
127 uint8_t pri[3];
128 uint8_t MajorVersion;
129 uint8_t MinorVersion;
130} __attribute__((packed));
131
132/* Vendor-Specific PRI for Intel/Sharp Extended Command Set (0x0001) */
133
134struct cfi_pri_intelext {
135 uint8_t pri[3];
136 uint8_t MajorVersion;
137 uint8_t MinorVersion;
138 uint32_t FeatureSupport; /* if bit 31 is set then an additional uint32_t feature
139 block follows - FIXME - not currently supported */
140 uint8_t SuspendCmdSupport;
141 uint16_t BlkStatusRegMask;
142 uint8_t VccOptimal;
143 uint8_t VppOptimal;
144 uint8_t NumProtectionFields;
145 uint16_t ProtRegAddr;
146 uint8_t FactProtRegSize;
147 uint8_t UserProtRegSize;
148 uint8_t extra[0];
149} __attribute__((packed));
150
151struct cfi_intelext_blockinfo {
152 uint16_t NumIdentBlocks;
153 uint16_t BlockSize;
154 uint16_t MinBlockEraseCycles;
155 uint8_t BitsPerCell;
156 uint8_t BlockCap;
157} __attribute__((packed));
158
159struct cfi_intelext_regioninfo {
160 uint16_t NumIdentPartitions;
161 uint8_t NumOpAllowed;
162 uint8_t NumOpAllowedSimProgMode;
163 uint8_t NumOpAllowedSimEraMode;
164 uint8_t NumBlockTypes;
165 struct cfi_intelext_blockinfo BlockTypes[1];
166} __attribute__((packed));
167
168/* Vendor-Specific PRI for AMD/Fujitsu Extended Command Set (0x0002) */
169
170struct cfi_pri_amdstd {
171 uint8_t pri[3];
172 uint8_t MajorVersion;
173 uint8_t MinorVersion;
174 uint8_t SiliconRevision; /* bits 1-0: Address Sensitive Unlock */
175 uint8_t EraseSuspend;
176 uint8_t BlkProt;
177 uint8_t TmpBlkUnprotect;
178 uint8_t BlkProtUnprot;
179 uint8_t SimultaneousOps;
180 uint8_t BurstMode;
181 uint8_t PageMode;
182 uint8_t VppMin;
183 uint8_t VppMax;
184 uint8_t TopBottom;
185} __attribute__((packed));
186
187struct cfi_pri_query {
188 uint8_t NumFields;
189 uint32_t ProtField[1]; /* Not host ordered */
190} __attribute__((packed));
191
192struct cfi_bri_query {
193 uint8_t PageModeReadCap;
194 uint8_t NumFields;
195 uint32_t ConfField[1]; /* Not host ordered */
196} __attribute__((packed));
197
198#define P_ID_NONE 0x0000
199#define P_ID_INTEL_EXT 0x0001
200#define P_ID_AMD_STD 0x0002
201#define P_ID_INTEL_STD 0x0003
202#define P_ID_AMD_EXT 0x0004
203#define P_ID_WINBOND 0x0006
204#define P_ID_ST_ADV 0x0020
205#define P_ID_MITSUBISHI_STD 0x0100
206#define P_ID_MITSUBISHI_EXT 0x0101
207#define P_ID_SST_PAGE 0x0102
208#define P_ID_INTEL_PERFORMANCE 0x0200
209#define P_ID_INTEL_DATA 0x0210
210#define P_ID_RESERVED 0xffff
211
212
213#define CFI_MODE_CFI 1
214#define CFI_MODE_JEDEC 0
215
216struct cfi_private {
217 uint16_t cmdset;
218 void *cmdset_priv;
219 int interleave;
220 int device_type;
221 int cfi_mode; /* Are we a JEDEC device pretending to be CFI? */
222 int addr_unlock1;
223 int addr_unlock2;
224 struct mtd_info *(*cmdset_setup)(struct map_info *);
225 struct cfi_ident *cfiq; /* For now only one. We insist that all devs
226 must be of the same type. */
227 int mfr, id;
228 int numchips;
229 unsigned long chipshift; /* Because they're of the same type */
230 const char *im_name; /* inter_module name for cmdset_setup */
231 struct flchip chips[0]; /* per-chip data structure for each chip */
232};
233
234/*
235 * Returns the command address according to the given geometry.
236 */
237static inline uint32_t cfi_build_cmd_addr(uint32_t cmd_ofs, int interleave, int type)
238{
239 return (cmd_ofs * type) * interleave;
240}
241
242/*
243 * Transforms the CFI command for the given geometry (bus width & interleave).
244 * It looks too long to be inline, but in the common case it should almost all
245 * get optimised away.
246 */
247static inline map_word cfi_build_cmd(u_char cmd, struct map_info *map, struct cfi_private *cfi)
248{
249 map_word val = { {0} };
250 int wordwidth, words_per_bus, chip_mode, chips_per_word;
251 unsigned long onecmd;
252 int i;
253
254 /* We do it this way to give the compiler a fighting chance
255 of optimising away all the crap for 'bankwidth' larger than
256 an unsigned long, in the common case where that support is
257 disabled */
258 if (map_bankwidth_is_large(map)) {
259 wordwidth = sizeof(unsigned long);
260 words_per_bus = (map_bankwidth(map)) / wordwidth; // i.e. normally 1
261 } else {
262 wordwidth = map_bankwidth(map);
263 words_per_bus = 1;
264 }
265
266 chip_mode = map_bankwidth(map) / cfi_interleave(cfi);
267 chips_per_word = wordwidth * cfi_interleave(cfi) / map_bankwidth(map);
268
269 /* First, determine what the bit-pattern should be for a single
270 device, according to chip mode and endianness... */
271 switch (chip_mode) {
272 default: BUG();
273 case 1:
274 onecmd = cmd;
275 break;
276 case 2:
277 onecmd = cpu_to_cfi16(cmd);
278 break;
279 case 4:
280 onecmd = cpu_to_cfi32(cmd);
281 break;
282 }
283
284 /* Now replicate it across the size of an unsigned long, or
285 just to the bus width as appropriate */
286 switch (chips_per_word) {
287 default: BUG();
288#if BITS_PER_LONG >= 64
289 case 8:
290 onecmd |= (onecmd << (chip_mode * 32));
291#endif
292 case 4:
293 onecmd |= (onecmd << (chip_mode * 16));
294 case 2:
295 onecmd |= (onecmd << (chip_mode * 8));
296 case 1:
297 ;
298 }
299
300 /* And finally, for the multi-word case, replicate it
301 in all words in the structure */
302 for (i=0; i < words_per_bus; i++) {
303 val.x[i] = onecmd;
304 }
305
306 return val;
307}
308#define CMD(x) cfi_build_cmd((x), map, cfi)
309
310/*
311 * Sends a CFI command to a bank of flash for the given geometry.
312 *
313 * Returns the offset in flash where the command was written.
314 * If prev_val is non-null, it will be set to the value at the command address,
315 * before the command was written.
316 */
317static inline uint32_t cfi_send_gen_cmd(u_char cmd, uint32_t cmd_addr, uint32_t base,
318 struct map_info *map, struct cfi_private *cfi,
319 int type, map_word *prev_val)
320{
321 map_word val;
322 uint32_t addr = base + cfi_build_cmd_addr(cmd_addr, cfi_interleave(cfi), type);
323
324 val = cfi_build_cmd(cmd, map, cfi);
325
326 if (prev_val)
327 *prev_val = map_read(map, addr);
328
329 map_write(map, val, addr);
330
331 return addr - base;
332}
333
334static inline uint8_t cfi_read_query(struct map_info *map, uint32_t addr)
335{
336 map_word val = map_read(map, addr);
337
338 if (map_bankwidth_is_1(map)) {
339 return val.x[0];
340 } else if (map_bankwidth_is_2(map)) {
341 return cfi16_to_cpu(val.x[0]);
342 } else {
343 /* No point in a 64-bit byteswap since that would just be
344 swapping the responses from different chips, and we are
345 only interested in one chip (a representative sample) */
346 return cfi32_to_cpu(val.x[0]);
347 }
348}
349
350static inline void cfi_udelay(int us)
351{
352 if (us >= 1000) {
353 msleep((us+999)/1000);
354 } else {
355 udelay(us);
356 cond_resched();
357 }
358}
359
360static inline void cfi_spin_lock(spinlock_t *mutex)
361{
362 spin_lock_bh(mutex);
363}
364
365static inline void cfi_spin_unlock(spinlock_t *mutex)
366{
367 spin_unlock_bh(mutex);
368}
369
370struct cfi_extquery *cfi_read_pri(struct map_info *map, uint16_t adr, uint16_t size,
371 const char* name);
372struct cfi_fixup {
373 uint16_t mfr;
374 uint16_t id;
375 void (*fixup)(struct mtd_info *mtd, void* param);
376 void* param;
377};
378
379#define CFI_MFR_ANY 0xffff
380#define CFI_ID_ANY 0xffff
381
382#define CFI_MFR_AMD 0x0001
383#define CFI_MFR_ST 0x0020 /* STMicroelectronics */
384
385void cfi_fixup(struct mtd_info *mtd, struct cfi_fixup* fixups);
386
387typedef int (*varsize_frob_t)(struct map_info *map, struct flchip *chip,
388 unsigned long adr, int len, void *thunk);
389
390int cfi_varsize_frob(struct mtd_info *mtd, varsize_frob_t frob,
391 loff_t ofs, size_t len, void *thunk);
392
393
394#endif /* __MTD_CFI_H__ */
diff --git a/include/linux/mtd/cfi_endian.h b/include/linux/mtd/cfi_endian.h
new file mode 100644
index 000000000000..25724f7d3867
--- /dev/null
+++ b/include/linux/mtd/cfi_endian.h
@@ -0,0 +1,57 @@
1/*
2 * $Id: cfi_endian.h,v 1.11 2002/01/30 23:20:48 awozniak Exp $
3 *
4 */
5
6#include <asm/byteorder.h>
7
8#ifndef CONFIG_MTD_CFI_ADV_OPTIONS
9
10#define CFI_HOST_ENDIAN
11
12#else
13
14#ifdef CONFIG_MTD_CFI_NOSWAP
15#define CFI_HOST_ENDIAN
16#endif
17
18#ifdef CONFIG_MTD_CFI_LE_BYTE_SWAP
19#define CFI_LITTLE_ENDIAN
20#endif
21
22#ifdef CONFIG_MTD_CFI_BE_BYTE_SWAP
23#define CFI_BIG_ENDIAN
24#endif
25
26#endif
27
28#if defined(CFI_LITTLE_ENDIAN)
29#define cpu_to_cfi8(x) (x)
30#define cfi8_to_cpu(x) (x)
31#define cpu_to_cfi16(x) cpu_to_le16(x)
32#define cpu_to_cfi32(x) cpu_to_le32(x)
33#define cpu_to_cfi64(x) cpu_to_le64(x)
34#define cfi16_to_cpu(x) le16_to_cpu(x)
35#define cfi32_to_cpu(x) le32_to_cpu(x)
36#define cfi64_to_cpu(x) le64_to_cpu(x)
37#elif defined (CFI_BIG_ENDIAN)
38#define cpu_to_cfi8(x) (x)
39#define cfi8_to_cpu(x) (x)
40#define cpu_to_cfi16(x) cpu_to_be16(x)
41#define cpu_to_cfi32(x) cpu_to_be32(x)
42#define cpu_to_cfi64(x) cpu_to_be64(x)
43#define cfi16_to_cpu(x) be16_to_cpu(x)
44#define cfi32_to_cpu(x) be32_to_cpu(x)
45#define cfi64_to_cpu(x) be64_to_cpu(x)
46#elif defined (CFI_HOST_ENDIAN)
47#define cpu_to_cfi8(x) (x)
48#define cfi8_to_cpu(x) (x)
49#define cpu_to_cfi16(x) (x)
50#define cpu_to_cfi32(x) (x)
51#define cpu_to_cfi64(x) (x)
52#define cfi16_to_cpu(x) (x)
53#define cfi32_to_cpu(x) (x)
54#define cfi64_to_cpu(x) (x)
55#else
56#error No CFI endianness defined
57#endif
diff --git a/include/linux/mtd/compatmac.h b/include/linux/mtd/compatmac.h
new file mode 100644
index 000000000000..7d1300d9bd51
--- /dev/null
+++ b/include/linux/mtd/compatmac.h
@@ -0,0 +1,10 @@
1
2#ifndef __LINUX_MTD_COMPATMAC_H__
3#define __LINUX_MTD_COMPATMAC_H__
4
5/* Nothing to see here. We write 2.5-compatible code and this
6 file makes it all OK in older kernels, but it's empty in _current_
7 kernels. Include guard just to make GCC ignore it in future inclusions
8 anyway... */
9
10#endif /* __LINUX_MTD_COMPATMAC_H__ */
diff --git a/include/linux/mtd/concat.h b/include/linux/mtd/concat.h
new file mode 100644
index 000000000000..ed8dc6755219
--- /dev/null
+++ b/include/linux/mtd/concat.h
@@ -0,0 +1,23 @@
1/*
2 * MTD device concatenation layer definitions
3 *
4 * (C) 2002 Robert Kaiser <rkaiser@sysgo.de>
5 *
6 * This code is GPL
7 *
8 * $Id: concat.h,v 1.1 2002/03/08 16:34:36 rkaiser Exp $
9 */
10
11#ifndef MTD_CONCAT_H
12#define MTD_CONCAT_H
13
14
15struct mtd_info *mtd_concat_create(
16 struct mtd_info *subdev[], /* subdevices to concatenate */
17 int num_devs, /* number of subdevices */
18 char *name); /* name for the new device */
19
20void mtd_concat_destroy(struct mtd_info *mtd);
21
22#endif
23
diff --git a/include/linux/mtd/doc2000.h b/include/linux/mtd/doc2000.h
new file mode 100644
index 000000000000..953e64fb8ac5
--- /dev/null
+++ b/include/linux/mtd/doc2000.h
@@ -0,0 +1,195 @@
1/*
2 * Linux driver for Disk-On-Chip devices
3 *
4 * Copyright (C) 1999 Machine Vision Holdings, Inc.
5 * Copyright (C) 2001-2003 David Woodhouse <dwmw2@infradead.org>
6 * Copyright (C) 2002-2003 Greg Ungerer <gerg@snapgear.com>
7 * Copyright (C) 2002-2003 SnapGear Inc
8 *
9 * $Id: doc2000.h,v 1.24 2005/01/05 12:40:38 dwmw2 Exp $
10 *
11 * Released under GPL
12 */
13
14#ifndef __MTD_DOC2000_H__
15#define __MTD_DOC2000_H__
16
17#include <linux/mtd/mtd.h>
18#include <asm/semaphore.h>
19
20#define DoC_Sig1 0
21#define DoC_Sig2 1
22
23#define DoC_ChipID 0x1000
24#define DoC_DOCStatus 0x1001
25#define DoC_DOCControl 0x1002
26#define DoC_FloorSelect 0x1003
27#define DoC_CDSNControl 0x1004
28#define DoC_CDSNDeviceSelect 0x1005
29#define DoC_ECCConf 0x1006
30#define DoC_2k_ECCStatus 0x1007
31
32#define DoC_CDSNSlowIO 0x100d
33#define DoC_ECCSyndrome0 0x1010
34#define DoC_ECCSyndrome1 0x1011
35#define DoC_ECCSyndrome2 0x1012
36#define DoC_ECCSyndrome3 0x1013
37#define DoC_ECCSyndrome4 0x1014
38#define DoC_ECCSyndrome5 0x1015
39#define DoC_AliasResolution 0x101b
40#define DoC_ConfigInput 0x101c
41#define DoC_ReadPipeInit 0x101d
42#define DoC_WritePipeTerm 0x101e
43#define DoC_LastDataRead 0x101f
44#define DoC_NOP 0x1020
45
46#define DoC_Mil_CDSN_IO 0x0800
47#define DoC_2k_CDSN_IO 0x1800
48
49#define DoC_Mplus_NOP 0x1002
50#define DoC_Mplus_AliasResolution 0x1004
51#define DoC_Mplus_DOCControl 0x1006
52#define DoC_Mplus_AccessStatus 0x1008
53#define DoC_Mplus_DeviceSelect 0x1008
54#define DoC_Mplus_Configuration 0x100a
55#define DoC_Mplus_OutputControl 0x100c
56#define DoC_Mplus_FlashControl 0x1020
57#define DoC_Mplus_FlashSelect 0x1022
58#define DoC_Mplus_FlashCmd 0x1024
59#define DoC_Mplus_FlashAddress 0x1026
60#define DoC_Mplus_FlashData0 0x1028
61#define DoC_Mplus_FlashData1 0x1029
62#define DoC_Mplus_ReadPipeInit 0x102a
63#define DoC_Mplus_LastDataRead 0x102c
64#define DoC_Mplus_LastDataRead1 0x102d
65#define DoC_Mplus_WritePipeTerm 0x102e
66#define DoC_Mplus_ECCSyndrome0 0x1040
67#define DoC_Mplus_ECCSyndrome1 0x1041
68#define DoC_Mplus_ECCSyndrome2 0x1042
69#define DoC_Mplus_ECCSyndrome3 0x1043
70#define DoC_Mplus_ECCSyndrome4 0x1044
71#define DoC_Mplus_ECCSyndrome5 0x1045
72#define DoC_Mplus_ECCConf 0x1046
73#define DoC_Mplus_Toggle 0x1046
74#define DoC_Mplus_DownloadStatus 0x1074
75#define DoC_Mplus_CtrlConfirm 0x1076
76#define DoC_Mplus_Power 0x1fff
77
78/* How to access the device?
79 * On ARM, it'll be mmap'd directly with 32-bit wide accesses.
80 * On PPC, it's mmap'd and 16-bit wide.
81 * Others use readb/writeb
82 */
83#if defined(__arm__)
84#define ReadDOC_(adr, reg) ((unsigned char)(*(volatile __u32 *)(((unsigned long)adr)+((reg)<<2))))
85#define WriteDOC_(d, adr, reg) do{ *(volatile __u32 *)(((unsigned long)adr)+((reg)<<2)) = (__u32)d; wmb();} while(0)
86#define DOC_IOREMAP_LEN 0x8000
87#elif defined(__ppc__)
88#define ReadDOC_(adr, reg) ((unsigned char)(*(volatile __u16 *)(((unsigned long)adr)+((reg)<<1))))
89#define WriteDOC_(d, adr, reg) do{ *(volatile __u16 *)(((unsigned long)adr)+((reg)<<1)) = (__u16)d; wmb();} while(0)
90#define DOC_IOREMAP_LEN 0x4000
91#else
92#define ReadDOC_(adr, reg) readb((void __iomem *)(adr) + (reg))
93#define WriteDOC_(d, adr, reg) writeb(d, (void __iomem *)(adr) + (reg))
94#define DOC_IOREMAP_LEN 0x2000
95
96#endif
97
98#if defined(__i386__) || defined(__x86_64__)
99#define USE_MEMCPY
100#endif
101
102/* These are provided to directly use the DoC_xxx defines */
103#define ReadDOC(adr, reg) ReadDOC_(adr,DoC_##reg)
104#define WriteDOC(d, adr, reg) WriteDOC_(d,adr,DoC_##reg)
105
106#define DOC_MODE_RESET 0
107#define DOC_MODE_NORMAL 1
108#define DOC_MODE_RESERVED1 2
109#define DOC_MODE_RESERVED2 3
110
111#define DOC_MODE_CLR_ERR 0x80
112#define DOC_MODE_RST_LAT 0x10
113#define DOC_MODE_BDECT 0x08
114#define DOC_MODE_MDWREN 0x04
115
116#define DOC_ChipID_Doc2k 0x20
117#define DOC_ChipID_Doc2kTSOP 0x21 /* internal number for MTD */
118#define DOC_ChipID_DocMil 0x30
119#define DOC_ChipID_DocMilPlus32 0x40
120#define DOC_ChipID_DocMilPlus16 0x41
121
122#define CDSN_CTRL_FR_B 0x80
123#define CDSN_CTRL_FR_B0 0x40
124#define CDSN_CTRL_FR_B1 0x80
125
126#define CDSN_CTRL_ECC_IO 0x20
127#define CDSN_CTRL_FLASH_IO 0x10
128#define CDSN_CTRL_WP 0x08
129#define CDSN_CTRL_ALE 0x04
130#define CDSN_CTRL_CLE 0x02
131#define CDSN_CTRL_CE 0x01
132
133#define DOC_ECC_RESET 0
134#define DOC_ECC_ERROR 0x80
135#define DOC_ECC_RW 0x20
136#define DOC_ECC__EN 0x08
137#define DOC_TOGGLE_BIT 0x04
138#define DOC_ECC_RESV 0x02
139#define DOC_ECC_IGNORE 0x01
140
141#define DOC_FLASH_CE 0x80
142#define DOC_FLASH_WP 0x40
143#define DOC_FLASH_BANK 0x02
144
145/* We have to also set the reserved bit 1 for enable */
146#define DOC_ECC_EN (DOC_ECC__EN | DOC_ECC_RESV)
147#define DOC_ECC_DIS (DOC_ECC_RESV)
148
149struct Nand {
150 char floor, chip;
151 unsigned long curadr;
152 unsigned char curmode;
153 /* Also some erase/write/pipeline info when we get that far */
154};
155
156#define MAX_FLOORS 4
157#define MAX_CHIPS 4
158
159#define MAX_FLOORS_MIL 1
160#define MAX_CHIPS_MIL 1
161
162#define MAX_FLOORS_MPLUS 2
163#define MAX_CHIPS_MPLUS 1
164
165#define ADDR_COLUMN 1
166#define ADDR_PAGE 2
167#define ADDR_COLUMN_PAGE 3
168
169struct DiskOnChip {
170 unsigned long physadr;
171 void __iomem *virtadr;
172 unsigned long totlen;
173 unsigned char ChipID; /* Type of DiskOnChip */
174 int ioreg;
175
176 unsigned long mfr; /* Flash IDs - only one type of flash per device */
177 unsigned long id;
178 int chipshift;
179 char page256;
180 char pageadrlen;
181 char interleave; /* Internal interleaving - Millennium Plus style */
182 unsigned long erasesize;
183
184 int curfloor;
185 int curchip;
186
187 int numchips;
188 struct Nand *chips;
189 struct mtd_info *nextdoc;
190 struct semaphore lock;
191};
192
193int doc_decode_ecc(unsigned char sector[512], unsigned char ecc1[6]);
194
195#endif /* __MTD_DOC2000_H__ */
diff --git a/include/linux/mtd/flashchip.h b/include/linux/mtd/flashchip.h
new file mode 100644
index 000000000000..c66ba812bf90
--- /dev/null
+++ b/include/linux/mtd/flashchip.h
@@ -0,0 +1,89 @@
1
2/*
3 * struct flchip definition
4 *
5 * Contains information about the location and state of a given flash device
6 *
7 * (C) 2000 Red Hat. GPLd.
8 *
9 * $Id: flashchip.h,v 1.15 2004/11/05 22:41:06 nico Exp $
10 *
11 */
12
13#ifndef __MTD_FLASHCHIP_H__
14#define __MTD_FLASHCHIP_H__
15
16/* For spinlocks. sched.h includes spinlock.h from whichever directory it
17 * happens to be in - so we don't have to care whether we're on 2.2, which
18 * has asm/spinlock.h, or 2.4, which has linux/spinlock.h
19 */
20#include <linux/sched.h>
21
22typedef enum {
23 FL_READY,
24 FL_STATUS,
25 FL_CFI_QUERY,
26 FL_JEDEC_QUERY,
27 FL_ERASING,
28 FL_ERASE_SUSPENDING,
29 FL_ERASE_SUSPENDED,
30 FL_WRITING,
31 FL_WRITING_TO_BUFFER,
32 FL_WRITE_SUSPENDING,
33 FL_WRITE_SUSPENDED,
34 FL_PM_SUSPENDED,
35 FL_SYNCING,
36 FL_UNLOADING,
37 FL_LOCKING,
38 FL_UNLOCKING,
39 FL_POINT,
40 FL_XIP_WHILE_ERASING,
41 FL_XIP_WHILE_WRITING,
42 FL_UNKNOWN
43} flstate_t;
44
45
46
47/* NOTE: confusingly, this can be used to refer to more than one chip at a time,
48 if they're interleaved. This can even refer to individual partitions on
49 the same physical chip when present. */
50
51struct flchip {
52 unsigned long start; /* Offset within the map */
53 // unsigned long len;
54 /* We omit len for now, because when we group them together
55 we insist that they're all of the same size, and the chip size
56 is held in the next level up. If we get more versatile later,
57 it'll make it a damn sight harder to find which chip we want from
58 a given offset, and we'll want to add the per-chip length field
59 back in.
60 */
61 int ref_point_counter;
62 flstate_t state;
63 flstate_t oldstate;
64
65 int write_suspended:1;
66 int erase_suspended:1;
67 unsigned long in_progress_block_addr;
68
69 spinlock_t *mutex;
70 spinlock_t _spinlock; /* We do it like this because sometimes they'll be shared. */
71 wait_queue_head_t wq; /* Wait on here when we're waiting for the chip
72 to be ready */
73 int word_write_time;
74 int buffer_write_time;
75 int erase_time;
76
77 void *priv;
78};
79
80/* This is used to handle contention on write/erase operations
81 between partitions of the same physical chip. */
82struct flchip_shared {
83 spinlock_t lock;
84 struct flchip *writing;
85 struct flchip *erasing;
86};
87
88
89#endif /* __MTD_FLASHCHIP_H__ */
diff --git a/include/linux/mtd/ftl.h b/include/linux/mtd/ftl.h
new file mode 100644
index 000000000000..3678459b4535
--- /dev/null
+++ b/include/linux/mtd/ftl.h
@@ -0,0 +1,76 @@
1/*
2 * $Id: ftl.h,v 1.6 2003/01/24 13:20:04 dwmw2 Exp $
3 *
4 * Derived from (and probably identical to):
5 * ftl.h 1.7 1999/10/25 20:23:17
6 *
7 * The contents of this file are subject to the Mozilla Public License
8 * Version 1.1 (the "License"); you may not use this file except in
9 * compliance with the License. You may obtain a copy of the License
10 * at http://www.mozilla.org/MPL/
11 *
12 * Software distributed under the License is distributed on an "AS IS"
13 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 * the License for the specific language governing rights and
15 * limitations under the License.
16 *
17 * The initial developer of the original code is David A. Hinds
18 * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
19 * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
20 *
21 * Alternatively, the contents of this file may be used under the
22 * terms of the GNU General Public License version 2 (the "GPL"), in
23 * which case the provisions of the GPL are applicable instead of the
24 * above. If you wish to allow the use of your version of this file
25 * only under the terms of the GPL and not to allow others to use
26 * your version of this file under the MPL, indicate your decision by
27 * deleting the provisions above and replace them with the notice and
28 * other provisions required by the GPL. If you do not delete the
29 * provisions above, a recipient may use your version of this file
30 * under either the MPL or the GPL.
31 */
32
33#ifndef _LINUX_FTL_H
34#define _LINUX_FTL_H
35
36typedef struct erase_unit_header_t {
37 u_int8_t LinkTargetTuple[5];
38 u_int8_t DataOrgTuple[10];
39 u_int8_t NumTransferUnits;
40 u_int32_t EraseCount;
41 u_int16_t LogicalEUN;
42 u_int8_t BlockSize;
43 u_int8_t EraseUnitSize;
44 u_int16_t FirstPhysicalEUN;
45 u_int16_t NumEraseUnits;
46 u_int32_t FormattedSize;
47 u_int32_t FirstVMAddress;
48 u_int16_t NumVMPages;
49 u_int8_t Flags;
50 u_int8_t Code;
51 u_int32_t SerialNumber;
52 u_int32_t AltEUHOffset;
53 u_int32_t BAMOffset;
54 u_int8_t Reserved[12];
55 u_int8_t EndTuple[2];
56} erase_unit_header_t;
57
58/* Flags in erase_unit_header_t */
59#define HIDDEN_AREA 0x01
60#define REVERSE_POLARITY 0x02
61#define DOUBLE_BAI 0x04
62
63/* Definitions for block allocation information */
64
65#define BLOCK_FREE(b) ((b) == 0xffffffff)
66#define BLOCK_DELETED(b) (((b) == 0) || ((b) == 0xfffffffe))
67
68#define BLOCK_TYPE(b) ((b) & 0x7f)
69#define BLOCK_ADDRESS(b) ((b) & ~0x7f)
70#define BLOCK_NUMBER(b) ((b) >> 9)
71#define BLOCK_CONTROL 0x30
72#define BLOCK_DATA 0x40
73#define BLOCK_REPLACEMENT 0x60
74#define BLOCK_BAD 0x70
75
76#endif /* _LINUX_FTL_H */
diff --git a/include/linux/mtd/gen_probe.h b/include/linux/mtd/gen_probe.h
new file mode 100644
index 000000000000..3d7bdec14f97
--- /dev/null
+++ b/include/linux/mtd/gen_probe.h
@@ -0,0 +1,23 @@
1/*
2 * (C) 2001, 2001 Red Hat, Inc.
3 * GPL'd
4 * $Id: gen_probe.h,v 1.3 2004/10/20 22:10:33 dwmw2 Exp $
5 */
6
7#ifndef __LINUX_MTD_GEN_PROBE_H__
8#define __LINUX_MTD_GEN_PROBE_H__
9
10#include <linux/mtd/flashchip.h>
11#include <linux/mtd/map.h>
12#include <linux/mtd/cfi.h>
13#include <linux/bitops.h>
14
15struct chip_probe {
16 char *name;
17 int (*probe_chip)(struct map_info *map, __u32 base,
18 unsigned long *chip_map, struct cfi_private *cfi);
19};
20
21struct mtd_info *mtd_do_chip_probe(struct map_info *map, struct chip_probe *cp);
22
23#endif /* __LINUX_MTD_GEN_PROBE_H__ */
diff --git a/include/linux/mtd/iflash.h b/include/linux/mtd/iflash.h
new file mode 100644
index 000000000000..9aa5b4f02666
--- /dev/null
+++ b/include/linux/mtd/iflash.h
@@ -0,0 +1,98 @@
1/* $Id: iflash.h,v 1.2 2000/11/13 18:01:54 dwmw2 Exp $ */
2
3#ifndef __MTD_IFLASH_H__
4#define __MTD_IFLASH_H__
5
6/* Extended CIS registers for Series 2 and 2+ cards */
7/* The registers are all offsets from 0x4000 */
8#define CISREG_CSR 0x0100
9#define CISREG_WP 0x0104
10#define CISREG_RDYBSY 0x0140
11
12/* Extended CIS registers for Series 2 cards */
13#define CISREG_SLEEP 0x0118
14#define CISREG_RDY_MASK 0x0120
15#define CISREG_RDY_STATUS 0x0130
16
17/* Extended CIS registers for Series 2+ cards */
18#define CISREG_VCR 0x010c
19
20/* Card Status Register */
21#define CSR_SRESET 0x20 /* Soft reset */
22#define CSR_CMWP 0x10 /* Common memory write protect */
23#define CSR_PWRDOWN 0x08 /* Power down status */
24#define CSR_CISWP 0x04 /* Common memory CIS WP */
25#define CSR_WP 0x02 /* Mechanical write protect */
26#define CSR_READY 0x01 /* Ready/busy status */
27
28/* Write Protection Register */
29#define WP_BLKEN 0x04 /* Enable block locking */
30#define WP_CMWP 0x02 /* Common memory write protect */
31#define WP_CISWP 0x01 /* Common memory CIS WP */
32
33/* Voltage Control Register */
34#define VCR_VCC_LEVEL 0x80 /* 0 = 5V, 1 = 3.3V */
35#define VCR_VPP_VALID 0x02 /* Vpp Valid */
36#define VCR_VPP_GEN 0x01 /* Integrated Vpp generator */
37
38/* Ready/Busy Mode Register */
39#define RDYBSY_RACK 0x02 /* Ready acknowledge */
40#define RDYBSY_MODE 0x01 /* 1 = high performance */
41
42#define LOW(x) ((x) & 0xff)
43
44/* 28F008SA-Compatible Command Set */
45#define IF_READ_ARRAY 0xffff
46#define IF_INTEL_ID 0x9090
47#define IF_READ_CSR 0x7070
48#define IF_CLEAR_CSR 0x5050
49#define IF_WRITE 0x4040
50#define IF_BLOCK_ERASE 0x2020
51#define IF_ERASE_SUSPEND 0xb0b0
52#define IF_CONFIRM 0xd0d0
53
54/* 28F016SA Performance Enhancement Commands */
55#define IF_READ_PAGE 0x7575
56#define IF_PAGE_SWAP 0x7272
57#define IF_SINGLE_LOAD 0x7474
58#define IF_SEQ_LOAD 0xe0e0
59#define IF_PAGE_WRITE 0x0c0c
60#define IF_RDY_MODE 0x9696
61#define IF_RDY_LEVEL 0x0101
62#define IF_RDY_PULSE_WRITE 0x0202
63#define IF_RDY_PULSE_ERASE 0x0303
64#define IF_RDY_DISABLE 0x0404
65#define IF_LOCK_BLOCK 0x7777
66#define IF_UPLOAD_STATUS 0x9797
67#define IF_READ_ESR 0x7171
68#define IF_ERASE_UNLOCKED 0xa7a7
69#define IF_SLEEP 0xf0f0
70#define IF_ABORT 0x8080
71#define IF_UPLOAD_DEVINFO 0x9999
72
73/* Definitions for Compatible Status Register */
74#define CSR_WR_READY 0x8080 /* Write state machine status */
75#define CSR_ERA_SUSPEND 0x4040 /* Erase suspend status */
76#define CSR_ERA_ERR 0x2020 /* Erase status */
77#define CSR_WR_ERR 0x1010 /* Data write status */
78#define CSR_VPP_LOW 0x0808 /* Vpp status */
79
80/* Definitions for Global Status Register */
81#define GSR_WR_READY 0x8080 /* Write state machine status */
82#define GSR_OP_SUSPEND 0x4040 /* Operation suspend status */
83#define GSR_OP_ERR 0x2020 /* Device operation status */
84#define GSR_SLEEP 0x1010 /* Device sleep status */
85#define GSR_QUEUE_FULL 0x0808 /* Queue status */
86#define GSR_PAGE_AVAIL 0x0404 /* Page buffer available status */
87#define GSR_PAGE_READY 0x0202 /* Page buffer status */
88#define GSR_PAGE_SELECT 0x0101 /* Page buffer select status */
89
90/* Definitions for Block Status Register */
91#define BSR_READY 0x8080 /* Block status */
92#define BSR_UNLOCK 0x4040 /* Block lock status */
93#define BSR_FAILED 0x2020 /* Block operation status */
94#define BSR_ABORTED 0x1010 /* Operation abort status */
95#define BSR_QUEUE_FULL 0x0808 /* Queue status */
96#define BSR_VPP_LOW 0x0404 /* Vpp status */
97
98#endif /* __MTD_IFLASH_H__ */
diff --git a/include/linux/mtd/inftl.h b/include/linux/mtd/inftl.h
new file mode 100644
index 000000000000..b52c8cbd235c
--- /dev/null
+++ b/include/linux/mtd/inftl.h
@@ -0,0 +1,57 @@
1/*
2 * inftl.h -- defines to support the Inverse NAND Flash Translation Layer
3 *
4 * (C) Copyright 2002, Greg Ungerer (gerg@snapgear.com)
5 *
6 * $Id: inftl.h,v 1.6 2004/06/30 14:49:00 dbrown Exp $
7 */
8
9#ifndef __MTD_INFTL_H__
10#define __MTD_INFTL_H__
11
12#ifndef __KERNEL__
13#error This is a kernel header. Perhaps include nftl-user.h instead?
14#endif
15
16#include <linux/mtd/blktrans.h>
17#include <linux/mtd/mtd.h>
18#include <linux/mtd/nftl.h>
19
20#include <mtd/inftl-user.h>
21
22#ifndef INFTL_MAJOR
23#define INFTL_MAJOR 94
24#endif
25#define INFTL_PARTN_BITS 4
26
27#ifdef __KERNEL__
28
29struct INFTLrecord {
30 struct mtd_blktrans_dev mbd;
31 __u16 MediaUnit;
32 __u32 EraseSize;
33 struct INFTLMediaHeader MediaHdr;
34 int usecount;
35 unsigned char heads;
36 unsigned char sectors;
37 unsigned short cylinders;
38 __u16 numvunits;
39 __u16 firstEUN;
40 __u16 lastEUN;
41 __u16 numfreeEUNs;
42 __u16 LastFreeEUN; /* To speed up finding a free EUN */
43 int head,sect,cyl;
44 __u16 *PUtable; /* Physical Unit Table */
45 __u16 *VUtable; /* Virtual Unit Table */
46 unsigned int nb_blocks; /* number of physical blocks */
47 unsigned int nb_boot_blocks; /* number of blocks used by the bios */
48 struct erase_info instr;
49 struct nand_oobinfo oobinfo;
50};
51
52int INFTL_mount(struct INFTLrecord *s);
53int INFTL_formatblock(struct INFTLrecord *s, int block);
54
55#endif /* __KERNEL__ */
56
57#endif /* __MTD_INFTL_H__ */
diff --git a/include/linux/mtd/jedec.h b/include/linux/mtd/jedec.h
new file mode 100644
index 000000000000..2ba0f700ddbc
--- /dev/null
+++ b/include/linux/mtd/jedec.h
@@ -0,0 +1,66 @@
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.3 2003/05/21 11:51:01 dwmw2 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/map.h b/include/linux/mtd/map.h
new file mode 100644
index 000000000000..f0268b99c900
--- /dev/null
+++ b/include/linux/mtd/map.h
@@ -0,0 +1,412 @@
1
2/* Overhauled routines for dealing with different mmap regions of flash */
3/* $Id: map.h,v 1.46 2005/01/05 17:09:44 dwmw2 Exp $ */
4
5#ifndef __LINUX_MTD_MAP_H__
6#define __LINUX_MTD_MAP_H__
7
8#include <linux/config.h>
9#include <linux/types.h>
10#include <linux/list.h>
11#include <linux/mtd/compatmac.h>
12#include <asm/unaligned.h>
13#include <asm/system.h>
14#include <asm/io.h>
15#include <asm/bug.h>
16
17#ifdef CONFIG_MTD_MAP_BANK_WIDTH_1
18#define map_bankwidth(map) 1
19#define map_bankwidth_is_1(map) (map_bankwidth(map) == 1)
20#define map_bankwidth_is_large(map) (0)
21#define map_words(map) (1)
22#define MAX_MAP_BANKWIDTH 1
23#else
24#define map_bankwidth_is_1(map) (0)
25#endif
26
27#ifdef CONFIG_MTD_MAP_BANK_WIDTH_2
28# ifdef map_bankwidth
29# undef map_bankwidth
30# define map_bankwidth(map) ((map)->bankwidth)
31# else
32# define map_bankwidth(map) 2
33# define map_bankwidth_is_large(map) (0)
34# define map_words(map) (1)
35# endif
36#define map_bankwidth_is_2(map) (map_bankwidth(map) == 2)
37#undef MAX_MAP_BANKWIDTH
38#define MAX_MAP_BANKWIDTH 2
39#else
40#define map_bankwidth_is_2(map) (0)
41#endif
42
43#ifdef CONFIG_MTD_MAP_BANK_WIDTH_4
44# ifdef map_bankwidth
45# undef map_bankwidth
46# define map_bankwidth(map) ((map)->bankwidth)
47# else
48# define map_bankwidth(map) 4
49# define map_bankwidth_is_large(map) (0)
50# define map_words(map) (1)
51# endif
52#define map_bankwidth_is_4(map) (map_bankwidth(map) == 4)
53#undef MAX_MAP_BANKWIDTH
54#define MAX_MAP_BANKWIDTH 4
55#else
56#define map_bankwidth_is_4(map) (0)
57#endif
58
59/* ensure we never evaluate anything shorted than an unsigned long
60 * to zero, and ensure we'll never miss the end of an comparison (bjd) */
61
62#define map_calc_words(map) ((map_bankwidth(map) + (sizeof(unsigned long)-1))/ sizeof(unsigned long))
63
64#ifdef CONFIG_MTD_MAP_BANK_WIDTH_8
65# ifdef map_bankwidth
66# undef map_bankwidth
67# define map_bankwidth(map) ((map)->bankwidth)
68# if BITS_PER_LONG < 64
69# undef map_bankwidth_is_large
70# define map_bankwidth_is_large(map) (map_bankwidth(map) > BITS_PER_LONG/8)
71# undef map_words
72# define map_words(map) map_calc_words(map)
73# endif
74# else
75# define map_bankwidth(map) 8
76# define map_bankwidth_is_large(map) (BITS_PER_LONG < 64)
77# define map_words(map) map_calc_words(map)
78# endif
79#define map_bankwidth_is_8(map) (map_bankwidth(map) == 8)
80#undef MAX_MAP_BANKWIDTH
81#define MAX_MAP_BANKWIDTH 8
82#else
83#define map_bankwidth_is_8(map) (0)
84#endif
85
86#ifdef CONFIG_MTD_MAP_BANK_WIDTH_16
87# ifdef map_bankwidth
88# undef map_bankwidth
89# define map_bankwidth(map) ((map)->bankwidth)
90# undef map_bankwidth_is_large
91# define map_bankwidth_is_large(map) (map_bankwidth(map) > BITS_PER_LONG/8)
92# undef map_words
93# define map_words(map) map_calc_words(map)
94# else
95# define map_bankwidth(map) 16
96# define map_bankwidth_is_large(map) (1)
97# define map_words(map) map_calc_words(map)
98# endif
99#define map_bankwidth_is_16(map) (map_bankwidth(map) == 16)
100#undef MAX_MAP_BANKWIDTH
101#define MAX_MAP_BANKWIDTH 16
102#else
103#define map_bankwidth_is_16(map) (0)
104#endif
105
106#ifdef CONFIG_MTD_MAP_BANK_WIDTH_32
107# ifdef map_bankwidth
108# undef map_bankwidth
109# define map_bankwidth(map) ((map)->bankwidth)
110# undef map_bankwidth_is_large
111# define map_bankwidth_is_large(map) (map_bankwidth(map) > BITS_PER_LONG/8)
112# undef map_words
113# define map_words(map) map_calc_words(map)
114# else
115# define map_bankwidth(map) 32
116# define map_bankwidth_is_large(map) (1)
117# define map_words(map) map_calc_words(map)
118# endif
119#define map_bankwidth_is_32(map) (map_bankwidth(map) == 32)
120#undef MAX_MAP_BANKWIDTH
121#define MAX_MAP_BANKWIDTH 32
122#else
123#define map_bankwidth_is_32(map) (0)
124#endif
125
126#ifndef map_bankwidth
127#error "No bus width supported. What's the point?"
128#endif
129
130static inline int map_bankwidth_supported(int w)
131{
132 switch (w) {
133#ifdef CONFIG_MTD_MAP_BANK_WIDTH_1
134 case 1:
135#endif
136#ifdef CONFIG_MTD_MAP_BANK_WIDTH_2
137 case 2:
138#endif
139#ifdef CONFIG_MTD_MAP_BANK_WIDTH_4
140 case 4:
141#endif
142#ifdef CONFIG_MTD_MAP_BANK_WIDTH_8
143 case 8:
144#endif
145#ifdef CONFIG_MTD_MAP_BANK_WIDTH_16
146 case 16:
147#endif
148#ifdef CONFIG_MTD_MAP_BANK_WIDTH_32
149 case 32:
150#endif
151 return 1;
152
153 default:
154 return 0;
155 }
156}
157
158#define MAX_MAP_LONGS ( ((MAX_MAP_BANKWIDTH*8) + BITS_PER_LONG - 1) / BITS_PER_LONG )
159
160typedef union {
161 unsigned long x[MAX_MAP_LONGS];
162} map_word;
163
164/* The map stuff is very simple. You fill in your struct map_info with
165 a handful of routines for accessing the device, making sure they handle
166 paging etc. correctly if your device needs it. Then you pass it off
167 to a chip probe routine -- either JEDEC or CFI probe or both -- via
168 do_map_probe(). If a chip is recognised, the probe code will invoke the
169 appropriate chip driver (if present) and return a struct mtd_info.
170 At which point, you fill in the mtd->module with your own module
171 address, and register it with the MTD core code. Or you could partition
172 it and register the partitions instead, or keep it for your own private
173 use; whatever.
174
175 The mtd->priv field will point to the struct map_info, and any further
176 private data required by the chip driver is linked from the
177 mtd->priv->fldrv_priv field. This allows the map driver to get at
178 the destructor function map->fldrv_destroy() when it's tired
179 of living.
180*/
181
182struct map_info {
183 char *name;
184 unsigned long size;
185 unsigned long phys;
186#define NO_XIP (-1UL)
187
188 void __iomem *virt;
189 void *cached;
190
191 int bankwidth; /* in octets. This isn't necessarily the width
192 of actual bus cycles -- it's the repeat interval
193 in bytes, before you are talking to the first chip again.
194 */
195
196#ifdef CONFIG_MTD_COMPLEX_MAPPINGS
197 map_word (*read)(struct map_info *, unsigned long);
198 void (*copy_from)(struct map_info *, void *, unsigned long, ssize_t);
199
200 void (*write)(struct map_info *, const map_word, unsigned long);
201 void (*copy_to)(struct map_info *, unsigned long, const void *, ssize_t);
202
203 /* We can perhaps put in 'point' and 'unpoint' methods, if we really
204 want to enable XIP for non-linear mappings. Not yet though. */
205#endif
206 /* It's possible for the map driver to use cached memory in its
207 copy_from implementation (and _only_ with copy_from). However,
208 when the chip driver knows some flash area has changed contents,
209 it will signal it to the map driver through this routine to let
210 the map driver invalidate the corresponding cache as needed.
211 If there is no cache to care about this can be set to NULL. */
212 void (*inval_cache)(struct map_info *, unsigned long, ssize_t);
213
214 /* set_vpp() must handle being reentered -- enable, enable, disable
215 must leave it enabled. */
216 void (*set_vpp)(struct map_info *, int);
217
218 unsigned long map_priv_1;
219 unsigned long map_priv_2;
220 void *fldrv_priv;
221 struct mtd_chip_driver *fldrv;
222};
223
224struct mtd_chip_driver {
225 struct mtd_info *(*probe)(struct map_info *map);
226 void (*destroy)(struct mtd_info *);
227 struct module *module;
228 char *name;
229 struct list_head list;
230};
231
232void register_mtd_chip_driver(struct mtd_chip_driver *);
233void unregister_mtd_chip_driver(struct mtd_chip_driver *);
234
235struct mtd_info *do_map_probe(const char *name, struct map_info *map);
236void map_destroy(struct mtd_info *mtd);
237
238#define ENABLE_VPP(map) do { if(map->set_vpp) map->set_vpp(map, 1); } while(0)
239#define DISABLE_VPP(map) do { if(map->set_vpp) map->set_vpp(map, 0); } while(0)
240
241#define INVALIDATE_CACHED_RANGE(map, from, size) \
242 do { if(map->inval_cache) map->inval_cache(map, from, size); } while(0)
243
244
245static inline int map_word_equal(struct map_info *map, map_word val1, map_word val2)
246{
247 int i;
248 for (i=0; i<map_words(map); i++) {
249 if (val1.x[i] != val2.x[i])
250 return 0;
251 }
252 return 1;
253}
254
255static inline map_word map_word_and(struct map_info *map, map_word val1, map_word val2)
256{
257 map_word r;
258 int i;
259
260 for (i=0; i<map_words(map); i++) {
261 r.x[i] = val1.x[i] & val2.x[i];
262 }
263 return r;
264}
265
266static inline map_word map_word_or(struct map_info *map, map_word val1, map_word val2)
267{
268 map_word r;
269 int i;
270
271 for (i=0; i<map_words(map); i++) {
272 r.x[i] = val1.x[i] | val2.x[i];
273 }
274 return r;
275}
276#define map_word_andequal(m, a, b, z) map_word_equal(m, z, map_word_and(m, a, b))
277
278static inline int map_word_bitsset(struct map_info *map, map_word val1, map_word val2)
279{
280 int i;
281
282 for (i=0; i<map_words(map); i++) {
283 if (val1.x[i] & val2.x[i])
284 return 1;
285 }
286 return 0;
287}
288
289static inline map_word map_word_load(struct map_info *map, const void *ptr)
290{
291 map_word r;
292
293 if (map_bankwidth_is_1(map))
294 r.x[0] = *(unsigned char *)ptr;
295 else if (map_bankwidth_is_2(map))
296 r.x[0] = get_unaligned((uint16_t *)ptr);
297 else if (map_bankwidth_is_4(map))
298 r.x[0] = get_unaligned((uint32_t *)ptr);
299#if BITS_PER_LONG >= 64
300 else if (map_bankwidth_is_8(map))
301 r.x[0] = get_unaligned((uint64_t *)ptr);
302#endif
303 else if (map_bankwidth_is_large(map))
304 memcpy(r.x, ptr, map->bankwidth);
305
306 return r;
307}
308
309static inline map_word map_word_load_partial(struct map_info *map, map_word orig, const unsigned char *buf, int start, int len)
310{
311 int i;
312
313 if (map_bankwidth_is_large(map)) {
314 char *dest = (char *)&orig;
315 memcpy(dest+start, buf, len);
316 } else {
317 for (i=start; i < start+len; i++) {
318 int bitpos;
319#ifdef __LITTLE_ENDIAN
320 bitpos = i*8;
321#else /* __BIG_ENDIAN */
322 bitpos = (map_bankwidth(map)-1-i)*8;
323#endif
324 orig.x[0] &= ~(0xff << bitpos);
325 orig.x[0] |= buf[i-start] << bitpos;
326 }
327 }
328 return orig;
329}
330
331static inline map_word map_word_ff(struct map_info *map)
332{
333 map_word r;
334 int i;
335
336 for (i=0; i<map_words(map); i++) {
337 r.x[i] = ~0UL;
338 }
339 return r;
340}
341static inline map_word inline_map_read(struct map_info *map, unsigned long ofs)
342{
343 map_word r;
344
345 if (map_bankwidth_is_1(map))
346 r.x[0] = __raw_readb(map->virt + ofs);
347 else if (map_bankwidth_is_2(map))
348 r.x[0] = __raw_readw(map->virt + ofs);
349 else if (map_bankwidth_is_4(map))
350 r.x[0] = __raw_readl(map->virt + ofs);
351#if BITS_PER_LONG >= 64
352 else if (map_bankwidth_is_8(map))
353 r.x[0] = __raw_readq(map->virt + ofs);
354#endif
355 else if (map_bankwidth_is_large(map))
356 memcpy_fromio(r.x, map->virt+ofs, map->bankwidth);
357
358 return r;
359}
360
361static inline void inline_map_write(struct map_info *map, const map_word datum, unsigned long ofs)
362{
363 if (map_bankwidth_is_1(map))
364 __raw_writeb(datum.x[0], map->virt + ofs);
365 else if (map_bankwidth_is_2(map))
366 __raw_writew(datum.x[0], map->virt + ofs);
367 else if (map_bankwidth_is_4(map))
368 __raw_writel(datum.x[0], map->virt + ofs);
369#if BITS_PER_LONG >= 64
370 else if (map_bankwidth_is_8(map))
371 __raw_writeq(datum.x[0], map->virt + ofs);
372#endif
373 else if (map_bankwidth_is_large(map))
374 memcpy_toio(map->virt+ofs, datum.x, map->bankwidth);
375 mb();
376}
377
378static inline void inline_map_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
379{
380 if (map->cached)
381 memcpy(to, (char *)map->cached + from, len);
382 else
383 memcpy_fromio(to, map->virt + from, len);
384}
385
386static inline void inline_map_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
387{
388 memcpy_toio(map->virt + to, from, len);
389}
390
391#ifdef CONFIG_MTD_COMPLEX_MAPPINGS
392#define map_read(map, ofs) (map)->read(map, ofs)
393#define map_copy_from(map, to, from, len) (map)->copy_from(map, to, from, len)
394#define map_write(map, datum, ofs) (map)->write(map, datum, ofs)
395#define map_copy_to(map, to, from, len) (map)->copy_to(map, to, from, len)
396
397extern void simple_map_init(struct map_info *);
398#define map_is_linear(map) (map->phys != NO_XIP)
399
400#else
401#define map_read(map, ofs) inline_map_read(map, ofs)
402#define map_copy_from(map, to, from, len) inline_map_copy_from(map, to, from, len)
403#define map_write(map, datum, ofs) inline_map_write(map, datum, ofs)
404#define map_copy_to(map, to, from, len) inline_map_copy_to(map, to, from, len)
405
406
407#define simple_map_init(map) BUG_ON(!map_bankwidth_supported((map)->bankwidth))
408#define map_is_linear(map) (1)
409
410#endif /* !CONFIG_MTD_COMPLEX_MAPPINGS */
411
412#endif /* __LINUX_MTD_MAP_H__ */
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
new file mode 100644
index 000000000000..b3d134392b31
--- /dev/null
+++ b/include/linux/mtd/mtd.h
@@ -0,0 +1,226 @@
1/*
2 * $Id: mtd.h,v 1.56 2004/08/09 18:46:04 dmarlin Exp $
3 *
4 * Copyright (C) 1999-2003 David Woodhouse <dwmw2@infradead.org> et al.
5 *
6 * Released under GPL
7 */
8
9#ifndef __MTD_MTD_H__
10#define __MTD_MTD_H__
11
12#ifndef __KERNEL__
13#error This is a kernel header. Perhaps include mtd-user.h instead?
14#endif
15
16#include <linux/config.h>
17#include <linux/version.h>
18#include <linux/types.h>
19#include <linux/module.h>
20#include <linux/uio.h>
21
22#include <linux/mtd/compatmac.h>
23#include <mtd/mtd-abi.h>
24
25#define MTD_CHAR_MAJOR 90
26#define MTD_BLOCK_MAJOR 31
27#define MAX_MTD_DEVICES 16
28
29#define MTD_ERASE_PENDING 0x01
30#define MTD_ERASING 0x02
31#define MTD_ERASE_SUSPEND 0x04
32#define MTD_ERASE_DONE 0x08
33#define MTD_ERASE_FAILED 0x10
34
35/* If the erase fails, fail_addr might indicate exactly which block failed. If
36 fail_addr = 0xffffffff, the failure was not at the device level or was not
37 specific to any particular block. */
38struct erase_info {
39 struct mtd_info *mtd;
40 u_int32_t addr;
41 u_int32_t len;
42 u_int32_t fail_addr;
43 u_long time;
44 u_long retries;
45 u_int dev;
46 u_int cell;
47 void (*callback) (struct erase_info *self);
48 u_long priv;
49 u_char state;
50 struct erase_info *next;
51};
52
53struct mtd_erase_region_info {
54 u_int32_t offset; /* At which this region starts, from the beginning of the MTD */
55 u_int32_t erasesize; /* For this region */
56 u_int32_t numblocks; /* Number of blocks of erasesize in this region */
57};
58
59struct mtd_info {
60 u_char type;
61 u_int32_t flags;
62 u_int32_t size; // Total size of the MTD
63
64 /* "Major" erase size for the device. Naïve users may take this
65 * to be the only erase size available, or may use the more detailed
66 * information below if they desire
67 */
68 u_int32_t erasesize;
69
70 u_int32_t oobblock; // Size of OOB blocks (e.g. 512)
71 u_int32_t oobsize; // Amount of OOB data per block (e.g. 16)
72 u_int32_t oobavail; // Number of bytes in OOB area available for fs
73 u_int32_t ecctype;
74 u_int32_t eccsize;
75
76
77 // Kernel-only stuff starts here.
78 char *name;
79 int index;
80
81 // oobinfo is a nand_oobinfo structure, which can be set by iotcl (MEMSETOOBINFO)
82 struct nand_oobinfo oobinfo;
83
84 /* Data for variable erase regions. If numeraseregions is zero,
85 * it means that the whole device has erasesize as given above.
86 */
87 int numeraseregions;
88 struct mtd_erase_region_info *eraseregions;
89
90 /* This really shouldn't be here. It can go away in 2.5 */
91 u_int32_t bank_size;
92
93 int (*erase) (struct mtd_info *mtd, struct erase_info *instr);
94
95 /* This stuff for eXecute-In-Place */
96 int (*point) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char **mtdbuf);
97
98 /* We probably shouldn't allow XIP if the unpoint isn't a NULL */
99 void (*unpoint) (struct mtd_info *mtd, u_char * addr, loff_t from, size_t len);
100
101
102 int (*read) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
103 int (*write) (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf);
104
105 int (*read_ecc) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf, u_char *eccbuf, struct nand_oobinfo *oobsel);
106 int (*write_ecc) (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf, u_char *eccbuf, struct nand_oobinfo *oobsel);
107
108 int (*read_oob) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
109 int (*write_oob) (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf);
110
111 /*
112 * Methods to access the protection register area, present in some
113 * flash devices. The user data is one time programmable but the
114 * factory data is read only.
115 */
116 int (*read_user_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
117
118 int (*read_fact_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
119
120 /* This function is not yet implemented */
121 int (*write_user_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
122
123 /* kvec-based read/write methods. We need these especially for NAND flash,
124 with its limited number of write cycles per erase.
125 NB: The 'count' parameter is the number of _vectors_, each of
126 which contains an (ofs, len) tuple.
127 */
128 int (*readv) (struct mtd_info *mtd, struct kvec *vecs, unsigned long count, loff_t from, size_t *retlen);
129 int (*readv_ecc) (struct mtd_info *mtd, struct kvec *vecs, unsigned long count, loff_t from,
130 size_t *retlen, u_char *eccbuf, struct nand_oobinfo *oobsel);
131 int (*writev) (struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, loff_t to, size_t *retlen);
132 int (*writev_ecc) (struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, loff_t to,
133 size_t *retlen, u_char *eccbuf, struct nand_oobinfo *oobsel);
134
135 /* Sync */
136 void (*sync) (struct mtd_info *mtd);
137
138 /* Chip-supported device locking */
139 int (*lock) (struct mtd_info *mtd, loff_t ofs, size_t len);
140 int (*unlock) (struct mtd_info *mtd, loff_t ofs, size_t len);
141
142 /* Power Management functions */
143 int (*suspend) (struct mtd_info *mtd);
144 void (*resume) (struct mtd_info *mtd);
145
146 /* Bad block management functions */
147 int (*block_isbad) (struct mtd_info *mtd, loff_t ofs);
148 int (*block_markbad) (struct mtd_info *mtd, loff_t ofs);
149
150 void *priv;
151
152 struct module *owner;
153 int usecount;
154};
155
156
157 /* Kernel-side ioctl definitions */
158
159extern int add_mtd_device(struct mtd_info *mtd);
160extern int del_mtd_device (struct mtd_info *mtd);
161
162extern struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num);
163
164extern void put_mtd_device(struct mtd_info *mtd);
165
166
167struct mtd_notifier {
168 void (*add)(struct mtd_info *mtd);
169 void (*remove)(struct mtd_info *mtd);
170 struct list_head list;
171};
172
173
174extern void register_mtd_user (struct mtd_notifier *new);
175extern int unregister_mtd_user (struct mtd_notifier *old);
176
177int default_mtd_writev(struct mtd_info *mtd, const struct kvec *vecs,
178 unsigned long count, loff_t to, size_t *retlen);
179
180int default_mtd_readv(struct mtd_info *mtd, struct kvec *vecs,
181 unsigned long count, loff_t from, size_t *retlen);
182
183#define MTD_ERASE(mtd, args...) (*(mtd->erase))(mtd, args)
184#define MTD_POINT(mtd, a,b,c,d) (*(mtd->point))(mtd, a,b,c, (u_char **)(d))
185#define MTD_UNPOINT(mtd, arg) (*(mtd->unpoint))(mtd, (u_char *)arg)
186#define MTD_READ(mtd, args...) (*(mtd->read))(mtd, args)
187#define MTD_WRITE(mtd, args...) (*(mtd->write))(mtd, args)
188#define MTD_READV(mtd, args...) (*(mtd->readv))(mtd, args)
189#define MTD_WRITEV(mtd, args...) (*(mtd->writev))(mtd, args)
190#define MTD_READECC(mtd, args...) (*(mtd->read_ecc))(mtd, args)
191#define MTD_WRITEECC(mtd, args...) (*(mtd->write_ecc))(mtd, args)
192#define MTD_READOOB(mtd, args...) (*(mtd->read_oob))(mtd, args)
193#define MTD_WRITEOOB(mtd, args...) (*(mtd->write_oob))(mtd, args)
194#define MTD_SYNC(mtd) do { if (mtd->sync) (*(mtd->sync))(mtd); } while (0)
195
196
197#ifdef CONFIG_MTD_PARTITIONS
198void mtd_erase_callback(struct erase_info *instr);
199#else
200static inline void mtd_erase_callback(struct erase_info *instr)
201{
202 if (instr->callback)
203 instr->callback(instr);
204}
205#endif
206
207/*
208 * Debugging macro and defines
209 */
210#define MTD_DEBUG_LEVEL0 (0) /* Quiet */
211#define MTD_DEBUG_LEVEL1 (1) /* Audible */
212#define MTD_DEBUG_LEVEL2 (2) /* Loud */
213#define MTD_DEBUG_LEVEL3 (3) /* Noisy */
214
215#ifdef CONFIG_MTD_DEBUG
216#define DEBUG(n, args...) \
217 do { \
218 if (n <= CONFIG_MTD_DEBUG_VERBOSE) \
219 printk(KERN_INFO args); \
220 } while(0)
221#else /* CONFIG_MTD_DEBUG */
222#define DEBUG(n, args...) do { } while(0)
223
224#endif /* CONFIG_MTD_DEBUG */
225
226#endif /* __MTD_MTD_H__ */
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
new file mode 100644
index 000000000000..9a19c65abd74
--- /dev/null
+++ b/include/linux/mtd/nand.h
@@ -0,0 +1,469 @@
1/*
2 * linux/include/linux/mtd/nand.h
3 *
4 * Copyright (c) 2000 David Woodhouse <dwmw2@mvhi.com>
5 * Steven J. Hill <sjhill@realitydiluted.com>
6 * Thomas Gleixner <tglx@linutronix.de>
7 *
8 * $Id: nand.h,v 1.68 2004/11/12 10:40:37 gleixner Exp $
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 version 2 as
12 * published by the Free Software Foundation.
13 *
14 * Info:
15 * Contains standard defines and IDs for NAND flash devices
16 *
17 * Changelog:
18 * 01-31-2000 DMW Created
19 * 09-18-2000 SJH Moved structure out of the Disk-On-Chip drivers
20 * so it can be used by other NAND flash device
21 * drivers. I also changed the copyright since none
22 * of the original contents of this file are specific
23 * to DoC devices. David can whack me with a baseball
24 * bat later if I did something naughty.
25 * 10-11-2000 SJH Added private NAND flash structure for driver
26 * 10-24-2000 SJH Added prototype for 'nand_scan' function
27 * 10-29-2001 TG changed nand_chip structure to support
28 * hardwarespecific function for accessing control lines
29 * 02-21-2002 TG added support for different read/write adress and
30 * ready/busy line access function
31 * 02-26-2002 TG added chip_delay to nand_chip structure to optimize
32 * command delay times for different chips
33 * 04-28-2002 TG OOB config defines moved from nand.c to avoid duplicate
34 * defines in jffs2/wbuf.c
35 * 08-07-2002 TG forced bad block location to byte 5 of OOB, even if
36 * CONFIG_MTD_NAND_ECC_JFFS2 is not set
37 * 08-10-2002 TG extensions to nand_chip structure to support HW-ECC
38 *
39 * 08-29-2002 tglx nand_chip structure: data_poi for selecting
40 * internal / fs-driver buffer
41 * support for 6byte/512byte hardware ECC
42 * read_ecc, write_ecc extended for different oob-layout
43 * oob layout selections: NAND_NONE_OOB, NAND_JFFS2_OOB,
44 * NAND_YAFFS_OOB
45 * 11-25-2002 tglx Added Manufacturer code FUJITSU, NATIONAL
46 * Split manufacturer and device ID structures
47 *
48 * 02-08-2004 tglx added option field to nand structure for chip anomalities
49 * 05-25-2004 tglx added bad block table support, ST-MICRO manufacturer id
50 * update of nand_chip structure description
51 */
52#ifndef __LINUX_MTD_NAND_H
53#define __LINUX_MTD_NAND_H
54
55#include <linux/config.h>
56#include <linux/wait.h>
57#include <linux/spinlock.h>
58#include <linux/mtd/mtd.h>
59
60struct mtd_info;
61/* Scan and identify a NAND device */
62extern int nand_scan (struct mtd_info *mtd, int max_chips);
63/* Free resources held by the NAND device */
64extern void nand_release (struct mtd_info *mtd);
65
66/* Read raw data from the device without ECC */
67extern int nand_read_raw (struct mtd_info *mtd, uint8_t *buf, loff_t from, size_t len, size_t ooblen);
68
69
70/* The maximum number of NAND chips in an array */
71#define NAND_MAX_CHIPS 8
72
73/* This constant declares the max. oobsize / page, which
74 * is supported now. If you add a chip with bigger oobsize/page
75 * adjust this accordingly.
76 */
77#define NAND_MAX_OOBSIZE 64
78
79/*
80 * Constants for hardware specific CLE/ALE/NCE function
81*/
82/* Select the chip by setting nCE to low */
83#define NAND_CTL_SETNCE 1
84/* Deselect the chip by setting nCE to high */
85#define NAND_CTL_CLRNCE 2
86/* Select the command latch by setting CLE to high */
87#define NAND_CTL_SETCLE 3
88/* Deselect the command latch by setting CLE to low */
89#define NAND_CTL_CLRCLE 4
90/* Select the address latch by setting ALE to high */
91#define NAND_CTL_SETALE 5
92/* Deselect the address latch by setting ALE to low */
93#define NAND_CTL_CLRALE 6
94/* Set write protection by setting WP to high. Not used! */
95#define NAND_CTL_SETWP 7
96/* Clear write protection by setting WP to low. Not used! */
97#define NAND_CTL_CLRWP 8
98
99/*
100 * Standard NAND flash commands
101 */
102#define NAND_CMD_READ0 0
103#define NAND_CMD_READ1 1
104#define NAND_CMD_PAGEPROG 0x10
105#define NAND_CMD_READOOB 0x50
106#define NAND_CMD_ERASE1 0x60
107#define NAND_CMD_STATUS 0x70
108#define NAND_CMD_STATUS_MULTI 0x71
109#define NAND_CMD_SEQIN 0x80
110#define NAND_CMD_READID 0x90
111#define NAND_CMD_ERASE2 0xd0
112#define NAND_CMD_RESET 0xff
113
114/* Extended commands for large page devices */
115#define NAND_CMD_READSTART 0x30
116#define NAND_CMD_CACHEDPROG 0x15
117
118/* Status bits */
119#define NAND_STATUS_FAIL 0x01
120#define NAND_STATUS_FAIL_N1 0x02
121#define NAND_STATUS_TRUE_READY 0x20
122#define NAND_STATUS_READY 0x40
123#define NAND_STATUS_WP 0x80
124
125/*
126 * Constants for ECC_MODES
127 */
128
129/* No ECC. Usage is not recommended ! */
130#define NAND_ECC_NONE 0
131/* Software ECC 3 byte ECC per 256 Byte data */
132#define NAND_ECC_SOFT 1
133/* Hardware ECC 3 byte ECC per 256 Byte data */
134#define NAND_ECC_HW3_256 2
135/* Hardware ECC 3 byte ECC per 512 Byte data */
136#define NAND_ECC_HW3_512 3
137/* Hardware ECC 3 byte ECC per 512 Byte data */
138#define NAND_ECC_HW6_512 4
139/* Hardware ECC 8 byte ECC per 512 Byte data */
140#define NAND_ECC_HW8_512 6
141/* Hardware ECC 12 byte ECC per 2048 Byte data */
142#define NAND_ECC_HW12_2048 7
143
144/*
145 * Constants for Hardware ECC
146*/
147/* Reset Hardware ECC for read */
148#define NAND_ECC_READ 0
149/* Reset Hardware ECC for write */
150#define NAND_ECC_WRITE 1
151/* Enable Hardware ECC before syndrom is read back from flash */
152#define NAND_ECC_READSYN 2
153
154/* Option constants for bizarre disfunctionality and real
155* features
156*/
157/* Chip can not auto increment pages */
158#define NAND_NO_AUTOINCR 0x00000001
159/* Buswitdh is 16 bit */
160#define NAND_BUSWIDTH_16 0x00000002
161/* Device supports partial programming without padding */
162#define NAND_NO_PADDING 0x00000004
163/* Chip has cache program function */
164#define NAND_CACHEPRG 0x00000008
165/* Chip has copy back function */
166#define NAND_COPYBACK 0x00000010
167/* AND Chip which has 4 banks and a confusing page / block
168 * assignment. See Renesas datasheet for further information */
169#define NAND_IS_AND 0x00000020
170/* Chip has a array of 4 pages which can be read without
171 * additional ready /busy waits */
172#define NAND_4PAGE_ARRAY 0x00000040
173
174/* Options valid for Samsung large page devices */
175#define NAND_SAMSUNG_LP_OPTIONS \
176 (NAND_NO_PADDING | NAND_CACHEPRG | NAND_COPYBACK)
177
178/* Macros to identify the above */
179#define NAND_CANAUTOINCR(chip) (!(chip->options & NAND_NO_AUTOINCR))
180#define NAND_MUST_PAD(chip) (!(chip->options & NAND_NO_PADDING))
181#define NAND_HAS_CACHEPROG(chip) ((chip->options & NAND_CACHEPRG))
182#define NAND_HAS_COPYBACK(chip) ((chip->options & NAND_COPYBACK))
183
184/* Mask to zero out the chip options, which come from the id table */
185#define NAND_CHIPOPTIONS_MSK (0x0000ffff & ~NAND_NO_AUTOINCR)
186
187/* Non chip related options */
188/* Use a flash based bad block table. This option is passed to the
189 * default bad block table function. */
190#define NAND_USE_FLASH_BBT 0x00010000
191/* The hw ecc generator provides a syndrome instead a ecc value on read
192 * This can only work if we have the ecc bytes directly behind the
193 * data bytes. Applies for DOC and AG-AND Renesas HW Reed Solomon generators */
194#define NAND_HWECC_SYNDROME 0x00020000
195
196
197/* Options set by nand scan */
198/* Nand scan has allocated oob_buf */
199#define NAND_OOBBUF_ALLOC 0x40000000
200/* Nand scan has allocated data_buf */
201#define NAND_DATABUF_ALLOC 0x80000000
202
203
204/*
205 * nand_state_t - chip states
206 * Enumeration for NAND flash chip state
207 */
208typedef enum {
209 FL_READY,
210 FL_READING,
211 FL_WRITING,
212 FL_ERASING,
213 FL_SYNCING,
214 FL_CACHEDPRG,
215} nand_state_t;
216
217/* Keep gcc happy */
218struct nand_chip;
219
220/**
221 * struct nand_hw_control - Control structure for hardware controller (e.g ECC generator) shared among independend devices
222 * @lock: protection lock
223 * @active: the mtd device which holds the controller currently
224 */
225struct nand_hw_control {
226 spinlock_t lock;
227 struct nand_chip *active;
228};
229
230/**
231 * struct nand_chip - NAND Private Flash Chip Data
232 * @IO_ADDR_R: [BOARDSPECIFIC] address to read the 8 I/O lines of the flash device
233 * @IO_ADDR_W: [BOARDSPECIFIC] address to write the 8 I/O lines of the flash device
234 * @read_byte: [REPLACEABLE] read one byte from the chip
235 * @write_byte: [REPLACEABLE] write one byte to the chip
236 * @read_word: [REPLACEABLE] read one word from the chip
237 * @write_word: [REPLACEABLE] write one word to the chip
238 * @write_buf: [REPLACEABLE] write data from the buffer to the chip
239 * @read_buf: [REPLACEABLE] read data from the chip into the buffer
240 * @verify_buf: [REPLACEABLE] verify buffer contents against the chip data
241 * @select_chip: [REPLACEABLE] select chip nr
242 * @block_bad: [REPLACEABLE] check, if the block is bad
243 * @block_markbad: [REPLACEABLE] mark the block bad
244 * @hwcontrol: [BOARDSPECIFIC] hardwarespecific function for accesing control-lines
245 * @dev_ready: [BOARDSPECIFIC] hardwarespecific function for accesing device ready/busy line
246 * If set to NULL no access to ready/busy is available and the ready/busy information
247 * is read from the chip status register
248 * @cmdfunc: [REPLACEABLE] hardwarespecific function for writing commands to the chip
249 * @waitfunc: [REPLACEABLE] hardwarespecific function for wait on ready
250 * @calculate_ecc: [REPLACEABLE] function for ecc calculation or readback from ecc hardware
251 * @correct_data: [REPLACEABLE] function for ecc correction, matching to ecc generator (sw/hw)
252 * @enable_hwecc: [BOARDSPECIFIC] function to enable (reset) hardware ecc generator. Must only
253 * be provided if a hardware ECC is available
254 * @erase_cmd: [INTERN] erase command write function, selectable due to AND support
255 * @scan_bbt: [REPLACEABLE] function to scan bad block table
256 * @eccmode: [BOARDSPECIFIC] mode of ecc, see defines
257 * @eccsize: [INTERN] databytes used per ecc-calculation
258 * @eccbytes: [INTERN] number of ecc bytes per ecc-calculation step
259 * @eccsteps: [INTERN] number of ecc calculation steps per page
260 * @chip_delay: [BOARDSPECIFIC] chip dependent delay for transfering data from array to read regs (tR)
261 * @chip_lock: [INTERN] spinlock used to protect access to this structure and the chip
262 * @wq: [INTERN] wait queue to sleep on if a NAND operation is in progress
263 * @state: [INTERN] the current state of the NAND device
264 * @page_shift: [INTERN] number of address bits in a page (column address bits)
265 * @phys_erase_shift: [INTERN] number of address bits in a physical eraseblock
266 * @bbt_erase_shift: [INTERN] number of address bits in a bbt entry
267 * @chip_shift: [INTERN] number of address bits in one chip
268 * @data_buf: [INTERN] internal buffer for one page + oob
269 * @oob_buf: [INTERN] oob buffer for one eraseblock
270 * @oobdirty: [INTERN] indicates that oob_buf must be reinitialized
271 * @data_poi: [INTERN] pointer to a data buffer
272 * @options: [BOARDSPECIFIC] various chip options. They can partly be set to inform nand_scan about
273 * special functionality. See the defines for further explanation
274 * @badblockpos: [INTERN] position of the bad block marker in the oob area
275 * @numchips: [INTERN] number of physical chips
276 * @chipsize: [INTERN] the size of one chip for multichip arrays
277 * @pagemask: [INTERN] page number mask = number of (pages / chip) - 1
278 * @pagebuf: [INTERN] holds the pagenumber which is currently in data_buf
279 * @autooob: [REPLACEABLE] the default (auto)placement scheme
280 * @bbt: [INTERN] bad block table pointer
281 * @bbt_td: [REPLACEABLE] bad block table descriptor for flash lookup
282 * @bbt_md: [REPLACEABLE] bad block table mirror descriptor
283 * @badblock_pattern: [REPLACEABLE] bad block scan pattern used for initial bad block scan
284 * @controller: [OPTIONAL] a pointer to a hardware controller structure which is shared among multiple independend devices
285 * @priv: [OPTIONAL] pointer to private chip date
286 */
287
288struct nand_chip {
289 void __iomem *IO_ADDR_R;
290 void __iomem *IO_ADDR_W;
291
292 u_char (*read_byte)(struct mtd_info *mtd);
293 void (*write_byte)(struct mtd_info *mtd, u_char byte);
294 u16 (*read_word)(struct mtd_info *mtd);
295 void (*write_word)(struct mtd_info *mtd, u16 word);
296
297 void (*write_buf)(struct mtd_info *mtd, const u_char *buf, int len);
298 void (*read_buf)(struct mtd_info *mtd, u_char *buf, int len);
299 int (*verify_buf)(struct mtd_info *mtd, const u_char *buf, int len);
300 void (*select_chip)(struct mtd_info *mtd, int chip);
301 int (*block_bad)(struct mtd_info *mtd, loff_t ofs, int getchip);
302 int (*block_markbad)(struct mtd_info *mtd, loff_t ofs);
303 void (*hwcontrol)(struct mtd_info *mtd, int cmd);
304 int (*dev_ready)(struct mtd_info *mtd);
305 void (*cmdfunc)(struct mtd_info *mtd, unsigned command, int column, int page_addr);
306 int (*waitfunc)(struct mtd_info *mtd, struct nand_chip *this, int state);
307 int (*calculate_ecc)(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code);
308 int (*correct_data)(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_char *calc_ecc);
309 void (*enable_hwecc)(struct mtd_info *mtd, int mode);
310 void (*erase_cmd)(struct mtd_info *mtd, int page);
311 int (*scan_bbt)(struct mtd_info *mtd);
312 int eccmode;
313 int eccsize;
314 int eccbytes;
315 int eccsteps;
316 int chip_delay;
317 spinlock_t chip_lock;
318 wait_queue_head_t wq;
319 nand_state_t state;
320 int page_shift;
321 int phys_erase_shift;
322 int bbt_erase_shift;
323 int chip_shift;
324 u_char *data_buf;
325 u_char *oob_buf;
326 int oobdirty;
327 u_char *data_poi;
328 unsigned int options;
329 int badblockpos;
330 int numchips;
331 unsigned long chipsize;
332 int pagemask;
333 int pagebuf;
334 struct nand_oobinfo *autooob;
335 uint8_t *bbt;
336 struct nand_bbt_descr *bbt_td;
337 struct nand_bbt_descr *bbt_md;
338 struct nand_bbt_descr *badblock_pattern;
339 struct nand_hw_control *controller;
340 void *priv;
341};
342
343/*
344 * NAND Flash Manufacturer ID Codes
345 */
346#define NAND_MFR_TOSHIBA 0x98
347#define NAND_MFR_SAMSUNG 0xec
348#define NAND_MFR_FUJITSU 0x04
349#define NAND_MFR_NATIONAL 0x8f
350#define NAND_MFR_RENESAS 0x07
351#define NAND_MFR_STMICRO 0x20
352
353/**
354 * struct nand_flash_dev - NAND Flash Device ID Structure
355 *
356 * @name: Identify the device type
357 * @id: device ID code
358 * @pagesize: Pagesize in bytes. Either 256 or 512 or 0
359 * If the pagesize is 0, then the real pagesize
360 * and the eraseize are determined from the
361 * extended id bytes in the chip
362 * @erasesize: Size of an erase block in the flash device.
363 * @chipsize: Total chipsize in Mega Bytes
364 * @options: Bitfield to store chip relevant options
365 */
366struct nand_flash_dev {
367 char *name;
368 int id;
369 unsigned long pagesize;
370 unsigned long chipsize;
371 unsigned long erasesize;
372 unsigned long options;
373};
374
375/**
376 * struct nand_manufacturers - NAND Flash Manufacturer ID Structure
377 * @name: Manufacturer name
378 * @id: manufacturer ID code of device.
379*/
380struct nand_manufacturers {
381 int id;
382 char * name;
383};
384
385extern struct nand_flash_dev nand_flash_ids[];
386extern struct nand_manufacturers nand_manuf_ids[];
387
388/**
389 * struct nand_bbt_descr - bad block table descriptor
390 * @options: options for this descriptor
391 * @pages: the page(s) where we find the bbt, used with option BBT_ABSPAGE
392 * when bbt is searched, then we store the found bbts pages here.
393 * Its an array and supports up to 8 chips now
394 * @offs: offset of the pattern in the oob area of the page
395 * @veroffs: offset of the bbt version counter in the oob are of the page
396 * @version: version read from the bbt page during scan
397 * @len: length of the pattern, if 0 no pattern check is performed
398 * @maxblocks: maximum number of blocks to search for a bbt. This number of
399 * blocks is reserved at the end of the device where the tables are
400 * written.
401 * @reserved_block_code: if non-0, this pattern denotes a reserved (rather than
402 * bad) block in the stored bbt
403 * @pattern: pattern to identify bad block table or factory marked good /
404 * bad blocks, can be NULL, if len = 0
405 *
406 * Descriptor for the bad block table marker and the descriptor for the
407 * pattern which identifies good and bad blocks. The assumption is made
408 * that the pattern and the version count are always located in the oob area
409 * of the first block.
410 */
411struct nand_bbt_descr {
412 int options;
413 int pages[NAND_MAX_CHIPS];
414 int offs;
415 int veroffs;
416 uint8_t version[NAND_MAX_CHIPS];
417 int len;
418 int maxblocks;
419 int reserved_block_code;
420 uint8_t *pattern;
421};
422
423/* Options for the bad block table descriptors */
424
425/* The number of bits used per block in the bbt on the device */
426#define NAND_BBT_NRBITS_MSK 0x0000000F
427#define NAND_BBT_1BIT 0x00000001
428#define NAND_BBT_2BIT 0x00000002
429#define NAND_BBT_4BIT 0x00000004
430#define NAND_BBT_8BIT 0x00000008
431/* The bad block table is in the last good block of the device */
432#define NAND_BBT_LASTBLOCK 0x00000010
433/* The bbt is at the given page, else we must scan for the bbt */
434#define NAND_BBT_ABSPAGE 0x00000020
435/* The bbt is at the given page, else we must scan for the bbt */
436#define NAND_BBT_SEARCH 0x00000040
437/* bbt is stored per chip on multichip devices */
438#define NAND_BBT_PERCHIP 0x00000080
439/* bbt has a version counter at offset veroffs */
440#define NAND_BBT_VERSION 0x00000100
441/* Create a bbt if none axists */
442#define NAND_BBT_CREATE 0x00000200
443/* Search good / bad pattern through all pages of a block */
444#define NAND_BBT_SCANALLPAGES 0x00000400
445/* Scan block empty during good / bad block scan */
446#define NAND_BBT_SCANEMPTY 0x00000800
447/* Write bbt if neccecary */
448#define NAND_BBT_WRITE 0x00001000
449/* Read and write back block contents when writing bbt */
450#define NAND_BBT_SAVECONTENT 0x00002000
451/* Search good / bad pattern on the first and the second page */
452#define NAND_BBT_SCAN2NDPAGE 0x00004000
453
454/* The maximum number of blocks to scan for a bbt */
455#define NAND_BBT_SCAN_MAXBLOCKS 4
456
457extern int nand_scan_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd);
458extern int nand_update_bbt (struct mtd_info *mtd, loff_t offs);
459extern int nand_default_bbt (struct mtd_info *mtd);
460extern int nand_isbad_bbt (struct mtd_info *mtd, loff_t offs, int allowbbt);
461extern int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbbt);
462
463/*
464* Constants for oob configuration
465*/
466#define NAND_SMALL_BADBLOCK_POS 5
467#define NAND_LARGE_BADBLOCK_POS 0
468
469#endif /* __LINUX_MTD_NAND_H */
diff --git a/include/linux/mtd/nand_ecc.h b/include/linux/mtd/nand_ecc.h
new file mode 100644
index 000000000000..12c5bc342ead
--- /dev/null
+++ b/include/linux/mtd/nand_ecc.h
@@ -0,0 +1,30 @@
1/*
2 * drivers/mtd/nand_ecc.h
3 *
4 * Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com)
5 *
6 * $Id: nand_ecc.h,v 1.4 2004/06/17 02:35:02 dbrown Exp $
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * This file is the header for the ECC algorithm.
13 */
14
15#ifndef __MTD_NAND_ECC_H__
16#define __MTD_NAND_ECC_H__
17
18struct mtd_info;
19
20/*
21 * Calculate 3 byte ECC code for 256 byte block
22 */
23int nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code);
24
25/*
26 * Detect and correct a 1 bit error for 256 byte block
27 */
28int nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_char *calc_ecc);
29
30#endif /* __MTD_NAND_ECC_H__ */
diff --git a/include/linux/mtd/nftl.h b/include/linux/mtd/nftl.h
new file mode 100644
index 000000000000..d35d2c21ff3e
--- /dev/null
+++ b/include/linux/mtd/nftl.h
@@ -0,0 +1,54 @@
1/*
2 * $Id: nftl.h,v 1.16 2004/06/30 14:49:00 dbrown Exp $
3 *
4 * (C) 1999-2003 David Woodhouse <dwmw2@infradead.org>
5 */
6
7#ifndef __MTD_NFTL_H__
8#define __MTD_NFTL_H__
9
10#include <linux/mtd/mtd.h>
11#include <linux/mtd/blktrans.h>
12
13#include <mtd/nftl-user.h>
14
15/* these info are used in ReplUnitTable */
16#define BLOCK_NIL 0xffff /* last block of a chain */
17#define BLOCK_FREE 0xfffe /* free block */
18#define BLOCK_NOTEXPLORED 0xfffd /* non explored block, only used during mounting */
19#define BLOCK_RESERVED 0xfffc /* bios block or bad block */
20
21struct NFTLrecord {
22 struct mtd_blktrans_dev mbd;
23 __u16 MediaUnit, SpareMediaUnit;
24 __u32 EraseSize;
25 struct NFTLMediaHeader MediaHdr;
26 int usecount;
27 unsigned char heads;
28 unsigned char sectors;
29 unsigned short cylinders;
30 __u16 numvunits;
31 __u16 lastEUN; /* should be suppressed */
32 __u16 numfreeEUNs;
33 __u16 LastFreeEUN; /* To speed up finding a free EUN */
34 int head,sect,cyl;
35 __u16 *EUNtable; /* [numvunits]: First EUN for each virtual unit */
36 __u16 *ReplUnitTable; /* [numEUNs]: ReplUnitNumber for each */
37 unsigned int nb_blocks; /* number of physical blocks */
38 unsigned int nb_boot_blocks; /* number of blocks used by the bios */
39 struct erase_info instr;
40 struct nand_oobinfo oobinfo;
41};
42
43int NFTL_mount(struct NFTLrecord *s);
44int NFTL_formatblock(struct NFTLrecord *s, int block);
45
46#ifndef NFTL_MAJOR
47#define NFTL_MAJOR 93
48#endif
49
50#define MAX_NFTLS 16
51#define MAX_SECTORS_PER_UNIT 64
52#define NFTL_PARTN_BITS 4
53
54#endif /* __MTD_NFTL_H__ */
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
new file mode 100644
index 000000000000..50b2edfc8f11
--- /dev/null
+++ b/include/linux/mtd/partitions.h
@@ -0,0 +1,75 @@
1/*
2 * MTD partitioning layer definitions
3 *
4 * (C) 2000 Nicolas Pitre <nico@cam.org>
5 *
6 * This code is GPL
7 *
8 * $Id: partitions.h,v 1.16 2004/11/16 18:34:40 dwmw2 Exp $
9 */
10
11#ifndef MTD_PARTITIONS_H
12#define MTD_PARTITIONS_H
13
14#include <linux/types.h>
15
16
17/*
18 * Partition definition structure:
19 *
20 * An array of struct partition is passed along with a MTD object to
21 * add_mtd_partitions() to create them.
22 *
23 * For each partition, these fields are available:
24 * name: string that will be used to label the partition's MTD device.
25 * size: the partition size; if defined as MTDPART_SIZ_FULL, the partition
26 * will extend to the end of the master MTD device.
27 * offset: absolute starting position within the master MTD device; if
28 * defined as MTDPART_OFS_APPEND, the partition will start where the
29 * previous one ended; if MTDPART_OFS_NXTBLK, at the next erase block.
30 * mask_flags: contains flags that have to be masked (removed) from the
31 * master MTD flag set for the corresponding MTD partition.
32 * For example, to force a read-only partition, simply adding
33 * MTD_WRITEABLE to the mask_flags will do the trick.
34 *
35 * Note: writeable partitions require their size and offset be
36 * erasesize aligned (e.g. use MTDPART_OFS_NEXTBLK).
37 */
38
39struct mtd_partition {
40 char *name; /* identifier string */
41 u_int32_t size; /* partition size */
42 u_int32_t offset; /* offset within the master MTD space */
43 u_int32_t mask_flags; /* master MTD flags to mask out for this partition */
44 struct nand_oobinfo *oobsel; /* out of band layout for this partition (NAND only)*/
45 struct mtd_info **mtdp; /* pointer to store the MTD object */
46};
47
48#define MTDPART_OFS_NXTBLK (-2)
49#define MTDPART_OFS_APPEND (-1)
50#define MTDPART_SIZ_FULL (0)
51
52
53int add_mtd_partitions(struct mtd_info *, const struct mtd_partition *, int);
54int del_mtd_partitions(struct mtd_info *);
55
56/*
57 * Functions dealing with the various ways of partitioning the space
58 */
59
60struct mtd_part_parser {
61 struct list_head list;
62 struct module *owner;
63 const char *name;
64 int (*parse_fn)(struct mtd_info *, struct mtd_partition **, unsigned long);
65};
66
67extern int register_mtd_parser(struct mtd_part_parser *parser);
68extern int deregister_mtd_parser(struct mtd_part_parser *parser);
69extern int parse_mtd_partitions(struct mtd_info *master, const char **types,
70 struct mtd_partition **pparts, unsigned long origin);
71
72#define put_partition_parser(p) do { module_put((p)->owner); } while(0)
73
74#endif
75
diff --git a/include/linux/mtd/physmap.h b/include/linux/mtd/physmap.h
new file mode 100644
index 000000000000..05aa4970677f
--- /dev/null
+++ b/include/linux/mtd/physmap.h
@@ -0,0 +1,61 @@
1/*
2 * For boards with physically mapped flash and using
3 * drivers/mtd/maps/physmap.c mapping driver.
4 *
5 * $Id: physmap.h,v 1.3 2004/07/21 00:16:15 jwboyer Exp $
6 *
7 * Copyright (C) 2003 MontaVista Software Inc.
8 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */
16
17#ifndef __LINUX_MTD_PHYSMAP__
18
19#include <linux/config.h>
20
21#if defined(CONFIG_MTD_PHYSMAP)
22
23#include <linux/mtd/mtd.h>
24#include <linux/mtd/map.h>
25#include <linux/mtd/partitions.h>
26
27/*
28 * The map_info for physmap. Board can override size, buswidth, phys,
29 * (*set_vpp)(), etc in their initial setup routine.
30 */
31extern struct map_info physmap_map;
32
33/*
34 * Board needs to specify the exact mapping during their setup time.
35 */
36static inline void physmap_configure(unsigned long addr, unsigned long size, int bankwidth, void (*set_vpp)(struct map_info *, int) )
37{
38 physmap_map.phys = addr;
39 physmap_map.size = size;
40 physmap_map.bankwidth = bankwidth;
41 physmap_map.set_vpp = set_vpp;
42}
43
44#if defined(CONFIG_MTD_PARTITIONS)
45
46/*
47 * Machines that wish to do flash partition may want to call this function in
48 * their setup routine.
49 *
50 * physmap_set_partitions(mypartitions, num_parts);
51 *
52 * Note that one can always override this hard-coded partition with
53 * command line partition (you need to enable CONFIG_MTD_CMDLINE_PARTS).
54 */
55void physmap_set_partitions(struct mtd_partition *parts, int num_parts);
56
57#endif /* defined(CONFIG_MTD_PARTITIONS) */
58#endif /* defined(CONFIG_MTD) */
59
60#endif /* __LINUX_MTD_PHYSMAP__ */
61
diff --git a/include/linux/mtd/pmc551.h b/include/linux/mtd/pmc551.h
new file mode 100644
index 000000000000..113e3087f68a
--- /dev/null
+++ b/include/linux/mtd/pmc551.h
@@ -0,0 +1,79 @@
1/*
2 * $Id: pmc551.h,v 1.5 2003/01/24 16:49:53 dwmw2 Exp $
3 *
4 * PMC551 PCI Mezzanine Ram Device
5 *
6 * Author:
7 * Mark Ferrell
8 * Copyright 1999,2000 Nortel Networks
9 *
10 * License:
11 * As part of this driver was derrived from the slram.c driver it falls
12 * under the same license, which is GNU General Public License v2
13 */
14
15#ifndef __MTD_PMC551_H__
16#define __MTD_PMC551_H__
17
18#include <linux/mtd/mtd.h>
19
20#define PMC551_VERSION "$Id: pmc551.h,v 1.5 2003/01/24 16:49:53 dwmw2 Exp $\n"\
21 "Ramix PMC551 PCI Mezzanine Ram Driver. (C) 1999,2000 Nortel Networks.\n"
22
23/*
24 * Our personal and private information
25 */
26struct mypriv {
27 struct pci_dev *dev;
28 u_char *start;
29 u32 base_map0;
30 u32 curr_map0;
31 u32 asize;
32 struct mtd_info *nextpmc551;
33};
34
35/*
36 * Function Prototypes
37 */
38static int pmc551_erase(struct mtd_info *, struct erase_info *);
39static void pmc551_unpoint(struct mtd_info *, u_char *, loff_t, size_t);
40static int pmc551_point (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char **mtdbuf);
41static 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 *);
43
44
45/*
46 * Define the PCI ID's if the kernel doesn't define them for us
47 */
48#ifndef PCI_VENDOR_ID_V3_SEMI
49#define PCI_VENDOR_ID_V3_SEMI 0x11b0
50#endif
51
52#ifndef PCI_DEVICE_ID_V3_SEMI_V370PDC
53#define PCI_DEVICE_ID_V3_SEMI_V370PDC 0x0200
54#endif
55
56
57#define PMC551_PCI_MEM_MAP0 0x50
58#define PMC551_PCI_MEM_MAP1 0x54
59#define PMC551_PCI_MEM_MAP_MAP_ADDR_MASK 0x3ff00000
60#define PMC551_PCI_MEM_MAP_APERTURE_MASK 0x000000f0
61#define PMC551_PCI_MEM_MAP_REG_EN 0x00000002
62#define PMC551_PCI_MEM_MAP_ENABLE 0x00000001
63
64#define PMC551_SDRAM_MA 0x60
65#define PMC551_SDRAM_CMD 0x62
66#define PMC551_DRAM_CFG 0x64
67#define PMC551_SYS_CTRL_REG 0x78
68
69#define PMC551_DRAM_BLK0 0x68
70#define PMC551_DRAM_BLK1 0x6c
71#define PMC551_DRAM_BLK2 0x70
72#define PMC551_DRAM_BLK3 0x74
73#define PMC551_DRAM_BLK_GET_SIZE(x) (524288<<((x>>4)&0x0f))
74#define PMC551_DRAM_BLK_SET_COL_MUX(x,v) (((x) & ~0x00007000) | (((v) & 0x7) << 12))
75#define PMC551_DRAM_BLK_SET_ROW_MUX(x,v) (((x) & ~0x00000f00) | (((v) & 0xf) << 8))
76
77
78#endif /* __MTD_PMC551_H__ */
79
diff --git a/include/linux/mtd/xip.h b/include/linux/mtd/xip.h
new file mode 100644
index 000000000000..fc071125cbcc
--- /dev/null
+++ b/include/linux/mtd/xip.h
@@ -0,0 +1,107 @@
1/*
2 * MTD primitives for XIP support
3 *
4 * Author: Nicolas Pitre
5 * Created: Nov 2, 2004
6 * Copyright: (C) 2004 MontaVista Software, Inc.
7 *
8 * This XIP support for MTD has been loosely inspired
9 * by an earlier patch authored by David Woodhouse.
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 version 2 as
13 * published by the Free Software Foundation.
14 *
15 * $Id: xip.h,v 1.2 2004/12/01 15:49:10 nico Exp $
16 */
17
18#ifndef __LINUX_MTD_XIP_H__
19#define __LINUX_MTD_XIP_H__
20
21#include <linux/config.h>
22
23#ifdef CONFIG_MTD_XIP
24
25/*
26 * Function that are modifying the flash state away from array mode must
27 * obviously not be running from flash. The __xipram is therefore marking
28 * those functions so they get relocated to ram.
29 */
30#define __xipram __attribute__ ((__section__ (".data")))
31
32/*
33 * We really don't want gcc to guess anything.
34 * We absolutely _need_ proper inlining.
35 */
36#include <linux/compiler.h>
37
38/*
39 * Each architecture has to provide the following macros. They must access
40 * the hardware directly and not rely on any other (XIP) functions since they
41 * won't be available when used (flash not in array mode).
42 *
43 * xip_irqpending()
44 *
45 * return non zero when any hardware interrupt is pending.
46 *
47 * xip_currtime()
48 *
49 * return a platform specific time reference to be used with
50 * xip_elapsed_since().
51 *
52 * xip_elapsed_since(x)
53 *
54 * return in usecs the elapsed timebetween now and the reference x as
55 * returned by xip_currtime().
56 *
57 * note 1: convertion to usec can be approximated, as long as the
58 * returned value is <= the real elapsed time.
59 * note 2: this should be able to cope with a few seconds without
60 * overflowing.
61 */
62
63#if defined(CONFIG_ARCH_SA1100) || defined(CONFIG_ARCH_PXA)
64
65#include <asm/hardware.h>
66#ifdef CONFIG_ARCH_PXA
67#include <asm/arch/pxa-regs.h>
68#endif
69
70#define xip_irqpending() (ICIP & ICMR)
71
72/* we sample OSCR and convert desired delta to usec (1/4 ~= 1000000/3686400) */
73#define xip_currtime() (OSCR)
74#define xip_elapsed_since(x) (signed)((OSCR - (x)) / 4)
75
76#else
77
78#warning "missing IRQ and timer primitives for XIP MTD support"
79#warning "some of the XIP MTD support code will be disabled"
80#warning "your system will therefore be unresponsive when writing or erasing flash"
81
82#define xip_irqpending() (0)
83#define xip_currtime() (0)
84#define xip_elapsed_since(x) (0)
85
86#endif
87
88/*
89 * xip_cpu_idle() is used when waiting for a delay equal or larger than
90 * the system timer tick period. This should put the CPU into idle mode
91 * to save power and to be woken up only when some interrupts are pending.
92 * As above, this should not rely upon standard kernel code.
93 */
94
95#if defined(CONFIG_CPU_XSCALE)
96#define xip_cpu_idle() asm volatile ("mcr p14, 0, %0, c7, c0, 0" :: "r" (1))
97#else
98#define xip_cpu_idle() do { } while (0)
99#endif
100
101#else
102
103#define __xipram
104
105#endif /* CONFIG_MTD_XIP */
106
107#endif /* __LINUX_MTD_XIP_H__ */
diff --git a/include/linux/mtio.h b/include/linux/mtio.h
new file mode 100644
index 000000000000..8c66151821e3
--- /dev/null
+++ b/include/linux/mtio.h
@@ -0,0 +1,351 @@
1/*
2 * linux/mtio.h header file for Linux. Written by H. Bergman
3 *
4 * Modified for special ioctls provided by zftape in September 1997
5 * by C.-J. Heine.
6 */
7
8#ifndef _LINUX_MTIO_H
9#define _LINUX_MTIO_H
10
11#include <linux/types.h>
12#include <linux/ioctl.h>
13#include <linux/qic117.h>
14
15/*
16 * Structures and definitions for mag tape io control commands
17 */
18
19/* structure for MTIOCTOP - mag tape op command */
20struct mtop {
21 short mt_op; /* operations defined below */
22 int mt_count; /* how many of them */
23};
24
25/* Magnetic Tape operations [Not all operations supported by all drivers]: */
26#define MTRESET 0 /* +reset drive in case of problems */
27#define MTFSF 1 /* forward space over FileMark,
28 * position at first record of next file
29 */
30#define MTBSF 2 /* backward space FileMark (position before FM) */
31#define MTFSR 3 /* forward space record */
32#define MTBSR 4 /* backward space record */
33#define MTWEOF 5 /* write an end-of-file record (mark) */
34#define MTREW 6 /* rewind */
35#define MTOFFL 7 /* rewind and put the drive offline (eject?) */
36#define MTNOP 8 /* no op, set status only (read with MTIOCGET) */
37#define MTRETEN 9 /* retension tape */
38#define MTBSFM 10 /* +backward space FileMark, position at FM */
39#define MTFSFM 11 /* +forward space FileMark, position at FM */
40#define MTEOM 12 /* goto end of recorded media (for appending files).
41 * MTEOM positions after the last FM, ready for
42 * appending another file.
43 */
44#define MTERASE 13 /* erase tape -- be careful! */
45
46#define MTRAS1 14 /* run self test 1 (nondestructive) */
47#define MTRAS2 15 /* run self test 2 (destructive) */
48#define MTRAS3 16 /* reserved for self test 3 */
49
50#define MTSETBLK 20 /* set block length (SCSI) */
51#define MTSETDENSITY 21 /* set tape density (SCSI) */
52#define MTSEEK 22 /* seek to block (Tandberg, etc.) */
53#define MTTELL 23 /* tell block (Tandberg, etc.) */
54#define MTSETDRVBUFFER 24 /* set the drive buffering according to SCSI-2 */
55 /* ordinary buffered operation with code 1 */
56#define MTFSS 25 /* space forward over setmarks */
57#define MTBSS 26 /* space backward over setmarks */
58#define MTWSM 27 /* write setmarks */
59
60#define MTLOCK 28 /* lock the drive door */
61#define MTUNLOCK 29 /* unlock the drive door */
62#define MTLOAD 30 /* execute the SCSI load command */
63#define MTUNLOAD 31 /* execute the SCSI unload command */
64#define MTCOMPRESSION 32/* control compression with SCSI mode page 15 */
65#define MTSETPART 33 /* Change the active tape partition */
66#define MTMKPART 34 /* Format the tape with one or two partitions */
67
68/* structure for MTIOCGET - mag tape get status command */
69
70struct mtget {
71 long mt_type; /* type of magtape device */
72 long mt_resid; /* residual count: (not sure)
73 * number of bytes ignored, or
74 * number of files not skipped, or
75 * number of records not skipped.
76 */
77 /* the following registers are device dependent */
78 long mt_dsreg; /* status register */
79 long mt_gstat; /* generic (device independent) status */
80 long mt_erreg; /* error register */
81 /* The next two fields are not always used */
82 __kernel_daddr_t mt_fileno; /* number of current file on tape */
83 __kernel_daddr_t mt_blkno; /* current block number */
84};
85
86
87
88/*
89 * Constants for mt_type. Not all of these are supported,
90 * and these are not all of the ones that are supported.
91 */
92#define MT_ISUNKNOWN 0x01
93#define MT_ISQIC02 0x02 /* Generic QIC-02 tape streamer */
94#define MT_ISWT5150 0x03 /* Wangtek 5150EQ, QIC-150, QIC-02 */
95#define MT_ISARCHIVE_5945L2 0x04 /* Archive 5945L-2, QIC-24, QIC-02? */
96#define MT_ISCMSJ500 0x05 /* CMS Jumbo 500 (QIC-02?) */
97#define MT_ISTDC3610 0x06 /* Tandberg 6310, QIC-24 */
98#define MT_ISARCHIVE_VP60I 0x07 /* Archive VP60i, QIC-02 */
99#define MT_ISARCHIVE_2150L 0x08 /* Archive Viper 2150L */
100#define MT_ISARCHIVE_2060L 0x09 /* Archive Viper 2060L */
101#define MT_ISARCHIVESC499 0x0A /* Archive SC-499 QIC-36 controller */
102#define MT_ISQIC02_ALL_FEATURES 0x0F /* Generic QIC-02 with all features */
103#define MT_ISWT5099EEN24 0x11 /* Wangtek 5099-een24, 60MB, QIC-24 */
104#define MT_ISTEAC_MT2ST 0x12 /* Teac MT-2ST 155mb drive, Teac DC-1 card (Wangtek type) */
105#define MT_ISEVEREX_FT40A 0x32 /* Everex FT40A (QIC-40) */
106#define MT_ISDDS1 0x51 /* DDS device without partitions */
107#define MT_ISDDS2 0x52 /* DDS device with partitions */
108#define MT_ISONSTREAM_SC 0x61 /* OnStream SCSI tape drives (SC-x0)
109 and SCSI emulated (DI, DP, USB) */
110#define MT_ISSCSI1 0x71 /* Generic ANSI SCSI-1 tape unit */
111#define MT_ISSCSI2 0x72 /* Generic ANSI SCSI-2 tape unit */
112
113/* QIC-40/80/3010/3020 ftape supported drives.
114 * 20bit vendor ID + 0x800000 (see ftape-vendors.h)
115 */
116#define MT_ISFTAPE_UNKNOWN 0x800000 /* obsolete */
117#define MT_ISFTAPE_FLAG 0x800000
118
119struct mt_tape_info {
120 long t_type; /* device type id (mt_type) */
121 char *t_name; /* descriptive name */
122};
123
124#define MT_TAPE_INFO { \
125 {MT_ISUNKNOWN, "Unknown type of tape device"}, \
126 {MT_ISQIC02, "Generic QIC-02 tape streamer"}, \
127 {MT_ISWT5150, "Wangtek 5150, QIC-150"}, \
128 {MT_ISARCHIVE_5945L2, "Archive 5945L-2"}, \
129 {MT_ISCMSJ500, "CMS Jumbo 500"}, \
130 {MT_ISTDC3610, "Tandberg TDC 3610, QIC-24"}, \
131 {MT_ISARCHIVE_VP60I, "Archive VP60i, QIC-02"}, \
132 {MT_ISARCHIVE_2150L, "Archive Viper 2150L"}, \
133 {MT_ISARCHIVE_2060L, "Archive Viper 2060L"}, \
134 {MT_ISARCHIVESC499, "Archive SC-499 QIC-36 controller"}, \
135 {MT_ISQIC02_ALL_FEATURES, "Generic QIC-02 tape, all features"}, \
136 {MT_ISWT5099EEN24, "Wangtek 5099-een24, 60MB"}, \
137 {MT_ISTEAC_MT2ST, "Teac MT-2ST 155mb data cassette drive"}, \
138 {MT_ISEVEREX_FT40A, "Everex FT40A, QIC-40"}, \
139 {MT_ISONSTREAM_SC, "OnStream SC-, DI-, DP-, or USB tape drive"}, \
140 {MT_ISSCSI1, "Generic SCSI-1 tape"}, \
141 {MT_ISSCSI2, "Generic SCSI-2 tape"}, \
142 {0, NULL} \
143}
144
145
146/* structure for MTIOCPOS - mag tape get position command */
147
148struct mtpos {
149 long mt_blkno; /* current block number */
150};
151
152
153/* structure for MTIOCVOLINFO, query information about the volume
154 * currently positioned at (zftape)
155 */
156struct mtvolinfo {
157 unsigned int mt_volno; /* vol-number */
158 unsigned int mt_blksz; /* blocksize used when recording */
159 unsigned int mt_rawsize; /* raw tape space consumed, in kb */
160 unsigned int mt_size; /* volume size after decompression, in kb */
161 unsigned int mt_cmpr:1; /* this volume has been compressed */
162};
163
164/* raw access to a floppy drive, read and write an arbitrary segment.
165 * For ftape/zftape to support formatting etc.
166 */
167#define MT_FT_RD_SINGLE 0
168#define MT_FT_RD_AHEAD 1
169#define MT_FT_WR_ASYNC 0 /* start tape only when all buffers are full */
170#define MT_FT_WR_MULTI 1 /* start tape, continue until buffers are empty */
171#define MT_FT_WR_SINGLE 2 /* write a single segment and stop afterwards */
172#define MT_FT_WR_DELETE 3 /* write deleted data marks, one segment at time */
173
174struct mtftseg
175{
176 unsigned mt_segno; /* the segment to read or write */
177 unsigned mt_mode; /* modes for read/write (sync/async etc.) */
178 int mt_result; /* result of r/w request, not of the ioctl */
179 void __user *mt_data; /* User space buffer: must be 29kb */
180};
181
182/* get tape capacity (ftape/zftape)
183 */
184struct mttapesize {
185 unsigned long mt_capacity; /* entire, uncompressed capacity
186 * of a cartridge
187 */
188 unsigned long mt_used; /* what has been used so far, raw
189 * uncompressed amount
190 */
191};
192
193/* possible values of the ftfmt_op field
194 */
195#define FTFMT_SET_PARMS 1 /* set software parms */
196#define FTFMT_GET_PARMS 2 /* get software parms */
197#define FTFMT_FORMAT_TRACK 3 /* start formatting a tape track */
198#define FTFMT_STATUS 4 /* monitor formatting a tape track */
199#define FTFMT_VERIFY 5 /* verify the given segment */
200
201struct ftfmtparms {
202 unsigned char ft_qicstd; /* QIC-40/QIC-80/QIC-3010/QIC-3020 */
203 unsigned char ft_fmtcode; /* Refer to the QIC specs */
204 unsigned char ft_fhm; /* floppy head max */
205 unsigned char ft_ftm; /* floppy track max */
206 unsigned short ft_spt; /* segments per track */
207 unsigned short ft_tpc; /* tracks per cartridge */
208};
209
210struct ftfmttrack {
211 unsigned int ft_track; /* track to format */
212 unsigned char ft_gap3; /* size of gap3, for FORMAT_TRK */
213};
214
215struct ftfmtstatus {
216 unsigned int ft_segment; /* segment currently being formatted */
217};
218
219struct ftfmtverify {
220 unsigned int ft_segment; /* segment to verify */
221 unsigned long ft_bsm; /* bsm as result of VERIFY cmd */
222};
223
224struct mtftformat {
225 unsigned int fmt_op; /* operation to perform */
226 union fmt_arg {
227 struct ftfmtparms fmt_parms; /* format parameters */
228 struct ftfmttrack fmt_track; /* ctrl while formatting */
229 struct ftfmtstatus fmt_status;
230 struct ftfmtverify fmt_verify; /* for verifying */
231 } fmt_arg;
232};
233
234struct mtftcmd {
235 unsigned int ft_wait_before; /* timeout to wait for drive to get ready
236 * before command is sent. Milliseconds
237 */
238 qic117_cmd_t ft_cmd; /* command to send */
239 unsigned char ft_parm_cnt; /* zero: no parm is sent. */
240 unsigned char ft_parms[3]; /* parameter(s) to send to
241 * the drive. The parms are nibbles
242 * driver sends cmd + 2 step pulses */
243 unsigned int ft_result_bits; /* if non zero, number of bits
244 * returned by the tape drive
245 */
246 unsigned int ft_result; /* the result returned by the tape drive*/
247 unsigned int ft_wait_after; /* timeout to wait for drive to get ready
248 * after command is sent. 0: don't wait */
249 int ft_status; /* status returned by ready wait
250 * undefined if timeout was 0.
251 */
252 int ft_error; /* error code if error status was set by
253 * command
254 */
255};
256
257/* mag tape io control commands */
258#define MTIOCTOP _IOW('m', 1, struct mtop) /* do a mag tape op */
259#define MTIOCGET _IOR('m', 2, struct mtget) /* get tape status */
260#define MTIOCPOS _IOR('m', 3, struct mtpos) /* get tape position */
261
262/* The next two are used by the QIC-02 driver for runtime reconfiguration.
263 * See tpqic02.h for struct mtconfiginfo.
264 */
265#define MTIOCGETCONFIG _IOR('m', 4, struct mtconfiginfo) /* get tape config */
266#define MTIOCSETCONFIG _IOW('m', 5, struct mtconfiginfo) /* set tape config */
267
268/* the next six are used by the floppy ftape drivers and its frontends
269 * sorry, but MTIOCTOP commands are write only.
270 */
271#define MTIOCRDFTSEG _IOWR('m', 6, struct mtftseg) /* read a segment */
272#define MTIOCWRFTSEG _IOWR('m', 7, struct mtftseg) /* write a segment */
273#define MTIOCVOLINFO _IOR('m', 8, struct mtvolinfo) /* info about volume */
274#define MTIOCGETSIZE _IOR('m', 9, struct mttapesize)/* get cartridge size*/
275#define MTIOCFTFORMAT _IOWR('m', 10, struct mtftformat) /* format ftape */
276#define MTIOCFTCMD _IOWR('m', 11, struct mtftcmd) /* send QIC-117 cmd */
277
278/* Generic Mag Tape (device independent) status macros for examining
279 * mt_gstat -- HP-UX compatible.
280 * There is room for more generic status bits here, but I don't
281 * know which of them are reserved. At least three or so should
282 * be added to make this really useful.
283 */
284#define GMT_EOF(x) ((x) & 0x80000000)
285#define GMT_BOT(x) ((x) & 0x40000000)
286#define GMT_EOT(x) ((x) & 0x20000000)
287#define GMT_SM(x) ((x) & 0x10000000) /* DDS setmark */
288#define GMT_EOD(x) ((x) & 0x08000000) /* DDS EOD */
289#define GMT_WR_PROT(x) ((x) & 0x04000000)
290/* #define GMT_ ? ((x) & 0x02000000) */
291#define GMT_ONLINE(x) ((x) & 0x01000000)
292#define GMT_D_6250(x) ((x) & 0x00800000)
293#define GMT_D_1600(x) ((x) & 0x00400000)
294#define GMT_D_800(x) ((x) & 0x00200000)
295/* #define GMT_ ? ((x) & 0x00100000) */
296/* #define GMT_ ? ((x) & 0x00080000) */
297#define GMT_DR_OPEN(x) ((x) & 0x00040000) /* door open (no tape) */
298/* #define GMT_ ? ((x) & 0x00020000) */
299#define GMT_IM_REP_EN(x) ((x) & 0x00010000) /* immediate report mode */
300#define GMT_CLN(x) ((x) & 0x00008000) /* cleaning requested */
301/* 15 generic status bits unused */
302
303
304/* SCSI-tape specific definitions */
305/* Bitfield shifts in the status */
306#define MT_ST_BLKSIZE_SHIFT 0
307#define MT_ST_BLKSIZE_MASK 0xffffff
308#define MT_ST_DENSITY_SHIFT 24
309#define MT_ST_DENSITY_MASK 0xff000000
310
311#define MT_ST_SOFTERR_SHIFT 0
312#define MT_ST_SOFTERR_MASK 0xffff
313
314/* Bitfields for the MTSETDRVBUFFER ioctl */
315#define MT_ST_OPTIONS 0xf0000000
316#define MT_ST_BOOLEANS 0x10000000
317#define MT_ST_SETBOOLEANS 0x30000000
318#define MT_ST_CLEARBOOLEANS 0x40000000
319#define MT_ST_WRITE_THRESHOLD 0x20000000
320#define MT_ST_DEF_BLKSIZE 0x50000000
321#define MT_ST_DEF_OPTIONS 0x60000000
322#define MT_ST_TIMEOUTS 0x70000000
323#define MT_ST_SET_TIMEOUT (MT_ST_TIMEOUTS | 0x000000)
324#define MT_ST_SET_LONG_TIMEOUT (MT_ST_TIMEOUTS | 0x100000)
325#define MT_ST_SET_CLN 0x80000000
326
327#define MT_ST_BUFFER_WRITES 0x1
328#define MT_ST_ASYNC_WRITES 0x2
329#define MT_ST_READ_AHEAD 0x4
330#define MT_ST_DEBUGGING 0x8
331#define MT_ST_TWO_FM 0x10
332#define MT_ST_FAST_MTEOM 0x20
333#define MT_ST_AUTO_LOCK 0x40
334#define MT_ST_DEF_WRITES 0x80
335#define MT_ST_CAN_BSR 0x100
336#define MT_ST_NO_BLKLIMS 0x200
337#define MT_ST_CAN_PARTITIONS 0x400
338#define MT_ST_SCSI2LOGICAL 0x800
339#define MT_ST_SYSV 0x1000
340#define MT_ST_NOWAIT 0x2000
341
342/* The mode parameters to be controlled. Parameter chosen with bits 20-28 */
343#define MT_ST_CLEAR_DEFAULT 0xfffff
344#define MT_ST_DEF_DENSITY (MT_ST_DEF_OPTIONS | 0x100000)
345#define MT_ST_DEF_COMPRESSION (MT_ST_DEF_OPTIONS | 0x200000)
346#define MT_ST_DEF_DRVBUFFER (MT_ST_DEF_OPTIONS | 0x300000)
347
348/* The offset for the arguments for the special HP changer load command. */
349#define MT_ST_HPLOADER_OFFSET 10000
350
351#endif /* _LINUX_MTIO_H */
diff --git a/include/linux/mv643xx.h b/include/linux/mv643xx.h
new file mode 100644
index 000000000000..5773ea42f6e4
--- /dev/null
+++ b/include/linux/mv643xx.h
@@ -0,0 +1,1313 @@
1/*
2 * mv643xx.h - MV-643XX Internal registers definition file.
3 *
4 * Copyright 2002 Momentum Computer, Inc.
5 * Author: Matthew Dharm <mdharm@momenco.com>
6 * Copyright 2002 GALILEO TECHNOLOGY, LTD.
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 of the License, or (at your
11 * option) any later version.
12 */
13#ifndef __ASM_MV643XX_H
14#define __ASM_MV643XX_H
15
16#ifdef __MIPS__
17#include <asm/addrspace.h>
18#include <asm/marvell.h>
19#endif
20#include <asm/types.h>
21
22/****************************************/
23/* Processor Address Space */
24/****************************************/
25
26/* DDR SDRAM BAR and size registers */
27
28#define MV64340_CS_0_BASE_ADDR 0x008
29#define MV64340_CS_0_SIZE 0x010
30#define MV64340_CS_1_BASE_ADDR 0x208
31#define MV64340_CS_1_SIZE 0x210
32#define MV64340_CS_2_BASE_ADDR 0x018
33#define MV64340_CS_2_SIZE 0x020
34#define MV64340_CS_3_BASE_ADDR 0x218
35#define MV64340_CS_3_SIZE 0x220
36
37/* Devices BAR and size registers */
38
39#define MV64340_DEV_CS0_BASE_ADDR 0x028
40#define MV64340_DEV_CS0_SIZE 0x030
41#define MV64340_DEV_CS1_BASE_ADDR 0x228
42#define MV64340_DEV_CS1_SIZE 0x230
43#define MV64340_DEV_CS2_BASE_ADDR 0x248
44#define MV64340_DEV_CS2_SIZE 0x250
45#define MV64340_DEV_CS3_BASE_ADDR 0x038
46#define MV64340_DEV_CS3_SIZE 0x040
47#define MV64340_BOOTCS_BASE_ADDR 0x238
48#define MV64340_BOOTCS_SIZE 0x240
49
50/* PCI 0 BAR and size registers */
51
52#define MV64340_PCI_0_IO_BASE_ADDR 0x048
53#define MV64340_PCI_0_IO_SIZE 0x050
54#define MV64340_PCI_0_MEMORY0_BASE_ADDR 0x058
55#define MV64340_PCI_0_MEMORY0_SIZE 0x060
56#define MV64340_PCI_0_MEMORY1_BASE_ADDR 0x080
57#define MV64340_PCI_0_MEMORY1_SIZE 0x088
58#define MV64340_PCI_0_MEMORY2_BASE_ADDR 0x258
59#define MV64340_PCI_0_MEMORY2_SIZE 0x260
60#define MV64340_PCI_0_MEMORY3_BASE_ADDR 0x280
61#define MV64340_PCI_0_MEMORY3_SIZE 0x288
62
63/* PCI 1 BAR and size registers */
64#define MV64340_PCI_1_IO_BASE_ADDR 0x090
65#define MV64340_PCI_1_IO_SIZE 0x098
66#define MV64340_PCI_1_MEMORY0_BASE_ADDR 0x0a0
67#define MV64340_PCI_1_MEMORY0_SIZE 0x0a8
68#define MV64340_PCI_1_MEMORY1_BASE_ADDR 0x0b0
69#define MV64340_PCI_1_MEMORY1_SIZE 0x0b8
70#define MV64340_PCI_1_MEMORY2_BASE_ADDR 0x2a0
71#define MV64340_PCI_1_MEMORY2_SIZE 0x2a8
72#define MV64340_PCI_1_MEMORY3_BASE_ADDR 0x2b0
73#define MV64340_PCI_1_MEMORY3_SIZE 0x2b8
74
75/* SRAM base address */
76#define MV64340_INTEGRATED_SRAM_BASE_ADDR 0x268
77
78/* internal registers space base address */
79#define MV64340_INTERNAL_SPACE_BASE_ADDR 0x068
80
81/* Enables the CS , DEV_CS , PCI 0 and PCI 1
82 windows above */
83#define MV64340_BASE_ADDR_ENABLE 0x278
84
85/****************************************/
86/* PCI remap registers */
87/****************************************/
88 /* PCI 0 */
89#define MV64340_PCI_0_IO_ADDR_REMAP 0x0f0
90#define MV64340_PCI_0_MEMORY0_LOW_ADDR_REMAP 0x0f8
91#define MV64340_PCI_0_MEMORY0_HIGH_ADDR_REMAP 0x320
92#define MV64340_PCI_0_MEMORY1_LOW_ADDR_REMAP 0x100
93#define MV64340_PCI_0_MEMORY1_HIGH_ADDR_REMAP 0x328
94#define MV64340_PCI_0_MEMORY2_LOW_ADDR_REMAP 0x2f8
95#define MV64340_PCI_0_MEMORY2_HIGH_ADDR_REMAP 0x330
96#define MV64340_PCI_0_MEMORY3_LOW_ADDR_REMAP 0x300
97#define MV64340_PCI_0_MEMORY3_HIGH_ADDR_REMAP 0x338
98 /* PCI 1 */
99#define MV64340_PCI_1_IO_ADDR_REMAP 0x108
100#define MV64340_PCI_1_MEMORY0_LOW_ADDR_REMAP 0x110
101#define MV64340_PCI_1_MEMORY0_HIGH_ADDR_REMAP 0x340
102#define MV64340_PCI_1_MEMORY1_LOW_ADDR_REMAP 0x118
103#define MV64340_PCI_1_MEMORY1_HIGH_ADDR_REMAP 0x348
104#define MV64340_PCI_1_MEMORY2_LOW_ADDR_REMAP 0x310
105#define MV64340_PCI_1_MEMORY2_HIGH_ADDR_REMAP 0x350
106#define MV64340_PCI_1_MEMORY3_LOW_ADDR_REMAP 0x318
107#define MV64340_PCI_1_MEMORY3_HIGH_ADDR_REMAP 0x358
108
109#define MV64340_CPU_PCI_0_HEADERS_RETARGET_CONTROL 0x3b0
110#define MV64340_CPU_PCI_0_HEADERS_RETARGET_BASE 0x3b8
111#define MV64340_CPU_PCI_1_HEADERS_RETARGET_CONTROL 0x3c0
112#define MV64340_CPU_PCI_1_HEADERS_RETARGET_BASE 0x3c8
113#define MV64340_CPU_GE_HEADERS_RETARGET_CONTROL 0x3d0
114#define MV64340_CPU_GE_HEADERS_RETARGET_BASE 0x3d8
115#define MV64340_CPU_IDMA_HEADERS_RETARGET_CONTROL 0x3e0
116#define MV64340_CPU_IDMA_HEADERS_RETARGET_BASE 0x3e8
117
118/****************************************/
119/* CPU Control Registers */
120/****************************************/
121
122#define MV64340_CPU_CONFIG 0x000
123#define MV64340_CPU_MODE 0x120
124#define MV64340_CPU_MASTER_CONTROL 0x160
125#define MV64340_CPU_CROSS_BAR_CONTROL_LOW 0x150
126#define MV64340_CPU_CROSS_BAR_CONTROL_HIGH 0x158
127#define MV64340_CPU_CROSS_BAR_TIMEOUT 0x168
128
129/****************************************/
130/* SMP RegisterS */
131/****************************************/
132
133#define MV64340_SMP_WHO_AM_I 0x200
134#define MV64340_SMP_CPU0_DOORBELL 0x214
135#define MV64340_SMP_CPU0_DOORBELL_CLEAR 0x21C
136#define MV64340_SMP_CPU1_DOORBELL 0x224
137#define MV64340_SMP_CPU1_DOORBELL_CLEAR 0x22C
138#define MV64340_SMP_CPU0_DOORBELL_MASK 0x234
139#define MV64340_SMP_CPU1_DOORBELL_MASK 0x23C
140#define MV64340_SMP_SEMAPHOR0 0x244
141#define MV64340_SMP_SEMAPHOR1 0x24c
142#define MV64340_SMP_SEMAPHOR2 0x254
143#define MV64340_SMP_SEMAPHOR3 0x25c
144#define MV64340_SMP_SEMAPHOR4 0x264
145#define MV64340_SMP_SEMAPHOR5 0x26c
146#define MV64340_SMP_SEMAPHOR6 0x274
147#define MV64340_SMP_SEMAPHOR7 0x27c
148
149/****************************************/
150/* CPU Sync Barrier Register */
151/****************************************/
152
153#define MV64340_CPU_0_SYNC_BARRIER_TRIGGER 0x0c0
154#define MV64340_CPU_0_SYNC_BARRIER_VIRTUAL 0x0c8
155#define MV64340_CPU_1_SYNC_BARRIER_TRIGGER 0x0d0
156#define MV64340_CPU_1_SYNC_BARRIER_VIRTUAL 0x0d8
157
158/****************************************/
159/* CPU Access Protect */
160/****************************************/
161
162#define MV64340_CPU_PROTECT_WINDOW_0_BASE_ADDR 0x180
163#define MV64340_CPU_PROTECT_WINDOW_0_SIZE 0x188
164#define MV64340_CPU_PROTECT_WINDOW_1_BASE_ADDR 0x190
165#define MV64340_CPU_PROTECT_WINDOW_1_SIZE 0x198
166#define MV64340_CPU_PROTECT_WINDOW_2_BASE_ADDR 0x1a0
167#define MV64340_CPU_PROTECT_WINDOW_2_SIZE 0x1a8
168#define MV64340_CPU_PROTECT_WINDOW_3_BASE_ADDR 0x1b0
169#define MV64340_CPU_PROTECT_WINDOW_3_SIZE 0x1b8
170
171
172/****************************************/
173/* CPU Error Report */
174/****************************************/
175
176#define MV64340_CPU_ERROR_ADDR_LOW 0x070
177#define MV64340_CPU_ERROR_ADDR_HIGH 0x078
178#define MV64340_CPU_ERROR_DATA_LOW 0x128
179#define MV64340_CPU_ERROR_DATA_HIGH 0x130
180#define MV64340_CPU_ERROR_PARITY 0x138
181#define MV64340_CPU_ERROR_CAUSE 0x140
182#define MV64340_CPU_ERROR_MASK 0x148
183
184/****************************************/
185/* CPU Interface Debug Registers */
186/****************************************/
187
188#define MV64340_PUNIT_SLAVE_DEBUG_LOW 0x360
189#define MV64340_PUNIT_SLAVE_DEBUG_HIGH 0x368
190#define MV64340_PUNIT_MASTER_DEBUG_LOW 0x370
191#define MV64340_PUNIT_MASTER_DEBUG_HIGH 0x378
192#define MV64340_PUNIT_MMASK 0x3e4
193
194/****************************************/
195/* Integrated SRAM Registers */
196/****************************************/
197
198#define MV64340_SRAM_CONFIG 0x380
199#define MV64340_SRAM_TEST_MODE 0X3F4
200#define MV64340_SRAM_ERROR_CAUSE 0x388
201#define MV64340_SRAM_ERROR_ADDR 0x390
202#define MV64340_SRAM_ERROR_ADDR_HIGH 0X3F8
203#define MV64340_SRAM_ERROR_DATA_LOW 0x398
204#define MV64340_SRAM_ERROR_DATA_HIGH 0x3a0
205#define MV64340_SRAM_ERROR_DATA_PARITY 0x3a8
206
207/****************************************/
208/* SDRAM Configuration */
209/****************************************/
210
211#define MV64340_SDRAM_CONFIG 0x1400
212#define MV64340_D_UNIT_CONTROL_LOW 0x1404
213#define MV64340_D_UNIT_CONTROL_HIGH 0x1424
214#define MV64340_SDRAM_TIMING_CONTROL_LOW 0x1408
215#define MV64340_SDRAM_TIMING_CONTROL_HIGH 0x140c
216#define MV64340_SDRAM_ADDR_CONTROL 0x1410
217#define MV64340_SDRAM_OPEN_PAGES_CONTROL 0x1414
218#define MV64340_SDRAM_OPERATION 0x1418
219#define MV64340_SDRAM_MODE 0x141c
220#define MV64340_EXTENDED_DRAM_MODE 0x1420
221#define MV64340_SDRAM_CROSS_BAR_CONTROL_LOW 0x1430
222#define MV64340_SDRAM_CROSS_BAR_CONTROL_HIGH 0x1434
223#define MV64340_SDRAM_CROSS_BAR_TIMEOUT 0x1438
224#define MV64340_SDRAM_ADDR_CTRL_PADS_CALIBRATION 0x14c0
225#define MV64340_SDRAM_DATA_PADS_CALIBRATION 0x14c4
226
227/****************************************/
228/* SDRAM Error Report */
229/****************************************/
230
231#define MV64340_SDRAM_ERROR_DATA_LOW 0x1444
232#define MV64340_SDRAM_ERROR_DATA_HIGH 0x1440
233#define MV64340_SDRAM_ERROR_ADDR 0x1450
234#define MV64340_SDRAM_RECEIVED_ECC 0x1448
235#define MV64340_SDRAM_CALCULATED_ECC 0x144c
236#define MV64340_SDRAM_ECC_CONTROL 0x1454
237#define MV64340_SDRAM_ECC_ERROR_COUNTER 0x1458
238
239/******************************************/
240/* Controlled Delay Line (CDL) Registers */
241/******************************************/
242
243#define MV64340_DFCDL_CONFIG0 0x1480
244#define MV64340_DFCDL_CONFIG1 0x1484
245#define MV64340_DLL_WRITE 0x1488
246#define MV64340_DLL_READ 0x148c
247#define MV64340_SRAM_ADDR 0x1490
248#define MV64340_SRAM_DATA0 0x1494
249#define MV64340_SRAM_DATA1 0x1498
250#define MV64340_SRAM_DATA2 0x149c
251#define MV64340_DFCL_PROBE 0x14a0
252
253/******************************************/
254/* Debug Registers */
255/******************************************/
256
257#define MV64340_DUNIT_DEBUG_LOW 0x1460
258#define MV64340_DUNIT_DEBUG_HIGH 0x1464
259#define MV64340_DUNIT_MMASK 0X1b40
260
261/****************************************/
262/* Device Parameters */
263/****************************************/
264
265#define MV64340_DEVICE_BANK0_PARAMETERS 0x45c
266#define MV64340_DEVICE_BANK1_PARAMETERS 0x460
267#define MV64340_DEVICE_BANK2_PARAMETERS 0x464
268#define MV64340_DEVICE_BANK3_PARAMETERS 0x468
269#define MV64340_DEVICE_BOOT_BANK_PARAMETERS 0x46c
270#define MV64340_DEVICE_INTERFACE_CONTROL 0x4c0
271#define MV64340_DEVICE_INTERFACE_CROSS_BAR_CONTROL_LOW 0x4c8
272#define MV64340_DEVICE_INTERFACE_CROSS_BAR_CONTROL_HIGH 0x4cc
273#define MV64340_DEVICE_INTERFACE_CROSS_BAR_TIMEOUT 0x4c4
274
275/****************************************/
276/* Device interrupt registers */
277/****************************************/
278
279#define MV64340_DEVICE_INTERRUPT_CAUSE 0x4d0
280#define MV64340_DEVICE_INTERRUPT_MASK 0x4d4
281#define MV64340_DEVICE_ERROR_ADDR 0x4d8
282#define MV64340_DEVICE_ERROR_DATA 0x4dc
283#define MV64340_DEVICE_ERROR_PARITY 0x4e0
284
285/****************************************/
286/* Device debug registers */
287/****************************************/
288
289#define MV64340_DEVICE_DEBUG_LOW 0x4e4
290#define MV64340_DEVICE_DEBUG_HIGH 0x4e8
291#define MV64340_RUNIT_MMASK 0x4f0
292
293/****************************************/
294/* PCI Slave Address Decoding registers */
295/****************************************/
296
297#define MV64340_PCI_0_CS_0_BANK_SIZE 0xc08
298#define MV64340_PCI_1_CS_0_BANK_SIZE 0xc88
299#define MV64340_PCI_0_CS_1_BANK_SIZE 0xd08
300#define MV64340_PCI_1_CS_1_BANK_SIZE 0xd88
301#define MV64340_PCI_0_CS_2_BANK_SIZE 0xc0c
302#define MV64340_PCI_1_CS_2_BANK_SIZE 0xc8c
303#define MV64340_PCI_0_CS_3_BANK_SIZE 0xd0c
304#define MV64340_PCI_1_CS_3_BANK_SIZE 0xd8c
305#define MV64340_PCI_0_DEVCS_0_BANK_SIZE 0xc10
306#define MV64340_PCI_1_DEVCS_0_BANK_SIZE 0xc90
307#define MV64340_PCI_0_DEVCS_1_BANK_SIZE 0xd10
308#define MV64340_PCI_1_DEVCS_1_BANK_SIZE 0xd90
309#define MV64340_PCI_0_DEVCS_2_BANK_SIZE 0xd18
310#define MV64340_PCI_1_DEVCS_2_BANK_SIZE 0xd98
311#define MV64340_PCI_0_DEVCS_3_BANK_SIZE 0xc14
312#define MV64340_PCI_1_DEVCS_3_BANK_SIZE 0xc94
313#define MV64340_PCI_0_DEVCS_BOOT_BANK_SIZE 0xd14
314#define MV64340_PCI_1_DEVCS_BOOT_BANK_SIZE 0xd94
315#define MV64340_PCI_0_P2P_MEM0_BAR_SIZE 0xd1c
316#define MV64340_PCI_1_P2P_MEM0_BAR_SIZE 0xd9c
317#define MV64340_PCI_0_P2P_MEM1_BAR_SIZE 0xd20
318#define MV64340_PCI_1_P2P_MEM1_BAR_SIZE 0xda0
319#define MV64340_PCI_0_P2P_I_O_BAR_SIZE 0xd24
320#define MV64340_PCI_1_P2P_I_O_BAR_SIZE 0xda4
321#define MV64340_PCI_0_CPU_BAR_SIZE 0xd28
322#define MV64340_PCI_1_CPU_BAR_SIZE 0xda8
323#define MV64340_PCI_0_INTERNAL_SRAM_BAR_SIZE 0xe00
324#define MV64340_PCI_1_INTERNAL_SRAM_BAR_SIZE 0xe80
325#define MV64340_PCI_0_EXPANSION_ROM_BAR_SIZE 0xd2c
326#define MV64340_PCI_1_EXPANSION_ROM_BAR_SIZE 0xd9c
327#define MV64340_PCI_0_BASE_ADDR_REG_ENABLE 0xc3c
328#define MV64340_PCI_1_BASE_ADDR_REG_ENABLE 0xcbc
329#define MV64340_PCI_0_CS_0_BASE_ADDR_REMAP 0xc48
330#define MV64340_PCI_1_CS_0_BASE_ADDR_REMAP 0xcc8
331#define MV64340_PCI_0_CS_1_BASE_ADDR_REMAP 0xd48
332#define MV64340_PCI_1_CS_1_BASE_ADDR_REMAP 0xdc8
333#define MV64340_PCI_0_CS_2_BASE_ADDR_REMAP 0xc4c
334#define MV64340_PCI_1_CS_2_BASE_ADDR_REMAP 0xccc
335#define MV64340_PCI_0_CS_3_BASE_ADDR_REMAP 0xd4c
336#define MV64340_PCI_1_CS_3_BASE_ADDR_REMAP 0xdcc
337#define MV64340_PCI_0_CS_0_BASE_HIGH_ADDR_REMAP 0xF04
338#define MV64340_PCI_1_CS_0_BASE_HIGH_ADDR_REMAP 0xF84
339#define MV64340_PCI_0_CS_1_BASE_HIGH_ADDR_REMAP 0xF08
340#define MV64340_PCI_1_CS_1_BASE_HIGH_ADDR_REMAP 0xF88
341#define MV64340_PCI_0_CS_2_BASE_HIGH_ADDR_REMAP 0xF0C
342#define MV64340_PCI_1_CS_2_BASE_HIGH_ADDR_REMAP 0xF8C
343#define MV64340_PCI_0_CS_3_BASE_HIGH_ADDR_REMAP 0xF10
344#define MV64340_PCI_1_CS_3_BASE_HIGH_ADDR_REMAP 0xF90
345#define MV64340_PCI_0_DEVCS_0_BASE_ADDR_REMAP 0xc50
346#define MV64340_PCI_1_DEVCS_0_BASE_ADDR_REMAP 0xcd0
347#define MV64340_PCI_0_DEVCS_1_BASE_ADDR_REMAP 0xd50
348#define MV64340_PCI_1_DEVCS_1_BASE_ADDR_REMAP 0xdd0
349#define MV64340_PCI_0_DEVCS_2_BASE_ADDR_REMAP 0xd58
350#define MV64340_PCI_1_DEVCS_2_BASE_ADDR_REMAP 0xdd8
351#define MV64340_PCI_0_DEVCS_3_BASE_ADDR_REMAP 0xc54
352#define MV64340_PCI_1_DEVCS_3_BASE_ADDR_REMAP 0xcd4
353#define MV64340_PCI_0_DEVCS_BOOTCS_BASE_ADDR_REMAP 0xd54
354#define MV64340_PCI_1_DEVCS_BOOTCS_BASE_ADDR_REMAP 0xdd4
355#define MV64340_PCI_0_P2P_MEM0_BASE_ADDR_REMAP_LOW 0xd5c
356#define MV64340_PCI_1_P2P_MEM0_BASE_ADDR_REMAP_LOW 0xddc
357#define MV64340_PCI_0_P2P_MEM0_BASE_ADDR_REMAP_HIGH 0xd60
358#define MV64340_PCI_1_P2P_MEM0_BASE_ADDR_REMAP_HIGH 0xde0
359#define MV64340_PCI_0_P2P_MEM1_BASE_ADDR_REMAP_LOW 0xd64
360#define MV64340_PCI_1_P2P_MEM1_BASE_ADDR_REMAP_LOW 0xde4
361#define MV64340_PCI_0_P2P_MEM1_BASE_ADDR_REMAP_HIGH 0xd68
362#define MV64340_PCI_1_P2P_MEM1_BASE_ADDR_REMAP_HIGH 0xde8
363#define MV64340_PCI_0_P2P_I_O_BASE_ADDR_REMAP 0xd6c
364#define MV64340_PCI_1_P2P_I_O_BASE_ADDR_REMAP 0xdec
365#define MV64340_PCI_0_CPU_BASE_ADDR_REMAP_LOW 0xd70
366#define MV64340_PCI_1_CPU_BASE_ADDR_REMAP_LOW 0xdf0
367#define MV64340_PCI_0_CPU_BASE_ADDR_REMAP_HIGH 0xd74
368#define MV64340_PCI_1_CPU_BASE_ADDR_REMAP_HIGH 0xdf4
369#define MV64340_PCI_0_INTEGRATED_SRAM_BASE_ADDR_REMAP 0xf00
370#define MV64340_PCI_1_INTEGRATED_SRAM_BASE_ADDR_REMAP 0xf80
371#define MV64340_PCI_0_EXPANSION_ROM_BASE_ADDR_REMAP 0xf38
372#define MV64340_PCI_1_EXPANSION_ROM_BASE_ADDR_REMAP 0xfb8
373#define MV64340_PCI_0_ADDR_DECODE_CONTROL 0xd3c
374#define MV64340_PCI_1_ADDR_DECODE_CONTROL 0xdbc
375#define MV64340_PCI_0_HEADERS_RETARGET_CONTROL 0xF40
376#define MV64340_PCI_1_HEADERS_RETARGET_CONTROL 0xFc0
377#define MV64340_PCI_0_HEADERS_RETARGET_BASE 0xF44
378#define MV64340_PCI_1_HEADERS_RETARGET_BASE 0xFc4
379#define MV64340_PCI_0_HEADERS_RETARGET_HIGH 0xF48
380#define MV64340_PCI_1_HEADERS_RETARGET_HIGH 0xFc8
381
382/***********************************/
383/* PCI Control Register Map */
384/***********************************/
385
386#define MV64340_PCI_0_DLL_STATUS_AND_COMMAND 0x1d20
387#define MV64340_PCI_1_DLL_STATUS_AND_COMMAND 0x1da0
388#define MV64340_PCI_0_MPP_PADS_DRIVE_CONTROL 0x1d1C
389#define MV64340_PCI_1_MPP_PADS_DRIVE_CONTROL 0x1d9C
390#define MV64340_PCI_0_COMMAND 0xc00
391#define MV64340_PCI_1_COMMAND 0xc80
392#define MV64340_PCI_0_MODE 0xd00
393#define MV64340_PCI_1_MODE 0xd80
394#define MV64340_PCI_0_RETRY 0xc04
395#define MV64340_PCI_1_RETRY 0xc84
396#define MV64340_PCI_0_READ_BUFFER_DISCARD_TIMER 0xd04
397#define MV64340_PCI_1_READ_BUFFER_DISCARD_TIMER 0xd84
398#define MV64340_PCI_0_MSI_TRIGGER_TIMER 0xc38
399#define MV64340_PCI_1_MSI_TRIGGER_TIMER 0xcb8
400#define MV64340_PCI_0_ARBITER_CONTROL 0x1d00
401#define MV64340_PCI_1_ARBITER_CONTROL 0x1d80
402#define MV64340_PCI_0_CROSS_BAR_CONTROL_LOW 0x1d08
403#define MV64340_PCI_1_CROSS_BAR_CONTROL_LOW 0x1d88
404#define MV64340_PCI_0_CROSS_BAR_CONTROL_HIGH 0x1d0c
405#define MV64340_PCI_1_CROSS_BAR_CONTROL_HIGH 0x1d8c
406#define MV64340_PCI_0_CROSS_BAR_TIMEOUT 0x1d04
407#define MV64340_PCI_1_CROSS_BAR_TIMEOUT 0x1d84
408#define MV64340_PCI_0_SYNC_BARRIER_TRIGGER_REG 0x1D18
409#define MV64340_PCI_1_SYNC_BARRIER_TRIGGER_REG 0x1D98
410#define MV64340_PCI_0_SYNC_BARRIER_VIRTUAL_REG 0x1d10
411#define MV64340_PCI_1_SYNC_BARRIER_VIRTUAL_REG 0x1d90
412#define MV64340_PCI_0_P2P_CONFIG 0x1d14
413#define MV64340_PCI_1_P2P_CONFIG 0x1d94
414
415#define MV64340_PCI_0_ACCESS_CONTROL_BASE_0_LOW 0x1e00
416#define MV64340_PCI_0_ACCESS_CONTROL_BASE_0_HIGH 0x1e04
417#define MV64340_PCI_0_ACCESS_CONTROL_SIZE_0 0x1e08
418#define MV64340_PCI_0_ACCESS_CONTROL_BASE_1_LOW 0x1e10
419#define MV64340_PCI_0_ACCESS_CONTROL_BASE_1_HIGH 0x1e14
420#define MV64340_PCI_0_ACCESS_CONTROL_SIZE_1 0x1e18
421#define MV64340_PCI_0_ACCESS_CONTROL_BASE_2_LOW 0x1e20
422#define MV64340_PCI_0_ACCESS_CONTROL_BASE_2_HIGH 0x1e24
423#define MV64340_PCI_0_ACCESS_CONTROL_SIZE_2 0x1e28
424#define MV64340_PCI_0_ACCESS_CONTROL_BASE_3_LOW 0x1e30
425#define MV64340_PCI_0_ACCESS_CONTROL_BASE_3_HIGH 0x1e34
426#define MV64340_PCI_0_ACCESS_CONTROL_SIZE_3 0x1e38
427#define MV64340_PCI_0_ACCESS_CONTROL_BASE_4_LOW 0x1e40
428#define MV64340_PCI_0_ACCESS_CONTROL_BASE_4_HIGH 0x1e44
429#define MV64340_PCI_0_ACCESS_CONTROL_SIZE_4 0x1e48
430#define MV64340_PCI_0_ACCESS_CONTROL_BASE_5_LOW 0x1e50
431#define MV64340_PCI_0_ACCESS_CONTROL_BASE_5_HIGH 0x1e54
432#define MV64340_PCI_0_ACCESS_CONTROL_SIZE_5 0x1e58
433
434#define MV64340_PCI_1_ACCESS_CONTROL_BASE_0_LOW 0x1e80
435#define MV64340_PCI_1_ACCESS_CONTROL_BASE_0_HIGH 0x1e84
436#define MV64340_PCI_1_ACCESS_CONTROL_SIZE_0 0x1e88
437#define MV64340_PCI_1_ACCESS_CONTROL_BASE_1_LOW 0x1e90
438#define MV64340_PCI_1_ACCESS_CONTROL_BASE_1_HIGH 0x1e94
439#define MV64340_PCI_1_ACCESS_CONTROL_SIZE_1 0x1e98
440#define MV64340_PCI_1_ACCESS_CONTROL_BASE_2_LOW 0x1ea0
441#define MV64340_PCI_1_ACCESS_CONTROL_BASE_2_HIGH 0x1ea4
442#define MV64340_PCI_1_ACCESS_CONTROL_SIZE_2 0x1ea8
443#define MV64340_PCI_1_ACCESS_CONTROL_BASE_3_LOW 0x1eb0
444#define MV64340_PCI_1_ACCESS_CONTROL_BASE_3_HIGH 0x1eb4
445#define MV64340_PCI_1_ACCESS_CONTROL_SIZE_3 0x1eb8
446#define MV64340_PCI_1_ACCESS_CONTROL_BASE_4_LOW 0x1ec0
447#define MV64340_PCI_1_ACCESS_CONTROL_BASE_4_HIGH 0x1ec4
448#define MV64340_PCI_1_ACCESS_CONTROL_SIZE_4 0x1ec8
449#define MV64340_PCI_1_ACCESS_CONTROL_BASE_5_LOW 0x1ed0
450#define MV64340_PCI_1_ACCESS_CONTROL_BASE_5_HIGH 0x1ed4
451#define MV64340_PCI_1_ACCESS_CONTROL_SIZE_5 0x1ed8
452
453/****************************************/
454/* PCI Configuration Access Registers */
455/****************************************/
456
457#define MV64340_PCI_0_CONFIG_ADDR 0xcf8
458#define MV64340_PCI_0_CONFIG_DATA_VIRTUAL_REG 0xcfc
459#define MV64340_PCI_1_CONFIG_ADDR 0xc78
460#define MV64340_PCI_1_CONFIG_DATA_VIRTUAL_REG 0xc7c
461#define MV64340_PCI_0_INTERRUPT_ACKNOWLEDGE_VIRTUAL_REG 0xc34
462#define MV64340_PCI_1_INTERRUPT_ACKNOWLEDGE_VIRTUAL_REG 0xcb4
463
464/****************************************/
465/* PCI Error Report Registers */
466/****************************************/
467
468#define MV64340_PCI_0_SERR_MASK 0xc28
469#define MV64340_PCI_1_SERR_MASK 0xca8
470#define MV64340_PCI_0_ERROR_ADDR_LOW 0x1d40
471#define MV64340_PCI_1_ERROR_ADDR_LOW 0x1dc0
472#define MV64340_PCI_0_ERROR_ADDR_HIGH 0x1d44
473#define MV64340_PCI_1_ERROR_ADDR_HIGH 0x1dc4
474#define MV64340_PCI_0_ERROR_ATTRIBUTE 0x1d48
475#define MV64340_PCI_1_ERROR_ATTRIBUTE 0x1dc8
476#define MV64340_PCI_0_ERROR_COMMAND 0x1d50
477#define MV64340_PCI_1_ERROR_COMMAND 0x1dd0
478#define MV64340_PCI_0_ERROR_CAUSE 0x1d58
479#define MV64340_PCI_1_ERROR_CAUSE 0x1dd8
480#define MV64340_PCI_0_ERROR_MASK 0x1d5c
481#define MV64340_PCI_1_ERROR_MASK 0x1ddc
482
483/****************************************/
484/* PCI Debug Registers */
485/****************************************/
486
487#define MV64340_PCI_0_MMASK 0X1D24
488#define MV64340_PCI_1_MMASK 0X1DA4
489
490/*********************************************/
491/* PCI Configuration, Function 0, Registers */
492/*********************************************/
493
494#define MV64340_PCI_DEVICE_AND_VENDOR_ID 0x000
495#define MV64340_PCI_STATUS_AND_COMMAND 0x004
496#define MV64340_PCI_CLASS_CODE_AND_REVISION_ID 0x008
497#define MV64340_PCI_BIST_HEADER_TYPE_LATENCY_TIMER_CACHE_LINE 0x00C
498
499#define MV64340_PCI_SCS_0_BASE_ADDR_LOW 0x010
500#define MV64340_PCI_SCS_0_BASE_ADDR_HIGH 0x014
501#define MV64340_PCI_SCS_1_BASE_ADDR_LOW 0x018
502#define MV64340_PCI_SCS_1_BASE_ADDR_HIGH 0x01C
503#define MV64340_PCI_INTERNAL_REG_MEM_MAPPED_BASE_ADDR_LOW 0x020
504#define MV64340_PCI_INTERNAL_REG_MEM_MAPPED_BASE_ADDR_HIGH 0x024
505#define MV64340_PCI_SUBSYSTEM_ID_AND_SUBSYSTEM_VENDOR_ID 0x02c
506#define MV64340_PCI_EXPANSION_ROM_BASE_ADDR_REG 0x030
507#define MV64340_PCI_CAPABILTY_LIST_POINTER 0x034
508#define MV64340_PCI_INTERRUPT_PIN_AND_LINE 0x03C
509 /* capability list */
510#define MV64340_PCI_POWER_MANAGEMENT_CAPABILITY 0x040
511#define MV64340_PCI_POWER_MANAGEMENT_STATUS_AND_CONTROL 0x044
512#define MV64340_PCI_VPD_ADDR 0x048
513#define MV64340_PCI_VPD_DATA 0x04c
514#define MV64340_PCI_MSI_MESSAGE_CONTROL 0x050
515#define MV64340_PCI_MSI_MESSAGE_ADDR 0x054
516#define MV64340_PCI_MSI_MESSAGE_UPPER_ADDR 0x058
517#define MV64340_PCI_MSI_MESSAGE_DATA 0x05c
518#define MV64340_PCI_X_COMMAND 0x060
519#define MV64340_PCI_X_STATUS 0x064
520#define MV64340_PCI_COMPACT_PCI_HOT_SWAP 0x068
521
522/***********************************************/
523/* PCI Configuration, Function 1, Registers */
524/***********************************************/
525
526#define MV64340_PCI_SCS_2_BASE_ADDR_LOW 0x110
527#define MV64340_PCI_SCS_2_BASE_ADDR_HIGH 0x114
528#define MV64340_PCI_SCS_3_BASE_ADDR_LOW 0x118
529#define MV64340_PCI_SCS_3_BASE_ADDR_HIGH 0x11c
530#define MV64340_PCI_INTERNAL_SRAM_BASE_ADDR_LOW 0x120
531#define MV64340_PCI_INTERNAL_SRAM_BASE_ADDR_HIGH 0x124
532
533/***********************************************/
534/* PCI Configuration, Function 2, Registers */
535/***********************************************/
536
537#define MV64340_PCI_DEVCS_0_BASE_ADDR_LOW 0x210
538#define MV64340_PCI_DEVCS_0_BASE_ADDR_HIGH 0x214
539#define MV64340_PCI_DEVCS_1_BASE_ADDR_LOW 0x218
540#define MV64340_PCI_DEVCS_1_BASE_ADDR_HIGH 0x21c
541#define MV64340_PCI_DEVCS_2_BASE_ADDR_LOW 0x220
542#define MV64340_PCI_DEVCS_2_BASE_ADDR_HIGH 0x224
543
544/***********************************************/
545/* PCI Configuration, Function 3, Registers */
546/***********************************************/
547
548#define MV64340_PCI_DEVCS_3_BASE_ADDR_LOW 0x310
549#define MV64340_PCI_DEVCS_3_BASE_ADDR_HIGH 0x314
550#define MV64340_PCI_BOOT_CS_BASE_ADDR_LOW 0x318
551#define MV64340_PCI_BOOT_CS_BASE_ADDR_HIGH 0x31c
552#define MV64340_PCI_CPU_BASE_ADDR_LOW 0x220
553#define MV64340_PCI_CPU_BASE_ADDR_HIGH 0x224
554
555/***********************************************/
556/* PCI Configuration, Function 4, Registers */
557/***********************************************/
558
559#define MV64340_PCI_P2P_MEM0_BASE_ADDR_LOW 0x410
560#define MV64340_PCI_P2P_MEM0_BASE_ADDR_HIGH 0x414
561#define MV64340_PCI_P2P_MEM1_BASE_ADDR_LOW 0x418
562#define MV64340_PCI_P2P_MEM1_BASE_ADDR_HIGH 0x41c
563#define MV64340_PCI_P2P_I_O_BASE_ADDR 0x420
564#define MV64340_PCI_INTERNAL_REGS_I_O_MAPPED_BASE_ADDR 0x424
565
566/****************************************/
567/* Messaging Unit Registers (I20) */
568/****************************************/
569
570#define MV64340_I2O_INBOUND_MESSAGE_REG0_PCI_0_SIDE 0x010
571#define MV64340_I2O_INBOUND_MESSAGE_REG1_PCI_0_SIDE 0x014
572#define MV64340_I2O_OUTBOUND_MESSAGE_REG0_PCI_0_SIDE 0x018
573#define MV64340_I2O_OUTBOUND_MESSAGE_REG1_PCI_0_SIDE 0x01C
574#define MV64340_I2O_INBOUND_DOORBELL_REG_PCI_0_SIDE 0x020
575#define MV64340_I2O_INBOUND_INTERRUPT_CAUSE_REG_PCI_0_SIDE 0x024
576#define MV64340_I2O_INBOUND_INTERRUPT_MASK_REG_PCI_0_SIDE 0x028
577#define MV64340_I2O_OUTBOUND_DOORBELL_REG_PCI_0_SIDE 0x02C
578#define MV64340_I2O_OUTBOUND_INTERRUPT_CAUSE_REG_PCI_0_SIDE 0x030
579#define MV64340_I2O_OUTBOUND_INTERRUPT_MASK_REG_PCI_0_SIDE 0x034
580#define MV64340_I2O_INBOUND_QUEUE_PORT_VIRTUAL_REG_PCI_0_SIDE 0x040
581#define MV64340_I2O_OUTBOUND_QUEUE_PORT_VIRTUAL_REG_PCI_0_SIDE 0x044
582#define MV64340_I2O_QUEUE_CONTROL_REG_PCI_0_SIDE 0x050
583#define MV64340_I2O_QUEUE_BASE_ADDR_REG_PCI_0_SIDE 0x054
584#define MV64340_I2O_INBOUND_FREE_HEAD_POINTER_REG_PCI_0_SIDE 0x060
585#define MV64340_I2O_INBOUND_FREE_TAIL_POINTER_REG_PCI_0_SIDE 0x064
586#define MV64340_I2O_INBOUND_POST_HEAD_POINTER_REG_PCI_0_SIDE 0x068
587#define MV64340_I2O_INBOUND_POST_TAIL_POINTER_REG_PCI_0_SIDE 0x06C
588#define MV64340_I2O_OUTBOUND_FREE_HEAD_POINTER_REG_PCI_0_SIDE 0x070
589#define MV64340_I2O_OUTBOUND_FREE_TAIL_POINTER_REG_PCI_0_SIDE 0x074
590#define MV64340_I2O_OUTBOUND_POST_HEAD_POINTER_REG_PCI_0_SIDE 0x0F8
591#define MV64340_I2O_OUTBOUND_POST_TAIL_POINTER_REG_PCI_0_SIDE 0x0FC
592
593#define MV64340_I2O_INBOUND_MESSAGE_REG0_PCI_1_SIDE 0x090
594#define MV64340_I2O_INBOUND_MESSAGE_REG1_PCI_1_SIDE 0x094
595#define MV64340_I2O_OUTBOUND_MESSAGE_REG0_PCI_1_SIDE 0x098
596#define MV64340_I2O_OUTBOUND_MESSAGE_REG1_PCI_1_SIDE 0x09C
597#define MV64340_I2O_INBOUND_DOORBELL_REG_PCI_1_SIDE 0x0A0
598#define MV64340_I2O_INBOUND_INTERRUPT_CAUSE_REG_PCI_1_SIDE 0x0A4
599#define MV64340_I2O_INBOUND_INTERRUPT_MASK_REG_PCI_1_SIDE 0x0A8
600#define MV64340_I2O_OUTBOUND_DOORBELL_REG_PCI_1_SIDE 0x0AC
601#define MV64340_I2O_OUTBOUND_INTERRUPT_CAUSE_REG_PCI_1_SIDE 0x0B0
602#define MV64340_I2O_OUTBOUND_INTERRUPT_MASK_REG_PCI_1_SIDE 0x0B4
603#define MV64340_I2O_INBOUND_QUEUE_PORT_VIRTUAL_REG_PCI_1_SIDE 0x0C0
604#define MV64340_I2O_OUTBOUND_QUEUE_PORT_VIRTUAL_REG_PCI_1_SIDE 0x0C4
605#define MV64340_I2O_QUEUE_CONTROL_REG_PCI_1_SIDE 0x0D0
606#define MV64340_I2O_QUEUE_BASE_ADDR_REG_PCI_1_SIDE 0x0D4
607#define MV64340_I2O_INBOUND_FREE_HEAD_POINTER_REG_PCI_1_SIDE 0x0E0
608#define MV64340_I2O_INBOUND_FREE_TAIL_POINTER_REG_PCI_1_SIDE 0x0E4
609#define MV64340_I2O_INBOUND_POST_HEAD_POINTER_REG_PCI_1_SIDE 0x0E8
610#define MV64340_I2O_INBOUND_POST_TAIL_POINTER_REG_PCI_1_SIDE 0x0EC
611#define MV64340_I2O_OUTBOUND_FREE_HEAD_POINTER_REG_PCI_1_SIDE 0x0F0
612#define MV64340_I2O_OUTBOUND_FREE_TAIL_POINTER_REG_PCI_1_SIDE 0x0F4
613#define MV64340_I2O_OUTBOUND_POST_HEAD_POINTER_REG_PCI_1_SIDE 0x078
614#define MV64340_I2O_OUTBOUND_POST_TAIL_POINTER_REG_PCI_1_SIDE 0x07C
615
616#define MV64340_I2O_INBOUND_MESSAGE_REG0_CPU0_SIDE 0x1C10
617#define MV64340_I2O_INBOUND_MESSAGE_REG1_CPU0_SIDE 0x1C14
618#define MV64340_I2O_OUTBOUND_MESSAGE_REG0_CPU0_SIDE 0x1C18
619#define MV64340_I2O_OUTBOUND_MESSAGE_REG1_CPU0_SIDE 0x1C1C
620#define MV64340_I2O_INBOUND_DOORBELL_REG_CPU0_SIDE 0x1C20
621#define MV64340_I2O_INBOUND_INTERRUPT_CAUSE_REG_CPU0_SIDE 0x1C24
622#define MV64340_I2O_INBOUND_INTERRUPT_MASK_REG_CPU0_SIDE 0x1C28
623#define MV64340_I2O_OUTBOUND_DOORBELL_REG_CPU0_SIDE 0x1C2C
624#define MV64340_I2O_OUTBOUND_INTERRUPT_CAUSE_REG_CPU0_SIDE 0x1C30
625#define MV64340_I2O_OUTBOUND_INTERRUPT_MASK_REG_CPU0_SIDE 0x1C34
626#define MV64340_I2O_INBOUND_QUEUE_PORT_VIRTUAL_REG_CPU0_SIDE 0x1C40
627#define MV64340_I2O_OUTBOUND_QUEUE_PORT_VIRTUAL_REG_CPU0_SIDE 0x1C44
628#define MV64340_I2O_QUEUE_CONTROL_REG_CPU0_SIDE 0x1C50
629#define MV64340_I2O_QUEUE_BASE_ADDR_REG_CPU0_SIDE 0x1C54
630#define MV64340_I2O_INBOUND_FREE_HEAD_POINTER_REG_CPU0_SIDE 0x1C60
631#define MV64340_I2O_INBOUND_FREE_TAIL_POINTER_REG_CPU0_SIDE 0x1C64
632#define MV64340_I2O_INBOUND_POST_HEAD_POINTER_REG_CPU0_SIDE 0x1C68
633#define MV64340_I2O_INBOUND_POST_TAIL_POINTER_REG_CPU0_SIDE 0x1C6C
634#define MV64340_I2O_OUTBOUND_FREE_HEAD_POINTER_REG_CPU0_SIDE 0x1C70
635#define MV64340_I2O_OUTBOUND_FREE_TAIL_POINTER_REG_CPU0_SIDE 0x1C74
636#define MV64340_I2O_OUTBOUND_POST_HEAD_POINTER_REG_CPU0_SIDE 0x1CF8
637#define MV64340_I2O_OUTBOUND_POST_TAIL_POINTER_REG_CPU0_SIDE 0x1CFC
638#define MV64340_I2O_INBOUND_MESSAGE_REG0_CPU1_SIDE 0x1C90
639#define MV64340_I2O_INBOUND_MESSAGE_REG1_CPU1_SIDE 0x1C94
640#define MV64340_I2O_OUTBOUND_MESSAGE_REG0_CPU1_SIDE 0x1C98
641#define MV64340_I2O_OUTBOUND_MESSAGE_REG1_CPU1_SIDE 0x1C9C
642#define MV64340_I2O_INBOUND_DOORBELL_REG_CPU1_SIDE 0x1CA0
643#define MV64340_I2O_INBOUND_INTERRUPT_CAUSE_REG_CPU1_SIDE 0x1CA4
644#define MV64340_I2O_INBOUND_INTERRUPT_MASK_REG_CPU1_SIDE 0x1CA8
645#define MV64340_I2O_OUTBOUND_DOORBELL_REG_CPU1_SIDE 0x1CAC
646#define MV64340_I2O_OUTBOUND_INTERRUPT_CAUSE_REG_CPU1_SIDE 0x1CB0
647#define MV64340_I2O_OUTBOUND_INTERRUPT_MASK_REG_CPU1_SIDE 0x1CB4
648#define MV64340_I2O_INBOUND_QUEUE_PORT_VIRTUAL_REG_CPU1_SIDE 0x1CC0
649#define MV64340_I2O_OUTBOUND_QUEUE_PORT_VIRTUAL_REG_CPU1_SIDE 0x1CC4
650#define MV64340_I2O_QUEUE_CONTROL_REG_CPU1_SIDE 0x1CD0
651#define MV64340_I2O_QUEUE_BASE_ADDR_REG_CPU1_SIDE 0x1CD4
652#define MV64340_I2O_INBOUND_FREE_HEAD_POINTER_REG_CPU1_SIDE 0x1CE0
653#define MV64340_I2O_INBOUND_FREE_TAIL_POINTER_REG_CPU1_SIDE 0x1CE4
654#define MV64340_I2O_INBOUND_POST_HEAD_POINTER_REG_CPU1_SIDE 0x1CE8
655#define MV64340_I2O_INBOUND_POST_TAIL_POINTER_REG_CPU1_SIDE 0x1CEC
656#define MV64340_I2O_OUTBOUND_FREE_HEAD_POINTER_REG_CPU1_SIDE 0x1CF0
657#define MV64340_I2O_OUTBOUND_FREE_TAIL_POINTER_REG_CPU1_SIDE 0x1CF4
658#define MV64340_I2O_OUTBOUND_POST_HEAD_POINTER_REG_CPU1_SIDE 0x1C78
659#define MV64340_I2O_OUTBOUND_POST_TAIL_POINTER_REG_CPU1_SIDE 0x1C7C
660
661/****************************************/
662/* Ethernet Unit Registers */
663/****************************************/
664
665#define MV643XX_ETH_SHARED_REGS 0x2000
666#define MV643XX_ETH_SHARED_REGS_SIZE 0x2000
667
668#define MV643XX_ETH_PHY_ADDR_REG 0x2000
669#define MV643XX_ETH_SMI_REG 0x2004
670#define MV643XX_ETH_UNIT_DEFAULT_ADDR_REG 0x2008
671#define MV643XX_ETH_UNIT_DEFAULTID_REG 0x200c
672#define MV643XX_ETH_UNIT_INTERRUPT_CAUSE_REG 0x2080
673#define MV643XX_ETH_UNIT_INTERRUPT_MASK_REG 0x2084
674#define MV643XX_ETH_UNIT_INTERNAL_USE_REG 0x24fc
675#define MV643XX_ETH_UNIT_ERROR_ADDR_REG 0x2094
676#define MV643XX_ETH_BAR_0 0x2200
677#define MV643XX_ETH_BAR_1 0x2208
678#define MV643XX_ETH_BAR_2 0x2210
679#define MV643XX_ETH_BAR_3 0x2218
680#define MV643XX_ETH_BAR_4 0x2220
681#define MV643XX_ETH_BAR_5 0x2228
682#define MV643XX_ETH_SIZE_REG_0 0x2204
683#define MV643XX_ETH_SIZE_REG_1 0x220c
684#define MV643XX_ETH_SIZE_REG_2 0x2214
685#define MV643XX_ETH_SIZE_REG_3 0x221c
686#define MV643XX_ETH_SIZE_REG_4 0x2224
687#define MV643XX_ETH_SIZE_REG_5 0x222c
688#define MV643XX_ETH_HEADERS_RETARGET_BASE_REG 0x2230
689#define MV643XX_ETH_HEADERS_RETARGET_CONTROL_REG 0x2234
690#define MV643XX_ETH_HIGH_ADDR_REMAP_REG_0 0x2280
691#define MV643XX_ETH_HIGH_ADDR_REMAP_REG_1 0x2284
692#define MV643XX_ETH_HIGH_ADDR_REMAP_REG_2 0x2288
693#define MV643XX_ETH_HIGH_ADDR_REMAP_REG_3 0x228c
694#define MV643XX_ETH_BASE_ADDR_ENABLE_REG 0x2290
695#define MV643XX_ETH_ACCESS_PROTECTION_REG(port) (0x2294 + (port<<2))
696#define MV643XX_ETH_MIB_COUNTERS_BASE(port) (0x3000 + (port<<7))
697#define MV643XX_ETH_PORT_CONFIG_REG(port) (0x2400 + (port<<10))
698#define MV643XX_ETH_PORT_CONFIG_EXTEND_REG(port) (0x2404 + (port<<10))
699#define MV643XX_ETH_MII_SERIAL_PARAMETRS_REG(port) (0x2408 + (port<<10))
700#define MV643XX_ETH_GMII_SERIAL_PARAMETRS_REG(port) (0x240c + (port<<10))
701#define MV643XX_ETH_VLAN_ETHERTYPE_REG(port) (0x2410 + (port<<10))
702#define MV643XX_ETH_MAC_ADDR_LOW(port) (0x2414 + (port<<10))
703#define MV643XX_ETH_MAC_ADDR_HIGH(port) (0x2418 + (port<<10))
704#define MV643XX_ETH_SDMA_CONFIG_REG(port) (0x241c + (port<<10))
705#define MV643XX_ETH_DSCP_0(port) (0x2420 + (port<<10))
706#define MV643XX_ETH_DSCP_1(port) (0x2424 + (port<<10))
707#define MV643XX_ETH_DSCP_2(port) (0x2428 + (port<<10))
708#define MV643XX_ETH_DSCP_3(port) (0x242c + (port<<10))
709#define MV643XX_ETH_DSCP_4(port) (0x2430 + (port<<10))
710#define MV643XX_ETH_DSCP_5(port) (0x2434 + (port<<10))
711#define MV643XX_ETH_DSCP_6(port) (0x2438 + (port<<10))
712#define MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port) (0x243c + (port<<10))
713#define MV643XX_ETH_VLAN_PRIORITY_TAG_TO_PRIORITY(port) (0x2440 + (port<<10))
714#define MV643XX_ETH_PORT_STATUS_REG(port) (0x2444 + (port<<10))
715#define MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port) (0x2448 + (port<<10))
716#define MV643XX_ETH_TX_QUEUE_FIXED_PRIORITY(port) (0x244c + (port<<10))
717#define MV643XX_ETH_PORT_TX_TOKEN_BUCKET_RATE_CONFIG(port) (0x2450 + (port<<10))
718#define MV643XX_ETH_MAXIMUM_TRANSMIT_UNIT(port) (0x2458 + (port<<10))
719#define MV643XX_ETH_PORT_MAXIMUM_TOKEN_BUCKET_SIZE(port) (0x245c + (port<<10))
720#define MV643XX_ETH_INTERRUPT_CAUSE_REG(port) (0x2460 + (port<<10))
721#define MV643XX_ETH_INTERRUPT_CAUSE_EXTEND_REG(port) (0x2464 + (port<<10))
722#define MV643XX_ETH_INTERRUPT_MASK_REG(port) (0x2468 + (port<<10))
723#define MV643XX_ETH_INTERRUPT_EXTEND_MASK_REG(port) (0x246c + (port<<10))
724#define MV643XX_ETH_RX_FIFO_URGENT_THRESHOLD_REG(port) (0x2470 + (port<<10))
725#define MV643XX_ETH_TX_FIFO_URGENT_THRESHOLD_REG(port) (0x2474 + (port<<10))
726#define MV643XX_ETH_RX_MINIMAL_FRAME_SIZE_REG(port) (0x247c + (port<<10))
727#define MV643XX_ETH_RX_DISCARDED_FRAMES_COUNTER(port) (0x2484 + (port<<10)
728#define MV643XX_ETH_PORT_DEBUG_0_REG(port) (0x248c + (port<<10))
729#define MV643XX_ETH_PORT_DEBUG_1_REG(port) (0x2490 + (port<<10))
730#define MV643XX_ETH_PORT_INTERNAL_ADDR_ERROR_REG(port) (0x2494 + (port<<10))
731#define MV643XX_ETH_INTERNAL_USE_REG(port) (0x24fc + (port<<10))
732#define MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port) (0x2680 + (port<<10))
733#define MV643XX_ETH_CURRENT_SERVED_TX_DESC_PTR(port) (0x2684 + (port<<10))
734#define MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_0(port) (0x260c + (port<<10))
735#define MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_1(port) (0x261c + (port<<10))
736#define MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_2(port) (0x262c + (port<<10))
737#define MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_3(port) (0x263c + (port<<10))
738#define MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_4(port) (0x264c + (port<<10))
739#define MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_5(port) (0x265c + (port<<10))
740#define MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_6(port) (0x266c + (port<<10))
741#define MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_7(port) (0x267c + (port<<10))
742#define MV643XX_ETH_TX_CURRENT_QUEUE_DESC_PTR_0(port) (0x26c0 + (port<<10))
743#define MV643XX_ETH_TX_CURRENT_QUEUE_DESC_PTR_1(port) (0x26c4 + (port<<10))
744#define MV643XX_ETH_TX_CURRENT_QUEUE_DESC_PTR_2(port) (0x26c8 + (port<<10))
745#define MV643XX_ETH_TX_CURRENT_QUEUE_DESC_PTR_3(port) (0x26cc + (port<<10))
746#define MV643XX_ETH_TX_CURRENT_QUEUE_DESC_PTR_4(port) (0x26d0 + (port<<10))
747#define MV643XX_ETH_TX_CURRENT_QUEUE_DESC_PTR_5(port) (0x26d4 + (port<<10))
748#define MV643XX_ETH_TX_CURRENT_QUEUE_DESC_PTR_6(port) (0x26d8 + (port<<10))
749#define MV643XX_ETH_TX_CURRENT_QUEUE_DESC_PTR_7(port) (0x26dc + (port<<10))
750#define MV643XX_ETH_TX_QUEUE_0_TOKEN_BUCKET_COUNT(port) (0x2700 + (port<<10))
751#define MV643XX_ETH_TX_QUEUE_1_TOKEN_BUCKET_COUNT(port) (0x2710 + (port<<10))
752#define MV643XX_ETH_TX_QUEUE_2_TOKEN_BUCKET_COUNT(port) (0x2720 + (port<<10))
753#define MV643XX_ETH_TX_QUEUE_3_TOKEN_BUCKET_COUNT(port) (0x2730 + (port<<10))
754#define MV643XX_ETH_TX_QUEUE_4_TOKEN_BUCKET_COUNT(port) (0x2740 + (port<<10))
755#define MV643XX_ETH_TX_QUEUE_5_TOKEN_BUCKET_COUNT(port) (0x2750 + (port<<10))
756#define MV643XX_ETH_TX_QUEUE_6_TOKEN_BUCKET_COUNT(port) (0x2760 + (port<<10))
757#define MV643XX_ETH_TX_QUEUE_7_TOKEN_BUCKET_COUNT(port) (0x2770 + (port<<10))
758#define MV643XX_ETH_TX_QUEUE_0_TOKEN_BUCKET_CONFIG(port) (0x2704 + (port<<10))
759#define MV643XX_ETH_TX_QUEUE_1_TOKEN_BUCKET_CONFIG(port) (0x2714 + (port<<10))
760#define MV643XX_ETH_TX_QUEUE_2_TOKEN_BUCKET_CONFIG(port) (0x2724 + (port<<10))
761#define MV643XX_ETH_TX_QUEUE_3_TOKEN_BUCKET_CONFIG(port) (0x2734 + (port<<10))
762#define MV643XX_ETH_TX_QUEUE_4_TOKEN_BUCKET_CONFIG(port) (0x2744 + (port<<10))
763#define MV643XX_ETH_TX_QUEUE_5_TOKEN_BUCKET_CONFIG(port) (0x2754 + (port<<10))
764#define MV643XX_ETH_TX_QUEUE_6_TOKEN_BUCKET_CONFIG(port) (0x2764 + (port<<10))
765#define MV643XX_ETH_TX_QUEUE_7_TOKEN_BUCKET_CONFIG(port) (0x2774 + (port<<10))
766#define MV643XX_ETH_TX_QUEUE_0_ARBITER_CONFIG(port) (0x2708 + (port<<10))
767#define MV643XX_ETH_TX_QUEUE_1_ARBITER_CONFIG(port) (0x2718 + (port<<10))
768#define MV643XX_ETH_TX_QUEUE_2_ARBITER_CONFIG(port) (0x2728 + (port<<10))
769#define MV643XX_ETH_TX_QUEUE_3_ARBITER_CONFIG(port) (0x2738 + (port<<10))
770#define MV643XX_ETH_TX_QUEUE_4_ARBITER_CONFIG(port) (0x2748 + (port<<10))
771#define MV643XX_ETH_TX_QUEUE_5_ARBITER_CONFIG(port) (0x2758 + (port<<10))
772#define MV643XX_ETH_TX_QUEUE_6_ARBITER_CONFIG(port) (0x2768 + (port<<10))
773#define MV643XX_ETH_TX_QUEUE_7_ARBITER_CONFIG(port) (0x2778 + (port<<10))
774#define MV643XX_ETH_PORT_TX_TOKEN_BUCKET_COUNT(port) (0x2780 + (port<<10))
775#define MV643XX_ETH_DA_FILTER_SPECIAL_MULTICAST_TABLE_BASE(port) (0x3400 + (port<<10))
776#define MV643XX_ETH_DA_FILTER_OTHER_MULTICAST_TABLE_BASE(port) (0x3500 + (port<<10))
777#define MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE(port) (0x3600 + (port<<10))
778
779/*******************************************/
780/* CUNIT Registers */
781/*******************************************/
782
783 /* Address Decoding Register Map */
784
785#define MV64340_CUNIT_BASE_ADDR_REG0 0xf200
786#define MV64340_CUNIT_BASE_ADDR_REG1 0xf208
787#define MV64340_CUNIT_BASE_ADDR_REG2 0xf210
788#define MV64340_CUNIT_BASE_ADDR_REG3 0xf218
789#define MV64340_CUNIT_SIZE0 0xf204
790#define MV64340_CUNIT_SIZE1 0xf20c
791#define MV64340_CUNIT_SIZE2 0xf214
792#define MV64340_CUNIT_SIZE3 0xf21c
793#define MV64340_CUNIT_HIGH_ADDR_REMAP_REG0 0xf240
794#define MV64340_CUNIT_HIGH_ADDR_REMAP_REG1 0xf244
795#define MV64340_CUNIT_BASE_ADDR_ENABLE_REG 0xf250
796#define MV64340_MPSC0_ACCESS_PROTECTION_REG 0xf254
797#define MV64340_MPSC1_ACCESS_PROTECTION_REG 0xf258
798#define MV64340_CUNIT_INTERNAL_SPACE_BASE_ADDR_REG 0xf25C
799
800 /* Error Report Registers */
801
802#define MV64340_CUNIT_INTERRUPT_CAUSE_REG 0xf310
803#define MV64340_CUNIT_INTERRUPT_MASK_REG 0xf314
804#define MV64340_CUNIT_ERROR_ADDR 0xf318
805
806 /* Cunit Control Registers */
807
808#define MV64340_CUNIT_ARBITER_CONTROL_REG 0xf300
809#define MV64340_CUNIT_CONFIG_REG 0xb40c
810#define MV64340_CUNIT_CRROSBAR_TIMEOUT_REG 0xf304
811
812 /* Cunit Debug Registers */
813
814#define MV64340_CUNIT_DEBUG_LOW 0xf340
815#define MV64340_CUNIT_DEBUG_HIGH 0xf344
816#define MV64340_CUNIT_MMASK 0xf380
817
818 /* MPSCs Clocks Routing Registers */
819
820#define MV64340_MPSC_ROUTING_REG 0xb400
821#define MV64340_MPSC_RX_CLOCK_ROUTING_REG 0xb404
822#define MV64340_MPSC_TX_CLOCK_ROUTING_REG 0xb408
823
824 /* MPSCs Interrupts Registers */
825
826#define MV64340_MPSC_CAUSE_REG(port) (0xb804 + (port<<3))
827#define MV64340_MPSC_MASK_REG(port) (0xb884 + (port<<3))
828
829#define MV64340_MPSC_MAIN_CONFIG_LOW(port) (0x8000 + (port<<12))
830#define MV64340_MPSC_MAIN_CONFIG_HIGH(port) (0x8004 + (port<<12))
831#define MV64340_MPSC_PROTOCOL_CONFIG(port) (0x8008 + (port<<12))
832#define MV64340_MPSC_CHANNEL_REG1(port) (0x800c + (port<<12))
833#define MV64340_MPSC_CHANNEL_REG2(port) (0x8010 + (port<<12))
834#define MV64340_MPSC_CHANNEL_REG3(port) (0x8014 + (port<<12))
835#define MV64340_MPSC_CHANNEL_REG4(port) (0x8018 + (port<<12))
836#define MV64340_MPSC_CHANNEL_REG5(port) (0x801c + (port<<12))
837#define MV64340_MPSC_CHANNEL_REG6(port) (0x8020 + (port<<12))
838#define MV64340_MPSC_CHANNEL_REG7(port) (0x8024 + (port<<12))
839#define MV64340_MPSC_CHANNEL_REG8(port) (0x8028 + (port<<12))
840#define MV64340_MPSC_CHANNEL_REG9(port) (0x802c + (port<<12))
841#define MV64340_MPSC_CHANNEL_REG10(port) (0x8030 + (port<<12))
842
843 /* MPSC0 Registers */
844
845
846/***************************************/
847/* SDMA Registers */
848/***************************************/
849
850#define MV64340_SDMA_CONFIG_REG(channel) (0x4000 + (channel<<13))
851#define MV64340_SDMA_COMMAND_REG(channel) (0x4008 + (channel<<13))
852#define MV64340_SDMA_CURRENT_RX_DESCRIPTOR_POINTER(channel) (0x4810 + (channel<<13))
853#define MV64340_SDMA_CURRENT_TX_DESCRIPTOR_POINTER(channel) (0x4c10 + (channel<<13))
854#define MV64340_SDMA_FIRST_TX_DESCRIPTOR_POINTER(channel) (0x4c14 + (channel<<13))
855
856#define MV64340_SDMA_CAUSE_REG 0xb800
857#define MV64340_SDMA_MASK_REG 0xb880
858
859/* BRG Interrupts */
860
861#define MV64340_BRG_CONFIG_REG(brg) (0xb200 + (brg<<3))
862#define MV64340_BRG_BAUDE_TUNING_REG(brg) (0xb208 + (brg<<3))
863#define MV64340_BRG_CAUSE_REG 0xb834
864#define MV64340_BRG_MASK_REG 0xb8b4
865
866/****************************************/
867/* DMA Channel Control */
868/****************************************/
869
870#define MV64340_DMA_CHANNEL0_CONTROL 0x840
871#define MV64340_DMA_CHANNEL0_CONTROL_HIGH 0x880
872#define MV64340_DMA_CHANNEL1_CONTROL 0x844
873#define MV64340_DMA_CHANNEL1_CONTROL_HIGH 0x884
874#define MV64340_DMA_CHANNEL2_CONTROL 0x848
875#define MV64340_DMA_CHANNEL2_CONTROL_HIGH 0x888
876#define MV64340_DMA_CHANNEL3_CONTROL 0x84C
877#define MV64340_DMA_CHANNEL3_CONTROL_HIGH 0x88C
878
879
880/****************************************/
881/* IDMA Registers */
882/****************************************/
883
884#define MV64340_DMA_CHANNEL0_BYTE_COUNT 0x800
885#define MV64340_DMA_CHANNEL1_BYTE_COUNT 0x804
886#define MV64340_DMA_CHANNEL2_BYTE_COUNT 0x808
887#define MV64340_DMA_CHANNEL3_BYTE_COUNT 0x80C
888#define MV64340_DMA_CHANNEL0_SOURCE_ADDR 0x810
889#define MV64340_DMA_CHANNEL1_SOURCE_ADDR 0x814
890#define MV64340_DMA_CHANNEL2_SOURCE_ADDR 0x818
891#define MV64340_DMA_CHANNEL3_SOURCE_ADDR 0x81c
892#define MV64340_DMA_CHANNEL0_DESTINATION_ADDR 0x820
893#define MV64340_DMA_CHANNEL1_DESTINATION_ADDR 0x824
894#define MV64340_DMA_CHANNEL2_DESTINATION_ADDR 0x828
895#define MV64340_DMA_CHANNEL3_DESTINATION_ADDR 0x82C
896#define MV64340_DMA_CHANNEL0_NEXT_DESCRIPTOR_POINTER 0x830
897#define MV64340_DMA_CHANNEL1_NEXT_DESCRIPTOR_POINTER 0x834
898#define MV64340_DMA_CHANNEL2_NEXT_DESCRIPTOR_POINTER 0x838
899#define MV64340_DMA_CHANNEL3_NEXT_DESCRIPTOR_POINTER 0x83C
900#define MV64340_DMA_CHANNEL0_CURRENT_DESCRIPTOR_POINTER 0x870
901#define MV64340_DMA_CHANNEL1_CURRENT_DESCRIPTOR_POINTER 0x874
902#define MV64340_DMA_CHANNEL2_CURRENT_DESCRIPTOR_POINTER 0x878
903#define MV64340_DMA_CHANNEL3_CURRENT_DESCRIPTOR_POINTER 0x87C
904
905 /* IDMA Address Decoding Base Address Registers */
906
907#define MV64340_DMA_BASE_ADDR_REG0 0xa00
908#define MV64340_DMA_BASE_ADDR_REG1 0xa08
909#define MV64340_DMA_BASE_ADDR_REG2 0xa10
910#define MV64340_DMA_BASE_ADDR_REG3 0xa18
911#define MV64340_DMA_BASE_ADDR_REG4 0xa20
912#define MV64340_DMA_BASE_ADDR_REG5 0xa28
913#define MV64340_DMA_BASE_ADDR_REG6 0xa30
914#define MV64340_DMA_BASE_ADDR_REG7 0xa38
915
916 /* IDMA Address Decoding Size Address Register */
917
918#define MV64340_DMA_SIZE_REG0 0xa04
919#define MV64340_DMA_SIZE_REG1 0xa0c
920#define MV64340_DMA_SIZE_REG2 0xa14
921#define MV64340_DMA_SIZE_REG3 0xa1c
922#define MV64340_DMA_SIZE_REG4 0xa24
923#define MV64340_DMA_SIZE_REG5 0xa2c
924#define MV64340_DMA_SIZE_REG6 0xa34
925#define MV64340_DMA_SIZE_REG7 0xa3C
926
927 /* IDMA Address Decoding High Address Remap and Access
928 Protection Registers */
929
930#define MV64340_DMA_HIGH_ADDR_REMAP_REG0 0xa60
931#define MV64340_DMA_HIGH_ADDR_REMAP_REG1 0xa64
932#define MV64340_DMA_HIGH_ADDR_REMAP_REG2 0xa68
933#define MV64340_DMA_HIGH_ADDR_REMAP_REG3 0xa6C
934#define MV64340_DMA_BASE_ADDR_ENABLE_REG 0xa80
935#define MV64340_DMA_CHANNEL0_ACCESS_PROTECTION_REG 0xa70
936#define MV64340_DMA_CHANNEL1_ACCESS_PROTECTION_REG 0xa74
937#define MV64340_DMA_CHANNEL2_ACCESS_PROTECTION_REG 0xa78
938#define MV64340_DMA_CHANNEL3_ACCESS_PROTECTION_REG 0xa7c
939#define MV64340_DMA_ARBITER_CONTROL 0x860
940#define MV64340_DMA_CROSS_BAR_TIMEOUT 0x8d0
941
942 /* IDMA Headers Retarget Registers */
943
944#define MV64340_DMA_HEADERS_RETARGET_CONTROL 0xa84
945#define MV64340_DMA_HEADERS_RETARGET_BASE 0xa88
946
947 /* IDMA Interrupt Register */
948
949#define MV64340_DMA_INTERRUPT_CAUSE_REG 0x8c0
950#define MV64340_DMA_INTERRUPT_CAUSE_MASK 0x8c4
951#define MV64340_DMA_ERROR_ADDR 0x8c8
952#define MV64340_DMA_ERROR_SELECT 0x8cc
953
954 /* IDMA Debug Register ( for internal use ) */
955
956#define MV64340_DMA_DEBUG_LOW 0x8e0
957#define MV64340_DMA_DEBUG_HIGH 0x8e4
958#define MV64340_DMA_SPARE 0xA8C
959
960/****************************************/
961/* Timer_Counter */
962/****************************************/
963
964#define MV64340_TIMER_COUNTER0 0x850
965#define MV64340_TIMER_COUNTER1 0x854
966#define MV64340_TIMER_COUNTER2 0x858
967#define MV64340_TIMER_COUNTER3 0x85C
968#define MV64340_TIMER_COUNTER_0_3_CONTROL 0x864
969#define MV64340_TIMER_COUNTER_0_3_INTERRUPT_CAUSE 0x868
970#define MV64340_TIMER_COUNTER_0_3_INTERRUPT_MASK 0x86c
971
972/****************************************/
973/* Watchdog registers */
974/****************************************/
975
976#define MV64340_WATCHDOG_CONFIG_REG 0xb410
977#define MV64340_WATCHDOG_VALUE_REG 0xb414
978
979/****************************************/
980/* I2C Registers */
981/****************************************/
982
983#define MV64XXX_I2C_CTLR_NAME "mv64xxx i2c"
984#define MV64XXX_I2C_OFFSET 0xc000
985#define MV64XXX_I2C_REG_BLOCK_SIZE 0x0020
986
987/****************************************/
988/* GPP Interface Registers */
989/****************************************/
990
991#define MV64340_GPP_IO_CONTROL 0xf100
992#define MV64340_GPP_LEVEL_CONTROL 0xf110
993#define MV64340_GPP_VALUE 0xf104
994#define MV64340_GPP_INTERRUPT_CAUSE 0xf108
995#define MV64340_GPP_INTERRUPT_MASK0 0xf10c
996#define MV64340_GPP_INTERRUPT_MASK1 0xf114
997#define MV64340_GPP_VALUE_SET 0xf118
998#define MV64340_GPP_VALUE_CLEAR 0xf11c
999
1000/****************************************/
1001/* Interrupt Controller Registers */
1002/****************************************/
1003
1004/****************************************/
1005/* Interrupts */
1006/****************************************/
1007
1008#define MV64340_MAIN_INTERRUPT_CAUSE_LOW 0x004
1009#define MV64340_MAIN_INTERRUPT_CAUSE_HIGH 0x00c
1010#define MV64340_CPU_INTERRUPT0_MASK_LOW 0x014
1011#define MV64340_CPU_INTERRUPT0_MASK_HIGH 0x01c
1012#define MV64340_CPU_INTERRUPT0_SELECT_CAUSE 0x024
1013#define MV64340_CPU_INTERRUPT1_MASK_LOW 0x034
1014#define MV64340_CPU_INTERRUPT1_MASK_HIGH 0x03c
1015#define MV64340_CPU_INTERRUPT1_SELECT_CAUSE 0x044
1016#define MV64340_INTERRUPT0_MASK_0_LOW 0x054
1017#define MV64340_INTERRUPT0_MASK_0_HIGH 0x05c
1018#define MV64340_INTERRUPT0_SELECT_CAUSE 0x064
1019#define MV64340_INTERRUPT1_MASK_0_LOW 0x074
1020#define MV64340_INTERRUPT1_MASK_0_HIGH 0x07c
1021#define MV64340_INTERRUPT1_SELECT_CAUSE 0x084
1022
1023/****************************************/
1024/* MPP Interface Registers */
1025/****************************************/
1026
1027#define MV64340_MPP_CONTROL0 0xf000
1028#define MV64340_MPP_CONTROL1 0xf004
1029#define MV64340_MPP_CONTROL2 0xf008
1030#define MV64340_MPP_CONTROL3 0xf00c
1031
1032/****************************************/
1033/* Serial Initialization registers */
1034/****************************************/
1035
1036#define MV64340_SERIAL_INIT_LAST_DATA 0xf324
1037#define MV64340_SERIAL_INIT_CONTROL 0xf328
1038#define MV64340_SERIAL_INIT_STATUS 0xf32c
1039
1040extern void mv64340_irq_init(unsigned int base);
1041
1042/* MPSC Platform Device, Driver Data (Shared register regions) */
1043#define MPSC_SHARED_NAME "mpsc_shared"
1044
1045#define MPSC_ROUTING_BASE_ORDER 0
1046#define MPSC_SDMA_INTR_BASE_ORDER 1
1047
1048#define MPSC_ROUTING_REG_BLOCK_SIZE 0x000c
1049#define MPSC_SDMA_INTR_REG_BLOCK_SIZE 0x0084
1050
1051struct mpsc_shared_pdata {
1052 u32 mrr_val;
1053 u32 rcrr_val;
1054 u32 tcrr_val;
1055 u32 intr_cause_val;
1056 u32 intr_mask_val;
1057};
1058
1059/* MPSC Platform Device, Driver Data */
1060#define MPSC_CTLR_NAME "mpsc"
1061
1062#define MPSC_BASE_ORDER 0
1063#define MPSC_SDMA_BASE_ORDER 1
1064#define MPSC_BRG_BASE_ORDER 2
1065
1066#define MPSC_REG_BLOCK_SIZE 0x0038
1067#define MPSC_SDMA_REG_BLOCK_SIZE 0x0c18
1068#define MPSC_BRG_REG_BLOCK_SIZE 0x0008
1069
1070struct mpsc_pdata {
1071 u8 mirror_regs;
1072 u8 cache_mgmt;
1073 u8 max_idle;
1074 int default_baud;
1075 int default_bits;
1076 int default_parity;
1077 int default_flow;
1078 u32 chr_1_val;
1079 u32 chr_2_val;
1080 u32 chr_10_val;
1081 u32 mpcr_val;
1082 u32 bcr_val;
1083 u8 brg_can_tune;
1084 u8 brg_clk_src;
1085 u32 brg_clk_freq;
1086};
1087
1088/* i2c Platform Device, Driver Data */
1089struct mv64xxx_i2c_pdata {
1090 u32 freq_m;
1091 u32 freq_n;
1092 u32 timeout; /* In milliseconds */
1093 u32 retries;
1094};
1095
1096/* These macros describe Ethernet Port configuration reg (Px_cR) bits */
1097#define MV643XX_ETH_UNICAST_NORMAL_MODE 0
1098#define MV643XX_ETH_UNICAST_PROMISCUOUS_MODE (1<<0)
1099#define MV643XX_ETH_DEFAULT_RX_QUEUE_0 0
1100#define MV643XX_ETH_DEFAULT_RX_QUEUE_1 (1<<1)
1101#define MV643XX_ETH_DEFAULT_RX_QUEUE_2 (1<<2)
1102#define MV643XX_ETH_DEFAULT_RX_QUEUE_3 ((1<<2) | (1<<1))
1103#define MV643XX_ETH_DEFAULT_RX_QUEUE_4 (1<<3)
1104#define MV643XX_ETH_DEFAULT_RX_QUEUE_5 ((1<<3) | (1<<1))
1105#define MV643XX_ETH_DEFAULT_RX_QUEUE_6 ((1<<3) | (1<<2))
1106#define MV643XX_ETH_DEFAULT_RX_QUEUE_7 ((1<<3) | (1<<2) | (1<<1))
1107#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_0 0
1108#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_1 (1<<4)
1109#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_2 (1<<5)
1110#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_3 ((1<<5) | (1<<4))
1111#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_4 (1<<6)
1112#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_5 ((1<<6) | (1<<4))
1113#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_6 ((1<<6) | (1<<5))
1114#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_7 ((1<<6) | (1<<5) | (1<<4))
1115#define MV643XX_ETH_RECEIVE_BC_IF_NOT_IP_OR_ARP 0
1116#define MV643XX_ETH_REJECT_BC_IF_NOT_IP_OR_ARP (1<<7)
1117#define MV643XX_ETH_RECEIVE_BC_IF_IP 0
1118#define MV643XX_ETH_REJECT_BC_IF_IP (1<<8)
1119#define MV643XX_ETH_RECEIVE_BC_IF_ARP 0
1120#define MV643XX_ETH_REJECT_BC_IF_ARP (1<<9)
1121#define MV643XX_ETH_TX_AM_NO_UPDATE_ERROR_SUMMARY (1<<12)
1122#define MV643XX_ETH_CAPTURE_TCP_FRAMES_DIS 0
1123#define MV643XX_ETH_CAPTURE_TCP_FRAMES_EN (1<<14)
1124#define MV643XX_ETH_CAPTURE_UDP_FRAMES_DIS 0
1125#define MV643XX_ETH_CAPTURE_UDP_FRAMES_EN (1<<15)
1126#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_0 0
1127#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_1 (1<<16)
1128#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_2 (1<<17)
1129#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_3 ((1<<17) | (1<<16))
1130#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_4 (1<<18)
1131#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_5 ((1<<18) | (1<<16))
1132#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_6 ((1<<18) | (1<<17))
1133#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_7 ((1<<18) | (1<<17) | (1<<16))
1134#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_0 0
1135#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_1 (1<<19)
1136#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_2 (1<<20)
1137#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_3 ((1<<20) | (1<<19))
1138#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_4 ((1<<21)
1139#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_5 ((1<<21) | (1<<19))
1140#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_6 ((1<<21) | (1<<20))
1141#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_7 ((1<<21) | (1<<20) | (1<<19))
1142#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_0 0
1143#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_1 (1<<22)
1144#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_2 (1<<23)
1145#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_3 ((1<<23) | (1<<22))
1146#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_4 (1<<24)
1147#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_5 ((1<<24) | (1<<22))
1148#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_6 ((1<<24) | (1<<23))
1149#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_7 ((1<<24) | (1<<23) | (1<<22))
1150
1151#define MV643XX_ETH_PORT_CONFIG_DEFAULT_VALUE \
1152 MV643XX_ETH_UNICAST_NORMAL_MODE | \
1153 MV643XX_ETH_DEFAULT_RX_QUEUE_0 | \
1154 MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_0 | \
1155 MV643XX_ETH_RECEIVE_BC_IF_NOT_IP_OR_ARP | \
1156 MV643XX_ETH_RECEIVE_BC_IF_IP | \
1157 MV643XX_ETH_RECEIVE_BC_IF_ARP | \
1158 MV643XX_ETH_CAPTURE_TCP_FRAMES_DIS | \
1159 MV643XX_ETH_CAPTURE_UDP_FRAMES_DIS | \
1160 MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_0 | \
1161 MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_0 | \
1162 MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_0
1163
1164/* These macros describe Ethernet Port configuration extend reg (Px_cXR) bits*/
1165#define MV643XX_ETH_CLASSIFY_EN (1<<0)
1166#define MV643XX_ETH_SPAN_BPDU_PACKETS_AS_NORMAL 0
1167#define MV643XX_ETH_SPAN_BPDU_PACKETS_TO_RX_QUEUE_7 (1<<1)
1168#define MV643XX_ETH_PARTITION_DISABLE 0
1169#define MV643XX_ETH_PARTITION_ENABLE (1<<2)
1170
1171#define MV643XX_ETH_PORT_CONFIG_EXTEND_DEFAULT_VALUE \
1172 MV643XX_ETH_SPAN_BPDU_PACKETS_AS_NORMAL | \
1173 MV643XX_ETH_PARTITION_DISABLE
1174
1175/* These macros describe Ethernet Port Sdma configuration reg (SDCR) bits */
1176#define MV643XX_ETH_RIFB (1<<0)
1177#define MV643XX_ETH_RX_BURST_SIZE_1_64BIT 0
1178#define MV643XX_ETH_RX_BURST_SIZE_2_64BIT (1<<1)
1179#define MV643XX_ETH_RX_BURST_SIZE_4_64BIT (1<<2)
1180#define MV643XX_ETH_RX_BURST_SIZE_8_64BIT ((1<<2) | (1<<1))
1181#define MV643XX_ETH_RX_BURST_SIZE_16_64BIT (1<<3)
1182#define MV643XX_ETH_BLM_RX_NO_SWAP (1<<4)
1183#define MV643XX_ETH_BLM_RX_BYTE_SWAP 0
1184#define MV643XX_ETH_BLM_TX_NO_SWAP (1<<5)
1185#define MV643XX_ETH_BLM_TX_BYTE_SWAP 0
1186#define MV643XX_ETH_DESCRIPTORS_BYTE_SWAP (1<<6)
1187#define MV643XX_ETH_DESCRIPTORS_NO_SWAP 0
1188#define MV643XX_ETH_TX_BURST_SIZE_1_64BIT 0
1189#define MV643XX_ETH_TX_BURST_SIZE_2_64BIT (1<<22)
1190#define MV643XX_ETH_TX_BURST_SIZE_4_64BIT (1<<23)
1191#define MV643XX_ETH_TX_BURST_SIZE_8_64BIT ((1<<23) | (1<<22))
1192#define MV643XX_ETH_TX_BURST_SIZE_16_64BIT (1<<24)
1193
1194#define MV643XX_ETH_IPG_INT_RX(value) ((value & 0x3fff) << 8)
1195
1196#define MV643XX_ETH_PORT_SDMA_CONFIG_DEFAULT_VALUE \
1197 MV643XX_ETH_RX_BURST_SIZE_4_64BIT | \
1198 MV643XX_ETH_IPG_INT_RX(0) | \
1199 MV643XX_ETH_TX_BURST_SIZE_4_64BIT
1200
1201/* These macros describe Ethernet Port serial control reg (PSCR) bits */
1202#define MV643XX_ETH_SERIAL_PORT_DISABLE 0
1203#define MV643XX_ETH_SERIAL_PORT_ENABLE (1<<0)
1204#define MV643XX_ETH_FORCE_LINK_PASS (1<<1)
1205#define MV643XX_ETH_DO_NOT_FORCE_LINK_PASS 0
1206#define MV643XX_ETH_ENABLE_AUTO_NEG_FOR_DUPLX 0
1207#define MV643XX_ETH_DISABLE_AUTO_NEG_FOR_DUPLX (1<<2)
1208#define MV643XX_ETH_ENABLE_AUTO_NEG_FOR_FLOW_CTRL 0
1209#define MV643XX_ETH_DISABLE_AUTO_NEG_FOR_FLOW_CTRL (1<<3)
1210#define MV643XX_ETH_ADV_NO_FLOW_CTRL 0
1211#define MV643XX_ETH_ADV_SYMMETRIC_FLOW_CTRL (1<<4)
1212#define MV643XX_ETH_FORCE_FC_MODE_NO_PAUSE_DIS_TX 0
1213#define MV643XX_ETH_FORCE_FC_MODE_TX_PAUSE_DIS (1<<5)
1214#define MV643XX_ETH_FORCE_BP_MODE_NO_JAM 0
1215#define MV643XX_ETH_FORCE_BP_MODE_JAM_TX (1<<7)
1216#define MV643XX_ETH_FORCE_BP_MODE_JAM_TX_ON_RX_ERR (1<<8)
1217#define MV643XX_ETH_FORCE_LINK_FAIL 0
1218#define MV643XX_ETH_DO_NOT_FORCE_LINK_FAIL (1<<10)
1219#define MV643XX_ETH_RETRANSMIT_16_ATTEMPTS 0
1220#define MV643XX_ETH_RETRANSMIT_FOREVER (1<<11)
1221#define MV643XX_ETH_DISABLE_AUTO_NEG_SPEED_GMII (1<<13)
1222#define MV643XX_ETH_ENABLE_AUTO_NEG_SPEED_GMII 0
1223#define MV643XX_ETH_DTE_ADV_0 0
1224#define MV643XX_ETH_DTE_ADV_1 (1<<14)
1225#define MV643XX_ETH_DISABLE_AUTO_NEG_BYPASS 0
1226#define MV643XX_ETH_ENABLE_AUTO_NEG_BYPASS (1<<15)
1227#define MV643XX_ETH_AUTO_NEG_NO_CHANGE 0
1228#define MV643XX_ETH_RESTART_AUTO_NEG (1<<16)
1229#define MV643XX_ETH_MAX_RX_PACKET_1518BYTE 0
1230#define MV643XX_ETH_MAX_RX_PACKET_1522BYTE (1<<17)
1231#define MV643XX_ETH_MAX_RX_PACKET_1552BYTE (1<<18)
1232#define MV643XX_ETH_MAX_RX_PACKET_9022BYTE ((1<<18) | (1<<17))
1233#define MV643XX_ETH_MAX_RX_PACKET_9192BYTE (1<<19)
1234#define MV643XX_ETH_MAX_RX_PACKET_9700BYTE ((1<<19) | (1<<17))
1235#define MV643XX_ETH_SET_EXT_LOOPBACK (1<<20)
1236#define MV643XX_ETH_CLR_EXT_LOOPBACK 0
1237#define MV643XX_ETH_SET_FULL_DUPLEX_MODE (1<<21)
1238#define MV643XX_ETH_SET_HALF_DUPLEX_MODE 0
1239#define MV643XX_ETH_ENABLE_FLOW_CTRL_TX_RX_IN_FULL_DUPLEX (1<<22)
1240#define MV643XX_ETH_DISABLE_FLOW_CTRL_TX_RX_IN_FULL_DUPLEX 0
1241#define MV643XX_ETH_SET_GMII_SPEED_TO_10_100 0
1242#define MV643XX_ETH_SET_GMII_SPEED_TO_1000 (1<<23)
1243#define MV643XX_ETH_SET_MII_SPEED_TO_10 0
1244#define MV643XX_ETH_SET_MII_SPEED_TO_100 (1<<24)
1245
1246#define MV643XX_ETH_PORT_SERIAL_CONTROL_DEFAULT_VALUE \
1247 MV643XX_ETH_DO_NOT_FORCE_LINK_PASS | \
1248 MV643XX_ETH_ENABLE_AUTO_NEG_FOR_DUPLX | \
1249 MV643XX_ETH_DISABLE_AUTO_NEG_FOR_FLOW_CTRL | \
1250 MV643XX_ETH_ADV_SYMMETRIC_FLOW_CTRL | \
1251 MV643XX_ETH_FORCE_FC_MODE_NO_PAUSE_DIS_TX | \
1252 MV643XX_ETH_FORCE_BP_MODE_NO_JAM | \
1253 (1<<9) /* reserved */ | \
1254 MV643XX_ETH_DO_NOT_FORCE_LINK_FAIL | \
1255 MV643XX_ETH_RETRANSMIT_16_ATTEMPTS | \
1256 MV643XX_ETH_ENABLE_AUTO_NEG_SPEED_GMII | \
1257 MV643XX_ETH_DTE_ADV_0 | \
1258 MV643XX_ETH_DISABLE_AUTO_NEG_BYPASS | \
1259 MV643XX_ETH_AUTO_NEG_NO_CHANGE | \
1260 MV643XX_ETH_MAX_RX_PACKET_9700BYTE | \
1261 MV643XX_ETH_CLR_EXT_LOOPBACK | \
1262 MV643XX_ETH_SET_FULL_DUPLEX_MODE | \
1263 MV643XX_ETH_ENABLE_FLOW_CTRL_TX_RX_IN_FULL_DUPLEX
1264
1265/* These macros describe Ethernet Serial Status reg (PSR) bits */
1266#define MV643XX_ETH_PORT_STATUS_MODE_10_BIT (1<<0)
1267#define MV643XX_ETH_PORT_STATUS_LINK_UP (1<<1)
1268#define MV643XX_ETH_PORT_STATUS_FULL_DUPLEX (1<<2)
1269#define MV643XX_ETH_PORT_STATUS_FLOW_CONTROL (1<<3)
1270#define MV643XX_ETH_PORT_STATUS_GMII_1000 (1<<4)
1271#define MV643XX_ETH_PORT_STATUS_MII_100 (1<<5)
1272/* PSR bit 6 is undocumented */
1273#define MV643XX_ETH_PORT_STATUS_TX_IN_PROGRESS (1<<7)
1274#define MV643XX_ETH_PORT_STATUS_AUTONEG_BYPASSED (1<<8)
1275#define MV643XX_ETH_PORT_STATUS_PARTITION (1<<9)
1276#define MV643XX_ETH_PORT_STATUS_TX_FIFO_EMPTY (1<<10)
1277/* PSR bits 11-31 are reserved */
1278
1279#define MV643XX_ETH_PORT_DEFAULT_TRANSMIT_QUEUE_SIZE 800
1280#define MV643XX_ETH_PORT_DEFAULT_RECEIVE_QUEUE_SIZE 400
1281
1282#define MV643XX_ETH_DESC_SIZE 64
1283
1284#define MV643XX_ETH_SHARED_NAME "mv643xx_eth_shared"
1285#define MV643XX_ETH_NAME "mv643xx_eth"
1286
1287struct mv643xx_eth_platform_data {
1288 /*
1289 * Non-values for mac_addr, phy_addr, port_config, etc.
1290 * override the default value. Setting the corresponding
1291 * force_* field, causes the default value to be overridden
1292 * even when zero.
1293 */
1294 unsigned int force_phy_addr:1;
1295 unsigned int force_port_config:1;
1296 unsigned int force_port_config_extend:1;
1297 unsigned int force_port_sdma_config:1;
1298 unsigned int force_port_serial_control:1;
1299 int phy_addr;
1300 char *mac_addr; /* pointer to mac address */
1301 u32 port_config;
1302 u32 port_config_extend;
1303 u32 port_sdma_config;
1304 u32 port_serial_control;
1305 u32 tx_queue_size;
1306 u32 rx_queue_size;
1307 u32 tx_sram_addr;
1308 u32 tx_sram_size;
1309 u32 rx_sram_addr;
1310 u32 rx_sram_size;
1311};
1312
1313#endif /* __ASM_MV643XX_H */
diff --git a/include/linux/n_r3964.h b/include/linux/n_r3964.h
new file mode 100644
index 000000000000..2352bcd31a06
--- /dev/null
+++ b/include/linux/n_r3964.h
@@ -0,0 +1,226 @@
1/* r3964 linediscipline for linux
2 *
3 * -----------------------------------------------------------
4 * Copyright by
5 * Philips Automation Projects
6 * Kassel (Germany)
7 * http://www.pap-philips.de
8 * -----------------------------------------------------------
9 * This software may be used and distributed according to the terms of
10 * the GNU General Public License, incorporated herein by reference.
11 *
12 * Author:
13 * L. Haag
14 *
15 * $Log: r3964.h,v $
16 * Revision 1.3 2001/03/18 13:02:24 dwmw2
17 * Fix timer usage, use spinlocks properly.
18 *
19 * Revision 1.2 2001/03/18 12:53:15 dwmw2
20 * Merge changes in 2.4.2
21 *
22 * Revision 1.1.1.1 1998/10/13 16:43:14 dwmw2
23 * This'll screw the version control
24 *
25 * Revision 1.6 1998/09/30 00:40:38 dwmw2
26 * Updated to use kernel's N_R3964 if available
27 *
28 * Revision 1.4 1998/04/02 20:29:44 lhaag
29 * select, blocking, ...
30 *
31 * Revision 1.3 1998/02/12 18:58:43 root
32 * fixed some memory leaks
33 * calculation of checksum characters
34 *
35 * Revision 1.2 1998/02/07 13:03:17 root
36 * ioctl read_telegram
37 *
38 * Revision 1.1 1998/02/06 19:19:43 root
39 * Initial revision
40 *
41 *
42 */
43
44#ifndef __LINUX_N_R3964_H__
45#define __LINUX_N_R3964_H__
46
47/* line disciplines for r3964 protocol */
48#include <asm/termios.h>
49
50#ifdef __KERNEL__
51/*
52 * Common ascii handshake characters:
53 */
54
55#define STX 0x02
56#define ETX 0x03
57#define DLE 0x10
58#define NAK 0x15
59
60/*
61 * Timeouts (msecs/10 msecs per timer interrupt):
62 */
63
64#define R3964_TO_QVZ 550/10
65#define R3964_TO_ZVZ 220/10
66#define R3964_TO_NO_BUF 400/10
67#define R3964_NO_TX_ROOM 100/10
68#define R3964_TO_RX_PANIC 4000/10
69#define R3964_MAX_RETRIES 5
70
71#endif
72
73/*
74 * Ioctl-commands
75 */
76
77#define R3964_ENABLE_SIGNALS 0x5301
78#define R3964_SETPRIORITY 0x5302
79#define R3964_USE_BCC 0x5303
80#define R3964_READ_TELEGRAM 0x5304
81
82/* Options for R3964_SETPRIORITY */
83#define R3964_MASTER 0
84#define R3964_SLAVE 1
85
86/* Options for R3964_ENABLE_SIGNALS */
87#define R3964_SIG_ACK 0x0001
88#define R3964_SIG_DATA 0x0002
89#define R3964_SIG_ALL 0x000f
90#define R3964_SIG_NONE 0x0000
91#define R3964_USE_SIGIO 0x1000
92
93/*
94 * r3964 operation states:
95 */
96#ifdef __KERNEL__
97
98enum { R3964_IDLE,
99 R3964_TX_REQUEST, R3964_TRANSMITTING,
100 R3964_WAIT_ZVZ_BEFORE_TX_RETRY, R3964_WAIT_FOR_TX_ACK,
101 R3964_WAIT_FOR_RX_BUF,
102 R3964_RECEIVING, R3964_WAIT_FOR_BCC, R3964_WAIT_FOR_RX_REPEAT
103 };
104
105/*
106 * All open file-handles are 'clients' and are stored in a linked list:
107 */
108
109struct r3964_message;
110
111struct r3964_client_info {
112 spinlock_t lock;
113 pid_t pid;
114 unsigned int sig_flags;
115
116 struct r3964_client_info *next;
117
118 struct r3964_message *first_msg;
119 struct r3964_message *last_msg;
120 struct r3964_block_header *next_block_to_read;
121 int msg_count;
122};
123
124
125#endif
126
127/* types for msg_id: */
128enum {R3964_MSG_ACK=1, R3964_MSG_DATA };
129
130#define R3964_MAX_MSG_COUNT 32
131
132/* error codes for client messages */
133#define R3964_OK 0 /* no error. */
134#define R3964_TX_FAIL -1 /* transmission error, block NOT sent */
135#define R3964_OVERFLOW -2 /* msg queue overflow */
136
137/* the client gets this struct when calling read(fd,...): */
138struct r3964_client_message {
139 int msg_id;
140 int arg;
141 int error_code;
142};
143
144#define R3964_MTU 256
145
146
147#ifdef __KERNEL__
148
149struct r3964_block_header;
150
151/* internal version of client_message: */
152struct r3964_message {
153 int msg_id;
154 int arg;
155 int error_code;
156 struct r3964_block_header *block;
157 struct r3964_message *next;
158};
159
160/*
161 * Header of received block in rx_buf/tx_buf:
162 */
163
164struct r3964_block_header
165{
166 unsigned int length; /* length in chars without header */
167 unsigned char *data; /* usually data is located
168 immediately behind this struct */
169 unsigned int locks; /* only used in rx_buffer */
170
171 struct r3964_block_header *next;
172 struct r3964_client_info *owner; /* =NULL in rx_buffer */
173};
174
175/*
176 * If rx_buf hasn't enough space to store R3964_MTU chars,
177 * we will reject all incoming STX-requests by sending NAK.
178 */
179
180#define RX_BUF_SIZE 4000
181#define TX_BUF_SIZE 4000
182#define R3964_MAX_BLOCKS_IN_RX_QUEUE 100
183
184#define R3964_PARITY 0x0001
185#define R3964_FRAME 0x0002
186#define R3964_OVERRUN 0x0004
187#define R3964_UNKNOWN 0x0008
188#define R3964_BREAK 0x0010
189#define R3964_CHECKSUM 0x0020
190#define R3964_ERROR 0x003f
191#define R3964_BCC 0x4000
192#define R3964_DEBUG 0x8000
193
194
195struct r3964_info {
196 spinlock_t lock;
197 struct tty_struct *tty;
198 unsigned char priority;
199 unsigned char *rx_buf; /* ring buffer */
200 unsigned char *tx_buf;
201
202 wait_queue_head_t read_wait;
203 //struct wait_queue *read_wait;
204
205 struct r3964_block_header *rx_first;
206 struct r3964_block_header *rx_last;
207 struct r3964_block_header *tx_first;
208 struct r3964_block_header *tx_last;
209 unsigned int tx_position;
210 unsigned int rx_position;
211 unsigned char last_rx;
212 unsigned char bcc;
213 unsigned int blocks_in_rx_queue;
214
215
216 struct r3964_client_info *firstClient;
217 unsigned int state;
218 unsigned int flags;
219
220 struct timer_list tmr;
221 int nRetry;
222};
223
224#endif
225
226#endif
diff --git a/include/linux/namei.h b/include/linux/namei.h
new file mode 100644
index 000000000000..7db67b008cac
--- /dev/null
+++ b/include/linux/namei.h
@@ -0,0 +1,87 @@
1#ifndef _LINUX_NAMEI_H
2#define _LINUX_NAMEI_H
3
4#include <linux/linkage.h>
5
6struct vfsmount;
7
8struct open_intent {
9 int flags;
10 int create_mode;
11};
12
13enum { MAX_NESTED_LINKS = 5 };
14
15struct nameidata {
16 struct dentry *dentry;
17 struct vfsmount *mnt;
18 struct qstr last;
19 unsigned int flags;
20 int last_type;
21 unsigned depth;
22 char *saved_names[MAX_NESTED_LINKS + 1];
23
24 /* Intent data */
25 union {
26 struct open_intent open;
27 } intent;
28};
29
30/*
31 * Type of the last component on LOOKUP_PARENT
32 */
33enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT, LAST_BIND};
34
35/*
36 * The bitmask for a lookup event:
37 * - follow links at the end
38 * - require a directory
39 * - ending slashes ok even for nonexistent files
40 * - internal "there are more path compnents" flag
41 * - locked when lookup done with dcache_lock held
42 * - dentry cache is untrusted; force a real lookup
43 */
44#define LOOKUP_FOLLOW 1
45#define LOOKUP_DIRECTORY 2
46#define LOOKUP_CONTINUE 4
47#define LOOKUP_PARENT 16
48#define LOOKUP_NOALT 32
49#define LOOKUP_REVAL 64
50/*
51 * Intent data
52 */
53#define LOOKUP_OPEN (0x0100)
54#define LOOKUP_CREATE (0x0200)
55#define LOOKUP_ACCESS (0x0400)
56
57extern int FASTCALL(__user_walk(const char __user *, unsigned, struct nameidata *));
58#define user_path_walk(name,nd) \
59 __user_walk(name, LOOKUP_FOLLOW, nd)
60#define user_path_walk_link(name,nd) \
61 __user_walk(name, 0, nd)
62extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
63extern int FASTCALL(path_walk(const char *, struct nameidata *));
64extern int FASTCALL(link_path_walk(const char *, struct nameidata *));
65extern void path_release(struct nameidata *);
66extern void path_release_on_umount(struct nameidata *);
67
68extern struct dentry * lookup_one_len(const char *, struct dentry *, int);
69extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
70
71extern int follow_down(struct vfsmount **, struct dentry **);
72extern int follow_up(struct vfsmount **, struct dentry **);
73
74extern struct dentry *lock_rename(struct dentry *, struct dentry *);
75extern void unlock_rename(struct dentry *, struct dentry *);
76
77static inline void nd_set_link(struct nameidata *nd, char *path)
78{
79 nd->saved_names[nd->depth] = path;
80}
81
82static inline char *nd_get_link(struct nameidata *nd)
83{
84 return nd->saved_names[nd->depth];
85}
86
87#endif /* _LINUX_NAMEI_H */
diff --git a/include/linux/namespace.h b/include/linux/namespace.h
new file mode 100644
index 000000000000..9eca1558d72f
--- /dev/null
+++ b/include/linux/namespace.h
@@ -0,0 +1,42 @@
1#ifndef _NAMESPACE_H_
2#define _NAMESPACE_H_
3#ifdef __KERNEL__
4
5#include <linux/mount.h>
6#include <linux/sched.h>
7
8struct namespace {
9 atomic_t count;
10 struct vfsmount * root;
11 struct list_head list;
12 struct rw_semaphore sem;
13};
14
15extern void umount_tree(struct vfsmount *);
16extern int copy_namespace(int, struct task_struct *);
17extern void __put_namespace(struct namespace *namespace);
18
19static inline void put_namespace(struct namespace *namespace)
20{
21 if (atomic_dec_and_test(&namespace->count))
22 __put_namespace(namespace);
23}
24
25static inline void exit_namespace(struct task_struct *p)
26{
27 struct namespace *namespace = p->namespace;
28 if (namespace) {
29 task_lock(p);
30 p->namespace = NULL;
31 task_unlock(p);
32 put_namespace(namespace);
33 }
34}
35
36static inline void get_namespace(struct namespace *namespace)
37{
38 atomic_inc(&namespace->count);
39}
40
41#endif
42#endif
diff --git a/include/linux/nbd.h b/include/linux/nbd.h
new file mode 100644
index 000000000000..090e210e98f0
--- /dev/null
+++ b/include/linux/nbd.h
@@ -0,0 +1,91 @@
1/*
2 * 1999 Copyright (C) Pavel Machek, pavel@ucw.cz. This code is GPL.
3 * 1999/11/04 Copyright (C) 1999 VMware, Inc. (Regis "HPReg" Duchesne)
4 * Made nbd_end_request() use the io_request_lock
5 * 2001 Copyright (C) Steven Whitehouse
6 * New nbd_end_request() for compatibility with new linux block
7 * layer code.
8 * 2003/06/24 Louis D. Langholtz <ldl@aros.net>
9 * Removed unneeded blksize_bits field from nbd_device struct.
10 * Cleanup PARANOIA usage & code.
11 * 2004/02/19 Paul Clements
12 * Removed PARANOIA, plus various cleanup and comments
13 */
14
15#ifndef LINUX_NBD_H
16#define LINUX_NBD_H
17
18#define NBD_SET_SOCK _IO( 0xab, 0 )
19#define NBD_SET_BLKSIZE _IO( 0xab, 1 )
20#define NBD_SET_SIZE _IO( 0xab, 2 )
21#define NBD_DO_IT _IO( 0xab, 3 )
22#define NBD_CLEAR_SOCK _IO( 0xab, 4 )
23#define NBD_CLEAR_QUE _IO( 0xab, 5 )
24#define NBD_PRINT_DEBUG _IO( 0xab, 6 )
25#define NBD_SET_SIZE_BLOCKS _IO( 0xab, 7 )
26#define NBD_DISCONNECT _IO( 0xab, 8 )
27
28enum {
29 NBD_CMD_READ = 0,
30 NBD_CMD_WRITE = 1,
31 NBD_CMD_DISC = 2
32};
33
34#define nbd_cmd(req) ((req)->cmd[0])
35#define MAX_NBD 128
36
37/* userspace doesn't need the nbd_device structure */
38#ifdef __KERNEL__
39
40/* values for flags field */
41#define NBD_READ_ONLY 0x0001
42#define NBD_WRITE_NOCHK 0x0002
43
44struct nbd_device {
45 int flags;
46 int harderror; /* Code of hard error */
47 struct socket * sock;
48 struct file * file; /* If == NULL, device is not ready, yet */
49 int magic;
50 spinlock_t queue_lock;
51 struct list_head queue_head;/* Requests are added here... */
52 struct semaphore tx_lock;
53 struct gendisk *disk;
54 int blksize;
55 u64 bytesize;
56};
57
58#endif
59
60/* These are sent over the network in the request/reply magic fields */
61
62#define NBD_REQUEST_MAGIC 0x25609513
63#define NBD_REPLY_MAGIC 0x67446698
64/* Do *not* use magics: 0x12560953 0x96744668. */
65
66/*
67 * This is the packet used for communication between client and
68 * server. All data are in network byte order.
69 */
70struct nbd_request {
71 u32 magic;
72 u32 type; /* == READ || == WRITE */
73 char handle[8];
74 u64 from;
75 u32 len;
76}
77#ifdef __GNUC__
78 __attribute__ ((packed))
79#endif
80;
81
82/*
83 * This is the reply packet that nbd-server sends back to the client after
84 * it has completed an I/O request (or an error occurs).
85 */
86struct nbd_reply {
87 u32 magic;
88 u32 error; /* 0 = ok, else error */
89 char handle[8]; /* handle you got from request */
90};
91#endif
diff --git a/include/linux/ncp.h b/include/linux/ncp.h
new file mode 100644
index 000000000000..99f77876b716
--- /dev/null
+++ b/include/linux/ncp.h
@@ -0,0 +1,201 @@
1/*
2 * ncp.h
3 *
4 * Copyright (C) 1995 by Volker Lendecke
5 * Modified for sparc by J.F. Chadima
6 * Modified for __constant_ntoh by Frank A. Vorstenbosch
7 *
8 */
9
10#ifndef _LINUX_NCP_H
11#define _LINUX_NCP_H
12
13#include <linux/types.h>
14
15#define NCP_PTYPE (0x11)
16#define NCP_PORT (0x0451)
17
18#define NCP_ALLOC_SLOT_REQUEST (0x1111)
19#define NCP_REQUEST (0x2222)
20#define NCP_DEALLOC_SLOT_REQUEST (0x5555)
21
22struct ncp_request_header {
23 __u16 type __attribute__((packed));
24 __u8 sequence __attribute__((packed));
25 __u8 conn_low __attribute__((packed));
26 __u8 task __attribute__((packed));
27 __u8 conn_high __attribute__((packed));
28 __u8 function __attribute__((packed));
29 __u8 data[0] __attribute__((packed));
30};
31
32#define NCP_REPLY (0x3333)
33#define NCP_WATCHDOG (0x3E3E)
34#define NCP_POSITIVE_ACK (0x9999)
35
36struct ncp_reply_header {
37 __u16 type __attribute__((packed));
38 __u8 sequence __attribute__((packed));
39 __u8 conn_low __attribute__((packed));
40 __u8 task __attribute__((packed));
41 __u8 conn_high __attribute__((packed));
42 __u8 completion_code __attribute__((packed));
43 __u8 connection_state __attribute__((packed));
44 __u8 data[0] __attribute__((packed));
45};
46
47#define NCP_VOLNAME_LEN (16)
48#define NCP_NUMBER_OF_VOLUMES (256)
49struct ncp_volume_info {
50 __u32 total_blocks;
51 __u32 free_blocks;
52 __u32 purgeable_blocks;
53 __u32 not_yet_purgeable_blocks;
54 __u32 total_dir_entries;
55 __u32 available_dir_entries;
56 __u8 sectors_per_block;
57 char volume_name[NCP_VOLNAME_LEN + 1];
58};
59
60#define AR_READ (cpu_to_le16(1))
61#define AR_WRITE (cpu_to_le16(2))
62#define AR_EXCLUSIVE (cpu_to_le16(0x20))
63
64#define NCP_FILE_ID_LEN 6
65
66/* Defines for Name Spaces */
67#define NW_NS_DOS 0
68#define NW_NS_MAC 1
69#define NW_NS_NFS 2
70#define NW_NS_FTAM 3
71#define NW_NS_OS2 4
72
73/* Defines for ReturnInformationMask */
74#define RIM_NAME (cpu_to_le32(1))
75#define RIM_SPACE_ALLOCATED (cpu_to_le32(2))
76#define RIM_ATTRIBUTES (cpu_to_le32(4))
77#define RIM_DATA_SIZE (cpu_to_le32(8))
78#define RIM_TOTAL_SIZE (cpu_to_le32(0x10))
79#define RIM_EXT_ATTR_INFO (cpu_to_le32(0x20))
80#define RIM_ARCHIVE (cpu_to_le32(0x40))
81#define RIM_MODIFY (cpu_to_le32(0x80))
82#define RIM_CREATION (cpu_to_le32(0x100))
83#define RIM_OWNING_NAMESPACE (cpu_to_le32(0x200))
84#define RIM_DIRECTORY (cpu_to_le32(0x400))
85#define RIM_RIGHTS (cpu_to_le32(0x800))
86#define RIM_ALL (cpu_to_le32(0xFFF))
87#define RIM_COMPRESSED_INFO (cpu_to_le32(0x80000000))
88
89/* Defines for NSInfoBitMask */
90#define NSIBM_NFS_NAME 0x0001
91#define NSIBM_NFS_MODE 0x0002
92#define NSIBM_NFS_GID 0x0004
93#define NSIBM_NFS_NLINKS 0x0008
94#define NSIBM_NFS_RDEV 0x0010
95#define NSIBM_NFS_LINK 0x0020
96#define NSIBM_NFS_CREATED 0x0040
97#define NSIBM_NFS_UID 0x0080
98#define NSIBM_NFS_ACSFLAG 0x0100
99#define NSIBM_NFS_MYFLAG 0x0200
100
101/* open/create modes */
102#define OC_MODE_OPEN 0x01
103#define OC_MODE_TRUNCATE 0x02
104#define OC_MODE_REPLACE 0x02
105#define OC_MODE_CREATE 0x08
106
107/* open/create results */
108#define OC_ACTION_NONE 0x00
109#define OC_ACTION_OPEN 0x01
110#define OC_ACTION_CREATE 0x02
111#define OC_ACTION_TRUNCATE 0x04
112#define OC_ACTION_REPLACE 0x04
113
114/* access rights attributes */
115#ifndef AR_READ_ONLY
116#define AR_READ_ONLY 0x0001
117#define AR_WRITE_ONLY 0x0002
118#define AR_DENY_READ 0x0004
119#define AR_DENY_WRITE 0x0008
120#define AR_COMPATIBILITY 0x0010
121#define AR_WRITE_THROUGH 0x0040
122#define AR_OPEN_COMPRESSED 0x0100
123#endif
124
125struct nw_nfs_info {
126 __u32 mode;
127 __u32 rdev;
128};
129
130struct nw_info_struct {
131 __u32 spaceAlloc __attribute__((packed));
132 __le32 attributes __attribute__((packed));
133 __u16 flags __attribute__((packed));
134 __le32 dataStreamSize __attribute__((packed));
135 __le32 totalStreamSize __attribute__((packed));
136 __u16 numberOfStreams __attribute__((packed));
137 __le16 creationTime __attribute__((packed));
138 __le16 creationDate __attribute__((packed));
139 __u32 creatorID __attribute__((packed));
140 __le16 modifyTime __attribute__((packed));
141 __le16 modifyDate __attribute__((packed));
142 __u32 modifierID __attribute__((packed));
143 __le16 lastAccessDate __attribute__((packed));
144 __u16 archiveTime __attribute__((packed));
145 __u16 archiveDate __attribute__((packed));
146 __u32 archiverID __attribute__((packed));
147 __u16 inheritedRightsMask __attribute__((packed));
148 __le32 dirEntNum __attribute__((packed));
149 __le32 DosDirNum __attribute__((packed));
150 __u32 volNumber __attribute__((packed));
151 __u32 EADataSize __attribute__((packed));
152 __u32 EAKeyCount __attribute__((packed));
153 __u32 EAKeySize __attribute__((packed));
154 __u32 NSCreator __attribute__((packed));
155 __u8 nameLen __attribute__((packed));
156 __u8 entryName[256] __attribute__((packed));
157 /* libncp may depend on there being nothing after entryName */
158#ifdef __KERNEL__
159 struct nw_nfs_info nfs;
160#endif
161};
162
163/* modify mask - use with MODIFY_DOS_INFO structure */
164#define DM_ATTRIBUTES (cpu_to_le32(0x02))
165#define DM_CREATE_DATE (cpu_to_le32(0x04))
166#define DM_CREATE_TIME (cpu_to_le32(0x08))
167#define DM_CREATOR_ID (cpu_to_le32(0x10))
168#define DM_ARCHIVE_DATE (cpu_to_le32(0x20))
169#define DM_ARCHIVE_TIME (cpu_to_le32(0x40))
170#define DM_ARCHIVER_ID (cpu_to_le32(0x80))
171#define DM_MODIFY_DATE (cpu_to_le32(0x0100))
172#define DM_MODIFY_TIME (cpu_to_le32(0x0200))
173#define DM_MODIFIER_ID (cpu_to_le32(0x0400))
174#define DM_LAST_ACCESS_DATE (cpu_to_le32(0x0800))
175#define DM_INHERITED_RIGHTS_MASK (cpu_to_le32(0x1000))
176#define DM_MAXIMUM_SPACE (cpu_to_le32(0x2000))
177
178struct nw_modify_dos_info {
179 __le32 attributes __attribute__((packed));
180 __le16 creationDate __attribute__((packed));
181 __le16 creationTime __attribute__((packed));
182 __u32 creatorID __attribute__((packed));
183 __le16 modifyDate __attribute__((packed));
184 __le16 modifyTime __attribute__((packed));
185 __u32 modifierID __attribute__((packed));
186 __u16 archiveDate __attribute__((packed));
187 __u16 archiveTime __attribute__((packed));
188 __u32 archiverID __attribute__((packed));
189 __le16 lastAccessDate __attribute__((packed));
190 __u16 inheritanceGrantMask __attribute__((packed));
191 __u16 inheritanceRevokeMask __attribute__((packed));
192 __u32 maximumSpace __attribute__((packed));
193};
194
195struct nw_search_sequence {
196 __u8 volNumber __attribute__((packed));
197 __u32 dirBase __attribute__((packed));
198 __u32 sequence __attribute__((packed));
199};
200
201#endif /* _LINUX_NCP_H */
diff --git a/include/linux/ncp_fs.h b/include/linux/ncp_fs.h
new file mode 100644
index 000000000000..7297e4372c0f
--- /dev/null
+++ b/include/linux/ncp_fs.h
@@ -0,0 +1,300 @@
1/*
2 * ncp_fs.h
3 *
4 * Copyright (C) 1995, 1996 by Volker Lendecke
5 *
6 */
7
8#ifndef _LINUX_NCP_FS_H
9#define _LINUX_NCP_FS_H
10
11#include <linux/fs.h>
12#include <linux/in.h>
13#include <linux/types.h>
14
15#include <linux/ncp_fs_i.h>
16#include <linux/ncp_fs_sb.h>
17#include <linux/ipx.h>
18#include <linux/ncp_no.h>
19
20/*
21 * ioctl commands
22 */
23
24struct ncp_ioctl_request {
25 unsigned int function;
26 unsigned int size;
27 char __user *data;
28};
29
30struct ncp_fs_info {
31 int version;
32 struct sockaddr_ipx addr;
33 __kernel_uid_t mounted_uid;
34 int connection; /* Connection number the server assigned us */
35 int buffer_size; /* The negotiated buffer size, to be
36 used for read/write requests! */
37
38 int volume_number;
39 __le32 directory_id;
40};
41
42struct ncp_fs_info_v2 {
43 int version;
44 unsigned long mounted_uid;
45 unsigned int connection;
46 unsigned int buffer_size;
47
48 unsigned int volume_number;
49 __le32 directory_id;
50
51 __u32 dummy1;
52 __u32 dummy2;
53 __u32 dummy3;
54};
55
56struct ncp_sign_init
57{
58 char sign_root[8];
59 char sign_last[16];
60};
61
62struct ncp_lock_ioctl
63{
64#define NCP_LOCK_LOG 0
65#define NCP_LOCK_SH 1
66#define NCP_LOCK_EX 2
67#define NCP_LOCK_CLEAR 256
68 int cmd;
69 int origin;
70 unsigned int offset;
71 unsigned int length;
72#define NCP_LOCK_DEFAULT_TIMEOUT 18
73#define NCP_LOCK_MAX_TIMEOUT 180
74 int timeout;
75};
76
77struct ncp_setroot_ioctl
78{
79 int volNumber;
80 int namespace;
81 __le32 dirEntNum;
82};
83
84struct ncp_objectname_ioctl
85{
86#define NCP_AUTH_NONE 0x00
87#define NCP_AUTH_BIND 0x31
88#define NCP_AUTH_NDS 0x32
89 int auth_type;
90 size_t object_name_len;
91 void __user * object_name; /* an userspace data, in most cases user name */
92};
93
94struct ncp_privatedata_ioctl
95{
96 size_t len;
97 void __user * data; /* ~1000 for NDS */
98};
99
100/* NLS charsets by ioctl */
101#define NCP_IOCSNAME_LEN 20
102struct ncp_nls_ioctl
103{
104 unsigned char codepage[NCP_IOCSNAME_LEN+1];
105 unsigned char iocharset[NCP_IOCSNAME_LEN+1];
106};
107
108#define NCP_IOC_NCPREQUEST _IOR('n', 1, struct ncp_ioctl_request)
109#define NCP_IOC_GETMOUNTUID _IOW('n', 2, __kernel_old_uid_t)
110#define NCP_IOC_GETMOUNTUID2 _IOW('n', 2, unsigned long)
111
112#define NCP_IOC_CONN_LOGGED_IN _IO('n', 3)
113
114#define NCP_GET_FS_INFO_VERSION (1)
115#define NCP_IOC_GET_FS_INFO _IOWR('n', 4, struct ncp_fs_info)
116#define NCP_GET_FS_INFO_VERSION_V2 (2)
117#define NCP_IOC_GET_FS_INFO_V2 _IOWR('n', 4, struct ncp_fs_info_v2)
118
119#define NCP_IOC_SIGN_INIT _IOR('n', 5, struct ncp_sign_init)
120#define NCP_IOC_SIGN_WANTED _IOR('n', 6, int)
121#define NCP_IOC_SET_SIGN_WANTED _IOW('n', 6, int)
122
123#define NCP_IOC_LOCKUNLOCK _IOR('n', 7, struct ncp_lock_ioctl)
124
125#define NCP_IOC_GETROOT _IOW('n', 8, struct ncp_setroot_ioctl)
126#define NCP_IOC_SETROOT _IOR('n', 8, struct ncp_setroot_ioctl)
127
128#define NCP_IOC_GETOBJECTNAME _IOWR('n', 9, struct ncp_objectname_ioctl)
129#define NCP_IOC_SETOBJECTNAME _IOR('n', 9, struct ncp_objectname_ioctl)
130#define NCP_IOC_GETPRIVATEDATA _IOWR('n', 10, struct ncp_privatedata_ioctl)
131#define NCP_IOC_SETPRIVATEDATA _IOR('n', 10, struct ncp_privatedata_ioctl)
132
133#define NCP_IOC_GETCHARSETS _IOWR('n', 11, struct ncp_nls_ioctl)
134#define NCP_IOC_SETCHARSETS _IOR('n', 11, struct ncp_nls_ioctl)
135
136#define NCP_IOC_GETDENTRYTTL _IOW('n', 12, __u32)
137#define NCP_IOC_SETDENTRYTTL _IOR('n', 12, __u32)
138
139/*
140 * The packet size to allocate. One page should be enough.
141 */
142#define NCP_PACKET_SIZE 4070
143
144#define NCP_MAXPATHLEN 255
145#define NCP_MAXNAMELEN 14
146
147#ifdef __KERNEL__
148
149#include <linux/config.h>
150
151/* undef because public define in umsdos_fs.h (ncp_fs.h isn't public) */
152#undef PRINTK
153/* define because it is easy to change PRINTK to {*}PRINTK */
154#define PRINTK(format, args...) printk(KERN_DEBUG format , ## args)
155
156#undef NCPFS_PARANOIA
157#ifdef NCPFS_PARANOIA
158#define PPRINTK(format, args...) PRINTK(format , ## args)
159#else
160#define PPRINTK(format, args...)
161#endif
162
163#ifndef DEBUG_NCP
164#define DEBUG_NCP 0
165#endif
166#if DEBUG_NCP > 0
167#define DPRINTK(format, args...) PRINTK(format , ## args)
168#else
169#define DPRINTK(format, args...)
170#endif
171#if DEBUG_NCP > 1
172#define DDPRINTK(format, args...) PRINTK(format , ## args)
173#else
174#define DDPRINTK(format, args...)
175#endif
176
177#define NCP_MAX_RPC_TIMEOUT (6*HZ)
178
179
180struct ncp_entry_info {
181 struct nw_info_struct i;
182 ino_t ino;
183 int opened;
184 int access;
185 unsigned int volume;
186 __u8 file_handle[6];
187};
188
189/* Guess, what 0x564c is :-) */
190#define NCP_SUPER_MAGIC 0x564c
191
192
193static inline struct ncp_server *NCP_SBP(struct super_block *sb)
194{
195 return sb->s_fs_info;
196}
197
198#define NCP_SERVER(inode) NCP_SBP((inode)->i_sb)
199static inline struct ncp_inode_info *NCP_FINFO(struct inode *inode)
200{
201 return container_of(inode, struct ncp_inode_info, vfs_inode);
202}
203
204#ifdef DEBUG_NCP_MALLOC
205
206#include <linux/slab.h>
207
208extern int ncp_malloced;
209extern int ncp_current_malloced;
210
211static inline void *
212 ncp_kmalloc(unsigned int size, int priority)
213{
214 ncp_malloced += 1;
215 ncp_current_malloced += 1;
216 return kmalloc(size, priority);
217}
218
219static inline void ncp_kfree_s(void *obj, int size)
220{
221 ncp_current_malloced -= 1;
222 kfree(obj);
223}
224
225#else /* DEBUG_NCP_MALLOC */
226
227#define ncp_kmalloc(s,p) kmalloc(s,p)
228#define ncp_kfree_s(o,s) kfree(o)
229
230#endif /* DEBUG_NCP_MALLOC */
231
232/* linux/fs/ncpfs/inode.c */
233int ncp_notify_change(struct dentry *, struct iattr *);
234struct inode *ncp_iget(struct super_block *, struct ncp_entry_info *);
235void ncp_update_inode(struct inode *, struct ncp_entry_info *);
236void ncp_update_inode2(struct inode *, struct ncp_entry_info *);
237
238/* linux/fs/ncpfs/dir.c */
239extern struct inode_operations ncp_dir_inode_operations;
240extern struct file_operations ncp_dir_operations;
241int ncp_conn_logged_in(struct super_block *);
242int ncp_date_dos2unix(__le16 time, __le16 date);
243void ncp_date_unix2dos(int unix_date, __le16 * time, __le16 * date);
244
245/* linux/fs/ncpfs/ioctl.c */
246int ncp_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
247
248/* linux/fs/ncpfs/sock.c */
249int ncp_request2(struct ncp_server *server, int function,
250 void* reply, int max_reply_size);
251static inline int ncp_request(struct ncp_server *server, int function) {
252 return ncp_request2(server, function, server->packet, server->packet_size);
253}
254int ncp_connect(struct ncp_server *server);
255int ncp_disconnect(struct ncp_server *server);
256void ncp_lock_server(struct ncp_server *server);
257void ncp_unlock_server(struct ncp_server *server);
258
259/* linux/fs/ncpfs/file.c */
260extern struct inode_operations ncp_file_inode_operations;
261extern struct file_operations ncp_file_operations;
262int ncp_make_open(struct inode *, int);
263
264/* linux/fs/ncpfs/mmap.c */
265int ncp_mmap(struct file *, struct vm_area_struct *);
266
267/* linux/fs/ncpfs/ncplib_kernel.c */
268int ncp_make_closed(struct inode *);
269
270#define ncp_namespace(i) (NCP_SERVER(i)->name_space[NCP_FINFO(i)->volNumber])
271
272static inline int ncp_preserve_entry_case(struct inode *i, __u32 nscreator)
273{
274#ifdef CONFIG_NCPFS_SMALLDOS
275 int ns = ncp_namespace(i);
276
277 if ((ns == NW_NS_DOS)
278#ifdef CONFIG_NCPFS_OS2_NS
279 || ((ns == NW_NS_OS2) && (nscreator == NW_NS_DOS))
280#endif /* CONFIG_NCPFS_OS2_NS */
281 )
282 return 0;
283#endif /* CONFIG_NCPFS_SMALLDOS */
284 return 1;
285}
286
287#define ncp_preserve_case(i) (ncp_namespace(i) != NW_NS_DOS)
288
289static inline int ncp_case_sensitive(struct inode *i)
290{
291#ifdef CONFIG_NCPFS_NFS_NS
292 return ncp_namespace(i) == NW_NS_NFS;
293#else
294 return 0;
295#endif /* CONFIG_NCPFS_NFS_NS */
296}
297
298#endif /* __KERNEL__ */
299
300#endif /* _LINUX_NCP_FS_H */
diff --git a/include/linux/ncp_fs_i.h b/include/linux/ncp_fs_i.h
new file mode 100644
index 000000000000..415be1ec6f98
--- /dev/null
+++ b/include/linux/ncp_fs_i.h
@@ -0,0 +1,33 @@
1/*
2 * ncp_fs_i.h
3 *
4 * Copyright (C) 1995 Volker Lendecke
5 *
6 */
7
8#ifndef _LINUX_NCP_FS_I
9#define _LINUX_NCP_FS_I
10
11#ifdef __KERNEL__
12
13/*
14 * 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.
16 */
17struct ncp_inode_info {
18 __le32 dirEntNum;
19 __le32 DosDirNum;
20 __u8 volNumber;
21 __le32 nwattr;
22 struct semaphore open_sem;
23 atomic_t opened;
24 int access;
25 int flags;
26#define NCPI_KLUDGE_SYMLINK 0x0001
27 __u8 file_handle[6];
28 struct inode vfs_inode;
29};
30
31#endif /* __KERNEL__ */
32
33#endif /* _LINUX_NCP_FS_I */
diff --git a/include/linux/ncp_fs_sb.h b/include/linux/ncp_fs_sb.h
new file mode 100644
index 000000000000..cf858eb80f0b
--- /dev/null
+++ b/include/linux/ncp_fs_sb.h
@@ -0,0 +1,157 @@
1/*
2 * ncp_fs_sb.h
3 *
4 * Copyright (C) 1995, 1996 by Volker Lendecke
5 *
6 */
7
8#ifndef _NCP_FS_SB
9#define _NCP_FS_SB
10
11#include <linux/types.h>
12#include <linux/ncp_mount.h>
13#include <linux/net.h>
14
15#ifdef __KERNEL__
16
17#include <linux/workqueue.h>
18
19#define NCP_DEFAULT_OPTIONS 0 /* 2 for packet signatures */
20
21struct sock;
22
23struct ncp_server {
24
25 struct ncp_mount_data_kernel m; /* Nearly all of the mount data is of
26 interest for us later, so we store
27 it completely. */
28
29 __u8 name_space[NCP_NUMBER_OF_VOLUMES + 2];
30
31 struct file *ncp_filp; /* File pointer to ncp socket */
32 struct socket *ncp_sock;/* ncp socket */
33 struct file *info_filp;
34 struct socket *info_sock;
35
36 u8 sequence;
37 u8 task;
38 u16 connection; /* Remote connection number */
39
40 u8 completion; /* Status message from server */
41 u8 conn_status; /* Bit 4 = 1 ==> Server going down, no
42 requests allowed anymore.
43 Bit 0 = 1 ==> Server is down. */
44
45 int buffer_size; /* Negotiated bufsize */
46
47 int reply_size; /* Size of last reply */
48
49 int packet_size;
50 unsigned char *packet; /* Here we prepare requests and
51 receive replies */
52
53 int lock; /* To prevent mismatch in protocols. */
54 struct semaphore sem;
55
56 int current_size; /* for packet preparation */
57 int has_subfunction;
58 int ncp_reply_size;
59
60 int root_setuped;
61
62 /* info for packet signing */
63 int sign_wanted; /* 1=Server needs signed packets */
64 int sign_active; /* 0=don't do signing, 1=do */
65 char sign_root[8]; /* generated from password and encr. key */
66 char sign_last[16];
67
68 /* Authentication info: NDS or BINDERY, username */
69 struct {
70 int auth_type;
71 size_t object_name_len;
72 void* object_name;
73 int object_type;
74 } auth;
75 /* Password info */
76 struct {
77 size_t len;
78 void* data;
79 } priv;
80
81 /* nls info: codepage for volume and charset for I/O */
82 struct nls_table *nls_vol;
83 struct nls_table *nls_io;
84
85 /* maximum age in jiffies */
86 int dentry_ttl;
87
88 /* miscellaneous */
89 unsigned int flags;
90
91 spinlock_t requests_lock; /* Lock accesses to tx.requests, tx.creq and rcv.creq when STREAM mode */
92
93 void (*data_ready)(struct sock* sk, int len);
94 void (*error_report)(struct sock* sk);
95 void (*write_space)(struct sock* sk); /* STREAM mode only */
96 struct {
97 struct work_struct tq; /* STREAM/DGRAM: data/error ready */
98 struct ncp_request_reply* creq; /* STREAM/DGRAM: awaiting reply from this request */
99 struct semaphore creq_sem; /* DGRAM only: lock accesses to rcv.creq */
100
101 unsigned int state; /* STREAM only: receiver state */
102 struct {
103 __u32 magic __attribute__((packed));
104 __u32 len __attribute__((packed));
105 __u16 type __attribute__((packed));
106 __u16 p1 __attribute__((packed));
107 __u16 p2 __attribute__((packed));
108 __u16 p3 __attribute__((packed));
109 __u16 type2 __attribute__((packed));
110 } buf; /* STREAM only: temporary buffer */
111 unsigned char* ptr; /* STREAM only: pointer to data */
112 size_t len; /* STREAM only: length of data to receive */
113 } rcv;
114 struct {
115 struct list_head requests; /* STREAM only: queued requests */
116 struct work_struct tq; /* STREAM only: transmitter ready */
117 struct ncp_request_reply* creq; /* STREAM only: currently transmitted entry */
118 } tx;
119 struct timer_list timeout_tm; /* DGRAM only: timeout timer */
120 struct work_struct timeout_tq; /* DGRAM only: associated queue, we run timers from process context */
121 int timeout_last; /* DGRAM only: current timeout length */
122 int timeout_retries; /* DGRAM only: retries left */
123 struct {
124 size_t len;
125 __u8 data[128];
126 } unexpected_packet;
127};
128
129extern void ncp_tcp_rcv_proc(void *server);
130extern void ncp_tcp_tx_proc(void *server);
131extern void ncpdgram_rcv_proc(void *server);
132extern void ncpdgram_timeout_proc(void *server);
133extern void ncpdgram_timeout_call(unsigned long server);
134extern void ncp_tcp_data_ready(struct sock* sk, int len);
135extern void ncp_tcp_write_space(struct sock* sk);
136extern void ncp_tcp_error_report(struct sock* sk);
137
138#define NCP_FLAG_UTF8 1
139
140#define NCP_CLR_FLAG(server, flag) ((server)->flags &= ~(flag))
141#define NCP_SET_FLAG(server, flag) ((server)->flags |= (flag))
142#define NCP_IS_FLAG(server, flag) ((server)->flags & (flag))
143
144static inline int ncp_conn_valid(struct ncp_server *server)
145{
146 return ((server->conn_status & 0x11) == 0);
147}
148
149static inline void ncp_invalidate_conn(struct ncp_server *server)
150{
151 server->conn_status |= 0x01;
152}
153
154#endif /* __KERNEL__ */
155
156#endif
157
diff --git a/include/linux/ncp_mount.h b/include/linux/ncp_mount.h
new file mode 100644
index 000000000000..f46bddcdbd3b
--- /dev/null
+++ b/include/linux/ncp_mount.h
@@ -0,0 +1,93 @@
1/*
2 * ncp_mount.h
3 *
4 * Copyright (C) 1995, 1996 by Volker Lendecke
5 *
6 */
7
8#ifndef _LINUX_NCP_MOUNT_H
9#define _LINUX_NCP_MOUNT_H
10
11#include <linux/types.h>
12#include <linux/ncp.h>
13
14#define NCP_MOUNT_VERSION 3 /* Binary */
15
16/* Values for flags */
17#define NCP_MOUNT_SOFT 0x0001
18#define NCP_MOUNT_INTR 0x0002
19#define NCP_MOUNT_STRONG 0x0004 /* enable delete/rename of r/o files */
20#define NCP_MOUNT_NO_OS2 0x0008 /* do not use OS/2 (LONG) namespace */
21#define NCP_MOUNT_NO_NFS 0x0010 /* do not use NFS namespace */
22#define NCP_MOUNT_EXTRAS 0x0020
23#define NCP_MOUNT_SYMLINKS 0x0040 /* enable symlinks */
24#define NCP_MOUNT_NFS_EXTRAS 0x0080 /* Enable use of NFS NS meta-info */
25
26struct ncp_mount_data {
27 int version;
28 unsigned int ncp_fd; /* The socket to the ncp port */
29 __kernel_uid_t mounted_uid; /* Who may umount() this filesystem? */
30 __kernel_pid_t wdog_pid; /* Who cares for our watchdog packets? */
31
32 unsigned char mounted_vol[NCP_VOLNAME_LEN + 1];
33 unsigned int time_out; /* How long should I wait after
34 sending a NCP request? */
35 unsigned int retry_count; /* And how often should I retry? */
36 unsigned int flags;
37
38 __kernel_uid_t uid;
39 __kernel_gid_t gid;
40 __kernel_mode_t file_mode;
41 __kernel_mode_t dir_mode;
42};
43
44#define NCP_MOUNT_VERSION_V4 (4) /* Binary or text */
45
46struct ncp_mount_data_v4 {
47 int version;
48 unsigned long flags; /* NCP_MOUNT_* flags */
49 /* MIPS uses long __kernel_uid_t, but... */
50 /* we neever pass -1, so it is safe */
51 unsigned long mounted_uid; /* Who may umount() this filesystem? */
52 /* MIPS uses long __kernel_pid_t */
53 long wdog_pid; /* Who cares for our watchdog packets? */
54
55 unsigned int ncp_fd; /* The socket to the ncp port */
56 unsigned int time_out; /* How long should I wait after
57 sending a NCP request? */
58 unsigned int retry_count; /* And how often should I retry? */
59
60 /* MIPS uses long __kernel_uid_t... */
61 /* we never pass -1, so it is safe */
62 unsigned long uid;
63 unsigned long gid;
64 /* MIPS uses unsigned long __kernel_mode_t */
65 unsigned long file_mode;
66 unsigned long dir_mode;
67};
68
69#define NCP_MOUNT_VERSION_V5 (5) /* Text only */
70
71#ifdef __KERNEL__
72
73struct ncp_mount_data_kernel {
74 unsigned long flags; /* NCP_MOUNT_* flags */
75 unsigned int int_flags; /* internal flags */
76#define NCP_IMOUNT_LOGGEDIN_POSSIBLE 0x0001
77 __kernel_uid32_t mounted_uid; /* Who may umount() this filesystem? */
78 __kernel_pid_t wdog_pid; /* Who cares for our watchdog packets? */
79 unsigned int ncp_fd; /* The socket to the ncp port */
80 unsigned int time_out; /* How long should I wait after
81 sending a NCP request? */
82 unsigned int retry_count; /* And how often should I retry? */
83 unsigned char mounted_vol[NCP_VOLNAME_LEN + 1];
84 __kernel_uid32_t uid;
85 __kernel_gid32_t gid;
86 __kernel_mode_t file_mode;
87 __kernel_mode_t dir_mode;
88 int info_fd;
89};
90
91#endif /* __KERNEL__ */
92
93#endif
diff --git a/include/linux/ncp_no.h b/include/linux/ncp_no.h
new file mode 100644
index 000000000000..f56a696a7cc6
--- /dev/null
+++ b/include/linux/ncp_no.h
@@ -0,0 +1,19 @@
1#ifndef _NCP_NO
2#define _NCP_NO
3
4/* these define the attribute byte as seen by NCP */
5#define aRONLY (__constant_cpu_to_le32(1))
6#define aHIDDEN (__constant_cpu_to_le32(2))
7#define aSYSTEM (__constant_cpu_to_le32(4))
8#define aEXECUTE (__constant_cpu_to_le32(8))
9#define aDIR (__constant_cpu_to_le32(0x10))
10#define aARCH (__constant_cpu_to_le32(0x20))
11#define aSHARED (__constant_cpu_to_le32(0x80))
12#define aDONTSUBALLOCATE (__constant_cpu_to_le32(1L<<11))
13#define aTRANSACTIONAL (__constant_cpu_to_le32(1L<<12))
14#define aPURGE (__constant_cpu_to_le32(1L<<16))
15#define aRENAMEINHIBIT (__constant_cpu_to_le32(1L<<17))
16#define aDELETEINHIBIT (__constant_cpu_to_le32(1L<<18))
17#define aDONTCOMPRESS (__constant_cpu_to_le32(1L<<27))
18
19#endif /* _NCP_NO */
diff --git a/include/linux/net.h b/include/linux/net.h
new file mode 100644
index 000000000000..7823b3482506
--- /dev/null
+++ b/include/linux/net.h
@@ -0,0 +1,287 @@
1/*
2 * NET An implementation of the SOCKET network access protocol.
3 * This is the master header file for the Linux NET layer,
4 * or, in plain English: the networking handling part of the
5 * kernel.
6 *
7 * Version: @(#)net.h 1.0.3 05/25/93
8 *
9 * Authors: Orest Zborowski, <obz@Kodak.COM>
10 * Ross Biro, <bir7@leland.Stanford.Edu>
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version
16 * 2 of the License, or (at your option) any later version.
17 */
18#ifndef _LINUX_NET_H
19#define _LINUX_NET_H
20
21#include <linux/config.h>
22#include <linux/wait.h>
23#include <linux/stringify.h>
24#include <asm/socket.h>
25
26struct poll_table_struct;
27struct inode;
28
29#define NPROTO 32 /* should be enough for now.. */
30
31#define SYS_SOCKET 1 /* sys_socket(2) */
32#define SYS_BIND 2 /* sys_bind(2) */
33#define SYS_CONNECT 3 /* sys_connect(2) */
34#define SYS_LISTEN 4 /* sys_listen(2) */
35#define SYS_ACCEPT 5 /* sys_accept(2) */
36#define SYS_GETSOCKNAME 6 /* sys_getsockname(2) */
37#define SYS_GETPEERNAME 7 /* sys_getpeername(2) */
38#define SYS_SOCKETPAIR 8 /* sys_socketpair(2) */
39#define SYS_SEND 9 /* sys_send(2) */
40#define SYS_RECV 10 /* sys_recv(2) */
41#define SYS_SENDTO 11 /* sys_sendto(2) */
42#define SYS_RECVFROM 12 /* sys_recvfrom(2) */
43#define SYS_SHUTDOWN 13 /* sys_shutdown(2) */
44#define SYS_SETSOCKOPT 14 /* sys_setsockopt(2) */
45#define SYS_GETSOCKOPT 15 /* sys_getsockopt(2) */
46#define SYS_SENDMSG 16 /* sys_sendmsg(2) */
47#define SYS_RECVMSG 17 /* sys_recvmsg(2) */
48
49typedef enum {
50 SS_FREE = 0, /* not allocated */
51 SS_UNCONNECTED, /* unconnected to any socket */
52 SS_CONNECTING, /* in process of connecting */
53 SS_CONNECTED, /* connected to socket */
54 SS_DISCONNECTING /* in process of disconnecting */
55} socket_state;
56
57#define __SO_ACCEPTCON (1 << 16) /* performed a listen */
58
59#ifdef __KERNEL__
60
61#define SOCK_ASYNC_NOSPACE 0
62#define SOCK_ASYNC_WAITDATA 1
63#define SOCK_NOSPACE 2
64#define SOCK_PASSCRED 3
65
66#ifndef ARCH_HAS_SOCKET_TYPES
67/** sock_type - Socket types
68 *
69 * When adding some new socket type please
70 * grep ARCH_HAS_SOCKET_TYPE include/asm-* /socket.h, at least MIPS
71 * overrides this enum for binary compat reasons.
72 *
73 * @SOCK_STREAM - stream (connection) socket
74 * @SOCK_DGRAM - datagram (conn.less) socket
75 * @SOCK_RAW - raw socket
76 * @SOCK_RDM - reliably-delivered message
77 * @SOCK_SEQPACKET - sequential packet socket
78 * @SOCK_PACKET - linux specific way of getting packets at the dev level.
79 * For writing rarp and other similar things on the user level.
80 */
81enum sock_type {
82 SOCK_STREAM = 1,
83 SOCK_DGRAM = 2,
84 SOCK_RAW = 3,
85 SOCK_RDM = 4,
86 SOCK_SEQPACKET = 5,
87 SOCK_PACKET = 10,
88};
89
90#define SOCK_MAX (SOCK_PACKET + 1)
91
92#endif /* ARCH_HAS_SOCKET_TYPES */
93
94/**
95 * struct socket - general BSD socket
96 * @state - socket state (%SS_CONNECTED, etc)
97 * @flags - socket flags (%SOCK_ASYNC_NOSPACE, etc)
98 * @ops - protocol specific socket operations
99 * @fasync_list - Asynchronous wake up list
100 * @file - File back pointer for gc
101 * @sk - internal networking protocol agnostic socket representation
102 * @wait - wait queue for several uses
103 * @type - socket type (%SOCK_STREAM, etc)
104 * @passcred - credentials (used only in Unix Sockets (aka PF_LOCAL))
105 */
106struct socket {
107 socket_state state;
108 unsigned long flags;
109 struct proto_ops *ops;
110 struct fasync_struct *fasync_list;
111 struct file *file;
112 struct sock *sk;
113 wait_queue_head_t wait;
114 short type;
115};
116
117struct vm_area_struct;
118struct page;
119struct kiocb;
120struct sockaddr;
121struct msghdr;
122struct module;
123
124struct proto_ops {
125 int family;
126 struct module *owner;
127 int (*release) (struct socket *sock);
128 int (*bind) (struct socket *sock,
129 struct sockaddr *myaddr,
130 int sockaddr_len);
131 int (*connect) (struct socket *sock,
132 struct sockaddr *vaddr,
133 int sockaddr_len, int flags);
134 int (*socketpair)(struct socket *sock1,
135 struct socket *sock2);
136 int (*accept) (struct socket *sock,
137 struct socket *newsock, int flags);
138 int (*getname) (struct socket *sock,
139 struct sockaddr *addr,
140 int *sockaddr_len, int peer);
141 unsigned int (*poll) (struct file *file, struct socket *sock,
142 struct poll_table_struct *wait);
143 int (*ioctl) (struct socket *sock, unsigned int cmd,
144 unsigned long arg);
145 int (*listen) (struct socket *sock, int len);
146 int (*shutdown) (struct socket *sock, int flags);
147 int (*setsockopt)(struct socket *sock, int level,
148 int optname, char __user *optval, int optlen);
149 int (*getsockopt)(struct socket *sock, int level,
150 int optname, char __user *optval, int __user *optlen);
151 int (*sendmsg) (struct kiocb *iocb, struct socket *sock,
152 struct msghdr *m, size_t total_len);
153 int (*recvmsg) (struct kiocb *iocb, struct socket *sock,
154 struct msghdr *m, size_t total_len,
155 int flags);
156 int (*mmap) (struct file *file, struct socket *sock,
157 struct vm_area_struct * vma);
158 ssize_t (*sendpage) (struct socket *sock, struct page *page,
159 int offset, size_t size, int flags);
160};
161
162struct net_proto_family {
163 int family;
164 int (*create)(struct socket *sock, int protocol);
165 /* These are counters for the number of different methods of
166 each we support */
167 short authentication;
168 short encryption;
169 short encrypt_net;
170 struct module *owner;
171};
172
173struct iovec;
174struct kvec;
175
176extern int sock_wake_async(struct socket *sk, int how, int band);
177extern int sock_register(struct net_proto_family *fam);
178extern int sock_unregister(int family);
179extern int sock_create(int family, int type, int proto,
180 struct socket **res);
181extern int sock_create_kern(int family, int type, int proto,
182 struct socket **res);
183extern int sock_create_lite(int family, int type, int proto,
184 struct socket **res);
185extern void sock_release(struct socket *sock);
186extern int sock_sendmsg(struct socket *sock, struct msghdr *msg,
187 size_t len);
188extern int sock_recvmsg(struct socket *sock, struct msghdr *msg,
189 size_t size, int flags);
190extern int sock_map_fd(struct socket *sock);
191extern struct socket *sockfd_lookup(int fd, int *err);
192#define sockfd_put(sock) fput(sock->file)
193extern int net_ratelimit(void);
194extern unsigned long net_random(void);
195extern void net_srandom(unsigned long);
196extern void net_random_init(void);
197
198extern int kernel_sendmsg(struct socket *sock, struct msghdr *msg,
199 struct kvec *vec, size_t num, size_t len);
200extern int kernel_recvmsg(struct socket *sock, struct msghdr *msg,
201 struct kvec *vec, size_t num,
202 size_t len, int flags);
203
204#ifndef CONFIG_SMP
205#define SOCKOPS_WRAPPED(name) name
206#define SOCKOPS_WRAP(name, fam)
207#else
208
209#define SOCKOPS_WRAPPED(name) __unlocked_##name
210
211#define SOCKCALL_WRAP(name, call, parms, args) \
212static int __lock_##name##_##call parms \
213{ \
214 int ret; \
215 lock_kernel(); \
216 ret = __unlocked_##name##_ops.call args ;\
217 unlock_kernel(); \
218 return ret; \
219}
220
221#define SOCKCALL_UWRAP(name, call, parms, args) \
222static unsigned int __lock_##name##_##call parms \
223{ \
224 int ret; \
225 lock_kernel(); \
226 ret = __unlocked_##name##_ops.call args ;\
227 unlock_kernel(); \
228 return ret; \
229}
230
231
232#define SOCKOPS_WRAP(name, fam) \
233SOCKCALL_WRAP(name, release, (struct socket *sock), (sock)) \
234SOCKCALL_WRAP(name, bind, (struct socket *sock, struct sockaddr *uaddr, int addr_len), \
235 (sock, uaddr, addr_len)) \
236SOCKCALL_WRAP(name, connect, (struct socket *sock, struct sockaddr * uaddr, \
237 int addr_len, int flags), \
238 (sock, uaddr, addr_len, flags)) \
239SOCKCALL_WRAP(name, socketpair, (struct socket *sock1, struct socket *sock2), \
240 (sock1, sock2)) \
241SOCKCALL_WRAP(name, accept, (struct socket *sock, struct socket *newsock, \
242 int flags), (sock, newsock, flags)) \
243SOCKCALL_WRAP(name, getname, (struct socket *sock, struct sockaddr *uaddr, \
244 int *addr_len, int peer), (sock, uaddr, addr_len, peer)) \
245SOCKCALL_UWRAP(name, poll, (struct file *file, struct socket *sock, struct poll_table_struct *wait), \
246 (file, sock, wait)) \
247SOCKCALL_WRAP(name, ioctl, (struct socket *sock, unsigned int cmd, \
248 unsigned long arg), (sock, cmd, arg)) \
249SOCKCALL_WRAP(name, listen, (struct socket *sock, int len), (sock, len)) \
250SOCKCALL_WRAP(name, shutdown, (struct socket *sock, int flags), (sock, flags)) \
251SOCKCALL_WRAP(name, setsockopt, (struct socket *sock, int level, int optname, \
252 char __user *optval, int optlen), (sock, level, optname, optval, optlen)) \
253SOCKCALL_WRAP(name, getsockopt, (struct socket *sock, int level, int optname, \
254 char __user *optval, int __user *optlen), (sock, level, optname, optval, optlen)) \
255SOCKCALL_WRAP(name, sendmsg, (struct kiocb *iocb, struct socket *sock, struct msghdr *m, size_t len), \
256 (iocb, sock, m, len)) \
257SOCKCALL_WRAP(name, recvmsg, (struct kiocb *iocb, struct socket *sock, struct msghdr *m, size_t len, int flags), \
258 (iocb, sock, m, len, flags)) \
259SOCKCALL_WRAP(name, mmap, (struct file *file, struct socket *sock, struct vm_area_struct *vma), \
260 (file, sock, vma)) \
261 \
262static struct proto_ops name##_ops = { \
263 .family = fam, \
264 .owner = THIS_MODULE, \
265 .release = __lock_##name##_release, \
266 .bind = __lock_##name##_bind, \
267 .connect = __lock_##name##_connect, \
268 .socketpair = __lock_##name##_socketpair, \
269 .accept = __lock_##name##_accept, \
270 .getname = __lock_##name##_getname, \
271 .poll = __lock_##name##_poll, \
272 .ioctl = __lock_##name##_ioctl, \
273 .listen = __lock_##name##_listen, \
274 .shutdown = __lock_##name##_shutdown, \
275 .setsockopt = __lock_##name##_setsockopt, \
276 .getsockopt = __lock_##name##_getsockopt, \
277 .sendmsg = __lock_##name##_sendmsg, \
278 .recvmsg = __lock_##name##_recvmsg, \
279 .mmap = __lock_##name##_mmap, \
280};
281#endif
282
283#define MODULE_ALIAS_NETPROTO(proto) \
284 MODULE_ALIAS("net-pf-" __stringify(proto))
285
286#endif /* __KERNEL__ */
287#endif /* _LINUX_NET_H */
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
new file mode 100644
index 000000000000..8d775be67833
--- /dev/null
+++ b/include/linux/netdevice.h
@@ -0,0 +1,933 @@
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Definitions for the Interfaces handler.
7 *
8 * Version: @(#)dev.h 1.0.10 08/12/93
9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu>
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * Corey Minyard <wf-rch!minyard@relay.EU.net>
13 * Donald J. Becker, <becker@cesdis.gsfc.nasa.gov>
14 * Alan Cox, <Alan.Cox@linux.org>
15 * Bjorn Ekwall. <bj0rn@blox.se>
16 * Pekka Riikonen <priikone@poseidon.pspt.fi>
17 *
18 * This program is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU General Public License
20 * as published by the Free Software Foundation; either version
21 * 2 of the License, or (at your option) any later version.
22 *
23 * Moved to /usr/include/linux for NET3
24 */
25#ifndef _LINUX_NETDEVICE_H
26#define _LINUX_NETDEVICE_H
27
28#include <linux/if.h>
29#include <linux/if_ether.h>
30#include <linux/if_packet.h>
31
32#ifdef __KERNEL__
33#include <asm/atomic.h>
34#include <asm/cache.h>
35#include <asm/byteorder.h>
36
37#include <linux/config.h>
38#include <linux/device.h>
39#include <linux/percpu.h>
40
41struct divert_blk;
42struct vlan_group;
43struct ethtool_ops;
44struct netpoll;
45 /* source back-compat hooks */
46#define SET_ETHTOOL_OPS(netdev,ops) \
47 ( (netdev)->ethtool_ops = (ops) )
48
49#define HAVE_ALLOC_NETDEV /* feature macro: alloc_xxxdev
50 functions are available. */
51#define HAVE_FREE_NETDEV /* free_netdev() */
52#define HAVE_NETDEV_PRIV /* netdev_priv() */
53
54#define NET_XMIT_SUCCESS 0
55#define NET_XMIT_DROP 1 /* skb dropped */
56#define NET_XMIT_CN 2 /* congestion notification */
57#define NET_XMIT_POLICED 3 /* skb is shot by police */
58#define NET_XMIT_BYPASS 4 /* packet does not leave via dequeue;
59 (TC use only - dev_queue_xmit
60 returns this as NET_XMIT_SUCCESS) */
61
62/* Backlog congestion levels */
63#define NET_RX_SUCCESS 0 /* keep 'em coming, baby */
64#define NET_RX_DROP 1 /* packet dropped */
65#define NET_RX_CN_LOW 2 /* storm alert, just in case */
66#define NET_RX_CN_MOD 3 /* Storm on its way! */
67#define NET_RX_CN_HIGH 4 /* The storm is here */
68#define NET_RX_BAD 5 /* packet dropped due to kernel error */
69
70#define net_xmit_errno(e) ((e) != NET_XMIT_CN ? -ENOBUFS : 0)
71
72#endif
73
74#define MAX_ADDR_LEN 32 /* Largest hardware address length */
75
76/* Driver transmit return codes */
77#define NETDEV_TX_OK 0 /* driver took care of packet */
78#define NETDEV_TX_BUSY 1 /* driver tx path was busy*/
79#define NETDEV_TX_LOCKED -1 /* driver tx lock was already taken */
80
81/*
82 * Compute the worst case header length according to the protocols
83 * used.
84 */
85
86#if !defined(CONFIG_AX25) && !defined(CONFIG_AX25_MODULE) && !defined(CONFIG_TR)
87#define LL_MAX_HEADER 32
88#else
89#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
90#define LL_MAX_HEADER 96
91#else
92#define LL_MAX_HEADER 48
93#endif
94#endif
95
96#if !defined(CONFIG_NET_IPIP) && \
97 !defined(CONFIG_IPV6) && !defined(CONFIG_IPV6_MODULE)
98#define MAX_HEADER LL_MAX_HEADER
99#else
100#define MAX_HEADER (LL_MAX_HEADER + 48)
101#endif
102
103/*
104 * Network device statistics. Akin to the 2.0 ether stats but
105 * with byte counters.
106 */
107
108struct net_device_stats
109{
110 unsigned long rx_packets; /* total packets received */
111 unsigned long tx_packets; /* total packets transmitted */
112 unsigned long rx_bytes; /* total bytes received */
113 unsigned long tx_bytes; /* total bytes transmitted */
114 unsigned long rx_errors; /* bad packets received */
115 unsigned long tx_errors; /* packet transmit problems */
116 unsigned long rx_dropped; /* no space in linux buffers */
117 unsigned long tx_dropped; /* no space available in linux */
118 unsigned long multicast; /* multicast packets received */
119 unsigned long collisions;
120
121 /* detailed rx_errors: */
122 unsigned long rx_length_errors;
123 unsigned long rx_over_errors; /* receiver ring buff overflow */
124 unsigned long rx_crc_errors; /* recved pkt with crc error */
125 unsigned long rx_frame_errors; /* recv'd frame alignment error */
126 unsigned long rx_fifo_errors; /* recv'r fifo overrun */
127 unsigned long rx_missed_errors; /* receiver missed packet */
128
129 /* detailed tx_errors */
130 unsigned long tx_aborted_errors;
131 unsigned long tx_carrier_errors;
132 unsigned long tx_fifo_errors;
133 unsigned long tx_heartbeat_errors;
134 unsigned long tx_window_errors;
135
136 /* for cslip etc */
137 unsigned long rx_compressed;
138 unsigned long tx_compressed;
139};
140
141
142/* Media selection options. */
143enum {
144 IF_PORT_UNKNOWN = 0,
145 IF_PORT_10BASE2,
146 IF_PORT_10BASET,
147 IF_PORT_AUI,
148 IF_PORT_100BASET,
149 IF_PORT_100BASETX,
150 IF_PORT_100BASEFX
151};
152
153#ifdef __KERNEL__
154
155#include <linux/cache.h>
156#include <linux/skbuff.h>
157
158struct neighbour;
159struct neigh_parms;
160struct sk_buff;
161
162struct netif_rx_stats
163{
164 unsigned total;
165 unsigned dropped;
166 unsigned time_squeeze;
167 unsigned throttled;
168 unsigned fastroute_hit;
169 unsigned fastroute_success;
170 unsigned fastroute_defer;
171 unsigned fastroute_deferred_out;
172 unsigned fastroute_latency_reduction;
173 unsigned cpu_collision;
174};
175
176DECLARE_PER_CPU(struct netif_rx_stats, netdev_rx_stat);
177
178
179/*
180 * We tag multicasts with these structures.
181 */
182
183struct dev_mc_list
184{
185 struct dev_mc_list *next;
186 __u8 dmi_addr[MAX_ADDR_LEN];
187 unsigned char dmi_addrlen;
188 int dmi_users;
189 int dmi_gusers;
190};
191
192struct hh_cache
193{
194 struct hh_cache *hh_next; /* Next entry */
195 atomic_t hh_refcnt; /* number of users */
196 unsigned short hh_type; /* protocol identifier, f.e ETH_P_IP
197 * NOTE: For VLANs, this will be the
198 * encapuslated type. --BLG
199 */
200 int hh_len; /* length of header */
201 int (*hh_output)(struct sk_buff *skb);
202 rwlock_t hh_lock;
203
204 /* cached hardware header; allow for machine alignment needs. */
205#define HH_DATA_MOD 16
206#define HH_DATA_OFF(__len) \
207 (HH_DATA_MOD - ((__len) & (HH_DATA_MOD - 1)))
208#define HH_DATA_ALIGN(__len) \
209 (((__len)+(HH_DATA_MOD-1))&~(HH_DATA_MOD - 1))
210 unsigned long hh_data[HH_DATA_ALIGN(LL_MAX_HEADER) / sizeof(long)];
211};
212
213/* Reserve HH_DATA_MOD byte aligned hard_header_len, but at least that much.
214 * Alternative is:
215 * dev->hard_header_len ? (dev->hard_header_len +
216 * (HH_DATA_MOD - 1)) & ~(HH_DATA_MOD - 1) : 0
217 *
218 * We could use other alignment values, but we must maintain the
219 * relationship HH alignment <= LL alignment.
220 */
221#define LL_RESERVED_SPACE(dev) \
222 (((dev)->hard_header_len&~(HH_DATA_MOD - 1)) + HH_DATA_MOD)
223#define LL_RESERVED_SPACE_EXTRA(dev,extra) \
224 ((((dev)->hard_header_len+extra)&~(HH_DATA_MOD - 1)) + HH_DATA_MOD)
225
226/* These flag bits are private to the generic network queueing
227 * layer, they may not be explicitly referenced by any other
228 * code.
229 */
230
231enum netdev_state_t
232{
233 __LINK_STATE_XOFF=0,
234 __LINK_STATE_START,
235 __LINK_STATE_PRESENT,
236 __LINK_STATE_SCHED,
237 __LINK_STATE_NOCARRIER,
238 __LINK_STATE_RX_SCHED,
239 __LINK_STATE_LINKWATCH_PENDING
240};
241
242
243/*
244 * This structure holds at boot time configured netdevice settings. They
245 * are then used in the device probing.
246 */
247struct netdev_boot_setup {
248 char name[IFNAMSIZ];
249 struct ifmap map;
250};
251#define NETDEV_BOOT_SETUP_MAX 8
252
253
254/*
255 * The DEVICE structure.
256 * Actually, this whole structure is a big mistake. It mixes I/O
257 * data with strictly "high-level" data, and it has to know about
258 * almost every data structure used in the INET module.
259 *
260 * FIXME: cleanup struct net_device such that network protocol info
261 * moves out.
262 */
263
264struct net_device
265{
266
267 /*
268 * This is the first field of the "visible" part of this structure
269 * (i.e. as seen by users in the "Space.c" file). It is the name
270 * the interface.
271 */
272 char name[IFNAMSIZ];
273
274 /*
275 * I/O specific fields
276 * FIXME: Merge these and struct ifmap into one
277 */
278 unsigned long mem_end; /* shared mem end */
279 unsigned long mem_start; /* shared mem start */
280 unsigned long base_addr; /* device I/O address */
281 unsigned int irq; /* device IRQ number */
282
283 /*
284 * Some hardware also needs these fields, but they are not
285 * part of the usual set specified in Space.c.
286 */
287
288 unsigned char if_port; /* Selectable AUI, TP,..*/
289 unsigned char dma; /* DMA channel */
290
291 unsigned long state;
292
293 struct net_device *next;
294
295 /* The device initialization function. Called only once. */
296 int (*init)(struct net_device *dev);
297
298 /* ------- Fields preinitialized in Space.c finish here ------- */
299
300 struct net_device *next_sched;
301
302 /* Interface index. Unique device identifier */
303 int ifindex;
304 int iflink;
305
306
307 struct net_device_stats* (*get_stats)(struct net_device *dev);
308 struct iw_statistics* (*get_wireless_stats)(struct net_device *dev);
309
310 /* List of functions to handle Wireless Extensions (instead of ioctl).
311 * See <net/iw_handler.h> for details. Jean II */
312 const struct iw_handler_def * wireless_handlers;
313 /* Instance data managed by the core of Wireless Extensions. */
314 struct iw_public_data * wireless_data;
315
316 struct ethtool_ops *ethtool_ops;
317
318 /*
319 * This marks the end of the "visible" part of the structure. All
320 * fields hereafter are internal to the system, and may change at
321 * will (read: may be cleaned up at will).
322 */
323
324 /* These may be needed for future network-power-down code. */
325 unsigned long trans_start; /* Time (in jiffies) of last Tx */
326 unsigned long last_rx; /* Time of last Rx */
327
328 unsigned short flags; /* interface flags (a la BSD) */
329 unsigned short gflags;
330 unsigned short priv_flags; /* Like 'flags' but invisible to userspace. */
331 unsigned short padded; /* How much padding added by alloc_netdev() */
332
333 unsigned mtu; /* interface MTU value */
334 unsigned short type; /* interface hardware type */
335 unsigned short hard_header_len; /* hardware hdr length */
336 void *priv; /* pointer to private data */
337
338 struct net_device *master; /* Pointer to master device of a group,
339 * which this device is member of.
340 */
341
342 /* Interface address info. */
343 unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */
344 unsigned char dev_addr[MAX_ADDR_LEN]; /* hw address */
345 unsigned char addr_len; /* hardware address length */
346 unsigned short dev_id; /* for shared network cards */
347
348 struct dev_mc_list *mc_list; /* Multicast mac addresses */
349 int mc_count; /* Number of installed mcasts */
350 int promiscuity;
351 int allmulti;
352
353 int watchdog_timeo;
354 struct timer_list watchdog_timer;
355
356 /* Protocol specific pointers */
357
358 void *atalk_ptr; /* AppleTalk link */
359 void *ip_ptr; /* IPv4 specific data */
360 void *dn_ptr; /* DECnet specific data */
361 void *ip6_ptr; /* IPv6 specific data */
362 void *ec_ptr; /* Econet specific data */
363 void *ax25_ptr; /* AX.25 specific data */
364
365 struct list_head poll_list; /* Link to poll list */
366 int quota;
367 int weight;
368
369 struct Qdisc *qdisc;
370 struct Qdisc *qdisc_sleeping;
371 struct Qdisc *qdisc_ingress;
372 struct list_head qdisc_list;
373 unsigned long tx_queue_len; /* Max frames per queue allowed */
374
375 /* ingress path synchronizer */
376 spinlock_t ingress_lock;
377 /* hard_start_xmit synchronizer */
378 spinlock_t xmit_lock;
379 /* cpu id of processor entered to hard_start_xmit or -1,
380 if nobody entered there.
381 */
382 int xmit_lock_owner;
383 /* device queue lock */
384 spinlock_t queue_lock;
385 /* Number of references to this device */
386 atomic_t refcnt;
387 /* delayed register/unregister */
388 struct list_head todo_list;
389 /* device name hash chain */
390 struct hlist_node name_hlist;
391 /* device index hash chain */
392 struct hlist_node index_hlist;
393
394 /* register/unregister state machine */
395 enum { NETREG_UNINITIALIZED=0,
396 NETREG_REGISTERING, /* called register_netdevice */
397 NETREG_REGISTERED, /* completed register todo */
398 NETREG_UNREGISTERING, /* called unregister_netdevice */
399 NETREG_UNREGISTERED, /* completed unregister todo */
400 NETREG_RELEASED, /* called free_netdev */
401 } reg_state;
402
403 /* Net device features */
404 int features;
405#define NETIF_F_SG 1 /* Scatter/gather IO. */
406#define NETIF_F_IP_CSUM 2 /* Can checksum only TCP/UDP over IPv4. */
407#define NETIF_F_NO_CSUM 4 /* Does not require checksum. F.e. loopack. */
408#define NETIF_F_HW_CSUM 8 /* Can checksum all the packets. */
409#define NETIF_F_HIGHDMA 32 /* Can DMA to high memory. */
410#define NETIF_F_FRAGLIST 64 /* Scatter/gather IO. */
411#define NETIF_F_HW_VLAN_TX 128 /* Transmit VLAN hw acceleration */
412#define NETIF_F_HW_VLAN_RX 256 /* Receive VLAN hw acceleration */
413#define NETIF_F_HW_VLAN_FILTER 512 /* Receive filtering on VLAN */
414#define NETIF_F_VLAN_CHALLENGED 1024 /* Device cannot handle VLAN packets */
415#define NETIF_F_TSO 2048 /* Can offload TCP/IP segmentation */
416#define NETIF_F_LLTX 4096 /* LockLess TX */
417
418 /* Called after device is detached from network. */
419 void (*uninit)(struct net_device *dev);
420 /* Called after last user reference disappears. */
421 void (*destructor)(struct net_device *dev);
422
423 /* Pointers to interface service routines. */
424 int (*open)(struct net_device *dev);
425 int (*stop)(struct net_device *dev);
426 int (*hard_start_xmit) (struct sk_buff *skb,
427 struct net_device *dev);
428#define HAVE_NETDEV_POLL
429 int (*poll) (struct net_device *dev, int *quota);
430 int (*hard_header) (struct sk_buff *skb,
431 struct net_device *dev,
432 unsigned short type,
433 void *daddr,
434 void *saddr,
435 unsigned len);
436 int (*rebuild_header)(struct sk_buff *skb);
437#define HAVE_MULTICAST
438 void (*set_multicast_list)(struct net_device *dev);
439#define HAVE_SET_MAC_ADDR
440 int (*set_mac_address)(struct net_device *dev,
441 void *addr);
442#define HAVE_PRIVATE_IOCTL
443 int (*do_ioctl)(struct net_device *dev,
444 struct ifreq *ifr, int cmd);
445#define HAVE_SET_CONFIG
446 int (*set_config)(struct net_device *dev,
447 struct ifmap *map);
448#define HAVE_HEADER_CACHE
449 int (*hard_header_cache)(struct neighbour *neigh,
450 struct hh_cache *hh);
451 void (*header_cache_update)(struct hh_cache *hh,
452 struct net_device *dev,
453 unsigned char * haddr);
454#define HAVE_CHANGE_MTU
455 int (*change_mtu)(struct net_device *dev, int new_mtu);
456
457#define HAVE_TX_TIMEOUT
458 void (*tx_timeout) (struct net_device *dev);
459
460 void (*vlan_rx_register)(struct net_device *dev,
461 struct vlan_group *grp);
462 void (*vlan_rx_add_vid)(struct net_device *dev,
463 unsigned short vid);
464 void (*vlan_rx_kill_vid)(struct net_device *dev,
465 unsigned short vid);
466
467 int (*hard_header_parse)(struct sk_buff *skb,
468 unsigned char *haddr);
469 int (*neigh_setup)(struct net_device *dev, struct neigh_parms *);
470#ifdef CONFIG_NETPOLL
471 struct netpoll *np;
472#endif
473#ifdef CONFIG_NET_POLL_CONTROLLER
474 void (*poll_controller)(struct net_device *dev);
475#endif
476
477 /* bridge stuff */
478 struct net_bridge_port *br_port;
479
480#ifdef CONFIG_NET_DIVERT
481 /* this will get initialized at each interface type init routine */
482 struct divert_blk *divert;
483#endif /* CONFIG_NET_DIVERT */
484
485 /* class/net/name entry */
486 struct class_device class_dev;
487};
488
489#define NETDEV_ALIGN 32
490#define NETDEV_ALIGN_CONST (NETDEV_ALIGN - 1)
491
492static inline void *netdev_priv(struct net_device *dev)
493{
494 return (char *)dev + ((sizeof(struct net_device)
495 + NETDEV_ALIGN_CONST)
496 & ~NETDEV_ALIGN_CONST);
497}
498
499#define SET_MODULE_OWNER(dev) do { } while (0)
500/* Set the sysfs physical device reference for the network logical device
501 * if set prior to registration will cause a symlink during initialization.
502 */
503#define SET_NETDEV_DEV(net, pdev) ((net)->class_dev.dev = (pdev))
504
505struct packet_type {
506 unsigned short type; /* This is really htons(ether_type). */
507 struct net_device *dev; /* NULL is wildcarded here */
508 int (*func) (struct sk_buff *, struct net_device *,
509 struct packet_type *);
510 void *af_packet_priv;
511 struct list_head list;
512};
513
514#include <linux/interrupt.h>
515#include <linux/notifier.h>
516
517extern struct net_device loopback_dev; /* The loopback */
518extern struct net_device *dev_base; /* All devices */
519extern rwlock_t dev_base_lock; /* Device list lock */
520
521extern int netdev_boot_setup_check(struct net_device *dev);
522extern unsigned long netdev_boot_base(const char *prefix, int unit);
523extern struct net_device *dev_getbyhwaddr(unsigned short type, char *hwaddr);
524extern struct net_device *dev_getfirstbyhwtype(unsigned short type);
525extern void dev_add_pack(struct packet_type *pt);
526extern void dev_remove_pack(struct packet_type *pt);
527extern void __dev_remove_pack(struct packet_type *pt);
528
529extern struct net_device *dev_get_by_flags(unsigned short flags,
530 unsigned short mask);
531extern struct net_device *dev_get_by_name(const char *name);
532extern struct net_device *__dev_get_by_name(const char *name);
533extern int dev_alloc_name(struct net_device *dev, const char *name);
534extern int dev_open(struct net_device *dev);
535extern int dev_close(struct net_device *dev);
536extern int dev_queue_xmit(struct sk_buff *skb);
537extern int register_netdevice(struct net_device *dev);
538extern int unregister_netdevice(struct net_device *dev);
539extern void free_netdev(struct net_device *dev);
540extern void synchronize_net(void);
541extern int register_netdevice_notifier(struct notifier_block *nb);
542extern int unregister_netdevice_notifier(struct notifier_block *nb);
543extern int call_netdevice_notifiers(unsigned long val, void *v);
544extern struct net_device *dev_get_by_index(int ifindex);
545extern struct net_device *__dev_get_by_index(int ifindex);
546extern int dev_restart(struct net_device *dev);
547#ifdef CONFIG_NETPOLL_TRAP
548extern int netpoll_trap(void);
549#endif
550
551typedef int gifconf_func_t(struct net_device * dev, char __user * bufptr, int len);
552extern int register_gifconf(unsigned int family, gifconf_func_t * gifconf);
553static inline int unregister_gifconf(unsigned int family)
554{
555 return register_gifconf(family, NULL);
556}
557
558/*
559 * Incoming packets are placed on per-cpu queues so that
560 * no locking is needed.
561 */
562
563struct softnet_data
564{
565 int throttle;
566 int cng_level;
567 int avg_blog;
568 struct sk_buff_head input_pkt_queue;
569 struct list_head poll_list;
570 struct net_device *output_queue;
571 struct sk_buff *completion_queue;
572
573 struct net_device backlog_dev; /* Sorry. 8) */
574};
575
576DECLARE_PER_CPU(struct softnet_data,softnet_data);
577
578#define HAVE_NETIF_QUEUE
579
580static inline void __netif_schedule(struct net_device *dev)
581{
582 if (!test_and_set_bit(__LINK_STATE_SCHED, &dev->state)) {
583 unsigned long flags;
584 struct softnet_data *sd;
585
586 local_irq_save(flags);
587 sd = &__get_cpu_var(softnet_data);
588 dev->next_sched = sd->output_queue;
589 sd->output_queue = dev;
590 raise_softirq_irqoff(NET_TX_SOFTIRQ);
591 local_irq_restore(flags);
592 }
593}
594
595static inline void netif_schedule(struct net_device *dev)
596{
597 if (!test_bit(__LINK_STATE_XOFF, &dev->state))
598 __netif_schedule(dev);
599}
600
601static inline void netif_start_queue(struct net_device *dev)
602{
603 clear_bit(__LINK_STATE_XOFF, &dev->state);
604}
605
606static inline void netif_wake_queue(struct net_device *dev)
607{
608#ifdef CONFIG_NETPOLL_TRAP
609 if (netpoll_trap())
610 return;
611#endif
612 if (test_and_clear_bit(__LINK_STATE_XOFF, &dev->state))
613 __netif_schedule(dev);
614}
615
616static inline void netif_stop_queue(struct net_device *dev)
617{
618#ifdef CONFIG_NETPOLL_TRAP
619 if (netpoll_trap())
620 return;
621#endif
622 set_bit(__LINK_STATE_XOFF, &dev->state);
623}
624
625static inline int netif_queue_stopped(const struct net_device *dev)
626{
627 return test_bit(__LINK_STATE_XOFF, &dev->state);
628}
629
630static inline int netif_running(const struct net_device *dev)
631{
632 return test_bit(__LINK_STATE_START, &dev->state);
633}
634
635
636/* Use this variant when it is known for sure that it
637 * is executing from interrupt context.
638 */
639static inline void dev_kfree_skb_irq(struct sk_buff *skb)
640{
641 if (atomic_dec_and_test(&skb->users)) {
642 struct softnet_data *sd;
643 unsigned long flags;
644
645 local_irq_save(flags);
646 sd = &__get_cpu_var(softnet_data);
647 skb->next = sd->completion_queue;
648 sd->completion_queue = skb;
649 raise_softirq_irqoff(NET_TX_SOFTIRQ);
650 local_irq_restore(flags);
651 }
652}
653
654/* Use this variant in places where it could be invoked
655 * either from interrupt or non-interrupt context.
656 */
657static inline void dev_kfree_skb_any(struct sk_buff *skb)
658{
659 if (in_irq() || irqs_disabled())
660 dev_kfree_skb_irq(skb);
661 else
662 dev_kfree_skb(skb);
663}
664
665#define HAVE_NETIF_RX 1
666extern int netif_rx(struct sk_buff *skb);
667extern int netif_rx_ni(struct sk_buff *skb);
668#define HAVE_NETIF_RECEIVE_SKB 1
669extern int netif_receive_skb(struct sk_buff *skb);
670extern int dev_ioctl(unsigned int cmd, void __user *);
671extern int dev_ethtool(struct ifreq *);
672extern unsigned dev_get_flags(const struct net_device *);
673extern int dev_change_flags(struct net_device *, unsigned);
674extern int dev_change_name(struct net_device *, char *);
675extern int dev_set_mtu(struct net_device *, int);
676extern int dev_set_mac_address(struct net_device *,
677 struct sockaddr *);
678extern void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev);
679
680extern void dev_init(void);
681
682extern int netdev_nit;
683
684/* Called by rtnetlink.c:rtnl_unlock() */
685extern void netdev_run_todo(void);
686
687static inline void dev_put(struct net_device *dev)
688{
689 atomic_dec(&dev->refcnt);
690}
691
692#define __dev_put(dev) atomic_dec(&(dev)->refcnt)
693#define dev_hold(dev) atomic_inc(&(dev)->refcnt)
694
695/* Carrier loss detection, dial on demand. The functions netif_carrier_on
696 * and _off may be called from IRQ context, but it is caller
697 * who is responsible for serialization of these calls.
698 */
699
700extern void linkwatch_fire_event(struct net_device *dev);
701
702static inline int netif_carrier_ok(const struct net_device *dev)
703{
704 return !test_bit(__LINK_STATE_NOCARRIER, &dev->state);
705}
706
707extern void __netdev_watchdog_up(struct net_device *dev);
708
709static inline void netif_carrier_on(struct net_device *dev)
710{
711 if (test_and_clear_bit(__LINK_STATE_NOCARRIER, &dev->state))
712 linkwatch_fire_event(dev);
713 if (netif_running(dev))
714 __netdev_watchdog_up(dev);
715}
716
717static inline void netif_carrier_off(struct net_device *dev)
718{
719 if (!test_and_set_bit(__LINK_STATE_NOCARRIER, &dev->state))
720 linkwatch_fire_event(dev);
721}
722
723/* Hot-plugging. */
724static inline int netif_device_present(struct net_device *dev)
725{
726 return test_bit(__LINK_STATE_PRESENT, &dev->state);
727}
728
729static inline void netif_device_detach(struct net_device *dev)
730{
731 if (test_and_clear_bit(__LINK_STATE_PRESENT, &dev->state) &&
732 netif_running(dev)) {
733 netif_stop_queue(dev);
734 }
735}
736
737static inline void netif_device_attach(struct net_device *dev)
738{
739 if (!test_and_set_bit(__LINK_STATE_PRESENT, &dev->state) &&
740 netif_running(dev)) {
741 netif_wake_queue(dev);
742 __netdev_watchdog_up(dev);
743 }
744}
745
746/*
747 * Network interface message level settings
748 */
749#define HAVE_NETIF_MSG 1
750
751enum {
752 NETIF_MSG_DRV = 0x0001,
753 NETIF_MSG_PROBE = 0x0002,
754 NETIF_MSG_LINK = 0x0004,
755 NETIF_MSG_TIMER = 0x0008,
756 NETIF_MSG_IFDOWN = 0x0010,
757 NETIF_MSG_IFUP = 0x0020,
758 NETIF_MSG_RX_ERR = 0x0040,
759 NETIF_MSG_TX_ERR = 0x0080,
760 NETIF_MSG_TX_QUEUED = 0x0100,
761 NETIF_MSG_INTR = 0x0200,
762 NETIF_MSG_TX_DONE = 0x0400,
763 NETIF_MSG_RX_STATUS = 0x0800,
764 NETIF_MSG_PKTDATA = 0x1000,
765 NETIF_MSG_HW = 0x2000,
766 NETIF_MSG_WOL = 0x4000,
767};
768
769#define netif_msg_drv(p) ((p)->msg_enable & NETIF_MSG_DRV)
770#define netif_msg_probe(p) ((p)->msg_enable & NETIF_MSG_PROBE)
771#define netif_msg_link(p) ((p)->msg_enable & NETIF_MSG_LINK)
772#define netif_msg_timer(p) ((p)->msg_enable & NETIF_MSG_TIMER)
773#define netif_msg_ifdown(p) ((p)->msg_enable & NETIF_MSG_IFDOWN)
774#define netif_msg_ifup(p) ((p)->msg_enable & NETIF_MSG_IFUP)
775#define netif_msg_rx_err(p) ((p)->msg_enable & NETIF_MSG_RX_ERR)
776#define netif_msg_tx_err(p) ((p)->msg_enable & NETIF_MSG_TX_ERR)
777#define netif_msg_tx_queued(p) ((p)->msg_enable & NETIF_MSG_TX_QUEUED)
778#define netif_msg_intr(p) ((p)->msg_enable & NETIF_MSG_INTR)
779#define netif_msg_tx_done(p) ((p)->msg_enable & NETIF_MSG_TX_DONE)
780#define netif_msg_rx_status(p) ((p)->msg_enable & NETIF_MSG_RX_STATUS)
781#define netif_msg_pktdata(p) ((p)->msg_enable & NETIF_MSG_PKTDATA)
782#define netif_msg_hw(p) ((p)->msg_enable & NETIF_MSG_HW)
783#define netif_msg_wol(p) ((p)->msg_enable & NETIF_MSG_WOL)
784
785static inline u32 netif_msg_init(int debug_value, int default_msg_enable_bits)
786{
787 /* use default */
788 if (debug_value < 0 || debug_value >= (sizeof(u32) * 8))
789 return default_msg_enable_bits;
790 if (debug_value == 0) /* no output */
791 return 0;
792 /* set low N bits */
793 return (1 << debug_value) - 1;
794}
795
796/* Schedule rx intr now? */
797
798static inline int netif_rx_schedule_prep(struct net_device *dev)
799{
800 return netif_running(dev) &&
801 !test_and_set_bit(__LINK_STATE_RX_SCHED, &dev->state);
802}
803
804/* Add interface to tail of rx poll list. This assumes that _prep has
805 * already been called and returned 1.
806 */
807
808static inline void __netif_rx_schedule(struct net_device *dev)
809{
810 unsigned long flags;
811
812 local_irq_save(flags);
813 dev_hold(dev);
814 list_add_tail(&dev->poll_list, &__get_cpu_var(softnet_data).poll_list);
815 if (dev->quota < 0)
816 dev->quota += dev->weight;
817 else
818 dev->quota = dev->weight;
819 __raise_softirq_irqoff(NET_RX_SOFTIRQ);
820 local_irq_restore(flags);
821}
822
823/* Try to reschedule poll. Called by irq handler. */
824
825static inline void netif_rx_schedule(struct net_device *dev)
826{
827 if (netif_rx_schedule_prep(dev))
828 __netif_rx_schedule(dev);
829}
830
831/* Try to reschedule poll. Called by dev->poll() after netif_rx_complete().
832 * Do not inline this?
833 */
834static inline int netif_rx_reschedule(struct net_device *dev, int undo)
835{
836 if (netif_rx_schedule_prep(dev)) {
837 unsigned long flags;
838
839 dev->quota += undo;
840
841 local_irq_save(flags);
842 list_add_tail(&dev->poll_list, &__get_cpu_var(softnet_data).poll_list);
843 __raise_softirq_irqoff(NET_RX_SOFTIRQ);
844 local_irq_restore(flags);
845 return 1;
846 }
847 return 0;
848}
849
850/* Remove interface from poll list: it must be in the poll list
851 * on current cpu. This primitive is called by dev->poll(), when
852 * it completes the work. The device cannot be out of poll list at this
853 * moment, it is BUG().
854 */
855static inline void netif_rx_complete(struct net_device *dev)
856{
857 unsigned long flags;
858
859 local_irq_save(flags);
860 BUG_ON(!test_bit(__LINK_STATE_RX_SCHED, &dev->state));
861 list_del(&dev->poll_list);
862 smp_mb__before_clear_bit();
863 clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
864 local_irq_restore(flags);
865}
866
867static inline void netif_poll_disable(struct net_device *dev)
868{
869 while (test_and_set_bit(__LINK_STATE_RX_SCHED, &dev->state)) {
870 /* No hurry. */
871 current->state = TASK_INTERRUPTIBLE;
872 schedule_timeout(1);
873 }
874}
875
876static inline void netif_poll_enable(struct net_device *dev)
877{
878 clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
879}
880
881/* same as netif_rx_complete, except that local_irq_save(flags)
882 * has already been issued
883 */
884static inline void __netif_rx_complete(struct net_device *dev)
885{
886 BUG_ON(!test_bit(__LINK_STATE_RX_SCHED, &dev->state));
887 list_del(&dev->poll_list);
888 smp_mb__before_clear_bit();
889 clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
890}
891
892static inline void netif_tx_disable(struct net_device *dev)
893{
894 spin_lock_bh(&dev->xmit_lock);
895 netif_stop_queue(dev);
896 spin_unlock_bh(&dev->xmit_lock);
897}
898
899/* These functions live elsewhere (drivers/net/net_init.c, but related) */
900
901extern void ether_setup(struct net_device *dev);
902
903/* Support for loadable net-drivers */
904extern struct net_device *alloc_netdev(int sizeof_priv, const char *name,
905 void (*setup)(struct net_device *));
906extern int register_netdev(struct net_device *dev);
907extern void unregister_netdev(struct net_device *dev);
908/* Functions used for multicast support */
909extern void dev_mc_upload(struct net_device *dev);
910extern int dev_mc_delete(struct net_device *dev, void *addr, int alen, int all);
911extern int dev_mc_add(struct net_device *dev, void *addr, int alen, int newonly);
912extern void dev_mc_discard(struct net_device *dev);
913extern void dev_set_promiscuity(struct net_device *dev, int inc);
914extern void dev_set_allmulti(struct net_device *dev, int inc);
915extern void netdev_state_change(struct net_device *dev);
916/* Load a device via the kmod */
917extern void dev_load(const char *name);
918extern void dev_mcast_init(void);
919extern int netdev_max_backlog;
920extern int weight_p;
921extern int netdev_set_master(struct net_device *dev, struct net_device *master);
922extern int skb_checksum_help(struct sk_buff *skb, int inward);
923/* rx skb timestamps */
924extern void net_enable_timestamp(void);
925extern void net_disable_timestamp(void);
926
927#ifdef CONFIG_SYSCTL
928extern char *net_sysctl_strdup(const char *s);
929#endif
930
931#endif /* __KERNEL__ */
932
933#endif /* _LINUX_DEV_H */
diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
new file mode 100644
index 000000000000..2e2045482cb1
--- /dev/null
+++ b/include/linux/netfilter.h
@@ -0,0 +1,199 @@
1#ifndef __LINUX_NETFILTER_H
2#define __LINUX_NETFILTER_H
3
4#ifdef __KERNEL__
5#include <linux/init.h>
6#include <linux/types.h>
7#include <linux/skbuff.h>
8#include <linux/net.h>
9#include <linux/if.h>
10#include <linux/wait.h>
11#include <linux/list.h>
12#endif
13#include <linux/compiler.h>
14
15/* Responses from hook functions. */
16#define NF_DROP 0
17#define NF_ACCEPT 1
18#define NF_STOLEN 2
19#define NF_QUEUE 3
20#define NF_REPEAT 4
21#define NF_STOP 5
22#define NF_MAX_VERDICT NF_STOP
23
24/* Generic cache responses from hook functions.
25 <= 0x2000 is used for protocol-flags. */
26#define NFC_UNKNOWN 0x4000
27#define NFC_ALTERED 0x8000
28
29#ifdef __KERNEL__
30#include <linux/config.h>
31#ifdef CONFIG_NETFILTER
32
33extern void netfilter_init(void);
34
35/* Largest hook number + 1 */
36#define NF_MAX_HOOKS 8
37
38struct sk_buff;
39struct net_device;
40
41typedef unsigned int nf_hookfn(unsigned int hooknum,
42 struct sk_buff **skb,
43 const struct net_device *in,
44 const struct net_device *out,
45 int (*okfn)(struct sk_buff *));
46
47struct nf_hook_ops
48{
49 struct list_head list;
50
51 /* User fills in from here down. */
52 nf_hookfn *hook;
53 struct module *owner;
54 int pf;
55 int hooknum;
56 /* Hooks are ordered in ascending priority. */
57 int priority;
58};
59
60struct nf_sockopt_ops
61{
62 struct list_head list;
63
64 int pf;
65
66 /* Non-inclusive ranges: use 0/0/NULL to never get called. */
67 int set_optmin;
68 int set_optmax;
69 int (*set)(struct sock *sk, int optval, void __user *user, unsigned int len);
70
71 int get_optmin;
72 int get_optmax;
73 int (*get)(struct sock *sk, int optval, void __user *user, int *len);
74
75 /* Number of users inside set() or get(). */
76 unsigned int use;
77 struct task_struct *cleanup_task;
78};
79
80/* Each queued (to userspace) skbuff has one of these. */
81struct nf_info
82{
83 /* The ops struct which sent us to userspace. */
84 struct nf_hook_ops *elem;
85
86 /* If we're sent to userspace, this keeps housekeeping info */
87 int pf;
88 unsigned int hook;
89 struct net_device *indev, *outdev;
90 int (*okfn)(struct sk_buff *);
91};
92
93/* Function to register/unregister hook points. */
94int nf_register_hook(struct nf_hook_ops *reg);
95void nf_unregister_hook(struct nf_hook_ops *reg);
96
97/* Functions to register get/setsockopt ranges (non-inclusive). You
98 need to check permissions yourself! */
99int nf_register_sockopt(struct nf_sockopt_ops *reg);
100void nf_unregister_sockopt(struct nf_sockopt_ops *reg);
101
102extern struct list_head nf_hooks[NPROTO][NF_MAX_HOOKS];
103
104typedef void nf_logfn(unsigned int hooknum,
105 const struct sk_buff *skb,
106 const struct net_device *in,
107 const struct net_device *out,
108 const char *prefix);
109
110/* Function to register/unregister log function. */
111int nf_log_register(int pf, nf_logfn *logfn);
112void nf_log_unregister(int pf, nf_logfn *logfn);
113
114/* Calls the registered backend logging function */
115void nf_log_packet(int pf,
116 unsigned int hooknum,
117 const struct sk_buff *skb,
118 const struct net_device *in,
119 const struct net_device *out,
120 const char *fmt, ...);
121
122/* Activate hook; either okfn or kfree_skb called, unless a hook
123 returns NF_STOLEN (in which case, it's up to the hook to deal with
124 the consequences).
125
126 Returns -ERRNO if packet dropped. Zero means queued, stolen or
127 accepted.
128*/
129
130/* RR:
131 > I don't want nf_hook to return anything because people might forget
132 > about async and trust the return value to mean "packet was ok".
133
134 AK:
135 Just document it clearly, then you can expect some sense from kernel
136 coders :)
137*/
138
139/* This is gross, but inline doesn't cut it for avoiding the function
140 call in fast path: gcc doesn't inline (needs value tracking?). --RR */
141#ifdef CONFIG_NETFILTER_DEBUG
142#define NF_HOOK(pf, hook, skb, indev, outdev, okfn) \
143({int __ret; \
144if ((__ret=nf_hook_slow(pf, hook, &(skb), indev, outdev, okfn, INT_MIN)) == 1) \
145 __ret = (okfn)(skb); \
146__ret;})
147#define NF_HOOK_THRESH(pf, hook, skb, indev, outdev, okfn, thresh) \
148({int __ret; \
149if ((__ret=nf_hook_slow(pf, hook, &(skb), indev, outdev, okfn, thresh)) == 1) \
150 __ret = (okfn)(skb); \
151__ret;})
152#else
153#define NF_HOOK(pf, hook, skb, indev, outdev, okfn) \
154({int __ret; \
155if (list_empty(&nf_hooks[pf][hook]) || \
156 (__ret=nf_hook_slow(pf, hook, &(skb), indev, outdev, okfn, INT_MIN)) == 1) \
157 __ret = (okfn)(skb); \
158__ret;})
159#define NF_HOOK_THRESH(pf, hook, skb, indev, outdev, okfn, thresh) \
160({int __ret; \
161if (list_empty(&nf_hooks[pf][hook]) || \
162 (__ret=nf_hook_slow(pf, hook, &(skb), indev, outdev, okfn, thresh)) == 1) \
163 __ret = (okfn)(skb); \
164__ret;})
165#endif
166
167int nf_hook_slow(int pf, unsigned int hook, struct sk_buff **pskb,
168 struct net_device *indev, struct net_device *outdev,
169 int (*okfn)(struct sk_buff *), int thresh);
170
171/* Call setsockopt() */
172int nf_setsockopt(struct sock *sk, int pf, int optval, char __user *opt,
173 int len);
174int nf_getsockopt(struct sock *sk, int pf, int optval, char __user *opt,
175 int *len);
176
177/* Packet queuing */
178typedef int (*nf_queue_outfn_t)(struct sk_buff *skb,
179 struct nf_info *info, void *data);
180extern int nf_register_queue_handler(int pf,
181 nf_queue_outfn_t outfn, void *data);
182extern int nf_unregister_queue_handler(int pf);
183extern void nf_reinject(struct sk_buff *skb,
184 struct nf_info *info,
185 unsigned int verdict);
186
187extern void (*ip_ct_attach)(struct sk_buff *, struct sk_buff *);
188extern void nf_ct_attach(struct sk_buff *, struct sk_buff *);
189
190/* FIXME: Before cache is ever used, this must be implemented for real. */
191extern void nf_invalidate_cache(int pf);
192
193#else /* !CONFIG_NETFILTER */
194#define NF_HOOK(pf, hook, skb, indev, outdev, okfn) (okfn)(skb)
195static inline void nf_ct_attach(struct sk_buff *new, struct sk_buff *skb) {}
196#endif /*CONFIG_NETFILTER*/
197
198#endif /*__KERNEL__*/
199#endif /*__LINUX_NETFILTER_H*/
diff --git a/include/linux/netfilter_arp.h b/include/linux/netfilter_arp.h
new file mode 100644
index 000000000000..a3f8977f7f12
--- /dev/null
+++ b/include/linux/netfilter_arp.h
@@ -0,0 +1,20 @@
1#ifndef __LINUX_ARP_NETFILTER_H
2#define __LINUX_ARP_NETFILTER_H
3
4/* ARP-specific defines for netfilter.
5 * (C)2002 Rusty Russell IBM -- This code is GPL.
6 */
7
8#include <linux/config.h>
9#include <linux/netfilter.h>
10
11/* There is no PF_ARP. */
12#define NF_ARP 0
13
14/* ARP Hooks */
15#define NF_ARP_IN 0
16#define NF_ARP_OUT 1
17#define NF_ARP_FORWARD 2
18#define NF_ARP_NUMHOOKS 3
19
20#endif /* __LINUX_ARP_NETFILTER_H */
diff --git a/include/linux/netfilter_arp/arp_tables.h b/include/linux/netfilter_arp/arp_tables.h
new file mode 100644
index 000000000000..d759a637bded
--- /dev/null
+++ b/include/linux/netfilter_arp/arp_tables.h
@@ -0,0 +1,340 @@
1/*
2 * Format of an ARP firewall descriptor
3 *
4 * src, tgt, src_mask, tgt_mask, arpop, arpop_mask are always stored in
5 * network byte order.
6 * flags are stored in host byte order (of course).
7 */
8
9#ifndef _ARPTABLES_H
10#define _ARPTABLES_H
11
12#ifdef __KERNEL__
13#include <linux/if.h>
14#include <linux/types.h>
15#include <linux/in.h>
16#include <linux/if_arp.h>
17#include <linux/skbuff.h>
18#endif
19#include <linux/compiler.h>
20#include <linux/netfilter_arp.h>
21
22#define ARPT_FUNCTION_MAXNAMELEN 30
23#define ARPT_TABLE_MAXNAMELEN 32
24
25#define ARPT_DEV_ADDR_LEN_MAX 16
26
27struct arpt_devaddr_info {
28 char addr[ARPT_DEV_ADDR_LEN_MAX];
29 char mask[ARPT_DEV_ADDR_LEN_MAX];
30};
31
32/* Yes, Virginia, you have to zero the padding. */
33struct arpt_arp {
34 /* Source and target IP addr */
35 struct in_addr src, tgt;
36 /* Mask for src and target IP addr */
37 struct in_addr smsk, tmsk;
38
39 /* Device hw address length, src+target device addresses */
40 u_int8_t arhln, arhln_mask;
41 struct arpt_devaddr_info src_devaddr;
42 struct arpt_devaddr_info tgt_devaddr;
43
44 /* ARP operation code. */
45 u_int16_t arpop, arpop_mask;
46
47 /* ARP hardware address and protocol address format. */
48 u_int16_t arhrd, arhrd_mask;
49 u_int16_t arpro, arpro_mask;
50
51 /* The protocol address length is only accepted if it is 4
52 * so there is no use in offering a way to do filtering on it.
53 */
54
55 char iniface[IFNAMSIZ], outiface[IFNAMSIZ];
56 unsigned char iniface_mask[IFNAMSIZ], outiface_mask[IFNAMSIZ];
57
58 /* Flags word */
59 u_int8_t flags;
60 /* Inverse flags */
61 u_int16_t invflags;
62};
63
64struct arpt_entry_target
65{
66 union {
67 struct {
68 u_int16_t target_size;
69
70 /* Used by userspace */
71 char name[ARPT_FUNCTION_MAXNAMELEN];
72 } user;
73 struct {
74 u_int16_t target_size;
75
76 /* Used inside the kernel */
77 struct arpt_target *target;
78 } kernel;
79
80 /* Total length */
81 u_int16_t target_size;
82 } u;
83
84 unsigned char data[0];
85};
86
87struct arpt_standard_target
88{
89 struct arpt_entry_target target;
90 int verdict;
91};
92
93struct arpt_counters
94{
95 u_int64_t pcnt, bcnt; /* Packet and byte counters */
96};
97
98/* Values for "flag" field in struct arpt_ip (general arp structure).
99 * No flags defined yet.
100 */
101#define ARPT_F_MASK 0x00 /* All possible flag bits mask. */
102
103/* Values for "inv" field in struct arpt_arp. */
104#define ARPT_INV_VIA_IN 0x0001 /* Invert the sense of IN IFACE. */
105#define ARPT_INV_VIA_OUT 0x0002 /* Invert the sense of OUT IFACE */
106#define ARPT_INV_SRCIP 0x0004 /* Invert the sense of SRC IP. */
107#define ARPT_INV_TGTIP 0x0008 /* Invert the sense of TGT IP. */
108#define ARPT_INV_SRCDEVADDR 0x0010 /* Invert the sense of SRC DEV ADDR. */
109#define ARPT_INV_TGTDEVADDR 0x0020 /* Invert the sense of TGT DEV ADDR. */
110#define ARPT_INV_ARPOP 0x0040 /* Invert the sense of ARP OP. */
111#define ARPT_INV_ARPHRD 0x0080 /* Invert the sense of ARP HRD. */
112#define ARPT_INV_ARPPRO 0x0100 /* Invert the sense of ARP PRO. */
113#define ARPT_INV_ARPHLN 0x0200 /* Invert the sense of ARP HLN. */
114#define ARPT_INV_MASK 0x03FF /* All possible flag bits mask. */
115
116/* This structure defines each of the firewall rules. Consists of 3
117 parts which are 1) general ARP header stuff 2) match specific
118 stuff 3) the target to perform if the rule matches */
119struct arpt_entry
120{
121 struct arpt_arp arp;
122
123 /* Size of arpt_entry + matches */
124 u_int16_t target_offset;
125 /* Size of arpt_entry + matches + target */
126 u_int16_t next_offset;
127
128 /* Back pointer */
129 unsigned int comefrom;
130
131 /* Packet and byte counters. */
132 struct arpt_counters counters;
133
134 /* The matches (if any), then the target. */
135 unsigned char elems[0];
136};
137
138/*
139 * New IP firewall options for [gs]etsockopt at the RAW IP level.
140 * Unlike BSD Linux inherits IP options so you don't have to use a raw
141 * socket for this. Instead we check rights in the calls.
142 */
143#define ARPT_BASE_CTL 96 /* base for firewall socket options */
144
145#define ARPT_SO_SET_REPLACE (ARPT_BASE_CTL)
146#define ARPT_SO_SET_ADD_COUNTERS (ARPT_BASE_CTL + 1)
147#define ARPT_SO_SET_MAX ARPT_SO_SET_ADD_COUNTERS
148
149#define ARPT_SO_GET_INFO (ARPT_BASE_CTL)
150#define ARPT_SO_GET_ENTRIES (ARPT_BASE_CTL + 1)
151#define ARPT_SO_GET_MAX ARPT_SO_GET_ENTRIES
152
153/* CONTINUE verdict for targets */
154#define ARPT_CONTINUE 0xFFFFFFFF
155
156/* For standard target */
157#define ARPT_RETURN (-NF_REPEAT - 1)
158
159/* The argument to ARPT_SO_GET_INFO */
160struct arpt_getinfo
161{
162 /* Which table: caller fills this in. */
163 char name[ARPT_TABLE_MAXNAMELEN];
164
165 /* Kernel fills these in. */
166 /* Which hook entry points are valid: bitmask */
167 unsigned int valid_hooks;
168
169 /* Hook entry points: one per netfilter hook. */
170 unsigned int hook_entry[NF_ARP_NUMHOOKS];
171
172 /* Underflow points. */
173 unsigned int underflow[NF_ARP_NUMHOOKS];
174
175 /* Number of entries */
176 unsigned int num_entries;
177
178 /* Size of entries. */
179 unsigned int size;
180};
181
182/* The argument to ARPT_SO_SET_REPLACE. */
183struct arpt_replace
184{
185 /* Which table. */
186 char name[ARPT_TABLE_MAXNAMELEN];
187
188 /* Which hook entry points are valid: bitmask. You can't
189 change this. */
190 unsigned int valid_hooks;
191
192 /* Number of entries */
193 unsigned int num_entries;
194
195 /* Total size of new entries */
196 unsigned int size;
197
198 /* Hook entry points. */
199 unsigned int hook_entry[NF_ARP_NUMHOOKS];
200
201 /* Underflow points. */
202 unsigned int underflow[NF_ARP_NUMHOOKS];
203
204 /* Information about old entries: */
205 /* Number of counters (must be equal to current number of entries). */
206 unsigned int num_counters;
207 /* The old entries' counters. */
208 struct arpt_counters __user *counters;
209
210 /* The entries (hang off end: not really an array). */
211 struct arpt_entry entries[0];
212};
213
214/* The argument to ARPT_SO_ADD_COUNTERS. */
215struct arpt_counters_info
216{
217 /* Which table. */
218 char name[ARPT_TABLE_MAXNAMELEN];
219
220 unsigned int num_counters;
221
222 /* The counters (actually `number' of these). */
223 struct arpt_counters counters[0];
224};
225
226/* The argument to ARPT_SO_GET_ENTRIES. */
227struct arpt_get_entries
228{
229 /* Which table: user fills this in. */
230 char name[ARPT_TABLE_MAXNAMELEN];
231
232 /* User fills this in: total entry size. */
233 unsigned int size;
234
235 /* The entries. */
236 struct arpt_entry entrytable[0];
237};
238
239/* Standard return verdict, or do jump. */
240#define ARPT_STANDARD_TARGET ""
241/* Error verdict. */
242#define ARPT_ERROR_TARGET "ERROR"
243
244/* Helper functions */
245static __inline__ struct arpt_entry_target *arpt_get_target(struct arpt_entry *e)
246{
247 return (void *)e + e->target_offset;
248}
249
250/* fn returns 0 to continue iteration */
251#define ARPT_ENTRY_ITERATE(entries, size, fn, args...) \
252({ \
253 unsigned int __i; \
254 int __ret = 0; \
255 struct arpt_entry *__entry; \
256 \
257 for (__i = 0; __i < (size); __i += __entry->next_offset) { \
258 __entry = (void *)(entries) + __i; \
259 \
260 __ret = fn(__entry , ## args); \
261 if (__ret != 0) \
262 break; \
263 } \
264 __ret; \
265})
266
267/*
268 * Main firewall chains definitions and global var's definitions.
269 */
270#ifdef __KERNEL__
271
272/* Registration hooks for targets. */
273struct arpt_target
274{
275 struct list_head list;
276
277 const char name[ARPT_FUNCTION_MAXNAMELEN];
278
279 /* Returns verdict. */
280 unsigned int (*target)(struct sk_buff **pskb,
281 unsigned int hooknum,
282 const struct net_device *in,
283 const struct net_device *out,
284 const void *targinfo,
285 void *userdata);
286
287 /* Called when user tries to insert an entry of this type:
288 hook_mask is a bitmask of hooks from which it can be
289 called. */
290 /* Should return true or false. */
291 int (*checkentry)(const char *tablename,
292 const struct arpt_entry *e,
293 void *targinfo,
294 unsigned int targinfosize,
295 unsigned int hook_mask);
296
297 /* Called when entry of this type deleted. */
298 void (*destroy)(void *targinfo, unsigned int targinfosize);
299
300 /* Set this to THIS_MODULE if you are a module, otherwise NULL */
301 struct module *me;
302};
303
304extern int arpt_register_target(struct arpt_target *target);
305extern void arpt_unregister_target(struct arpt_target *target);
306
307/* Furniture shopping... */
308struct arpt_table
309{
310 struct list_head list;
311
312 /* A unique name... */
313 char name[ARPT_TABLE_MAXNAMELEN];
314
315 /* What hooks you will enter on */
316 unsigned int valid_hooks;
317
318 /* Lock for the curtain */
319 rwlock_t lock;
320
321 /* Man behind the curtain... */
322 struct arpt_table_info *private;
323
324 /* Set this to THIS_MODULE if you are a module, otherwise NULL */
325 struct module *me;
326};
327
328extern int arpt_register_table(struct arpt_table *table,
329 const struct arpt_replace *repl);
330extern void arpt_unregister_table(struct arpt_table *table);
331extern unsigned int arpt_do_table(struct sk_buff **pskb,
332 unsigned int hook,
333 const struct net_device *in,
334 const struct net_device *out,
335 struct arpt_table *table,
336 void *userdata);
337
338#define ARPT_ALIGN(s) (((s) + (__alignof__(struct arpt_entry)-1)) & ~(__alignof__(struct arpt_entry)-1))
339#endif /*__KERNEL__*/
340#endif /* _ARPTABLES_H */
diff --git a/include/linux/netfilter_arp/arpt_mangle.h b/include/linux/netfilter_arp/arpt_mangle.h
new file mode 100644
index 000000000000..250f502902bb
--- /dev/null
+++ b/include/linux/netfilter_arp/arpt_mangle.h
@@ -0,0 +1,26 @@
1#ifndef _ARPT_MANGLE_H
2#define _ARPT_MANGLE_H
3#include <linux/netfilter_arp/arp_tables.h>
4
5#define ARPT_MANGLE_ADDR_LEN_MAX sizeof(struct in_addr)
6struct arpt_mangle
7{
8 char src_devaddr[ARPT_DEV_ADDR_LEN_MAX];
9 char tgt_devaddr[ARPT_DEV_ADDR_LEN_MAX];
10 union {
11 struct in_addr src_ip;
12 } u_s;
13 union {
14 struct in_addr tgt_ip;
15 } u_t;
16 u_int8_t flags;
17 int target;
18};
19
20#define ARPT_MANGLE_SDEV 0x01
21#define ARPT_MANGLE_TDEV 0x02
22#define ARPT_MANGLE_SIP 0x04
23#define ARPT_MANGLE_TIP 0x08
24#define ARPT_MANGLE_MASK 0x0f
25
26#endif /* _ARPT_MANGLE_H */
diff --git a/include/linux/netfilter_bridge.h b/include/linux/netfilter_bridge.h
new file mode 100644
index 000000000000..de4d397865ce
--- /dev/null
+++ b/include/linux/netfilter_bridge.h
@@ -0,0 +1,113 @@
1#ifndef __LINUX_BRIDGE_NETFILTER_H
2#define __LINUX_BRIDGE_NETFILTER_H
3
4/* bridge-specific defines for netfilter.
5 */
6
7#include <linux/config.h>
8#include <linux/netfilter.h>
9#if defined(__KERNEL__) && defined(CONFIG_BRIDGE_NETFILTER)
10#include <asm/atomic.h>
11#include <linux/if_ether.h>
12#endif
13
14/* Bridge Hooks */
15/* After promisc drops, checksum checks. */
16#define NF_BR_PRE_ROUTING 0
17/* If the packet is destined for this box. */
18#define NF_BR_LOCAL_IN 1
19/* If the packet is destined for another interface. */
20#define NF_BR_FORWARD 2
21/* Packets coming from a local process. */
22#define NF_BR_LOCAL_OUT 3
23/* Packets about to hit the wire. */
24#define NF_BR_POST_ROUTING 4
25/* Not really a hook, but used for the ebtables broute table */
26#define NF_BR_BROUTING 5
27#define NF_BR_NUMHOOKS 6
28
29#ifdef __KERNEL__
30
31enum nf_br_hook_priorities {
32 NF_BR_PRI_FIRST = INT_MIN,
33 NF_BR_PRI_NAT_DST_BRIDGED = -300,
34 NF_BR_PRI_FILTER_BRIDGED = -200,
35 NF_BR_PRI_BRNF = 0,
36 NF_BR_PRI_NAT_DST_OTHER = 100,
37 NF_BR_PRI_FILTER_OTHER = 200,
38 NF_BR_PRI_NAT_SRC = 300,
39 NF_BR_PRI_LAST = INT_MAX,
40};
41
42#ifdef CONFIG_BRIDGE_NETFILTER
43
44#define BRNF_PKT_TYPE 0x01
45#define BRNF_BRIDGED_DNAT 0x02
46#define BRNF_DONT_TAKE_PARENT 0x04
47#define BRNF_BRIDGED 0x08
48#define BRNF_NF_BRIDGE_PREROUTING 0x10
49
50static inline
51struct nf_bridge_info *nf_bridge_alloc(struct sk_buff *skb)
52{
53 struct nf_bridge_info **nf_bridge = &(skb->nf_bridge);
54
55 if ((*nf_bridge = kmalloc(sizeof(**nf_bridge), GFP_ATOMIC)) != NULL) {
56 atomic_set(&(*nf_bridge)->use, 1);
57 (*nf_bridge)->mask = 0;
58 (*nf_bridge)->physindev = (*nf_bridge)->physoutdev = NULL;
59#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
60 (*nf_bridge)->netoutdev = NULL;
61#endif
62 }
63
64 return *nf_bridge;
65}
66
67/* Only used in br_forward.c */
68static inline
69void nf_bridge_maybe_copy_header(struct sk_buff *skb)
70{
71 if (skb->nf_bridge) {
72 if (skb->protocol == __constant_htons(ETH_P_8021Q)) {
73 memcpy(skb->data - 18, skb->nf_bridge->data, 18);
74 skb_push(skb, 4);
75 } else
76 memcpy(skb->data - 16, skb->nf_bridge->data, 16);
77 }
78}
79
80static inline
81void nf_bridge_save_header(struct sk_buff *skb)
82{
83 int header_size = 16;
84
85 if (skb->protocol == __constant_htons(ETH_P_8021Q))
86 header_size = 18;
87
88 memcpy(skb->nf_bridge->data, skb->data - header_size, header_size);
89}
90
91/* This is called by the IP fragmenting code and it ensures there is
92 * enough room for the encapsulating header (if there is one). */
93static inline
94int nf_bridge_pad(struct sk_buff *skb)
95{
96 if (skb->protocol == __constant_htons(ETH_P_IP))
97 return 0;
98 if (skb->nf_bridge) {
99 if (skb->protocol == __constant_htons(ETH_P_8021Q))
100 return 4;
101 }
102 return 0;
103}
104
105struct bridge_skb_cb {
106 union {
107 __u32 ipv4;
108 } daddr;
109};
110#endif /* CONFIG_BRIDGE_NETFILTER */
111
112#endif /* __KERNEL__ */
113#endif
diff --git a/include/linux/netfilter_bridge/ebt_802_3.h b/include/linux/netfilter_bridge/ebt_802_3.h
new file mode 100644
index 000000000000..b9f712c14a0a
--- /dev/null
+++ b/include/linux/netfilter_bridge/ebt_802_3.h
@@ -0,0 +1,69 @@
1#ifndef __LINUX_BRIDGE_EBT_802_3_H
2#define __LINUX_BRIDGE_EBT_802_3_H
3
4#define EBT_802_3_SAP 0x01
5#define EBT_802_3_TYPE 0x02
6
7#define EBT_802_3_MATCH "802_3"
8
9/*
10 * If frame has DSAP/SSAP value 0xaa you must check the SNAP type
11 * to discover what kind of packet we're carrying.
12 */
13#define CHECK_TYPE 0xaa
14
15/*
16 * Control field may be one or two bytes. If the first byte has
17 * the value 0x03 then the entire length is one byte, otherwise it is two.
18 * One byte controls are used in Unnumbered Information frames.
19 * Two byte controls are used in Numbered Information frames.
20 */
21#define IS_UI 0x03
22
23#define EBT_802_3_MASK (EBT_802_3_SAP | EBT_802_3_TYPE | EBT_802_3)
24
25/* ui has one byte ctrl, ni has two */
26struct hdr_ui {
27 uint8_t dsap;
28 uint8_t ssap;
29 uint8_t ctrl;
30 uint8_t orig[3];
31 uint16_t type;
32};
33
34struct hdr_ni {
35 uint8_t dsap;
36 uint8_t ssap;
37 uint16_t ctrl;
38 uint8_t orig[3];
39 uint16_t type;
40};
41
42struct ebt_802_3_hdr {
43 uint8_t daddr[6];
44 uint8_t saddr[6];
45 uint16_t len;
46 union {
47 struct hdr_ui ui;
48 struct hdr_ni ni;
49 } llc;
50};
51
52#ifdef __KERNEL__
53#include <linux/skbuff.h>
54
55static inline struct ebt_802_3_hdr *ebt_802_3_hdr(const struct sk_buff *skb)
56{
57 return (struct ebt_802_3_hdr *)skb->mac.raw;
58}
59#endif
60
61struct ebt_802_3_info
62{
63 uint8_t sap;
64 uint16_t type;
65 uint8_t bitmask;
66 uint8_t invflags;
67};
68
69#endif
diff --git a/include/linux/netfilter_bridge/ebt_among.h b/include/linux/netfilter_bridge/ebt_among.h
new file mode 100644
index 000000000000..307c1fed8511
--- /dev/null
+++ b/include/linux/netfilter_bridge/ebt_among.h
@@ -0,0 +1,65 @@
1#ifndef __LINUX_BRIDGE_EBT_AMONG_H
2#define __LINUX_BRIDGE_EBT_AMONG_H
3
4#define EBT_AMONG_DST 0x01
5#define EBT_AMONG_SRC 0x02
6
7/* Grzegorz Borowiak <grzes@gnu.univ.gda.pl> 2003
8 *
9 * Write-once-read-many hash table, used for checking if a given
10 * MAC address belongs to a set or not and possibly for checking
11 * if it is related with a given IPv4 address.
12 *
13 * The hash value of an address is its last byte.
14 *
15 * In real-world ethernet addresses, values of the last byte are
16 * evenly distributed and there is no need to consider other bytes.
17 * It would only slow the routines down.
18 *
19 * For MAC address comparison speedup reasons, we introduce a trick.
20 * MAC address is mapped onto an array of two 32-bit integers.
21 * This pair of integers is compared with MAC addresses in the
22 * hash table, which are stored also in form of pairs of integers
23 * (in `cmp' array). This is quick as it requires only two elementary
24 * number comparisons in worst case. Further, we take advantage of
25 * fact that entropy of 3 last bytes of address is larger than entropy
26 * of 3 first bytes. So first we compare 4 last bytes of addresses and
27 * if they are the same we compare 2 first.
28 *
29 * Yes, it is a memory overhead, but in 2003 AD, who cares?
30 */
31
32struct ebt_mac_wormhash_tuple
33{
34 uint32_t cmp[2];
35 uint32_t ip;
36};
37
38struct ebt_mac_wormhash
39{
40 int table[257];
41 int poolsize;
42 struct ebt_mac_wormhash_tuple pool[0];
43};
44
45#define ebt_mac_wormhash_size(x) ((x) ? sizeof(struct ebt_mac_wormhash) \
46 + (x)->poolsize * sizeof(struct ebt_mac_wormhash_tuple) : 0)
47
48struct ebt_among_info
49{
50 int wh_dst_ofs;
51 int wh_src_ofs;
52 int bitmask;
53};
54
55#define EBT_AMONG_DST_NEG 0x1
56#define EBT_AMONG_SRC_NEG 0x2
57
58#define ebt_among_wh_dst(x) ((x)->wh_dst_ofs ? \
59 (struct ebt_mac_wormhash*)((char*)(x) + (x)->wh_dst_ofs) : NULL)
60#define ebt_among_wh_src(x) ((x)->wh_src_ofs ? \
61 (struct ebt_mac_wormhash*)((char*)(x) + (x)->wh_src_ofs) : NULL)
62
63#define EBT_AMONG_MATCH "among"
64
65#endif
diff --git a/include/linux/netfilter_bridge/ebt_arp.h b/include/linux/netfilter_bridge/ebt_arp.h
new file mode 100644
index 000000000000..537ec6b487a2
--- /dev/null
+++ b/include/linux/netfilter_bridge/ebt_arp.h
@@ -0,0 +1,32 @@
1#ifndef __LINUX_BRIDGE_EBT_ARP_H
2#define __LINUX_BRIDGE_EBT_ARP_H
3
4#define EBT_ARP_OPCODE 0x01
5#define EBT_ARP_HTYPE 0x02
6#define EBT_ARP_PTYPE 0x04
7#define EBT_ARP_SRC_IP 0x08
8#define EBT_ARP_DST_IP 0x10
9#define EBT_ARP_SRC_MAC 0x20
10#define EBT_ARP_DST_MAC 0x40
11#define EBT_ARP_MASK (EBT_ARP_OPCODE | EBT_ARP_HTYPE | EBT_ARP_PTYPE | \
12 EBT_ARP_SRC_IP | EBT_ARP_DST_IP | EBT_ARP_SRC_MAC | EBT_ARP_DST_MAC)
13#define EBT_ARP_MATCH "arp"
14
15struct ebt_arp_info
16{
17 uint16_t htype;
18 uint16_t ptype;
19 uint16_t opcode;
20 uint32_t saddr;
21 uint32_t smsk;
22 uint32_t daddr;
23 uint32_t dmsk;
24 unsigned char smaddr[ETH_ALEN];
25 unsigned char smmsk[ETH_ALEN];
26 unsigned char dmaddr[ETH_ALEN];
27 unsigned char dmmsk[ETH_ALEN];
28 uint8_t bitmask;
29 uint8_t invflags;
30};
31
32#endif
diff --git a/include/linux/netfilter_bridge/ebt_arpreply.h b/include/linux/netfilter_bridge/ebt_arpreply.h
new file mode 100644
index 000000000000..96a8339960e0
--- /dev/null
+++ b/include/linux/netfilter_bridge/ebt_arpreply.h
@@ -0,0 +1,11 @@
1#ifndef __LINUX_BRIDGE_EBT_ARPREPLY_H
2#define __LINUX_BRIDGE_EBT_ARPREPLY_H
3
4struct ebt_arpreply_info
5{
6 unsigned char mac[ETH_ALEN];
7 int target;
8};
9#define EBT_ARPREPLY_TARGET "arpreply"
10
11#endif
diff --git a/include/linux/netfilter_bridge/ebt_ip.h b/include/linux/netfilter_bridge/ebt_ip.h
new file mode 100644
index 000000000000..7247385cdcb1
--- /dev/null
+++ b/include/linux/netfilter_bridge/ebt_ip.h
@@ -0,0 +1,43 @@
1/*
2 * ebt_ip
3 *
4 * Authors:
5 * Bart De Schuymer <bart.de.schuymer@pandora.be>
6 *
7 * April, 2002
8 *
9 * Changes:
10 * added ip-sport and ip-dport
11 * Innominate Security Technologies AG <mhopf@innominate.com>
12 * September, 2002
13 */
14
15#ifndef __LINUX_BRIDGE_EBT_IP_H
16#define __LINUX_BRIDGE_EBT_IP_H
17
18#define EBT_IP_SOURCE 0x01
19#define EBT_IP_DEST 0x02
20#define EBT_IP_TOS 0x04
21#define EBT_IP_PROTO 0x08
22#define EBT_IP_SPORT 0x10
23#define EBT_IP_DPORT 0x20
24#define EBT_IP_MASK (EBT_IP_SOURCE | EBT_IP_DEST | EBT_IP_TOS | EBT_IP_PROTO |\
25 EBT_IP_SPORT | EBT_IP_DPORT )
26#define EBT_IP_MATCH "ip"
27
28/* the same values are used for the invflags */
29struct ebt_ip_info
30{
31 uint32_t saddr;
32 uint32_t daddr;
33 uint32_t smsk;
34 uint32_t dmsk;
35 uint8_t tos;
36 uint8_t protocol;
37 uint8_t bitmask;
38 uint8_t invflags;
39 uint16_t sport[2];
40 uint16_t dport[2];
41};
42
43#endif
diff --git a/include/linux/netfilter_bridge/ebt_limit.h b/include/linux/netfilter_bridge/ebt_limit.h
new file mode 100644
index 000000000000..d8b65000afe4
--- /dev/null
+++ b/include/linux/netfilter_bridge/ebt_limit.h
@@ -0,0 +1,23 @@
1#ifndef __LINUX_BRIDGE_EBT_LIMIT_H
2#define __LINUX_BRIDGE_EBT_LIMIT_H
3
4#define EBT_LIMIT_MATCH "limit"
5
6/* timings are in milliseconds. */
7#define EBT_LIMIT_SCALE 10000
8
9/* 1/10,000 sec period => max of 10,000/sec. Min rate is then 429490
10 seconds, or one every 59 hours. */
11
12struct ebt_limit_info
13{
14 u_int32_t avg; /* Average secs between packets * scale */
15 u_int32_t burst; /* Period multiplier for upper limit. */
16
17 /* Used internally by the kernel */
18 unsigned long prev;
19 u_int32_t credit;
20 u_int32_t credit_cap, cost;
21};
22
23#endif
diff --git a/include/linux/netfilter_bridge/ebt_log.h b/include/linux/netfilter_bridge/ebt_log.h
new file mode 100644
index 000000000000..358fbc84fb59
--- /dev/null
+++ b/include/linux/netfilter_bridge/ebt_log.h
@@ -0,0 +1,17 @@
1#ifndef __LINUX_BRIDGE_EBT_LOG_H
2#define __LINUX_BRIDGE_EBT_LOG_H
3
4#define EBT_LOG_IP 0x01 /* if the frame is made by ip, log the ip information */
5#define EBT_LOG_ARP 0x02
6#define EBT_LOG_MASK (EBT_LOG_IP | EBT_LOG_ARP)
7#define EBT_LOG_PREFIX_SIZE 30
8#define EBT_LOG_WATCHER "log"
9
10struct ebt_log_info
11{
12 uint8_t loglevel;
13 uint8_t prefix[EBT_LOG_PREFIX_SIZE];
14 uint32_t bitmask;
15};
16
17#endif
diff --git a/include/linux/netfilter_bridge/ebt_mark_m.h b/include/linux/netfilter_bridge/ebt_mark_m.h
new file mode 100644
index 000000000000..301524ff1065
--- /dev/null
+++ b/include/linux/netfilter_bridge/ebt_mark_m.h
@@ -0,0 +1,15 @@
1#ifndef __LINUX_BRIDGE_EBT_MARK_M_H
2#define __LINUX_BRIDGE_EBT_MARK_M_H
3
4#define EBT_MARK_AND 0x01
5#define EBT_MARK_OR 0x02
6#define EBT_MARK_MASK (EBT_MARK_AND | EBT_MARK_OR)
7struct ebt_mark_m_info
8{
9 unsigned long mark, mask;
10 uint8_t invert;
11 uint8_t bitmask;
12};
13#define EBT_MARK_MATCH "mark_m"
14
15#endif
diff --git a/include/linux/netfilter_bridge/ebt_mark_t.h b/include/linux/netfilter_bridge/ebt_mark_t.h
new file mode 100644
index 000000000000..110fec6a40a2
--- /dev/null
+++ b/include/linux/netfilter_bridge/ebt_mark_t.h
@@ -0,0 +1,12 @@
1#ifndef __LINUX_BRIDGE_EBT_MARK_T_H
2#define __LINUX_BRIDGE_EBT_MARK_T_H
3
4struct ebt_mark_t_info
5{
6 unsigned long mark;
7 /* EBT_ACCEPT, EBT_DROP, EBT_CONTINUE or EBT_RETURN */
8 int target;
9};
10#define EBT_MARK_TARGET "mark"
11
12#endif
diff --git a/include/linux/netfilter_bridge/ebt_nat.h b/include/linux/netfilter_bridge/ebt_nat.h
new file mode 100644
index 000000000000..26fd90da4cd6
--- /dev/null
+++ b/include/linux/netfilter_bridge/ebt_nat.h
@@ -0,0 +1,13 @@
1#ifndef __LINUX_BRIDGE_EBT_NAT_H
2#define __LINUX_BRIDGE_EBT_NAT_H
3
4struct ebt_nat_info
5{
6 unsigned char mac[ETH_ALEN];
7 /* EBT_ACCEPT, EBT_DROP, EBT_CONTINUE or EBT_RETURN */
8 int target;
9};
10#define EBT_SNAT_TARGET "snat"
11#define EBT_DNAT_TARGET "dnat"
12
13#endif
diff --git a/include/linux/netfilter_bridge/ebt_pkttype.h b/include/linux/netfilter_bridge/ebt_pkttype.h
new file mode 100644
index 000000000000..0d64bbb29c66
--- /dev/null
+++ b/include/linux/netfilter_bridge/ebt_pkttype.h
@@ -0,0 +1,11 @@
1#ifndef __LINUX_BRIDGE_EBT_PKTTYPE_H
2#define __LINUX_BRIDGE_EBT_PKTTYPE_H
3
4struct ebt_pkttype_info
5{
6 uint8_t pkt_type;
7 uint8_t invert;
8};
9#define EBT_PKTTYPE_MATCH "pkttype"
10
11#endif
diff --git a/include/linux/netfilter_bridge/ebt_redirect.h b/include/linux/netfilter_bridge/ebt_redirect.h
new file mode 100644
index 000000000000..5c67990fce39
--- /dev/null
+++ b/include/linux/netfilter_bridge/ebt_redirect.h
@@ -0,0 +1,11 @@
1#ifndef __LINUX_BRIDGE_EBT_REDIRECT_H
2#define __LINUX_BRIDGE_EBT_REDIRECT_H
3
4struct ebt_redirect_info
5{
6 /* EBT_ACCEPT, EBT_DROP, EBT_CONTINUE or EBT_RETURN */
7 int target;
8};
9#define EBT_REDIRECT_TARGET "redirect"
10
11#endif
diff --git a/include/linux/netfilter_bridge/ebt_stp.h b/include/linux/netfilter_bridge/ebt_stp.h
new file mode 100644
index 000000000000..e5fd67850f4d
--- /dev/null
+++ b/include/linux/netfilter_bridge/ebt_stp.h
@@ -0,0 +1,46 @@
1#ifndef __LINUX_BRIDGE_EBT_STP_H
2#define __LINUX_BRIDGE_EBT_STP_H
3
4#define EBT_STP_TYPE 0x0001
5
6#define EBT_STP_FLAGS 0x0002
7#define EBT_STP_ROOTPRIO 0x0004
8#define EBT_STP_ROOTADDR 0x0008
9#define EBT_STP_ROOTCOST 0x0010
10#define EBT_STP_SENDERPRIO 0x0020
11#define EBT_STP_SENDERADDR 0x0040
12#define EBT_STP_PORT 0x0080
13#define EBT_STP_MSGAGE 0x0100
14#define EBT_STP_MAXAGE 0x0200
15#define EBT_STP_HELLOTIME 0x0400
16#define EBT_STP_FWDD 0x0800
17
18#define EBT_STP_MASK 0x0fff
19#define EBT_STP_CONFIG_MASK 0x0ffe
20
21#define EBT_STP_MATCH "stp"
22
23struct ebt_stp_config_info
24{
25 uint8_t flags;
26 uint16_t root_priol, root_priou;
27 char root_addr[6], root_addrmsk[6];
28 uint32_t root_costl, root_costu;
29 uint16_t sender_priol, sender_priou;
30 char sender_addr[6], sender_addrmsk[6];
31 uint16_t portl, portu;
32 uint16_t msg_agel, msg_ageu;
33 uint16_t max_agel, max_ageu;
34 uint16_t hello_timel, hello_timeu;
35 uint16_t forward_delayl, forward_delayu;
36};
37
38struct ebt_stp_info
39{
40 uint8_t type;
41 struct ebt_stp_config_info config;
42 uint16_t bitmask;
43 uint16_t invflags;
44};
45
46#endif
diff --git a/include/linux/netfilter_bridge/ebt_ulog.h b/include/linux/netfilter_bridge/ebt_ulog.h
new file mode 100644
index 000000000000..b677e2671541
--- /dev/null
+++ b/include/linux/netfilter_bridge/ebt_ulog.h
@@ -0,0 +1,36 @@
1#ifndef _EBT_ULOG_H
2#define _EBT_ULOG_H
3
4#define EBT_ULOG_DEFAULT_NLGROUP 0
5#define EBT_ULOG_DEFAULT_QTHRESHOLD 1
6#define EBT_ULOG_MAXNLGROUPS 32 /* hardcoded netlink max */
7#define EBT_ULOG_PREFIX_LEN 32
8#define EBT_ULOG_MAX_QLEN 50
9#define EBT_ULOG_WATCHER "ulog"
10#define EBT_ULOG_VERSION 1
11
12struct ebt_ulog_info {
13 uint32_t nlgroup;
14 unsigned int cprange;
15 unsigned int qthreshold;
16 char prefix[EBT_ULOG_PREFIX_LEN];
17};
18
19typedef struct ebt_ulog_packet_msg {
20 int version;
21 char indev[IFNAMSIZ];
22 char outdev[IFNAMSIZ];
23 char physindev[IFNAMSIZ];
24 char physoutdev[IFNAMSIZ];
25 char prefix[EBT_ULOG_PREFIX_LEN];
26 struct timeval stamp;
27 unsigned long mark;
28 unsigned int hook;
29 size_t data_len;
30 /* The complete packet, including Ethernet header and perhaps
31 * the VLAN header is appended */
32 unsigned char data[0] __attribute__
33 ((aligned (__alignof__(struct ebt_ulog_info))));
34} ebt_ulog_packet_msg_t;
35
36#endif /* _EBT_ULOG_H */
diff --git a/include/linux/netfilter_bridge/ebt_vlan.h b/include/linux/netfilter_bridge/ebt_vlan.h
new file mode 100644
index 000000000000..cb1fcc41565f
--- /dev/null
+++ b/include/linux/netfilter_bridge/ebt_vlan.h
@@ -0,0 +1,20 @@
1#ifndef __LINUX_BRIDGE_EBT_VLAN_H
2#define __LINUX_BRIDGE_EBT_VLAN_H
3
4#define EBT_VLAN_ID 0x01
5#define EBT_VLAN_PRIO 0x02
6#define EBT_VLAN_ENCAP 0x04
7#define EBT_VLAN_MASK (EBT_VLAN_ID | EBT_VLAN_PRIO | EBT_VLAN_ENCAP)
8#define EBT_VLAN_MATCH "vlan"
9
10struct ebt_vlan_info {
11 uint16_t id; /* VLAN ID {1-4095} */
12 uint8_t prio; /* VLAN User Priority {0-7} */
13 uint16_t encap; /* VLAN Encapsulated frame code {0-65535} */
14 uint8_t bitmask; /* Args bitmask bit 1=1 - ID arg,
15 bit 2=1 User-Priority arg, bit 3=1 encap*/
16 uint8_t invflags; /* Inverse bitmask bit 1=1 - inversed ID arg,
17 bit 2=1 - inversed Pirority arg */
18};
19
20#endif
diff --git a/include/linux/netfilter_bridge/ebtables.h b/include/linux/netfilter_bridge/ebtables.h
new file mode 100644
index 000000000000..b1a7cc90877b
--- /dev/null
+++ b/include/linux/netfilter_bridge/ebtables.h
@@ -0,0 +1,363 @@
1/*
2 * ebtables
3 *
4 * Authors:
5 * Bart De Schuymer <bdschuym@pandora.be>
6 *
7 * ebtables.c,v 2.0, April, 2002
8 *
9 * This code is stongly inspired on the iptables code which is
10 * Copyright (C) 1999 Paul `Rusty' Russell & Michael J. Neuling
11 */
12
13#ifndef __LINUX_BRIDGE_EFF_H
14#define __LINUX_BRIDGE_EFF_H
15#include <linux/if.h>
16#include <linux/netfilter_bridge.h>
17#include <linux/if_ether.h>
18
19#define EBT_TABLE_MAXNAMELEN 32
20#define EBT_CHAIN_MAXNAMELEN EBT_TABLE_MAXNAMELEN
21#define EBT_FUNCTION_MAXNAMELEN EBT_TABLE_MAXNAMELEN
22
23/* verdicts >0 are "branches" */
24#define EBT_ACCEPT -1
25#define EBT_DROP -2
26#define EBT_CONTINUE -3
27#define EBT_RETURN -4
28#define NUM_STANDARD_TARGETS 4
29
30struct ebt_counter
31{
32 uint64_t pcnt;
33 uint64_t bcnt;
34};
35
36struct ebt_replace
37{
38 char name[EBT_TABLE_MAXNAMELEN];
39 unsigned int valid_hooks;
40 /* nr of rules in the table */
41 unsigned int nentries;
42 /* total size of the entries */
43 unsigned int entries_size;
44 /* start of the chains */
45 struct ebt_entries *hook_entry[NF_BR_NUMHOOKS];
46 /* nr of counters userspace expects back */
47 unsigned int num_counters;
48 /* where the kernel will put the old counters */
49 struct ebt_counter *counters;
50 char *entries;
51};
52
53struct ebt_entries {
54 /* this field is always set to zero
55 * See EBT_ENTRY_OR_ENTRIES.
56 * Must be same size as ebt_entry.bitmask */
57 unsigned int distinguisher;
58 /* the chain name */
59 char name[EBT_CHAIN_MAXNAMELEN];
60 /* counter offset for this chain */
61 unsigned int counter_offset;
62 /* one standard (accept, drop, return) per hook */
63 int policy;
64 /* nr. of entries */
65 unsigned int nentries;
66 /* entry list */
67 char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
68};
69
70/* used for the bitmask of struct ebt_entry */
71
72/* This is a hack to make a difference between an ebt_entry struct and an
73 * ebt_entries struct when traversing the entries from start to end.
74 * Using this simplifies the code alot, while still being able to use
75 * ebt_entries.
76 * Contrary, iptables doesn't use something like ebt_entries and therefore uses
77 * different techniques for naming the policy and such. So, iptables doesn't
78 * need a hack like this.
79 */
80#define EBT_ENTRY_OR_ENTRIES 0x01
81/* these are the normal masks */
82#define EBT_NOPROTO 0x02
83#define EBT_802_3 0x04
84#define EBT_SOURCEMAC 0x08
85#define EBT_DESTMAC 0x10
86#define EBT_F_MASK (EBT_NOPROTO | EBT_802_3 | EBT_SOURCEMAC | EBT_DESTMAC \
87 | EBT_ENTRY_OR_ENTRIES)
88
89#define EBT_IPROTO 0x01
90#define EBT_IIN 0x02
91#define EBT_IOUT 0x04
92#define EBT_ISOURCE 0x8
93#define EBT_IDEST 0x10
94#define EBT_ILOGICALIN 0x20
95#define EBT_ILOGICALOUT 0x40
96#define EBT_INV_MASK (EBT_IPROTO | EBT_IIN | EBT_IOUT | EBT_ILOGICALIN \
97 | EBT_ILOGICALOUT | EBT_ISOURCE | EBT_IDEST)
98
99struct ebt_entry_match
100{
101 union {
102 char name[EBT_FUNCTION_MAXNAMELEN];
103 struct ebt_match *match;
104 } u;
105 /* size of data */
106 unsigned int match_size;
107 unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
108};
109
110struct ebt_entry_watcher
111{
112 union {
113 char name[EBT_FUNCTION_MAXNAMELEN];
114 struct ebt_watcher *watcher;
115 } u;
116 /* size of data */
117 unsigned int watcher_size;
118 unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
119};
120
121struct ebt_entry_target
122{
123 union {
124 char name[EBT_FUNCTION_MAXNAMELEN];
125 struct ebt_target *target;
126 } u;
127 /* size of data */
128 unsigned int target_size;
129 unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
130};
131
132#define EBT_STANDARD_TARGET "standard"
133struct ebt_standard_target
134{
135 struct ebt_entry_target target;
136 int verdict;
137};
138
139/* one entry */
140struct ebt_entry {
141 /* this needs to be the first field */
142 unsigned int bitmask;
143 unsigned int invflags;
144 uint16_t ethproto;
145 /* the physical in-dev */
146 char in[IFNAMSIZ];
147 /* the logical in-dev */
148 char logical_in[IFNAMSIZ];
149 /* the physical out-dev */
150 char out[IFNAMSIZ];
151 /* the logical out-dev */
152 char logical_out[IFNAMSIZ];
153 unsigned char sourcemac[ETH_ALEN];
154 unsigned char sourcemsk[ETH_ALEN];
155 unsigned char destmac[ETH_ALEN];
156 unsigned char destmsk[ETH_ALEN];
157 /* sizeof ebt_entry + matches */
158 unsigned int watchers_offset;
159 /* sizeof ebt_entry + matches + watchers */
160 unsigned int target_offset;
161 /* sizeof ebt_entry + matches + watchers + target */
162 unsigned int next_offset;
163 unsigned char elems[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
164};
165
166/* {g,s}etsockopt numbers */
167#define EBT_BASE_CTL 128
168
169#define EBT_SO_SET_ENTRIES (EBT_BASE_CTL)
170#define EBT_SO_SET_COUNTERS (EBT_SO_SET_ENTRIES+1)
171#define EBT_SO_SET_MAX (EBT_SO_SET_COUNTERS+1)
172
173#define EBT_SO_GET_INFO (EBT_BASE_CTL)
174#define EBT_SO_GET_ENTRIES (EBT_SO_GET_INFO+1)
175#define EBT_SO_GET_INIT_INFO (EBT_SO_GET_ENTRIES+1)
176#define EBT_SO_GET_INIT_ENTRIES (EBT_SO_GET_INIT_INFO+1)
177#define EBT_SO_GET_MAX (EBT_SO_GET_INIT_ENTRIES+1)
178
179#ifdef __KERNEL__
180
181/* return values for match() functions */
182#define EBT_MATCH 0
183#define EBT_NOMATCH 1
184
185struct ebt_match
186{
187 struct list_head list;
188 const char name[EBT_FUNCTION_MAXNAMELEN];
189 /* 0 == it matches */
190 int (*match)(const struct sk_buff *skb, const struct net_device *in,
191 const struct net_device *out, const void *matchdata,
192 unsigned int datalen);
193 /* 0 == let it in */
194 int (*check)(const char *tablename, unsigned int hookmask,
195 const struct ebt_entry *e, void *matchdata, unsigned int datalen);
196 void (*destroy)(void *matchdata, unsigned int datalen);
197 struct module *me;
198};
199
200struct ebt_watcher
201{
202 struct list_head list;
203 const char name[EBT_FUNCTION_MAXNAMELEN];
204 void (*watcher)(const struct sk_buff *skb, unsigned int hooknr,
205 const struct net_device *in, const struct net_device *out,
206 const void *watcherdata, unsigned int datalen);
207 /* 0 == let it in */
208 int (*check)(const char *tablename, unsigned int hookmask,
209 const struct ebt_entry *e, void *watcherdata, unsigned int datalen);
210 void (*destroy)(void *watcherdata, unsigned int datalen);
211 struct module *me;
212};
213
214struct ebt_target
215{
216 struct list_head list;
217 const char name[EBT_FUNCTION_MAXNAMELEN];
218 /* returns one of the standard verdicts */
219 int (*target)(struct sk_buff **pskb, unsigned int hooknr,
220 const struct net_device *in, const struct net_device *out,
221 const void *targetdata, unsigned int datalen);
222 /* 0 == let it in */
223 int (*check)(const char *tablename, unsigned int hookmask,
224 const struct ebt_entry *e, void *targetdata, unsigned int datalen);
225 void (*destroy)(void *targetdata, unsigned int datalen);
226 struct module *me;
227};
228
229/* used for jumping from and into user defined chains (udc) */
230struct ebt_chainstack
231{
232 struct ebt_entries *chaininfo; /* pointer to chain data */
233 struct ebt_entry *e; /* pointer to entry data */
234 unsigned int n; /* n'th entry */
235};
236
237struct ebt_table_info
238{
239 /* total size of the entries */
240 unsigned int entries_size;
241 unsigned int nentries;
242 /* pointers to the start of the chains */
243 struct ebt_entries *hook_entry[NF_BR_NUMHOOKS];
244 /* room to maintain the stack used for jumping from and into udc */
245 struct ebt_chainstack **chainstack;
246 char *entries;
247 struct ebt_counter counters[0] ____cacheline_aligned;
248};
249
250struct ebt_table
251{
252 struct list_head list;
253 char name[EBT_TABLE_MAXNAMELEN];
254 struct ebt_replace *table;
255 unsigned int valid_hooks;
256 rwlock_t lock;
257 /* e.g. could be the table explicitly only allows certain
258 * matches, targets, ... 0 == let it in */
259 int (*check)(const struct ebt_table_info *info,
260 unsigned int valid_hooks);
261 /* the data used by the kernel */
262 struct ebt_table_info *private;
263 struct module *me;
264};
265
266#define EBT_ALIGN(s) (((s) + (__alignof__(struct ebt_replace)-1)) & \
267 ~(__alignof__(struct ebt_replace)-1))
268extern int ebt_register_table(struct ebt_table *table);
269extern void ebt_unregister_table(struct ebt_table *table);
270extern int ebt_register_match(struct ebt_match *match);
271extern void ebt_unregister_match(struct ebt_match *match);
272extern int ebt_register_watcher(struct ebt_watcher *watcher);
273extern void ebt_unregister_watcher(struct ebt_watcher *watcher);
274extern int ebt_register_target(struct ebt_target *target);
275extern void ebt_unregister_target(struct ebt_target *target);
276extern unsigned int ebt_do_table(unsigned int hook, struct sk_buff **pskb,
277 const struct net_device *in, const struct net_device *out,
278 struct ebt_table *table);
279
280/* Used in the kernel match() functions */
281#define FWINV(bool,invflg) ((bool) ^ !!(info->invflags & invflg))
282/* True if the hook mask denotes that the rule is in a base chain,
283 * used in the check() functions */
284#define BASE_CHAIN (hookmask & (1 << NF_BR_NUMHOOKS))
285/* Clear the bit in the hook mask that tells if the rule is on a base chain */
286#define CLEAR_BASE_CHAIN_BIT (hookmask &= ~(1 << NF_BR_NUMHOOKS))
287/* True if the target is not a standard target */
288#define INVALID_TARGET (info->target < -NUM_STANDARD_TARGETS || info->target >= 0)
289
290#endif /* __KERNEL__ */
291
292/* blatently stolen from ip_tables.h
293 * fn returns 0 to continue iteration */
294#define EBT_MATCH_ITERATE(e, fn, args...) \
295({ \
296 unsigned int __i; \
297 int __ret = 0; \
298 struct ebt_entry_match *__match; \
299 \
300 for (__i = sizeof(struct ebt_entry); \
301 __i < (e)->watchers_offset; \
302 __i += __match->match_size + \
303 sizeof(struct ebt_entry_match)) { \
304 __match = (void *)(e) + __i; \
305 \
306 __ret = fn(__match , ## args); \
307 if (__ret != 0) \
308 break; \
309 } \
310 if (__ret == 0) { \
311 if (__i != (e)->watchers_offset) \
312 __ret = -EINVAL; \
313 } \
314 __ret; \
315})
316
317#define EBT_WATCHER_ITERATE(e, fn, args...) \
318({ \
319 unsigned int __i; \
320 int __ret = 0; \
321 struct ebt_entry_watcher *__watcher; \
322 \
323 for (__i = e->watchers_offset; \
324 __i < (e)->target_offset; \
325 __i += __watcher->watcher_size + \
326 sizeof(struct ebt_entry_watcher)) { \
327 __watcher = (void *)(e) + __i; \
328 \
329 __ret = fn(__watcher , ## args); \
330 if (__ret != 0) \
331 break; \
332 } \
333 if (__ret == 0) { \
334 if (__i != (e)->target_offset) \
335 __ret = -EINVAL; \
336 } \
337 __ret; \
338})
339
340#define EBT_ENTRY_ITERATE(entries, size, fn, args...) \
341({ \
342 unsigned int __i; \
343 int __ret = 0; \
344 struct ebt_entry *__entry; \
345 \
346 for (__i = 0; __i < (size);) { \
347 __entry = (void *)(entries) + __i; \
348 __ret = fn(__entry , ## args); \
349 if (__ret != 0) \
350 break; \
351 if (__entry->bitmask != 0) \
352 __i += __entry->next_offset; \
353 else \
354 __i += sizeof(struct ebt_entries); \
355 } \
356 if (__ret == 0) { \
357 if (__i != (size)) \
358 __ret = -EINVAL; \
359 } \
360 __ret; \
361})
362
363#endif
diff --git a/include/linux/netfilter_decnet.h b/include/linux/netfilter_decnet.h
new file mode 100644
index 000000000000..3064eec9cb8e
--- /dev/null
+++ b/include/linux/netfilter_decnet.h
@@ -0,0 +1,59 @@
1#ifndef __LINUX_DECNET_NETFILTER_H
2#define __LINUX_DECNET_NETFILTER_H
3
4/* DECnet-specific defines for netfilter.
5 * This file (C) Steve Whitehouse 1999 derived from the
6 * ipv4 netfilter header file which is
7 * (C)1998 Rusty Russell -- This code is GPL.
8 */
9
10#include <linux/netfilter.h>
11
12/* IP Cache bits. */
13/* Src IP address. */
14#define NFC_DN_SRC 0x0001
15/* Dest IP address. */
16#define NFC_DN_DST 0x0002
17/* Input device. */
18#define NFC_DN_IF_IN 0x0004
19/* Output device. */
20#define NFC_DN_IF_OUT 0x0008
21
22/* DECnet Hooks */
23/* After promisc drops, checksum checks. */
24#define NF_DN_PRE_ROUTING 0
25/* If the packet is destined for this box. */
26#define NF_DN_LOCAL_IN 1
27/* If the packet is destined for another interface. */
28#define NF_DN_FORWARD 2
29/* Packets coming from a local process. */
30#define NF_DN_LOCAL_OUT 3
31/* Packets about to hit the wire. */
32#define NF_DN_POST_ROUTING 4
33/* Input Hello Packets */
34#define NF_DN_HELLO 5
35/* Input Routing Packets */
36#define NF_DN_ROUTE 6
37#define NF_DN_NUMHOOKS 7
38
39enum nf_dn_hook_priorities {
40 NF_DN_PRI_FIRST = INT_MIN,
41 NF_DN_PRI_CONNTRACK = -200,
42 NF_DN_PRI_MANGLE = -150,
43 NF_DN_PRI_NAT_DST = -100,
44 NF_DN_PRI_FILTER = 0,
45 NF_DN_PRI_NAT_SRC = 100,
46 NF_DN_PRI_DNRTMSG = 200,
47 NF_DN_PRI_LAST = INT_MAX,
48};
49
50struct nf_dn_rtmsg {
51 int nfdn_ifindex;
52};
53
54#define NFDN_RTMSG(r) ((unsigned char *)(r) + NLMSG_ALIGN(sizeof(struct nf_dn_rtmsg)))
55
56#define DNRMG_L1_GROUP 0x01
57#define DNRMG_L2_GROUP 0x02
58
59#endif /*__LINUX_DECNET_NETFILTER_H*/
diff --git a/include/linux/netfilter_ipv4.h b/include/linux/netfilter_ipv4.h
new file mode 100644
index 000000000000..c9bacf9b2431
--- /dev/null
+++ b/include/linux/netfilter_ipv4.h
@@ -0,0 +1,90 @@
1#ifndef __LINUX_IP_NETFILTER_H
2#define __LINUX_IP_NETFILTER_H
3
4/* IPv4-specific defines for netfilter.
5 * (C)1998 Rusty Russell -- This code is GPL.
6 */
7
8#include <linux/config.h>
9#include <linux/netfilter.h>
10
11/* IP Cache bits. */
12/* Src IP address. */
13#define NFC_IP_SRC 0x0001
14/* Dest IP address. */
15#define NFC_IP_DST 0x0002
16/* Input device. */
17#define NFC_IP_IF_IN 0x0004
18/* Output device. */
19#define NFC_IP_IF_OUT 0x0008
20/* TOS. */
21#define NFC_IP_TOS 0x0010
22/* Protocol. */
23#define NFC_IP_PROTO 0x0020
24/* IP options. */
25#define NFC_IP_OPTIONS 0x0040
26/* Frag & flags. */
27#define NFC_IP_FRAG 0x0080
28
29/* Per-protocol information: only matters if proto match. */
30/* TCP flags. */
31#define NFC_IP_TCPFLAGS 0x0100
32/* Source port. */
33#define NFC_IP_SRC_PT 0x0200
34/* Dest port. */
35#define NFC_IP_DST_PT 0x0400
36/* Something else about the proto */
37#define NFC_IP_PROTO_UNKNOWN 0x2000
38
39/* IP Hooks */
40/* After promisc drops, checksum checks. */
41#define NF_IP_PRE_ROUTING 0
42/* If the packet is destined for this box. */
43#define NF_IP_LOCAL_IN 1
44/* If the packet is destined for another interface. */
45#define NF_IP_FORWARD 2
46/* Packets coming from a local process. */
47#define NF_IP_LOCAL_OUT 3
48/* Packets about to hit the wire. */
49#define NF_IP_POST_ROUTING 4
50#define NF_IP_NUMHOOKS 5
51
52enum nf_ip_hook_priorities {
53 NF_IP_PRI_FIRST = INT_MIN,
54 NF_IP_PRI_CONNTRACK_DEFRAG = -400,
55 NF_IP_PRI_RAW = -300,
56 NF_IP_PRI_SELINUX_FIRST = -225,
57 NF_IP_PRI_CONNTRACK = -200,
58 NF_IP_PRI_BRIDGE_SABOTAGE_FORWARD = -175,
59 NF_IP_PRI_MANGLE = -150,
60 NF_IP_PRI_NAT_DST = -100,
61 NF_IP_PRI_BRIDGE_SABOTAGE_LOCAL_OUT = -50,
62 NF_IP_PRI_FILTER = 0,
63 NF_IP_PRI_NAT_SRC = 100,
64 NF_IP_PRI_SELINUX_LAST = 225,
65 NF_IP_PRI_LAST = INT_MAX,
66};
67
68/* Arguments for setsockopt SOL_IP: */
69/* 2.0 firewalling went from 64 through 71 (and +256, +512, etc). */
70/* 2.2 firewalling (+ masq) went from 64 through 76 */
71/* 2.4 firewalling went 64 through 67. */
72#define SO_ORIGINAL_DST 80
73
74#ifdef __KERNEL__
75#ifdef CONFIG_NETFILTER_DEBUG
76void nf_debug_ip_local_deliver(struct sk_buff *skb);
77void nf_debug_ip_loopback_xmit(struct sk_buff *newskb);
78void nf_debug_ip_finish_output2(struct sk_buff *skb);
79#endif /*CONFIG_NETFILTER_DEBUG*/
80
81extern int ip_route_me_harder(struct sk_buff **pskb);
82
83/* Call this before modifying an existing IP packet: ensures it is
84 modifiable and linear to the point you care about (writable_len).
85 Returns true or false. */
86extern int skb_ip_make_writable(struct sk_buff **pskb,
87 unsigned int writable_len);
88#endif /*__KERNEL__*/
89
90#endif /*__LINUX_IP_NETFILTER_H*/
diff --git a/include/linux/netfilter_ipv4/ip_conntrack.h b/include/linux/netfilter_ipv4/ip_conntrack.h
new file mode 100644
index 000000000000..3781192ce159
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ip_conntrack.h
@@ -0,0 +1,314 @@
1#ifndef _IP_CONNTRACK_H
2#define _IP_CONNTRACK_H
3/* Connection state tracking for netfilter. This is separated from,
4 but required by, the NAT layer; it can also be used by an iptables
5 extension. */
6enum ip_conntrack_info
7{
8 /* Part of an established connection (either direction). */
9 IP_CT_ESTABLISHED,
10
11 /* Like NEW, but related to an existing connection, or ICMP error
12 (in either direction). */
13 IP_CT_RELATED,
14
15 /* Started a new connection to track (only
16 IP_CT_DIR_ORIGINAL); may be a retransmission. */
17 IP_CT_NEW,
18
19 /* >= this indicates reply direction */
20 IP_CT_IS_REPLY,
21
22 /* Number of distinct IP_CT types (no NEW in reply dirn). */
23 IP_CT_NUMBER = IP_CT_IS_REPLY * 2 - 1
24};
25
26/* Bitset representing status of connection. */
27enum ip_conntrack_status {
28 /* It's an expected connection: bit 0 set. This bit never changed */
29 IPS_EXPECTED_BIT = 0,
30 IPS_EXPECTED = (1 << IPS_EXPECTED_BIT),
31
32 /* We've seen packets both ways: bit 1 set. Can be set, not unset. */
33 IPS_SEEN_REPLY_BIT = 1,
34 IPS_SEEN_REPLY = (1 << IPS_SEEN_REPLY_BIT),
35
36 /* Conntrack should never be early-expired. */
37 IPS_ASSURED_BIT = 2,
38 IPS_ASSURED = (1 << IPS_ASSURED_BIT),
39
40 /* Connection is confirmed: originating packet has left box */
41 IPS_CONFIRMED_BIT = 3,
42 IPS_CONFIRMED = (1 << IPS_CONFIRMED_BIT),
43
44 /* Connection needs src nat in orig dir. This bit never changed. */
45 IPS_SRC_NAT_BIT = 4,
46 IPS_SRC_NAT = (1 << IPS_SRC_NAT_BIT),
47
48 /* Connection needs dst nat in orig dir. This bit never changed. */
49 IPS_DST_NAT_BIT = 5,
50 IPS_DST_NAT = (1 << IPS_DST_NAT_BIT),
51
52 /* Both together. */
53 IPS_NAT_MASK = (IPS_DST_NAT | IPS_SRC_NAT),
54
55 /* Connection needs TCP sequence adjusted. */
56 IPS_SEQ_ADJUST_BIT = 6,
57 IPS_SEQ_ADJUST = (1 << IPS_SEQ_ADJUST_BIT),
58
59 /* NAT initialization bits. */
60 IPS_SRC_NAT_DONE_BIT = 7,
61 IPS_SRC_NAT_DONE = (1 << IPS_SRC_NAT_DONE_BIT),
62
63 IPS_DST_NAT_DONE_BIT = 8,
64 IPS_DST_NAT_DONE = (1 << IPS_DST_NAT_DONE_BIT),
65
66 /* Both together */
67 IPS_NAT_DONE_MASK = (IPS_DST_NAT_DONE | IPS_SRC_NAT_DONE),
68};
69
70#ifdef __KERNEL__
71#include <linux/config.h>
72#include <linux/netfilter_ipv4/ip_conntrack_tuple.h>
73#include <linux/bitops.h>
74#include <linux/compiler.h>
75#include <asm/atomic.h>
76
77#include <linux/netfilter_ipv4/ip_conntrack_tcp.h>
78#include <linux/netfilter_ipv4/ip_conntrack_icmp.h>
79#include <linux/netfilter_ipv4/ip_conntrack_sctp.h>
80
81/* per conntrack: protocol private data */
82union ip_conntrack_proto {
83 /* insert conntrack proto private data here */
84 struct ip_ct_sctp sctp;
85 struct ip_ct_tcp tcp;
86 struct ip_ct_icmp icmp;
87};
88
89union ip_conntrack_expect_proto {
90 /* insert expect proto private data here */
91};
92
93/* Add protocol helper include file here */
94#include <linux/netfilter_ipv4/ip_conntrack_amanda.h>
95#include <linux/netfilter_ipv4/ip_conntrack_ftp.h>
96#include <linux/netfilter_ipv4/ip_conntrack_irc.h>
97
98/* per conntrack: application helper private data */
99union ip_conntrack_help {
100 /* insert conntrack helper private data (master) here */
101 struct ip_ct_ftp_master ct_ftp_info;
102 struct ip_ct_irc_master ct_irc_info;
103};
104
105#ifdef CONFIG_IP_NF_NAT_NEEDED
106#include <linux/netfilter_ipv4/ip_nat.h>
107#endif
108
109#include <linux/types.h>
110#include <linux/skbuff.h>
111
112#ifdef CONFIG_NETFILTER_DEBUG
113#define IP_NF_ASSERT(x) \
114do { \
115 if (!(x)) \
116 /* Wooah! I'm tripping my conntrack in a frenzy of \
117 netplay... */ \
118 printk("NF_IP_ASSERT: %s:%i(%s)\n", \
119 __FILE__, __LINE__, __FUNCTION__); \
120} while(0)
121#else
122#define IP_NF_ASSERT(x)
123#endif
124
125struct ip_conntrack_counter
126{
127 u_int64_t packets;
128 u_int64_t bytes;
129};
130
131struct ip_conntrack_helper;
132
133struct ip_conntrack
134{
135 /* Usage count in here is 1 for hash table/destruct timer, 1 per skb,
136 plus 1 for any connection(s) we are `master' for */
137 struct nf_conntrack ct_general;
138
139 /* Have we seen traffic both ways yet? (bitset) */
140 unsigned long status;
141
142 /* Timer function; drops refcnt when it goes off. */
143 struct timer_list timeout;
144
145#ifdef CONFIG_IP_NF_CT_ACCT
146 /* Accounting Information (same cache line as other written members) */
147 struct ip_conntrack_counter counters[IP_CT_DIR_MAX];
148#endif
149 /* If we were expected by an expectation, this will be it */
150 struct ip_conntrack *master;
151
152 /* Current number of expected connections */
153 unsigned int expecting;
154
155 /* Helper, if any. */
156 struct ip_conntrack_helper *helper;
157
158 /* Storage reserved for other modules: */
159 union ip_conntrack_proto proto;
160
161 union ip_conntrack_help help;
162
163#ifdef CONFIG_IP_NF_NAT_NEEDED
164 struct {
165 struct ip_nat_info info;
166#if defined(CONFIG_IP_NF_TARGET_MASQUERADE) || \
167 defined(CONFIG_IP_NF_TARGET_MASQUERADE_MODULE)
168 int masq_index;
169#endif
170 } nat;
171#endif /* CONFIG_IP_NF_NAT_NEEDED */
172
173#if defined(CONFIG_IP_NF_CONNTRACK_MARK)
174 unsigned long mark;
175#endif
176
177 /* Traversed often, so hopefully in different cacheline to top */
178 /* These are my tuples; original and reply */
179 struct ip_conntrack_tuple_hash tuplehash[IP_CT_DIR_MAX];
180};
181
182struct ip_conntrack_expect
183{
184 /* Internal linked list (global expectation list) */
185 struct list_head list;
186
187 /* We expect this tuple, with the following mask */
188 struct ip_conntrack_tuple tuple, mask;
189
190 /* Function to call after setup and insertion */
191 void (*expectfn)(struct ip_conntrack *new,
192 struct ip_conntrack_expect *this);
193
194 /* The conntrack of the master connection */
195 struct ip_conntrack *master;
196
197 /* Timer function; deletes the expectation. */
198 struct timer_list timeout;
199
200#ifdef CONFIG_IP_NF_NAT_NEEDED
201 /* This is the original per-proto part, used to map the
202 * expected connection the way the recipient expects. */
203 union ip_conntrack_manip_proto saved_proto;
204 /* Direction relative to the master connection. */
205 enum ip_conntrack_dir dir;
206#endif
207};
208
209static inline struct ip_conntrack *
210tuplehash_to_ctrack(const struct ip_conntrack_tuple_hash *hash)
211{
212 return container_of(hash, struct ip_conntrack,
213 tuplehash[hash->tuple.dst.dir]);
214}
215
216/* get master conntrack via master expectation */
217#define master_ct(conntr) (conntr->master)
218
219/* Alter reply tuple (maybe alter helper). */
220extern void
221ip_conntrack_alter_reply(struct ip_conntrack *conntrack,
222 const struct ip_conntrack_tuple *newreply);
223
224/* Is this tuple taken? (ignoring any belonging to the given
225 conntrack). */
226extern int
227ip_conntrack_tuple_taken(const struct ip_conntrack_tuple *tuple,
228 const struct ip_conntrack *ignored_conntrack);
229
230/* Return conntrack_info and tuple hash for given skb. */
231static inline struct ip_conntrack *
232ip_conntrack_get(const struct sk_buff *skb, enum ip_conntrack_info *ctinfo)
233{
234 *ctinfo = skb->nfctinfo;
235 return (struct ip_conntrack *)skb->nfct;
236}
237
238/* decrement reference count on a conntrack */
239extern inline void ip_conntrack_put(struct ip_conntrack *ct);
240
241/* call to create an explicit dependency on ip_conntrack. */
242extern void need_ip_conntrack(void);
243
244extern int invert_tuplepr(struct ip_conntrack_tuple *inverse,
245 const struct ip_conntrack_tuple *orig);
246
247/* Refresh conntrack for this many jiffies */
248extern void ip_ct_refresh_acct(struct ip_conntrack *ct,
249 enum ip_conntrack_info ctinfo,
250 const struct sk_buff *skb,
251 unsigned long extra_jiffies);
252
253/* These are for NAT. Icky. */
254/* Update TCP window tracking data when NAT mangles the packet */
255extern void ip_conntrack_tcp_update(struct sk_buff *skb,
256 struct ip_conntrack *conntrack,
257 enum ip_conntrack_dir dir);
258
259/* Call me when a conntrack is destroyed. */
260extern void (*ip_conntrack_destroyed)(struct ip_conntrack *conntrack);
261
262/* Fake conntrack entry for untracked connections */
263extern struct ip_conntrack ip_conntrack_untracked;
264
265/* Returns new sk_buff, or NULL */
266struct sk_buff *
267ip_ct_gather_frags(struct sk_buff *skb, u_int32_t user);
268
269/* Iterate over all conntracks: if iter returns true, it's deleted. */
270extern void
271ip_ct_iterate_cleanup(int (*iter)(struct ip_conntrack *i, void *data),
272 void *data);
273
274/* It's confirmed if it is, or has been in the hash table. */
275static inline int is_confirmed(struct ip_conntrack *ct)
276{
277 return test_bit(IPS_CONFIRMED_BIT, &ct->status);
278}
279
280extern unsigned int ip_conntrack_htable_size;
281
282struct ip_conntrack_stat
283{
284 unsigned int searched;
285 unsigned int found;
286 unsigned int new;
287 unsigned int invalid;
288 unsigned int ignore;
289 unsigned int delete;
290 unsigned int delete_list;
291 unsigned int insert;
292 unsigned int insert_failed;
293 unsigned int drop;
294 unsigned int early_drop;
295 unsigned int error;
296 unsigned int expect_new;
297 unsigned int expect_create;
298 unsigned int expect_delete;
299};
300
301#define CONNTRACK_STAT_INC(count) (__get_cpu_var(ip_conntrack_stat).count++)
302
303#ifdef CONFIG_IP_NF_NAT_NEEDED
304static inline int ip_nat_initialized(struct ip_conntrack *conntrack,
305 enum ip_nat_manip_type manip)
306{
307 if (manip == IP_NAT_MANIP_SRC)
308 return test_bit(IPS_SRC_NAT_DONE_BIT, &conntrack->status);
309 return test_bit(IPS_DST_NAT_DONE_BIT, &conntrack->status);
310}
311#endif /* CONFIG_IP_NF_NAT_NEEDED */
312
313#endif /* __KERNEL__ */
314#endif /* _IP_CONNTRACK_H */
diff --git a/include/linux/netfilter_ipv4/ip_conntrack_amanda.h b/include/linux/netfilter_ipv4/ip_conntrack_amanda.h
new file mode 100644
index 000000000000..de3e41f51aec
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ip_conntrack_amanda.h
@@ -0,0 +1,11 @@
1#ifndef _IP_CONNTRACK_AMANDA_H
2#define _IP_CONNTRACK_AMANDA_H
3/* AMANDA tracking. */
4
5struct ip_conntrack_expect;
6extern unsigned int (*ip_nat_amanda_hook)(struct sk_buff **pskb,
7 enum ip_conntrack_info ctinfo,
8 unsigned int matchoff,
9 unsigned int matchlen,
10 struct ip_conntrack_expect *exp);
11#endif /* _IP_CONNTRACK_AMANDA_H */
diff --git a/include/linux/netfilter_ipv4/ip_conntrack_core.h b/include/linux/netfilter_ipv4/ip_conntrack_core.h
new file mode 100644
index 000000000000..d84be02cb4fc
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ip_conntrack_core.h
@@ -0,0 +1,52 @@
1#ifndef _IP_CONNTRACK_CORE_H
2#define _IP_CONNTRACK_CORE_H
3#include <linux/netfilter.h>
4#include <linux/netfilter_ipv4/lockhelp.h>
5
6/* This header is used to share core functionality between the
7 standalone connection tracking module, and the compatibility layer's use
8 of connection tracking. */
9extern unsigned int ip_conntrack_in(unsigned int hooknum,
10 struct sk_buff **pskb,
11 const struct net_device *in,
12 const struct net_device *out,
13 int (*okfn)(struct sk_buff *));
14
15extern int ip_conntrack_init(void);
16extern void ip_conntrack_cleanup(void);
17
18struct ip_conntrack_protocol;
19
20extern int
21ip_ct_get_tuple(const struct iphdr *iph,
22 const struct sk_buff *skb,
23 unsigned int dataoff,
24 struct ip_conntrack_tuple *tuple,
25 const struct ip_conntrack_protocol *protocol);
26
27extern int
28ip_ct_invert_tuple(struct ip_conntrack_tuple *inverse,
29 const struct ip_conntrack_tuple *orig,
30 const struct ip_conntrack_protocol *protocol);
31
32/* Find a connection corresponding to a tuple. */
33struct ip_conntrack_tuple_hash *
34ip_conntrack_find_get(const struct ip_conntrack_tuple *tuple,
35 const struct ip_conntrack *ignored_conntrack);
36
37extern int __ip_conntrack_confirm(struct sk_buff **pskb);
38
39/* Confirm a connection: returns NF_DROP if packet must be dropped. */
40static inline int ip_conntrack_confirm(struct sk_buff **pskb)
41{
42 if ((*pskb)->nfct
43 && !is_confirmed((struct ip_conntrack *)(*pskb)->nfct))
44 return __ip_conntrack_confirm(pskb);
45 return NF_ACCEPT;
46}
47
48extern struct list_head *ip_conntrack_hash;
49extern struct list_head ip_conntrack_expect_list;
50DECLARE_RWLOCK_EXTERN(ip_conntrack_lock);
51#endif /* _IP_CONNTRACK_CORE_H */
52
diff --git a/include/linux/netfilter_ipv4/ip_conntrack_ftp.h b/include/linux/netfilter_ipv4/ip_conntrack_ftp.h
new file mode 100644
index 000000000000..5f06429b9047
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ip_conntrack_ftp.h
@@ -0,0 +1,43 @@
1#ifndef _IP_CONNTRACK_FTP_H
2#define _IP_CONNTRACK_FTP_H
3/* FTP tracking. */
4
5#ifdef __KERNEL__
6
7#define FTP_PORT 21
8
9#endif /* __KERNEL__ */
10
11enum ip_ct_ftp_type
12{
13 /* PORT command from client */
14 IP_CT_FTP_PORT,
15 /* PASV response from server */
16 IP_CT_FTP_PASV,
17 /* EPRT command from client */
18 IP_CT_FTP_EPRT,
19 /* EPSV response from server */
20 IP_CT_FTP_EPSV,
21};
22
23#define NUM_SEQ_TO_REMEMBER 2
24/* This structure exists only once per master */
25struct ip_ct_ftp_master {
26 /* Valid seq positions for cmd matching after newline */
27 u_int32_t seq_aft_nl[IP_CT_DIR_MAX][NUM_SEQ_TO_REMEMBER];
28 /* 0 means seq_match_aft_nl not set */
29 int seq_aft_nl_num[IP_CT_DIR_MAX];
30};
31
32struct ip_conntrack_expect;
33
34/* For NAT to hook in when we find a packet which describes what other
35 * connection we should expect. */
36extern unsigned int (*ip_nat_ftp_hook)(struct sk_buff **pskb,
37 enum ip_conntrack_info ctinfo,
38 enum ip_ct_ftp_type type,
39 unsigned int matchoff,
40 unsigned int matchlen,
41 struct ip_conntrack_expect *exp,
42 u32 *seq);
43#endif /* _IP_CONNTRACK_FTP_H */
diff --git a/include/linux/netfilter_ipv4/ip_conntrack_helper.h b/include/linux/netfilter_ipv4/ip_conntrack_helper.h
new file mode 100644
index 000000000000..b1bbba0a12cb
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ip_conntrack_helper.h
@@ -0,0 +1,41 @@
1/* IP connection tracking helpers. */
2#ifndef _IP_CONNTRACK_HELPER_H
3#define _IP_CONNTRACK_HELPER_H
4#include <linux/netfilter_ipv4/ip_conntrack.h>
5
6struct module;
7
8struct ip_conntrack_helper
9{
10 struct list_head list; /* Internal use. */
11
12 const char *name; /* name of the module */
13 struct module *me; /* pointer to self */
14 unsigned int max_expected; /* Maximum number of concurrent
15 * expected connections */
16 unsigned int timeout; /* timeout for expecteds */
17
18 /* Mask of things we will help (compared against server response) */
19 struct ip_conntrack_tuple tuple;
20 struct ip_conntrack_tuple mask;
21
22 /* Function to call when data passes; return verdict, or -1 to
23 invalidate. */
24 int (*help)(struct sk_buff **pskb,
25 struct ip_conntrack *ct,
26 enum ip_conntrack_info conntrackinfo);
27};
28
29extern int ip_conntrack_helper_register(struct ip_conntrack_helper *);
30extern void ip_conntrack_helper_unregister(struct ip_conntrack_helper *);
31
32/* Allocate space for an expectation: this is mandatory before calling
33 ip_conntrack_expect_related. */
34extern struct ip_conntrack_expect *ip_conntrack_expect_alloc(void);
35extern void ip_conntrack_expect_free(struct ip_conntrack_expect *exp);
36
37/* Add an expected connection: can have more than one per connection */
38extern int ip_conntrack_expect_related(struct ip_conntrack_expect *exp);
39extern void ip_conntrack_unexpect_related(struct ip_conntrack_expect *exp);
40
41#endif /*_IP_CONNTRACK_HELPER_H*/
diff --git a/include/linux/netfilter_ipv4/ip_conntrack_icmp.h b/include/linux/netfilter_ipv4/ip_conntrack_icmp.h
new file mode 100644
index 000000000000..f1664abbe392
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ip_conntrack_icmp.h
@@ -0,0 +1,11 @@
1#ifndef _IP_CONNTRACK_ICMP_H
2#define _IP_CONNTRACK_ICMP_H
3/* ICMP tracking. */
4#include <asm/atomic.h>
5
6struct ip_ct_icmp
7{
8 /* Optimization: when number in == number out, forget immediately. */
9 atomic_t count;
10};
11#endif /* _IP_CONNTRACK_ICMP_H */
diff --git a/include/linux/netfilter_ipv4/ip_conntrack_irc.h b/include/linux/netfilter_ipv4/ip_conntrack_irc.h
new file mode 100644
index 000000000000..16601e0d5626
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ip_conntrack_irc.h
@@ -0,0 +1,32 @@
1/* IRC extension for IP connection tracking.
2 * (C) 2000 by Harald Welte <laforge@gnumonks.org>
3 * based on RR's ip_conntrack_ftp.h
4 *
5 * ip_conntrack_irc.h,v 1.6 2000/11/07 18:26:42 laforge Exp
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 */
14#ifndef _IP_CONNTRACK_IRC_H
15#define _IP_CONNTRACK_IRC_H
16
17/* This structure exists only once per master */
18struct ip_ct_irc_master {
19};
20
21#ifdef __KERNEL__
22extern unsigned int (*ip_nat_irc_hook)(struct sk_buff **pskb,
23 enum ip_conntrack_info ctinfo,
24 unsigned int matchoff,
25 unsigned int matchlen,
26 struct ip_conntrack_expect *exp);
27
28#define IRC_PORT 6667
29
30#endif /* __KERNEL__ */
31
32#endif /* _IP_CONNTRACK_IRC_H */
diff --git a/include/linux/netfilter_ipv4/ip_conntrack_protocol.h b/include/linux/netfilter_ipv4/ip_conntrack_protocol.h
new file mode 100644
index 000000000000..e20b57c5e1b7
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ip_conntrack_protocol.h
@@ -0,0 +1,89 @@
1/* Header for use in defining a given protocol for connection tracking. */
2#ifndef _IP_CONNTRACK_PROTOCOL_H
3#define _IP_CONNTRACK_PROTOCOL_H
4#include <linux/netfilter_ipv4/ip_conntrack.h>
5
6struct seq_file;
7
8struct ip_conntrack_protocol
9{
10 /* Protocol number. */
11 u_int8_t proto;
12
13 /* Protocol name */
14 const char *name;
15
16 /* Try to fill in the third arg: dataoff is offset past IP
17 hdr. Return true if possible. */
18 int (*pkt_to_tuple)(const struct sk_buff *skb,
19 unsigned int dataoff,
20 struct ip_conntrack_tuple *tuple);
21
22 /* Invert the per-proto part of the tuple: ie. turn xmit into reply.
23 * Some packets can't be inverted: return 0 in that case.
24 */
25 int (*invert_tuple)(struct ip_conntrack_tuple *inverse,
26 const struct ip_conntrack_tuple *orig);
27
28 /* Print out the per-protocol part of the tuple. Return like seq_* */
29 int (*print_tuple)(struct seq_file *,
30 const struct ip_conntrack_tuple *);
31
32 /* Print out the private part of the conntrack. */
33 int (*print_conntrack)(struct seq_file *, const struct ip_conntrack *);
34
35 /* Returns verdict for packet, or -1 for invalid. */
36 int (*packet)(struct ip_conntrack *conntrack,
37 const struct sk_buff *skb,
38 enum ip_conntrack_info ctinfo);
39
40 /* Called when a new connection for this protocol found;
41 * returns TRUE if it's OK. If so, packet() called next. */
42 int (*new)(struct ip_conntrack *conntrack, const struct sk_buff *skb);
43
44 /* Called when a conntrack entry is destroyed */
45 void (*destroy)(struct ip_conntrack *conntrack);
46
47 int (*error)(struct sk_buff *skb, enum ip_conntrack_info *ctinfo,
48 unsigned int hooknum);
49
50 /* Module (if any) which this is connected to. */
51 struct module *me;
52};
53
54#define MAX_IP_CT_PROTO 256
55extern struct ip_conntrack_protocol *ip_ct_protos[MAX_IP_CT_PROTO];
56
57/* Protocol registration. */
58extern int ip_conntrack_protocol_register(struct ip_conntrack_protocol *proto);
59extern void ip_conntrack_protocol_unregister(struct ip_conntrack_protocol *proto);
60
61static inline struct ip_conntrack_protocol *ip_ct_find_proto(u_int8_t protocol)
62{
63 return ip_ct_protos[protocol];
64}
65
66/* Existing built-in protocols */
67extern struct ip_conntrack_protocol ip_conntrack_protocol_tcp;
68extern struct ip_conntrack_protocol ip_conntrack_protocol_udp;
69extern struct ip_conntrack_protocol ip_conntrack_protocol_icmp;
70extern struct ip_conntrack_protocol ip_conntrack_generic_protocol;
71extern int ip_conntrack_protocol_tcp_init(void);
72
73/* Log invalid packets */
74extern unsigned int ip_ct_log_invalid;
75
76#ifdef CONFIG_SYSCTL
77#ifdef DEBUG_INVALID_PACKETS
78#define LOG_INVALID(proto) \
79 (ip_ct_log_invalid == (proto) || ip_ct_log_invalid == IPPROTO_RAW)
80#else
81#define LOG_INVALID(proto) \
82 ((ip_ct_log_invalid == (proto) || ip_ct_log_invalid == IPPROTO_RAW) \
83 && net_ratelimit())
84#endif
85#else
86#define LOG_INVALID(proto) 0
87#endif /* CONFIG_SYSCTL */
88
89#endif /*_IP_CONNTRACK_PROTOCOL_H*/
diff --git a/include/linux/netfilter_ipv4/ip_conntrack_sctp.h b/include/linux/netfilter_ipv4/ip_conntrack_sctp.h
new file mode 100644
index 000000000000..7a8d869321f7
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ip_conntrack_sctp.h
@@ -0,0 +1,25 @@
1#ifndef _IP_CONNTRACK_SCTP_H
2#define _IP_CONNTRACK_SCTP_H
3/* SCTP tracking. */
4
5enum sctp_conntrack {
6 SCTP_CONNTRACK_NONE,
7 SCTP_CONNTRACK_CLOSED,
8 SCTP_CONNTRACK_COOKIE_WAIT,
9 SCTP_CONNTRACK_COOKIE_ECHOED,
10 SCTP_CONNTRACK_ESTABLISHED,
11 SCTP_CONNTRACK_SHUTDOWN_SENT,
12 SCTP_CONNTRACK_SHUTDOWN_RECD,
13 SCTP_CONNTRACK_SHUTDOWN_ACK_SENT,
14 SCTP_CONNTRACK_MAX
15};
16
17struct ip_ct_sctp
18{
19 enum sctp_conntrack state;
20
21 u_int32_t vtag[IP_CT_DIR_MAX];
22 u_int32_t ttag[IP_CT_DIR_MAX];
23};
24
25#endif /* _IP_CONNTRACK_SCTP_H */
diff --git a/include/linux/netfilter_ipv4/ip_conntrack_tcp.h b/include/linux/netfilter_ipv4/ip_conntrack_tcp.h
new file mode 100644
index 000000000000..16da044d97a7
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ip_conntrack_tcp.h
@@ -0,0 +1,51 @@
1#ifndef _IP_CONNTRACK_TCP_H
2#define _IP_CONNTRACK_TCP_H
3/* TCP tracking. */
4
5enum tcp_conntrack {
6 TCP_CONNTRACK_NONE,
7 TCP_CONNTRACK_SYN_SENT,
8 TCP_CONNTRACK_SYN_RECV,
9 TCP_CONNTRACK_ESTABLISHED,
10 TCP_CONNTRACK_FIN_WAIT,
11 TCP_CONNTRACK_CLOSE_WAIT,
12 TCP_CONNTRACK_LAST_ACK,
13 TCP_CONNTRACK_TIME_WAIT,
14 TCP_CONNTRACK_CLOSE,
15 TCP_CONNTRACK_LISTEN,
16 TCP_CONNTRACK_MAX,
17 TCP_CONNTRACK_IGNORE
18};
19
20/* Window scaling is advertised by the sender */
21#define IP_CT_TCP_FLAG_WINDOW_SCALE 0x01
22
23/* SACK is permitted by the sender */
24#define IP_CT_TCP_FLAG_SACK_PERM 0x02
25
26/* This sender sent FIN first */
27#define IP_CT_TCP_FLAG_CLOSE_INIT 0x03
28
29struct ip_ct_tcp_state {
30 u_int32_t td_end; /* max of seq + len */
31 u_int32_t td_maxend; /* max of ack + max(win, 1) */
32 u_int32_t td_maxwin; /* max(win) */
33 u_int8_t td_scale; /* window scale factor */
34 u_int8_t loose; /* used when connection picked up from the middle */
35 u_int8_t flags; /* per direction options */
36};
37
38struct ip_ct_tcp
39{
40 struct ip_ct_tcp_state seen[2]; /* connection parameters per direction */
41 u_int8_t state; /* state of the connection (enum tcp_conntrack) */
42 /* For detecting stale connections */
43 u_int8_t last_dir; /* Direction of the last packet (enum ip_conntrack_dir) */
44 u_int8_t retrans; /* Number of retransmitted packets */
45 u_int8_t last_index; /* Index of the last packet */
46 u_int32_t last_seq; /* Last sequence number seen in dir */
47 u_int32_t last_ack; /* Last sequence number seen in opposite dir */
48 u_int32_t last_end; /* Last seq + len */
49};
50
51#endif /* _IP_CONNTRACK_TCP_H */
diff --git a/include/linux/netfilter_ipv4/ip_conntrack_tftp.h b/include/linux/netfilter_ipv4/ip_conntrack_tftp.h
new file mode 100644
index 000000000000..cde9729aa173
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ip_conntrack_tftp.h
@@ -0,0 +1,20 @@
1#ifndef _IP_CT_TFTP
2#define _IP_CT_TFTP
3
4#define TFTP_PORT 69
5
6struct tftphdr {
7 u_int16_t opcode;
8};
9
10#define TFTP_OPCODE_READ 1
11#define TFTP_OPCODE_WRITE 2
12#define TFTP_OPCODE_DATA 3
13#define TFTP_OPCODE_ACK 4
14#define TFTP_OPCODE_ERROR 5
15
16extern unsigned int (*ip_nat_tftp_hook)(struct sk_buff **pskb,
17 enum ip_conntrack_info ctinfo,
18 struct ip_conntrack_expect *exp);
19
20#endif /* _IP_CT_TFTP */
diff --git a/include/linux/netfilter_ipv4/ip_conntrack_tuple.h b/include/linux/netfilter_ipv4/ip_conntrack_tuple.h
new file mode 100644
index 000000000000..c33f0b5e0d0a
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ip_conntrack_tuple.h
@@ -0,0 +1,145 @@
1#ifndef _IP_CONNTRACK_TUPLE_H
2#define _IP_CONNTRACK_TUPLE_H
3
4/* A `tuple' is a structure containing the information to uniquely
5 identify a connection. ie. if two packets have the same tuple, they
6 are in the same connection; if not, they are not.
7
8 We divide the structure along "manipulatable" and
9 "non-manipulatable" lines, for the benefit of the NAT code.
10*/
11
12/* The protocol-specific manipulable parts of the tuple: always in
13 network order! */
14union ip_conntrack_manip_proto
15{
16 /* Add other protocols here. */
17 u_int16_t all;
18
19 struct {
20 u_int16_t port;
21 } tcp;
22 struct {
23 u_int16_t port;
24 } udp;
25 struct {
26 u_int16_t id;
27 } icmp;
28 struct {
29 u_int16_t port;
30 } sctp;
31};
32
33/* The manipulable part of the tuple. */
34struct ip_conntrack_manip
35{
36 u_int32_t ip;
37 union ip_conntrack_manip_proto u;
38};
39
40/* This contains the information to distinguish a connection. */
41struct ip_conntrack_tuple
42{
43 struct ip_conntrack_manip src;
44
45 /* These are the parts of the tuple which are fixed. */
46 struct {
47 u_int32_t ip;
48 union {
49 /* Add other protocols here. */
50 u_int16_t all;
51
52 struct {
53 u_int16_t port;
54 } tcp;
55 struct {
56 u_int16_t port;
57 } udp;
58 struct {
59 u_int8_t type, code;
60 } icmp;
61 struct {
62 u_int16_t port;
63 } sctp;
64 } u;
65
66 /* The protocol. */
67 u_int8_t protonum;
68
69 /* The direction (for tuplehash) */
70 u_int8_t dir;
71 } dst;
72};
73
74/* This is optimized opposed to a memset of the whole structure. Everything we
75 * really care about is the source/destination unions */
76#define IP_CT_TUPLE_U_BLANK(tuple) \
77 do { \
78 (tuple)->src.u.all = 0; \
79 (tuple)->dst.u.all = 0; \
80 } while (0)
81
82enum ip_conntrack_dir
83{
84 IP_CT_DIR_ORIGINAL,
85 IP_CT_DIR_REPLY,
86 IP_CT_DIR_MAX
87};
88
89#ifdef __KERNEL__
90
91#define DUMP_TUPLE(tp) \
92DEBUGP("tuple %p: %u %u.%u.%u.%u:%hu -> %u.%u.%u.%u:%hu\n", \
93 (tp), (tp)->dst.protonum, \
94 NIPQUAD((tp)->src.ip), ntohs((tp)->src.u.all), \
95 NIPQUAD((tp)->dst.ip), ntohs((tp)->dst.u.all))
96
97#define CTINFO2DIR(ctinfo) ((ctinfo) >= IP_CT_IS_REPLY ? IP_CT_DIR_REPLY : IP_CT_DIR_ORIGINAL)
98
99/* If we're the first tuple, it's the original dir. */
100#define DIRECTION(h) ((enum ip_conntrack_dir)(h)->tuple.dst.dir)
101
102/* Connections have two entries in the hash table: one for each way */
103struct ip_conntrack_tuple_hash
104{
105 struct list_head list;
106
107 struct ip_conntrack_tuple tuple;
108};
109
110#endif /* __KERNEL__ */
111
112static inline int ip_ct_tuple_src_equal(const struct ip_conntrack_tuple *t1,
113 const struct ip_conntrack_tuple *t2)
114{
115 return t1->src.ip == t2->src.ip
116 && t1->src.u.all == t2->src.u.all;
117}
118
119static inline int ip_ct_tuple_dst_equal(const struct ip_conntrack_tuple *t1,
120 const struct ip_conntrack_tuple *t2)
121{
122 return t1->dst.ip == t2->dst.ip
123 && t1->dst.u.all == t2->dst.u.all
124 && t1->dst.protonum == t2->dst.protonum;
125}
126
127static inline int ip_ct_tuple_equal(const struct ip_conntrack_tuple *t1,
128 const struct ip_conntrack_tuple *t2)
129{
130 return ip_ct_tuple_src_equal(t1, t2) && ip_ct_tuple_dst_equal(t1, t2);
131}
132
133static inline int ip_ct_tuple_mask_cmp(const struct ip_conntrack_tuple *t,
134 const struct ip_conntrack_tuple *tuple,
135 const struct ip_conntrack_tuple *mask)
136{
137 return !(((t->src.ip ^ tuple->src.ip) & mask->src.ip)
138 || ((t->dst.ip ^ tuple->dst.ip) & mask->dst.ip)
139 || ((t->src.u.all ^ tuple->src.u.all) & mask->src.u.all)
140 || ((t->dst.u.all ^ tuple->dst.u.all) & mask->dst.u.all)
141 || ((t->dst.protonum ^ tuple->dst.protonum)
142 & mask->dst.protonum));
143}
144
145#endif /* _IP_CONNTRACK_TUPLE_H */
diff --git a/include/linux/netfilter_ipv4/ip_logging.h b/include/linux/netfilter_ipv4/ip_logging.h
new file mode 100644
index 000000000000..0c5c52cb6589
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ip_logging.h
@@ -0,0 +1,20 @@
1/* IPv4 macros for the internal logging interface. */
2#ifndef __IP_LOGGING_H
3#define __IP_LOGGING_H
4
5#ifdef __KERNEL__
6#include <linux/socket.h>
7#include <linux/netfilter_logging.h>
8
9#define nf_log_ip_packet(pskb,hooknum,in,out,fmt,args...) \
10 nf_log_packet(AF_INET,pskb,hooknum,in,out,fmt,##args)
11
12#define nf_log_ip(pfh,len,fmt,args...) \
13 nf_log(AF_INET,pfh,len,fmt,##args)
14
15#define nf_ip_log_register(logging) nf_log_register(AF_INET,logging)
16#define nf_ip_log_unregister(logging) nf_log_unregister(AF_INET,logging)
17
18#endif /*__KERNEL__*/
19
20#endif /*__IP_LOGGING_H*/
diff --git a/include/linux/netfilter_ipv4/ip_nat.h b/include/linux/netfilter_ipv4/ip_nat.h
new file mode 100644
index 000000000000..2b72b86176f0
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ip_nat.h
@@ -0,0 +1,87 @@
1#ifndef _IP_NAT_H
2#define _IP_NAT_H
3#include <linux/netfilter_ipv4.h>
4#include <linux/netfilter_ipv4/ip_conntrack_tuple.h>
5
6#define IP_NAT_MAPPING_TYPE_MAX_NAMELEN 16
7
8enum ip_nat_manip_type
9{
10 IP_NAT_MANIP_SRC,
11 IP_NAT_MANIP_DST
12};
13
14/* SRC manip occurs POST_ROUTING or LOCAL_IN */
15#define HOOK2MANIP(hooknum) ((hooknum) != NF_IP_POST_ROUTING && (hooknum) != NF_IP_LOCAL_IN)
16
17#define IP_NAT_RANGE_MAP_IPS 1
18#define IP_NAT_RANGE_PROTO_SPECIFIED 2
19
20/* NAT sequence number modifications */
21struct ip_nat_seq {
22 /* position of the last TCP sequence number
23 * modification (if any) */
24 u_int32_t correction_pos;
25 /* sequence number offset before and after last modification */
26 int32_t offset_before, offset_after;
27};
28
29/* Single range specification. */
30struct ip_nat_range
31{
32 /* Set to OR of flags above. */
33 unsigned int flags;
34
35 /* Inclusive: network order. */
36 u_int32_t min_ip, max_ip;
37
38 /* Inclusive: network order */
39 union ip_conntrack_manip_proto min, max;
40};
41
42/* For backwards compat: don't use in modern code. */
43struct ip_nat_multi_range_compat
44{
45 unsigned int rangesize; /* Must be 1. */
46
47 /* hangs off end. */
48 struct ip_nat_range range[1];
49};
50
51#ifdef __KERNEL__
52#include <linux/list.h>
53#include <linux/netfilter_ipv4/lockhelp.h>
54
55/* Protects NAT hash tables, and NAT-private part of conntracks. */
56DECLARE_RWLOCK_EXTERN(ip_nat_lock);
57
58/* The structure embedded in the conntrack structure. */
59struct ip_nat_info
60{
61 struct list_head bysource;
62
63 /* Helper (NULL if none). */
64 struct ip_nat_helper *helper;
65
66 struct ip_nat_seq seq[IP_CT_DIR_MAX];
67};
68
69struct ip_conntrack;
70
71/* Set up the info structure to map into this range. */
72extern unsigned int ip_nat_setup_info(struct ip_conntrack *conntrack,
73 const struct ip_nat_range *range,
74 unsigned int hooknum);
75
76/* Is this tuple already taken? (not by us)*/
77extern int ip_nat_used_tuple(const struct ip_conntrack_tuple *tuple,
78 const struct ip_conntrack *ignored_conntrack);
79
80/* Calculate relative checksum. */
81extern u_int16_t ip_nat_cheat_check(u_int32_t oldvalinv,
82 u_int32_t newval,
83 u_int16_t oldcheck);
84#else /* !__KERNEL__: iptables wants this to compile. */
85#define ip_nat_multi_range ip_nat_multi_range_compat
86#endif /*__KERNEL__*/
87#endif
diff --git a/include/linux/netfilter_ipv4/ip_nat_core.h b/include/linux/netfilter_ipv4/ip_nat_core.h
new file mode 100644
index 000000000000..3b50eb91f007
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ip_nat_core.h
@@ -0,0 +1,20 @@
1#ifndef _IP_NAT_CORE_H
2#define _IP_NAT_CORE_H
3#include <linux/list.h>
4#include <linux/netfilter_ipv4/ip_conntrack.h>
5
6/* This header used to share core functionality between the standalone
7 NAT module, and the compatibility layer's use of NAT for masquerading. */
8extern int ip_nat_init(void);
9extern void ip_nat_cleanup(void);
10
11extern unsigned int nat_packet(struct ip_conntrack *ct,
12 enum ip_conntrack_info conntrackinfo,
13 unsigned int hooknum,
14 struct sk_buff **pskb);
15
16extern int icmp_reply_translation(struct sk_buff **pskb,
17 struct ip_conntrack *ct,
18 enum ip_nat_manip_type manip,
19 enum ip_conntrack_dir dir);
20#endif /* _IP_NAT_CORE_H */
diff --git a/include/linux/netfilter_ipv4/ip_nat_helper.h b/include/linux/netfilter_ipv4/ip_nat_helper.h
new file mode 100644
index 000000000000..bf9cb105c885
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ip_nat_helper.h
@@ -0,0 +1,33 @@
1#ifndef _IP_NAT_HELPER_H
2#define _IP_NAT_HELPER_H
3/* NAT protocol helper routines. */
4
5#include <linux/netfilter_ipv4/ip_conntrack.h>
6#include <linux/module.h>
7
8struct sk_buff;
9
10/* These return true or false. */
11extern int ip_nat_mangle_tcp_packet(struct sk_buff **skb,
12 struct ip_conntrack *ct,
13 enum ip_conntrack_info ctinfo,
14 unsigned int match_offset,
15 unsigned int match_len,
16 const char *rep_buffer,
17 unsigned int rep_len);
18extern int ip_nat_mangle_udp_packet(struct sk_buff **skb,
19 struct ip_conntrack *ct,
20 enum ip_conntrack_info ctinfo,
21 unsigned int match_offset,
22 unsigned int match_len,
23 const char *rep_buffer,
24 unsigned int rep_len);
25extern int ip_nat_seq_adjust(struct sk_buff **pskb,
26 struct ip_conntrack *ct,
27 enum ip_conntrack_info ctinfo);
28
29/* Setup NAT on this expected conntrack so it follows master, but goes
30 * to port ct->master->saved_proto. */
31extern void ip_nat_follow_master(struct ip_conntrack *ct,
32 struct ip_conntrack_expect *this);
33#endif
diff --git a/include/linux/netfilter_ipv4/ip_nat_protocol.h b/include/linux/netfilter_ipv4/ip_nat_protocol.h
new file mode 100644
index 000000000000..129708c22386
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ip_nat_protocol.h
@@ -0,0 +1,70 @@
1/* Header for use in defining a given protocol. */
2#ifndef _IP_NAT_PROTOCOL_H
3#define _IP_NAT_PROTOCOL_H
4#include <linux/init.h>
5#include <linux/list.h>
6
7struct iphdr;
8struct ip_nat_range;
9
10struct ip_nat_protocol
11{
12 /* Protocol name */
13 const char *name;
14
15 /* Protocol number. */
16 unsigned int protonum;
17
18 /* Translate a packet to the target according to manip type.
19 Return true if succeeded. */
20 int (*manip_pkt)(struct sk_buff **pskb,
21 unsigned int iphdroff,
22 const struct ip_conntrack_tuple *tuple,
23 enum ip_nat_manip_type maniptype);
24
25 /* Is the manipable part of the tuple between min and max incl? */
26 int (*in_range)(const struct ip_conntrack_tuple *tuple,
27 enum ip_nat_manip_type maniptype,
28 const union ip_conntrack_manip_proto *min,
29 const union ip_conntrack_manip_proto *max);
30
31 /* Alter the per-proto part of the tuple (depending on
32 maniptype), to give a unique tuple in the given range if
33 possible; return false if not. Per-protocol part of tuple
34 is initialized to the incoming packet. */
35 int (*unique_tuple)(struct ip_conntrack_tuple *tuple,
36 const struct ip_nat_range *range,
37 enum ip_nat_manip_type maniptype,
38 const struct ip_conntrack *conntrack);
39
40 unsigned int (*print)(char *buffer,
41 const struct ip_conntrack_tuple *match,
42 const struct ip_conntrack_tuple *mask);
43
44 unsigned int (*print_range)(char *buffer,
45 const struct ip_nat_range *range);
46};
47
48#define MAX_IP_NAT_PROTO 256
49extern struct ip_nat_protocol *ip_nat_protos[MAX_IP_NAT_PROTO];
50
51/* Protocol registration. */
52extern int ip_nat_protocol_register(struct ip_nat_protocol *proto);
53extern void ip_nat_protocol_unregister(struct ip_nat_protocol *proto);
54
55static inline struct ip_nat_protocol *ip_nat_find_proto(u_int8_t protocol)
56{
57 return ip_nat_protos[protocol];
58}
59
60/* Built-in protocols. */
61extern struct ip_nat_protocol ip_nat_protocol_tcp;
62extern struct ip_nat_protocol ip_nat_protocol_udp;
63extern struct ip_nat_protocol ip_nat_protocol_icmp;
64extern struct ip_nat_protocol ip_nat_unknown_protocol;
65
66extern int init_protocols(void) __init;
67extern void cleanup_protocols(void);
68extern struct ip_nat_protocol *find_nat_proto(u_int16_t protonum);
69
70#endif /*_IP_NAT_PROTO_H*/
diff --git a/include/linux/netfilter_ipv4/ip_nat_rule.h b/include/linux/netfilter_ipv4/ip_nat_rule.h
new file mode 100644
index 000000000000..fecd2a06dcd8
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ip_nat_rule.h
@@ -0,0 +1,23 @@
1#ifndef _IP_NAT_RULE_H
2#define _IP_NAT_RULE_H
3#include <linux/netfilter_ipv4/ip_conntrack.h>
4#include <linux/netfilter_ipv4/ip_tables.h>
5#include <linux/netfilter_ipv4/ip_nat.h>
6
7#ifdef __KERNEL__
8
9extern int ip_nat_rule_init(void) __init;
10extern void ip_nat_rule_cleanup(void);
11extern int ip_nat_rule_find(struct sk_buff **pskb,
12 unsigned int hooknum,
13 const struct net_device *in,
14 const struct net_device *out,
15 struct ip_conntrack *ct,
16 struct ip_nat_info *info);
17
18extern unsigned int
19alloc_null_binding(struct ip_conntrack *conntrack,
20 struct ip_nat_info *info,
21 unsigned int hooknum);
22#endif
23#endif /* _IP_NAT_RULE_H */
diff --git a/include/linux/netfilter_ipv4/ip_queue.h b/include/linux/netfilter_ipv4/ip_queue.h
new file mode 100644
index 000000000000..aa08d68c4841
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ip_queue.h
@@ -0,0 +1,72 @@
1/*
2 * This is a module which is used for queueing IPv4 packets and
3 * communicating with userspace via netlink.
4 *
5 * (C) 2000 James Morris, this code is GPL.
6 */
7#ifndef _IP_QUEUE_H
8#define _IP_QUEUE_H
9
10#ifdef __KERNEL__
11#ifdef DEBUG_IPQ
12#define QDEBUG(x...) printk(KERN_DEBUG ## x)
13#else
14#define QDEBUG(x...)
15#endif /* DEBUG_IPQ */
16#else
17#include <net/if.h>
18#endif /* ! __KERNEL__ */
19
20/* Messages sent from kernel */
21typedef struct ipq_packet_msg {
22 unsigned long packet_id; /* ID of queued packet */
23 unsigned long mark; /* Netfilter mark value */
24 long timestamp_sec; /* Packet arrival time (seconds) */
25 long timestamp_usec; /* Packet arrvial time (+useconds) */
26 unsigned int hook; /* Netfilter hook we rode in on */
27 char indev_name[IFNAMSIZ]; /* Name of incoming interface */
28 char outdev_name[IFNAMSIZ]; /* Name of outgoing interface */
29 unsigned short hw_protocol; /* Hardware protocol (network order) */
30 unsigned short hw_type; /* Hardware type */
31 unsigned char hw_addrlen; /* Hardware address length */
32 unsigned char hw_addr[8]; /* Hardware address */
33 size_t data_len; /* Length of packet data */
34 unsigned char payload[0]; /* Optional packet data */
35} ipq_packet_msg_t;
36
37/* Messages sent from userspace */
38typedef struct ipq_mode_msg {
39 unsigned char value; /* Requested mode */
40 size_t range; /* Optional range of packet requested */
41} ipq_mode_msg_t;
42
43typedef struct ipq_verdict_msg {
44 unsigned int value; /* Verdict to hand to netfilter */
45 unsigned long id; /* Packet ID for this verdict */
46 size_t data_len; /* Length of replacement data */
47 unsigned char payload[0]; /* Optional replacement packet */
48} ipq_verdict_msg_t;
49
50typedef struct ipq_peer_msg {
51 union {
52 ipq_verdict_msg_t verdict;
53 ipq_mode_msg_t mode;
54 } msg;
55} ipq_peer_msg_t;
56
57/* Packet delivery modes */
58enum {
59 IPQ_COPY_NONE, /* Initial mode, packets are dropped */
60 IPQ_COPY_META, /* Copy metadata */
61 IPQ_COPY_PACKET /* Copy metadata + packet (range) */
62};
63#define IPQ_COPY_MAX IPQ_COPY_PACKET
64
65/* Types of messages */
66#define IPQM_BASE 0x10 /* standard netlink messages below this */
67#define IPQM_MODE (IPQM_BASE + 1) /* Mode request from peer */
68#define IPQM_VERDICT (IPQM_BASE + 2) /* Verdict from peer */
69#define IPQM_PACKET (IPQM_BASE + 3) /* Packet from kernel */
70#define IPQM_MAX (IPQM_BASE + 4)
71
72#endif /*_IP_QUEUE_H*/
diff --git a/include/linux/netfilter_ipv4/ip_tables.h b/include/linux/netfilter_ipv4/ip_tables.h
new file mode 100644
index 000000000000..12ce47808e7d
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ip_tables.h
@@ -0,0 +1,490 @@
1/*
2 * 25-Jul-1998 Major changes to allow for ip chain table
3 *
4 * 3-Jan-2000 Named tables to allow packet selection for different uses.
5 */
6
7/*
8 * Format of an IP firewall descriptor
9 *
10 * src, dst, src_mask, dst_mask are always stored in network byte order.
11 * flags are stored in host byte order (of course).
12 * Port numbers are stored in HOST byte order.
13 */
14
15#ifndef _IPTABLES_H
16#define _IPTABLES_H
17
18#ifdef __KERNEL__
19#include <linux/if.h>
20#include <linux/types.h>
21#include <linux/in.h>
22#include <linux/ip.h>
23#include <linux/skbuff.h>
24#endif
25#include <linux/compiler.h>
26#include <linux/netfilter_ipv4.h>
27
28#define IPT_FUNCTION_MAXNAMELEN 30
29#define IPT_TABLE_MAXNAMELEN 32
30
31/* Yes, Virginia, you have to zero the padding. */
32struct ipt_ip {
33 /* Source and destination IP addr */
34 struct in_addr src, dst;
35 /* Mask for src and dest IP addr */
36 struct in_addr smsk, dmsk;
37 char iniface[IFNAMSIZ], outiface[IFNAMSIZ];
38 unsigned char iniface_mask[IFNAMSIZ], outiface_mask[IFNAMSIZ];
39
40 /* Protocol, 0 = ANY */
41 u_int16_t proto;
42
43 /* Flags word */
44 u_int8_t flags;
45 /* Inverse flags */
46 u_int8_t invflags;
47};
48
49struct ipt_entry_match
50{
51 union {
52 struct {
53 u_int16_t match_size;
54
55 /* Used by userspace */
56 char name[IPT_FUNCTION_MAXNAMELEN-1];
57
58 u_int8_t revision;
59 } user;
60 struct {
61 u_int16_t match_size;
62
63 /* Used inside the kernel */
64 struct ipt_match *match;
65 } kernel;
66
67 /* Total length */
68 u_int16_t match_size;
69 } u;
70
71 unsigned char data[0];
72};
73
74struct ipt_entry_target
75{
76 union {
77 struct {
78 u_int16_t target_size;
79
80 /* Used by userspace */
81 char name[IPT_FUNCTION_MAXNAMELEN-1];
82
83 u_int8_t revision;
84 } user;
85 struct {
86 u_int16_t target_size;
87
88 /* Used inside the kernel */
89 struct ipt_target *target;
90 } kernel;
91
92 /* Total length */
93 u_int16_t target_size;
94 } u;
95
96 unsigned char data[0];
97};
98
99struct ipt_standard_target
100{
101 struct ipt_entry_target target;
102 int verdict;
103};
104
105struct ipt_counters
106{
107 u_int64_t pcnt, bcnt; /* Packet and byte counters */
108};
109
110/* Values for "flag" field in struct ipt_ip (general ip structure). */
111#define IPT_F_FRAG 0x01 /* Set if rule is a fragment rule */
112#define IPT_F_MASK 0x01 /* All possible flag bits mask. */
113
114/* Values for "inv" field in struct ipt_ip. */
115#define IPT_INV_VIA_IN 0x01 /* Invert the sense of IN IFACE. */
116#define IPT_INV_VIA_OUT 0x02 /* Invert the sense of OUT IFACE */
117#define IPT_INV_TOS 0x04 /* Invert the sense of TOS. */
118#define IPT_INV_SRCIP 0x08 /* Invert the sense of SRC IP. */
119#define IPT_INV_DSTIP 0x10 /* Invert the sense of DST OP. */
120#define IPT_INV_FRAG 0x20 /* Invert the sense of FRAG. */
121#define IPT_INV_PROTO 0x40 /* Invert the sense of PROTO. */
122#define IPT_INV_MASK 0x7F /* All possible flag bits mask. */
123
124/* This structure defines each of the firewall rules. Consists of 3
125 parts which are 1) general IP header stuff 2) match specific
126 stuff 3) the target to perform if the rule matches */
127struct ipt_entry
128{
129 struct ipt_ip ip;
130
131 /* Mark with fields that we care about. */
132 unsigned int nfcache;
133
134 /* Size of ipt_entry + matches */
135 u_int16_t target_offset;
136 /* Size of ipt_entry + matches + target */
137 u_int16_t next_offset;
138
139 /* Back pointer */
140 unsigned int comefrom;
141
142 /* Packet and byte counters. */
143 struct ipt_counters counters;
144
145 /* The matches (if any), then the target. */
146 unsigned char elems[0];
147};
148
149/*
150 * New IP firewall options for [gs]etsockopt at the RAW IP level.
151 * Unlike BSD Linux inherits IP options so you don't have to use a raw
152 * socket for this. Instead we check rights in the calls. */
153#define IPT_BASE_CTL 64 /* base for firewall socket options */
154
155#define IPT_SO_SET_REPLACE (IPT_BASE_CTL)
156#define IPT_SO_SET_ADD_COUNTERS (IPT_BASE_CTL + 1)
157#define IPT_SO_SET_MAX IPT_SO_SET_ADD_COUNTERS
158
159#define IPT_SO_GET_INFO (IPT_BASE_CTL)
160#define IPT_SO_GET_ENTRIES (IPT_BASE_CTL + 1)
161#define IPT_SO_GET_REVISION_MATCH (IPT_BASE_CTL + 2)
162#define IPT_SO_GET_REVISION_TARGET (IPT_BASE_CTL + 3)
163#define IPT_SO_GET_MAX IPT_SO_GET_REVISION_TARGET
164
165/* CONTINUE verdict for targets */
166#define IPT_CONTINUE 0xFFFFFFFF
167
168/* For standard target */
169#define IPT_RETURN (-NF_REPEAT - 1)
170
171/* TCP matching stuff */
172struct ipt_tcp
173{
174 u_int16_t spts[2]; /* Source port range. */
175 u_int16_t dpts[2]; /* Destination port range. */
176 u_int8_t option; /* TCP Option iff non-zero*/
177 u_int8_t flg_mask; /* TCP flags mask byte */
178 u_int8_t flg_cmp; /* TCP flags compare byte */
179 u_int8_t invflags; /* Inverse flags */
180};
181
182/* Values for "inv" field in struct ipt_tcp. */
183#define IPT_TCP_INV_SRCPT 0x01 /* Invert the sense of source ports. */
184#define IPT_TCP_INV_DSTPT 0x02 /* Invert the sense of dest ports. */
185#define IPT_TCP_INV_FLAGS 0x04 /* Invert the sense of TCP flags. */
186#define IPT_TCP_INV_OPTION 0x08 /* Invert the sense of option test. */
187#define IPT_TCP_INV_MASK 0x0F /* All possible flags. */
188
189/* UDP matching stuff */
190struct ipt_udp
191{
192 u_int16_t spts[2]; /* Source port range. */
193 u_int16_t dpts[2]; /* Destination port range. */
194 u_int8_t invflags; /* Inverse flags */
195};
196
197/* Values for "invflags" field in struct ipt_udp. */
198#define IPT_UDP_INV_SRCPT 0x01 /* Invert the sense of source ports. */
199#define IPT_UDP_INV_DSTPT 0x02 /* Invert the sense of dest ports. */
200#define IPT_UDP_INV_MASK 0x03 /* All possible flags. */
201
202/* ICMP matching stuff */
203struct ipt_icmp
204{
205 u_int8_t type; /* type to match */
206 u_int8_t code[2]; /* range of code */
207 u_int8_t invflags; /* Inverse flags */
208};
209
210/* Values for "inv" field for struct ipt_icmp. */
211#define IPT_ICMP_INV 0x01 /* Invert the sense of type/code test */
212
213/* The argument to IPT_SO_GET_INFO */
214struct ipt_getinfo
215{
216 /* Which table: caller fills this in. */
217 char name[IPT_TABLE_MAXNAMELEN];
218
219 /* Kernel fills these in. */
220 /* Which hook entry points are valid: bitmask */
221 unsigned int valid_hooks;
222
223 /* Hook entry points: one per netfilter hook. */
224 unsigned int hook_entry[NF_IP_NUMHOOKS];
225
226 /* Underflow points. */
227 unsigned int underflow[NF_IP_NUMHOOKS];
228
229 /* Number of entries */
230 unsigned int num_entries;
231
232 /* Size of entries. */
233 unsigned int size;
234};
235
236/* The argument to IPT_SO_SET_REPLACE. */
237struct ipt_replace
238{
239 /* Which table. */
240 char name[IPT_TABLE_MAXNAMELEN];
241
242 /* Which hook entry points are valid: bitmask. You can't
243 change this. */
244 unsigned int valid_hooks;
245
246 /* Number of entries */
247 unsigned int num_entries;
248
249 /* Total size of new entries */
250 unsigned int size;
251
252 /* Hook entry points. */
253 unsigned int hook_entry[NF_IP_NUMHOOKS];
254
255 /* Underflow points. */
256 unsigned int underflow[NF_IP_NUMHOOKS];
257
258 /* Information about old entries: */
259 /* Number of counters (must be equal to current number of entries). */
260 unsigned int num_counters;
261 /* The old entries' counters. */
262 struct ipt_counters __user *counters;
263
264 /* The entries (hang off end: not really an array). */
265 struct ipt_entry entries[0];
266};
267
268/* The argument to IPT_SO_ADD_COUNTERS. */
269struct ipt_counters_info
270{
271 /* Which table. */
272 char name[IPT_TABLE_MAXNAMELEN];
273
274 unsigned int num_counters;
275
276 /* The counters (actually `number' of these). */
277 struct ipt_counters counters[0];
278};
279
280/* The argument to IPT_SO_GET_ENTRIES. */
281struct ipt_get_entries
282{
283 /* Which table: user fills this in. */
284 char name[IPT_TABLE_MAXNAMELEN];
285
286 /* User fills this in: total entry size. */
287 unsigned int size;
288
289 /* The entries. */
290 struct ipt_entry entrytable[0];
291};
292
293/* The argument to IPT_SO_GET_REVISION_*. Returns highest revision
294 * kernel supports, if >= revision. */
295struct ipt_get_revision
296{
297 char name[IPT_FUNCTION_MAXNAMELEN-1];
298
299 u_int8_t revision;
300};
301
302/* Standard return verdict, or do jump. */
303#define IPT_STANDARD_TARGET ""
304/* Error verdict. */
305#define IPT_ERROR_TARGET "ERROR"
306
307/* Helper functions */
308static __inline__ struct ipt_entry_target *
309ipt_get_target(struct ipt_entry *e)
310{
311 return (void *)e + e->target_offset;
312}
313
314/* fn returns 0 to continue iteration */
315#define IPT_MATCH_ITERATE(e, fn, args...) \
316({ \
317 unsigned int __i; \
318 int __ret = 0; \
319 struct ipt_entry_match *__match; \
320 \
321 for (__i = sizeof(struct ipt_entry); \
322 __i < (e)->target_offset; \
323 __i += __match->u.match_size) { \
324 __match = (void *)(e) + __i; \
325 \
326 __ret = fn(__match , ## args); \
327 if (__ret != 0) \
328 break; \
329 } \
330 __ret; \
331})
332
333/* fn returns 0 to continue iteration */
334#define IPT_ENTRY_ITERATE(entries, size, fn, args...) \
335({ \
336 unsigned int __i; \
337 int __ret = 0; \
338 struct ipt_entry *__entry; \
339 \
340 for (__i = 0; __i < (size); __i += __entry->next_offset) { \
341 __entry = (void *)(entries) + __i; \
342 \
343 __ret = fn(__entry , ## args); \
344 if (__ret != 0) \
345 break; \
346 } \
347 __ret; \
348})
349
350/*
351 * Main firewall chains definitions and global var's definitions.
352 */
353#ifdef __KERNEL__
354
355#include <linux/init.h>
356extern void ipt_init(void) __init;
357
358struct ipt_match
359{
360 struct list_head list;
361
362 const char name[IPT_FUNCTION_MAXNAMELEN-1];
363
364 u_int8_t revision;
365
366 /* Return true or false: return FALSE and set *hotdrop = 1 to
367 force immediate packet drop. */
368 /* Arguments changed since 2.4, as this must now handle
369 non-linear skbs, using skb_copy_bits and
370 skb_ip_make_writable. */
371 int (*match)(const struct sk_buff *skb,
372 const struct net_device *in,
373 const struct net_device *out,
374 const void *matchinfo,
375 int offset,
376 int *hotdrop);
377
378 /* Called when user tries to insert an entry of this type. */
379 /* Should return true or false. */
380 int (*checkentry)(const char *tablename,
381 const struct ipt_ip *ip,
382 void *matchinfo,
383 unsigned int matchinfosize,
384 unsigned int hook_mask);
385
386 /* Called when entry of this type deleted. */
387 void (*destroy)(void *matchinfo, unsigned int matchinfosize);
388
389 /* Set this to THIS_MODULE. */
390 struct module *me;
391};
392
393/* Registration hooks for targets. */
394struct ipt_target
395{
396 struct list_head list;
397
398 const char name[IPT_FUNCTION_MAXNAMELEN-1];
399
400 u_int8_t revision;
401
402 /* Called when user tries to insert an entry of this type:
403 hook_mask is a bitmask of hooks from which it can be
404 called. */
405 /* Should return true or false. */
406 int (*checkentry)(const char *tablename,
407 const struct ipt_entry *e,
408 void *targinfo,
409 unsigned int targinfosize,
410 unsigned int hook_mask);
411
412 /* Called when entry of this type deleted. */
413 void (*destroy)(void *targinfo, unsigned int targinfosize);
414
415 /* Returns verdict. Argument order changed since 2.4, as this
416 must now handle non-linear skbs, using skb_copy_bits and
417 skb_ip_make_writable. */
418 unsigned int (*target)(struct sk_buff **pskb,
419 const struct net_device *in,
420 const struct net_device *out,
421 unsigned int hooknum,
422 const void *targinfo,
423 void *userdata);
424
425 /* Set this to THIS_MODULE. */
426 struct module *me;
427};
428
429extern int ipt_register_target(struct ipt_target *target);
430extern void ipt_unregister_target(struct ipt_target *target);
431
432extern int ipt_register_match(struct ipt_match *match);
433extern void ipt_unregister_match(struct ipt_match *match);
434
435/* Furniture shopping... */
436struct ipt_table
437{
438 struct list_head list;
439
440 /* A unique name... */
441 char name[IPT_TABLE_MAXNAMELEN];
442
443 /* What hooks you will enter on */
444 unsigned int valid_hooks;
445
446 /* Lock for the curtain */
447 rwlock_t lock;
448
449 /* Man behind the curtain... */
450 struct ipt_table_info *private;
451
452 /* Set to THIS_MODULE. */
453 struct module *me;
454};
455
456/* net/sched/ipt.c: Gimme access to your targets! Gets target->me. */
457extern struct ipt_target *ipt_find_target(const char *name, u8 revision);
458
459/* Standard entry. */
460struct ipt_standard
461{
462 struct ipt_entry entry;
463 struct ipt_standard_target target;
464};
465
466struct ipt_error_target
467{
468 struct ipt_entry_target target;
469 char errorname[IPT_FUNCTION_MAXNAMELEN];
470};
471
472struct ipt_error
473{
474 struct ipt_entry entry;
475 struct ipt_error_target target;
476};
477
478extern int ipt_register_table(struct ipt_table *table,
479 const struct ipt_replace *repl);
480extern void ipt_unregister_table(struct ipt_table *table);
481extern unsigned int ipt_do_table(struct sk_buff **pskb,
482 unsigned int hook,
483 const struct net_device *in,
484 const struct net_device *out,
485 struct ipt_table *table,
486 void *userdata);
487
488#define IPT_ALIGN(s) (((s) + (__alignof__(struct ipt_entry)-1)) & ~(__alignof__(struct ipt_entry)-1))
489#endif /*__KERNEL__*/
490#endif /* _IPTABLES_H */
diff --git a/include/linux/netfilter_ipv4/ipt_CLASSIFY.h b/include/linux/netfilter_ipv4/ipt_CLASSIFY.h
new file mode 100644
index 000000000000..7596e3dd00ca
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_CLASSIFY.h
@@ -0,0 +1,8 @@
1#ifndef _IPT_CLASSIFY_H
2#define _IPT_CLASSIFY_H
3
4struct ipt_classify_target_info {
5 u_int32_t priority;
6};
7
8#endif /*_IPT_CLASSIFY_H */
diff --git a/include/linux/netfilter_ipv4/ipt_CLUSTERIP.h b/include/linux/netfilter_ipv4/ipt_CLUSTERIP.h
new file mode 100644
index 000000000000..baa83e757156
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_CLUSTERIP.h
@@ -0,0 +1,32 @@
1#ifndef _IPT_CLUSTERIP_H_target
2#define _IPT_CLUSTERIP_H_target
3
4enum clusterip_hashmode {
5 CLUSTERIP_HASHMODE_SIP = 0,
6 CLUSTERIP_HASHMODE_SIP_SPT,
7 CLUSTERIP_HASHMODE_SIP_SPT_DPT,
8};
9
10#define CLUSTERIP_HASHMODE_MAX CLUSTERIP_HASHMODE_SIP_SPT_DPT
11
12#define CLUSTERIP_MAX_NODES 16
13
14#define CLUSTERIP_FLAG_NEW 0x00000001
15
16struct clusterip_config;
17
18struct ipt_clusterip_tgt_info {
19
20 u_int32_t flags;
21 struct clusterip_config *config;
22
23 /* only relevant for new ones */
24 u_int8_t clustermac[6];
25 u_int16_t num_total_nodes;
26 u_int16_t num_local_nodes;
27 u_int16_t local_nodes[CLUSTERIP_MAX_NODES];
28 enum clusterip_hashmode hash_mode;
29 u_int32_t hash_initval;
30};
31
32#endif /*_IPT_CLUSTERIP_H_target*/
diff --git a/include/linux/netfilter_ipv4/ipt_CONNMARK.h b/include/linux/netfilter_ipv4/ipt_CONNMARK.h
new file mode 100644
index 000000000000..d3c02536fc4c
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_CONNMARK.h
@@ -0,0 +1,25 @@
1#ifndef _IPT_CONNMARK_H_target
2#define _IPT_CONNMARK_H_target
3
4/* Copyright (C) 2002,2004 MARA Systems AB <http://www.marasystems.com>
5 * by Henrik Nordstrom <hno@marasystems.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
13enum {
14 IPT_CONNMARK_SET = 0,
15 IPT_CONNMARK_SAVE,
16 IPT_CONNMARK_RESTORE
17};
18
19struct ipt_connmark_target_info {
20 unsigned long mark;
21 unsigned long mask;
22 u_int8_t mode;
23};
24
25#endif /*_IPT_CONNMARK_H_target*/
diff --git a/include/linux/netfilter_ipv4/ipt_DSCP.h b/include/linux/netfilter_ipv4/ipt_DSCP.h
new file mode 100644
index 000000000000..b30f510b5bef
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_DSCP.h
@@ -0,0 +1,20 @@
1/* iptables module for setting the IPv4 DSCP field
2 *
3 * (C) 2002 Harald Welte <laforge@gnumonks.org>
4 * based on ipt_FTOS.c (C) 2000 by Matthew G. Marsh <mgm@paktronix.com>
5 * This software is distributed under GNU GPL v2, 1991
6 *
7 * See RFC2474 for a description of the DSCP field within the IP Header.
8 *
9 * ipt_DSCP.h,v 1.7 2002/03/14 12:03:13 laforge Exp
10*/
11#ifndef _IPT_DSCP_TARGET_H
12#define _IPT_DSCP_TARGET_H
13#include <linux/netfilter_ipv4/ipt_dscp.h>
14
15/* target info */
16struct ipt_DSCP_info {
17 u_int8_t dscp;
18};
19
20#endif /* _IPT_DSCP_TARGET_H */
diff --git a/include/linux/netfilter_ipv4/ipt_ECN.h b/include/linux/netfilter_ipv4/ipt_ECN.h
new file mode 100644
index 000000000000..94e0d9866469
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_ECN.h
@@ -0,0 +1,31 @@
1/* Header file for iptables ipt_ECN target
2 *
3 * (C) 2002 by Harald Welte <laforge@gnumonks.org>
4 *
5 * This software is distributed under GNU GPL v2, 1991
6 *
7 * ipt_ECN.h,v 1.3 2002/05/29 12:17:40 laforge Exp
8*/
9#ifndef _IPT_ECN_TARGET_H
10#define _IPT_ECN_TARGET_H
11#include <linux/netfilter_ipv4/ipt_DSCP.h>
12
13#define IPT_ECN_IP_MASK (~IPT_DSCP_MASK)
14
15#define IPT_ECN_OP_SET_IP 0x01 /* set ECN bits of IPv4 header */
16#define IPT_ECN_OP_SET_ECE 0x10 /* set ECE bit of TCP header */
17#define IPT_ECN_OP_SET_CWR 0x20 /* set CWR bit of TCP header */
18
19#define IPT_ECN_OP_MASK 0xce
20
21struct ipt_ECN_info {
22 u_int8_t operation; /* bitset of operations */
23 u_int8_t ip_ect; /* ECT codepoint of IPv4 header, pre-shifted */
24 union {
25 struct {
26 u_int8_t ece:1, cwr:1; /* TCP ECT bits */
27 } tcp;
28 } proto;
29};
30
31#endif /* _IPT_ECN_TARGET_H */
diff --git a/include/linux/netfilter_ipv4/ipt_LOG.h b/include/linux/netfilter_ipv4/ipt_LOG.h
new file mode 100644
index 000000000000..d25f782e57d1
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_LOG.h
@@ -0,0 +1,16 @@
1#ifndef _IPT_LOG_H
2#define _IPT_LOG_H
3
4#define IPT_LOG_TCPSEQ 0x01 /* Log TCP sequence numbers */
5#define IPT_LOG_TCPOPT 0x02 /* Log TCP options */
6#define IPT_LOG_IPOPT 0x04 /* Log IP options */
7#define IPT_LOG_UID 0x08 /* Log UID owning local socket */
8#define IPT_LOG_MASK 0x0f
9
10struct ipt_log_info {
11 unsigned char level;
12 unsigned char logflags;
13 char prefix[30];
14};
15
16#endif /*_IPT_LOG_H*/
diff --git a/include/linux/netfilter_ipv4/ipt_MARK.h b/include/linux/netfilter_ipv4/ipt_MARK.h
new file mode 100644
index 000000000000..f47485790ed4
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_MARK.h
@@ -0,0 +1,20 @@
1#ifndef _IPT_MARK_H_target
2#define _IPT_MARK_H_target
3
4/* Version 0 */
5struct ipt_mark_target_info {
6 unsigned long mark;
7};
8
9/* Version 1 */
10enum {
11 IPT_MARK_SET=0,
12 IPT_MARK_AND,
13 IPT_MARK_OR
14};
15
16struct ipt_mark_target_info_v1 {
17 unsigned long mark;
18 u_int8_t mode;
19};
20#endif /*_IPT_MARK_H_target*/
diff --git a/include/linux/netfilter_ipv4/ipt_REJECT.h b/include/linux/netfilter_ipv4/ipt_REJECT.h
new file mode 100644
index 000000000000..4293a1ad1b01
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_REJECT.h
@@ -0,0 +1,20 @@
1#ifndef _IPT_REJECT_H
2#define _IPT_REJECT_H
3
4enum ipt_reject_with {
5 IPT_ICMP_NET_UNREACHABLE,
6 IPT_ICMP_HOST_UNREACHABLE,
7 IPT_ICMP_PROT_UNREACHABLE,
8 IPT_ICMP_PORT_UNREACHABLE,
9 IPT_ICMP_ECHOREPLY,
10 IPT_ICMP_NET_PROHIBITED,
11 IPT_ICMP_HOST_PROHIBITED,
12 IPT_TCP_RESET,
13 IPT_ICMP_ADMIN_PROHIBITED
14};
15
16struct ipt_reject_info {
17 enum ipt_reject_with with; /* reject type */
18};
19
20#endif /*_IPT_REJECT_H*/
diff --git a/include/linux/netfilter_ipv4/ipt_SAME.h b/include/linux/netfilter_ipv4/ipt_SAME.h
new file mode 100644
index 000000000000..cc4c0b2269af
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_SAME.h
@@ -0,0 +1,19 @@
1#ifndef _IPT_SAME_H
2#define _IPT_SAME_H
3
4#define IPT_SAME_MAX_RANGE 10
5
6#define IPT_SAME_NODST 0x01
7
8struct ipt_same_info
9{
10 unsigned char info;
11 u_int32_t rangesize;
12 u_int32_t ipnum;
13 u_int32_t *iparray;
14
15 /* hangs off end. */
16 struct ip_nat_range range[IPT_SAME_MAX_RANGE];
17};
18
19#endif /*_IPT_SAME_H*/
diff --git a/include/linux/netfilter_ipv4/ipt_TCPMSS.h b/include/linux/netfilter_ipv4/ipt_TCPMSS.h
new file mode 100644
index 000000000000..aadb39580cd3
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_TCPMSS.h
@@ -0,0 +1,10 @@
1#ifndef _IPT_TCPMSS_H
2#define _IPT_TCPMSS_H
3
4struct ipt_tcpmss_info {
5 u_int16_t mss;
6};
7
8#define IPT_TCPMSS_CLAMP_PMTU 0xffff
9
10#endif /*_IPT_TCPMSS_H*/
diff --git a/include/linux/netfilter_ipv4/ipt_TOS.h b/include/linux/netfilter_ipv4/ipt_TOS.h
new file mode 100644
index 000000000000..6bf9e1fdfd88
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_TOS.h
@@ -0,0 +1,12 @@
1#ifndef _IPT_TOS_H_target
2#define _IPT_TOS_H_target
3
4#ifndef IPTOS_NORMALSVC
5#define IPTOS_NORMALSVC 0
6#endif
7
8struct ipt_tos_target_info {
9 u_int8_t tos;
10};
11
12#endif /*_IPT_TOS_H_target*/
diff --git a/include/linux/netfilter_ipv4/ipt_ULOG.h b/include/linux/netfilter_ipv4/ipt_ULOG.h
new file mode 100644
index 000000000000..417aad280bcc
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_ULOG.h
@@ -0,0 +1,49 @@
1/* Header file for IP tables userspace logging, Version 1.8
2 *
3 * (C) 2000-2002 by Harald Welte <laforge@gnumonks.org>
4 *
5 * Distributed under the terms of GNU GPL */
6
7#ifndef _IPT_ULOG_H
8#define _IPT_ULOG_H
9
10#ifndef NETLINK_NFLOG
11#define NETLINK_NFLOG 5
12#endif
13
14#define ULOG_DEFAULT_NLGROUP 1
15#define ULOG_DEFAULT_QTHRESHOLD 1
16
17#define ULOG_MAC_LEN 80
18#define ULOG_PREFIX_LEN 32
19
20#define ULOG_MAX_QLEN 50
21/* Why 50? Well... there is a limit imposed by the slab cache 131000
22 * bytes. So the multipart netlink-message has to be < 131000 bytes.
23 * Assuming a standard ethernet-mtu of 1500, we could define this up
24 * to 80... but even 50 seems to be big enough. */
25
26/* private data structure for each rule with a ULOG target */
27struct ipt_ulog_info {
28 unsigned int nl_group;
29 size_t copy_range;
30 size_t qthreshold;
31 char prefix[ULOG_PREFIX_LEN];
32};
33
34/* Format of the ULOG packets passed through netlink */
35typedef struct ulog_packet_msg {
36 unsigned long mark;
37 long timestamp_sec;
38 long timestamp_usec;
39 unsigned int hook;
40 char indev_name[IFNAMSIZ];
41 char outdev_name[IFNAMSIZ];
42 size_t data_len;
43 char prefix[ULOG_PREFIX_LEN];
44 unsigned char mac_len;
45 unsigned char mac[ULOG_MAC_LEN];
46 unsigned char payload[0];
47} ulog_packet_msg_t;
48
49#endif /*_IPT_ULOG_H*/
diff --git a/include/linux/netfilter_ipv4/ipt_addrtype.h b/include/linux/netfilter_ipv4/ipt_addrtype.h
new file mode 100644
index 000000000000..166ed01a8122
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_addrtype.h
@@ -0,0 +1,11 @@
1#ifndef _IPT_ADDRTYPE_H
2#define _IPT_ADDRTYPE_H
3
4struct ipt_addrtype_info {
5 u_int16_t source; /* source-type mask */
6 u_int16_t dest; /* dest-type mask */
7 u_int32_t invert_source;
8 u_int32_t invert_dest;
9};
10
11#endif
diff --git a/include/linux/netfilter_ipv4/ipt_ah.h b/include/linux/netfilter_ipv4/ipt_ah.h
new file mode 100644
index 000000000000..7b9a2ac7adb9
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_ah.h
@@ -0,0 +1,16 @@
1#ifndef _IPT_AH_H
2#define _IPT_AH_H
3
4struct ipt_ah
5{
6 u_int32_t spis[2]; /* Security Parameter Index */
7 u_int8_t invflags; /* Inverse flags */
8};
9
10
11
12/* Values for "invflags" field in struct ipt_ah. */
13#define IPT_AH_INV_SPI 0x01 /* Invert the sense of spi. */
14#define IPT_AH_INV_MASK 0x01 /* All possible flags. */
15
16#endif /*_IPT_AH_H*/
diff --git a/include/linux/netfilter_ipv4/ipt_comment.h b/include/linux/netfilter_ipv4/ipt_comment.h
new file mode 100644
index 000000000000..85c1123c29ce
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_comment.h
@@ -0,0 +1,10 @@
1#ifndef _IPT_COMMENT_H
2#define _IPT_COMMENT_H
3
4#define IPT_MAX_COMMENT_LEN 256
5
6struct ipt_comment_info {
7 unsigned char comment[IPT_MAX_COMMENT_LEN];
8};
9
10#endif /* _IPT_COMMENT_H */
diff --git a/include/linux/netfilter_ipv4/ipt_connmark.h b/include/linux/netfilter_ipv4/ipt_connmark.h
new file mode 100644
index 000000000000..46573270d9aa
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_connmark.h
@@ -0,0 +1,18 @@
1#ifndef _IPT_CONNMARK_H
2#define _IPT_CONNMARK_H
3
4/* Copyright (C) 2002,2004 MARA Systems AB <http://www.marasystems.com>
5 * by Henrik Nordstrom <hno@marasystems.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
13struct ipt_connmark_info {
14 unsigned long mark, mask;
15 u_int8_t invert;
16};
17
18#endif /*_IPT_CONNMARK_H*/
diff --git a/include/linux/netfilter_ipv4/ipt_conntrack.h b/include/linux/netfilter_ipv4/ipt_conntrack.h
new file mode 100644
index 000000000000..413c5658bd3a
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_conntrack.h
@@ -0,0 +1,60 @@
1/* Header file for kernel module to match connection tracking information.
2 * GPL (C) 2001 Marc Boucher (marc@mbsi.ca).
3 */
4
5#ifndef _IPT_CONNTRACK_H
6#define _IPT_CONNTRACK_H
7
8#define IPT_CONNTRACK_STATE_BIT(ctinfo) (1 << ((ctinfo)%IP_CT_IS_REPLY+1))
9#define IPT_CONNTRACK_STATE_INVALID (1 << 0)
10
11#define IPT_CONNTRACK_STATE_SNAT (1 << (IP_CT_NUMBER + 1))
12#define IPT_CONNTRACK_STATE_DNAT (1 << (IP_CT_NUMBER + 2))
13#define IPT_CONNTRACK_STATE_UNTRACKED (1 << (IP_CT_NUMBER + 3))
14
15/* flags, invflags: */
16#define IPT_CONNTRACK_STATE 0x01
17#define IPT_CONNTRACK_PROTO 0x02
18#define IPT_CONNTRACK_ORIGSRC 0x04
19#define IPT_CONNTRACK_ORIGDST 0x08
20#define IPT_CONNTRACK_REPLSRC 0x10
21#define IPT_CONNTRACK_REPLDST 0x20
22#define IPT_CONNTRACK_STATUS 0x40
23#define IPT_CONNTRACK_EXPIRES 0x80
24
25/* This is exposed to userspace, so remains frozen in time. */
26struct ip_conntrack_old_tuple
27{
28 struct {
29 __u32 ip;
30 union {
31 __u16 all;
32 } u;
33 } src;
34
35 struct {
36 __u32 ip;
37 union {
38 __u16 all;
39 } u;
40
41 /* The protocol. */
42 u16 protonum;
43 } dst;
44};
45
46struct ipt_conntrack_info
47{
48 unsigned int statemask, statusmask;
49
50 struct ip_conntrack_old_tuple tuple[IP_CT_DIR_MAX];
51 struct in_addr sipmsk[IP_CT_DIR_MAX], dipmsk[IP_CT_DIR_MAX];
52
53 unsigned long expires_min, expires_max;
54
55 /* Flags word */
56 u_int8_t flags;
57 /* Inverse flags */
58 u_int8_t invflags;
59};
60#endif /*_IPT_CONNTRACK_H*/
diff --git a/include/linux/netfilter_ipv4/ipt_dscp.h b/include/linux/netfilter_ipv4/ipt_dscp.h
new file mode 100644
index 000000000000..2fa6dfe92894
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_dscp.h
@@ -0,0 +1,23 @@
1/* iptables module for matching the IPv4 DSCP field
2 *
3 * (C) 2002 Harald Welte <laforge@gnumonks.org>
4 * This software is distributed under GNU GPL v2, 1991
5 *
6 * See RFC2474 for a description of the DSCP field within the IP Header.
7 *
8 * ipt_dscp.h,v 1.3 2002/08/05 19:00:21 laforge Exp
9*/
10#ifndef _IPT_DSCP_H
11#define _IPT_DSCP_H
12
13#define IPT_DSCP_MASK 0xfc /* 11111100 */
14#define IPT_DSCP_SHIFT 2
15#define IPT_DSCP_MAX 0x3f /* 00111111 */
16
17/* match info */
18struct ipt_dscp_info {
19 u_int8_t dscp;
20 u_int8_t invert;
21};
22
23#endif /* _IPT_DSCP_H */
diff --git a/include/linux/netfilter_ipv4/ipt_ecn.h b/include/linux/netfilter_ipv4/ipt_ecn.h
new file mode 100644
index 000000000000..1f0d9a4d3378
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_ecn.h
@@ -0,0 +1,33 @@
1/* iptables module for matching the ECN header in IPv4 and TCP header
2 *
3 * (C) 2002 Harald Welte <laforge@gnumonks.org>
4 *
5 * This software is distributed under GNU GPL v2, 1991
6 *
7 * ipt_ecn.h,v 1.4 2002/08/05 19:39:00 laforge Exp
8*/
9#ifndef _IPT_ECN_H
10#define _IPT_ECN_H
11#include <linux/netfilter_ipv4/ipt_dscp.h>
12
13#define IPT_ECN_IP_MASK (~IPT_DSCP_MASK)
14
15#define IPT_ECN_OP_MATCH_IP 0x01
16#define IPT_ECN_OP_MATCH_ECE 0x10
17#define IPT_ECN_OP_MATCH_CWR 0x20
18
19#define IPT_ECN_OP_MATCH_MASK 0xce
20
21/* match info */
22struct ipt_ecn_info {
23 u_int8_t operation;
24 u_int8_t invert;
25 u_int8_t ip_ect;
26 union {
27 struct {
28 u_int8_t ect;
29 } tcp;
30 } proto;
31};
32
33#endif /* _IPT_ECN_H */
diff --git a/include/linux/netfilter_ipv4/ipt_esp.h b/include/linux/netfilter_ipv4/ipt_esp.h
new file mode 100644
index 000000000000..c782a83e53e0
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_esp.h
@@ -0,0 +1,16 @@
1#ifndef _IPT_ESP_H
2#define _IPT_ESP_H
3
4struct ipt_esp
5{
6 u_int32_t spis[2]; /* Security Parameter Index */
7 u_int8_t invflags; /* Inverse flags */
8};
9
10
11
12/* Values for "invflags" field in struct ipt_esp. */
13#define IPT_ESP_INV_SPI 0x01 /* Invert the sense of spi. */
14#define IPT_ESP_INV_MASK 0x01 /* All possible flags. */
15
16#endif /*_IPT_ESP_H*/
diff --git a/include/linux/netfilter_ipv4/ipt_hashlimit.h b/include/linux/netfilter_ipv4/ipt_hashlimit.h
new file mode 100644
index 000000000000..ac2cb64ecd76
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_hashlimit.h
@@ -0,0 +1,40 @@
1#ifndef _IPT_HASHLIMIT_H
2#define _IPT_HASHLIMIT_H
3
4/* timings are in milliseconds. */
5#define IPT_HASHLIMIT_SCALE 10000
6/* 1/10,000 sec period => max of 10,000/sec. Min rate is then 429490
7 seconds, or one every 59 hours. */
8
9/* details of this structure hidden by the implementation */
10struct ipt_hashlimit_htable;
11
12#define IPT_HASHLIMIT_HASH_DIP 0x0001
13#define IPT_HASHLIMIT_HASH_DPT 0x0002
14#define IPT_HASHLIMIT_HASH_SIP 0x0004
15#define IPT_HASHLIMIT_HASH_SPT 0x0008
16
17struct hashlimit_cfg {
18 u_int32_t mode; /* bitmask of IPT_HASHLIMIT_HASH_* */
19 u_int32_t avg; /* Average secs between packets * scale */
20 u_int32_t burst; /* Period multiplier for upper limit. */
21
22 /* user specified */
23 u_int32_t size; /* how many buckets */
24 u_int32_t max; /* max number of entries */
25 u_int32_t gc_interval; /* gc interval */
26 u_int32_t expire; /* when do entries expire? */
27};
28
29struct ipt_hashlimit_info {
30 char name [IFNAMSIZ]; /* name */
31 struct hashlimit_cfg cfg;
32 struct ipt_hashlimit_htable *hinfo;
33
34 /* Used internally by the kernel */
35 union {
36 void *ptr;
37 struct ipt_hashlimit_info *master;
38 } u;
39};
40#endif /*_IPT_HASHLIMIT_H*/
diff --git a/include/linux/netfilter_ipv4/ipt_helper.h b/include/linux/netfilter_ipv4/ipt_helper.h
new file mode 100644
index 000000000000..6f12ecb8c93d
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_helper.h
@@ -0,0 +1,8 @@
1#ifndef _IPT_HELPER_H
2#define _IPT_HELPER_H
3
4struct ipt_helper_info {
5 int invert;
6 char name[30];
7};
8#endif /* _IPT_HELPER_H */
diff --git a/include/linux/netfilter_ipv4/ipt_iprange.h b/include/linux/netfilter_ipv4/ipt_iprange.h
new file mode 100644
index 000000000000..3ecb3bd63676
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_iprange.h
@@ -0,0 +1,23 @@
1#ifndef _IPT_IPRANGE_H
2#define _IPT_IPRANGE_H
3
4#define IPRANGE_SRC 0x01 /* Match source IP address */
5#define IPRANGE_DST 0x02 /* Match destination IP address */
6#define IPRANGE_SRC_INV 0x10 /* Negate the condition */
7#define IPRANGE_DST_INV 0x20 /* Negate the condition */
8
9struct ipt_iprange {
10 /* Inclusive: network order. */
11 u_int32_t min_ip, max_ip;
12};
13
14struct ipt_iprange_info
15{
16 struct ipt_iprange src;
17 struct ipt_iprange dst;
18
19 /* Flags from above */
20 u_int8_t flags;
21};
22
23#endif /* _IPT_IPRANGE_H */
diff --git a/include/linux/netfilter_ipv4/ipt_length.h b/include/linux/netfilter_ipv4/ipt_length.h
new file mode 100644
index 000000000000..6e0885229615
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_length.h
@@ -0,0 +1,9 @@
1#ifndef _IPT_LENGTH_H
2#define _IPT_LENGTH_H
3
4struct ipt_length_info {
5 u_int16_t min, max;
6 u_int8_t invert;
7};
8
9#endif /*_IPT_LENGTH_H*/
diff --git a/include/linux/netfilter_ipv4/ipt_limit.h b/include/linux/netfilter_ipv4/ipt_limit.h
new file mode 100644
index 000000000000..256453409e21
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_limit.h
@@ -0,0 +1,21 @@
1#ifndef _IPT_RATE_H
2#define _IPT_RATE_H
3
4/* timings are in milliseconds. */
5#define IPT_LIMIT_SCALE 10000
6
7/* 1/10,000 sec period => max of 10,000/sec. Min rate is then 429490
8 seconds, or one every 59 hours. */
9struct ipt_rateinfo {
10 u_int32_t avg; /* Average secs between packets * scale */
11 u_int32_t burst; /* Period multiplier for upper limit. */
12
13 /* Used internally by the kernel */
14 unsigned long prev;
15 u_int32_t credit;
16 u_int32_t credit_cap, cost;
17
18 /* Ugly, ugly fucker. */
19 struct ipt_rateinfo *master;
20};
21#endif /*_IPT_RATE_H*/
diff --git a/include/linux/netfilter_ipv4/ipt_mac.h b/include/linux/netfilter_ipv4/ipt_mac.h
new file mode 100644
index 000000000000..f8d5b8e7ccdb
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_mac.h
@@ -0,0 +1,8 @@
1#ifndef _IPT_MAC_H
2#define _IPT_MAC_H
3
4struct ipt_mac_info {
5 unsigned char srcaddr[ETH_ALEN];
6 int invert;
7};
8#endif /*_IPT_MAC_H*/
diff --git a/include/linux/netfilter_ipv4/ipt_mark.h b/include/linux/netfilter_ipv4/ipt_mark.h
new file mode 100644
index 000000000000..f3952b563d4c
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_mark.h
@@ -0,0 +1,9 @@
1#ifndef _IPT_MARK_H
2#define _IPT_MARK_H
3
4struct ipt_mark_info {
5 unsigned long mark, mask;
6 u_int8_t invert;
7};
8
9#endif /*_IPT_MARK_H*/
diff --git a/include/linux/netfilter_ipv4/ipt_multiport.h b/include/linux/netfilter_ipv4/ipt_multiport.h
new file mode 100644
index 000000000000..e6b6fff811df
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_multiport.h
@@ -0,0 +1,30 @@
1#ifndef _IPT_MULTIPORT_H
2#define _IPT_MULTIPORT_H
3#include <linux/netfilter_ipv4/ip_tables.h>
4
5enum ipt_multiport_flags
6{
7 IPT_MULTIPORT_SOURCE,
8 IPT_MULTIPORT_DESTINATION,
9 IPT_MULTIPORT_EITHER
10};
11
12#define IPT_MULTI_PORTS 15
13
14/* Must fit inside union ipt_matchinfo: 16 bytes */
15struct ipt_multiport
16{
17 u_int8_t flags; /* Type of comparison */
18 u_int8_t count; /* Number of ports */
19 u_int16_t ports[IPT_MULTI_PORTS]; /* Ports */
20};
21
22struct ipt_multiport_v1
23{
24 u_int8_t flags; /* Type of comparison */
25 u_int8_t count; /* Number of ports */
26 u_int16_t ports[IPT_MULTI_PORTS]; /* Ports */
27 u_int8_t pflags[IPT_MULTI_PORTS]; /* Port flags */
28 u_int8_t invert; /* Invert flag */
29};
30#endif /*_IPT_MULTIPORT_H*/
diff --git a/include/linux/netfilter_ipv4/ipt_owner.h b/include/linux/netfilter_ipv4/ipt_owner.h
new file mode 100644
index 000000000000..92f4bdac54ef
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_owner.h
@@ -0,0 +1,20 @@
1#ifndef _IPT_OWNER_H
2#define _IPT_OWNER_H
3
4/* match and invert flags */
5#define IPT_OWNER_UID 0x01
6#define IPT_OWNER_GID 0x02
7#define IPT_OWNER_PID 0x04
8#define IPT_OWNER_SID 0x08
9#define IPT_OWNER_COMM 0x10
10
11struct ipt_owner_info {
12 uid_t uid;
13 gid_t gid;
14 pid_t pid;
15 pid_t sid;
16 char comm[16];
17 u_int8_t match, invert; /* flags */
18};
19
20#endif /*_IPT_OWNER_H*/
diff --git a/include/linux/netfilter_ipv4/ipt_physdev.h b/include/linux/netfilter_ipv4/ipt_physdev.h
new file mode 100644
index 000000000000..7538c8655ec0
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_physdev.h
@@ -0,0 +1,24 @@
1#ifndef _IPT_PHYSDEV_H
2#define _IPT_PHYSDEV_H
3
4#ifdef __KERNEL__
5#include <linux/if.h>
6#endif
7
8#define IPT_PHYSDEV_OP_IN 0x01
9#define IPT_PHYSDEV_OP_OUT 0x02
10#define IPT_PHYSDEV_OP_BRIDGED 0x04
11#define IPT_PHYSDEV_OP_ISIN 0x08
12#define IPT_PHYSDEV_OP_ISOUT 0x10
13#define IPT_PHYSDEV_OP_MASK (0x20 - 1)
14
15struct ipt_physdev_info {
16 char physindev[IFNAMSIZ];
17 char in_mask[IFNAMSIZ];
18 char physoutdev[IFNAMSIZ];
19 char out_mask[IFNAMSIZ];
20 u_int8_t invert;
21 u_int8_t bitmask;
22};
23
24#endif /*_IPT_PHYSDEV_H*/
diff --git a/include/linux/netfilter_ipv4/ipt_pkttype.h b/include/linux/netfilter_ipv4/ipt_pkttype.h
new file mode 100644
index 000000000000..d53a65848683
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_pkttype.h
@@ -0,0 +1,8 @@
1#ifndef _IPT_PKTTYPE_H
2#define _IPT_PKTTYPE_H
3
4struct ipt_pkttype_info {
5 int pkttype;
6 int invert;
7};
8#endif /*_IPT_PKTTYPE_H*/
diff --git a/include/linux/netfilter_ipv4/ipt_realm.h b/include/linux/netfilter_ipv4/ipt_realm.h
new file mode 100644
index 000000000000..a4d6698723ac
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_realm.h
@@ -0,0 +1,10 @@
1#ifndef _IPT_REALM_H
2#define _IPT_REALM_H
3
4struct ipt_realm_info {
5 u_int32_t id;
6 u_int32_t mask;
7 u_int8_t invert;
8};
9
10#endif /* _IPT_REALM_H */
diff --git a/include/linux/netfilter_ipv4/ipt_recent.h b/include/linux/netfilter_ipv4/ipt_recent.h
new file mode 100644
index 000000000000..6508a4592651
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_recent.h
@@ -0,0 +1,27 @@
1#ifndef _IPT_RECENT_H
2#define _IPT_RECENT_H
3
4#define RECENT_NAME "ipt_recent"
5#define RECENT_VER "v0.3.1"
6
7#define IPT_RECENT_CHECK 1
8#define IPT_RECENT_SET 2
9#define IPT_RECENT_UPDATE 4
10#define IPT_RECENT_REMOVE 8
11#define IPT_RECENT_TTL 16
12
13#define IPT_RECENT_SOURCE 0
14#define IPT_RECENT_DEST 1
15
16#define IPT_RECENT_NAME_LEN 200
17
18struct ipt_recent_info {
19 u_int32_t seconds;
20 u_int32_t hit_count;
21 u_int8_t check_set;
22 u_int8_t invert;
23 char name[IPT_RECENT_NAME_LEN];
24 u_int8_t side;
25};
26
27#endif /*_IPT_RECENT_H*/
diff --git a/include/linux/netfilter_ipv4/ipt_sctp.h b/include/linux/netfilter_ipv4/ipt_sctp.h
new file mode 100644
index 000000000000..e93a9ec99fc2
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_sctp.h
@@ -0,0 +1,107 @@
1#ifndef _IPT_SCTP_H_
2#define _IPT_SCTP_H_
3
4#define IPT_SCTP_SRC_PORTS 0x01
5#define IPT_SCTP_DEST_PORTS 0x02
6#define IPT_SCTP_CHUNK_TYPES 0x04
7
8#define IPT_SCTP_VALID_FLAGS 0x07
9
10#define ELEMCOUNT(x) (sizeof(x)/sizeof(x[0]))
11
12
13struct ipt_sctp_flag_info {
14 u_int8_t chunktype;
15 u_int8_t flag;
16 u_int8_t flag_mask;
17};
18
19#define IPT_NUM_SCTP_FLAGS 4
20
21struct ipt_sctp_info {
22 u_int16_t dpts[2]; /* Min, Max */
23 u_int16_t spts[2]; /* Min, Max */
24
25 u_int32_t chunkmap[256 / sizeof (u_int32_t)]; /* Bit mask of chunks to be matched according to RFC 2960 */
26
27#define SCTP_CHUNK_MATCH_ANY 0x01 /* Match if any of the chunk types are present */
28#define SCTP_CHUNK_MATCH_ALL 0x02 /* Match if all of the chunk types are present */
29#define SCTP_CHUNK_MATCH_ONLY 0x04 /* Match if these are the only chunk types present */
30
31 u_int32_t chunk_match_type;
32 struct ipt_sctp_flag_info flag_info[IPT_NUM_SCTP_FLAGS];
33 int flag_count;
34
35 u_int32_t flags;
36 u_int32_t invflags;
37};
38
39#define bytes(type) (sizeof(type) * 8)
40
41#define SCTP_CHUNKMAP_SET(chunkmap, type) \
42 do { \
43 chunkmap[type / bytes(u_int32_t)] |= \
44 1 << (type % bytes(u_int32_t)); \
45 } while (0)
46
47#define SCTP_CHUNKMAP_CLEAR(chunkmap, type) \
48 do { \
49 chunkmap[type / bytes(u_int32_t)] &= \
50 ~(1 << (type % bytes(u_int32_t))); \
51 } while (0)
52
53#define SCTP_CHUNKMAP_IS_SET(chunkmap, type) \
54({ \
55 (chunkmap[type / bytes (u_int32_t)] & \
56 (1 << (type % bytes (u_int32_t)))) ? 1: 0; \
57})
58
59#define SCTP_CHUNKMAP_RESET(chunkmap) \
60 do { \
61 int i; \
62 for (i = 0; i < ELEMCOUNT(chunkmap); i++) \
63 chunkmap[i] = 0; \
64 } while (0)
65
66#define SCTP_CHUNKMAP_SET_ALL(chunkmap) \
67 do { \
68 int i; \
69 for (i = 0; i < ELEMCOUNT(chunkmap); i++) \
70 chunkmap[i] = ~0; \
71 } while (0)
72
73#define SCTP_CHUNKMAP_COPY(destmap, srcmap) \
74 do { \
75 int i; \
76 for (i = 0; i < ELEMCOUNT(chunkmap); i++) \
77 destmap[i] = srcmap[i]; \
78 } while (0)
79
80#define SCTP_CHUNKMAP_IS_CLEAR(chunkmap) \
81({ \
82 int i; \
83 int flag = 1; \
84 for (i = 0; i < ELEMCOUNT(chunkmap); i++) { \
85 if (chunkmap[i]) { \
86 flag = 0; \
87 break; \
88 } \
89 } \
90 flag; \
91})
92
93#define SCTP_CHUNKMAP_IS_ALL_SET(chunkmap) \
94({ \
95 int i; \
96 int flag = 1; \
97 for (i = 0; i < ELEMCOUNT(chunkmap); i++) { \
98 if (chunkmap[i] != ~0) { \
99 flag = 0; \
100 break; \
101 } \
102 } \
103 flag; \
104})
105
106#endif /* _IPT_SCTP_H_ */
107
diff --git a/include/linux/netfilter_ipv4/ipt_state.h b/include/linux/netfilter_ipv4/ipt_state.h
new file mode 100644
index 000000000000..5df37868933d
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_state.h
@@ -0,0 +1,13 @@
1#ifndef _IPT_STATE_H
2#define _IPT_STATE_H
3
4#define IPT_STATE_BIT(ctinfo) (1 << ((ctinfo)%IP_CT_IS_REPLY+1))
5#define IPT_STATE_INVALID (1 << 0)
6
7#define IPT_STATE_UNTRACKED (1 << (IP_CT_NUMBER + 1))
8
9struct ipt_state_info
10{
11 unsigned int statemask;
12};
13#endif /*_IPT_STATE_H*/
diff --git a/include/linux/netfilter_ipv4/ipt_tcpmss.h b/include/linux/netfilter_ipv4/ipt_tcpmss.h
new file mode 100644
index 000000000000..e2b14397f701
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_tcpmss.h
@@ -0,0 +1,9 @@
1#ifndef _IPT_TCPMSS_MATCH_H
2#define _IPT_TCPMSS_MATCH_H
3
4struct ipt_tcpmss_match_info {
5 u_int16_t mss_min, mss_max;
6 u_int8_t invert;
7};
8
9#endif /*_IPT_TCPMSS_MATCH_H*/
diff --git a/include/linux/netfilter_ipv4/ipt_tos.h b/include/linux/netfilter_ipv4/ipt_tos.h
new file mode 100644
index 000000000000..a21f5df23c50
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_tos.h
@@ -0,0 +1,13 @@
1#ifndef _IPT_TOS_H
2#define _IPT_TOS_H
3
4struct ipt_tos_info {
5 u_int8_t tos;
6 u_int8_t invert;
7};
8
9#ifndef IPTOS_NORMALSVC
10#define IPTOS_NORMALSVC 0
11#endif
12
13#endif /*_IPT_TOS_H*/
diff --git a/include/linux/netfilter_ipv4/ipt_ttl.h b/include/linux/netfilter_ipv4/ipt_ttl.h
new file mode 100644
index 000000000000..ee24fd86a3aa
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ipt_ttl.h
@@ -0,0 +1,21 @@
1/* IP tables module for matching the value of the TTL
2 * (C) 2000 by Harald Welte <laforge@gnumonks.org> */
3
4#ifndef _IPT_TTL_H
5#define _IPT_TTL_H
6
7enum {
8 IPT_TTL_EQ = 0, /* equals */
9 IPT_TTL_NE, /* not equals */
10 IPT_TTL_LT, /* less than */
11 IPT_TTL_GT, /* greater than */
12};
13
14
15struct ipt_ttl_info {
16 u_int8_t mode;
17 u_int8_t ttl;
18};
19
20
21#endif
diff --git a/include/linux/netfilter_ipv4/listhelp.h b/include/linux/netfilter_ipv4/listhelp.h
new file mode 100644
index 000000000000..f2ae7c5e57bb
--- /dev/null
+++ b/include/linux/netfilter_ipv4/listhelp.h
@@ -0,0 +1,125 @@
1#ifndef _LISTHELP_H
2#define _LISTHELP_H
3#include <linux/config.h>
4#include <linux/list.h>
5#include <linux/netfilter_ipv4/lockhelp.h>
6
7/* Header to do more comprehensive job than linux/list.h; assume list
8 is first entry in structure. */
9
10/* Return pointer to first true entry, if any, or NULL. A macro
11 required to allow inlining of cmpfn. */
12#define LIST_FIND(head, cmpfn, type, args...) \
13({ \
14 const struct list_head *__i, *__j = NULL; \
15 \
16 ASSERT_READ_LOCK(head); \
17 list_for_each(__i, (head)) \
18 if (cmpfn((const type)__i , ## args)) { \
19 __j = __i; \
20 break; \
21 } \
22 (type)__j; \
23})
24
25#define LIST_FIND_W(head, cmpfn, type, args...) \
26({ \
27 const struct list_head *__i, *__j = NULL; \
28 \
29 ASSERT_WRITE_LOCK(head); \
30 list_for_each(__i, (head)) \
31 if (cmpfn((type)__i , ## args)) { \
32 __j = __i; \
33 break; \
34 } \
35 (type)__j; \
36})
37
38/* Just like LIST_FIND but we search backwards */
39#define LIST_FIND_B(head, cmpfn, type, args...) \
40({ \
41 const struct list_head *__i, *__j = NULL; \
42 \
43 ASSERT_READ_LOCK(head); \
44 list_for_each_prev(__i, (head)) \
45 if (cmpfn((const type)__i , ## args)) { \
46 __j = __i; \
47 break; \
48 } \
49 (type)__j; \
50})
51
52static inline int
53__list_cmp_same(const void *p1, const void *p2) { return p1 == p2; }
54
55/* Is this entry in the list? */
56static inline int
57list_inlist(struct list_head *head, const void *entry)
58{
59 return LIST_FIND(head, __list_cmp_same, void *, entry) != NULL;
60}
61
62/* Delete from list. */
63#ifdef CONFIG_NETFILTER_DEBUG
64#define LIST_DELETE(head, oldentry) \
65do { \
66 ASSERT_WRITE_LOCK(head); \
67 if (!list_inlist(head, oldentry)) \
68 printk("LIST_DELETE: %s:%u `%s'(%p) not in %s.\n", \
69 __FILE__, __LINE__, #oldentry, oldentry, #head); \
70 else list_del((struct list_head *)oldentry); \
71} while(0)
72#else
73#define LIST_DELETE(head, oldentry) list_del((struct list_head *)oldentry)
74#endif
75
76/* Append. */
77static inline void
78list_append(struct list_head *head, void *new)
79{
80 ASSERT_WRITE_LOCK(head);
81 list_add((new), (head)->prev);
82}
83
84/* Prepend. */
85static inline void
86list_prepend(struct list_head *head, void *new)
87{
88 ASSERT_WRITE_LOCK(head);
89 list_add(new, head);
90}
91
92/* Insert according to ordering function; insert before first true. */
93#define LIST_INSERT(head, new, cmpfn) \
94do { \
95 struct list_head *__i; \
96 ASSERT_WRITE_LOCK(head); \
97 list_for_each(__i, (head)) \
98 if ((new), (typeof (new))__i) \
99 break; \
100 list_add((struct list_head *)(new), __i->prev); \
101} while(0)
102
103/* If the field after the list_head is a nul-terminated string, you
104 can use these functions. */
105static inline int __list_cmp_name(const void *i, const char *name)
106{
107 return strcmp(name, i+sizeof(struct list_head)) == 0;
108}
109
110/* Returns false if same name already in list, otherwise does insert. */
111static inline int
112list_named_insert(struct list_head *head, void *new)
113{
114 if (LIST_FIND(head, __list_cmp_name, void *,
115 new + sizeof(struct list_head)))
116 return 0;
117 list_prepend(head, new);
118 return 1;
119}
120
121/* Find this named element in the list. */
122#define list_named_find(head, name) \
123LIST_FIND(head, __list_cmp_name, void *, name)
124
125#endif /*_LISTHELP_H*/
diff --git a/include/linux/netfilter_ipv4/lockhelp.h b/include/linux/netfilter_ipv4/lockhelp.h
new file mode 100644
index 000000000000..a3288633ab46
--- /dev/null
+++ b/include/linux/netfilter_ipv4/lockhelp.h
@@ -0,0 +1,129 @@
1#ifndef _LOCKHELP_H
2#define _LOCKHELP_H
3#include <linux/config.h>
4
5#include <linux/spinlock.h>
6#include <asm/atomic.h>
7#include <linux/interrupt.h>
8#include <linux/smp.h>
9
10/* Header to do help in lock debugging. */
11
12#ifdef CONFIG_NETFILTER_DEBUG
13struct spinlock_debug
14{
15 spinlock_t l;
16 atomic_t locked_by;
17};
18
19struct rwlock_debug
20{
21 rwlock_t l;
22 long read_locked_map;
23 long write_locked_map;
24};
25
26#define DECLARE_LOCK(l) \
27struct spinlock_debug l = { SPIN_LOCK_UNLOCKED, ATOMIC_INIT(-1) }
28#define DECLARE_LOCK_EXTERN(l) \
29extern struct spinlock_debug l
30#define DECLARE_RWLOCK(l) \
31struct rwlock_debug l = { RW_LOCK_UNLOCKED, 0, 0 }
32#define DECLARE_RWLOCK_EXTERN(l) \
33extern struct rwlock_debug l
34
35#define MUST_BE_LOCKED(l) \
36do { if (atomic_read(&(l)->locked_by) != smp_processor_id()) \
37 printk("ASSERT %s:%u %s unlocked\n", __FILE__, __LINE__, #l); \
38} while(0)
39
40#define MUST_BE_UNLOCKED(l) \
41do { if (atomic_read(&(l)->locked_by) == smp_processor_id()) \
42 printk("ASSERT %s:%u %s locked\n", __FILE__, __LINE__, #l); \
43} while(0)
44
45/* Write locked OK as well. */
46#define MUST_BE_READ_LOCKED(l) \
47do { if (!((l)->read_locked_map & (1UL << smp_processor_id())) \
48 && !((l)->write_locked_map & (1UL << smp_processor_id()))) \
49 printk("ASSERT %s:%u %s not readlocked\n", __FILE__, __LINE__, #l); \
50} while(0)
51
52#define MUST_BE_WRITE_LOCKED(l) \
53do { if (!((l)->write_locked_map & (1UL << smp_processor_id()))) \
54 printk("ASSERT %s:%u %s not writelocked\n", __FILE__, __LINE__, #l); \
55} while(0)
56
57#define MUST_BE_READ_WRITE_UNLOCKED(l) \
58do { if ((l)->read_locked_map & (1UL << smp_processor_id())) \
59 printk("ASSERT %s:%u %s readlocked\n", __FILE__, __LINE__, #l); \
60 else if ((l)->write_locked_map & (1UL << smp_processor_id())) \
61 printk("ASSERT %s:%u %s writelocked\n", __FILE__, __LINE__, #l); \
62} while(0)
63
64#define LOCK_BH(lk) \
65do { \
66 MUST_BE_UNLOCKED(lk); \
67 spin_lock_bh(&(lk)->l); \
68 atomic_set(&(lk)->locked_by, smp_processor_id()); \
69} while(0)
70
71#define UNLOCK_BH(lk) \
72do { \
73 MUST_BE_LOCKED(lk); \
74 atomic_set(&(lk)->locked_by, -1); \
75 spin_unlock_bh(&(lk)->l); \
76} while(0)
77
78#define READ_LOCK(lk) \
79do { \
80 MUST_BE_READ_WRITE_UNLOCKED(lk); \
81 read_lock_bh(&(lk)->l); \
82 set_bit(smp_processor_id(), &(lk)->read_locked_map); \
83} while(0)
84
85#define WRITE_LOCK(lk) \
86do { \
87 MUST_BE_READ_WRITE_UNLOCKED(lk); \
88 write_lock_bh(&(lk)->l); \
89 set_bit(smp_processor_id(), &(lk)->write_locked_map); \
90} while(0)
91
92#define READ_UNLOCK(lk) \
93do { \
94 if (!((lk)->read_locked_map & (1UL << smp_processor_id()))) \
95 printk("ASSERT: %s:%u %s not readlocked\n", \
96 __FILE__, __LINE__, #lk); \
97 clear_bit(smp_processor_id(), &(lk)->read_locked_map); \
98 read_unlock_bh(&(lk)->l); \
99} while(0)
100
101#define WRITE_UNLOCK(lk) \
102do { \
103 MUST_BE_WRITE_LOCKED(lk); \
104 clear_bit(smp_processor_id(), &(lk)->write_locked_map); \
105 write_unlock_bh(&(lk)->l); \
106} while(0)
107
108#else
109#define DECLARE_LOCK(l) spinlock_t l = SPIN_LOCK_UNLOCKED
110#define DECLARE_LOCK_EXTERN(l) extern spinlock_t l
111#define DECLARE_RWLOCK(l) rwlock_t l = RW_LOCK_UNLOCKED
112#define DECLARE_RWLOCK_EXTERN(l) extern rwlock_t l
113
114#define MUST_BE_LOCKED(l)
115#define MUST_BE_UNLOCKED(l)
116#define MUST_BE_READ_LOCKED(l)
117#define MUST_BE_WRITE_LOCKED(l)
118#define MUST_BE_READ_WRITE_UNLOCKED(l)
119
120#define LOCK_BH(l) spin_lock_bh(l)
121#define UNLOCK_BH(l) spin_unlock_bh(l)
122
123#define READ_LOCK(l) read_lock_bh(l)
124#define WRITE_LOCK(l) write_lock_bh(l)
125#define READ_UNLOCK(l) read_unlock_bh(l)
126#define WRITE_UNLOCK(l) write_unlock_bh(l)
127#endif /*CONFIG_NETFILTER_DEBUG*/
128
129#endif /* _LOCKHELP_H */
diff --git a/include/linux/netfilter_ipv6.h b/include/linux/netfilter_ipv6.h
new file mode 100644
index 000000000000..bee7a5ec7c66
--- /dev/null
+++ b/include/linux/netfilter_ipv6.h
@@ -0,0 +1,71 @@
1#ifndef __LINUX_IP6_NETFILTER_H
2#define __LINUX_IP6_NETFILTER_H
3
4/* IPv6-specific defines for netfilter.
5 * (C)1998 Rusty Russell -- This code is GPL.
6 * (C)1999 David Jeffery
7 * this header was blatantly ripped from netfilter_ipv4.h
8 * it's amazing what adding a bunch of 6s can do =8^)
9 */
10
11#include <linux/netfilter.h>
12
13/* IP Cache bits. */
14/* Src IP address. */
15#define NFC_IP6_SRC 0x0001
16/* Dest IP address. */
17#define NFC_IP6_DST 0x0002
18/* Input device. */
19#define NFC_IP6_IF_IN 0x0004
20/* Output device. */
21#define NFC_IP6_IF_OUT 0x0008
22/* TOS. */
23#define NFC_IP6_TOS 0x0010
24/* Protocol. */
25#define NFC_IP6_PROTO 0x0020
26/* IP options. */
27#define NFC_IP6_OPTIONS 0x0040
28/* Frag & flags. */
29#define NFC_IP6_FRAG 0x0080
30
31
32/* Per-protocol information: only matters if proto match. */
33/* TCP flags. */
34#define NFC_IP6_TCPFLAGS 0x0100
35/* Source port. */
36#define NFC_IP6_SRC_PT 0x0200
37/* Dest port. */
38#define NFC_IP6_DST_PT 0x0400
39/* Something else about the proto */
40#define NFC_IP6_PROTO_UNKNOWN 0x2000
41
42
43/* IP6 Hooks */
44/* After promisc drops, checksum checks. */
45#define NF_IP6_PRE_ROUTING 0
46/* If the packet is destined for this box. */
47#define NF_IP6_LOCAL_IN 1
48/* If the packet is destined for another interface. */
49#define NF_IP6_FORWARD 2
50/* Packets coming from a local process. */
51#define NF_IP6_LOCAL_OUT 3
52/* Packets about to hit the wire. */
53#define NF_IP6_POST_ROUTING 4
54#define NF_IP6_NUMHOOKS 5
55
56
57enum nf_ip6_hook_priorities {
58 NF_IP6_PRI_FIRST = INT_MIN,
59 NF_IP6_PRI_SELINUX_FIRST = -225,
60 NF_IP6_PRI_CONNTRACK = -200,
61 NF_IP6_PRI_BRIDGE_SABOTAGE_FORWARD = -175,
62 NF_IP6_PRI_MANGLE = -150,
63 NF_IP6_PRI_NAT_DST = -100,
64 NF_IP6_PRI_BRIDGE_SABOTAGE_LOCAL_OUT = -50,
65 NF_IP6_PRI_FILTER = 0,
66 NF_IP6_PRI_NAT_SRC = 100,
67 NF_IP6_PRI_SELINUX_LAST = 225,
68 NF_IP6_PRI_LAST = INT_MAX,
69};
70
71#endif /*__LINUX_IP6_NETFILTER_H*/
diff --git a/include/linux/netfilter_ipv6/ip6_logging.h b/include/linux/netfilter_ipv6/ip6_logging.h
new file mode 100644
index 000000000000..a0b2ee3043aa
--- /dev/null
+++ b/include/linux/netfilter_ipv6/ip6_logging.h
@@ -0,0 +1,20 @@
1/* IPv6 macros for the nternal logging interface. */
2#ifndef __IP6_LOGGING_H
3#define __IP6_LOGGING_H
4
5#ifdef __KERNEL__
6#include <linux/socket.h>
7#include <linux/netfilter_logging.h>
8
9#define nf_log_ip6_packet(pskb,hooknum,in,out,fmt,args...) \
10 nf_log_packet(AF_INET6,pskb,hooknum,in,out,fmt,##args)
11
12#define nf_log_ip6(pfh,len,fmt,args...) \
13 nf_log(AF_INET6,pfh,len,fmt,##args)
14
15#define nf_ip6_log_register(logging) nf_log_register(AF_INET6,logging)
16#define nf_ip6_log_unregister(logging) nf_log_unregister(AF_INET6,logging)
17
18#endif /*__KERNEL__*/
19
20#endif /*__IP6_LOGGING_H*/
diff --git a/include/linux/netfilter_ipv6/ip6_tables.h b/include/linux/netfilter_ipv6/ip6_tables.h
new file mode 100644
index 000000000000..f1ce3b009853
--- /dev/null
+++ b/include/linux/netfilter_ipv6/ip6_tables.h
@@ -0,0 +1,461 @@
1/*
2 * 25-Jul-1998 Major changes to allow for ip chain table
3 *
4 * 3-Jan-2000 Named tables to allow packet selection for different uses.
5 */
6
7/*
8 * Format of an IP6 firewall descriptor
9 *
10 * src, dst, src_mask, dst_mask are always stored in network byte order.
11 * flags are stored in host byte order (of course).
12 * Port numbers are stored in HOST byte order.
13 */
14
15#ifndef _IP6_TABLES_H
16#define _IP6_TABLES_H
17
18#ifdef __KERNEL__
19#include <linux/if.h>
20#include <linux/types.h>
21#include <linux/in6.h>
22#include <linux/ipv6.h>
23#include <linux/skbuff.h>
24#endif
25#include <linux/compiler.h>
26#include <linux/netfilter_ipv6.h>
27
28#define IP6T_FUNCTION_MAXNAMELEN 30
29#define IP6T_TABLE_MAXNAMELEN 32
30
31/* Yes, Virginia, you have to zero the padding. */
32struct ip6t_ip6 {
33 /* Source and destination IP6 addr */
34 struct in6_addr src, dst;
35 /* Mask for src and dest IP6 addr */
36 struct in6_addr smsk, dmsk;
37 char iniface[IFNAMSIZ], outiface[IFNAMSIZ];
38 unsigned char iniface_mask[IFNAMSIZ], outiface_mask[IFNAMSIZ];
39
40 /* ARGH, HopByHop uses 0, so can't do 0 = ANY,
41 instead IP6T_F_NOPROTO must be set */
42 u_int16_t proto;
43 /* TOS to match iff flags & IP6T_F_TOS */
44 u_int8_t tos;
45
46 /* Flags word */
47 u_int8_t flags;
48 /* Inverse flags */
49 u_int8_t invflags;
50};
51
52/* FIXME: If alignment in kernel different from userspace? --RR */
53struct ip6t_entry_match
54{
55 union {
56 struct {
57 u_int16_t match_size;
58
59 /* Used by userspace */
60 char name[IP6T_FUNCTION_MAXNAMELEN];
61 } user;
62 struct {
63 u_int16_t match_size;
64
65 /* Used inside the kernel */
66 struct ip6t_match *match;
67 } kernel;
68
69 /* Total length */
70 u_int16_t match_size;
71 } u;
72
73 unsigned char data[0];
74};
75
76struct ip6t_entry_target
77{
78 union {
79 struct {
80 u_int16_t target_size;
81
82 /* Used by userspace */
83 char name[IP6T_FUNCTION_MAXNAMELEN];
84 } user;
85 struct {
86 u_int16_t target_size;
87
88 /* Used inside the kernel */
89 struct ip6t_target *target;
90 } kernel;
91
92 /* Total length */
93 u_int16_t target_size;
94 } u;
95
96 unsigned char data[0];
97};
98
99struct ip6t_standard_target
100{
101 struct ip6t_entry_target target;
102 int verdict;
103};
104
105struct ip6t_counters
106{
107 u_int64_t pcnt, bcnt; /* Packet and byte counters */
108};
109
110/* Values for "flag" field in struct ip6t_ip6 (general ip6 structure). */
111#define IP6T_F_PROTO 0x01 /* Set if rule cares about upper
112 protocols */
113#define IP6T_F_TOS 0x02 /* Match the TOS. */
114#define IP6T_F_MASK 0x03 /* All possible flag bits mask. */
115
116/* Values for "inv" field in struct ip6t_ip6. */
117#define IP6T_INV_VIA_IN 0x01 /* Invert the sense of IN IFACE. */
118#define IP6T_INV_VIA_OUT 0x02 /* Invert the sense of OUT IFACE */
119#define IP6T_INV_TOS 0x04 /* Invert the sense of TOS. */
120#define IP6T_INV_SRCIP 0x08 /* Invert the sense of SRC IP. */
121#define IP6T_INV_DSTIP 0x10 /* Invert the sense of DST OP. */
122#define IP6T_INV_FRAG 0x20 /* Invert the sense of FRAG. */
123#define IP6T_INV_PROTO 0x40 /* Invert the sense of PROTO. */
124#define IP6T_INV_MASK 0x7F /* All possible flag bits mask. */
125
126/* This structure defines each of the firewall rules. Consists of 3
127 parts which are 1) general IP header stuff 2) match specific
128 stuff 3) the target to perform if the rule matches */
129struct ip6t_entry
130{
131 struct ip6t_ip6 ipv6;
132
133 /* Mark with fields that we care about. */
134 unsigned int nfcache;
135
136 /* Size of ipt_entry + matches */
137 u_int16_t target_offset;
138 /* Size of ipt_entry + matches + target */
139 u_int16_t next_offset;
140
141 /* Back pointer */
142 unsigned int comefrom;
143
144 /* Packet and byte counters. */
145 struct ip6t_counters counters;
146
147 /* The matches (if any), then the target. */
148 unsigned char elems[0];
149};
150
151/*
152 * New IP firewall options for [gs]etsockopt at the RAW IP level.
153 * Unlike BSD Linux inherits IP options so you don't have to use
154 * a raw socket for this. Instead we check rights in the calls. */
155#define IP6T_BASE_CTL 64 /* base for firewall socket options */
156
157#define IP6T_SO_SET_REPLACE (IP6T_BASE_CTL)
158#define IP6T_SO_SET_ADD_COUNTERS (IP6T_BASE_CTL + 1)
159#define IP6T_SO_SET_MAX IP6T_SO_SET_ADD_COUNTERS
160
161#define IP6T_SO_GET_INFO (IP6T_BASE_CTL)
162#define IP6T_SO_GET_ENTRIES (IP6T_BASE_CTL + 1)
163#define IP6T_SO_GET_MAX IP6T_SO_GET_ENTRIES
164
165/* CONTINUE verdict for targets */
166#define IP6T_CONTINUE 0xFFFFFFFF
167
168/* For standard target */
169#define IP6T_RETURN (-NF_REPEAT - 1)
170
171/* TCP matching stuff */
172struct ip6t_tcp
173{
174 u_int16_t spts[2]; /* Source port range. */
175 u_int16_t dpts[2]; /* Destination port range. */
176 u_int8_t option; /* TCP Option iff non-zero*/
177 u_int8_t flg_mask; /* TCP flags mask byte */
178 u_int8_t flg_cmp; /* TCP flags compare byte */
179 u_int8_t invflags; /* Inverse flags */
180};
181
182/* Values for "inv" field in struct ipt_tcp. */
183#define IP6T_TCP_INV_SRCPT 0x01 /* Invert the sense of source ports. */
184#define IP6T_TCP_INV_DSTPT 0x02 /* Invert the sense of dest ports. */
185#define IP6T_TCP_INV_FLAGS 0x04 /* Invert the sense of TCP flags. */
186#define IP6T_TCP_INV_OPTION 0x08 /* Invert the sense of option test. */
187#define IP6T_TCP_INV_MASK 0x0F /* All possible flags. */
188
189/* UDP matching stuff */
190struct ip6t_udp
191{
192 u_int16_t spts[2]; /* Source port range. */
193 u_int16_t dpts[2]; /* Destination port range. */
194 u_int8_t invflags; /* Inverse flags */
195};
196
197/* Values for "invflags" field in struct ipt_udp. */
198#define IP6T_UDP_INV_SRCPT 0x01 /* Invert the sense of source ports. */
199#define IP6T_UDP_INV_DSTPT 0x02 /* Invert the sense of dest ports. */
200#define IP6T_UDP_INV_MASK 0x03 /* All possible flags. */
201
202/* ICMP matching stuff */
203struct ip6t_icmp
204{
205 u_int8_t type; /* type to match */
206 u_int8_t code[2]; /* range of code */
207 u_int8_t invflags; /* Inverse flags */
208};
209
210/* Values for "inv" field for struct ipt_icmp. */
211#define IP6T_ICMP_INV 0x01 /* Invert the sense of type/code test */
212
213/* The argument to IP6T_SO_GET_INFO */
214struct ip6t_getinfo
215{
216 /* Which table: caller fills this in. */
217 char name[IP6T_TABLE_MAXNAMELEN];
218
219 /* Kernel fills these in. */
220 /* Which hook entry points are valid: bitmask */
221 unsigned int valid_hooks;
222
223 /* Hook entry points: one per netfilter hook. */
224 unsigned int hook_entry[NF_IP6_NUMHOOKS];
225
226 /* Underflow points. */
227 unsigned int underflow[NF_IP6_NUMHOOKS];
228
229 /* Number of entries */
230 unsigned int num_entries;
231
232 /* Size of entries. */
233 unsigned int size;
234};
235
236/* The argument to IP6T_SO_SET_REPLACE. */
237struct ip6t_replace
238{
239 /* Which table. */
240 char name[IP6T_TABLE_MAXNAMELEN];
241
242 /* Which hook entry points are valid: bitmask. You can't
243 change this. */
244 unsigned int valid_hooks;
245
246 /* Number of entries */
247 unsigned int num_entries;
248
249 /* Total size of new entries */
250 unsigned int size;
251
252 /* Hook entry points. */
253 unsigned int hook_entry[NF_IP6_NUMHOOKS];
254
255 /* Underflow points. */
256 unsigned int underflow[NF_IP6_NUMHOOKS];
257
258 /* Information about old entries: */
259 /* Number of counters (must be equal to current number of entries). */
260 unsigned int num_counters;
261 /* The old entries' counters. */
262 struct ip6t_counters __user *counters;
263
264 /* The entries (hang off end: not really an array). */
265 struct ip6t_entry entries[0];
266};
267
268/* The argument to IP6T_SO_ADD_COUNTERS. */
269struct ip6t_counters_info
270{
271 /* Which table. */
272 char name[IP6T_TABLE_MAXNAMELEN];
273
274 unsigned int num_counters;
275
276 /* The counters (actually `number' of these). */
277 struct ip6t_counters counters[0];
278};
279
280/* The argument to IP6T_SO_GET_ENTRIES. */
281struct ip6t_get_entries
282{
283 /* Which table: user fills this in. */
284 char name[IP6T_TABLE_MAXNAMELEN];
285
286 /* User fills this in: total entry size. */
287 unsigned int size;
288
289 /* The entries. */
290 struct ip6t_entry entrytable[0];
291};
292
293/* Standard return verdict, or do jump. */
294#define IP6T_STANDARD_TARGET ""
295/* Error verdict. */
296#define IP6T_ERROR_TARGET "ERROR"
297
298/* Helper functions */
299static __inline__ struct ip6t_entry_target *
300ip6t_get_target(struct ip6t_entry *e)
301{
302 return (void *)e + e->target_offset;
303}
304
305/* fn returns 0 to continue iteration */
306#define IP6T_MATCH_ITERATE(e, fn, args...) \
307({ \
308 unsigned int __i; \
309 int __ret = 0; \
310 struct ip6t_entry_match *__m; \
311 \
312 for (__i = sizeof(struct ip6t_entry); \
313 __i < (e)->target_offset; \
314 __i += __m->u.match_size) { \
315 __m = (void *)(e) + __i; \
316 \
317 __ret = fn(__m , ## args); \
318 if (__ret != 0) \
319 break; \
320 } \
321 __ret; \
322})
323
324/* fn returns 0 to continue iteration */
325#define IP6T_ENTRY_ITERATE(entries, size, fn, args...) \
326({ \
327 unsigned int __i; \
328 int __ret = 0; \
329 struct ip6t_entry *__e; \
330 \
331 for (__i = 0; __i < (size); __i += __e->next_offset) { \
332 __e = (void *)(entries) + __i; \
333 \
334 __ret = fn(__e , ## args); \
335 if (__ret != 0) \
336 break; \
337 } \
338 __ret; \
339})
340
341/*
342 * Main firewall chains definitions and global var's definitions.
343 */
344
345#ifdef __KERNEL__
346
347#include <linux/init.h>
348extern void ip6t_init(void) __init;
349
350struct ip6t_match
351{
352 struct list_head list;
353
354 const char name[IP6T_FUNCTION_MAXNAMELEN];
355
356 /* Return true or false: return FALSE and set *hotdrop = 1 to
357 force immediate packet drop. */
358 /* Arguments changed since 2.6.9, as this must now handle
359 non-linear skb, using skb_header_pointer and
360 skb_ip_make_writable. */
361 int (*match)(const struct sk_buff *skb,
362 const struct net_device *in,
363 const struct net_device *out,
364 const void *matchinfo,
365 int offset,
366 unsigned int protoff,
367 int *hotdrop);
368
369 /* Called when user tries to insert an entry of this type. */
370 /* Should return true or false. */
371 int (*checkentry)(const char *tablename,
372 const struct ip6t_ip6 *ip,
373 void *matchinfo,
374 unsigned int matchinfosize,
375 unsigned int hook_mask);
376
377 /* Called when entry of this type deleted. */
378 void (*destroy)(void *matchinfo, unsigned int matchinfosize);
379
380 /* Set this to THIS_MODULE if you are a module, otherwise NULL */
381 struct module *me;
382};
383
384/* Registration hooks for targets. */
385struct ip6t_target
386{
387 struct list_head list;
388
389 const char name[IP6T_FUNCTION_MAXNAMELEN];
390
391 /* Returns verdict. Argument order changed since 2.6.9, as this
392 must now handle non-linear skbs, using skb_copy_bits and
393 skb_ip_make_writable. */
394 unsigned int (*target)(struct sk_buff **pskb,
395 const struct net_device *in,
396 const struct net_device *out,
397 unsigned int hooknum,
398 const void *targinfo,
399 void *userdata);
400
401 /* Called when user tries to insert an entry of this type:
402 hook_mask is a bitmask of hooks from which it can be
403 called. */
404 /* Should return true or false. */
405 int (*checkentry)(const char *tablename,
406 const struct ip6t_entry *e,
407 void *targinfo,
408 unsigned int targinfosize,
409 unsigned int hook_mask);
410
411 /* Called when entry of this type deleted. */
412 void (*destroy)(void *targinfo, unsigned int targinfosize);
413
414 /* Set this to THIS_MODULE if you are a module, otherwise NULL */
415 struct module *me;
416};
417
418extern int ip6t_register_target(struct ip6t_target *target);
419extern void ip6t_unregister_target(struct ip6t_target *target);
420
421extern int ip6t_register_match(struct ip6t_match *match);
422extern void ip6t_unregister_match(struct ip6t_match *match);
423
424/* Furniture shopping... */
425struct ip6t_table
426{
427 struct list_head list;
428
429 /* A unique name... */
430 char name[IP6T_TABLE_MAXNAMELEN];
431
432 /* What hooks you will enter on */
433 unsigned int valid_hooks;
434
435 /* Lock for the curtain */
436 rwlock_t lock;
437
438 /* Man behind the curtain... */
439 struct ip6t_table_info *private;
440
441 /* Set this to THIS_MODULE if you are a module, otherwise NULL */
442 struct module *me;
443};
444
445extern int ip6t_register_table(struct ip6t_table *table,
446 const struct ip6t_replace *repl);
447extern void ip6t_unregister_table(struct ip6t_table *table);
448extern unsigned int ip6t_do_table(struct sk_buff **pskb,
449 unsigned int hook,
450 const struct net_device *in,
451 const struct net_device *out,
452 struct ip6t_table *table,
453 void *userdata);
454
455/* Check for an extension */
456extern int ip6t_ext_hdr(u8 nexthdr);
457
458#define IP6T_ALIGN(s) (((s) + (__alignof__(struct ip6t_entry)-1)) & ~(__alignof__(struct ip6t_entry)-1))
459
460#endif /*__KERNEL__*/
461#endif /* _IP6_TABLES_H */
diff --git a/include/linux/netfilter_ipv6/ip6t_LOG.h b/include/linux/netfilter_ipv6/ip6t_LOG.h
new file mode 100644
index 000000000000..42996a43bb39
--- /dev/null
+++ b/include/linux/netfilter_ipv6/ip6t_LOG.h
@@ -0,0 +1,16 @@
1#ifndef _IP6T_LOG_H
2#define _IP6T_LOG_H
3
4#define IP6T_LOG_TCPSEQ 0x01 /* Log TCP sequence numbers */
5#define IP6T_LOG_TCPOPT 0x02 /* Log TCP options */
6#define IP6T_LOG_IPOPT 0x04 /* Log IP options */
7#define IP6T_LOG_UID 0x08 /* Log UID owning local socket */
8#define IP6T_LOG_MASK 0x0f
9
10struct ip6t_log_info {
11 unsigned char level;
12 unsigned char logflags;
13 char prefix[30];
14};
15
16#endif /*_IPT_LOG_H*/
diff --git a/include/linux/netfilter_ipv6/ip6t_MARK.h b/include/linux/netfilter_ipv6/ip6t_MARK.h
new file mode 100644
index 000000000000..7ade8d8f5246
--- /dev/null
+++ b/include/linux/netfilter_ipv6/ip6t_MARK.h
@@ -0,0 +1,8 @@
1#ifndef _IP6T_MARK_H_target
2#define _IP6T_MARK_H_target
3
4struct ip6t_mark_target_info {
5 unsigned long mark;
6};
7
8#endif /*_IPT_MARK_H_target*/
diff --git a/include/linux/netfilter_ipv6/ip6t_ah.h b/include/linux/netfilter_ipv6/ip6t_ah.h
new file mode 100644
index 000000000000..c4f0793a0a98
--- /dev/null
+++ b/include/linux/netfilter_ipv6/ip6t_ah.h
@@ -0,0 +1,30 @@
1#ifndef _IP6T_AH_H
2#define _IP6T_AH_H
3
4struct ip6t_ah
5{
6 u_int32_t spis[2]; /* Security Parameter Index */
7 u_int32_t hdrlen; /* Header Length */
8 u_int8_t hdrres; /* Test of the Reserved Filed */
9 u_int8_t invflags; /* Inverse flags */
10};
11
12#define IP6T_AH_SPI 0x01
13#define IP6T_AH_LEN 0x02
14#define IP6T_AH_RES 0x04
15
16/* Values for "invflags" field in struct ip6t_ah. */
17#define IP6T_AH_INV_SPI 0x01 /* Invert the sense of spi. */
18#define IP6T_AH_INV_LEN 0x02 /* Invert the sense of length. */
19#define IP6T_AH_INV_MASK 0x03 /* All possible flags. */
20
21#define MASK_HOPOPTS 128
22#define MASK_DSTOPTS 64
23#define MASK_ROUTING 32
24#define MASK_FRAGMENT 16
25#define MASK_AH 8
26#define MASK_ESP 4
27#define MASK_NONE 2
28#define MASK_PROTO 1
29
30#endif /*_IP6T_AH_H*/
diff --git a/include/linux/netfilter_ipv6/ip6t_esp.h b/include/linux/netfilter_ipv6/ip6t_esp.h
new file mode 100644
index 000000000000..01142b98a231
--- /dev/null
+++ b/include/linux/netfilter_ipv6/ip6t_esp.h
@@ -0,0 +1,23 @@
1#ifndef _IP6T_ESP_H
2#define _IP6T_ESP_H
3
4struct ip6t_esp
5{
6 u_int32_t spis[2]; /* Security Parameter Index */
7 u_int8_t invflags; /* Inverse flags */
8};
9
10#define MASK_HOPOPTS 128
11#define MASK_DSTOPTS 64
12#define MASK_ROUTING 32
13#define MASK_FRAGMENT 16
14#define MASK_AH 8
15#define MASK_ESP 4
16#define MASK_NONE 2
17#define MASK_PROTO 1
18
19/* Values for "invflags" field in struct ip6t_esp. */
20#define IP6T_ESP_INV_SPI 0x01 /* Invert the sense of spi. */
21#define IP6T_ESP_INV_MASK 0x01 /* All possible flags. */
22
23#endif /*_IP6T_ESP_H*/
diff --git a/include/linux/netfilter_ipv6/ip6t_frag.h b/include/linux/netfilter_ipv6/ip6t_frag.h
new file mode 100644
index 000000000000..449a57eca7dd
--- /dev/null
+++ b/include/linux/netfilter_ipv6/ip6t_frag.h
@@ -0,0 +1,33 @@
1#ifndef _IP6T_FRAG_H
2#define _IP6T_FRAG_H
3
4struct ip6t_frag
5{
6 u_int32_t ids[2]; /* Security Parameter Index */
7 u_int32_t hdrlen; /* Header Length */
8 u_int8_t flags; /* */
9 u_int8_t invflags; /* Inverse flags */
10};
11
12#define IP6T_FRAG_IDS 0x01
13#define IP6T_FRAG_LEN 0x02
14#define IP6T_FRAG_RES 0x04
15#define IP6T_FRAG_FST 0x08
16#define IP6T_FRAG_MF 0x10
17#define IP6T_FRAG_NMF 0x20
18
19/* Values for "invflags" field in struct ip6t_frag. */
20#define IP6T_FRAG_INV_IDS 0x01 /* Invert the sense of ids. */
21#define IP6T_FRAG_INV_LEN 0x02 /* Invert the sense of length. */
22#define IP6T_FRAG_INV_MASK 0x03 /* All possible flags. */
23
24#define MASK_HOPOPTS 128
25#define MASK_DSTOPTS 64
26#define MASK_ROUTING 32
27#define MASK_FRAGMENT 16
28#define MASK_AH 8
29#define MASK_ESP 4
30#define MASK_NONE 2
31#define MASK_PROTO 1
32
33#endif /*_IP6T_FRAG_H*/
diff --git a/include/linux/netfilter_ipv6/ip6t_hl.h b/include/linux/netfilter_ipv6/ip6t_hl.h
new file mode 100644
index 000000000000..5ef91b8319a8
--- /dev/null
+++ b/include/linux/netfilter_ipv6/ip6t_hl.h
@@ -0,0 +1,22 @@
1/* ip6tables module for matching the Hop Limit value
2 * Maciej Soltysiak <solt@dns.toxicfilms.tv>
3 * Based on HW's ttl module */
4
5#ifndef _IP6T_HL_H
6#define _IP6T_HL_H
7
8enum {
9 IP6T_HL_EQ = 0, /* equals */
10 IP6T_HL_NE, /* not equals */
11 IP6T_HL_LT, /* less than */
12 IP6T_HL_GT, /* greater than */
13};
14
15
16struct ip6t_hl_info {
17 u_int8_t mode;
18 u_int8_t hop_limit;
19};
20
21
22#endif
diff --git a/include/linux/netfilter_ipv6/ip6t_ipv6header.h b/include/linux/netfilter_ipv6/ip6t_ipv6header.h
new file mode 100644
index 000000000000..51c53fc9c44a
--- /dev/null
+++ b/include/linux/netfilter_ipv6/ip6t_ipv6header.h
@@ -0,0 +1,27 @@
1/* ipv6header match - matches IPv6 packets based
2on whether they contain certain headers */
3
4/* Original idea: Brad Chapman
5 * Rewritten by: Andras Kis-Szabo <kisza@sch.bme.hu> */
6
7
8#ifndef __IPV6HEADER_H
9#define __IPV6HEADER_H
10
11struct ip6t_ipv6header_info
12{
13 u_int8_t matchflags;
14 u_int8_t invflags;
15 u_int8_t modeflag;
16};
17
18#define MASK_HOPOPTS 128
19#define MASK_DSTOPTS 64
20#define MASK_ROUTING 32
21#define MASK_FRAGMENT 16
22#define MASK_AH 8
23#define MASK_ESP 4
24#define MASK_NONE 2
25#define MASK_PROTO 1
26
27#endif /* __IPV6HEADER_H */
diff --git a/include/linux/netfilter_ipv6/ip6t_length.h b/include/linux/netfilter_ipv6/ip6t_length.h
new file mode 100644
index 000000000000..7fc09f9f9d63
--- /dev/null
+++ b/include/linux/netfilter_ipv6/ip6t_length.h
@@ -0,0 +1,10 @@
1#ifndef _IP6T_LENGTH_H
2#define _IP6T_LENGTH_H
3
4struct ip6t_length_info {
5 u_int16_t min, max;
6 u_int8_t invert;
7};
8
9#endif /*_IP6T_LENGTH_H*/
10
diff --git a/include/linux/netfilter_ipv6/ip6t_limit.h b/include/linux/netfilter_ipv6/ip6t_limit.h
new file mode 100644
index 000000000000..f2866e50f3b4
--- /dev/null
+++ b/include/linux/netfilter_ipv6/ip6t_limit.h
@@ -0,0 +1,21 @@
1#ifndef _IP6T_RATE_H
2#define _IP6T_RATE_H
3
4/* timings are in milliseconds. */
5#define IP6T_LIMIT_SCALE 10000
6
7/* 1/10,000 sec period => max of 10,000/sec. Min rate is then 429490
8 seconds, or one every 59 hours. */
9struct ip6t_rateinfo {
10 u_int32_t avg; /* Average secs between packets * scale */
11 u_int32_t burst; /* Period multiplier for upper limit. */
12
13 /* Used internally by the kernel */
14 unsigned long prev;
15 u_int32_t credit;
16 u_int32_t credit_cap, cost;
17
18 /* Ugly, ugly fucker. */
19 struct ip6t_rateinfo *master;
20};
21#endif /*_IPT_RATE_H*/
diff --git a/include/linux/netfilter_ipv6/ip6t_mac.h b/include/linux/netfilter_ipv6/ip6t_mac.h
new file mode 100644
index 000000000000..87c088c21848
--- /dev/null
+++ b/include/linux/netfilter_ipv6/ip6t_mac.h
@@ -0,0 +1,8 @@
1#ifndef _IP6T_MAC_H
2#define _IP6T_MAC_H
3
4struct ip6t_mac_info {
5 unsigned char srcaddr[ETH_ALEN];
6 int invert;
7};
8#endif /*_IPT_MAC_H*/
diff --git a/include/linux/netfilter_ipv6/ip6t_mark.h b/include/linux/netfilter_ipv6/ip6t_mark.h
new file mode 100644
index 000000000000..a734441e1c19
--- /dev/null
+++ b/include/linux/netfilter_ipv6/ip6t_mark.h
@@ -0,0 +1,9 @@
1#ifndef _IP6T_MARK_H
2#define _IP6T_MARK_H
3
4struct ip6t_mark_info {
5 unsigned long mark, mask;
6 u_int8_t invert;
7};
8
9#endif /*_IPT_MARK_H*/
diff --git a/include/linux/netfilter_ipv6/ip6t_multiport.h b/include/linux/netfilter_ipv6/ip6t_multiport.h
new file mode 100644
index 000000000000..efe4954a8681
--- /dev/null
+++ b/include/linux/netfilter_ipv6/ip6t_multiport.h
@@ -0,0 +1,21 @@
1#ifndef _IP6T_MULTIPORT_H
2#define _IP6T_MULTIPORT_H
3#include <linux/netfilter_ipv6/ip6_tables.h>
4
5enum ip6t_multiport_flags
6{
7 IP6T_MULTIPORT_SOURCE,
8 IP6T_MULTIPORT_DESTINATION,
9 IP6T_MULTIPORT_EITHER
10};
11
12#define IP6T_MULTI_PORTS 15
13
14/* Must fit inside union ip6t_matchinfo: 16 bytes */
15struct ip6t_multiport
16{
17 u_int8_t flags; /* Type of comparison */
18 u_int8_t count; /* Number of ports */
19 u_int16_t ports[IP6T_MULTI_PORTS]; /* Ports */
20};
21#endif /*_IPT_MULTIPORT_H*/
diff --git a/include/linux/netfilter_ipv6/ip6t_opts.h b/include/linux/netfilter_ipv6/ip6t_opts.h
new file mode 100644
index 000000000000..e259b6275bd2
--- /dev/null
+++ b/include/linux/netfilter_ipv6/ip6t_opts.h
@@ -0,0 +1,32 @@
1#ifndef _IP6T_OPTS_H
2#define _IP6T_OPTS_H
3
4#define IP6T_OPTS_OPTSNR 16
5
6struct ip6t_opts
7{
8 u_int32_t hdrlen; /* Header Length */
9 u_int8_t flags; /* */
10 u_int8_t invflags; /* Inverse flags */
11 u_int16_t opts[IP6T_OPTS_OPTSNR]; /* opts */
12 u_int8_t optsnr; /* Nr of OPts */
13};
14
15#define IP6T_OPTS_LEN 0x01
16#define IP6T_OPTS_OPTS 0x02
17#define IP6T_OPTS_NSTRICT 0x04
18
19/* Values for "invflags" field in struct ip6t_rt. */
20#define IP6T_OPTS_INV_LEN 0x01 /* Invert the sense of length. */
21#define IP6T_OPTS_INV_MASK 0x01 /* All possible flags. */
22
23#define MASK_HOPOPTS 128
24#define MASK_DSTOPTS 64
25#define MASK_ROUTING 32
26#define MASK_FRAGMENT 16
27#define MASK_AH 8
28#define MASK_ESP 4
29#define MASK_NONE 2
30#define MASK_PROTO 1
31
32#endif /*_IP6T_OPTS_H*/
diff --git a/include/linux/netfilter_ipv6/ip6t_owner.h b/include/linux/netfilter_ipv6/ip6t_owner.h
new file mode 100644
index 000000000000..19937da3d101
--- /dev/null
+++ b/include/linux/netfilter_ipv6/ip6t_owner.h
@@ -0,0 +1,18 @@
1#ifndef _IP6T_OWNER_H
2#define _IP6T_OWNER_H
3
4/* match and invert flags */
5#define IP6T_OWNER_UID 0x01
6#define IP6T_OWNER_GID 0x02
7#define IP6T_OWNER_PID 0x04
8#define IP6T_OWNER_SID 0x08
9
10struct ip6t_owner_info {
11 uid_t uid;
12 gid_t gid;
13 pid_t pid;
14 pid_t sid;
15 u_int8_t match, invert; /* flags */
16};
17
18#endif /*_IPT_OWNER_H*/
diff --git a/include/linux/netfilter_ipv6/ip6t_physdev.h b/include/linux/netfilter_ipv6/ip6t_physdev.h
new file mode 100644
index 000000000000..c234731cd66b
--- /dev/null
+++ b/include/linux/netfilter_ipv6/ip6t_physdev.h
@@ -0,0 +1,24 @@
1#ifndef _IP6T_PHYSDEV_H
2#define _IP6T_PHYSDEV_H
3
4#ifdef __KERNEL__
5#include <linux/if.h>
6#endif
7
8#define IP6T_PHYSDEV_OP_IN 0x01
9#define IP6T_PHYSDEV_OP_OUT 0x02
10#define IP6T_PHYSDEV_OP_BRIDGED 0x04
11#define IP6T_PHYSDEV_OP_ISIN 0x08
12#define IP6T_PHYSDEV_OP_ISOUT 0x10
13#define IP6T_PHYSDEV_OP_MASK (0x20 - 1)
14
15struct ip6t_physdev_info {
16 char physindev[IFNAMSIZ];
17 char in_mask[IFNAMSIZ];
18 char physoutdev[IFNAMSIZ];
19 char out_mask[IFNAMSIZ];
20 u_int8_t invert;
21 u_int8_t bitmask;
22};
23
24#endif /*_IP6T_PHYSDEV_H*/
diff --git a/include/linux/netfilter_ipv6/ip6t_rt.h b/include/linux/netfilter_ipv6/ip6t_rt.h
new file mode 100644
index 000000000000..f1070fbf2757
--- /dev/null
+++ b/include/linux/netfilter_ipv6/ip6t_rt.h
@@ -0,0 +1,42 @@
1#ifndef _IP6T_RT_H
2#define _IP6T_RT_H
3
4/*#include <linux/in6.h>*/
5
6#define IP6T_RT_HOPS 16
7
8struct ip6t_rt
9{
10 u_int32_t rt_type; /* Routing Type */
11 u_int32_t segsleft[2]; /* Segments Left */
12 u_int32_t hdrlen; /* Header Length */
13 u_int8_t flags; /* */
14 u_int8_t invflags; /* Inverse flags */
15 struct in6_addr addrs[IP6T_RT_HOPS]; /* Hops */
16 u_int8_t addrnr; /* Nr of Addresses */
17};
18
19#define IP6T_RT_TYP 0x01
20#define IP6T_RT_SGS 0x02
21#define IP6T_RT_LEN 0x04
22#define IP6T_RT_RES 0x08
23#define IP6T_RT_FST_MASK 0x30
24#define IP6T_RT_FST 0x10
25#define IP6T_RT_FST_NSTRICT 0x20
26
27/* Values for "invflags" field in struct ip6t_rt. */
28#define IP6T_RT_INV_TYP 0x01 /* Invert the sense of type. */
29#define IP6T_RT_INV_SGS 0x02 /* Invert the sense of Segments. */
30#define IP6T_RT_INV_LEN 0x04 /* Invert the sense of length. */
31#define IP6T_RT_INV_MASK 0x07 /* All possible flags. */
32
33#define MASK_HOPOPTS 128
34#define MASK_DSTOPTS 64
35#define MASK_ROUTING 32
36#define MASK_FRAGMENT 16
37#define MASK_AH 8
38#define MASK_ESP 4
39#define MASK_NONE 2
40#define MASK_PROTO 1
41
42#endif /*_IP6T_RT_H*/
diff --git a/include/linux/netfilter_logging.h b/include/linux/netfilter_logging.h
new file mode 100644
index 000000000000..562bb6aad4e1
--- /dev/null
+++ b/include/linux/netfilter_logging.h
@@ -0,0 +1,33 @@
1/* Internal logging interface, which relies on the real
2 LOG target modules */
3#ifndef __LINUX_NETFILTER_LOGGING_H
4#define __LINUX_NETFILTER_LOGGING_H
5
6#ifdef __KERNEL__
7#include <asm/atomic.h>
8
9struct nf_logging_t {
10 void (*nf_log_packet)(struct sk_buff **pskb,
11 unsigned int hooknum,
12 const struct net_device *in,
13 const struct net_device *out,
14 const char *prefix);
15 void (*nf_log)(char *pfh, size_t len,
16 const char *prefix);
17};
18
19extern void nf_log_register(int pf, const struct nf_logging_t *logging);
20extern void nf_log_unregister(int pf, const struct nf_logging_t *logging);
21
22extern void nf_log_packet(int pf,
23 struct sk_buff **pskb,
24 unsigned int hooknum,
25 const struct net_device *in,
26 const struct net_device *out,
27 const char *fmt, ...);
28extern void nf_log(int pf,
29 char *pfh, size_t len,
30 const char *fmt, ...);
31#endif /*__KERNEL__*/
32
33#endif /*__LINUX_NETFILTER_LOGGING_H*/
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
new file mode 100644
index 000000000000..f731abdc1a29
--- /dev/null
+++ b/include/linux/netlink.h
@@ -0,0 +1,188 @@
1#ifndef __LINUX_NETLINK_H
2#define __LINUX_NETLINK_H
3
4#include <linux/socket.h> /* for sa_family_t */
5#include <linux/types.h>
6
7#define NETLINK_ROUTE 0 /* Routing/device hook */
8#define NETLINK_SKIP 1 /* Reserved for ENskip */
9#define NETLINK_USERSOCK 2 /* Reserved for user mode socket protocols */
10#define NETLINK_FIREWALL 3 /* Firewalling hook */
11#define NETLINK_TCPDIAG 4 /* TCP socket monitoring */
12#define NETLINK_NFLOG 5 /* netfilter/iptables ULOG */
13#define NETLINK_XFRM 6 /* ipsec */
14#define NETLINK_SELINUX 7 /* SELinux event notifications */
15#define NETLINK_ARPD 8
16#define NETLINK_AUDIT 9 /* auditing */
17#define NETLINK_ROUTE6 11 /* af_inet6 route comm channel */
18#define NETLINK_IP6_FW 13
19#define NETLINK_DNRTMSG 14 /* DECnet routing messages */
20#define NETLINK_KOBJECT_UEVENT 15 /* Kernel messages to userspace */
21#define NETLINK_TAPBASE 16 /* 16 to 31 are ethertap */
22
23#define MAX_LINKS 32
24
25struct sockaddr_nl
26{
27 sa_family_t nl_family; /* AF_NETLINK */
28 unsigned short nl_pad; /* zero */
29 __u32 nl_pid; /* process pid */
30 __u32 nl_groups; /* multicast groups mask */
31};
32
33struct nlmsghdr
34{
35 __u32 nlmsg_len; /* Length of message including header */
36 __u16 nlmsg_type; /* Message content */
37 __u16 nlmsg_flags; /* Additional flags */
38 __u32 nlmsg_seq; /* Sequence number */
39 __u32 nlmsg_pid; /* Sending process PID */
40};
41
42/* Flags values */
43
44#define NLM_F_REQUEST 1 /* It is request message. */
45#define NLM_F_MULTI 2 /* Multipart message, terminated by NLMSG_DONE */
46#define NLM_F_ACK 4 /* Reply with ack, with zero or error code */
47#define NLM_F_ECHO 8 /* Echo this request */
48
49/* Modifiers to GET request */
50#define NLM_F_ROOT 0x100 /* specify tree root */
51#define NLM_F_MATCH 0x200 /* return all matching */
52#define NLM_F_ATOMIC 0x400 /* atomic GET */
53#define NLM_F_DUMP (NLM_F_ROOT|NLM_F_MATCH)
54
55/* Modifiers to NEW request */
56#define NLM_F_REPLACE 0x100 /* Override existing */
57#define NLM_F_EXCL 0x200 /* Do not touch, if it exists */
58#define NLM_F_CREATE 0x400 /* Create, if it does not exist */
59#define NLM_F_APPEND 0x800 /* Add to end of list */
60
61/*
62 4.4BSD ADD NLM_F_CREATE|NLM_F_EXCL
63 4.4BSD CHANGE NLM_F_REPLACE
64
65 True CHANGE NLM_F_CREATE|NLM_F_REPLACE
66 Append NLM_F_CREATE
67 Check NLM_F_EXCL
68 */
69
70#define NLMSG_ALIGNTO 4
71#define NLMSG_ALIGN(len) ( ((len)+NLMSG_ALIGNTO-1) & ~(NLMSG_ALIGNTO-1) )
72#define NLMSG_LENGTH(len) ((len)+NLMSG_ALIGN(sizeof(struct nlmsghdr)))
73#define NLMSG_SPACE(len) NLMSG_ALIGN(NLMSG_LENGTH(len))
74#define NLMSG_DATA(nlh) ((void*)(((char*)nlh) + NLMSG_LENGTH(0)))
75#define NLMSG_NEXT(nlh,len) ((len) -= NLMSG_ALIGN((nlh)->nlmsg_len), \
76 (struct nlmsghdr*)(((char*)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len)))
77#define NLMSG_OK(nlh,len) ((len) >= (int)sizeof(struct nlmsghdr) && \
78 (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \
79 (nlh)->nlmsg_len <= (len))
80#define NLMSG_PAYLOAD(nlh,len) ((nlh)->nlmsg_len - NLMSG_SPACE((len)))
81
82#define NLMSG_NOOP 0x1 /* Nothing. */
83#define NLMSG_ERROR 0x2 /* Error */
84#define NLMSG_DONE 0x3 /* End of a dump */
85#define NLMSG_OVERRUN 0x4 /* Data lost */
86
87struct nlmsgerr
88{
89 int error;
90 struct nlmsghdr msg;
91};
92
93#define NET_MAJOR 36 /* Major 36 is reserved for networking */
94
95enum {
96 NETLINK_UNCONNECTED = 0,
97 NETLINK_CONNECTED,
98};
99
100#ifdef __KERNEL__
101
102#include <linux/capability.h>
103#include <linux/skbuff.h>
104
105struct netlink_skb_parms
106{
107 struct ucred creds; /* Skb credentials */
108 __u32 pid;
109 __u32 groups;
110 __u32 dst_pid;
111 __u32 dst_groups;
112 kernel_cap_t eff_cap;
113};
114
115#define NETLINK_CB(skb) (*(struct netlink_skb_parms*)&((skb)->cb))
116#define NETLINK_CREDS(skb) (&NETLINK_CB((skb)).creds)
117
118
119extern struct sock *netlink_kernel_create(int unit, void (*input)(struct sock *sk, int len));
120extern void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err);
121extern int netlink_unicast(struct sock *ssk, struct sk_buff *skb, __u32 pid, int nonblock);
122extern int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, __u32 pid,
123 __u32 group, int allocation);
124extern void netlink_set_err(struct sock *ssk, __u32 pid, __u32 group, int code);
125extern int netlink_register_notifier(struct notifier_block *nb);
126extern int netlink_unregister_notifier(struct notifier_block *nb);
127
128/* finegrained unicast helpers: */
129struct sock *netlink_getsockbyfilp(struct file *filp);
130int netlink_attachskb(struct sock *sk, struct sk_buff *skb, int nonblock, long timeo);
131void netlink_detachskb(struct sock *sk, struct sk_buff *skb);
132int netlink_sendskb(struct sock *sk, struct sk_buff *skb, int protocol);
133
134/*
135 * skb should fit one page. This choice is good for headerless malloc.
136 */
137#define NLMSG_GOODORDER 0
138#define NLMSG_GOODSIZE (SKB_MAX_ORDER(0, NLMSG_GOODORDER))
139
140
141struct netlink_callback
142{
143 struct sk_buff *skb;
144 struct nlmsghdr *nlh;
145 int (*dump)(struct sk_buff * skb, struct netlink_callback *cb);
146 int (*done)(struct netlink_callback *cb);
147 int family;
148 long args[4];
149};
150
151struct netlink_notify
152{
153 int pid;
154 int protocol;
155};
156
157static __inline__ struct nlmsghdr *
158__nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len)
159{
160 struct nlmsghdr *nlh;
161 int size = NLMSG_LENGTH(len);
162
163 nlh = (struct nlmsghdr*)skb_put(skb, NLMSG_ALIGN(size));
164 nlh->nlmsg_type = type;
165 nlh->nlmsg_len = size;
166 nlh->nlmsg_flags = 0;
167 nlh->nlmsg_pid = pid;
168 nlh->nlmsg_seq = seq;
169 return nlh;
170}
171
172#define NLMSG_PUT(skb, pid, seq, type, len) \
173({ if (skb_tailroom(skb) < (int)NLMSG_SPACE(len)) goto nlmsg_failure; \
174 __nlmsg_put(skb, pid, seq, type, len); })
175
176extern int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
177 struct nlmsghdr *nlh,
178 int (*dump)(struct sk_buff *skb, struct netlink_callback*),
179 int (*done)(struct netlink_callback*));
180
181
182#define NL_NONROOT_RECV 0x1
183#define NL_NONROOT_SEND 0x2
184extern void netlink_set_nonroot(int protocol, unsigned flag);
185
186#endif /* __KERNEL__ */
187
188#endif /* __LINUX_NETLINK_H */
diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h
new file mode 100644
index 000000000000..c0d8b90c5202
--- /dev/null
+++ b/include/linux/netpoll.h
@@ -0,0 +1,67 @@
1/*
2 * Common code for low-level network console, dump, and debugger code
3 *
4 * Derived from netconsole, kgdb-over-ethernet, and netdump patches
5 */
6
7#ifndef _LINUX_NETPOLL_H
8#define _LINUX_NETPOLL_H
9
10#include <linux/netdevice.h>
11#include <linux/interrupt.h>
12#include <linux/list.h>
13
14struct netpoll;
15
16struct netpoll {
17 struct net_device *dev;
18 char dev_name[16], *name;
19 int rx_flags;
20 void (*rx_hook)(struct netpoll *, int, char *, int);
21 void (*drop)(struct sk_buff *skb);
22 u32 local_ip, remote_ip;
23 u16 local_port, remote_port;
24 unsigned char local_mac[6], remote_mac[6];
25 spinlock_t poll_lock;
26 int poll_owner;
27};
28
29void netpoll_poll(struct netpoll *np);
30void netpoll_send_udp(struct netpoll *np, const char *msg, int len);
31int netpoll_parse_options(struct netpoll *np, char *opt);
32int netpoll_setup(struct netpoll *np);
33int netpoll_trap(void);
34void netpoll_set_trap(int trap);
35void netpoll_cleanup(struct netpoll *np);
36int __netpoll_rx(struct sk_buff *skb);
37void netpoll_queue(struct sk_buff *skb);
38
39#ifdef CONFIG_NETPOLL
40static inline int netpoll_rx(struct sk_buff *skb)
41{
42 return skb->dev->np && skb->dev->np->rx_flags && __netpoll_rx(skb);
43}
44
45static inline void netpoll_poll_lock(struct net_device *dev)
46{
47 if (dev->np) {
48 spin_lock(&dev->np->poll_lock);
49 dev->np->poll_owner = smp_processor_id();
50 }
51}
52
53static inline void netpoll_poll_unlock(struct net_device *dev)
54{
55 if (dev->np) {
56 spin_unlock(&dev->np->poll_lock);
57 dev->np->poll_owner = -1;
58 }
59}
60
61#else
62#define netpoll_rx(a) 0
63#define netpoll_poll_lock(a)
64#define netpoll_poll_unlock(a)
65#endif
66
67#endif
diff --git a/include/linux/netrom.h b/include/linux/netrom.h
new file mode 100644
index 000000000000..6939b32f66a0
--- /dev/null
+++ b/include/linux/netrom.h
@@ -0,0 +1,34 @@
1/*
2 * These are the public elements of the Linux kernel NET/ROM implementation.
3 * For kernel AX.25 see the file ax25.h. This file requires ax25.h for the
4 * definition of the ax25_address structure.
5 */
6
7#ifndef NETROM_KERNEL_H
8#define NETROM_KERNEL_H
9
10#define NETROM_MTU 236
11
12#define NETROM_T1 1
13#define NETROM_T2 2
14#define NETROM_N2 3
15#define NETROM_T4 6
16#define NETROM_IDLE 7
17
18#define SIOCNRDECOBS (SIOCPROTOPRIVATE+2)
19
20struct nr_route_struct {
21#define NETROM_NEIGH 0
22#define NETROM_NODE 1
23 int type;
24 ax25_address callsign;
25 char device[16];
26 unsigned int quality;
27 char mnemonic[7];
28 ax25_address neighbour;
29 unsigned int obs_count;
30 unsigned int ndigis;
31 ax25_address digipeaters[AX25_MAX_DIGIS];
32};
33
34#endif
diff --git a/include/linux/nfs.h b/include/linux/nfs.h
new file mode 100644
index 000000000000..ca2ffa6ae1d5
--- /dev/null
+++ b/include/linux/nfs.h
@@ -0,0 +1,171 @@
1/*
2 * NFS protocol definitions
3 *
4 * This file contains constants mostly for Version 2 of the protocol,
5 * but also has a couple of NFSv3 bits in (notably the error codes).
6 */
7#ifndef _LINUX_NFS_H
8#define _LINUX_NFS_H
9
10#include <linux/sunrpc/msg_prot.h>
11#include <linux/string.h>
12
13#define NFS_PROGRAM 100003
14#define NFS_PORT 2049
15#define NFS_MAXDATA 8192
16#define NFS_MAXPATHLEN 1024
17#define NFS_MAXNAMLEN 255
18#define NFS_MAXGROUPS 16
19#define NFS_FHSIZE 32
20#define NFS_COOKIESIZE 4
21#define NFS_FIFO_DEV (-1)
22#define NFSMODE_FMT 0170000
23#define NFSMODE_DIR 0040000
24#define NFSMODE_CHR 0020000
25#define NFSMODE_BLK 0060000
26#define NFSMODE_REG 0100000
27#define NFSMODE_LNK 0120000
28#define NFSMODE_SOCK 0140000
29#define NFSMODE_FIFO 0010000
30
31#define NFS_MNT_PROGRAM 100005
32#define NFS_MNT_PORT 627
33
34/*
35 * NFS stats. The good thing with these values is that NFSv3 errors are
36 * a superset of NFSv2 errors (with the exception of NFSERR_WFLUSH which
37 * no-one uses anyway), so we can happily mix code as long as we make sure
38 * no NFSv3 errors are returned to NFSv2 clients.
39 * Error codes that have a `--' in the v2 column are not part of the
40 * standard, but seem to be widely used nevertheless.
41 */
42 enum nfs_stat {
43 NFS_OK = 0, /* v2 v3 v4 */
44 NFSERR_PERM = 1, /* v2 v3 v4 */
45 NFSERR_NOENT = 2, /* v2 v3 v4 */
46 NFSERR_IO = 5, /* v2 v3 v4 */
47 NFSERR_NXIO = 6, /* v2 v3 v4 */
48 NFSERR_EAGAIN = 11, /* v2 v3 */
49 NFSERR_ACCES = 13, /* v2 v3 v4 */
50 NFSERR_EXIST = 17, /* v2 v3 v4 */
51 NFSERR_XDEV = 18, /* v3 v4 */
52 NFSERR_NODEV = 19, /* v2 v3 v4 */
53 NFSERR_NOTDIR = 20, /* v2 v3 v4 */
54 NFSERR_ISDIR = 21, /* v2 v3 v4 */
55 NFSERR_INVAL = 22, /* v2 v3 v4 */
56 NFSERR_FBIG = 27, /* v2 v3 v4 */
57 NFSERR_NOSPC = 28, /* v2 v3 v4 */
58 NFSERR_ROFS = 30, /* v2 v3 v4 */
59 NFSERR_MLINK = 31, /* v3 v4 */
60 NFSERR_OPNOTSUPP = 45, /* v2 v3 */
61 NFSERR_NAMETOOLONG = 63, /* v2 v3 v4 */
62 NFSERR_NOTEMPTY = 66, /* v2 v3 v4 */
63 NFSERR_DQUOT = 69, /* v2 v3 v4 */
64 NFSERR_STALE = 70, /* v2 v3 v4 */
65 NFSERR_REMOTE = 71, /* v2 v3 */
66 NFSERR_WFLUSH = 99, /* v2 */
67 NFSERR_BADHANDLE = 10001, /* v3 v4 */
68 NFSERR_NOT_SYNC = 10002, /* v3 */
69 NFSERR_BAD_COOKIE = 10003, /* v3 v4 */
70 NFSERR_NOTSUPP = 10004, /* v3 v4 */
71 NFSERR_TOOSMALL = 10005, /* v3 v4 */
72 NFSERR_SERVERFAULT = 10006, /* v3 v4 */
73 NFSERR_BADTYPE = 10007, /* v3 v4 */
74 NFSERR_JUKEBOX = 10008, /* v3 v4 */
75 NFSERR_SAME = 10009, /* v4 */
76 NFSERR_DENIED = 10010, /* v4 */
77 NFSERR_EXPIRED = 10011, /* v4 */
78 NFSERR_LOCKED = 10012, /* v4 */
79 NFSERR_GRACE = 10013, /* v4 */
80 NFSERR_FHEXPIRED = 10014, /* v4 */
81 NFSERR_SHARE_DENIED = 10015, /* v4 */
82 NFSERR_WRONGSEC = 10016, /* v4 */
83 NFSERR_CLID_INUSE = 10017, /* v4 */
84 NFSERR_RESOURCE = 10018, /* v4 */
85 NFSERR_MOVED = 10019, /* v4 */
86 NFSERR_NOFILEHANDLE = 10020, /* v4 */
87 NFSERR_MINOR_VERS_MISMATCH = 10021, /* v4 */
88 NFSERR_STALE_CLIENTID = 10022, /* v4 */
89 NFSERR_STALE_STATEID = 10023, /* v4 */
90 NFSERR_OLD_STATEID = 10024, /* v4 */
91 NFSERR_BAD_STATEID = 10025, /* v4 */
92 NFSERR_BAD_SEQID = 10026, /* v4 */
93 NFSERR_NOT_SAME = 10027, /* v4 */
94 NFSERR_LOCK_RANGE = 10028, /* v4 */
95 NFSERR_SYMLINK = 10029, /* v4 */
96 NFSERR_RESTOREFH = 10030, /* v4 */
97 NFSERR_LEASE_MOVED = 10031, /* v4 */
98 NFSERR_ATTRNOTSUPP = 10032, /* v4 */
99 NFSERR_NO_GRACE = 10033, /* v4 */
100 NFSERR_RECLAIM_BAD = 10034, /* v4 */
101 NFSERR_RECLAIM_CONFLICT = 10035,/* v4 */
102 NFSERR_BAD_XDR = 10036, /* v4 */
103 NFSERR_LOCKS_HELD = 10037, /* v4 */
104 NFSERR_OPENMODE = 10038, /* v4 */
105 NFSERR_BADOWNER = 10039, /* v4 */
106 NFSERR_BADCHAR = 10040, /* v4 */
107 NFSERR_BADNAME = 10041, /* v4 */
108 NFSERR_BAD_RANGE = 10042, /* v4 */
109 NFSERR_LOCK_NOTSUPP = 10043, /* v4 */
110 NFSERR_OP_ILLEGAL = 10044, /* v4 */
111 NFSERR_DEADLOCK = 10045, /* v4 */
112 NFSERR_FILE_OPEN = 10046, /* v4 */
113 NFSERR_ADMIN_REVOKED = 10047, /* v4 */
114 NFSERR_CB_PATH_DOWN = 10048, /* v4 */
115 NFSERR_REPLAY_ME = 10049 /* v4 */
116};
117
118/* NFSv2 file types - beware, these are not the same in NFSv3 */
119
120enum nfs_ftype {
121 NFNON = 0,
122 NFREG = 1,
123 NFDIR = 2,
124 NFBLK = 3,
125 NFCHR = 4,
126 NFLNK = 5,
127 NFSOCK = 6,
128 NFBAD = 7,
129 NFFIFO = 8
130};
131
132#if defined(__KERNEL__)
133/*
134 * This is the kernel NFS client file handle representation
135 */
136#define NFS_MAXFHSIZE 128
137struct nfs_fh {
138 unsigned short size;
139 unsigned char data[NFS_MAXFHSIZE];
140};
141
142/*
143 * Returns a zero iff the size and data fields match.
144 * Checks only "size" bytes in the data field.
145 */
146static inline int nfs_compare_fh(const struct nfs_fh *a, const struct nfs_fh *b)
147{
148 return a->size != b->size || memcmp(a->data, b->data, a->size) != 0;
149}
150
151static inline void nfs_copy_fh(struct nfs_fh *target, const struct nfs_fh *source)
152{
153 target->size = source->size;
154 memcpy(target->data, source->data, source->size);
155}
156
157
158/*
159 * This is really a general kernel constant, but since nothing like
160 * this is defined in the kernel headers, I have to do it here.
161 */
162#define NFS_OFFSET_MAX ((__s64)((~(__u64)0) >> 1))
163
164
165enum nfs3_stable_how {
166 NFS_UNSTABLE = 0,
167 NFS_DATA_SYNC = 1,
168 NFS_FILE_SYNC = 2
169};
170#endif /* __KERNEL__ */
171#endif /* _LINUX_NFS_H */
diff --git a/include/linux/nfs2.h b/include/linux/nfs2.h
new file mode 100644
index 000000000000..0ed9517138fc
--- /dev/null
+++ b/include/linux/nfs2.h
@@ -0,0 +1,74 @@
1/*
2 * NFS protocol definitions
3 *
4 * This file contains constants for Version 2 of the protocol.
5 */
6#ifndef _LINUX_NFS2_H
7#define _LINUX_NFS2_H
8
9#define NFS2_PORT 2049
10#define NFS2_MAXDATA 8192
11#define NFS2_MAXPATHLEN 1024
12#define NFS2_MAXNAMLEN 255
13#define NFS2_MAXGROUPS 16
14#define NFS2_FHSIZE 32
15#define NFS2_COOKIESIZE 4
16#define NFS2_FIFO_DEV (-1)
17#define NFS2MODE_FMT 0170000
18#define NFS2MODE_DIR 0040000
19#define NFS2MODE_CHR 0020000
20#define NFS2MODE_BLK 0060000
21#define NFS2MODE_REG 0100000
22#define NFS2MODE_LNK 0120000
23#define NFS2MODE_SOCK 0140000
24#define NFS2MODE_FIFO 0010000
25
26
27/* NFSv2 file types - beware, these are not the same in NFSv3 */
28enum nfs2_ftype {
29 NF2NON = 0,
30 NF2REG = 1,
31 NF2DIR = 2,
32 NF2BLK = 3,
33 NF2CHR = 4,
34 NF2LNK = 5,
35 NF2SOCK = 6,
36 NF2BAD = 7,
37 NF2FIFO = 8
38};
39
40struct nfs2_fh {
41 char data[NFS2_FHSIZE];
42};
43
44/*
45 * Procedure numbers for NFSv2
46 */
47#define NFS2_VERSION 2
48#define NFSPROC_NULL 0
49#define NFSPROC_GETATTR 1
50#define NFSPROC_SETATTR 2
51#define NFSPROC_ROOT 3
52#define NFSPROC_LOOKUP 4
53#define NFSPROC_READLINK 5
54#define NFSPROC_READ 6
55#define NFSPROC_WRITECACHE 7
56#define NFSPROC_WRITE 8
57#define NFSPROC_CREATE 9
58#define NFSPROC_REMOVE 10
59#define NFSPROC_RENAME 11
60#define NFSPROC_LINK 12
61#define NFSPROC_SYMLINK 13
62#define NFSPROC_MKDIR 14
63#define NFSPROC_RMDIR 15
64#define NFSPROC_READDIR 16
65#define NFSPROC_STATFS 17
66
67#define NFS_MNT_PROGRAM 100005
68#define NFS_MNT_VERSION 1
69#define MNTPROC_NULL 0
70#define MNTPROC_MNT 1
71#define MNTPROC_UMNT 3
72#define MNTPROC_UMNTALL 4
73
74#endif /* _LINUX_NFS2_H */
diff --git a/include/linux/nfs3.h b/include/linux/nfs3.h
new file mode 100644
index 000000000000..7f11fa589207
--- /dev/null
+++ b/include/linux/nfs3.h
@@ -0,0 +1,105 @@
1/*
2 * NFSv3 protocol definitions
3 */
4#ifndef _LINUX_NFS3_H
5#define _LINUX_NFS3_H
6
7#define NFS3_PORT 2049
8#define NFS3_MAXDATA 32768
9#define NFS3_MAXPATHLEN PATH_MAX
10#define NFS3_MAXNAMLEN NAME_MAX
11#define NFS3_MAXGROUPS 16
12#define NFS3_FHSIZE 64
13#define NFS3_COOKIESIZE 4
14#define NFS3_FIFO_DEV (-1)
15#define NFS3MODE_FMT 0170000
16#define NFS3MODE_DIR 0040000
17#define NFS3MODE_CHR 0020000
18#define NFS3MODE_BLK 0060000
19#define NFS3MODE_REG 0100000
20#define NFS3MODE_LNK 0120000
21#define NFS3MODE_SOCK 0140000
22#define NFS3MODE_FIFO 0010000
23
24/* Flags for access() call */
25#define NFS3_ACCESS_READ 0x0001
26#define NFS3_ACCESS_LOOKUP 0x0002
27#define NFS3_ACCESS_MODIFY 0x0004
28#define NFS3_ACCESS_EXTEND 0x0008
29#define NFS3_ACCESS_DELETE 0x0010
30#define NFS3_ACCESS_EXECUTE 0x0020
31#define NFS3_ACCESS_FULL 0x003f
32
33/* Flags for create mode */
34enum nfs3_createmode {
35 NFS3_CREATE_UNCHECKED = 0,
36 NFS3_CREATE_GUARDED = 1,
37 NFS3_CREATE_EXCLUSIVE = 2
38};
39
40/* NFSv3 file system properties */
41#define NFS3_FSF_LINK 0x0001
42#define NFS3_FSF_SYMLINK 0x0002
43#define NFS3_FSF_HOMOGENEOUS 0x0008
44#define NFS3_FSF_CANSETTIME 0x0010
45/* Some shorthands. See fs/nfsd/nfs3proc.c */
46#define NFS3_FSF_DEFAULT 0x001B
47#define NFS3_FSF_BILLYBOY 0x0018
48#define NFS3_FSF_READONLY 0x0008
49
50enum nfs3_ftype {
51 NF3NON = 0,
52 NF3REG = 1,
53 NF3DIR = 2,
54 NF3BLK = 3,
55 NF3CHR = 4,
56 NF3LNK = 5,
57 NF3SOCK = 6,
58 NF3FIFO = 7, /* changed from NFSv2 (was 8) */
59 NF3BAD = 8
60};
61
62struct nfs3_fh {
63 unsigned short size;
64 unsigned char data[NFS3_FHSIZE];
65};
66
67#define NFS3_VERSION 3
68#define NFS3PROC_NULL 0
69#define NFS3PROC_GETATTR 1
70#define NFS3PROC_SETATTR 2
71#define NFS3PROC_LOOKUP 3
72#define NFS3PROC_ACCESS 4
73#define NFS3PROC_READLINK 5
74#define NFS3PROC_READ 6
75#define NFS3PROC_WRITE 7
76#define NFS3PROC_CREATE 8
77#define NFS3PROC_MKDIR 9
78#define NFS3PROC_SYMLINK 10
79#define NFS3PROC_MKNOD 11
80#define NFS3PROC_REMOVE 12
81#define NFS3PROC_RMDIR 13
82#define NFS3PROC_RENAME 14
83#define NFS3PROC_LINK 15
84#define NFS3PROC_READDIR 16
85#define NFS3PROC_READDIRPLUS 17
86#define NFS3PROC_FSSTAT 18
87#define NFS3PROC_FSINFO 19
88#define NFS3PROC_PATHCONF 20
89#define NFS3PROC_COMMIT 21
90
91#define NFS_MNT3_PROGRAM 100005
92#define NFS_MNT3_VERSION 3
93#define MOUNTPROC3_NULL 0
94#define MOUNTPROC3_MNT 1
95#define MOUNTPROC3_UMNT 3
96#define MOUNTPROC3_UMNTALL 4
97
98
99#if defined(__KERNEL__) || defined(NFS_NEED_KERNEL_TYPES)
100
101/* Number of 32bit words in post_op_attr */
102#define NFS3_POST_OP_ATTR_WORDS 22
103
104#endif /* __KERNEL__ */
105#endif /* _LINUX_NFS3_H */
diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h
new file mode 100644
index 000000000000..5ca8a8d8ccdf
--- /dev/null
+++ b/include/linux/nfs4.h
@@ -0,0 +1,394 @@
1/*
2 * include/linux/nfs4.h
3 *
4 * NFSv4 protocol definitions.
5 *
6 * Copyright (c) 2002 The Regents of the University of Michigan.
7 * All rights reserved.
8 *
9 * Kendrick Smith <kmsmith@umich.edu>
10 * Andy Adamson <andros@umich.edu>
11 */
12
13#ifndef _LINUX_NFS4_H
14#define _LINUX_NFS4_H
15
16#include <linux/types.h>
17#include <linux/list.h>
18
19#define NFS4_VERIFIER_SIZE 8
20#define NFS4_FHSIZE 128
21#define NFS4_MAXPATHLEN PATH_MAX
22#define NFS4_MAXNAMLEN NAME_MAX
23
24#define NFS4_ACCESS_READ 0x0001
25#define NFS4_ACCESS_LOOKUP 0x0002
26#define NFS4_ACCESS_MODIFY 0x0004
27#define NFS4_ACCESS_EXTEND 0x0008
28#define NFS4_ACCESS_DELETE 0x0010
29#define NFS4_ACCESS_EXECUTE 0x0020
30
31#define NFS4_FH_PERISTENT 0x0000
32#define NFS4_FH_NOEXPIRE_WITH_OPEN 0x0001
33#define NFS4_FH_VOLATILE_ANY 0x0002
34#define NFS4_FH_VOL_MIGRATION 0x0004
35#define NFS4_FH_VOL_RENAME 0x0008
36
37#define NFS4_OPEN_RESULT_CONFIRM 0x0002
38#define NFS4_OPEN_RESULT_LOCKTYPE_POSIX 0x0004
39
40#define NFS4_SHARE_ACCESS_READ 0x0001
41#define NFS4_SHARE_ACCESS_WRITE 0x0002
42#define NFS4_SHARE_ACCESS_BOTH 0x0003
43#define NFS4_SHARE_DENY_READ 0x0001
44#define NFS4_SHARE_DENY_WRITE 0x0002
45#define NFS4_SHARE_DENY_BOTH 0x0003
46
47#define NFS4_SET_TO_SERVER_TIME 0
48#define NFS4_SET_TO_CLIENT_TIME 1
49
50#define NFS4_ACE_ACCESS_ALLOWED_ACE_TYPE 0
51#define NFS4_ACE_ACCESS_DENIED_ACE_TYPE 1
52#define NFS4_ACE_SYSTEM_AUDIT_ACE_TYPE 2
53#define NFS4_ACE_SYSTEM_ALARM_ACE_TYPE 3
54
55#define ACL4_SUPPORT_ALLOW_ACL 0x01
56#define ACL4_SUPPORT_DENY_ACL 0x02
57#define ACL4_SUPPORT_AUDIT_ACL 0x04
58#define ACL4_SUPPORT_ALARM_ACL 0x08
59
60#define NFS4_ACE_FILE_INHERIT_ACE 0x00000001
61#define NFS4_ACE_DIRECTORY_INHERIT_ACE 0x00000002
62#define NFS4_ACE_NO_PROPAGATE_INHERIT_ACE 0x00000004
63#define NFS4_ACE_INHERIT_ONLY_ACE 0x00000008
64#define NFS4_ACE_SUCCESSFUL_ACCESS_ACE_FLAG 0x00000010
65#define NFS4_ACE_FAILED_ACCESS_ACE_FLAG 0x00000020
66#define NFS4_ACE_IDENTIFIER_GROUP 0x00000040
67#define NFS4_ACE_OWNER 0x00000080
68#define NFS4_ACE_GROUP 0x00000100
69#define NFS4_ACE_EVERYONE 0x00000200
70
71#define NFS4_ACE_READ_DATA 0x00000001
72#define NFS4_ACE_LIST_DIRECTORY 0x00000001
73#define NFS4_ACE_WRITE_DATA 0x00000002
74#define NFS4_ACE_ADD_FILE 0x00000002
75#define NFS4_ACE_APPEND_DATA 0x00000004
76#define NFS4_ACE_ADD_SUBDIRECTORY 0x00000004
77#define NFS4_ACE_READ_NAMED_ATTRS 0x00000008
78#define NFS4_ACE_WRITE_NAMED_ATTRS 0x00000010
79#define NFS4_ACE_EXECUTE 0x00000020
80#define NFS4_ACE_DELETE_CHILD 0x00000040
81#define NFS4_ACE_READ_ATTRIBUTES 0x00000080
82#define NFS4_ACE_WRITE_ATTRIBUTES 0x00000100
83#define NFS4_ACE_DELETE 0x00010000
84#define NFS4_ACE_READ_ACL 0x00020000
85#define NFS4_ACE_WRITE_ACL 0x00040000
86#define NFS4_ACE_WRITE_OWNER 0x00080000
87#define NFS4_ACE_SYNCHRONIZE 0x00100000
88#define NFS4_ACE_GENERIC_READ 0x00120081
89#define NFS4_ACE_GENERIC_WRITE 0x00160106
90#define NFS4_ACE_GENERIC_EXECUTE 0x001200A0
91#define NFS4_ACE_MASK_ALL 0x001F01FF
92
93enum nfs4_acl_whotype {
94 NFS4_ACL_WHO_NAMED = 0,
95 NFS4_ACL_WHO_OWNER,
96 NFS4_ACL_WHO_GROUP,
97 NFS4_ACL_WHO_EVERYONE,
98};
99
100struct nfs4_ace {
101 uint32_t type;
102 uint32_t flag;
103 uint32_t access_mask;
104 int whotype;
105 uid_t who;
106 struct list_head l_ace;
107};
108
109struct nfs4_acl {
110 uint32_t naces;
111 struct list_head ace_head;
112};
113
114typedef struct { char data[NFS4_VERIFIER_SIZE]; } nfs4_verifier;
115typedef struct { char data[16]; } nfs4_stateid;
116
117enum nfs_opnum4 {
118 OP_ACCESS = 3,
119 OP_CLOSE = 4,
120 OP_COMMIT = 5,
121 OP_CREATE = 6,
122 OP_DELEGPURGE = 7,
123 OP_DELEGRETURN = 8,
124 OP_GETATTR = 9,
125 OP_GETFH = 10,
126 OP_LINK = 11,
127 OP_LOCK = 12,
128 OP_LOCKT = 13,
129 OP_LOCKU = 14,
130 OP_LOOKUP = 15,
131 OP_LOOKUPP = 16,
132 OP_NVERIFY = 17,
133 OP_OPEN = 18,
134 OP_OPENATTR = 19,
135 OP_OPEN_CONFIRM = 20,
136 OP_OPEN_DOWNGRADE = 21,
137 OP_PUTFH = 22,
138 OP_PUTPUBFH = 23,
139 OP_PUTROOTFH = 24,
140 OP_READ = 25,
141 OP_READDIR = 26,
142 OP_READLINK = 27,
143 OP_REMOVE = 28,
144 OP_RENAME = 29,
145 OP_RENEW = 30,
146 OP_RESTOREFH = 31,
147 OP_SAVEFH = 32,
148 OP_SECINFO = 33,
149 OP_SETATTR = 34,
150 OP_SETCLIENTID = 35,
151 OP_SETCLIENTID_CONFIRM = 36,
152 OP_VERIFY = 37,
153 OP_WRITE = 38,
154 OP_RELEASE_LOCKOWNER = 39,
155 OP_ILLEGAL = 10044,
156};
157
158enum nfsstat4 {
159 NFS4_OK = 0,
160 NFS4ERR_PERM = 1,
161 NFS4ERR_NOENT = 2,
162 NFS4ERR_IO = 5,
163 NFS4ERR_NXIO = 6,
164 NFS4ERR_ACCESS = 13,
165 NFS4ERR_EXIST = 17,
166 NFS4ERR_XDEV = 18,
167 /* Unused/reserved 19 */
168 NFS4ERR_NOTDIR = 20,
169 NFS4ERR_ISDIR = 21,
170 NFS4ERR_INVAL = 22,
171 NFS4ERR_FBIG = 27,
172 NFS4ERR_NOSPC = 28,
173 NFS4ERR_ROFS = 30,
174 NFS4ERR_MLINK = 31,
175 NFS4ERR_NAMETOOLONG = 63,
176 NFS4ERR_NOTEMPTY = 66,
177 NFS4ERR_DQUOT = 69,
178 NFS4ERR_STALE = 70,
179 NFS4ERR_BADHANDLE = 10001,
180 NFS4ERR_BAD_COOKIE = 10003,
181 NFS4ERR_NOTSUPP = 10004,
182 NFS4ERR_TOOSMALL = 10005,
183 NFS4ERR_SERVERFAULT = 10006,
184 NFS4ERR_BADTYPE = 10007,
185 NFS4ERR_DELAY = 10008,
186 NFS4ERR_SAME = 10009,
187 NFS4ERR_DENIED = 10010,
188 NFS4ERR_EXPIRED = 10011,
189 NFS4ERR_LOCKED = 10012,
190 NFS4ERR_GRACE = 10013,
191 NFS4ERR_FHEXPIRED = 10014,
192 NFS4ERR_SHARE_DENIED = 10015,
193 NFS4ERR_WRONGSEC = 10016,
194 NFS4ERR_CLID_INUSE = 10017,
195 NFS4ERR_RESOURCE = 10018,
196 NFS4ERR_MOVED = 10019,
197 NFS4ERR_NOFILEHANDLE = 10020,
198 NFS4ERR_MINOR_VERS_MISMATCH = 10021,
199 NFS4ERR_STALE_CLIENTID = 10022,
200 NFS4ERR_STALE_STATEID = 10023,
201 NFS4ERR_OLD_STATEID = 10024,
202 NFS4ERR_BAD_STATEID = 10025,
203 NFS4ERR_BAD_SEQID = 10026,
204 NFS4ERR_NOT_SAME = 10027,
205 NFS4ERR_LOCK_RANGE = 10028,
206 NFS4ERR_SYMLINK = 10029,
207 NFS4ERR_RESTOREFH = 10030,
208 NFS4ERR_LEASE_MOVED = 10031,
209 NFS4ERR_ATTRNOTSUPP = 10032,
210 NFS4ERR_NO_GRACE = 10033,
211 NFS4ERR_RECLAIM_BAD = 10034,
212 NFS4ERR_RECLAIM_CONFLICT = 10035,
213 NFS4ERR_BADXDR = 10036,
214 NFS4ERR_LOCKS_HELD = 10037,
215 NFS4ERR_OPENMODE = 10038,
216 NFS4ERR_BADOWNER = 10039,
217 NFS4ERR_BADCHAR = 10040,
218 NFS4ERR_BADNAME = 10041,
219 NFS4ERR_BAD_RANGE = 10042,
220 NFS4ERR_LOCK_NOTSUPP = 10043,
221 NFS4ERR_OP_ILLEGAL = 10044,
222 NFS4ERR_DEADLOCK = 10045,
223 NFS4ERR_FILE_OPEN = 10046,
224 NFS4ERR_ADMIN_REVOKED = 10047,
225 NFS4ERR_CB_PATH_DOWN = 10048
226};
227
228/*
229 * Note: NF4BAD is not actually part of the protocol; it is just used
230 * internally by nfsd.
231 */
232enum nfs_ftype4 {
233 NF4BAD = 0,
234 NF4REG = 1, /* Regular File */
235 NF4DIR = 2, /* Directory */
236 NF4BLK = 3, /* Special File - block device */
237 NF4CHR = 4, /* Special File - character device */
238 NF4LNK = 5, /* Symbolic Link */
239 NF4SOCK = 6, /* Special File - socket */
240 NF4FIFO = 7, /* Special File - fifo */
241 NF4ATTRDIR = 8, /* Attribute Directory */
242 NF4NAMEDATTR = 9 /* Named Attribute */
243};
244
245enum open_claim_type4 {
246 NFS4_OPEN_CLAIM_NULL = 0,
247 NFS4_OPEN_CLAIM_PREVIOUS = 1,
248 NFS4_OPEN_CLAIM_DELEGATE_CUR = 2,
249 NFS4_OPEN_CLAIM_DELEGATE_PREV = 3
250};
251
252enum opentype4 {
253 NFS4_OPEN_NOCREATE = 0,
254 NFS4_OPEN_CREATE = 1
255};
256
257enum createmode4 {
258 NFS4_CREATE_UNCHECKED = 0,
259 NFS4_CREATE_GUARDED = 1,
260 NFS4_CREATE_EXCLUSIVE = 2
261};
262
263enum limit_by4 {
264 NFS4_LIMIT_SIZE = 1,
265 NFS4_LIMIT_BLOCKS = 2
266};
267
268enum open_delegation_type4 {
269 NFS4_OPEN_DELEGATE_NONE = 0,
270 NFS4_OPEN_DELEGATE_READ = 1,
271 NFS4_OPEN_DELEGATE_WRITE = 2
272};
273
274enum lock_type4 {
275 NFS4_UNLOCK_LT = 0,
276 NFS4_READ_LT = 1,
277 NFS4_WRITE_LT = 2,
278 NFS4_READW_LT = 3,
279 NFS4_WRITEW_LT = 4
280};
281
282
283/* Mandatory Attributes */
284#define FATTR4_WORD0_SUPPORTED_ATTRS (1UL << 0)
285#define FATTR4_WORD0_TYPE (1UL << 1)
286#define FATTR4_WORD0_FH_EXPIRE_TYPE (1UL << 2)
287#define FATTR4_WORD0_CHANGE (1UL << 3)
288#define FATTR4_WORD0_SIZE (1UL << 4)
289#define FATTR4_WORD0_LINK_SUPPORT (1UL << 5)
290#define FATTR4_WORD0_SYMLINK_SUPPORT (1UL << 6)
291#define FATTR4_WORD0_NAMED_ATTR (1UL << 7)
292#define FATTR4_WORD0_FSID (1UL << 8)
293#define FATTR4_WORD0_UNIQUE_HANDLES (1UL << 9)
294#define FATTR4_WORD0_LEASE_TIME (1UL << 10)
295#define FATTR4_WORD0_RDATTR_ERROR (1UL << 11)
296
297/* Recommended Attributes */
298#define FATTR4_WORD0_ACL (1UL << 12)
299#define FATTR4_WORD0_ACLSUPPORT (1UL << 13)
300#define FATTR4_WORD0_ARCHIVE (1UL << 14)
301#define FATTR4_WORD0_CANSETTIME (1UL << 15)
302#define FATTR4_WORD0_CASE_INSENSITIVE (1UL << 16)
303#define FATTR4_WORD0_CASE_PRESERVING (1UL << 17)
304#define FATTR4_WORD0_CHOWN_RESTRICTED (1UL << 18)
305#define FATTR4_WORD0_FILEHANDLE (1UL << 19)
306#define FATTR4_WORD0_FILEID (1UL << 20)
307#define FATTR4_WORD0_FILES_AVAIL (1UL << 21)
308#define FATTR4_WORD0_FILES_FREE (1UL << 22)
309#define FATTR4_WORD0_FILES_TOTAL (1UL << 23)
310#define FATTR4_WORD0_FS_LOCATIONS (1UL << 24)
311#define FATTR4_WORD0_HIDDEN (1UL << 25)
312#define FATTR4_WORD0_HOMOGENEOUS (1UL << 26)
313#define FATTR4_WORD0_MAXFILESIZE (1UL << 27)
314#define FATTR4_WORD0_MAXLINK (1UL << 28)
315#define FATTR4_WORD0_MAXNAME (1UL << 29)
316#define FATTR4_WORD0_MAXREAD (1UL << 30)
317#define FATTR4_WORD0_MAXWRITE (1UL << 31)
318#define FATTR4_WORD1_MIMETYPE (1UL << 0)
319#define FATTR4_WORD1_MODE (1UL << 1)
320#define FATTR4_WORD1_NO_TRUNC (1UL << 2)
321#define FATTR4_WORD1_NUMLINKS (1UL << 3)
322#define FATTR4_WORD1_OWNER (1UL << 4)
323#define FATTR4_WORD1_OWNER_GROUP (1UL << 5)
324#define FATTR4_WORD1_QUOTA_HARD (1UL << 6)
325#define FATTR4_WORD1_QUOTA_SOFT (1UL << 7)
326#define FATTR4_WORD1_QUOTA_USED (1UL << 8)
327#define FATTR4_WORD1_RAWDEV (1UL << 9)
328#define FATTR4_WORD1_SPACE_AVAIL (1UL << 10)
329#define FATTR4_WORD1_SPACE_FREE (1UL << 11)
330#define FATTR4_WORD1_SPACE_TOTAL (1UL << 12)
331#define FATTR4_WORD1_SPACE_USED (1UL << 13)
332#define FATTR4_WORD1_SYSTEM (1UL << 14)
333#define FATTR4_WORD1_TIME_ACCESS (1UL << 15)
334#define FATTR4_WORD1_TIME_ACCESS_SET (1UL << 16)
335#define FATTR4_WORD1_TIME_BACKUP (1UL << 17)
336#define FATTR4_WORD1_TIME_CREATE (1UL << 18)
337#define FATTR4_WORD1_TIME_DELTA (1UL << 19)
338#define FATTR4_WORD1_TIME_METADATA (1UL << 20)
339#define FATTR4_WORD1_TIME_MODIFY (1UL << 21)
340#define FATTR4_WORD1_TIME_MODIFY_SET (1UL << 22)
341#define FATTR4_WORD1_MOUNTED_ON_FILEID (1UL << 23)
342
343#define NFSPROC4_NULL 0
344#define NFSPROC4_COMPOUND 1
345#define NFS4_MINOR_VERSION 0
346#define NFS4_DEBUG 1
347
348#ifdef __KERNEL__
349
350/* Index of predefined Linux client operations */
351
352enum {
353 NFSPROC4_CLNT_NULL = 0, /* Unused */
354 NFSPROC4_CLNT_READ,
355 NFSPROC4_CLNT_WRITE,
356 NFSPROC4_CLNT_COMMIT,
357 NFSPROC4_CLNT_OPEN,
358 NFSPROC4_CLNT_OPEN_CONFIRM,
359 NFSPROC4_CLNT_OPEN_NOATTR,
360 NFSPROC4_CLNT_OPEN_DOWNGRADE,
361 NFSPROC4_CLNT_CLOSE,
362 NFSPROC4_CLNT_SETATTR,
363 NFSPROC4_CLNT_FSINFO,
364 NFSPROC4_CLNT_RENEW,
365 NFSPROC4_CLNT_SETCLIENTID,
366 NFSPROC4_CLNT_SETCLIENTID_CONFIRM,
367 NFSPROC4_CLNT_LOCK,
368 NFSPROC4_CLNT_LOCKT,
369 NFSPROC4_CLNT_LOCKU,
370 NFSPROC4_CLNT_ACCESS,
371 NFSPROC4_CLNT_GETATTR,
372 NFSPROC4_CLNT_LOOKUP,
373 NFSPROC4_CLNT_LOOKUP_ROOT,
374 NFSPROC4_CLNT_REMOVE,
375 NFSPROC4_CLNT_RENAME,
376 NFSPROC4_CLNT_LINK,
377 NFSPROC4_CLNT_SYMLINK,
378 NFSPROC4_CLNT_CREATE,
379 NFSPROC4_CLNT_PATHCONF,
380 NFSPROC4_CLNT_STATFS,
381 NFSPROC4_CLNT_READLINK,
382 NFSPROC4_CLNT_READDIR,
383 NFSPROC4_CLNT_SERVER_CAPS,
384 NFSPROC4_CLNT_DELEGRETURN,
385};
386
387#endif
388#endif
389
390/*
391 * Local variables:
392 * c-basic-offset: 8
393 * End:
394 */
diff --git a/include/linux/nfs4_acl.h b/include/linux/nfs4_acl.h
new file mode 100644
index 000000000000..22aff4d01f20
--- /dev/null
+++ b/include/linux/nfs4_acl.h
@@ -0,0 +1,59 @@
1/*
2 * include/linux/nfs4_acl.c
3 *
4 * Common NFSv4 ACL handling definitions.
5 *
6 * Copyright (c) 2002 The Regents of the University of Michigan.
7 * All rights reserved.
8 *
9 * Marius Aamodt Eriksen <marius@umich.edu>
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 *
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the University nor the names of its
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
25 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
31 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#ifndef LINUX_NFS4_ACL_H
38#define LINUX_NFS4_ACL_H
39
40#include <linux/posix_acl.h>
41
42struct nfs4_acl *nfs4_acl_new(void);
43void nfs4_acl_free(struct nfs4_acl *);
44int nfs4_acl_add_ace(struct nfs4_acl *, u32, u32, u32, int, uid_t);
45int nfs4_acl_get_whotype(char *, u32);
46int nfs4_acl_write_who(int who, char *p);
47int nfs4_acl_permission(struct nfs4_acl *acl, uid_t owner, gid_t group,
48 uid_t who, u32 mask);
49
50#define NFS4_ACL_TYPE_DEFAULT 0x01
51#define NFS4_ACL_DIR 0x02
52#define NFS4_ACL_OWNER 0x04
53
54struct nfs4_acl *nfs4_acl_posix_to_nfsv4(struct posix_acl *,
55 struct posix_acl *, unsigned int flags);
56int nfs4_acl_nfsv4_to_posix(struct nfs4_acl *, struct posix_acl **,
57 struct posix_acl **, unsigned int flags);
58
59#endif /* LINUX_NFS4_ACL_H */
diff --git a/include/linux/nfs4_mount.h b/include/linux/nfs4_mount.h
new file mode 100644
index 000000000000..26b4c83f831d
--- /dev/null
+++ b/include/linux/nfs4_mount.h
@@ -0,0 +1,70 @@
1#ifndef _LINUX_NFS4_MOUNT_H
2#define _LINUX_NFS4_MOUNT_H
3
4/*
5 * linux/include/linux/nfs4_mount.h
6 *
7 * Copyright (C) 2002 Trond Myklebust
8 *
9 * structure passed from user-space to kernel-space during an nfsv4 mount
10 */
11
12/*
13 * WARNING! Do not delete or change the order of these fields. If
14 * a new field is required then add it to the end. The version field
15 * tracks which fields are present. This will ensure some measure of
16 * mount-to-kernel version compatibility. Some of these aren't used yet
17 * but here they are anyway.
18 */
19#define NFS4_MOUNT_VERSION 1
20
21struct nfs_string {
22 unsigned int len;
23 const char __user * data;
24};
25
26struct nfs4_mount_data {
27 int version; /* 1 */
28 int flags; /* 1 */
29 int rsize; /* 1 */
30 int wsize; /* 1 */
31 int timeo; /* 1 */
32 int retrans; /* 1 */
33 int acregmin; /* 1 */
34 int acregmax; /* 1 */
35 int acdirmin; /* 1 */
36 int acdirmax; /* 1 */
37
38 /* see the definition of 'struct clientaddr4' in RFC3010 */
39 struct nfs_string client_addr; /* 1 */
40
41 /* Mount path */
42 struct nfs_string mnt_path; /* 1 */
43
44 /* Server details */
45 struct nfs_string hostname; /* 1 */
46 /* Server IP address */
47 unsigned int host_addrlen; /* 1 */
48 struct sockaddr __user * host_addr; /* 1 */
49
50 /* Transport protocol to use */
51 int proto; /* 1 */
52
53 /* Pseudo-flavours to use for authentication. See RFC2623 */
54 int auth_flavourlen; /* 1 */
55 int __user *auth_flavours; /* 1 */
56};
57
58/* bits in the flags field */
59/* Note: the fields that correspond to existing NFSv2/v3 mount options
60 * should mirror the values from include/linux/nfs_mount.h
61 */
62
63#define NFS4_MOUNT_SOFT 0x0001 /* 1 */
64#define NFS4_MOUNT_INTR 0x0002 /* 1 */
65#define NFS4_MOUNT_NOCTO 0x0010 /* 1 */
66#define NFS4_MOUNT_NOAC 0x0020 /* 1 */
67#define NFS4_MOUNT_STRICTLOCK 0x1000 /* 1 */
68#define NFS4_MOUNT_FLAGMASK 0xFFFF
69
70#endif
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
new file mode 100644
index 000000000000..dbac7f363e5d
--- /dev/null
+++ b/include/linux/nfs_fs.h
@@ -0,0 +1,767 @@
1/*
2 * linux/include/linux/nfs_fs.h
3 *
4 * Copyright (C) 1992 Rick Sladkey
5 *
6 * OS-specific nfs filesystem definitions and declarations
7 */
8
9#ifndef _LINUX_NFS_FS_H
10#define _LINUX_NFS_FS_H
11
12#include <linux/config.h>
13#include <linux/in.h>
14#include <linux/mm.h>
15#include <linux/pagemap.h>
16#include <linux/rwsem.h>
17#include <linux/wait.h>
18#include <linux/uio.h>
19
20#include <linux/nfs_fs_sb.h>
21
22#include <linux/sunrpc/debug.h>
23#include <linux/sunrpc/auth.h>
24#include <linux/sunrpc/clnt.h>
25
26#include <linux/nfs.h>
27#include <linux/nfs2.h>
28#include <linux/nfs3.h>
29#include <linux/nfs4.h>
30#include <linux/nfs_xdr.h>
31#include <linux/rwsem.h>
32#include <linux/workqueue.h>
33#include <linux/mempool.h>
34
35/*
36 * Enable debugging support for nfs client.
37 * Requires RPC_DEBUG.
38 */
39#ifdef RPC_DEBUG
40# define NFS_DEBUG
41#endif
42
43#define NFS_MAX_FILE_IO_BUFFER_SIZE 32768
44#define NFS_DEF_FILE_IO_BUFFER_SIZE 4096
45
46/*
47 * The upper limit on timeouts for the exponential backoff algorithm.
48 */
49#define NFS_WRITEBACK_DELAY (5*HZ)
50#define NFS_WRITEBACK_LOCKDELAY (60*HZ)
51#define NFS_COMMIT_DELAY (5*HZ)
52
53/*
54 * superblock magic number for NFS
55 */
56#define NFS_SUPER_MAGIC 0x6969
57
58/*
59 * These are the default flags for swap requests
60 */
61#define NFS_RPC_SWAPFLAGS (RPC_TASK_SWAPPER|RPC_TASK_ROOTCREDS)
62
63#define NFS_RW_SYNC 0x0001 /* O_SYNC handling */
64#define NFS_RW_SWAP 0x0002 /* This is a swap request */
65
66/*
67 * When flushing a cluster of dirty pages, there can be different
68 * strategies:
69 */
70#define FLUSH_AGING 0 /* only flush old buffers */
71#define FLUSH_SYNC 1 /* file being synced, or contention */
72#define FLUSH_WAIT 2 /* wait for completion */
73#define FLUSH_STABLE 4 /* commit to stable storage */
74#define FLUSH_LOWPRI 8 /* low priority background flush */
75#define FLUSH_HIGHPRI 16 /* high priority memory reclaim flush */
76
77#ifdef __KERNEL__
78
79/*
80 * NFSv3/v4 Access mode cache entry
81 */
82struct nfs_access_entry {
83 unsigned long jiffies;
84 struct rpc_cred * cred;
85 int mask;
86};
87
88struct nfs4_state;
89struct nfs_open_context {
90 atomic_t count;
91 struct dentry *dentry;
92 struct rpc_cred *cred;
93 struct nfs4_state *state;
94 fl_owner_t lockowner;
95 int mode;
96 int error;
97
98 struct list_head list;
99 wait_queue_head_t waitq;
100};
101
102/*
103 * NFSv4 delegation
104 */
105struct nfs_delegation;
106
107/*
108 * nfs fs inode data in memory
109 */
110struct nfs_inode {
111 /*
112 * The 64bit 'inode number'
113 */
114 __u64 fileid;
115
116 /*
117 * NFS file handle
118 */
119 struct nfs_fh fh;
120
121 /*
122 * Various flags
123 */
124 unsigned int flags;
125
126 /*
127 * read_cache_jiffies is when we started read-caching this inode,
128 * and read_cache_mtime is the mtime of the inode at that time.
129 * attrtimeo is for how long the cached information is assumed
130 * to be valid. A successful attribute revalidation doubles
131 * attrtimeo (up to acregmax/acdirmax), a failure resets it to
132 * acregmin/acdirmin.
133 *
134 * We need to revalidate the cached attrs for this inode if
135 *
136 * jiffies - read_cache_jiffies > attrtimeo
137 *
138 * and invalidate any cached data/flush out any dirty pages if
139 * we find that
140 *
141 * mtime != read_cache_mtime
142 */
143 unsigned long readdir_timestamp;
144 unsigned long read_cache_jiffies;
145 unsigned long attrtimeo;
146 unsigned long attrtimeo_timestamp;
147 __u64 change_attr; /* v4 only */
148
149 /* "Generation counter" for the attribute cache. This is
150 * bumped whenever we update the metadata on the
151 * server.
152 */
153 unsigned long cache_change_attribute;
154 /*
155 * Counter indicating the number of outstanding requests that
156 * will cause a file data update.
157 */
158 atomic_t data_updates;
159
160 struct nfs_access_entry cache_access;
161
162 /*
163 * This is the cookie verifier used for NFSv3 readdir
164 * operations
165 */
166 __u32 cookieverf[2];
167
168 /*
169 * This is the list of dirty unwritten pages.
170 */
171 spinlock_t req_lock;
172 struct list_head dirty;
173 struct list_head commit;
174 struct radix_tree_root nfs_page_tree;
175
176 unsigned int ndirty,
177 ncommit,
178 npages;
179
180 /* Open contexts for shared mmap writes */
181 struct list_head open_files;
182
183 wait_queue_head_t nfs_i_wait;
184
185#ifdef CONFIG_NFS_V4
186 /* NFSv4 state */
187 struct list_head open_states;
188 struct nfs_delegation *delegation;
189 int delegation_state;
190 struct rw_semaphore rwsem;
191#endif /* CONFIG_NFS_V4*/
192
193 struct inode vfs_inode;
194};
195
196/*
197 * Legal inode flag values
198 */
199#define NFS_INO_STALE 0x0001 /* possible stale inode */
200#define NFS_INO_ADVISE_RDPLUS 0x0002 /* advise readdirplus */
201#define NFS_INO_REVALIDATING 0x0004 /* revalidating attrs */
202#define NFS_INO_INVALID_ATTR 0x0008 /* cached attrs are invalid */
203#define NFS_INO_INVALID_DATA 0x0010 /* cached data is invalid */
204#define NFS_INO_INVALID_ATIME 0x0020 /* cached atime is invalid */
205#define NFS_INO_INVALID_ACCESS 0x0040 /* cached access cred invalid */
206
207static inline struct nfs_inode *NFS_I(struct inode *inode)
208{
209 return container_of(inode, struct nfs_inode, vfs_inode);
210}
211#define NFS_SB(s) ((struct nfs_server *)(s->s_fs_info))
212
213#define NFS_FH(inode) (&NFS_I(inode)->fh)
214#define NFS_SERVER(inode) (NFS_SB(inode->i_sb))
215#define NFS_CLIENT(inode) (NFS_SERVER(inode)->client)
216#define NFS_PROTO(inode) (NFS_SERVER(inode)->rpc_ops)
217#define NFS_ADDR(inode) (RPC_PEERADDR(NFS_CLIENT(inode)))
218#define NFS_COOKIEVERF(inode) (NFS_I(inode)->cookieverf)
219#define NFS_READTIME(inode) (NFS_I(inode)->read_cache_jiffies)
220#define NFS_CHANGE_ATTR(inode) (NFS_I(inode)->change_attr)
221#define NFS_ATTRTIMEO(inode) (NFS_I(inode)->attrtimeo)
222#define NFS_MINATTRTIMEO(inode) \
223 (S_ISDIR(inode->i_mode)? NFS_SERVER(inode)->acdirmin \
224 : NFS_SERVER(inode)->acregmin)
225#define NFS_MAXATTRTIMEO(inode) \
226 (S_ISDIR(inode->i_mode)? NFS_SERVER(inode)->acdirmax \
227 : NFS_SERVER(inode)->acregmax)
228#define NFS_ATTRTIMEO_UPDATE(inode) (NFS_I(inode)->attrtimeo_timestamp)
229
230#define NFS_FLAGS(inode) (NFS_I(inode)->flags)
231#define NFS_REVALIDATING(inode) (NFS_FLAGS(inode) & NFS_INO_REVALIDATING)
232#define NFS_STALE(inode) (NFS_FLAGS(inode) & NFS_INO_STALE)
233
234#define NFS_FILEID(inode) (NFS_I(inode)->fileid)
235
236static inline int nfs_caches_unstable(struct inode *inode)
237{
238 return atomic_read(&NFS_I(inode)->data_updates) != 0;
239}
240
241static inline void NFS_CACHEINV(struct inode *inode)
242{
243 if (!nfs_caches_unstable(inode))
244 NFS_FLAGS(inode) |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS;
245}
246
247static inline int nfs_server_capable(struct inode *inode, int cap)
248{
249 return NFS_SERVER(inode)->caps & cap;
250}
251
252static inline int NFS_USE_READDIRPLUS(struct inode *inode)
253{
254 return NFS_FLAGS(inode) & NFS_INO_ADVISE_RDPLUS;
255}
256
257/**
258 * nfs_save_change_attribute - Returns the inode attribute change cookie
259 * @inode - pointer to inode
260 * The "change attribute" is updated every time we finish an operation
261 * that will result in a metadata change on the server.
262 */
263static inline long nfs_save_change_attribute(struct inode *inode)
264{
265 return NFS_I(inode)->cache_change_attribute;
266}
267
268/**
269 * nfs_verify_change_attribute - Detects NFS inode cache updates
270 * @inode - pointer to inode
271 * @chattr - previously saved change attribute
272 * Return "false" if metadata has been updated (or is in the process of
273 * being updated) since the change attribute was saved.
274 */
275static inline int nfs_verify_change_attribute(struct inode *inode, unsigned long chattr)
276{
277 return !nfs_caches_unstable(inode)
278 && chattr == NFS_I(inode)->cache_change_attribute;
279}
280
281/*
282 * linux/fs/nfs/inode.c
283 */
284extern void nfs_zap_caches(struct inode *);
285extern struct inode *nfs_fhget(struct super_block *, struct nfs_fh *,
286 struct nfs_fattr *);
287extern int nfs_refresh_inode(struct inode *, struct nfs_fattr *);
288extern int nfs_getattr(struct vfsmount *, struct dentry *, struct kstat *);
289extern int nfs_permission(struct inode *, int, struct nameidata *);
290extern int nfs_access_get_cached(struct inode *, struct rpc_cred *, struct nfs_access_entry *);
291extern void nfs_access_add_cache(struct inode *, struct nfs_access_entry *);
292extern int nfs_open(struct inode *, struct file *);
293extern int nfs_release(struct inode *, struct file *);
294extern int nfs_attribute_timeout(struct inode *inode);
295extern int nfs_revalidate_inode(struct nfs_server *server, struct inode *inode);
296extern int __nfs_revalidate_inode(struct nfs_server *, struct inode *);
297extern int nfs_setattr(struct dentry *, struct iattr *);
298extern void nfs_begin_attr_update(struct inode *);
299extern void nfs_end_attr_update(struct inode *);
300extern void nfs_begin_data_update(struct inode *);
301extern void nfs_end_data_update(struct inode *);
302extern void nfs_end_data_update_defer(struct inode *);
303extern struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, struct rpc_cred *cred);
304extern struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx);
305extern void put_nfs_open_context(struct nfs_open_context *ctx);
306extern void nfs_file_set_open_context(struct file *filp, struct nfs_open_context *ctx);
307extern struct nfs_open_context *nfs_find_open_context(struct inode *inode, int mode);
308extern void nfs_file_clear_open_context(struct file *filp);
309
310/* linux/net/ipv4/ipconfig.c: trims ip addr off front of name, too. */
311extern u32 root_nfs_parse_addr(char *name); /*__init*/
312
313/*
314 * linux/fs/nfs/file.c
315 */
316extern struct inode_operations nfs_file_inode_operations;
317extern struct file_operations nfs_file_operations;
318extern struct address_space_operations nfs_file_aops;
319
320static inline struct rpc_cred *nfs_file_cred(struct file *file)
321{
322 if (file != NULL) {
323 struct nfs_open_context *ctx;
324
325 ctx = (struct nfs_open_context*)file->private_data;
326 return ctx->cred;
327 }
328 return NULL;
329}
330
331/*
332 * linux/fs/nfs/direct.c
333 */
334extern ssize_t nfs_direct_IO(int, struct kiocb *, const struct iovec *, loff_t,
335 unsigned long);
336extern ssize_t nfs_file_direct_read(struct kiocb *iocb, char __user *buf,
337 size_t count, loff_t pos);
338extern ssize_t nfs_file_direct_write(struct kiocb *iocb, const char __user *buf,
339 size_t count, loff_t pos);
340
341/*
342 * linux/fs/nfs/dir.c
343 */
344extern struct inode_operations nfs_dir_inode_operations;
345extern struct file_operations nfs_dir_operations;
346extern struct dentry_operations nfs_dentry_operations;
347
348extern int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fh, struct nfs_fattr *fattr);
349
350/*
351 * linux/fs/nfs/symlink.c
352 */
353extern struct inode_operations nfs_symlink_inode_operations;
354
355/*
356 * linux/fs/nfs/unlink.c
357 */
358extern int nfs_async_unlink(struct dentry *);
359extern void nfs_complete_unlink(struct dentry *);
360
361/*
362 * linux/fs/nfs/write.c
363 */
364extern int nfs_writepage(struct page *page, struct writeback_control *wbc);
365extern int nfs_writepages(struct address_space *, struct writeback_control *);
366extern int nfs_flush_incompatible(struct file *file, struct page *page);
367extern int nfs_updatepage(struct file *, struct page *, unsigned int, unsigned int);
368extern void nfs_writeback_done(struct rpc_task *task);
369
370#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
371extern void nfs_commit_done(struct rpc_task *);
372#endif
373
374/*
375 * Try to write back everything synchronously (but check the
376 * return value!)
377 */
378extern int nfs_sync_inode(struct inode *, unsigned long, unsigned int, int);
379#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
380extern int nfs_commit_inode(struct inode *, unsigned long, unsigned int, int);
381#else
382static inline int
383nfs_commit_inode(struct inode *inode, unsigned long idx_start, unsigned int npages, int how)
384{
385 return 0;
386}
387#endif
388
389static inline int
390nfs_have_writebacks(struct inode *inode)
391{
392 return NFS_I(inode)->npages != 0;
393}
394
395static inline int
396nfs_wb_all(struct inode *inode)
397{
398 int error = nfs_sync_inode(inode, 0, 0, FLUSH_WAIT);
399 return (error < 0) ? error : 0;
400}
401
402/*
403 * Write back all requests on one page - we do this before reading it.
404 */
405static inline int nfs_wb_page_priority(struct inode *inode, struct page* page, int how)
406{
407 int error = nfs_sync_inode(inode, page->index, 1,
408 how | FLUSH_WAIT | FLUSH_STABLE);
409 return (error < 0) ? error : 0;
410}
411
412static inline int nfs_wb_page(struct inode *inode, struct page* page)
413{
414 return nfs_wb_page_priority(inode, page, 0);
415}
416
417/*
418 * Allocate and free nfs_write_data structures
419 */
420extern mempool_t *nfs_wdata_mempool;
421
422static inline struct nfs_write_data *nfs_writedata_alloc(void)
423{
424 struct nfs_write_data *p = mempool_alloc(nfs_wdata_mempool, SLAB_NOFS);
425 if (p) {
426 memset(p, 0, sizeof(*p));
427 INIT_LIST_HEAD(&p->pages);
428 }
429 return p;
430}
431
432static inline void nfs_writedata_free(struct nfs_write_data *p)
433{
434 mempool_free(p, nfs_wdata_mempool);
435}
436
437/* Hack for future NFS swap support */
438#ifndef IS_SWAPFILE
439# define IS_SWAPFILE(inode) (0)
440#endif
441
442/*
443 * linux/fs/nfs/read.c
444 */
445extern int nfs_readpage(struct file *, struct page *);
446extern int nfs_readpages(struct file *, struct address_space *,
447 struct list_head *, unsigned);
448extern void nfs_readpage_result(struct rpc_task *);
449
450/*
451 * Allocate and free nfs_read_data structures
452 */
453extern mempool_t *nfs_rdata_mempool;
454
455static inline struct nfs_read_data *nfs_readdata_alloc(void)
456{
457 struct nfs_read_data *p = mempool_alloc(nfs_rdata_mempool, SLAB_NOFS);
458 if (p)
459 memset(p, 0, sizeof(*p));
460 return p;
461}
462
463static inline void nfs_readdata_free(struct nfs_read_data *p)
464{
465 mempool_free(p, nfs_rdata_mempool);
466}
467
468extern void nfs_readdata_release(struct rpc_task *task);
469
470/*
471 * linux/fs/mount_clnt.c
472 * (Used only by nfsroot module)
473 */
474extern int nfsroot_mount(struct sockaddr_in *, char *, struct nfs_fh *,
475 int, int);
476
477/*
478 * inline functions
479 */
480
481static inline loff_t
482nfs_size_to_loff_t(__u64 size)
483{
484 loff_t maxsz = (((loff_t) ULONG_MAX) << PAGE_CACHE_SHIFT) + PAGE_CACHE_SIZE - 1;
485 if (size > maxsz)
486 return maxsz;
487 return (loff_t) size;
488}
489
490static inline ino_t
491nfs_fileid_to_ino_t(u64 fileid)
492{
493 ino_t ino = (ino_t) fileid;
494 if (sizeof(ino_t) < sizeof(u64))
495 ino ^= fileid >> (sizeof(u64)-sizeof(ino_t)) * 8;
496 return ino;
497}
498
499/* NFS root */
500
501extern void * nfs_root_data(void);
502
503#define nfs_wait_event(clnt, wq, condition) \
504({ \
505 int __retval = 0; \
506 if (clnt->cl_intr) { \
507 sigset_t oldmask; \
508 rpc_clnt_sigmask(clnt, &oldmask); \
509 __retval = wait_event_interruptible(wq, condition); \
510 rpc_clnt_sigunmask(clnt, &oldmask); \
511 } else \
512 wait_event(wq, condition); \
513 __retval; \
514})
515
516#define NFS_JUKEBOX_RETRY_TIME (5 * HZ)
517
518#ifdef CONFIG_NFS_V4
519
520struct idmap;
521
522/*
523 * In a seqid-mutating op, this macro controls which error return
524 * values trigger incrementation of the seqid.
525 *
526 * from rfc 3010:
527 * The client MUST monotonically increment the sequence number for the
528 * CLOSE, LOCK, LOCKU, OPEN, OPEN_CONFIRM, and OPEN_DOWNGRADE
529 * operations. This is true even in the event that the previous
530 * operation that used the sequence number received an error. The only
531 * exception to this rule is if the previous operation received one of
532 * the following errors: NFSERR_STALE_CLIENTID, NFSERR_STALE_STATEID,
533 * NFSERR_BAD_STATEID, NFSERR_BAD_SEQID, NFSERR_BADXDR,
534 * NFSERR_RESOURCE, NFSERR_NOFILEHANDLE.
535 *
536 */
537#define seqid_mutating_err(err) \
538(((err) != NFSERR_STALE_CLIENTID) && \
539 ((err) != NFSERR_STALE_STATEID) && \
540 ((err) != NFSERR_BAD_STATEID) && \
541 ((err) != NFSERR_BAD_SEQID) && \
542 ((err) != NFSERR_BAD_XDR) && \
543 ((err) != NFSERR_RESOURCE) && \
544 ((err) != NFSERR_NOFILEHANDLE))
545
546enum nfs4_client_state {
547 NFS4CLNT_OK = 0,
548};
549
550/*
551 * The nfs4_client identifies our client state to the server.
552 */
553struct nfs4_client {
554 struct list_head cl_servers; /* Global list of servers */
555 struct in_addr cl_addr; /* Server identifier */
556 u64 cl_clientid; /* constant */
557 nfs4_verifier cl_confirm;
558 unsigned long cl_state;
559
560 u32 cl_lockowner_id;
561
562 /*
563 * The following rwsem ensures exclusive access to the server
564 * while we recover the state following a lease expiration.
565 */
566 struct rw_semaphore cl_sem;
567
568 struct list_head cl_delegations;
569 struct list_head cl_state_owners;
570 struct list_head cl_unused;
571 int cl_nunused;
572 spinlock_t cl_lock;
573 atomic_t cl_count;
574
575 struct rpc_clnt * cl_rpcclient;
576 struct rpc_cred * cl_cred;
577
578 struct list_head cl_superblocks; /* List of nfs_server structs */
579
580 unsigned long cl_lease_time;
581 unsigned long cl_last_renewal;
582 struct work_struct cl_renewd;
583 struct work_struct cl_recoverd;
584
585 wait_queue_head_t cl_waitq;
586 struct rpc_wait_queue cl_rpcwaitq;
587
588 /* used for the setclientid verifier */
589 struct timespec cl_boot_time;
590
591 /* idmapper */
592 struct idmap * cl_idmap;
593
594 /* Our own IP address, as a null-terminated string.
595 * This is used to generate the clientid, and the callback address.
596 */
597 char cl_ipaddr[16];
598 unsigned char cl_id_uniquifier;
599};
600
601/*
602 * NFS4 state_owners and lock_owners are simply labels for ordered
603 * sequences of RPC calls. Their sole purpose is to provide once-only
604 * semantics by allowing the server to identify replayed requests.
605 *
606 * The ->so_sema is held during all state_owner seqid-mutating operations:
607 * OPEN, OPEN_DOWNGRADE, and CLOSE. Its purpose is to properly serialize
608 * so_seqid.
609 */
610struct nfs4_state_owner {
611 struct list_head so_list; /* per-clientid list of state_owners */
612 struct nfs4_client *so_client;
613 u32 so_id; /* 32-bit identifier, unique */
614 struct semaphore so_sema;
615 u32 so_seqid; /* protected by so_sema */
616 atomic_t so_count;
617
618 struct rpc_cred *so_cred; /* Associated cred */
619 struct list_head so_states;
620 struct list_head so_delegations;
621};
622
623/*
624 * struct nfs4_state maintains the client-side state for a given
625 * (state_owner,inode) tuple (OPEN) or state_owner (LOCK).
626 *
627 * OPEN:
628 * In order to know when to OPEN_DOWNGRADE or CLOSE the state on the server,
629 * we need to know how many files are open for reading or writing on a
630 * given inode. This information too is stored here.
631 *
632 * LOCK: one nfs4_state (LOCK) to hold the lock stateid nfs4_state(OPEN)
633 */
634
635struct nfs4_lock_state {
636 struct list_head ls_locks; /* Other lock stateids */
637 fl_owner_t ls_owner; /* POSIX lock owner */
638#define NFS_LOCK_INITIALIZED 1
639 int ls_flags;
640 u32 ls_seqid;
641 u32 ls_id;
642 nfs4_stateid ls_stateid;
643 atomic_t ls_count;
644};
645
646/* bits for nfs4_state->flags */
647enum {
648 LK_STATE_IN_USE,
649 NFS_DELEGATED_STATE,
650};
651
652struct nfs4_state {
653 struct list_head open_states; /* List of states for the same state_owner */
654 struct list_head inode_states; /* List of states for the same inode */
655 struct list_head lock_states; /* List of subservient lock stateids */
656
657 struct nfs4_state_owner *owner; /* Pointer to the open owner */
658 struct inode *inode; /* Pointer to the inode */
659
660 unsigned long flags; /* Do we hold any locks? */
661 struct semaphore lock_sema; /* Serializes file locking operations */
662 rwlock_t state_lock; /* Protects the lock_states list */
663
664 nfs4_stateid stateid;
665
666 unsigned int nreaders;
667 unsigned int nwriters;
668 int state; /* State on the server (R,W, or RW) */
669 atomic_t count;
670};
671
672
673struct nfs4_exception {
674 long timeout;
675 int retry;
676};
677
678struct nfs4_state_recovery_ops {
679 int (*recover_open)(struct nfs4_state_owner *, struct nfs4_state *);
680 int (*recover_lock)(struct nfs4_state *, struct file_lock *);
681};
682
683extern struct dentry_operations nfs4_dentry_operations;
684extern struct inode_operations nfs4_dir_inode_operations;
685
686/* nfs4proc.c */
687extern int nfs4_map_errors(int err);
688extern int nfs4_proc_setclientid(struct nfs4_client *, u32, unsigned short);
689extern int nfs4_proc_setclientid_confirm(struct nfs4_client *);
690extern int nfs4_proc_async_renew(struct nfs4_client *);
691extern int nfs4_proc_renew(struct nfs4_client *);
692extern int nfs4_do_close(struct inode *inode, struct nfs4_state *state, mode_t mode);
693extern struct inode *nfs4_atomic_open(struct inode *, struct dentry *, struct nameidata *);
694extern int nfs4_open_revalidate(struct inode *, struct dentry *, int);
695
696extern struct nfs4_state_recovery_ops nfs4_reboot_recovery_ops;
697extern struct nfs4_state_recovery_ops nfs4_network_partition_recovery_ops;
698
699/* nfs4renewd.c */
700extern void nfs4_schedule_state_renewal(struct nfs4_client *);
701extern void nfs4_renewd_prepare_shutdown(struct nfs_server *);
702extern void nfs4_kill_renewd(struct nfs4_client *);
703
704/* nfs4state.c */
705extern void init_nfsv4_state(struct nfs_server *);
706extern void destroy_nfsv4_state(struct nfs_server *);
707extern struct nfs4_client *nfs4_get_client(struct in_addr *);
708extern void nfs4_put_client(struct nfs4_client *clp);
709extern int nfs4_init_client(struct nfs4_client *clp);
710extern struct nfs4_client *nfs4_find_client(struct in_addr *);
711extern u32 nfs4_alloc_lockowner_id(struct nfs4_client *);
712
713extern struct nfs4_state_owner * nfs4_get_state_owner(struct nfs_server *, struct rpc_cred *);
714extern void nfs4_put_state_owner(struct nfs4_state_owner *);
715extern void nfs4_drop_state_owner(struct nfs4_state_owner *);
716extern struct nfs4_state * nfs4_get_open_state(struct inode *, struct nfs4_state_owner *);
717extern void nfs4_put_open_state(struct nfs4_state *);
718extern void nfs4_close_state(struct nfs4_state *, mode_t);
719extern struct nfs4_state *nfs4_find_state(struct inode *, struct rpc_cred *, mode_t mode);
720extern void nfs4_increment_seqid(int status, struct nfs4_state_owner *sp);
721extern void nfs4_schedule_state_recovery(struct nfs4_client *);
722extern struct nfs4_lock_state *nfs4_find_lock_state(struct nfs4_state *state, fl_owner_t);
723extern struct nfs4_lock_state *nfs4_get_lock_state(struct nfs4_state *state, fl_owner_t);
724extern void nfs4_put_lock_state(struct nfs4_lock_state *state);
725extern void nfs4_increment_lock_seqid(int status, struct nfs4_lock_state *ls);
726extern void nfs4_notify_setlk(struct nfs4_state *, struct file_lock *, struct nfs4_lock_state *);
727extern void nfs4_notify_unlck(struct nfs4_state *, struct file_lock *, struct nfs4_lock_state *);
728extern void nfs4_copy_stateid(nfs4_stateid *, struct nfs4_state *, fl_owner_t);
729
730
731
732struct nfs4_mount_data;
733#else
734#define init_nfsv4_state(server) do { } while (0)
735#define destroy_nfsv4_state(server) do { } while (0)
736#define nfs4_put_state_owner(inode, owner) do { } while (0)
737#define nfs4_put_open_state(state) do { } while (0)
738#define nfs4_close_state(a, b) do { } while (0)
739#define nfs4_renewd_prepare_shutdown(server) do { } while (0)
740#endif
741
742#endif /* __KERNEL__ */
743
744/*
745 * NFS debug flags
746 */
747#define NFSDBG_VFS 0x0001
748#define NFSDBG_DIRCACHE 0x0002
749#define NFSDBG_LOOKUPCACHE 0x0004
750#define NFSDBG_PAGECACHE 0x0008
751#define NFSDBG_PROC 0x0010
752#define NFSDBG_XDR 0x0020
753#define NFSDBG_FILE 0x0040
754#define NFSDBG_ROOT 0x0080
755#define NFSDBG_CALLBACK 0x0100
756#define NFSDBG_ALL 0xFFFF
757
758#ifdef __KERNEL__
759# undef ifdebug
760# ifdef NFS_DEBUG
761# define ifdebug(fac) if (unlikely(nfs_debug & NFSDBG_##fac))
762# else
763# define ifdebug(fac) if (0)
764# endif
765#endif /* __KERNEL */
766
767#endif
diff --git a/include/linux/nfs_fs_i.h b/include/linux/nfs_fs_i.h
new file mode 100644
index 000000000000..e9a749588a7b
--- /dev/null
+++ b/include/linux/nfs_fs_i.h
@@ -0,0 +1,25 @@
1#ifndef _NFS_FS_I
2#define _NFS_FS_I
3
4#include <asm/types.h>
5#include <linux/list.h>
6#include <linux/nfs.h>
7
8struct nlm_lockowner;
9
10/*
11 * NFS lock info
12 */
13struct nfs_lock_info {
14 u32 state;
15 u32 flags;
16 struct nlm_lockowner *owner;
17};
18
19/*
20 * Lock flag values
21 */
22#define NFS_LCK_GRANTED 0x0001 /* lock has been granted */
23#define NFS_LCK_RECLAIM 0x0002 /* lock marked for reclaiming */
24
25#endif
diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h
new file mode 100644
index 000000000000..fc51645d61ee
--- /dev/null
+++ b/include/linux/nfs_fs_sb.h
@@ -0,0 +1,58 @@
1#ifndef _NFS_FS_SB
2#define _NFS_FS_SB
3
4#include <linux/list.h>
5#include <linux/backing-dev.h>
6
7/*
8 * NFS client parameters stored in the superblock.
9 */
10struct nfs_server {
11 struct rpc_clnt * client; /* RPC client handle */
12 struct rpc_clnt * client_sys; /* 2nd handle for FSINFO */
13 struct nfs_rpc_ops * rpc_ops; /* NFS protocol vector */
14 struct backing_dev_info backing_dev_info;
15 int flags; /* various flags */
16 unsigned int caps; /* server capabilities */
17 unsigned int rsize; /* read size */
18 unsigned int rpages; /* read size (in pages) */
19 unsigned int wsize; /* write size */
20 unsigned int wpages; /* write size (in pages) */
21 unsigned int wtmult; /* server disk block size */
22 unsigned int dtsize; /* readdir size */
23 unsigned int bsize; /* server block size */
24 unsigned int acregmin; /* attr cache timeouts */
25 unsigned int acregmax;
26 unsigned int acdirmin;
27 unsigned int acdirmax;
28 unsigned int namelen;
29 char * hostname; /* remote hostname */
30 struct nfs_fh fh;
31 struct sockaddr_in addr;
32#ifdef CONFIG_NFS_V4
33 /* Our own IP address, as a null-terminated string.
34 * This is used to generate the clientid, and the callback address.
35 */
36 char ip_addr[16];
37 char * mnt_path;
38 struct nfs4_client * nfs4_state; /* all NFSv4 state starts here */
39 struct list_head nfs4_siblings; /* List of other nfs_server structs
40 * that share the same clientid
41 */
42 u32 attr_bitmask[2];/* V4 bitmask representing the set
43 of attributes supported on this
44 filesystem */
45 u32 acl_bitmask; /* V4 bitmask representing the ACEs
46 that are supported on this
47 filesystem */
48#endif
49};
50
51/* Server capabilities */
52#define NFS_CAP_READDIRPLUS (1U << 0)
53#define NFS_CAP_HARDLINKS (1U << 1)
54#define NFS_CAP_SYMLINKS (1U << 2)
55#define NFS_CAP_ACLS (1U << 3)
56#define NFS_CAP_ATOMIC_OPEN (1U << 4)
57
58#endif
diff --git a/include/linux/nfs_idmap.h b/include/linux/nfs_idmap.h
new file mode 100644
index 000000000000..a0f1f25e0ead
--- /dev/null
+++ b/include/linux/nfs_idmap.h
@@ -0,0 +1,76 @@
1/*
2 * include/linux/nfs_idmap.h
3 *
4 * UID and GID to name mapping for clients.
5 *
6 * Copyright (c) 2002 The Regents of the University of Michigan.
7 * All rights reserved.
8 *
9 * Marius Aamodt Eriksen <marius@umich.edu>
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 *
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the University nor the names of its
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
25 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
31 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#ifndef NFS_IDMAP_H
38#define NFS_IDMAP_H
39
40/* XXX from bits/utmp.h */
41#define IDMAP_NAMESZ 128
42
43#define IDMAP_TYPE_USER 0
44#define IDMAP_TYPE_GROUP 1
45
46#define IDMAP_CONV_IDTONAME 0
47#define IDMAP_CONV_NAMETOID 1
48
49#define IDMAP_STATUS_INVALIDMSG 0x01
50#define IDMAP_STATUS_AGAIN 0x02
51#define IDMAP_STATUS_LOOKUPFAIL 0x04
52#define IDMAP_STATUS_SUCCESS 0x08
53
54struct idmap_msg {
55 __u8 im_type;
56 __u8 im_conv;
57 char im_name[IDMAP_NAMESZ];
58 __u32 im_id;
59 __u8 im_status;
60};
61
62#ifdef __KERNEL__
63
64/* Forward declaration to make this header independent of others */
65struct nfs4_client;
66
67void nfs_idmap_new(struct nfs4_client *);
68void nfs_idmap_delete(struct nfs4_client *);
69
70int nfs_map_name_to_uid(struct nfs4_client *, const char *, size_t, __u32 *);
71int nfs_map_group_to_gid(struct nfs4_client *, const char *, size_t, __u32 *);
72int nfs_map_uid_to_name(struct nfs4_client *, __u32, char *);
73int nfs_map_gid_to_group(struct nfs4_client *, __u32, char *);
74#endif /* __KERNEL__ */
75
76#endif /* NFS_IDMAP_H */
diff --git a/include/linux/nfs_mount.h b/include/linux/nfs_mount.h
new file mode 100644
index 000000000000..0071428231f9
--- /dev/null
+++ b/include/linux/nfs_mount.h
@@ -0,0 +1,65 @@
1#ifndef _LINUX_NFS_MOUNT_H
2#define _LINUX_NFS_MOUNT_H
3
4/*
5 * linux/include/linux/nfs_mount.h
6 *
7 * Copyright (C) 1992 Rick Sladkey
8 *
9 * structure passed from user-space to kernel-space during an nfs mount
10 */
11#include <linux/in.h>
12#include <linux/nfs.h>
13#include <linux/nfs2.h>
14#include <linux/nfs3.h>
15
16/*
17 * WARNING! Do not delete or change the order of these fields. If
18 * a new field is required then add it to the end. The version field
19 * tracks which fields are present. This will ensure some measure of
20 * mount-to-kernel version compatibility. Some of these aren't used yet
21 * but here they are anyway.
22 */
23#define NFS_MOUNT_VERSION 6
24#define NFS_MAX_CONTEXT_LEN 256
25
26struct nfs_mount_data {
27 int version; /* 1 */
28 int fd; /* 1 */
29 struct nfs2_fh old_root; /* 1 */
30 int flags; /* 1 */
31 int rsize; /* 1 */
32 int wsize; /* 1 */
33 int timeo; /* 1 */
34 int retrans; /* 1 */
35 int acregmin; /* 1 */
36 int acregmax; /* 1 */
37 int acdirmin; /* 1 */
38 int acdirmax; /* 1 */
39 struct sockaddr_in addr; /* 1 */
40 char hostname[256]; /* 1 */
41 int namlen; /* 2 */
42 unsigned int bsize; /* 3 */
43 struct nfs3_fh root; /* 4 */
44 int pseudoflavor; /* 5 */
45 char context[NFS_MAX_CONTEXT_LEN + 1]; /* 6 */
46};
47
48/* bits in the flags field */
49
50#define NFS_MOUNT_SOFT 0x0001 /* 1 */
51#define NFS_MOUNT_INTR 0x0002 /* 1 */
52#define NFS_MOUNT_SECURE 0x0004 /* 1 */
53#define NFS_MOUNT_POSIX 0x0008 /* 1 */
54#define NFS_MOUNT_NOCTO 0x0010 /* 1 */
55#define NFS_MOUNT_NOAC 0x0020 /* 1 */
56#define NFS_MOUNT_TCP 0x0040 /* 2 */
57#define NFS_MOUNT_VER3 0x0080 /* 3 */
58#define NFS_MOUNT_KERBEROS 0x0100 /* 3 */
59#define NFS_MOUNT_NONLM 0x0200 /* 3 */
60#define NFS_MOUNT_BROKEN_SUID 0x0400 /* 4 */
61#define NFS_MOUNT_STRICTLOCK 0x1000 /* reserved for NFSv4 */
62#define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
63#define NFS_MOUNT_FLAGMASK 0xFFFF
64
65#endif
diff --git a/include/linux/nfs_page.h b/include/linux/nfs_page.h
new file mode 100644
index 000000000000..39e4895bcdb4
--- /dev/null
+++ b/include/linux/nfs_page.h
@@ -0,0 +1,151 @@
1/*
2 * linux/include/linux/nfs_page.h
3 *
4 * Copyright (C) 2000 Trond Myklebust
5 *
6 * NFS page cache wrapper.
7 */
8
9#ifndef _LINUX_NFS_PAGE_H
10#define _LINUX_NFS_PAGE_H
11
12
13#include <linux/list.h>
14#include <linux/pagemap.h>
15#include <linux/wait.h>
16#include <linux/nfs_fs_sb.h>
17#include <linux/sunrpc/auth.h>
18#include <linux/nfs_xdr.h>
19
20#include <asm/atomic.h>
21
22/*
23 * Valid flags for a dirty buffer
24 */
25#define PG_BUSY 0
26#define PG_NEED_COMMIT 1
27#define PG_NEED_RESCHED 2
28
29struct nfs_page {
30 struct list_head wb_list, /* Defines state of page: */
31 *wb_list_head; /* read/write/commit */
32 struct page *wb_page; /* page to read in/write out */
33 struct nfs_open_context *wb_context; /* File state context info */
34 atomic_t wb_complete; /* i/os we're waiting for */
35 unsigned long wb_index; /* Offset >> PAGE_CACHE_SHIFT */
36 unsigned int wb_offset, /* Offset & ~PAGE_CACHE_MASK */
37 wb_pgbase, /* Start of page data */
38 wb_bytes; /* Length of request */
39 atomic_t wb_count; /* reference count */
40 unsigned long wb_flags;
41 struct nfs_writeverf wb_verf; /* Commit cookie */
42};
43
44#define NFS_WBACK_BUSY(req) (test_bit(PG_BUSY,&(req)->wb_flags))
45#define NFS_NEED_COMMIT(req) (test_bit(PG_NEED_COMMIT,&(req)->wb_flags))
46#define NFS_NEED_RESCHED(req) (test_bit(PG_NEED_RESCHED,&(req)->wb_flags))
47
48extern struct nfs_page *nfs_create_request(struct nfs_open_context *ctx,
49 struct inode *inode,
50 struct page *page,
51 unsigned int offset,
52 unsigned int count);
53extern void nfs_clear_request(struct nfs_page *req);
54extern void nfs_release_request(struct nfs_page *req);
55
56
57extern void nfs_list_add_request(struct nfs_page *, struct list_head *);
58
59extern int nfs_scan_list(struct list_head *, struct list_head *,
60 unsigned long, unsigned int);
61extern int nfs_coalesce_requests(struct list_head *, struct list_head *,
62 unsigned int);
63extern int nfs_wait_on_request(struct nfs_page *);
64extern void nfs_unlock_request(struct nfs_page *req);
65
66/*
67 * Lock the page of an asynchronous request without incrementing the wb_count
68 */
69static inline int
70nfs_lock_request_dontget(struct nfs_page *req)
71{
72 if (test_and_set_bit(PG_BUSY, &req->wb_flags))
73 return 0;
74 return 1;
75}
76
77/*
78 * Lock the page of an asynchronous request
79 */
80static inline int
81nfs_lock_request(struct nfs_page *req)
82{
83 if (test_and_set_bit(PG_BUSY, &req->wb_flags))
84 return 0;
85 atomic_inc(&req->wb_count);
86 return 1;
87}
88
89
90/**
91 * nfs_list_remove_request - Remove a request from its wb_list
92 * @req: request
93 */
94static inline void
95nfs_list_remove_request(struct nfs_page *req)
96{
97 if (list_empty(&req->wb_list))
98 return;
99 if (!NFS_WBACK_BUSY(req)) {
100 printk(KERN_ERR "NFS: unlocked request attempted removed from list!\n");
101 BUG();
102 }
103 list_del_init(&req->wb_list);
104 req->wb_list_head = NULL;
105}
106
107static inline int
108nfs_defer_commit(struct nfs_page *req)
109{
110 if (test_and_set_bit(PG_NEED_COMMIT, &req->wb_flags))
111 return 0;
112 return 1;
113}
114
115static inline void
116nfs_clear_commit(struct nfs_page *req)
117{
118 smp_mb__before_clear_bit();
119 clear_bit(PG_NEED_COMMIT, &req->wb_flags);
120 smp_mb__after_clear_bit();
121}
122
123static inline int
124nfs_defer_reschedule(struct nfs_page *req)
125{
126 if (test_and_set_bit(PG_NEED_RESCHED, &req->wb_flags))
127 return 0;
128 return 1;
129}
130
131static inline void
132nfs_clear_reschedule(struct nfs_page *req)
133{
134 smp_mb__before_clear_bit();
135 clear_bit(PG_NEED_RESCHED, &req->wb_flags);
136 smp_mb__after_clear_bit();
137}
138
139static inline struct nfs_page *
140nfs_list_entry(struct list_head *head)
141{
142 return list_entry(head, struct nfs_page, wb_list);
143}
144
145static inline
146loff_t req_offset(struct nfs_page *req)
147{
148 return (((loff_t)req->wb_index) << PAGE_CACHE_SHIFT) + req->wb_offset;
149}
150
151#endif /* _LINUX_NFS_PAGE_H */
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
new file mode 100644
index 000000000000..47037d9521cb
--- /dev/null
+++ b/include/linux/nfs_xdr.h
@@ -0,0 +1,735 @@
1#ifndef _LINUX_NFS_XDR_H
2#define _LINUX_NFS_XDR_H
3
4#include <linux/sunrpc/xprt.h>
5
6struct nfs4_fsid {
7 __u64 major;
8 __u64 minor;
9};
10
11struct nfs_fattr {
12 unsigned short valid; /* which fields are valid */
13 __u64 pre_size; /* pre_op_attr.size */
14 struct timespec pre_mtime; /* pre_op_attr.mtime */
15 struct timespec pre_ctime; /* pre_op_attr.ctime */
16 enum nfs_ftype type; /* always use NFSv2 types */
17 __u32 mode;
18 __u32 nlink;
19 __u32 uid;
20 __u32 gid;
21 __u64 size;
22 union {
23 struct {
24 __u32 blocksize;
25 __u32 blocks;
26 } nfs2;
27 struct {
28 __u64 used;
29 } nfs3;
30 } du;
31 dev_t rdev;
32 union {
33 __u64 nfs3; /* also nfs2 */
34 struct nfs4_fsid nfs4;
35 } fsid_u;
36 __u64 fileid;
37 struct timespec atime;
38 struct timespec mtime;
39 struct timespec ctime;
40 __u32 bitmap[2]; /* NFSv4 returned attribute bitmap */
41 __u64 change_attr; /* NFSv4 change attribute */
42 __u64 pre_change_attr;/* pre-op NFSv4 change attribute */
43 unsigned long timestamp;
44};
45
46#define NFS_ATTR_WCC 0x0001 /* pre-op WCC data */
47#define NFS_ATTR_FATTR 0x0002 /* post-op attributes */
48#define NFS_ATTR_FATTR_V3 0x0004 /* NFSv3 attributes */
49#define NFS_ATTR_FATTR_V4 0x0008
50#define NFS_ATTR_PRE_CHANGE 0x0010
51
52/*
53 * Info on the file system
54 */
55struct nfs_fsinfo {
56 struct nfs_fattr *fattr; /* Post-op attributes */
57 __u32 rtmax; /* max. read transfer size */
58 __u32 rtpref; /* pref. read transfer size */
59 __u32 rtmult; /* reads should be multiple of this */
60 __u32 wtmax; /* max. write transfer size */
61 __u32 wtpref; /* pref. write transfer size */
62 __u32 wtmult; /* writes should be multiple of this */
63 __u32 dtpref; /* pref. readdir transfer size */
64 __u64 maxfilesize;
65 __u32 lease_time; /* in seconds */
66};
67
68struct nfs_fsstat {
69 struct nfs_fattr *fattr; /* Post-op attributes */
70 __u64 tbytes; /* total size in bytes */
71 __u64 fbytes; /* # of free bytes */
72 __u64 abytes; /* # of bytes available to user */
73 __u64 tfiles; /* # of files */
74 __u64 ffiles; /* # of free files */
75 __u64 afiles; /* # of files available to user */
76};
77
78struct nfs2_fsstat {
79 __u32 tsize; /* Server transfer size */
80 __u32 bsize; /* Filesystem block size */
81 __u32 blocks; /* No. of "bsize" blocks on filesystem */
82 __u32 bfree; /* No. of free "bsize" blocks */
83 __u32 bavail; /* No. of available "bsize" blocks */
84};
85
86struct nfs_pathconf {
87 struct nfs_fattr *fattr; /* Post-op attributes */
88 __u32 max_link; /* max # of hard links */
89 __u32 max_namelen; /* max name length */
90};
91
92struct nfs4_change_info {
93 u32 atomic;
94 u64 before;
95 u64 after;
96};
97
98/*
99 * Arguments to the open call.
100 */
101struct nfs_openargs {
102 const struct nfs_fh * fh;
103 __u32 seqid;
104 int open_flags;
105 __u64 clientid;
106 __u32 id;
107 union {
108 struct iattr * attrs; /* UNCHECKED, GUARDED */
109 nfs4_verifier verifier; /* EXCLUSIVE */
110 nfs4_stateid delegation; /* CLAIM_DELEGATE_CUR */
111 int delegation_type; /* CLAIM_PREVIOUS */
112 } u;
113 const struct qstr * name;
114 const struct nfs_server *server; /* Needed for ID mapping */
115 const u32 * bitmask;
116 __u32 claim;
117};
118
119struct nfs_openres {
120 nfs4_stateid stateid;
121 struct nfs_fh fh;
122 struct nfs4_change_info cinfo;
123 __u32 rflags;
124 struct nfs_fattr * f_attr;
125 const struct nfs_server *server;
126 int delegation_type;
127 nfs4_stateid delegation;
128 __u32 do_recall;
129 __u64 maxsize;
130};
131
132/*
133 * Arguments to the open_confirm call.
134 */
135struct nfs_open_confirmargs {
136 const struct nfs_fh * fh;
137 nfs4_stateid stateid;
138 __u32 seqid;
139};
140
141struct nfs_open_confirmres {
142 nfs4_stateid stateid;
143};
144
145/*
146 * Arguments to the close call.
147 */
148struct nfs_closeargs {
149 struct nfs_fh * fh;
150 nfs4_stateid stateid;
151 __u32 seqid;
152 int open_flags;
153};
154
155struct nfs_closeres {
156 nfs4_stateid stateid;
157};
158/*
159 * * Arguments to the lock,lockt, and locku call.
160 * */
161struct nfs_lowner {
162 __u64 clientid;
163 u32 id;
164};
165
166struct nfs_open_to_lock {
167 __u32 open_seqid;
168 nfs4_stateid open_stateid;
169 __u32 lock_seqid;
170 struct nfs_lowner lock_owner;
171};
172
173struct nfs_exist_lock {
174 nfs4_stateid stateid;
175 __u32 seqid;
176};
177
178struct nfs_lock_opargs {
179 __u32 reclaim;
180 __u32 new_lock_owner;
181 union {
182 struct nfs_open_to_lock *open_lock;
183 struct nfs_exist_lock *exist_lock;
184 } u;
185};
186
187struct nfs_locku_opargs {
188 __u32 seqid;
189 nfs4_stateid stateid;
190};
191
192struct nfs_lockargs {
193 struct nfs_fh * fh;
194 __u32 type;
195 __u64 offset;
196 __u64 length;
197 union {
198 struct nfs_lock_opargs *lock; /* LOCK */
199 struct nfs_lowner *lockt; /* LOCKT */
200 struct nfs_locku_opargs *locku; /* LOCKU */
201 } u;
202};
203
204struct nfs_lock_denied {
205 __u64 offset;
206 __u64 length;
207 __u32 type;
208 struct nfs_lowner owner;
209};
210
211struct nfs_lockres {
212 union {
213 nfs4_stateid stateid;/* LOCK success, LOCKU */
214 struct nfs_lock_denied denied; /* LOCK failed, LOCKT success */
215 } u;
216 const struct nfs_server * server;
217};
218
219struct nfs4_delegreturnargs {
220 const struct nfs_fh *fhandle;
221 const nfs4_stateid *stateid;
222};
223
224/*
225 * Arguments to the read call.
226 */
227
228#define NFS_READ_MAXIOV (9U)
229#if (NFS_READ_MAXIOV > (MAX_IOVEC -2))
230#error "NFS_READ_MAXIOV is too large"
231#endif
232
233struct nfs_readargs {
234 struct nfs_fh * fh;
235 struct nfs_open_context *context;
236 __u64 offset;
237 __u32 count;
238 unsigned int pgbase;
239 struct page ** pages;
240};
241
242struct nfs_readres {
243 struct nfs_fattr * fattr;
244 __u32 count;
245 int eof;
246};
247
248/*
249 * Arguments to the write call.
250 */
251#define NFS_WRITE_MAXIOV (9U)
252#if (NFS_WRITE_MAXIOV > (MAX_IOVEC -2))
253#error "NFS_WRITE_MAXIOV is too large"
254#endif
255
256struct nfs_writeargs {
257 struct nfs_fh * fh;
258 struct nfs_open_context *context;
259 __u64 offset;
260 __u32 count;
261 enum nfs3_stable_how stable;
262 unsigned int pgbase;
263 struct page ** pages;
264};
265
266struct nfs_writeverf {
267 enum nfs3_stable_how committed;
268 __u32 verifier[2];
269};
270
271struct nfs_writeres {
272 struct nfs_fattr * fattr;
273 struct nfs_writeverf * verf;
274 __u32 count;
275};
276
277/*
278 * Argument struct for decode_entry function
279 */
280struct nfs_entry {
281 __u64 ino;
282 __u64 cookie,
283 prev_cookie;
284 const char * name;
285 unsigned int len;
286 int eof;
287 struct nfs_fh * fh;
288 struct nfs_fattr * fattr;
289};
290
291/*
292 * The following types are for NFSv2 only.
293 */
294struct nfs_sattrargs {
295 struct nfs_fh * fh;
296 struct iattr * sattr;
297};
298
299struct nfs_diropargs {
300 struct nfs_fh * fh;
301 const char * name;
302 unsigned int len;
303};
304
305struct nfs_createargs {
306 struct nfs_fh * fh;
307 const char * name;
308 unsigned int len;
309 struct iattr * sattr;
310};
311
312struct nfs_renameargs {
313 struct nfs_fh * fromfh;
314 const char * fromname;
315 unsigned int fromlen;
316 struct nfs_fh * tofh;
317 const char * toname;
318 unsigned int tolen;
319};
320
321struct nfs_setattrargs {
322 struct nfs_fh * fh;
323 nfs4_stateid stateid;
324 struct iattr * iap;
325 const struct nfs_server * server; /* Needed for name mapping */
326 const u32 * bitmask;
327};
328
329struct nfs_setattrres {
330 struct nfs_fattr * fattr;
331 const struct nfs_server * server;
332};
333
334struct nfs_linkargs {
335 struct nfs_fh * fromfh;
336 struct nfs_fh * tofh;
337 const char * toname;
338 unsigned int tolen;
339};
340
341struct nfs_symlinkargs {
342 struct nfs_fh * fromfh;
343 const char * fromname;
344 unsigned int fromlen;
345 const char * topath;
346 unsigned int tolen;
347 struct iattr * sattr;
348};
349
350struct nfs_readdirargs {
351 struct nfs_fh * fh;
352 __u32 cookie;
353 unsigned int count;
354 struct page ** pages;
355};
356
357struct nfs_diropok {
358 struct nfs_fh * fh;
359 struct nfs_fattr * fattr;
360};
361
362struct nfs_readlinkargs {
363 struct nfs_fh * fh;
364 unsigned int pgbase;
365 unsigned int pglen;
366 struct page ** pages;
367};
368
369struct nfs3_sattrargs {
370 struct nfs_fh * fh;
371 struct iattr * sattr;
372 unsigned int guard;
373 struct timespec guardtime;
374};
375
376struct nfs3_diropargs {
377 struct nfs_fh * fh;
378 const char * name;
379 unsigned int len;
380};
381
382struct nfs3_accessargs {
383 struct nfs_fh * fh;
384 __u32 access;
385};
386
387struct nfs3_createargs {
388 struct nfs_fh * fh;
389 const char * name;
390 unsigned int len;
391 struct iattr * sattr;
392 enum nfs3_createmode createmode;
393 __u32 verifier[2];
394};
395
396struct nfs3_mkdirargs {
397 struct nfs_fh * fh;
398 const char * name;
399 unsigned int len;
400 struct iattr * sattr;
401};
402
403struct nfs3_symlinkargs {
404 struct nfs_fh * fromfh;
405 const char * fromname;
406 unsigned int fromlen;
407 const char * topath;
408 unsigned int tolen;
409 struct iattr * sattr;
410};
411
412struct nfs3_mknodargs {
413 struct nfs_fh * fh;
414 const char * name;
415 unsigned int len;
416 enum nfs3_ftype type;
417 struct iattr * sattr;
418 dev_t rdev;
419};
420
421struct nfs3_renameargs {
422 struct nfs_fh * fromfh;
423 const char * fromname;
424 unsigned int fromlen;
425 struct nfs_fh * tofh;
426 const char * toname;
427 unsigned int tolen;
428};
429
430struct nfs3_linkargs {
431 struct nfs_fh * fromfh;
432 struct nfs_fh * tofh;
433 const char * toname;
434 unsigned int tolen;
435};
436
437struct nfs3_readdirargs {
438 struct nfs_fh * fh;
439 __u64 cookie;
440 __u32 verf[2];
441 int plus;
442 unsigned int count;
443 struct page ** pages;
444};
445
446struct nfs3_diropres {
447 struct nfs_fattr * dir_attr;
448 struct nfs_fh * fh;
449 struct nfs_fattr * fattr;
450};
451
452struct nfs3_accessres {
453 struct nfs_fattr * fattr;
454 __u32 access;
455};
456
457struct nfs3_readlinkargs {
458 struct nfs_fh * fh;
459 unsigned int pgbase;
460 unsigned int pglen;
461 struct page ** pages;
462};
463
464struct nfs3_renameres {
465 struct nfs_fattr * fromattr;
466 struct nfs_fattr * toattr;
467};
468
469struct nfs3_linkres {
470 struct nfs_fattr * dir_attr;
471 struct nfs_fattr * fattr;
472};
473
474struct nfs3_readdirres {
475 struct nfs_fattr * dir_attr;
476 __u32 * verf;
477 int plus;
478};
479
480#ifdef CONFIG_NFS_V4
481
482typedef u64 clientid4;
483
484struct nfs4_accessargs {
485 const struct nfs_fh * fh;
486 u32 access;
487};
488
489struct nfs4_accessres {
490 u32 supported;
491 u32 access;
492};
493
494struct nfs4_create_arg {
495 u32 ftype;
496 union {
497 struct qstr * symlink; /* NF4LNK */
498 struct {
499 u32 specdata1;
500 u32 specdata2;
501 } device; /* NF4BLK, NF4CHR */
502 } u;
503 const struct qstr * name;
504 const struct nfs_server * server;
505 const struct iattr * attrs;
506 const struct nfs_fh * dir_fh;
507 const u32 * bitmask;
508};
509
510struct nfs4_create_res {
511 const struct nfs_server * server;
512 struct nfs_fh * fh;
513 struct nfs_fattr * fattr;
514 struct nfs4_change_info dir_cinfo;
515};
516
517struct nfs4_fsinfo_arg {
518 const struct nfs_fh * fh;
519 const u32 * bitmask;
520};
521
522struct nfs4_getattr_arg {
523 const struct nfs_fh * fh;
524 const u32 * bitmask;
525};
526
527struct nfs4_getattr_res {
528 const struct nfs_server * server;
529 struct nfs_fattr * fattr;
530};
531
532struct nfs4_link_arg {
533 const struct nfs_fh * fh;
534 const struct nfs_fh * dir_fh;
535 const struct qstr * name;
536};
537
538struct nfs4_lookup_arg {
539 const struct nfs_fh * dir_fh;
540 const struct qstr * name;
541 const u32 * bitmask;
542};
543
544struct nfs4_lookup_res {
545 const struct nfs_server * server;
546 struct nfs_fattr * fattr;
547 struct nfs_fh * fh;
548};
549
550struct nfs4_lookup_root_arg {
551 const u32 * bitmask;
552};
553
554struct nfs4_pathconf_arg {
555 const struct nfs_fh * fh;
556 const u32 * bitmask;
557};
558
559struct nfs4_readdir_arg {
560 const struct nfs_fh * fh;
561 u64 cookie;
562 nfs4_verifier verifier;
563 u32 count;
564 struct page ** pages; /* zero-copy data */
565 unsigned int pgbase; /* zero-copy data */
566 const u32 * bitmask;
567};
568
569struct nfs4_readdir_res {
570 nfs4_verifier verifier;
571 unsigned int pgbase;
572};
573
574struct nfs4_readlink {
575 const struct nfs_fh * fh;
576 unsigned int pgbase;
577 unsigned int pglen; /* zero-copy data */
578 struct page ** pages; /* zero-copy data */
579};
580
581struct nfs4_remove_arg {
582 const struct nfs_fh * fh;
583 const struct qstr * name;
584};
585
586struct nfs4_rename_arg {
587 const struct nfs_fh * old_dir;
588 const struct nfs_fh * new_dir;
589 const struct qstr * old_name;
590 const struct qstr * new_name;
591};
592
593struct nfs4_rename_res {
594 struct nfs4_change_info old_cinfo;
595 struct nfs4_change_info new_cinfo;
596};
597
598struct nfs4_setclientid {
599 const nfs4_verifier * sc_verifier; /* request */
600 unsigned int sc_name_len;
601 char sc_name[32]; /* request */
602 u32 sc_prog; /* request */
603 unsigned int sc_netid_len;
604 char sc_netid[4]; /* request */
605 unsigned int sc_uaddr_len;
606 char sc_uaddr[24]; /* request */
607 u32 sc_cb_ident; /* request */
608};
609
610struct nfs4_statfs_arg {
611 const struct nfs_fh * fh;
612 const u32 * bitmask;
613};
614
615struct nfs4_server_caps_res {
616 u32 attr_bitmask[2];
617 u32 acl_bitmask;
618 u32 has_links;
619 u32 has_symlinks;
620};
621
622#endif /* CONFIG_NFS_V4 */
623
624struct nfs_page;
625
626struct nfs_read_data {
627 int flags;
628 struct rpc_task task;
629 struct inode *inode;
630 struct rpc_cred *cred;
631 struct nfs_fattr fattr; /* fattr storage */
632 struct list_head pages; /* Coalesced read requests */
633 struct nfs_page *req; /* multi ops per nfs_page */
634 struct page *pagevec[NFS_READ_MAXIOV];
635 struct nfs_readargs args;
636 struct nfs_readres res;
637#ifdef CONFIG_NFS_V4
638 unsigned long timestamp; /* For lease renewal */
639#endif
640 void (*complete) (struct nfs_read_data *, int);
641};
642
643struct nfs_write_data {
644 int flags;
645 struct rpc_task task;
646 struct inode *inode;
647 struct rpc_cred *cred;
648 struct nfs_fattr fattr;
649 struct nfs_writeverf verf;
650 struct list_head pages; /* Coalesced requests we wish to flush */
651 struct nfs_page *req; /* multi ops per nfs_page */
652 struct page *pagevec[NFS_WRITE_MAXIOV];
653 struct nfs_writeargs args; /* argument struct */
654 struct nfs_writeres res; /* result struct */
655#ifdef CONFIG_NFS_V4
656 unsigned long timestamp; /* For lease renewal */
657#endif
658 void (*complete) (struct nfs_write_data *, int);
659};
660
661struct nfs_access_entry;
662
663/*
664 * RPC procedure vector for NFSv2/NFSv3 demuxing
665 */
666struct nfs_rpc_ops {
667 int version; /* Protocol version */
668 struct dentry_operations *dentry_ops;
669 struct inode_operations *dir_inode_ops;
670
671 int (*getroot) (struct nfs_server *, struct nfs_fh *,
672 struct nfs_fsinfo *);
673 int (*getattr) (struct nfs_server *, struct nfs_fh *,
674 struct nfs_fattr *);
675 int (*setattr) (struct dentry *, struct nfs_fattr *,
676 struct iattr *);
677 int (*lookup) (struct inode *, struct qstr *,
678 struct nfs_fh *, struct nfs_fattr *);
679 int (*access) (struct inode *, struct nfs_access_entry *);
680 int (*readlink)(struct inode *, struct page *, unsigned int,
681 unsigned int);
682 int (*read) (struct nfs_read_data *);
683 int (*write) (struct nfs_write_data *);
684 int (*commit) (struct nfs_write_data *);
685 int (*create) (struct inode *, struct dentry *,
686 struct iattr *, int);
687 int (*remove) (struct inode *, struct qstr *);
688 int (*unlink_setup) (struct rpc_message *,
689 struct dentry *, struct qstr *);
690 int (*unlink_done) (struct dentry *, struct rpc_task *);
691 int (*rename) (struct inode *, struct qstr *,
692 struct inode *, struct qstr *);
693 int (*link) (struct inode *, struct inode *, struct qstr *);
694 int (*symlink) (struct inode *, struct qstr *, struct qstr *,
695 struct iattr *, struct nfs_fh *,
696 struct nfs_fattr *);
697 int (*mkdir) (struct inode *, struct dentry *, struct iattr *);
698 int (*rmdir) (struct inode *, struct qstr *);
699 int (*readdir) (struct dentry *, struct rpc_cred *,
700 u64, struct page *, unsigned int, int);
701 int (*mknod) (struct inode *, struct dentry *, struct iattr *,
702 dev_t);
703 int (*statfs) (struct nfs_server *, struct nfs_fh *,
704 struct nfs_fsstat *);
705 int (*fsinfo) (struct nfs_server *, struct nfs_fh *,
706 struct nfs_fsinfo *);
707 int (*pathconf) (struct nfs_server *, struct nfs_fh *,
708 struct nfs_pathconf *);
709 u32 * (*decode_dirent)(u32 *, struct nfs_entry *, int plus);
710 void (*read_setup) (struct nfs_read_data *);
711 void (*write_setup) (struct nfs_write_data *, int how);
712 void (*commit_setup) (struct nfs_write_data *, int how);
713 int (*file_open) (struct inode *, struct file *);
714 int (*file_release) (struct inode *, struct file *);
715 int (*lock)(struct file *, int, struct file_lock *);
716};
717
718/*
719 * NFS_CALL(getattr, inode, (fattr));
720 * into
721 * NFS_PROTO(inode)->getattr(fattr);
722 */
723#define NFS_CALL(op, inode, args) NFS_PROTO(inode)->op args
724
725/*
726 * Function vectors etc. for the NFS client
727 */
728extern struct nfs_rpc_ops nfs_v2_clientops;
729extern struct nfs_rpc_ops nfs_v3_clientops;
730extern struct nfs_rpc_ops nfs_v4_clientops;
731extern struct rpc_version nfs_version2;
732extern struct rpc_version nfs_version3;
733extern struct rpc_version nfs_version4;
734
735#endif
diff --git a/include/linux/nfsd/auth.h b/include/linux/nfsd/auth.h
new file mode 100644
index 000000000000..0fb9f7212195
--- /dev/null
+++ b/include/linux/nfsd/auth.h
@@ -0,0 +1,27 @@
1/*
2 * include/linux/nfsd/auth.h
3 *
4 * nfsd-specific authentication stuff.
5 * uid/gid mapping not yet implemented.
6 *
7 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
8 */
9
10#ifndef LINUX_NFSD_AUTH_H
11#define LINUX_NFSD_AUTH_H
12
13#ifdef __KERNEL__
14
15#define nfsd_luid(rq, uid) ((u32)(uid))
16#define nfsd_lgid(rq, gid) ((u32)(gid))
17#define nfsd_ruid(rq, uid) ((u32)(uid))
18#define nfsd_rgid(rq, gid) ((u32)(gid))
19
20/*
21 * Set the current process's fsuid/fsgid etc to those of the NFS
22 * client user
23 */
24int nfsd_setuser(struct svc_rqst *, struct svc_export *);
25
26#endif /* __KERNEL__ */
27#endif /* LINUX_NFSD_AUTH_H */
diff --git a/include/linux/nfsd/cache.h b/include/linux/nfsd/cache.h
new file mode 100644
index 000000000000..c3a3557c2a5b
--- /dev/null
+++ b/include/linux/nfsd/cache.h
@@ -0,0 +1,81 @@
1/*
2 * include/linux/nfsd/cache.h
3 *
4 * Request reply cache. This was heavily inspired by the
5 * implementation in 4.3BSD/4.4BSD.
6 *
7 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
8 */
9
10#ifndef NFSCACHE_H
11#define NFSCACHE_H
12
13#ifdef __KERNEL__
14#include <linux/in.h>
15#include <linux/uio.h>
16
17/*
18 * Representation of a reply cache entry. The first two members *must*
19 * be hash_next and hash_prev.
20 */
21struct svc_cacherep {
22 struct hlist_node c_hash;
23 struct list_head c_lru;
24
25 unsigned char c_state, /* unused, inprog, done */
26 c_type, /* status, buffer */
27 c_secure : 1; /* req came from port < 1024 */
28 struct sockaddr_in c_addr;
29 u32 c_xid;
30 u32 c_prot;
31 u32 c_proc;
32 u32 c_vers;
33 unsigned long c_timestamp;
34 union {
35 struct kvec u_vec;
36 u32 u_status;
37 } c_u;
38};
39
40#define c_replvec c_u.u_vec
41#define c_replstat c_u.u_status
42
43/* cache entry states */
44enum {
45 RC_UNUSED,
46 RC_INPROG,
47 RC_DONE
48};
49
50/* return values */
51enum {
52 RC_DROPIT,
53 RC_REPLY,
54 RC_DOIT,
55 RC_INTR
56};
57
58/*
59 * Cache types.
60 * We may want to add more types one day, e.g. for diropres and
61 * attrstat replies. Using cache entries with fixed length instead
62 * of buffer pointers may be more efficient.
63 */
64enum {
65 RC_NOCACHE,
66 RC_REPLSTAT,
67 RC_REPLBUFF,
68};
69
70/*
71 * If requests are retransmitted within this interval, they're dropped.
72 */
73#define RC_DELAY (HZ/5)
74
75void nfsd_cache_init(void);
76void nfsd_cache_shutdown(void);
77int nfsd_cache_lookup(struct svc_rqst *, int);
78void nfsd_cache_update(struct svc_rqst *, int, u32 *);
79
80#endif /* __KERNEL__ */
81#endif /* NFSCACHE_H */
diff --git a/include/linux/nfsd/const.h b/include/linux/nfsd/const.h
new file mode 100644
index 000000000000..b75bb1b38d09
--- /dev/null
+++ b/include/linux/nfsd/const.h
@@ -0,0 +1,45 @@
1/*
2 * include/linux/nfsd/const.h
3 *
4 * Various constants related to NFS.
5 *
6 * Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de>
7 */
8
9#ifndef _LINUX_NFSD_CONST_H
10#define _LINUX_NFSD_CONST_H
11
12#include <linux/nfs.h>
13#include <linux/nfs2.h>
14#include <linux/nfs3.h>
15#include <linux/nfs4.h>
16
17/*
18 * Maximum protocol version supported by knfsd
19 */
20#define NFSSVC_MAXVERS 3
21
22/*
23 * Maximum blocksize supported by daemon currently at 32K
24 */
25#define NFSSVC_MAXBLKSIZE (32*1024)
26
27#ifdef __KERNEL__
28
29#ifndef NFS_SUPER_MAGIC
30# define NFS_SUPER_MAGIC 0x6969
31#endif
32
33#define NFSD_BUFSIZE (1024 + NFSSVC_MAXBLKSIZE)
34
35#ifdef CONFIG_NFSD_V4
36# define NFSSVC_XDRSIZE NFS4_SVC_XDRSIZE
37#elif defined(CONFIG_NFSD_V3)
38# define NFSSVC_XDRSIZE NFS3_SVC_XDRSIZE
39#else
40# define NFSSVC_XDRSIZE NFS2_SVC_XDRSIZE
41#endif
42
43#endif /* __KERNEL__ */
44
45#endif /* _LINUX_NFSD_CONST_H */
diff --git a/include/linux/nfsd/debug.h b/include/linux/nfsd/debug.h
new file mode 100644
index 000000000000..ee4aa91788e7
--- /dev/null
+++ b/include/linux/nfsd/debug.h
@@ -0,0 +1,48 @@
1/*
2 * linux/include/linux/nfsd/debug.h
3 *
4 * Debugging-related stuff for nfsd
5 *
6 * Copyright (C) 1995 Olaf Kirch <okir@monad.swb.de>
7 */
8
9#ifndef LINUX_NFSD_DEBUG_H
10#define LINUX_NFSD_DEBUG_H
11
12#include <linux/sunrpc/debug.h>
13
14/*
15 * Enable debugging for nfsd.
16 * Requires RPC_DEBUG.
17 */
18#ifdef RPC_DEBUG
19# define NFSD_DEBUG 1
20#endif
21
22/*
23 * knfsd debug flags
24 */
25#define NFSDDBG_SOCK 0x0001
26#define NFSDDBG_FH 0x0002
27#define NFSDDBG_EXPORT 0x0004
28#define NFSDDBG_SVC 0x0008
29#define NFSDDBG_PROC 0x0010
30#define NFSDDBG_FILEOP 0x0020
31#define NFSDDBG_AUTH 0x0040
32#define NFSDDBG_REPCACHE 0x0080
33#define NFSDDBG_XDR 0x0100
34#define NFSDDBG_LOCKD 0x0200
35#define NFSDDBG_ALL 0x7FFF
36#define NFSDDBG_NOCHANGE 0xFFFF
37
38
39#ifdef __KERNEL__
40# undef ifdebug
41# ifdef NFSD_DEBUG
42# define ifdebug(flag) if (nfsd_debug & NFSDDBG_##flag)
43# else
44# define ifdebug(flag) if (0)
45# endif
46#endif /* __KERNEL__ */
47
48#endif /* LINUX_NFSD_DEBUG_H */
diff --git a/include/linux/nfsd/export.h b/include/linux/nfsd/export.h
new file mode 100644
index 000000000000..6bad4766d3d9
--- /dev/null
+++ b/include/linux/nfsd/export.h
@@ -0,0 +1,137 @@
1/*
2 * include/linux/nfsd/export.h
3 *
4 * Public declarations for NFS exports. The definitions for the
5 * syscall interface are in nfsctl.h
6 *
7 * Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de>
8 */
9
10#ifndef NFSD_EXPORT_H
11#define NFSD_EXPORT_H
12
13#include <asm/types.h>
14#ifdef __KERNEL__
15# include <linux/types.h>
16# include <linux/in.h>
17#endif
18
19/*
20 * Important limits for the exports stuff.
21 */
22#define NFSCLNT_IDMAX 1024
23#define NFSCLNT_ADDRMAX 16
24#define NFSCLNT_KEYMAX 32
25
26/*
27 * Export flags.
28 */
29#define NFSEXP_READONLY 0x0001
30#define NFSEXP_INSECURE_PORT 0x0002
31#define NFSEXP_ROOTSQUASH 0x0004
32#define NFSEXP_ALLSQUASH 0x0008
33#define NFSEXP_ASYNC 0x0010
34#define NFSEXP_GATHERED_WRITES 0x0020
35/* 40 80 100 currently unused */
36#define NFSEXP_NOHIDE 0x0200
37#define NFSEXP_NOSUBTREECHECK 0x0400
38#define NFSEXP_NOAUTHNLM 0x0800 /* Don't authenticate NLM requests - just trust */
39#define NFSEXP_MSNFS 0x1000 /* do silly things that MS clients expect */
40#define NFSEXP_FSID 0x2000
41#define NFSEXP_CROSSMOUNT 0x4000
42#define NFSEXP_NOACL 0x8000 /* reserved for possible ACL related use */
43#define NFSEXP_ALLFLAGS 0xFE3F
44
45
46#ifdef __KERNEL__
47
48struct svc_export {
49 struct cache_head h;
50 struct auth_domain * ex_client;
51 int ex_flags;
52 struct vfsmount * ex_mnt;
53 struct dentry * ex_dentry;
54 uid_t ex_anon_uid;
55 gid_t ex_anon_gid;
56 int ex_fsid;
57};
58
59/* an "export key" (expkey) maps a filehandlefragement to an
60 * svc_export for a given client. There can be two per export, one
61 * for type 0 (dev/ino), one for type 1 (fsid)
62 */
63struct svc_expkey {
64 struct cache_head h;
65
66 struct auth_domain * ek_client;
67 int ek_fsidtype;
68 u32 ek_fsid[3];
69
70 struct svc_export * ek_export;
71};
72
73#define EX_SECURE(exp) (!((exp)->ex_flags & NFSEXP_INSECURE_PORT))
74#define EX_ISSYNC(exp) (!((exp)->ex_flags & NFSEXP_ASYNC))
75#define EX_RDONLY(exp) ((exp)->ex_flags & NFSEXP_READONLY)
76#define EX_NOHIDE(exp) ((exp)->ex_flags & NFSEXP_NOHIDE)
77#define EX_WGATHER(exp) ((exp)->ex_flags & NFSEXP_GATHERED_WRITES)
78
79
80/*
81 * Function declarations
82 */
83void nfsd_export_init(void);
84void nfsd_export_shutdown(void);
85void nfsd_export_flush(void);
86void exp_readlock(void);
87void exp_readunlock(void);
88struct svc_expkey * exp_find_key(struct auth_domain *clp,
89 int fsid_type, u32 *fsidv,
90 struct cache_req *reqp);
91struct svc_export * exp_get_by_name(struct auth_domain *clp,
92 struct vfsmount *mnt,
93 struct dentry *dentry,
94 struct cache_req *reqp);
95struct svc_export * exp_parent(struct auth_domain *clp,
96 struct vfsmount *mnt,
97 struct dentry *dentry,
98 struct cache_req *reqp);
99int exp_rootfh(struct auth_domain *,
100 char *path, struct knfsd_fh *, int maxsize);
101int exp_pseudoroot(struct auth_domain *, struct svc_fh *fhp, struct cache_req *creq);
102int nfserrno(int errno);
103
104extern void expkey_put(struct cache_head *item, struct cache_detail *cd);
105extern void svc_export_put(struct cache_head *item, struct cache_detail *cd);
106extern struct cache_detail svc_export_cache, svc_expkey_cache;
107
108static inline void exp_put(struct svc_export *exp)
109{
110 svc_export_put(&exp->h, &svc_export_cache);
111}
112
113static inline void exp_get(struct svc_export *exp)
114{
115 cache_get(&exp->h);
116}
117static inline struct svc_export *
118exp_find(struct auth_domain *clp, int fsid_type, u32 *fsidv,
119 struct cache_req *reqp)
120{
121 struct svc_expkey *ek = exp_find_key(clp, fsid_type, fsidv, reqp);
122 if (ek && !IS_ERR(ek)) {
123 struct svc_export *exp = ek->ek_export;
124 int err;
125 exp_get(exp);
126 expkey_put(&ek->h, &svc_expkey_cache);
127 if ((err = cache_check(&svc_export_cache, &exp->h, reqp)))
128 exp = ERR_PTR(err);
129 return exp;
130 } else
131 return ERR_PTR(PTR_ERR(ek));
132}
133
134#endif /* __KERNEL__ */
135
136#endif /* NFSD_EXPORT_H */
137
diff --git a/include/linux/nfsd/interface.h b/include/linux/nfsd/interface.h
new file mode 100644
index 000000000000..af0979704afb
--- /dev/null
+++ b/include/linux/nfsd/interface.h
@@ -0,0 +1,13 @@
1/*
2 * include/linux/nfsd/interface.h
3 *
4 * defines interface between nfsd and other bits of
5 * the kernel. Particularly filesystems (eventually).
6 *
7 * Copyright (C) 2000 Neil Brown <neilb@cse.unsw.edu.au>
8 */
9
10#ifndef LINUX_NFSD_INTERFACE_H
11#define LINUX_NFSD_INTERFACE_H
12
13#endif /* LINUX_NFSD_INTERFACE_H */
diff --git a/include/linux/nfsd/nfsd.h b/include/linux/nfsd/nfsd.h
new file mode 100644
index 000000000000..8f85d9a59607
--- /dev/null
+++ b/include/linux/nfsd/nfsd.h
@@ -0,0 +1,311 @@
1/*
2 * linux/include/linux/nfsd/nfsd.h
3 *
4 * Hodge-podge collection of knfsd-related stuff.
5 * I will sort this out later.
6 *
7 * Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de>
8 */
9
10#ifndef LINUX_NFSD_NFSD_H
11#define LINUX_NFSD_NFSD_H
12
13#include <linux/config.h>
14#include <linux/types.h>
15#include <linux/unistd.h>
16#include <linux/dirent.h>
17#include <linux/fs.h>
18#include <linux/mount.h>
19
20#include <linux/nfsd/debug.h>
21#include <linux/nfsd/nfsfh.h>
22#include <linux/nfsd/export.h>
23#include <linux/nfsd/auth.h>
24#include <linux/nfsd/stats.h>
25#include <linux/nfsd/interface.h>
26/*
27 * nfsd version
28 */
29#define NFSD_VERSION "0.5"
30#define NFSD_SUPPORTED_MINOR_VERSION 0
31
32#ifdef __KERNEL__
33/*
34 * Special flags for nfsd_permission. These must be different from MAY_READ,
35 * MAY_WRITE, and MAY_EXEC.
36 */
37#define MAY_NOP 0
38#define MAY_SATTR 8
39#define MAY_TRUNC 16
40#define MAY_LOCK 32
41#define MAY_OWNER_OVERRIDE 64
42#define MAY_LOCAL_ACCESS 128 /* IRIX doing local access check on device special file*/
43#if (MAY_SATTR | MAY_TRUNC | MAY_LOCK | MAY_OWNER_OVERRIDE | MAY_LOCAL_ACCESS) & (MAY_READ | MAY_WRITE | MAY_EXEC)
44# error "please use a different value for MAY_SATTR or MAY_TRUNC or MAY_LOCK or MAY_LOCAL_ACCESS or MAY_OWNER_OVERRIDE."
45#endif
46#define MAY_CREATE (MAY_EXEC|MAY_WRITE)
47#define MAY_REMOVE (MAY_EXEC|MAY_WRITE|MAY_TRUNC)
48
49/*
50 * Callback function for readdir
51 */
52struct readdir_cd {
53 int err; /* 0, nfserr, or nfserr_eof */
54};
55typedef int (*encode_dent_fn)(struct readdir_cd *, const char *,
56 int, loff_t, ino_t, unsigned int);
57typedef int (*nfsd_dirop_t)(struct inode *, struct dentry *, int, int);
58
59extern struct svc_program nfsd_program;
60extern struct svc_version nfsd_version2, nfsd_version3,
61 nfsd_version4;
62
63/*
64 * Function prototypes.
65 */
66int nfsd_svc(unsigned short port, int nrservs);
67int nfsd_dispatch(struct svc_rqst *rqstp, u32 *statp);
68
69/* nfsd/vfs.c */
70int fh_lock_parent(struct svc_fh *, struct dentry *);
71int nfsd_racache_init(int);
72void nfsd_racache_shutdown(void);
73int nfsd_cross_mnt(struct svc_rqst *rqstp, struct dentry **dpp,
74 struct svc_export **expp);
75int nfsd_lookup(struct svc_rqst *, struct svc_fh *,
76 const char *, int, struct svc_fh *);
77int nfsd_setattr(struct svc_rqst *, struct svc_fh *,
78 struct iattr *, int, time_t);
79#ifdef CONFIG_NFSD_V4
80int nfsd4_set_nfs4_acl(struct svc_rqst *, struct svc_fh *,
81 struct nfs4_acl *);
82int nfsd4_get_nfs4_acl(struct svc_rqst *, struct dentry *, struct nfs4_acl **);
83#endif /* CONFIG_NFSD_V4 */
84int nfsd_create(struct svc_rqst *, struct svc_fh *,
85 char *name, int len, struct iattr *attrs,
86 int type, dev_t rdev, struct svc_fh *res);
87#ifdef CONFIG_NFSD_V3
88int nfsd_access(struct svc_rqst *, struct svc_fh *, u32 *, u32 *);
89int nfsd_create_v3(struct svc_rqst *, struct svc_fh *,
90 char *name, int len, struct iattr *attrs,
91 struct svc_fh *res, int createmode,
92 u32 *verifier, int *truncp);
93int nfsd_commit(struct svc_rqst *, struct svc_fh *,
94 loff_t, unsigned long);
95#endif /* CONFIG_NFSD_V3 */
96int nfsd_open(struct svc_rqst *, struct svc_fh *, int,
97 int, struct file **);
98void nfsd_close(struct file *);
99int nfsd_read(struct svc_rqst *, struct svc_fh *, struct file *,
100 loff_t, struct kvec *, int, unsigned long *);
101int nfsd_write(struct svc_rqst *, struct svc_fh *,struct file *,
102 loff_t, struct kvec *,int, unsigned long, int *);
103int nfsd_readlink(struct svc_rqst *, struct svc_fh *,
104 char *, int *);
105int nfsd_symlink(struct svc_rqst *, struct svc_fh *,
106 char *name, int len, char *path, int plen,
107 struct svc_fh *res, struct iattr *);
108int nfsd_link(struct svc_rqst *, struct svc_fh *,
109 char *, int, struct svc_fh *);
110int nfsd_rename(struct svc_rqst *,
111 struct svc_fh *, char *, int,
112 struct svc_fh *, char *, int);
113int nfsd_remove(struct svc_rqst *,
114 struct svc_fh *, char *, int);
115int nfsd_unlink(struct svc_rqst *, struct svc_fh *, int type,
116 char *name, int len);
117int nfsd_truncate(struct svc_rqst *, struct svc_fh *,
118 unsigned long size);
119int nfsd_readdir(struct svc_rqst *, struct svc_fh *,
120 loff_t *, struct readdir_cd *, encode_dent_fn);
121int nfsd_statfs(struct svc_rqst *, struct svc_fh *,
122 struct kstatfs *);
123
124int nfsd_notify_change(struct inode *, struct iattr *);
125int nfsd_permission(struct svc_export *, struct dentry *, int);
126
127
128/*
129 * NFSv4 State
130 */
131#ifdef CONFIG_NFSD_V4
132int nfs4_state_init(void);
133void nfs4_state_shutdown(void);
134time_t nfs4_lease_time(void);
135void nfs4_reset_lease(time_t leasetime);
136#else
137static inline int nfs4_state_init(void){return 0;}
138static inline void nfs4_state_shutdown(void){}
139static inline time_t nfs4_lease_time(void){return 0;}
140static inline void nfs4_reset_lease(time_t leasetime){}
141#endif
142
143/*
144 * lockd binding
145 */
146void nfsd_lockd_init(void);
147void nfsd_lockd_shutdown(void);
148
149
150/*
151 * These macros provide pre-xdr'ed values for faster operation.
152 */
153#define nfs_ok __constant_htonl(NFS_OK)
154#define nfserr_perm __constant_htonl(NFSERR_PERM)
155#define nfserr_noent __constant_htonl(NFSERR_NOENT)
156#define nfserr_io __constant_htonl(NFSERR_IO)
157#define nfserr_nxio __constant_htonl(NFSERR_NXIO)
158#define nfserr_eagain __constant_htonl(NFSERR_EAGAIN)
159#define nfserr_acces __constant_htonl(NFSERR_ACCES)
160#define nfserr_exist __constant_htonl(NFSERR_EXIST)
161#define nfserr_xdev __constant_htonl(NFSERR_XDEV)
162#define nfserr_nodev __constant_htonl(NFSERR_NODEV)
163#define nfserr_notdir __constant_htonl(NFSERR_NOTDIR)
164#define nfserr_isdir __constant_htonl(NFSERR_ISDIR)
165#define nfserr_inval __constant_htonl(NFSERR_INVAL)
166#define nfserr_fbig __constant_htonl(NFSERR_FBIG)
167#define nfserr_nospc __constant_htonl(NFSERR_NOSPC)
168#define nfserr_rofs __constant_htonl(NFSERR_ROFS)
169#define nfserr_mlink __constant_htonl(NFSERR_MLINK)
170#define nfserr_opnotsupp __constant_htonl(NFSERR_OPNOTSUPP)
171#define nfserr_nametoolong __constant_htonl(NFSERR_NAMETOOLONG)
172#define nfserr_notempty __constant_htonl(NFSERR_NOTEMPTY)
173#define nfserr_dquot __constant_htonl(NFSERR_DQUOT)
174#define nfserr_stale __constant_htonl(NFSERR_STALE)
175#define nfserr_remote __constant_htonl(NFSERR_REMOTE)
176#define nfserr_wflush __constant_htonl(NFSERR_WFLUSH)
177#define nfserr_badhandle __constant_htonl(NFSERR_BADHANDLE)
178#define nfserr_notsync __constant_htonl(NFSERR_NOT_SYNC)
179#define nfserr_badcookie __constant_htonl(NFSERR_BAD_COOKIE)
180#define nfserr_notsupp __constant_htonl(NFSERR_NOTSUPP)
181#define nfserr_toosmall __constant_htonl(NFSERR_TOOSMALL)
182#define nfserr_serverfault __constant_htonl(NFSERR_SERVERFAULT)
183#define nfserr_badtype __constant_htonl(NFSERR_BADTYPE)
184#define nfserr_jukebox __constant_htonl(NFSERR_JUKEBOX)
185#define nfserr_denied __constant_htonl(NFSERR_DENIED)
186#define nfserr_deadlock __constant_htonl(NFSERR_DEADLOCK)
187#define nfserr_expired __constant_htonl(NFSERR_EXPIRED)
188#define nfserr_bad_cookie __constant_htonl(NFSERR_BAD_COOKIE)
189#define nfserr_same __constant_htonl(NFSERR_SAME)
190#define nfserr_clid_inuse __constant_htonl(NFSERR_CLID_INUSE)
191#define nfserr_stale_clientid __constant_htonl(NFSERR_STALE_CLIENTID)
192#define nfserr_resource __constant_htonl(NFSERR_RESOURCE)
193#define nfserr_nofilehandle __constant_htonl(NFSERR_NOFILEHANDLE)
194#define nfserr_minor_vers_mismatch __constant_htonl(NFSERR_MINOR_VERS_MISMATCH)
195#define nfserr_share_denied __constant_htonl(NFSERR_SHARE_DENIED)
196#define nfserr_stale_stateid __constant_htonl(NFSERR_STALE_STATEID)
197#define nfserr_old_stateid __constant_htonl(NFSERR_OLD_STATEID)
198#define nfserr_bad_stateid __constant_htonl(NFSERR_BAD_STATEID)
199#define nfserr_bad_seqid __constant_htonl(NFSERR_BAD_SEQID)
200#define nfserr_symlink __constant_htonl(NFSERR_SYMLINK)
201#define nfserr_not_same __constant_htonl(NFSERR_NOT_SAME)
202#define nfserr_restorefh __constant_htonl(NFSERR_RESTOREFH)
203#define nfserr_attrnotsupp __constant_htonl(NFSERR_ATTRNOTSUPP)
204#define nfserr_bad_xdr __constant_htonl(NFSERR_BAD_XDR)
205#define nfserr_openmode __constant_htonl(NFSERR_OPENMODE)
206#define nfserr_locks_held __constant_htonl(NFSERR_LOCKS_HELD)
207#define nfserr_op_illegal __constant_htonl(NFSERR_OP_ILLEGAL)
208#define nfserr_grace __constant_htonl(NFSERR_GRACE)
209#define nfserr_no_grace __constant_htonl(NFSERR_NO_GRACE)
210#define nfserr_reclaim_bad __constant_htonl(NFSERR_RECLAIM_BAD)
211#define nfserr_badname __constant_htonl(NFSERR_BADNAME)
212#define nfserr_cb_path_down __constant_htonl(NFSERR_CB_PATH_DOWN)
213
214/* error codes for internal use */
215/* if a request fails due to kmalloc failure, it gets dropped.
216 * Client should resend eventually
217 */
218#define nfserr_dropit __constant_htonl(30000)
219/* end-of-file indicator in readdir */
220#define nfserr_eof __constant_htonl(30001)
221
222/* Check for dir entries '.' and '..' */
223#define isdotent(n, l) (l < 3 && n[0] == '.' && (l == 1 || n[1] == '.'))
224
225/*
226 * Time of server startup
227 */
228extern struct timeval nfssvc_boot;
229
230static inline int is_fsid(struct svc_fh *fh, struct knfsd_fh *reffh)
231{
232 if (fh->fh_export->ex_flags & NFSEXP_FSID) {
233 struct vfsmount *mnt = fh->fh_export->ex_mnt;
234 if (!old_valid_dev(mnt->mnt_sb->s_dev) ||
235 (reffh->fh_version == 1 && reffh->fh_fsid_type == 1))
236 return 1;
237 }
238 return 0;
239}
240
241
242#ifdef CONFIG_NFSD_V4
243
244/* before processing a COMPOUND operation, we have to check that there
245 * is enough space in the buffer for XDR encode to succeed. otherwise,
246 * we might process an operation with side effects, and be unable to
247 * tell the client that the operation succeeded.
248 *
249 * COMPOUND_SLACK_SPACE - this is the minimum amount of buffer space
250 * needed to encode an "ordinary" _successful_ operation. (GETATTR,
251 * READ, READDIR, and READLINK have their own buffer checks.) if we
252 * fall below this level, we fail the next operation with NFS4ERR_RESOURCE.
253 *
254 * COMPOUND_ERR_SLACK_SPACE - this is the minimum amount of buffer space
255 * needed to encode an operation which has failed with NFS4ERR_RESOURCE.
256 * care is taken to ensure that we never fall below this level for any
257 * reason.
258 */
259#define COMPOUND_SLACK_SPACE 140 /* OP_GETFH */
260#define COMPOUND_ERR_SLACK_SPACE 12 /* OP_SETATTR */
261
262#define NFSD_LEASE_TIME (nfs4_lease_time())
263#define NFSD_LAUNDROMAT_MINTIMEOUT 10 /* seconds */
264
265/*
266 * The following attributes are currently not supported by the NFSv4 server:
267 * ARCHIVE (deprecated anyway)
268 * FS_LOCATIONS (will be supported eventually)
269 * HIDDEN (unlikely to be supported any time soon)
270 * MIMETYPE (unlikely to be supported any time soon)
271 * QUOTA_* (will be supported in a forthcoming patch)
272 * SYSTEM (unlikely to be supported any time soon)
273 * TIME_BACKUP (unlikely to be supported any time soon)
274 * TIME_CREATE (unlikely to be supported any time soon)
275 */
276#define NFSD_SUPPORTED_ATTRS_WORD0 \
277(FATTR4_WORD0_SUPPORTED_ATTRS | FATTR4_WORD0_TYPE | FATTR4_WORD0_FH_EXPIRE_TYPE \
278 | FATTR4_WORD0_CHANGE | FATTR4_WORD0_SIZE | FATTR4_WORD0_LINK_SUPPORT \
279 | FATTR4_WORD0_SYMLINK_SUPPORT | FATTR4_WORD0_NAMED_ATTR | FATTR4_WORD0_FSID \
280 | FATTR4_WORD0_UNIQUE_HANDLES | FATTR4_WORD0_LEASE_TIME | FATTR4_WORD0_RDATTR_ERROR \
281 | FATTR4_WORD0_ACLSUPPORT | FATTR4_WORD0_CANSETTIME | FATTR4_WORD0_CASE_INSENSITIVE \
282 | FATTR4_WORD0_CASE_PRESERVING | FATTR4_WORD0_CHOWN_RESTRICTED \
283 | FATTR4_WORD0_FILEHANDLE | FATTR4_WORD0_FILEID | FATTR4_WORD0_FILES_AVAIL \
284 | FATTR4_WORD0_FILES_FREE | FATTR4_WORD0_FILES_TOTAL | FATTR4_WORD0_HOMOGENEOUS \
285 | FATTR4_WORD0_MAXFILESIZE | FATTR4_WORD0_MAXLINK | FATTR4_WORD0_MAXNAME \
286 | FATTR4_WORD0_MAXREAD | FATTR4_WORD0_MAXWRITE | FATTR4_WORD0_ACL)
287
288#define NFSD_SUPPORTED_ATTRS_WORD1 \
289(FATTR4_WORD1_MODE | FATTR4_WORD1_NO_TRUNC | FATTR4_WORD1_NUMLINKS \
290 | FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP | FATTR4_WORD1_RAWDEV \
291 | FATTR4_WORD1_SPACE_AVAIL | FATTR4_WORD1_SPACE_FREE | FATTR4_WORD1_SPACE_TOTAL \
292 | FATTR4_WORD1_SPACE_USED | FATTR4_WORD1_TIME_ACCESS | FATTR4_WORD1_TIME_ACCESS_SET \
293 | FATTR4_WORD1_TIME_DELTA | FATTR4_WORD1_TIME_METADATA \
294 | FATTR4_WORD1_TIME_MODIFY | FATTR4_WORD1_TIME_MODIFY_SET | FATTR4_WORD1_MOUNTED_ON_FILEID)
295
296/* These will return ERR_INVAL if specified in GETATTR or READDIR. */
297#define NFSD_WRITEONLY_ATTRS_WORD1 \
298(FATTR4_WORD1_TIME_ACCESS_SET | FATTR4_WORD1_TIME_MODIFY_SET)
299
300/* These are the only attrs allowed in CREATE/OPEN/SETATTR. */
301#define NFSD_WRITEABLE_ATTRS_WORD0 \
302(FATTR4_WORD0_SIZE | FATTR4_WORD0_ACL )
303#define NFSD_WRITEABLE_ATTRS_WORD1 \
304(FATTR4_WORD1_MODE | FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP \
305 | FATTR4_WORD1_TIME_ACCESS_SET | FATTR4_WORD1_TIME_METADATA | FATTR4_WORD1_TIME_MODIFY_SET)
306
307#endif /* CONFIG_NFSD_V4 */
308
309#endif /* __KERNEL__ */
310
311#endif /* LINUX_NFSD_NFSD_H */
diff --git a/include/linux/nfsd/nfsfh.h b/include/linux/nfsd/nfsfh.h
new file mode 100644
index 000000000000..bb842ea41033
--- /dev/null
+++ b/include/linux/nfsd/nfsfh.h
@@ -0,0 +1,343 @@
1/*
2 * include/linux/nfsd/nfsfh.h
3 *
4 * This file describes the layout of the file handles as passed
5 * over the wire.
6 *
7 * Earlier versions of knfsd used to sign file handles using keyed MD5
8 * or SHA. I've removed this code, because it doesn't give you more
9 * security than blocking external access to port 2049 on your firewall.
10 *
11 * Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de>
12 */
13
14#ifndef _LINUX_NFSD_FH_H
15#define _LINUX_NFSD_FH_H
16
17#include <asm/types.h>
18#ifdef __KERNEL__
19# include <linux/config.h>
20# include <linux/types.h>
21# include <linux/string.h>
22# include <linux/fs.h>
23#endif
24#include <linux/nfsd/const.h>
25#include <linux/nfsd/debug.h>
26
27/*
28 * This is the old "dentry style" Linux NFSv2 file handle.
29 *
30 * The xino and xdev fields are currently used to transport the
31 * ino/dev of the exported inode.
32 */
33struct nfs_fhbase_old {
34 __u32 fb_dcookie; /* dentry cookie - always 0xfeebbaca */
35 __u32 fb_ino; /* our inode number */
36 __u32 fb_dirino; /* dir inode number, 0 for directories */
37 __u32 fb_dev; /* our device */
38 __u32 fb_xdev;
39 __u32 fb_xino;
40 __u32 fb_generation;
41};
42
43/*
44 * This is the new flexible, extensible style NFSv2/v3 file handle.
45 * by Neil Brown <neilb@cse.unsw.edu.au> - March 2000
46 *
47 * The file handle is seens as a list of 4byte words.
48 * The first word contains a version number (1) and four descriptor bytes
49 * that tell how the remaining 3 variable length fields should be handled.
50 * These three bytes are auth_type, fsid_type and fileid_type.
51 *
52 * All 4byte values are in host-byte-order.
53 *
54 * The auth_type field specifies how the filehandle can be authenticated
55 * This might allow a file to be confirmed to be in a writable part of a
56 * filetree without checking the path from it upto the root.
57 * Current values:
58 * 0 - No authentication. fb_auth is 0 bytes long
59 * Possible future values:
60 * 1 - 4 bytes taken from MD5 hash of the remainer of the file handle
61 * prefixed by a secret and with the important export flags.
62 *
63 * The fsid_type identifies how the filesystem (or export point) is
64 * encoded.
65 * Current values:
66 * 0 - 4 byte device id (ms-2-bytes major, ls-2-bytes minor), 4byte inode number
67 * NOTE: we cannot use the kdev_t device id value, because kdev_t.h
68 * says we mustn't. We must break it up and reassemble.
69 * 1 - 4 byte user specified identifier
70 * 2 - 4 byte major, 4 byte minor, 4 byte inode number - DEPRECATED
71 * 3 - 4 byte device id, encoded for user-space, 4 byte inode number
72 *
73 * The fileid_type identified how the file within the filesystem is encoded.
74 * This is (will be) passed to, and set by, the underlying filesystem if it supports
75 * filehandle operations. The filesystem must not use the value '0' or '0xff' and may
76 * only use the values 1 and 2 as defined below:
77 * Current values:
78 * 0 - The root, or export point, of the filesystem. fb_fileid is 0 bytes.
79 * 1 - 32bit inode number, 32 bit generation number.
80 * 2 - 32bit inode number, 32 bit generation number, 32 bit parent directory inode number.
81 *
82 */
83struct nfs_fhbase_new {
84 __u8 fb_version; /* == 1, even => nfs_fhbase_old */
85 __u8 fb_auth_type;
86 __u8 fb_fsid_type;
87 __u8 fb_fileid_type;
88 __u32 fb_auth[1];
89/* __u32 fb_fsid[0]; floating */
90/* __u32 fb_fileid[0]; floating */
91};
92
93struct knfsd_fh {
94 unsigned int fh_size; /* significant for NFSv3.
95 * Points to the current size while building
96 * a new file handle
97 */
98 union {
99 struct nfs_fhbase_old fh_old;
100 __u32 fh_pad[NFS4_FHSIZE/4];
101 struct nfs_fhbase_new fh_new;
102 } fh_base;
103};
104
105#define ofh_dcookie fh_base.fh_old.fb_dcookie
106#define ofh_ino fh_base.fh_old.fb_ino
107#define ofh_dirino fh_base.fh_old.fb_dirino
108#define ofh_dev fh_base.fh_old.fb_dev
109#define ofh_xdev fh_base.fh_old.fb_xdev
110#define ofh_xino fh_base.fh_old.fb_xino
111#define ofh_generation fh_base.fh_old.fb_generation
112
113#define fh_version fh_base.fh_new.fb_version
114#define fh_fsid_type fh_base.fh_new.fb_fsid_type
115#define fh_auth_type fh_base.fh_new.fb_auth_type
116#define fh_fileid_type fh_base.fh_new.fb_fileid_type
117#define fh_auth fh_base.fh_new.fb_auth
118#define fh_fsid fh_base.fh_new.fb_auth
119
120#ifdef __KERNEL__
121
122static inline __u32 ino_t_to_u32(ino_t ino)
123{
124 return (__u32) ino;
125}
126
127static inline ino_t u32_to_ino_t(__u32 uino)
128{
129 return (ino_t) uino;
130}
131
132/*
133 * This is the internal representation of an NFS handle used in knfsd.
134 * pre_mtime/post_version will be used to support wcc_attr's in NFSv3.
135 */
136typedef struct svc_fh {
137 struct knfsd_fh fh_handle; /* FH data */
138 struct dentry * fh_dentry; /* validated dentry */
139 struct svc_export * fh_export; /* export pointer */
140 int fh_maxsize; /* max size for fh_handle */
141
142 unsigned char fh_locked; /* inode locked by us */
143
144#ifdef CONFIG_NFSD_V3
145 unsigned char fh_post_saved; /* post-op attrs saved */
146 unsigned char fh_pre_saved; /* pre-op attrs saved */
147
148 /* Pre-op attributes saved during fh_lock */
149 __u64 fh_pre_size; /* size before operation */
150 struct timespec fh_pre_mtime; /* mtime before oper */
151 struct timespec fh_pre_ctime; /* ctime before oper */
152
153 /* Post-op attributes saved in fh_unlock */
154 umode_t fh_post_mode; /* i_mode */
155 nlink_t fh_post_nlink; /* i_nlink */
156 uid_t fh_post_uid; /* i_uid */
157 gid_t fh_post_gid; /* i_gid */
158 __u64 fh_post_size; /* i_size */
159 unsigned long fh_post_blocks; /* i_blocks */
160 unsigned long fh_post_blksize;/* i_blksize */
161 __u32 fh_post_rdev[2];/* i_rdev */
162 struct timespec fh_post_atime; /* i_atime */
163 struct timespec fh_post_mtime; /* i_mtime */
164 struct timespec fh_post_ctime; /* i_ctime */
165#endif /* CONFIG_NFSD_V3 */
166
167} svc_fh;
168
169static inline void mk_fsid_v0(u32 *fsidv, dev_t dev, ino_t ino)
170{
171 fsidv[0] = htonl((MAJOR(dev)<<16) |
172 MINOR(dev));
173 fsidv[1] = ino_t_to_u32(ino);
174}
175
176static inline void mk_fsid_v1(u32 *fsidv, u32 fsid)
177{
178 fsidv[0] = fsid;
179}
180
181static inline void mk_fsid_v2(u32 *fsidv, dev_t dev, ino_t ino)
182{
183 fsidv[0] = htonl(MAJOR(dev));
184 fsidv[1] = htonl(MINOR(dev));
185 fsidv[2] = ino_t_to_u32(ino);
186}
187
188static inline void mk_fsid_v3(u32 *fsidv, dev_t dev, ino_t ino)
189{
190 fsidv[0] = new_encode_dev(dev);
191 fsidv[1] = ino_t_to_u32(ino);
192}
193
194static inline int key_len(int type)
195{
196 switch(type) {
197 case 0: return 8;
198 case 1: return 4;
199 case 2: return 12;
200 case 3: return 8;
201 default: return 0;
202 }
203}
204
205/*
206 * Shorthand for dprintk()'s
207 */
208extern char * SVCFH_fmt(struct svc_fh *fhp);
209
210/*
211 * Function prototypes
212 */
213u32 fh_verify(struct svc_rqst *, struct svc_fh *, int, int);
214int fh_compose(struct svc_fh *, struct svc_export *, struct dentry *, struct svc_fh *);
215int fh_update(struct svc_fh *);
216void fh_put(struct svc_fh *);
217
218static __inline__ struct svc_fh *
219fh_copy(struct svc_fh *dst, struct svc_fh *src)
220{
221 if (src->fh_dentry || src->fh_locked) {
222 struct dentry *dentry = src->fh_dentry;
223 printk(KERN_ERR "fh_copy: copying %s/%s, already verified!\n",
224 dentry->d_parent->d_name.name, dentry->d_name.name);
225 }
226
227 *dst = *src;
228 return dst;
229}
230
231static __inline__ struct svc_fh *
232fh_init(struct svc_fh *fhp, int maxsize)
233{
234 memset(fhp, 0, sizeof(*fhp));
235 fhp->fh_maxsize = maxsize;
236 return fhp;
237}
238
239#ifdef CONFIG_NFSD_V3
240/*
241 * Fill in the pre_op attr for the wcc data
242 */
243static inline void
244fill_pre_wcc(struct svc_fh *fhp)
245{
246 struct inode *inode;
247
248 inode = fhp->fh_dentry->d_inode;
249 if (!fhp->fh_pre_saved) {
250 fhp->fh_pre_mtime = inode->i_mtime;
251 fhp->fh_pre_ctime = inode->i_ctime;
252 fhp->fh_pre_size = inode->i_size;
253 fhp->fh_pre_saved = 1;
254 }
255}
256
257/*
258 * Fill in the post_op attr for the wcc data
259 */
260static inline void
261fill_post_wcc(struct svc_fh *fhp)
262{
263 struct inode *inode = fhp->fh_dentry->d_inode;
264
265 if (fhp->fh_post_saved)
266 printk("nfsd: inode locked twice during operation.\n");
267
268 fhp->fh_post_mode = inode->i_mode;
269 fhp->fh_post_nlink = inode->i_nlink;
270 fhp->fh_post_uid = inode->i_uid;
271 fhp->fh_post_gid = inode->i_gid;
272 fhp->fh_post_size = inode->i_size;
273 if (inode->i_blksize) {
274 fhp->fh_post_blksize = inode->i_blksize;
275 fhp->fh_post_blocks = inode->i_blocks;
276 } else {
277 fhp->fh_post_blksize = BLOCK_SIZE;
278 /* how much do we care for accuracy with MinixFS? */
279 fhp->fh_post_blocks = (inode->i_size+511) >> 9;
280 }
281 fhp->fh_post_rdev[0] = htonl((u32)imajor(inode));
282 fhp->fh_post_rdev[1] = htonl((u32)iminor(inode));
283 fhp->fh_post_atime = inode->i_atime;
284 fhp->fh_post_mtime = inode->i_mtime;
285 fhp->fh_post_ctime = inode->i_ctime;
286 fhp->fh_post_saved = 1;
287}
288#else
289#define fill_pre_wcc(ignored)
290#define fill_post_wcc(notused)
291#endif /* CONFIG_NFSD_V3 */
292
293
294/*
295 * Lock a file handle/inode
296 * NOTE: both fh_lock and fh_unlock are done "by hand" in
297 * vfs.c:nfsd_rename as it needs to grab 2 i_sem's at once
298 * so, any changes here should be reflected there.
299 */
300static inline void
301fh_lock(struct svc_fh *fhp)
302{
303 struct dentry *dentry = fhp->fh_dentry;
304 struct inode *inode;
305
306 dfprintk(FILEOP, "nfsd: fh_lock(%s) locked = %d\n",
307 SVCFH_fmt(fhp), fhp->fh_locked);
308
309 if (!fhp->fh_dentry) {
310 printk(KERN_ERR "fh_lock: fh not verified!\n");
311 return;
312 }
313 if (fhp->fh_locked) {
314 printk(KERN_WARNING "fh_lock: %s/%s already locked!\n",
315 dentry->d_parent->d_name.name, dentry->d_name.name);
316 return;
317 }
318
319 inode = dentry->d_inode;
320 down(&inode->i_sem);
321 fill_pre_wcc(fhp);
322 fhp->fh_locked = 1;
323}
324
325/*
326 * Unlock a file handle/inode
327 */
328static inline void
329fh_unlock(struct svc_fh *fhp)
330{
331 if (!fhp->fh_dentry)
332 printk(KERN_ERR "fh_unlock: fh not verified!\n");
333
334 if (fhp->fh_locked) {
335 fill_post_wcc(fhp);
336 up(&fhp->fh_dentry->d_inode->i_sem);
337 fhp->fh_locked = 0;
338 }
339}
340#endif /* __KERNEL__ */
341
342
343#endif /* _LINUX_NFSD_FH_H */
diff --git a/include/linux/nfsd/state.h b/include/linux/nfsd/state.h
new file mode 100644
index 000000000000..b6b2fe1e7c63
--- /dev/null
+++ b/include/linux/nfsd/state.h
@@ -0,0 +1,298 @@
1/*
2 * linux/include/nfsd/state.h
3 *
4 * Copyright (c) 2001 The Regents of the University of Michigan.
5 * All rights reserved.
6 *
7 * Kendrick Smith <kmsmith@umich.edu>
8 * Andy Adamson <andros@umich.edu>
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 *
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the University nor the names of its
20 * contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
24 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *
35 */
36
37#ifndef _NFSD4_STATE_H
38#define _NFSD4_STATE_H
39
40#include <linux/list.h>
41#include <linux/kref.h>
42#include <linux/sunrpc/clnt.h>
43
44#define NFS4_OPAQUE_LIMIT 1024
45typedef struct {
46 u32 cl_boot;
47 u32 cl_id;
48} clientid_t;
49
50typedef struct {
51 u32 so_boot;
52 u32 so_stateownerid;
53 u32 so_fileid;
54} stateid_opaque_t;
55
56typedef struct {
57 u32 si_generation;
58 stateid_opaque_t si_opaque;
59} stateid_t;
60#define si_boot si_opaque.so_boot
61#define si_stateownerid si_opaque.so_stateownerid
62#define si_fileid si_opaque.so_fileid
63
64extern stateid_t zerostateid;
65extern stateid_t onestateid;
66
67#define ZERO_STATEID(stateid) (!memcmp((stateid), &zerostateid, sizeof(stateid_t)))
68#define ONE_STATEID(stateid) (!memcmp((stateid), &onestateid, sizeof(stateid_t)))
69
70struct nfs4_cb_recall {
71 u32 cbr_ident;
72 int cbr_trunc;
73 stateid_t cbr_stateid;
74 u32 cbr_fhlen;
75 u32 cbr_fhval[NFS4_FHSIZE];
76 struct nfs4_delegation *cbr_dp;
77};
78
79struct nfs4_delegation {
80 struct list_head dl_del_perfile; /* nfs4_file->fi_del_perfile */
81 struct list_head dl_del_perclnt; /* nfs4_client->cl_del_perclnt*/
82 struct list_head dl_recall_lru; /* delegation recalled */
83 atomic_t dl_count; /* ref count */
84 struct nfs4_client *dl_client;
85 struct nfs4_file *dl_file;
86 struct file_lock *dl_flock;
87 struct file *dl_vfs_file;
88 u32 dl_type;
89 time_t dl_time;
90 struct nfs4_cb_recall dl_recall;
91};
92
93#define dl_stateid dl_recall.cbr_stateid
94#define dl_fhlen dl_recall.cbr_fhlen
95#define dl_fhval dl_recall.cbr_fhval
96
97/* client delegation callback info */
98struct nfs4_callback {
99 /* SETCLIENTID info */
100 u32 cb_parsed; /* addr parsed */
101 u32 cb_addr;
102 unsigned short cb_port;
103 u32 cb_prog;
104 u32 cb_ident;
105 /* RPC client info */
106 atomic_t cb_set; /* successful CB_NULL call */
107 struct rpc_program cb_program;
108 struct rpc_stat cb_stat;
109 struct rpc_clnt * cb_client;
110};
111
112/*
113 * struct nfs4_client - one per client. Clientids live here.
114 * o Each nfs4_client is hashed by clientid.
115 *
116 * o Each nfs4_clients is also hashed by name
117 * (the opaque quantity initially sent by the client to identify itself).
118 *
119 * o cl_perclient list is used to ensure no dangling stateowner references
120 * when we expire the nfs4_client
121 */
122struct nfs4_client {
123 struct list_head cl_idhash; /* hash by cl_clientid.id */
124 struct list_head cl_strhash; /* hash by cl_name */
125 struct list_head cl_perclient; /* list: stateowners */
126 struct list_head cl_del_perclnt; /* list: delegations */
127 struct list_head cl_lru; /* tail queue */
128 struct xdr_netobj cl_name; /* id generated by client */
129 nfs4_verifier cl_verifier; /* generated by client */
130 time_t cl_time; /* time of last lease renewal */
131 u32 cl_addr; /* client ipaddress */
132 struct svc_cred cl_cred; /* setclientid principal */
133 clientid_t cl_clientid; /* generated by server */
134 nfs4_verifier cl_confirm; /* generated by server */
135 struct nfs4_callback cl_callback; /* callback info */
136 atomic_t cl_count; /* ref count */
137};
138
139/* struct nfs4_client_reset
140 * one per old client. Populates reset_str_hashtbl. Filled from conf_id_hashtbl
141 * upon lease reset, or from upcall to state_daemon (to read in state
142 * from non-volitile storage) upon reboot.
143 */
144struct nfs4_client_reclaim {
145 struct list_head cr_strhash; /* hash by cr_name */
146 struct xdr_netobj cr_name; /* id generated by client */
147};
148
149static inline void
150update_stateid(stateid_t *stateid)
151{
152 stateid->si_generation++;
153}
154
155/* A reasonable value for REPLAY_ISIZE was estimated as follows:
156 * The OPEN response, typically the largest, requires
157 * 4(status) + 8(stateid) + 20(changeinfo) + 4(rflags) + 8(verifier) +
158 * 4(deleg. type) + 8(deleg. stateid) + 4(deleg. recall flag) +
159 * 20(deleg. space limit) + ~32(deleg. ace) = 112 bytes
160 */
161
162#define NFSD4_REPLAY_ISIZE 112
163
164/*
165 * Replay buffer, where the result of the last seqid-mutating operation
166 * is cached.
167 */
168struct nfs4_replay {
169 u32 rp_status;
170 unsigned int rp_buflen;
171 char *rp_buf;
172 unsigned intrp_allocated;
173 int rp_openfh_len;
174 char rp_openfh[NFS4_FHSIZE];
175 char rp_ibuf[NFSD4_REPLAY_ISIZE];
176};
177
178/*
179* nfs4_stateowner can either be an open_owner, or a lock_owner
180*
181* so_idhash: stateid_hashtbl[] for open owner, lockstateid_hashtbl[]
182* for lock_owner
183* so_strhash: ownerstr_hashtbl[] for open_owner, lock_ownerstr_hashtbl[]
184* for lock_owner
185* so_perclient: nfs4_client->cl_perclient entry - used when nfs4_client
186* struct is reaped.
187* so_perfilestate: heads the list of nfs4_stateid (either open or lock)
188* and is used to ensure no dangling nfs4_stateid references when we
189* release a stateowner.
190* so_perlockowner: (open) nfs4_stateid->st_perlockowner entry - used when
191* close is called to reap associated byte-range locks
192* so_close_lru: (open) stateowner is placed on this list instead of being
193* reaped (when so_perfilestate is empty) to hold the last close replay.
194* reaped by laundramat thread after lease period.
195*/
196struct nfs4_stateowner {
197 struct kref so_ref;
198 struct list_head so_idhash; /* hash by so_id */
199 struct list_head so_strhash; /* hash by op_name */
200 struct list_head so_perclient; /* nfs4_client->cl_perclient */
201 struct list_head so_perfilestate; /* list: nfs4_stateid */
202 struct list_head so_perlockowner; /* nfs4_stateid->st_perlockowner */
203 struct list_head so_close_lru; /* tail queue */
204 time_t so_time; /* time of placement on so_close_lru */
205 int so_is_open_owner; /* 1=openowner,0=lockowner */
206 u32 so_id;
207 struct nfs4_client * so_client;
208 u32 so_seqid;
209 struct xdr_netobj so_owner; /* open owner name */
210 int so_confirmed; /* successful OPEN_CONFIRM? */
211 struct nfs4_replay so_replay;
212};
213
214/*
215* nfs4_file: a file opened by some number of (open) nfs4_stateowners.
216* o fi_perfile list is used to search for conflicting
217* share_acces, share_deny on the file.
218*/
219struct nfs4_file {
220 struct list_head fi_hash; /* hash by "struct inode *" */
221 struct list_head fi_perfile; /* list: nfs4_stateid */
222 struct list_head fi_del_perfile; /* list: nfs4_delegation */
223 struct inode *fi_inode;
224 u32 fi_id; /* used with stateowner->so_id
225 * for stateid_hashtbl hash */
226};
227
228/*
229* nfs4_stateid can either be an open stateid or (eventually) a lock stateid
230*
231* (open)nfs4_stateid: one per (open)nfs4_stateowner, nfs4_file
232*
233* st_hash: stateid_hashtbl[] entry or lockstateid_hashtbl entry
234* st_perfile: file_hashtbl[] entry.
235* st_perfile_state: nfs4_stateowner->so_perfilestate
236* st_perlockowner: (open stateid) list of lock nfs4_stateowners
237* st_access_bmap: used only for open stateid
238* st_deny_bmap: used only for open stateid
239*/
240
241struct nfs4_stateid {
242 struct list_head st_hash;
243 struct list_head st_perfile;
244 struct list_head st_perfilestate;
245 struct list_head st_perlockowner;
246 struct nfs4_stateowner * st_stateowner;
247 struct nfs4_file * st_file;
248 stateid_t st_stateid;
249 struct file * st_vfs_file;
250 unsigned long st_access_bmap;
251 unsigned long st_deny_bmap;
252};
253
254/* flags for preprocess_seqid_op() */
255#define CHECK_FH 0x00000001
256#define CONFIRM 0x00000002
257#define OPEN_STATE 0x00000004
258#define LOCK_STATE 0x00000008
259#define RD_STATE 0x00000010
260#define WR_STATE 0x00000020
261#define CLOSE_STATE 0x00000040
262#define DELEG_RET 0x00000080
263
264#define seqid_mutating_err(err) \
265 (((err) != nfserr_stale_clientid) && \
266 ((err) != nfserr_bad_seqid) && \
267 ((err) != nfserr_stale_stateid) && \
268 ((err) != nfserr_bad_stateid))
269
270extern time_t nfs4_laundromat(void);
271extern int nfsd4_renew(clientid_t *clid);
272extern int nfs4_preprocess_stateid_op(struct svc_fh *current_fh,
273 stateid_t *stateid, int flags, struct file **filp);
274extern int nfs4_share_conflict(struct svc_fh *current_fh,
275 unsigned int deny_type);
276extern void nfs4_lock_state(void);
277extern void nfs4_unlock_state(void);
278extern int nfs4_in_grace(void);
279extern int nfs4_check_open_reclaim(clientid_t *clid);
280extern void put_nfs4_client(struct nfs4_client *clp);
281extern void nfs4_free_stateowner(struct kref *kref);
282extern void nfsd4_probe_callback(struct nfs4_client *clp);
283extern void nfsd4_cb_recall(struct nfs4_delegation *dp);
284extern void nfs4_put_delegation(struct nfs4_delegation *dp);
285
286static inline void
287nfs4_put_stateowner(struct nfs4_stateowner *so)
288{
289 kref_put(&so->so_ref, nfs4_free_stateowner);
290}
291
292static inline void
293nfs4_get_stateowner(struct nfs4_stateowner *so)
294{
295 kref_get(&so->so_ref);
296}
297
298#endif /* NFSD4_STATE_H */
diff --git a/include/linux/nfsd/stats.h b/include/linux/nfsd/stats.h
new file mode 100644
index 000000000000..b6f1e0cda4f2
--- /dev/null
+++ b/include/linux/nfsd/stats.h
@@ -0,0 +1,44 @@
1/*
2 * linux/include/nfsd/stats.h
3 *
4 * Statistics for NFS server.
5 *
6 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
7 */
8
9#ifndef LINUX_NFSD_STATS_H
10#define LINUX_NFSD_STATS_H
11
12struct nfsd_stats {
13 unsigned int rchits; /* repcache hits */
14 unsigned int rcmisses; /* repcache hits */
15 unsigned int rcnocache; /* uncached reqs */
16 unsigned int fh_stale; /* FH stale error */
17 unsigned int fh_lookup; /* dentry cached */
18 unsigned int fh_anon; /* anon file dentry returned */
19 unsigned int fh_nocache_dir; /* filehandle not found in dcache */
20 unsigned int fh_nocache_nondir; /* filehandle not found in dcache */
21 unsigned int io_read; /* bytes returned to read requests */
22 unsigned int io_write; /* bytes passed in write requests */
23 unsigned int th_cnt; /* number of available threads */
24 unsigned int th_usage[10]; /* number of ticks during which n perdeciles
25 * of available threads were in use */
26 unsigned int th_fullcnt; /* number of times last free thread was used */
27 unsigned int ra_size; /* size of ra cache */
28 unsigned int ra_depth[11]; /* number of times ra entry was found that deep
29 * in the cache (10percentiles). [10] = not found */
30};
31
32/* thread usage wraps very million seconds (approx one fortnight) */
33#define NFSD_USAGE_WRAP (HZ*1000000)
34
35#ifdef __KERNEL__
36
37extern struct nfsd_stats nfsdstats;
38extern struct svc_stat nfsd_svcstats;
39
40void nfsd_stat_init(void);
41void nfsd_stat_shutdown(void);
42
43#endif /* __KERNEL__ */
44#endif /* LINUX_NFSD_STATS_H */
diff --git a/include/linux/nfsd/syscall.h b/include/linux/nfsd/syscall.h
new file mode 100644
index 000000000000..e65c9db6d13f
--- /dev/null
+++ b/include/linux/nfsd/syscall.h
@@ -0,0 +1,125 @@
1/*
2 * include/linux/nfsd/syscall.h
3 *
4 * This file holds all declarations for the knfsd syscall interface.
5 *
6 * Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de>
7 */
8
9#ifndef NFSD_SYSCALL_H
10#define NFSD_SYSCALL_H
11
12#include <asm/types.h>
13#ifdef __KERNEL__
14# include <linux/config.h>
15# include <linux/types.h>
16# include <linux/in.h>
17#endif
18#include <linux/posix_types.h>
19#include <linux/nfsd/const.h>
20#include <linux/nfsd/export.h>
21#include <linux/nfsd/nfsfh.h>
22#include <linux/nfsd/auth.h>
23
24/*
25 * Version of the syscall interface
26 */
27#define NFSCTL_VERSION 0x0201
28
29/*
30 * These are the commands understood by nfsctl().
31 */
32#define NFSCTL_SVC 0 /* This is a server process. */
33#define NFSCTL_ADDCLIENT 1 /* Add an NFS client. */
34#define NFSCTL_DELCLIENT 2 /* Remove an NFS client. */
35#define NFSCTL_EXPORT 3 /* export a file system. */
36#define NFSCTL_UNEXPORT 4 /* unexport a file system. */
37/*#define NFSCTL_UGIDUPDATE 5 / * update a client's uid/gid map. DISCARDED */
38/*#define NFSCTL_GETFH 6 / * get an fh by ino DISCARDED */
39#define NFSCTL_GETFD 7 /* get an fh by path (used by mountd) */
40#define NFSCTL_GETFS 8 /* get an fh by path with max FH len */
41
42/* SVC */
43struct nfsctl_svc {
44 unsigned short svc_port;
45 int svc_nthreads;
46};
47
48/* ADDCLIENT/DELCLIENT */
49struct nfsctl_client {
50 char cl_ident[NFSCLNT_IDMAX+1];
51 int cl_naddr;
52 struct in_addr cl_addrlist[NFSCLNT_ADDRMAX];
53 int cl_fhkeytype;
54 int cl_fhkeylen;
55 unsigned char cl_fhkey[NFSCLNT_KEYMAX];
56};
57
58/* EXPORT/UNEXPORT */
59struct nfsctl_export {
60 char ex_client[NFSCLNT_IDMAX+1];
61 char ex_path[NFS_MAXPATHLEN+1];
62 __kernel_old_dev_t ex_dev;
63 __kernel_ino_t ex_ino;
64 int ex_flags;
65 __kernel_uid_t ex_anon_uid;
66 __kernel_gid_t ex_anon_gid;
67};
68
69/* GETFD */
70struct nfsctl_fdparm {
71 struct sockaddr gd_addr;
72 char gd_path[NFS_MAXPATHLEN+1];
73 int gd_version;
74};
75
76/* GETFS - GET Filehandle with Size */
77struct nfsctl_fsparm {
78 struct sockaddr gd_addr;
79 char gd_path[NFS_MAXPATHLEN+1];
80 int gd_maxlen;
81};
82
83/*
84 * This is the argument union.
85 */
86struct nfsctl_arg {
87 int ca_version; /* safeguard */
88 union {
89 struct nfsctl_svc u_svc;
90 struct nfsctl_client u_client;
91 struct nfsctl_export u_export;
92 struct nfsctl_fdparm u_getfd;
93 struct nfsctl_fsparm u_getfs;
94 /*
95 * The following dummy member is needed to preserve binary compatibility
96 * on platforms where alignof(void*)>alignof(int). It's needed because
97 * this union used to contain a member (u_umap) which contained a
98 * pointer.
99 */
100 void *u_ptr;
101 } u;
102#define ca_svc u.u_svc
103#define ca_client u.u_client
104#define ca_export u.u_export
105#define ca_getfd u.u_getfd
106#define ca_getfs u.u_getfs
107};
108
109union nfsctl_res {
110 __u8 cr_getfh[NFS_FHSIZE];
111 struct knfsd_fh cr_getfs;
112};
113
114#ifdef __KERNEL__
115/*
116 * Kernel syscall implementation.
117 */
118extern int exp_addclient(struct nfsctl_client *ncp);
119extern int exp_delclient(struct nfsctl_client *ncp);
120extern int exp_export(struct nfsctl_export *nxp);
121extern int exp_unexport(struct nfsctl_export *nxp);
122
123#endif /* __KERNEL__ */
124
125#endif /* NFSD_SYSCALL_H */
diff --git a/include/linux/nfsd/xdr.h b/include/linux/nfsd/xdr.h
new file mode 100644
index 000000000000..ecccef777dae
--- /dev/null
+++ b/include/linux/nfsd/xdr.h
@@ -0,0 +1,172 @@
1/*
2 * linux/inxlude/linux/nfsd/xdr.h
3 *
4 * XDR types for nfsd. This is mainly a typing exercise.
5 */
6
7#ifndef LINUX_NFSD_H
8#define LINUX_NFSD_H
9
10#include <linux/fs.h>
11#include <linux/vfs.h>
12#include <linux/nfs.h>
13
14struct nfsd_fhandle {
15 struct svc_fh fh;
16};
17
18struct nfsd_sattrargs {
19 struct svc_fh fh;
20 struct iattr attrs;
21};
22
23struct nfsd_diropargs {
24 struct svc_fh fh;
25 char * name;
26 int len;
27};
28
29struct nfsd_readargs {
30 struct svc_fh fh;
31 __u32 offset;
32 __u32 count;
33 struct kvec vec[RPCSVC_MAXPAGES];
34 int vlen;
35};
36
37struct nfsd_writeargs {
38 svc_fh fh;
39 __u32 offset;
40 int len;
41 struct kvec vec[RPCSVC_MAXPAGES];
42 int vlen;
43};
44
45struct nfsd_createargs {
46 struct svc_fh fh;
47 char * name;
48 int len;
49 struct iattr attrs;
50};
51
52struct nfsd_renameargs {
53 struct svc_fh ffh;
54 char * fname;
55 int flen;
56 struct svc_fh tfh;
57 char * tname;
58 int tlen;
59};
60
61struct nfsd_readlinkargs {
62 struct svc_fh fh;
63 char * buffer;
64};
65
66struct nfsd_linkargs {
67 struct svc_fh ffh;
68 struct svc_fh tfh;
69 char * tname;
70 int tlen;
71};
72
73struct nfsd_symlinkargs {
74 struct svc_fh ffh;
75 char * fname;
76 int flen;
77 char * tname;
78 int tlen;
79 struct iattr attrs;
80};
81
82struct nfsd_readdirargs {
83 struct svc_fh fh;
84 __u32 cookie;
85 __u32 count;
86 u32 * buffer;
87};
88
89struct nfsd_attrstat {
90 struct svc_fh fh;
91};
92
93struct nfsd_diropres {
94 struct svc_fh fh;
95};
96
97struct nfsd_readlinkres {
98 int len;
99};
100
101struct nfsd_readres {
102 struct svc_fh fh;
103 unsigned long count;
104};
105
106struct nfsd_readdirres {
107 int count;
108
109 struct readdir_cd common;
110 u32 * buffer;
111 int buflen;
112 u32 * offset;
113};
114
115struct nfsd_statfsres {
116 struct kstatfs stats;
117};
118
119/*
120 * Storage requirements for XDR arguments and results.
121 */
122union nfsd_xdrstore {
123 struct nfsd_sattrargs sattr;
124 struct nfsd_diropargs dirop;
125 struct nfsd_readargs read;
126 struct nfsd_writeargs write;
127 struct nfsd_createargs create;
128 struct nfsd_renameargs rename;
129 struct nfsd_linkargs link;
130 struct nfsd_symlinkargs symlink;
131 struct nfsd_readdirargs readdir;
132};
133
134#define NFS2_SVC_XDRSIZE sizeof(union nfsd_xdrstore)
135
136
137int nfssvc_decode_void(struct svc_rqst *, u32 *, void *);
138int nfssvc_decode_fhandle(struct svc_rqst *, u32 *, struct nfsd_fhandle *);
139int nfssvc_decode_sattrargs(struct svc_rqst *, u32 *,
140 struct nfsd_sattrargs *);
141int nfssvc_decode_diropargs(struct svc_rqst *, u32 *,
142 struct nfsd_diropargs *);
143int nfssvc_decode_readargs(struct svc_rqst *, u32 *,
144 struct nfsd_readargs *);
145int nfssvc_decode_writeargs(struct svc_rqst *, u32 *,
146 struct nfsd_writeargs *);
147int nfssvc_decode_createargs(struct svc_rqst *, u32 *,
148 struct nfsd_createargs *);
149int nfssvc_decode_renameargs(struct svc_rqst *, u32 *,
150 struct nfsd_renameargs *);
151int nfssvc_decode_readlinkargs(struct svc_rqst *, u32 *,
152 struct nfsd_readlinkargs *);
153int nfssvc_decode_linkargs(struct svc_rqst *, u32 *,
154 struct nfsd_linkargs *);
155int nfssvc_decode_symlinkargs(struct svc_rqst *, u32 *,
156 struct nfsd_symlinkargs *);
157int nfssvc_decode_readdirargs(struct svc_rqst *, u32 *,
158 struct nfsd_readdirargs *);
159int nfssvc_encode_void(struct svc_rqst *, u32 *, void *);
160int nfssvc_encode_attrstat(struct svc_rqst *, u32 *, struct nfsd_attrstat *);
161int nfssvc_encode_diropres(struct svc_rqst *, u32 *, struct nfsd_diropres *);
162int nfssvc_encode_readlinkres(struct svc_rqst *, u32 *, struct nfsd_readlinkres *);
163int nfssvc_encode_readres(struct svc_rqst *, u32 *, struct nfsd_readres *);
164int nfssvc_encode_statfsres(struct svc_rqst *, u32 *, struct nfsd_statfsres *);
165int nfssvc_encode_readdirres(struct svc_rqst *, u32 *, struct nfsd_readdirres *);
166
167int nfssvc_encode_entry(struct readdir_cd *, const char *name,
168 int namlen, loff_t offset, ino_t ino, unsigned int);
169
170int nfssvc_release_fhandle(struct svc_rqst *, u32 *, struct nfsd_fhandle *);
171
172#endif /* LINUX_NFSD_H */
diff --git a/include/linux/nfsd/xdr3.h b/include/linux/nfsd/xdr3.h
new file mode 100644
index 000000000000..0ae9e0ef5f68
--- /dev/null
+++ b/include/linux/nfsd/xdr3.h
@@ -0,0 +1,321 @@
1/*
2 * linux/include/linux/nfsd/xdr3.h
3 *
4 * XDR types for NFSv3 in nfsd.
5 *
6 * Copyright (C) 1996-1998, Olaf Kirch <okir@monad.swb.de>
7 */
8
9#ifndef _LINUX_NFSD_XDR3_H
10#define _LINUX_NFSD_XDR3_H
11
12#include <linux/nfsd/xdr.h>
13
14struct nfsd3_sattrargs {
15 struct svc_fh fh;
16 struct iattr attrs;
17 int check_guard;
18 time_t guardtime;
19};
20
21struct nfsd3_diropargs {
22 struct svc_fh fh;
23 char * name;
24 int len;
25};
26
27struct nfsd3_accessargs {
28 struct svc_fh fh;
29 unsigned int access;
30};
31
32struct nfsd3_readargs {
33 struct svc_fh fh;
34 __u64 offset;
35 __u32 count;
36 struct kvec vec[RPCSVC_MAXPAGES];
37 int vlen;
38};
39
40struct nfsd3_writeargs {
41 svc_fh fh;
42 __u64 offset;
43 __u32 count;
44 int stable;
45 int len;
46 struct kvec vec[RPCSVC_MAXPAGES];
47 int vlen;
48};
49
50struct nfsd3_createargs {
51 struct svc_fh fh;
52 char * name;
53 int len;
54 int createmode;
55 struct iattr attrs;
56 __u32 * verf;
57};
58
59struct nfsd3_mknodargs {
60 struct svc_fh fh;
61 char * name;
62 int len;
63 __u32 ftype;
64 __u32 major, minor;
65 struct iattr attrs;
66};
67
68struct nfsd3_renameargs {
69 struct svc_fh ffh;
70 char * fname;
71 int flen;
72 struct svc_fh tfh;
73 char * tname;
74 int tlen;
75};
76
77struct nfsd3_readlinkargs {
78 struct svc_fh fh;
79 char * buffer;
80};
81
82struct nfsd3_linkargs {
83 struct svc_fh ffh;
84 struct svc_fh tfh;
85 char * tname;
86 int tlen;
87};
88
89struct nfsd3_symlinkargs {
90 struct svc_fh ffh;
91 char * fname;
92 int flen;
93 char * tname;
94 int tlen;
95 struct iattr attrs;
96};
97
98struct nfsd3_readdirargs {
99 struct svc_fh fh;
100 __u64 cookie;
101 __u32 dircount;
102 __u32 count;
103 __u32 * verf;
104 u32 * buffer;
105};
106
107struct nfsd3_commitargs {
108 struct svc_fh fh;
109 __u64 offset;
110 __u32 count;
111};
112
113struct nfsd3_attrstat {
114 __u32 status;
115 struct svc_fh fh;
116};
117
118/* LOOKUP, CREATE, MKDIR, SYMLINK, MKNOD */
119struct nfsd3_diropres {
120 __u32 status;
121 struct svc_fh dirfh;
122 struct svc_fh fh;
123};
124
125struct nfsd3_accessres {
126 __u32 status;
127 struct svc_fh fh;
128 __u32 access;
129};
130
131struct nfsd3_readlinkres {
132 __u32 status;
133 struct svc_fh fh;
134 __u32 len;
135};
136
137struct nfsd3_readres {
138 __u32 status;
139 struct svc_fh fh;
140 unsigned long count;
141 int eof;
142};
143
144struct nfsd3_writeres {
145 __u32 status;
146 struct svc_fh fh;
147 unsigned long count;
148 int committed;
149};
150
151struct nfsd3_renameres {
152 __u32 status;
153 struct svc_fh ffh;
154 struct svc_fh tfh;
155};
156
157struct nfsd3_linkres {
158 __u32 status;
159 struct svc_fh tfh;
160 struct svc_fh fh;
161};
162
163struct nfsd3_readdirres {
164 __u32 status;
165 struct svc_fh fh;
166 int count;
167 __u32 verf[2];
168
169 struct readdir_cd common;
170 u32 * buffer;
171 int buflen;
172 u32 * offset;
173 u32 * offset1;
174 struct svc_rqst * rqstp;
175
176};
177
178struct nfsd3_fsstatres {
179 __u32 status;
180 struct kstatfs stats;
181 __u32 invarsec;
182};
183
184struct nfsd3_fsinfores {
185 __u32 status;
186 __u32 f_rtmax;
187 __u32 f_rtpref;
188 __u32 f_rtmult;
189 __u32 f_wtmax;
190 __u32 f_wtpref;
191 __u32 f_wtmult;
192 __u32 f_dtpref;
193 __u64 f_maxfilesize;
194 __u32 f_properties;
195};
196
197struct nfsd3_pathconfres {
198 __u32 status;
199 __u32 p_link_max;
200 __u32 p_name_max;
201 __u32 p_no_trunc;
202 __u32 p_chown_restricted;
203 __u32 p_case_insensitive;
204 __u32 p_case_preserving;
205};
206
207struct nfsd3_commitres {
208 __u32 status;
209 struct svc_fh fh;
210};
211
212/* dummy type for release */
213struct nfsd3_fhandle_pair {
214 __u32 dummy;
215 struct svc_fh fh1;
216 struct svc_fh fh2;
217};
218
219/*
220 * Storage requirements for XDR arguments and results.
221 */
222union nfsd3_xdrstore {
223 struct nfsd3_sattrargs sattrargs;
224 struct nfsd3_diropargs diropargs;
225 struct nfsd3_readargs readargs;
226 struct nfsd3_writeargs writeargs;
227 struct nfsd3_createargs createargs;
228 struct nfsd3_renameargs renameargs;
229 struct nfsd3_linkargs linkargs;
230 struct nfsd3_symlinkargs symlinkargs;
231 struct nfsd3_readdirargs readdirargs;
232 struct nfsd3_diropres diropres;
233 struct nfsd3_accessres accessres;
234 struct nfsd3_readlinkres readlinkres;
235 struct nfsd3_readres readres;
236 struct nfsd3_writeres writeres;
237 struct nfsd3_renameres renameres;
238 struct nfsd3_linkres linkres;
239 struct nfsd3_readdirres readdirres;
240 struct nfsd3_fsstatres fsstatres;
241 struct nfsd3_fsinfores fsinfores;
242 struct nfsd3_pathconfres pathconfres;
243 struct nfsd3_commitres commitres;
244};
245
246#define NFS3_SVC_XDRSIZE sizeof(union nfsd3_xdrstore)
247
248int nfs3svc_decode_fhandle(struct svc_rqst *, u32 *, struct nfsd_fhandle *);
249int nfs3svc_decode_sattrargs(struct svc_rqst *, u32 *,
250 struct nfsd3_sattrargs *);
251int nfs3svc_decode_diropargs(struct svc_rqst *, u32 *,
252 struct nfsd3_diropargs *);
253int nfs3svc_decode_accessargs(struct svc_rqst *, u32 *,
254 struct nfsd3_accessargs *);
255int nfs3svc_decode_readargs(struct svc_rqst *, u32 *,
256 struct nfsd3_readargs *);
257int nfs3svc_decode_writeargs(struct svc_rqst *, u32 *,
258 struct nfsd3_writeargs *);
259int nfs3svc_decode_createargs(struct svc_rqst *, u32 *,
260 struct nfsd3_createargs *);
261int nfs3svc_decode_mkdirargs(struct svc_rqst *, u32 *,
262 struct nfsd3_createargs *);
263int nfs3svc_decode_mknodargs(struct svc_rqst *, u32 *,
264 struct nfsd3_mknodargs *);
265int nfs3svc_decode_renameargs(struct svc_rqst *, u32 *,
266 struct nfsd3_renameargs *);
267int nfs3svc_decode_readlinkargs(struct svc_rqst *, u32 *,
268 struct nfsd3_readlinkargs *);
269int nfs3svc_decode_linkargs(struct svc_rqst *, u32 *,
270 struct nfsd3_linkargs *);
271int nfs3svc_decode_symlinkargs(struct svc_rqst *, u32 *,
272 struct nfsd3_symlinkargs *);
273int nfs3svc_decode_readdirargs(struct svc_rqst *, u32 *,
274 struct nfsd3_readdirargs *);
275int nfs3svc_decode_readdirplusargs(struct svc_rqst *, u32 *,
276 struct nfsd3_readdirargs *);
277int nfs3svc_decode_commitargs(struct svc_rqst *, u32 *,
278 struct nfsd3_commitargs *);
279int nfs3svc_encode_voidres(struct svc_rqst *, u32 *, void *);
280int nfs3svc_encode_attrstat(struct svc_rqst *, u32 *,
281 struct nfsd3_attrstat *);
282int nfs3svc_encode_wccstat(struct svc_rqst *, u32 *,
283 struct nfsd3_attrstat *);
284int nfs3svc_encode_diropres(struct svc_rqst *, u32 *,
285 struct nfsd3_diropres *);
286int nfs3svc_encode_accessres(struct svc_rqst *, u32 *,
287 struct nfsd3_accessres *);
288int nfs3svc_encode_readlinkres(struct svc_rqst *, u32 *,
289 struct nfsd3_readlinkres *);
290int nfs3svc_encode_readres(struct svc_rqst *, u32 *, struct nfsd3_readres *);
291int nfs3svc_encode_writeres(struct svc_rqst *, u32 *, struct nfsd3_writeres *);
292int nfs3svc_encode_createres(struct svc_rqst *, u32 *,
293 struct nfsd3_diropres *);
294int nfs3svc_encode_renameres(struct svc_rqst *, u32 *,
295 struct nfsd3_renameres *);
296int nfs3svc_encode_linkres(struct svc_rqst *, u32 *,
297 struct nfsd3_linkres *);
298int nfs3svc_encode_readdirres(struct svc_rqst *, u32 *,
299 struct nfsd3_readdirres *);
300int nfs3svc_encode_fsstatres(struct svc_rqst *, u32 *,
301 struct nfsd3_fsstatres *);
302int nfs3svc_encode_fsinfores(struct svc_rqst *, u32 *,
303 struct nfsd3_fsinfores *);
304int nfs3svc_encode_pathconfres(struct svc_rqst *, u32 *,
305 struct nfsd3_pathconfres *);
306int nfs3svc_encode_commitres(struct svc_rqst *, u32 *,
307 struct nfsd3_commitres *);
308
309int nfs3svc_release_fhandle(struct svc_rqst *, u32 *,
310 struct nfsd3_attrstat *);
311int nfs3svc_release_fhandle2(struct svc_rqst *, u32 *,
312 struct nfsd3_fhandle_pair *);
313int nfs3svc_encode_entry(struct readdir_cd *, const char *name,
314 int namlen, loff_t offset, ino_t ino,
315 unsigned int);
316int nfs3svc_encode_entry_plus(struct readdir_cd *, const char *name,
317 int namlen, loff_t offset, ino_t ino,
318 unsigned int);
319
320
321#endif /* _LINUX_NFSD_XDR3_H */
diff --git a/include/linux/nfsd/xdr4.h b/include/linux/nfsd/xdr4.h
new file mode 100644
index 000000000000..a1f5ad0be1bf
--- /dev/null
+++ b/include/linux/nfsd/xdr4.h
@@ -0,0 +1,463 @@
1/*
2 * include/linux/nfsd/xdr4.h
3 *
4 * Server-side types for NFSv4.
5 *
6 * Copyright (c) 2002 The Regents of the University of Michigan.
7 * All rights reserved.
8 *
9 * Kendrick Smith <kmsmith@umich.edu>
10 * Andy Adamson <andros@umich.edu>
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 *
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. Neither the name of the University nor the names of its
22 * contributors may be used to endorse or promote products derived
23 * from this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
26 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
27 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
32 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 *
37 */
38
39#ifndef _LINUX_NFSD_XDR4_H
40#define _LINUX_NFSD_XDR4_H
41
42#include <linux/nfs4.h>
43
44#define NFSD4_MAX_TAGLEN 128
45#define XDR_LEN(n) (((n) + 3) & ~3)
46
47struct nfsd4_change_info {
48 u32 atomic;
49 u32 before_ctime_sec;
50 u32 before_ctime_nsec;
51 u32 after_ctime_sec;
52 u32 after_ctime_nsec;
53};
54
55struct nfsd4_access {
56 u32 ac_req_access; /* request */
57 u32 ac_supported; /* response */
58 u32 ac_resp_access; /* response */
59};
60
61struct nfsd4_close {
62 u32 cl_seqid; /* request */
63 stateid_t cl_stateid; /* request+response */
64 struct nfs4_stateowner * cl_stateowner; /* response */
65};
66
67struct nfsd4_commit {
68 u64 co_offset; /* request */
69 u32 co_count; /* request */
70 nfs4_verifier co_verf; /* response */
71};
72
73struct nfsd4_create {
74 u32 cr_namelen; /* request */
75 char * cr_name; /* request */
76 u32 cr_type; /* request */
77 union { /* request */
78 struct {
79 u32 namelen;
80 char *name;
81 } link; /* NF4LNK */
82 struct {
83 u32 specdata1;
84 u32 specdata2;
85 } dev; /* NF4BLK, NF4CHR */
86 } u;
87 u32 cr_bmval[2]; /* request */
88 struct iattr cr_iattr; /* request */
89 struct nfsd4_change_info cr_cinfo; /* response */
90 struct nfs4_acl *cr_acl;
91};
92#define cr_linklen u.link.namelen
93#define cr_linkname u.link.name
94#define cr_specdata1 u.dev.specdata1
95#define cr_specdata2 u.dev.specdata2
96
97struct nfsd4_delegreturn {
98 stateid_t dr_stateid;
99};
100
101struct nfsd4_getattr {
102 u32 ga_bmval[2]; /* request */
103 struct svc_fh *ga_fhp; /* response */
104};
105
106struct nfsd4_link {
107 u32 li_namelen; /* request */
108 char * li_name; /* request */
109 struct nfsd4_change_info li_cinfo; /* response */
110};
111
112struct nfsd4_lock_denied {
113 clientid_t ld_clientid;
114 struct nfs4_stateowner *ld_sop;
115 u64 ld_start;
116 u64 ld_length;
117 u32 ld_type;
118};
119
120struct nfsd4_lock {
121 /* request */
122 u32 lk_type;
123 u32 lk_reclaim; /* boolean */
124 u64 lk_offset;
125 u64 lk_length;
126 u32 lk_is_new;
127 union {
128 struct {
129 u32 open_seqid;
130 stateid_t open_stateid;
131 u32 lock_seqid;
132 clientid_t clientid;
133 struct xdr_netobj owner;
134 } new;
135 struct {
136 stateid_t lock_stateid;
137 u32 lock_seqid;
138 } old;
139 } v;
140
141 /* response */
142 union {
143 struct {
144 stateid_t stateid;
145 } ok;
146 struct nfsd4_lock_denied denied;
147 } u;
148
149 struct nfs4_stateowner *lk_stateowner;
150};
151#define lk_new_open_seqid v.new.open_seqid
152#define lk_new_open_stateid v.new.open_stateid
153#define lk_new_lock_seqid v.new.lock_seqid
154#define lk_new_clientid v.new.clientid
155#define lk_new_owner v.new.owner
156#define lk_old_lock_stateid v.old.lock_stateid
157#define lk_old_lock_seqid v.old.lock_seqid
158
159#define lk_rflags u.ok.rflags
160#define lk_resp_stateid u.ok.stateid
161#define lk_denied u.denied
162
163
164struct nfsd4_lockt {
165 u32 lt_type;
166 clientid_t lt_clientid;
167 struct xdr_netobj lt_owner;
168 u64 lt_offset;
169 u64 lt_length;
170 struct nfs4_stateowner * lt_stateowner;
171 struct nfsd4_lock_denied lt_denied;
172};
173
174
175struct nfsd4_locku {
176 u32 lu_type;
177 u32 lu_seqid;
178 stateid_t lu_stateid;
179 u64 lu_offset;
180 u64 lu_length;
181 struct nfs4_stateowner *lu_stateowner;
182};
183
184
185struct nfsd4_lookup {
186 u32 lo_len; /* request */
187 char * lo_name; /* request */
188};
189
190struct nfsd4_putfh {
191 u32 pf_fhlen; /* request */
192 char *pf_fhval; /* request */
193};
194
195struct nfsd4_open {
196 u32 op_claim_type; /* request */
197 struct xdr_netobj op_fname; /* request - everything but CLAIM_PREV */
198 u32 op_delegate_type; /* request - CLAIM_PREV only */
199 stateid_t op_delegate_stateid; /* request - response */
200 u32 op_create; /* request */
201 u32 op_createmode; /* request */
202 u32 op_bmval[2]; /* request */
203 union { /* request */
204 struct iattr iattr; /* UNCHECKED4,GUARDED4 */
205 nfs4_verifier verf; /* EXCLUSIVE4 */
206 } u;
207 clientid_t op_clientid; /* request */
208 struct xdr_netobj op_owner; /* request */
209 u32 op_seqid; /* request */
210 u32 op_share_access; /* request */
211 u32 op_share_deny; /* request */
212 stateid_t op_stateid; /* response */
213 struct nfsd4_change_info op_cinfo; /* response */
214 u32 op_rflags; /* response */
215 int op_truncate; /* used during processing */
216 struct nfs4_stateowner *op_stateowner; /* used during processing */
217 struct nfs4_acl *op_acl;
218};
219#define op_iattr u.iattr
220#define op_verf u.verf
221
222struct nfsd4_open_confirm {
223 stateid_t oc_req_stateid /* request */;
224 u32 oc_seqid /* request */;
225 stateid_t oc_resp_stateid /* response */;
226 struct nfs4_stateowner * oc_stateowner; /* response */
227};
228
229struct nfsd4_open_downgrade {
230 stateid_t od_stateid;
231 u32 od_seqid;
232 u32 od_share_access;
233 u32 od_share_deny;
234 struct nfs4_stateowner *od_stateowner;
235};
236
237
238struct nfsd4_read {
239 stateid_t rd_stateid; /* request */
240 u64 rd_offset; /* request */
241 u32 rd_length; /* request */
242 struct kvec rd_iov[RPCSVC_MAXPAGES];
243 int rd_vlen;
244 struct file *rd_filp;
245
246 struct svc_rqst *rd_rqstp; /* response */
247 struct svc_fh * rd_fhp; /* response */
248};
249
250struct nfsd4_readdir {
251 u64 rd_cookie; /* request */
252 nfs4_verifier rd_verf; /* request */
253 u32 rd_dircount; /* request */
254 u32 rd_maxcount; /* request */
255 u32 rd_bmval[2]; /* request */
256 struct svc_rqst *rd_rqstp; /* response */
257 struct svc_fh * rd_fhp; /* response */
258
259 struct readdir_cd common;
260 u32 * buffer;
261 int buflen;
262 u32 * offset;
263};
264
265struct nfsd4_release_lockowner {
266 clientid_t rl_clientid;
267 struct xdr_netobj rl_owner;
268};
269struct nfsd4_readlink {
270 struct svc_rqst *rl_rqstp; /* request */
271 struct svc_fh * rl_fhp; /* request */
272};
273
274struct nfsd4_remove {
275 u32 rm_namelen; /* request */
276 char * rm_name; /* request */
277 struct nfsd4_change_info rm_cinfo; /* response */
278};
279
280struct nfsd4_rename {
281 u32 rn_snamelen; /* request */
282 char * rn_sname; /* request */
283 u32 rn_tnamelen; /* request */
284 char * rn_tname; /* request */
285 struct nfsd4_change_info rn_sinfo; /* response */
286 struct nfsd4_change_info rn_tinfo; /* response */
287};
288
289struct nfsd4_setattr {
290 stateid_t sa_stateid; /* request */
291 u32 sa_bmval[2]; /* request */
292 struct iattr sa_iattr; /* request */
293 struct nfs4_acl *sa_acl;
294};
295
296struct nfsd4_setclientid {
297 nfs4_verifier se_verf; /* request */
298 u32 se_namelen; /* request */
299 char * se_name; /* request */
300 u32 se_callback_prog; /* request */
301 u32 se_callback_netid_len; /* request */
302 char * se_callback_netid_val; /* request */
303 u32 se_callback_addr_len; /* request */
304 char * se_callback_addr_val; /* request */
305 u32 se_callback_ident; /* request */
306 clientid_t se_clientid; /* response */
307 nfs4_verifier se_confirm; /* response */
308};
309
310struct nfsd4_setclientid_confirm {
311 clientid_t sc_clientid;
312 nfs4_verifier sc_confirm;
313};
314
315/* also used for NVERIFY */
316struct nfsd4_verify {
317 u32 ve_bmval[2]; /* request */
318 u32 ve_attrlen; /* request */
319 char * ve_attrval; /* request */
320};
321
322struct nfsd4_write {
323 stateid_t wr_stateid; /* request */
324 u64 wr_offset; /* request */
325 u32 wr_stable_how; /* request */
326 u32 wr_buflen; /* request */
327 struct kvec wr_vec[RPCSVC_MAXPAGES]; /* request */
328 int wr_vlen;
329
330 u32 wr_bytes_written; /* response */
331 u32 wr_how_written; /* response */
332 nfs4_verifier wr_verifier; /* response */
333};
334
335struct nfsd4_op {
336 int opnum;
337 int status;
338 union {
339 struct nfsd4_access access;
340 struct nfsd4_close close;
341 struct nfsd4_commit commit;
342 struct nfsd4_create create;
343 struct nfsd4_delegreturn delegreturn;
344 struct nfsd4_getattr getattr;
345 struct svc_fh * getfh;
346 struct nfsd4_link link;
347 struct nfsd4_lock lock;
348 struct nfsd4_lockt lockt;
349 struct nfsd4_locku locku;
350 struct nfsd4_lookup lookup;
351 struct nfsd4_verify nverify;
352 struct nfsd4_open open;
353 struct nfsd4_open_confirm open_confirm;
354 struct nfsd4_open_downgrade open_downgrade;
355 struct nfsd4_putfh putfh;
356 struct nfsd4_read read;
357 struct nfsd4_readdir readdir;
358 struct nfsd4_readlink readlink;
359 struct nfsd4_remove remove;
360 struct nfsd4_rename rename;
361 clientid_t renew;
362 struct nfsd4_setattr setattr;
363 struct nfsd4_setclientid setclientid;
364 struct nfsd4_setclientid_confirm setclientid_confirm;
365 struct nfsd4_verify verify;
366 struct nfsd4_write write;
367 struct nfsd4_release_lockowner release_lockowner;
368 } u;
369 struct nfs4_replay * replay;
370};
371
372struct nfsd4_compoundargs {
373 /* scratch variables for XDR decode */
374 u32 * p;
375 u32 * end;
376 struct page ** pagelist;
377 int pagelen;
378 u32 tmp[8];
379 u32 * tmpp;
380 struct tmpbuf {
381 struct tmpbuf *next;
382 void (*release)(const void *);
383 void *buf;
384 } *to_free;
385
386 struct svc_rqst *rqstp;
387
388 u32 taglen;
389 char * tag;
390 u32 minorversion;
391 u32 opcnt;
392 struct nfsd4_op *ops;
393 struct nfsd4_op iops[8];
394};
395
396struct nfsd4_compoundres {
397 /* scratch variables for XDR encode */
398 u32 * p;
399 u32 * end;
400 struct xdr_buf * xbuf;
401 struct svc_rqst * rqstp;
402
403 u32 taglen;
404 char * tag;
405 u32 opcnt;
406 u32 * tagp; /* where to encode tag and opcount */
407};
408
409#define NFS4_SVC_XDRSIZE sizeof(struct nfsd4_compoundargs)
410
411static inline void
412set_change_info(struct nfsd4_change_info *cinfo, struct svc_fh *fhp)
413{
414 BUG_ON(!fhp->fh_pre_saved || !fhp->fh_post_saved);
415 cinfo->atomic = 1;
416 cinfo->before_ctime_sec = fhp->fh_pre_ctime.tv_sec;
417 cinfo->before_ctime_nsec = fhp->fh_pre_ctime.tv_nsec;
418 cinfo->after_ctime_sec = fhp->fh_post_ctime.tv_sec;
419 cinfo->after_ctime_nsec = fhp->fh_post_ctime.tv_nsec;
420}
421
422int nfs4svc_encode_voidres(struct svc_rqst *, u32 *, void *);
423int nfs4svc_decode_compoundargs(struct svc_rqst *, u32 *,
424 struct nfsd4_compoundargs *);
425int nfs4svc_encode_compoundres(struct svc_rqst *, u32 *,
426 struct nfsd4_compoundres *);
427void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *);
428void nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op);
429int nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
430 struct dentry *dentry, u32 *buffer, int *countp,
431 u32 *bmval, struct svc_rqst *);
432extern int nfsd4_setclientid(struct svc_rqst *rqstp,
433 struct nfsd4_setclientid *setclid);
434extern int nfsd4_setclientid_confirm(struct svc_rqst *rqstp,
435 struct nfsd4_setclientid_confirm *setclientid_confirm);
436extern int nfsd4_process_open1(struct nfsd4_open *open);
437extern int nfsd4_process_open2(struct svc_rqst *rqstp,
438 struct svc_fh *current_fh, struct nfsd4_open *open);
439extern int nfsd4_open_confirm(struct svc_rqst *rqstp,
440 struct svc_fh *current_fh, struct nfsd4_open_confirm *oc);
441extern int nfsd4_close(struct svc_rqst *rqstp, struct svc_fh *current_fh,
442 struct nfsd4_close *close);
443extern int nfsd4_open_downgrade(struct svc_rqst *rqstp,
444 struct svc_fh *current_fh, struct nfsd4_open_downgrade *od);
445extern int nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh,
446 struct nfsd4_lock *lock);
447extern int nfsd4_lockt(struct svc_rqst *rqstp, struct svc_fh *current_fh,
448 struct nfsd4_lockt *lockt);
449extern int nfsd4_locku(struct svc_rqst *rqstp, struct svc_fh *current_fh,
450 struct nfsd4_locku *locku);
451extern int
452nfsd4_release_lockowner(struct svc_rqst *rqstp,
453 struct nfsd4_release_lockowner *rlockowner);
454extern void nfsd4_release_compoundargs(struct nfsd4_compoundargs *);
455extern int nfsd4_delegreturn(struct svc_rqst *rqstp,
456 struct svc_fh *current_fh, struct nfsd4_delegreturn *dr);
457#endif
458
459/*
460 * Local variables:
461 * c-basic-offset: 8
462 * End:
463 */
diff --git a/include/linux/nfsd_idmap.h b/include/linux/nfsd_idmap.h
new file mode 100644
index 000000000000..9bb7f30e923b
--- /dev/null
+++ b/include/linux/nfsd_idmap.h
@@ -0,0 +1,54 @@
1/*
2 * include/linux/nfsd_idmap.h
3 *
4 * Mapping of UID to name and vice versa.
5 *
6 * Copyright (c) 2002, 2003 The Regents of the University of
7 * Michigan. All rights reserved.
8> *
9 * Marius Aamodt Eriksen <marius@umich.edu>
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 *
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the University nor the names of its
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
25 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
31 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#ifndef LINUX_NFSD_IDMAP_H
38#define LINUX_NFSD_IDMAP_H
39
40#include <linux/in.h>
41#include <linux/sunrpc/svc.h>
42
43/* XXX from linux/nfs_idmap.h */
44#define IDMAP_NAMESZ 128
45
46void nfsd_idmap_init(void);
47void nfsd_idmap_shutdown(void);
48
49int nfsd_map_name_to_uid(struct svc_rqst *, const char *, size_t, __u32 *);
50int nfsd_map_name_to_gid(struct svc_rqst *, const char *, size_t, __u32 *);
51int nfsd_map_uid_to_name(struct svc_rqst *, __u32, char *);
52int nfsd_map_gid_to_name(struct svc_rqst *, __u32, char *);
53
54#endif /* LINUX_NFSD_IDMAP_H */
diff --git a/include/linux/nls.h b/include/linux/nls.h
new file mode 100644
index 000000000000..816c04ad7381
--- /dev/null
+++ b/include/linux/nls.h
@@ -0,0 +1,64 @@
1#ifndef _LINUX_NLS_H
2#define _LINUX_NLS_H
3
4#include <linux/init.h>
5
6/* unicode character */
7typedef __u16 wchar_t;
8
9struct nls_table {
10 char *charset;
11 char *alias;
12 int (*uni2char) (wchar_t uni, unsigned char *out, int boundlen);
13 int (*char2uni) (const unsigned char *rawstring, int boundlen,
14 wchar_t *uni);
15 unsigned char *charset2lower;
16 unsigned char *charset2upper;
17 struct module *owner;
18 struct nls_table *next;
19};
20
21/* this value hold the maximum octet of charset */
22#define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
23
24/* nls.c */
25extern int register_nls(struct nls_table *);
26extern int unregister_nls(struct nls_table *);
27extern struct nls_table *load_nls(char *);
28extern void unload_nls(struct nls_table *);
29extern struct nls_table *load_nls_default(void);
30
31extern int utf8_mbtowc(wchar_t *, const __u8 *, int);
32extern int utf8_mbstowcs(wchar_t *, const __u8 *, int);
33extern int utf8_wctomb(__u8 *, wchar_t, int);
34extern int utf8_wcstombs(__u8 *, const wchar_t *, int);
35
36static inline unsigned char nls_tolower(struct nls_table *t, unsigned char c)
37{
38 unsigned char nc = t->charset2lower[c];
39
40 return nc ? nc : c;
41}
42
43static inline unsigned char nls_toupper(struct nls_table *t, unsigned char c)
44{
45 unsigned char nc = t->charset2upper[c];
46
47 return nc ? nc : c;
48}
49
50static inline int nls_strnicmp(struct nls_table *t, const unsigned char *s1,
51 const unsigned char *s2, int len)
52{
53 while (len--) {
54 if (nls_tolower(t, *s1++) != nls_tolower(t, *s2++))
55 return 1;
56 }
57
58 return 0;
59}
60
61#define MODULE_ALIAS_NLS(name) MODULE_ALIAS("nls_" __stringify(name))
62
63#endif /* _LINUX_NLS_H */
64
diff --git a/include/linux/nmi.h b/include/linux/nmi.h
new file mode 100644
index 000000000000..c8f4d2f627d7
--- /dev/null
+++ b/include/linux/nmi.h
@@ -0,0 +1,22 @@
1/*
2 * linux/include/linux/nmi.h
3 */
4#ifndef LINUX_NMI_H
5#define LINUX_NMI_H
6
7#include <asm/irq.h>
8
9/**
10 * touch_nmi_watchdog - restart NMI watchdog timeout.
11 *
12 * If the architecture supports the NMI watchdog, touch_nmi_watchdog()
13 * may be used to reset the timeout - for code which intentionally
14 * disables interrupts for a long time. This call is stateless.
15 */
16#ifdef ARCH_HAS_NMI_WATCHDOG
17extern void touch_nmi_watchdog(void);
18#else
19# define touch_nmi_watchdog() do { } while(0)
20#endif
21
22#endif
diff --git a/include/linux/node.h b/include/linux/node.h
new file mode 100644
index 000000000000..6e0a697e594e
--- /dev/null
+++ b/include/linux/node.h
@@ -0,0 +1,33 @@
1/*
2 * include/linux/node.h - generic node definition
3 *
4 * This is mainly for topological representation. We define the
5 * basic 'struct node' here, which can be embedded in per-arch
6 * definitions of processors.
7 *
8 * Basic handling of the devices is done in drivers/base/node.c
9 * and system devices are handled in drivers/base/sys.c.
10 *
11 * Nodes are exported via driverfs in the class/node/devices/
12 * directory.
13 *
14 * Per-node interfaces can be implemented using a struct device_interface.
15 * See the following for how to do this:
16 * - drivers/base/intf.c
17 * - Documentation/driver-model/interface.txt
18 */
19#ifndef _LINUX_NODE_H_
20#define _LINUX_NODE_H_
21
22#include <linux/sysdev.h>
23#include <linux/cpumask.h>
24
25struct node {
26 struct sys_device sysdev;
27};
28
29extern int register_node(struct node *, int, struct node *);
30
31#define to_node(sys_device) container_of(sys_device, struct node, sysdev)
32
33#endif /* _LINUX_NODE_H_ */
diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h
new file mode 100644
index 000000000000..e96fe9062500
--- /dev/null
+++ b/include/linux/nodemask.h
@@ -0,0 +1,356 @@
1#ifndef __LINUX_NODEMASK_H
2#define __LINUX_NODEMASK_H
3
4/*
5 * Nodemasks provide a bitmap suitable for representing the
6 * set of Node's in a system, one bit position per Node number.
7 *
8 * See detailed comments in the file linux/bitmap.h describing the
9 * data type on which these nodemasks are based.
10 *
11 * For details of nodemask_scnprintf() and nodemask_parse(),
12 * see bitmap_scnprintf() and bitmap_parse() in lib/bitmap.c.
13 * For details of nodelist_scnprintf() and nodelist_parse(), see
14 * bitmap_scnlistprintf() and bitmap_parselist(), also in bitmap.c.
15 *
16 * The available nodemask operations are:
17 *
18 * void node_set(node, mask) turn on bit 'node' in mask
19 * void node_clear(node, mask) turn off bit 'node' in mask
20 * void nodes_setall(mask) set all bits
21 * void nodes_clear(mask) clear all bits
22 * int node_isset(node, mask) true iff bit 'node' set in mask
23 * int node_test_and_set(node, mask) test and set bit 'node' in mask
24 *
25 * void nodes_and(dst, src1, src2) dst = src1 & src2 [intersection]
26 * void nodes_or(dst, src1, src2) dst = src1 | src2 [union]
27 * void nodes_xor(dst, src1, src2) dst = src1 ^ src2
28 * void nodes_andnot(dst, src1, src2) dst = src1 & ~src2
29 * void nodes_complement(dst, src) dst = ~src
30 *
31 * int nodes_equal(mask1, mask2) Does mask1 == mask2?
32 * int nodes_intersects(mask1, mask2) Do mask1 and mask2 intersect?
33 * int nodes_subset(mask1, mask2) Is mask1 a subset of mask2?
34 * int nodes_empty(mask) Is mask empty (no bits sets)?
35 * int nodes_full(mask) Is mask full (all bits sets)?
36 * int nodes_weight(mask) Hamming weight - number of set bits
37 *
38 * void nodes_shift_right(dst, src, n) Shift right
39 * void nodes_shift_left(dst, src, n) Shift left
40 *
41 * int first_node(mask) Number lowest set bit, or MAX_NUMNODES
42 * int next_node(node, mask) Next node past 'node', or MAX_NUMNODES
43 * int first_unset_node(mask) First node not set in mask, or
44 * MAX_NUMNODES.
45 *
46 * nodemask_t nodemask_of_node(node) Return nodemask with bit 'node' set
47 * NODE_MASK_ALL Initializer - all bits set
48 * NODE_MASK_NONE Initializer - no bits set
49 * unsigned long *nodes_addr(mask) Array of unsigned long's in mask
50 *
51 * int nodemask_scnprintf(buf, len, mask) Format nodemask for printing
52 * int nodemask_parse(ubuf, ulen, mask) Parse ascii string as nodemask
53 * int nodelist_scnprintf(buf, len, mask) Format nodemask as list for printing
54 * int nodelist_parse(buf, map) Parse ascii string as nodelist
55 *
56 * for_each_node_mask(node, mask) for-loop node over mask
57 *
58 * int num_online_nodes() Number of online Nodes
59 * int num_possible_nodes() Number of all possible Nodes
60 *
61 * int node_online(node) Is some node online?
62 * int node_possible(node) Is some node possible?
63 *
64 * int any_online_node(mask) First online node in mask
65 *
66 * node_set_online(node) set bit 'node' in node_online_map
67 * node_set_offline(node) clear bit 'node' in node_online_map
68 *
69 * for_each_node(node) for-loop node over node_possible_map
70 * for_each_online_node(node) for-loop node over node_online_map
71 *
72 * Subtlety:
73 * 1) The 'type-checked' form of node_isset() causes gcc (3.3.2, anyway)
74 * to generate slightly worse code. So use a simple one-line #define
75 * for node_isset(), instead of wrapping an inline inside a macro, the
76 * way we do the other calls.
77 */
78
79#include <linux/kernel.h>
80#include <linux/threads.h>
81#include <linux/bitmap.h>
82#include <linux/numa.h>
83#include <asm/bug.h>
84
85typedef struct { DECLARE_BITMAP(bits, MAX_NUMNODES); } nodemask_t;
86extern nodemask_t _unused_nodemask_arg_;
87
88#define node_set(node, dst) __node_set((node), &(dst))
89static inline void __node_set(int node, volatile nodemask_t *dstp)
90{
91 set_bit(node, dstp->bits);
92}
93
94#define node_clear(node, dst) __node_clear((node), &(dst))
95static inline void __node_clear(int node, volatile nodemask_t *dstp)
96{
97 clear_bit(node, dstp->bits);
98}
99
100#define nodes_setall(dst) __nodes_setall(&(dst), MAX_NUMNODES)
101static inline void __nodes_setall(nodemask_t *dstp, int nbits)
102{
103 bitmap_fill(dstp->bits, nbits);
104}
105
106#define nodes_clear(dst) __nodes_clear(&(dst), MAX_NUMNODES)
107static inline void __nodes_clear(nodemask_t *dstp, int nbits)
108{
109 bitmap_zero(dstp->bits, nbits);
110}
111
112/* No static inline type checking - see Subtlety (1) above. */
113#define node_isset(node, nodemask) test_bit((node), (nodemask).bits)
114
115#define node_test_and_set(node, nodemask) \
116 __node_test_and_set((node), &(nodemask))
117static inline int __node_test_and_set(int node, nodemask_t *addr)
118{
119 return test_and_set_bit(node, addr->bits);
120}
121
122#define nodes_and(dst, src1, src2) \
123 __nodes_and(&(dst), &(src1), &(src2), MAX_NUMNODES)
124static inline void __nodes_and(nodemask_t *dstp, const nodemask_t *src1p,
125 const nodemask_t *src2p, int nbits)
126{
127 bitmap_and(dstp->bits, src1p->bits, src2p->bits, nbits);
128}
129
130#define nodes_or(dst, src1, src2) \
131 __nodes_or(&(dst), &(src1), &(src2), MAX_NUMNODES)
132static inline void __nodes_or(nodemask_t *dstp, const nodemask_t *src1p,
133 const nodemask_t *src2p, int nbits)
134{
135 bitmap_or(dstp->bits, src1p->bits, src2p->bits, nbits);
136}
137
138#define nodes_xor(dst, src1, src2) \
139 __nodes_xor(&(dst), &(src1), &(src2), MAX_NUMNODES)
140static inline void __nodes_xor(nodemask_t *dstp, const nodemask_t *src1p,
141 const nodemask_t *src2p, int nbits)
142{
143 bitmap_xor(dstp->bits, src1p->bits, src2p->bits, nbits);
144}
145
146#define nodes_andnot(dst, src1, src2) \
147 __nodes_andnot(&(dst), &(src1), &(src2), MAX_NUMNODES)
148static inline void __nodes_andnot(nodemask_t *dstp, const nodemask_t *src1p,
149 const nodemask_t *src2p, int nbits)
150{
151 bitmap_andnot(dstp->bits, src1p->bits, src2p->bits, nbits);
152}
153
154#define nodes_complement(dst, src) \
155 __nodes_complement(&(dst), &(src), MAX_NUMNODES)
156static inline void __nodes_complement(nodemask_t *dstp,
157 const nodemask_t *srcp, int nbits)
158{
159 bitmap_complement(dstp->bits, srcp->bits, nbits);
160}
161
162#define nodes_equal(src1, src2) \
163 __nodes_equal(&(src1), &(src2), MAX_NUMNODES)
164static inline int __nodes_equal(const nodemask_t *src1p,
165 const nodemask_t *src2p, int nbits)
166{
167 return bitmap_equal(src1p->bits, src2p->bits, nbits);
168}
169
170#define nodes_intersects(src1, src2) \
171 __nodes_intersects(&(src1), &(src2), MAX_NUMNODES)
172static inline int __nodes_intersects(const nodemask_t *src1p,
173 const nodemask_t *src2p, int nbits)
174{
175 return bitmap_intersects(src1p->bits, src2p->bits, nbits);
176}
177
178#define nodes_subset(src1, src2) \
179 __nodes_subset(&(src1), &(src2), MAX_NUMNODES)
180static inline int __nodes_subset(const nodemask_t *src1p,
181 const nodemask_t *src2p, int nbits)
182{
183 return bitmap_subset(src1p->bits, src2p->bits, nbits);
184}
185
186#define nodes_empty(src) __nodes_empty(&(src), MAX_NUMNODES)
187static inline int __nodes_empty(const nodemask_t *srcp, int nbits)
188{
189 return bitmap_empty(srcp->bits, nbits);
190}
191
192#define nodes_full(nodemask) __nodes_full(&(nodemask), MAX_NUMNODES)
193static inline int __nodes_full(const nodemask_t *srcp, int nbits)
194{
195 return bitmap_full(srcp->bits, nbits);
196}
197
198#define nodes_weight(nodemask) __nodes_weight(&(nodemask), MAX_NUMNODES)
199static inline int __nodes_weight(const nodemask_t *srcp, int nbits)
200{
201 return bitmap_weight(srcp->bits, nbits);
202}
203
204#define nodes_shift_right(dst, src, n) \
205 __nodes_shift_right(&(dst), &(src), (n), MAX_NUMNODES)
206static inline void __nodes_shift_right(nodemask_t *dstp,
207 const nodemask_t *srcp, int n, int nbits)
208{
209 bitmap_shift_right(dstp->bits, srcp->bits, n, nbits);
210}
211
212#define nodes_shift_left(dst, src, n) \
213 __nodes_shift_left(&(dst), &(src), (n), MAX_NUMNODES)
214static inline void __nodes_shift_left(nodemask_t *dstp,
215 const nodemask_t *srcp, int n, int nbits)
216{
217 bitmap_shift_left(dstp->bits, srcp->bits, n, nbits);
218}
219
220/* FIXME: better would be to fix all architectures to never return
221 > MAX_NUMNODES, then the silly min_ts could be dropped. */
222
223#define first_node(src) __first_node(&(src))
224static inline int __first_node(const nodemask_t *srcp)
225{
226 return min_t(int, MAX_NUMNODES, find_first_bit(srcp->bits, MAX_NUMNODES));
227}
228
229#define next_node(n, src) __next_node((n), &(src))
230static inline int __next_node(int n, const nodemask_t *srcp)
231{
232 return min_t(int,MAX_NUMNODES,find_next_bit(srcp->bits, MAX_NUMNODES, n+1));
233}
234
235#define nodemask_of_node(node) \
236({ \
237 typeof(_unused_nodemask_arg_) m; \
238 if (sizeof(m) == sizeof(unsigned long)) { \
239 m.bits[0] = 1UL<<(node); \
240 } else { \
241 nodes_clear(m); \
242 node_set((node), m); \
243 } \
244 m; \
245})
246
247#define first_unset_node(mask) __first_unset_node(&(mask))
248static inline int __first_unset_node(const nodemask_t *maskp)
249{
250 return min_t(int,MAX_NUMNODES,
251 find_first_zero_bit(maskp->bits, MAX_NUMNODES));
252}
253
254#define NODE_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(MAX_NUMNODES)
255
256#if MAX_NUMNODES <= BITS_PER_LONG
257
258#define NODE_MASK_ALL \
259((nodemask_t) { { \
260 [BITS_TO_LONGS(MAX_NUMNODES)-1] = NODE_MASK_LAST_WORD \
261} })
262
263#else
264
265#define NODE_MASK_ALL \
266((nodemask_t) { { \
267 [0 ... BITS_TO_LONGS(MAX_NUMNODES)-2] = ~0UL, \
268 [BITS_TO_LONGS(MAX_NUMNODES)-1] = NODE_MASK_LAST_WORD \
269} })
270
271#endif
272
273#define NODE_MASK_NONE \
274((nodemask_t) { { \
275 [0 ... BITS_TO_LONGS(MAX_NUMNODES)-1] = 0UL \
276} })
277
278#define nodes_addr(src) ((src).bits)
279
280#define nodemask_scnprintf(buf, len, src) \
281 __nodemask_scnprintf((buf), (len), &(src), MAX_NUMNODES)
282static inline int __nodemask_scnprintf(char *buf, int len,
283 const nodemask_t *srcp, int nbits)
284{
285 return bitmap_scnprintf(buf, len, srcp->bits, nbits);
286}
287
288#define nodemask_parse(ubuf, ulen, dst) \
289 __nodemask_parse((ubuf), (ulen), &(dst), MAX_NUMNODES)
290static inline int __nodemask_parse(const char __user *buf, int len,
291 nodemask_t *dstp, int nbits)
292{
293 return bitmap_parse(buf, len, dstp->bits, nbits);
294}
295
296#define nodelist_scnprintf(buf, len, src) \
297 __nodelist_scnprintf((buf), (len), &(src), MAX_NUMNODES)
298static inline int __nodelist_scnprintf(char *buf, int len,
299 const nodemask_t *srcp, int nbits)
300{
301 return bitmap_scnlistprintf(buf, len, srcp->bits, nbits);
302}
303
304#define nodelist_parse(buf, dst) __nodelist_parse((buf), &(dst), MAX_NUMNODES)
305static inline int __nodelist_parse(const char *buf, nodemask_t *dstp, int nbits)
306{
307 return bitmap_parselist(buf, dstp->bits, nbits);
308}
309
310#if MAX_NUMNODES > 1
311#define for_each_node_mask(node, mask) \
312 for ((node) = first_node(mask); \
313 (node) < MAX_NUMNODES; \
314 (node) = next_node((node), (mask)))
315#else /* MAX_NUMNODES == 1 */
316#define for_each_node_mask(node, mask) \
317 if (!nodes_empty(mask)) \
318 for ((node) = 0; (node) < 1; (node)++)
319#endif /* MAX_NUMNODES */
320
321/*
322 * The following particular system nodemasks and operations
323 * on them manage all possible and online nodes.
324 */
325
326extern nodemask_t node_online_map;
327extern nodemask_t node_possible_map;
328
329#if MAX_NUMNODES > 1
330#define num_online_nodes() nodes_weight(node_online_map)
331#define num_possible_nodes() nodes_weight(node_possible_map)
332#define node_online(node) node_isset((node), node_online_map)
333#define node_possible(node) node_isset((node), node_possible_map)
334#else
335#define num_online_nodes() 1
336#define num_possible_nodes() 1
337#define node_online(node) ((node) == 0)
338#define node_possible(node) ((node) == 0)
339#endif
340
341#define any_online_node(mask) \
342({ \
343 int node; \
344 for_each_node_mask(node, (mask)) \
345 if (node_online(node)) \
346 break; \
347 node; \
348})
349
350#define node_set_online(node) set_bit((node), node_online_map.bits)
351#define node_set_offline(node) clear_bit((node), node_online_map.bits)
352
353#define for_each_node(node) for_each_node_mask((node), node_possible_map)
354#define for_each_online_node(node) for_each_node_mask((node), node_online_map)
355
356#endif /* __LINUX_NODEMASK_H */
diff --git a/include/linux/notifier.h b/include/linux/notifier.h
new file mode 100644
index 000000000000..9303a003e9ab
--- /dev/null
+++ b/include/linux/notifier.h
@@ -0,0 +1,75 @@
1/*
2 * Routines to manage notifier chains for passing status changes to any
3 * interested routines. We need this instead of hard coded call lists so
4 * that modules can poke their nose into the innards. The network devices
5 * needed them so here they are for the rest of you.
6 *
7 * Alan Cox <Alan.Cox@linux.org>
8 */
9
10#ifndef _LINUX_NOTIFIER_H
11#define _LINUX_NOTIFIER_H
12#include <linux/errno.h>
13
14struct notifier_block
15{
16 int (*notifier_call)(struct notifier_block *self, unsigned long, void *);
17 struct notifier_block *next;
18 int priority;
19};
20
21
22#ifdef __KERNEL__
23
24extern int notifier_chain_register(struct notifier_block **list, struct notifier_block *n);
25extern int notifier_chain_unregister(struct notifier_block **nl, struct notifier_block *n);
26extern int notifier_call_chain(struct notifier_block **n, unsigned long val, void *v);
27
28#define NOTIFY_DONE 0x0000 /* Don't care */
29#define NOTIFY_OK 0x0001 /* Suits me */
30#define NOTIFY_STOP_MASK 0x8000 /* Don't call further */
31#define NOTIFY_BAD (NOTIFY_STOP_MASK|0x0002) /* Bad/Veto action */
32/*
33 * Clean way to return from the notifier and stop further calls.
34 */
35#define NOTIFY_STOP (NOTIFY_OK|NOTIFY_STOP_MASK)
36
37/*
38 * Declared notifiers so far. I can imagine quite a few more chains
39 * over time (eg laptop power reset chains, reboot chain (to clean
40 * device units up), device [un]mount chain, module load/unload chain,
41 * low memory chain, screenblank chain (for plug in modular screenblankers)
42 * VC switch chains (for loadable kernel svgalib VC switch helpers) etc...
43 */
44
45/* netdevice notifier chain */
46#define NETDEV_UP 0x0001 /* For now you can't veto a device up/down */
47#define NETDEV_DOWN 0x0002
48#define NETDEV_REBOOT 0x0003 /* Tell a protocol stack a network interface
49 detected a hardware crash and restarted
50 - we can use this eg to kick tcp sessions
51 once done */
52#define NETDEV_CHANGE 0x0004 /* Notify device state change */
53#define NETDEV_REGISTER 0x0005
54#define NETDEV_UNREGISTER 0x0006
55#define NETDEV_CHANGEMTU 0x0007
56#define NETDEV_CHANGEADDR 0x0008
57#define NETDEV_GOING_DOWN 0x0009
58#define NETDEV_CHANGENAME 0x000A
59
60#define SYS_DOWN 0x0001 /* Notify of system down */
61#define SYS_RESTART SYS_DOWN
62#define SYS_HALT 0x0002 /* Notify of system halt */
63#define SYS_POWER_OFF 0x0003 /* Notify of system power off */
64
65#define NETLINK_URELEASE 0x0001 /* Unicast netlink socket released */
66
67#define CPU_ONLINE 0x0002 /* CPU (unsigned)v is up */
68#define CPU_UP_PREPARE 0x0003 /* CPU (unsigned)v coming up */
69#define CPU_UP_CANCELED 0x0004 /* CPU (unsigned)v NOT coming up */
70#define CPU_DOWN_PREPARE 0x0005 /* CPU (unsigned)v going down */
71#define CPU_DOWN_FAILED 0x0006 /* CPU (unsigned)v NOT going down */
72#define CPU_DEAD 0x0007 /* CPU (unsigned)v dead */
73
74#endif /* __KERNEL__ */
75#endif /* _LINUX_NOTIFIER_H */
diff --git a/include/linux/nubus.h b/include/linux/nubus.h
new file mode 100644
index 000000000000..870e66a96286
--- /dev/null
+++ b/include/linux/nubus.h
@@ -0,0 +1,334 @@
1/*
2 nubus.h: various definitions and prototypes for NuBus drivers to use.
3
4 Originally written by Alan Cox.
5
6 Hacked to death by C. Scott Ananian and David Huggins-Daines.
7
8 Some of the constants in here are from the corresponding
9 NetBSD/OpenBSD header file, by Allen Briggs. We figured out the
10 rest of them on our own. */
11
12#ifndef LINUX_NUBUS_H
13#define LINUX_NUBUS_H
14
15#ifdef __KERNEL__
16#include <asm/nubus.h>
17#endif
18
19enum nubus_category {
20 NUBUS_CAT_BOARD = 0x0001,
21 NUBUS_CAT_DISPLAY = 0x0003,
22 NUBUS_CAT_NETWORK = 0x0004,
23 NUBUS_CAT_COMMUNICATIONS = 0x0006,
24 NUBUS_CAT_FONT = 0x0009,
25 NUBUS_CAT_CPU = 0x000A,
26 /* For lack of a better name */
27 NUBUS_CAT_DUODOCK = 0x0020
28};
29
30enum nubus_type_network {
31 NUBUS_TYPE_ETHERNET = 0x0001,
32 NUBUS_TYPE_RS232 = 0x0002
33};
34
35enum nubus_type_display {
36 NUBUS_TYPE_VIDEO = 0x0001
37};
38
39enum nubus_type_cpu {
40 NUBUS_TYPE_68020 = 0x0003,
41 NUBUS_TYPE_68030 = 0x0004,
42 NUBUS_TYPE_68040 = 0x0005
43};
44
45/* Known <Cat,Type,SW,HW> tuples: (according to TattleTech and Slots)
46 * 68030 motherboards: <10,4,0,24>
47 * 68040 motherboards: <10,5,0,24>
48 * DuoDock Plus: <32,1,1,2>
49 *
50 * Toby Frame Buffer card: <3,1,1,1>
51 * RBV built-in video (IIci): <3,1,1,24>
52 * Valkyrie built-in video (Q630): <3,1,1,46>
53 * Macintosh Display Card: <3,1,1,25>
54 * Sonora built-in video (P460): <3,1,1,34>
55 * Jet framebuffer (DuoDock Plus): <3,1,1,41>
56 *
57 * SONIC comm-slot/on-board and DuoDock Ethernet: <4,1,1,272>
58 * SONIC LC-PDS Ethernet (Dayna, but like Apple 16-bit, sort of): <4,1,1,271>
59 * Sonic Systems Ethernet A-Series Card: <4,1,268,256>
60 * Asante MacCon NuBus-A: <4,1,260,256> (alpha-1.0,1.1 revision)
61 * ROM on the above card: <2,1,0,0>
62 * Cabletron ethernet card: <4,1,1,265>
63 * Farallon ethernet card: <4,1,268,256> (identical to Sonic Systems card)
64 * Kinetics EtherPort IIN: <4,1,259,262>
65 * API Engineering EtherRun_LCa PDS enet card: <4,1,282,256>
66 *
67 * Add your devices to the list! You can obtain the "Slots" utility
68 * from Apple's FTP site at:
69 * ftp://dev.apple.com/devworld/Tool_Chest/Devices_-_Hardware/NuBus_Slot_Manager/
70 *
71 * Alternately, TattleTech can be found at any Info-Mac mirror site.
72 * or from its distribution site: ftp://ftp.decismkr.com/dms
73 */
74
75/* DrSW: Uniquely identifies the software interface to a board. This
76 is usually the one you want to look at when writing a driver. It's
77 not as useful as you think, though, because as we should know by
78 now (duh), "Apple Compatible" can mean a lot of things... */
79
80/* Add known DrSW values here */
81enum nubus_drsw {
82 /* NUBUS_CAT_DISPLAY */
83 NUBUS_DRSW_APPLE = 0x0001,
84 NUBUS_DRSW_APPLE_HIRES = 0x0013, /* MacII HiRes card driver */
85
86 /* NUBUS_CAT_NETWORK */
87 NUBUS_DRSW_CABLETRON = 0x0001,
88 NUBUS_DRSW_SONIC_LC = 0x0001,
89 NUBUS_DRSW_KINETICS = 0x0103,
90 NUBUS_DRSW_ASANTE = 0x0104,
91 NUBUS_DRSW_DAYNA = 0x010b,
92 NUBUS_DRSW_FARALLON = 0x010c,
93 NUBUS_DRSW_APPLE_SN = 0x010f,
94 NUBUS_DRSW_DAYNA2 = 0x0115,
95 NUBUS_DRSW_FOCUS = 0x011a,
96 NUBUS_DRSW_ASANTE_CS = 0x011d, /* use asante SMC9194 driver */
97 NUBUS_DRSW_DAYNA_LC = 0x011e,
98
99 /* NUBUS_CAT_CPU */
100 NUBUS_DRSW_NONE = 0x0000,
101};
102
103/* DrHW: Uniquely identifies the hardware interface to a board (or at
104 least, it should... some video cards are known to incorrectly
105 identify themselves as Toby cards) */
106
107/* Add known DrHW values here */
108enum nubus_drhw {
109 /* NUBUS_CAT_DISPLAY */
110 NUBUS_DRHW_APPLE_TFB = 0x0001, /* Toby frame buffer card */
111 NUBUS_DRHW_APPLE_HRVC = 0x0013, /* Mac II High Res Video card */
112 NUBUS_DRHW_APPLE_RBV1 = 0x0018, /* IIci RBV video */
113 NUBUS_DRHW_APPLE_MDC = 0x0019, /* Macintosh Display Card */
114 NUBUS_DRHW_APPLE_SONORA = 0x0022, /* Sonora built-in video */
115 NUBUS_DRHW_APPLE_JET = 0x0029, /* Jet framebuffer (DuoDock) */
116 NUBUS_DRHW_APPLE_VALKYRIE = 0x002e,
117 NUBUS_DRHW_THUNDER24 = 0x02cb, /* SuperMac Thunder/24 */
118
119 /* NUBUS_CAT_NETWORK */
120 NUBUS_DRHW_INTERLAN = 0x0100,
121 NUBUS_DRHW_SMC9194 = 0x0101,
122 NUBUS_DRHW_KINETICS = 0x0106,
123 NUBUS_DRHW_CABLETRON = 0x0109,
124 NUBUS_DRHW_ASANTE_LC = 0x010f,
125 NUBUS_DRHW_SONIC = 0x0110,
126 NUBUS_DRHW_SONIC_NB = 0x0118,
127 NUBUS_DRHW_SONIC_LC = 0x0119,
128
129 /* NUBUS_CAT_COMMUNICATIONS */
130 NUBUS_DRHW_DOVEFAX = 0x0100,
131};
132
133/* Resource IDs: These are the identifiers for the various weird and
134 wonderful tidbits of information that may or may not reside in the
135 NuBus ROM directory. */
136enum nubus_res_id {
137 NUBUS_RESID_TYPE = 0x0001,
138 NUBUS_RESID_NAME = 0x0002,
139 NUBUS_RESID_ICON = 0x0003,
140 NUBUS_RESID_DRVRDIR = 0x0004,
141 NUBUS_RESID_LOADREC = 0x0005,
142 NUBUS_RESID_BOOTREC = 0x0006,
143 NUBUS_RESID_FLAGS = 0x0007,
144 NUBUS_RESID_HWDEVID = 0x0008,
145 NUBUS_RESID_MINOR_BASEOS = 0x000a,
146 NUBUS_RESID_MINOR_LENGTH = 0x000b,
147 NUBUS_RESID_MAJOR_BASEOS = 0x000c,
148 NUBUS_RESID_MAJOR_LENGTH = 0x000d,
149 NUBUS_RESID_CICN = 0x000f,
150 NUBUS_RESID_ICL8 = 0x0010,
151 NUBUS_RESID_ICL4 = 0x0011,
152};
153
154/* Category-specific resources. */
155enum nubus_board_res_id {
156 NUBUS_RESID_BOARDID = 0x0020,
157 NUBUS_RESID_PRAMINITDATA = 0x0021,
158 NUBUS_RESID_PRIMARYINIT = 0x0022,
159 NUBUS_RESID_TIMEOUTCONST = 0x0023,
160 NUBUS_RESID_VENDORINFO = 0x0024,
161 NUBUS_RESID_BOARDFLAGS = 0x0025,
162 NUBUS_RESID_SECONDINIT = 0x0026,
163
164 /* Not sure why Apple put these next two in here */
165 NUBUS_RESID_VIDNAMES = 0x0041,
166 NUBUS_RESID_VIDMODES = 0x007e
167};
168
169/* Fields within the vendor info directory */
170enum nubus_vendor_res_id {
171 NUBUS_RESID_VEND_ID = 0x0001,
172 NUBUS_RESID_VEND_SERIAL = 0x0002,
173 NUBUS_RESID_VEND_REV = 0x0003,
174 NUBUS_RESID_VEND_PART = 0x0004,
175 NUBUS_RESID_VEND_DATE = 0x0005
176};
177
178enum nubus_net_res_id {
179 NUBUS_RESID_MAC_ADDRESS = 0x0080
180};
181
182enum nubus_cpu_res_id {
183 NUBUS_RESID_MEMINFO = 0x0081,
184 NUBUS_RESID_ROMINFO = 0x0082
185};
186
187enum nubus_display_res_id {
188 NUBUS_RESID_GAMMADIR = 0x0040,
189 NUBUS_RESID_FIRSTMODE = 0x0080,
190 NUBUS_RESID_SECONDMODE = 0x0081,
191 NUBUS_RESID_THIRDMODE = 0x0082,
192 NUBUS_RESID_FOURTHMODE = 0x0083,
193 NUBUS_RESID_FIFTHMODE = 0x0084,
194 NUBUS_RESID_SIXTHMODE = 0x0085
195};
196
197struct nubus_dir
198{
199 unsigned char *base;
200 unsigned char *ptr;
201 int done;
202 int mask;
203};
204
205struct nubus_dirent
206{
207 unsigned char *base;
208 unsigned char type;
209 __u32 data; /* Actually 24bits used */
210 int mask;
211};
212
213struct nubus_board {
214 struct nubus_board* next;
215 struct nubus_dev* first_dev;
216
217 /* Only 9-E actually exist, though 0-8 are also theoretically
218 possible, and 0 is a special case which represents the
219 motherboard and onboard peripherals (Ethernet, video) */
220 int slot;
221 /* For slot 0, this is bogus. */
222 char name[64];
223
224 /* Format block */
225 unsigned char* fblock;
226 /* Root directory (does *not* always equal fblock + doffset!) */
227 unsigned char* directory;
228
229 unsigned long slot_addr;
230 /* Offset to root directory (sometimes) */
231 unsigned long doffset;
232 /* Length over which to compute the crc */
233 unsigned long rom_length;
234 /* Completely useless most of the time */
235 unsigned long crc;
236 unsigned char rev;
237 unsigned char format;
238 unsigned char lanes;
239};
240
241struct nubus_dev {
242 /* Next link in device list */
243 struct nubus_dev* next;
244 /* Directory entry in /proc/bus/nubus */
245 struct proc_dir_entry* procdir;
246
247 /* The functional resource ID of this device */
248 unsigned char resid;
249 /* These are mostly here for convenience; we could always read
250 them from the ROMs if we wanted to */
251 unsigned short category;
252 unsigned short type;
253 unsigned short dr_sw;
254 unsigned short dr_hw;
255 /* This is the device's name rather than the board's.
256 Sometimes they are different. Usually the board name is
257 more correct. */
258 char name[64];
259 /* MacOS driver (I kid you not) */
260 unsigned char* driver;
261 /* Actually this is an offset */
262 unsigned long iobase;
263 unsigned long iosize;
264 unsigned char flags, hwdevid;
265
266 /* Functional directory */
267 unsigned char* directory;
268 /* Much of our info comes from here */
269 struct nubus_board* board;
270};
271
272/* This is all NuBus devices (used to find devices later on) */
273extern struct nubus_dev* nubus_devices;
274/* This is all NuBus cards */
275extern struct nubus_board* nubus_boards;
276
277/* Generic NuBus interface functions, modelled after the PCI interface */
278void nubus_scan_bus(void);
279extern void nubus_proc_init(void);
280int get_nubus_list(char *buf);
281int nubus_proc_attach_device(struct nubus_dev *dev);
282int nubus_proc_detach_device(struct nubus_dev *dev);
283/* If we need more precision we can add some more of these */
284struct nubus_dev* nubus_find_device(unsigned short category,
285 unsigned short type,
286 unsigned short dr_hw,
287 unsigned short dr_sw,
288 const struct nubus_dev* from);
289struct nubus_dev* nubus_find_type(unsigned short category,
290 unsigned short type,
291 const struct nubus_dev* from);
292/* Might have more than one device in a slot, you know... */
293struct nubus_dev* nubus_find_slot(unsigned int slot,
294 const struct nubus_dev* from);
295
296/* These are somewhat more NuBus-specific. They all return 0 for
297 success and -1 for failure, as you'd expect. */
298
299/* The root directory which contains the board and functional
300 directories */
301int nubus_get_root_dir(const struct nubus_board* board,
302 struct nubus_dir* dir);
303/* The board directory */
304int nubus_get_board_dir(const struct nubus_board* board,
305 struct nubus_dir* dir);
306/* The functional directory */
307int nubus_get_func_dir(const struct nubus_dev* dev,
308 struct nubus_dir* dir);
309
310/* These work on any directory gotten via the above */
311int nubus_readdir(struct nubus_dir* dir,
312 struct nubus_dirent* ent);
313int nubus_find_rsrc(struct nubus_dir* dir,
314 unsigned char rsrc_type,
315 struct nubus_dirent* ent);
316int nubus_rewinddir(struct nubus_dir* dir);
317
318/* Things to do with directory entries */
319int nubus_get_subdir(const struct nubus_dirent* ent,
320 struct nubus_dir* dir);
321void nubus_get_rsrc_mem(void* dest,
322 const struct nubus_dirent *dirent,
323 int len);
324void nubus_get_rsrc_str(void* dest,
325 const struct nubus_dirent *dirent,
326 int maxlen);
327
328/* We'd like to get rid of this eventually. Only daynaport.c uses it now. */
329static inline void *nubus_slot_addr(int slot)
330{
331 return (void *)(0xF0000000|(slot<<24));
332}
333
334#endif /* LINUX_NUBUS_H */
diff --git a/include/linux/numa.h b/include/linux/numa.h
new file mode 100644
index 000000000000..bd0c8c4e9a95
--- /dev/null
+++ b/include/linux/numa.h
@@ -0,0 +1,16 @@
1#ifndef _LINUX_NUMA_H
2#define _LINUX_NUMA_H
3
4#include <linux/config.h>
5
6#ifdef CONFIG_DISCONTIGMEM
7#include <asm/numnodes.h>
8#endif
9
10#ifndef NODES_SHIFT
11#define NODES_SHIFT 0
12#endif
13
14#define MAX_NUMNODES (1 << NODES_SHIFT)
15
16#endif /* _LINUX_NUMA_H */
diff --git a/include/linux/nvram.h b/include/linux/nvram.h
new file mode 100644
index 000000000000..b031e41b5e0d
--- /dev/null
+++ b/include/linux/nvram.h
@@ -0,0 +1,27 @@
1#ifndef _LINUX_NVRAM_H
2#define _LINUX_NVRAM_H
3
4#include <linux/ioctl.h>
5
6/* /dev/nvram ioctls */
7#define NVRAM_INIT _IO('p', 0x40) /* initialize NVRAM and set checksum */
8#define NVRAM_SETCKS _IO('p', 0x41) /* recalculate checksum */
9
10/* for all current systems, this is where NVRAM starts */
11#define NVRAM_FIRST_BYTE 14
12/* all these functions expect an NVRAM offset, not an absolute */
13#define NVRAM_OFFSET(x) ((x)-NVRAM_FIRST_BYTE)
14
15#ifdef __KERNEL__
16/* __foo is foo without grabbing the rtc_lock - get it yourself */
17extern unsigned char __nvram_read_byte(int i);
18extern unsigned char nvram_read_byte(int i);
19extern void __nvram_write_byte(unsigned char c, int i);
20extern void nvram_write_byte(unsigned char c, int i);
21extern int __nvram_check_checksum(void);
22extern int nvram_check_checksum(void);
23extern void __nvram_set_checksum(void);
24extern void nvram_set_checksum(void);
25#endif
26
27#endif /* _LINUX_NVRAM_H */
diff --git a/include/linux/openprom_fs.h b/include/linux/openprom_fs.h
new file mode 100644
index 000000000000..a837aab8217e
--- /dev/null
+++ b/include/linux/openprom_fs.h
@@ -0,0 +1,10 @@
1#ifndef _LINUX_OPENPROM_FS_H
2#define _LINUX_OPENPROM_FS_H
3
4/*
5 * The openprom filesystem constants/structures
6 */
7
8#define OPENPROM_SUPER_MAGIC 0x9fa1
9
10#endif /* _LINUX_OPENPROM_FS_H */
diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
new file mode 100644
index 000000000000..559c4c38a9c7
--- /dev/null
+++ b/include/linux/oprofile.h
@@ -0,0 +1,119 @@
1/**
2 * @file oprofile.h
3 *
4 * API for machine-specific interrupts to interface
5 * to oprofile.
6 *
7 * @remark Copyright 2002 OProfile authors
8 * @remark Read the file COPYING
9 *
10 * @author John Levon <levon@movementarian.org>
11 */
12
13#ifndef OPROFILE_H
14#define OPROFILE_H
15
16#include <linux/types.h>
17#include <linux/spinlock.h>
18#include <asm/atomic.h>
19
20struct super_block;
21struct dentry;
22struct file_operations;
23struct pt_regs;
24
25/* Operations structure to be filled in */
26struct oprofile_operations {
27 /* create any necessary configuration files in the oprofile fs.
28 * Optional. */
29 int (*create_files)(struct super_block * sb, struct dentry * root);
30 /* Do any necessary interrupt setup. Optional. */
31 int (*setup)(void);
32 /* Do any necessary interrupt shutdown. Optional. */
33 void (*shutdown)(void);
34 /* Start delivering interrupts. */
35 int (*start)(void);
36 /* Stop delivering interrupts. */
37 void (*stop)(void);
38 /* Initiate a stack backtrace. Optional. */
39 void (*backtrace)(struct pt_regs * const regs, unsigned int depth);
40 /* CPU identification string. */
41 char * cpu_type;
42};
43
44/**
45 * One-time initialisation. *ops must be set to a filled-in
46 * operations structure. This is called even in timer interrupt
47 * mode so an arch can set a backtrace callback.
48 *
49 * If an error occurs, the fields should be left untouched.
50 */
51int oprofile_arch_init(struct oprofile_operations * ops);
52
53/**
54 * One-time exit/cleanup for the arch.
55 */
56void oprofile_arch_exit(void);
57
58/**
59 * Add a sample. This may be called from any context. Pass
60 * smp_processor_id() as cpu.
61 */
62void oprofile_add_sample(struct pt_regs * const regs, unsigned long event);
63
64/* Use this instead when the PC value is not from the regs. Doesn't
65 * backtrace. */
66void oprofile_add_pc(unsigned long pc, int is_kernel, unsigned long event);
67
68/* add a backtrace entry, to be called from the ->backtrace callback */
69void oprofile_add_trace(unsigned long eip);
70
71
72/**
73 * Create a file of the given name as a child of the given root, with
74 * the specified file operations.
75 */
76int oprofilefs_create_file(struct super_block * sb, struct dentry * root,
77 char const * name, struct file_operations * fops);
78
79int oprofilefs_create_file_perm(struct super_block * sb, struct dentry * root,
80 char const * name, struct file_operations * fops, int perm);
81
82/** Create a file for read/write access to an unsigned long. */
83int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
84 char const * name, ulong * val);
85
86/** Create a file for read-only access to an unsigned long. */
87int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
88 char const * name, ulong * val);
89
90/** Create a file for read-only access to an atomic_t. */
91int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
92 char const * name, atomic_t * val);
93
94/** create a directory */
95struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
96 char const * name);
97
98/**
99 * Write the given asciz string to the given user buffer @buf, updating *offset
100 * appropriately. Returns bytes written or -EFAULT.
101 */
102ssize_t oprofilefs_str_to_user(char const * str, char __user * buf, size_t count, loff_t * offset);
103
104/**
105 * Convert an unsigned long value into ASCII and copy it to the user buffer @buf,
106 * updating *offset appropriately. Returns bytes written or -EFAULT.
107 */
108ssize_t oprofilefs_ulong_to_user(unsigned long val, char __user * buf, size_t count, loff_t * offset);
109
110/**
111 * Read an ASCII string for a number from a userspace buffer and fill *val on success.
112 * Returns 0 on success, < 0 on error.
113 */
114int oprofilefs_ulong_from_user(unsigned long * val, char const __user * buf, size_t count);
115
116/** lock for read/write safety */
117extern spinlock_t oprofilefs_lock;
118
119#endif /* OPROFILE_H */
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
new file mode 100644
index 000000000000..6b74fcf5bb63
--- /dev/null
+++ b/include/linux/page-flags.h
@@ -0,0 +1,324 @@
1/*
2 * Macros for manipulating and testing page->flags
3 */
4
5#ifndef PAGE_FLAGS_H
6#define PAGE_FLAGS_H
7
8#include <linux/percpu.h>
9#include <linux/cache.h>
10#include <asm/pgtable.h>
11
12/*
13 * Various page->flags bits:
14 *
15 * PG_reserved is set for special pages, which can never be swapped out. Some
16 * of them might not even exist (eg empty_bad_page)...
17 *
18 * The PG_private bitflag is set if page->private contains a valid value.
19 *
20 * During disk I/O, PG_locked is used. This bit is set before I/O and
21 * reset when I/O completes. page_waitqueue(page) is a wait queue of all tasks
22 * waiting for the I/O on this page to complete.
23 *
24 * PG_uptodate tells whether the page's contents is valid. When a read
25 * completes, the page becomes uptodate, unless a disk I/O error happened.
26 *
27 * For choosing which pages to swap out, inode pages carry a PG_referenced bit,
28 * which is set any time the system accesses that page through the (mapping,
29 * index) hash table. This referenced bit, together with the referenced bit
30 * in the page tables, is used to manipulate page->age and move the page across
31 * the active, inactive_dirty and inactive_clean lists.
32 *
33 * Note that the referenced bit, the page->lru list_head and the active,
34 * inactive_dirty and inactive_clean lists are protected by the
35 * zone->lru_lock, and *NOT* by the usual PG_locked bit!
36 *
37 * PG_error is set to indicate that an I/O error occurred on this page.
38 *
39 * PG_arch_1 is an architecture specific page state bit. The generic code
40 * guarantees that this bit is cleared for a page when it first is entered into
41 * the page cache.
42 *
43 * PG_highmem pages are not permanently mapped into the kernel virtual address
44 * space, they need to be kmapped separately for doing IO on the pages. The
45 * struct page (these bits with information) are always mapped into kernel
46 * address space...
47 */
48
49/*
50 * Don't use the *_dontuse flags. Use the macros. Otherwise you'll break
51 * locked- and dirty-page accounting. The top eight bits of page->flags are
52 * used for page->zone, so putting flag bits there doesn't work.
53 */
54#define PG_locked 0 /* Page is locked. Don't touch. */
55#define PG_error 1
56#define PG_referenced 2
57#define PG_uptodate 3
58
59#define PG_dirty 4
60#define PG_lru 5
61#define PG_active 6
62#define PG_slab 7 /* slab debug (Suparna wants this) */
63
64#define PG_highmem 8
65#define PG_checked 9 /* kill me in 2.5.<early>. */
66#define PG_arch_1 10
67#define PG_reserved 11
68
69#define PG_private 12 /* Has something at ->private */
70#define PG_writeback 13 /* Page is under writeback */
71#define PG_nosave 14 /* Used for system suspend/resume */
72#define PG_compound 15 /* Part of a compound page */
73
74#define PG_swapcache 16 /* Swap page: swp_entry_t in private */
75#define PG_mappedtodisk 17 /* Has blocks allocated on-disk */
76#define PG_reclaim 18 /* To be reclaimed asap */
77#define PG_nosave_free 19 /* Free, should not be written */
78#define PG_uncached 20 /* Page has been mapped as uncached */
79
80/*
81 * Global page accounting. One instance per CPU. Only unsigned longs are
82 * allowed.
83 */
84struct page_state {
85 unsigned long nr_dirty; /* Dirty writeable pages */
86 unsigned long nr_writeback; /* Pages under writeback */
87 unsigned long nr_unstable; /* NFS unstable pages */
88 unsigned long nr_page_table_pages;/* Pages used for pagetables */
89 unsigned long nr_mapped; /* mapped into pagetables */
90 unsigned long nr_slab; /* In slab */
91#define GET_PAGE_STATE_LAST nr_slab
92
93 /*
94 * The below are zeroed by get_page_state(). Use get_full_page_state()
95 * to add up all these.
96 */
97 unsigned long pgpgin; /* Disk reads */
98 unsigned long pgpgout; /* Disk writes */
99 unsigned long pswpin; /* swap reads */
100 unsigned long pswpout; /* swap writes */
101 unsigned long pgalloc_high; /* page allocations */
102
103 unsigned long pgalloc_normal;
104 unsigned long pgalloc_dma;
105 unsigned long pgfree; /* page freeings */
106 unsigned long pgactivate; /* pages moved inactive->active */
107 unsigned long pgdeactivate; /* pages moved active->inactive */
108
109 unsigned long pgfault; /* faults (major+minor) */
110 unsigned long pgmajfault; /* faults (major only) */
111 unsigned long pgrefill_high; /* inspected in refill_inactive_zone */
112 unsigned long pgrefill_normal;
113 unsigned long pgrefill_dma;
114
115 unsigned long pgsteal_high; /* total highmem pages reclaimed */
116 unsigned long pgsteal_normal;
117 unsigned long pgsteal_dma;
118 unsigned long pgscan_kswapd_high;/* total highmem pages scanned */
119 unsigned long pgscan_kswapd_normal;
120
121 unsigned long pgscan_kswapd_dma;
122 unsigned long pgscan_direct_high;/* total highmem pages scanned */
123 unsigned long pgscan_direct_normal;
124 unsigned long pgscan_direct_dma;
125 unsigned long pginodesteal; /* pages reclaimed via inode freeing */
126
127 unsigned long slabs_scanned; /* slab objects scanned */
128 unsigned long kswapd_steal; /* pages reclaimed by kswapd */
129 unsigned long kswapd_inodesteal;/* reclaimed via kswapd inode freeing */
130 unsigned long pageoutrun; /* kswapd's calls to page reclaim */
131 unsigned long allocstall; /* direct reclaim calls */
132
133 unsigned long pgrotated; /* pages rotated to tail of the LRU */
134};
135
136extern void get_page_state(struct page_state *ret);
137extern void get_full_page_state(struct page_state *ret);
138extern unsigned long __read_page_state(unsigned offset);
139extern void __mod_page_state(unsigned offset, unsigned long delta);
140
141#define read_page_state(member) \
142 __read_page_state(offsetof(struct page_state, member))
143
144#define mod_page_state(member, delta) \
145 __mod_page_state(offsetof(struct page_state, member), (delta))
146
147#define inc_page_state(member) mod_page_state(member, 1UL)
148#define dec_page_state(member) mod_page_state(member, 0UL - 1)
149#define add_page_state(member,delta) mod_page_state(member, (delta))
150#define sub_page_state(member,delta) mod_page_state(member, 0UL - (delta))
151
152#define mod_page_state_zone(zone, member, delta) \
153 do { \
154 unsigned offset; \
155 if (is_highmem(zone)) \
156 offset = offsetof(struct page_state, member##_high); \
157 else if (is_normal(zone)) \
158 offset = offsetof(struct page_state, member##_normal); \
159 else \
160 offset = offsetof(struct page_state, member##_dma); \
161 __mod_page_state(offset, (delta)); \
162 } while (0)
163
164/*
165 * Manipulation of page state flags
166 */
167#define PageLocked(page) \
168 test_bit(PG_locked, &(page)->flags)
169#define SetPageLocked(page) \
170 set_bit(PG_locked, &(page)->flags)
171#define TestSetPageLocked(page) \
172 test_and_set_bit(PG_locked, &(page)->flags)
173#define ClearPageLocked(page) \
174 clear_bit(PG_locked, &(page)->flags)
175#define TestClearPageLocked(page) \
176 test_and_clear_bit(PG_locked, &(page)->flags)
177
178#define PageError(page) test_bit(PG_error, &(page)->flags)
179#define SetPageError(page) set_bit(PG_error, &(page)->flags)
180#define ClearPageError(page) clear_bit(PG_error, &(page)->flags)
181
182#define PageReferenced(page) test_bit(PG_referenced, &(page)->flags)
183#define SetPageReferenced(page) set_bit(PG_referenced, &(page)->flags)
184#define ClearPageReferenced(page) clear_bit(PG_referenced, &(page)->flags)
185#define TestClearPageReferenced(page) test_and_clear_bit(PG_referenced, &(page)->flags)
186
187#define PageUptodate(page) test_bit(PG_uptodate, &(page)->flags)
188#ifndef SetPageUptodate
189#define SetPageUptodate(page) set_bit(PG_uptodate, &(page)->flags)
190#endif
191#define ClearPageUptodate(page) clear_bit(PG_uptodate, &(page)->flags)
192
193#define PageDirty(page) test_bit(PG_dirty, &(page)->flags)
194#define SetPageDirty(page) set_bit(PG_dirty, &(page)->flags)
195#define TestSetPageDirty(page) test_and_set_bit(PG_dirty, &(page)->flags)
196#define ClearPageDirty(page) clear_bit(PG_dirty, &(page)->flags)
197#define TestClearPageDirty(page) test_and_clear_bit(PG_dirty, &(page)->flags)
198
199#define SetPageLRU(page) set_bit(PG_lru, &(page)->flags)
200#define PageLRU(page) test_bit(PG_lru, &(page)->flags)
201#define TestSetPageLRU(page) test_and_set_bit(PG_lru, &(page)->flags)
202#define TestClearPageLRU(page) test_and_clear_bit(PG_lru, &(page)->flags)
203
204#define PageActive(page) test_bit(PG_active, &(page)->flags)
205#define SetPageActive(page) set_bit(PG_active, &(page)->flags)
206#define ClearPageActive(page) clear_bit(PG_active, &(page)->flags)
207#define TestClearPageActive(page) test_and_clear_bit(PG_active, &(page)->flags)
208#define TestSetPageActive(page) test_and_set_bit(PG_active, &(page)->flags)
209
210#define PageSlab(page) test_bit(PG_slab, &(page)->flags)
211#define SetPageSlab(page) set_bit(PG_slab, &(page)->flags)
212#define ClearPageSlab(page) clear_bit(PG_slab, &(page)->flags)
213#define TestClearPageSlab(page) test_and_clear_bit(PG_slab, &(page)->flags)
214#define TestSetPageSlab(page) test_and_set_bit(PG_slab, &(page)->flags)
215
216#ifdef CONFIG_HIGHMEM
217#define PageHighMem(page) test_bit(PG_highmem, &(page)->flags)
218#else
219#define PageHighMem(page) 0 /* needed to optimize away at compile time */
220#endif
221
222#define PageChecked(page) test_bit(PG_checked, &(page)->flags)
223#define SetPageChecked(page) set_bit(PG_checked, &(page)->flags)
224#define ClearPageChecked(page) clear_bit(PG_checked, &(page)->flags)
225
226#define PageReserved(page) test_bit(PG_reserved, &(page)->flags)
227#define SetPageReserved(page) set_bit(PG_reserved, &(page)->flags)
228#define ClearPageReserved(page) clear_bit(PG_reserved, &(page)->flags)
229#define __ClearPageReserved(page) __clear_bit(PG_reserved, &(page)->flags)
230
231#define SetPagePrivate(page) set_bit(PG_private, &(page)->flags)
232#define ClearPagePrivate(page) clear_bit(PG_private, &(page)->flags)
233#define PagePrivate(page) test_bit(PG_private, &(page)->flags)
234#define __SetPagePrivate(page) __set_bit(PG_private, &(page)->flags)
235#define __ClearPagePrivate(page) __clear_bit(PG_private, &(page)->flags)
236
237#define PageWriteback(page) test_bit(PG_writeback, &(page)->flags)
238#define SetPageWriteback(page) \
239 do { \
240 if (!test_and_set_bit(PG_writeback, \
241 &(page)->flags)) \
242 inc_page_state(nr_writeback); \
243 } while (0)
244#define TestSetPageWriteback(page) \
245 ({ \
246 int ret; \
247 ret = test_and_set_bit(PG_writeback, \
248 &(page)->flags); \
249 if (!ret) \
250 inc_page_state(nr_writeback); \
251 ret; \
252 })
253#define ClearPageWriteback(page) \
254 do { \
255 if (test_and_clear_bit(PG_writeback, \
256 &(page)->flags)) \
257 dec_page_state(nr_writeback); \
258 } while (0)
259#define TestClearPageWriteback(page) \
260 ({ \
261 int ret; \
262 ret = test_and_clear_bit(PG_writeback, \
263 &(page)->flags); \
264 if (ret) \
265 dec_page_state(nr_writeback); \
266 ret; \
267 })
268
269#define PageNosave(page) test_bit(PG_nosave, &(page)->flags)
270#define SetPageNosave(page) set_bit(PG_nosave, &(page)->flags)
271#define TestSetPageNosave(page) test_and_set_bit(PG_nosave, &(page)->flags)
272#define ClearPageNosave(page) clear_bit(PG_nosave, &(page)->flags)
273#define TestClearPageNosave(page) test_and_clear_bit(PG_nosave, &(page)->flags)
274
275#define PageNosaveFree(page) test_bit(PG_nosave_free, &(page)->flags)
276#define SetPageNosaveFree(page) set_bit(PG_nosave_free, &(page)->flags)
277#define ClearPageNosaveFree(page) clear_bit(PG_nosave_free, &(page)->flags)
278
279#define PageMappedToDisk(page) test_bit(PG_mappedtodisk, &(page)->flags)
280#define SetPageMappedToDisk(page) set_bit(PG_mappedtodisk, &(page)->flags)
281#define ClearPageMappedToDisk(page) clear_bit(PG_mappedtodisk, &(page)->flags)
282
283#define PageReclaim(page) test_bit(PG_reclaim, &(page)->flags)
284#define SetPageReclaim(page) set_bit(PG_reclaim, &(page)->flags)
285#define ClearPageReclaim(page) clear_bit(PG_reclaim, &(page)->flags)
286#define TestClearPageReclaim(page) test_and_clear_bit(PG_reclaim, &(page)->flags)
287
288#ifdef CONFIG_HUGETLB_PAGE
289#define PageCompound(page) test_bit(PG_compound, &(page)->flags)
290#else
291#define PageCompound(page) 0
292#endif
293#define SetPageCompound(page) set_bit(PG_compound, &(page)->flags)
294#define ClearPageCompound(page) clear_bit(PG_compound, &(page)->flags)
295
296#ifdef CONFIG_SWAP
297#define PageSwapCache(page) test_bit(PG_swapcache, &(page)->flags)
298#define SetPageSwapCache(page) set_bit(PG_swapcache, &(page)->flags)
299#define ClearPageSwapCache(page) clear_bit(PG_swapcache, &(page)->flags)
300#else
301#define PageSwapCache(page) 0
302#endif
303
304#define PageUncached(page) test_bit(PG_uncached, &(page)->flags)
305#define SetPageUncached(page) set_bit(PG_uncached, &(page)->flags)
306#define ClearPageUncached(page) clear_bit(PG_uncached, &(page)->flags)
307
308struct page; /* forward declaration */
309
310int test_clear_page_dirty(struct page *page);
311int test_clear_page_writeback(struct page *page);
312int test_set_page_writeback(struct page *page);
313
314static inline void clear_page_dirty(struct page *page)
315{
316 test_clear_page_dirty(page);
317}
318
319static inline void set_page_writeback(struct page *page)
320{
321 test_set_page_writeback(page);
322}
323
324#endif /* PAGE_FLAGS_H */
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
new file mode 100644
index 000000000000..0422031161ba
--- /dev/null
+++ b/include/linux/pagemap.h
@@ -0,0 +1,246 @@
1#ifndef _LINUX_PAGEMAP_H
2#define _LINUX_PAGEMAP_H
3
4/*
5 * Copyright 1995 Linus Torvalds
6 */
7#include <linux/mm.h>
8#include <linux/fs.h>
9#include <linux/list.h>
10#include <linux/highmem.h>
11#include <linux/compiler.h>
12#include <asm/uaccess.h>
13#include <linux/gfp.h>
14
15/*
16 * Bits in mapping->flags. The lower __GFP_BITS_SHIFT bits are the page
17 * allocation mode flags.
18 */
19#define AS_EIO (__GFP_BITS_SHIFT + 0) /* IO error on async write */
20#define AS_ENOSPC (__GFP_BITS_SHIFT + 1) /* ENOSPC on async write */
21
22static inline unsigned int __nocast mapping_gfp_mask(struct address_space * mapping)
23{
24 return mapping->flags & __GFP_BITS_MASK;
25}
26
27/*
28 * This is non-atomic. Only to be used before the mapping is activated.
29 * Probably needs a barrier...
30 */
31static inline void mapping_set_gfp_mask(struct address_space *m, int mask)
32{
33 m->flags = (m->flags & ~__GFP_BITS_MASK) | mask;
34}
35
36/*
37 * The page cache can done in larger chunks than
38 * one page, because it allows for more efficient
39 * throughput (it can then be mapped into user
40 * space in smaller chunks for same flexibility).
41 *
42 * Or rather, it _will_ be done in larger chunks.
43 */
44#define PAGE_CACHE_SHIFT PAGE_SHIFT
45#define PAGE_CACHE_SIZE PAGE_SIZE
46#define PAGE_CACHE_MASK PAGE_MASK
47#define PAGE_CACHE_ALIGN(addr) (((addr)+PAGE_CACHE_SIZE-1)&PAGE_CACHE_MASK)
48
49#define page_cache_get(page) get_page(page)
50#define page_cache_release(page) put_page(page)
51void release_pages(struct page **pages, int nr, int cold);
52
53static inline struct page *page_cache_alloc(struct address_space *x)
54{
55 return alloc_pages(mapping_gfp_mask(x), 0);
56}
57
58static inline struct page *page_cache_alloc_cold(struct address_space *x)
59{
60 return alloc_pages(mapping_gfp_mask(x)|__GFP_COLD, 0);
61}
62
63typedef int filler_t(void *, struct page *);
64
65extern struct page * find_get_page(struct address_space *mapping,
66 unsigned long index);
67extern struct page * find_lock_page(struct address_space *mapping,
68 unsigned long index);
69extern struct page * find_trylock_page(struct address_space *mapping,
70 unsigned long index);
71extern struct page * find_or_create_page(struct address_space *mapping,
72 unsigned long index, unsigned int gfp_mask);
73unsigned find_get_pages(struct address_space *mapping, pgoff_t start,
74 unsigned int nr_pages, struct page **pages);
75unsigned find_get_pages_tag(struct address_space *mapping, pgoff_t *index,
76 int tag, unsigned int nr_pages, struct page **pages);
77
78/*
79 * Returns locked page at given index in given cache, creating it if needed.
80 */
81static inline struct page *grab_cache_page(struct address_space *mapping, unsigned long index)
82{
83 return find_or_create_page(mapping, index, mapping_gfp_mask(mapping));
84}
85
86extern struct page * grab_cache_page_nowait(struct address_space *mapping,
87 unsigned long index);
88extern struct page * read_cache_page(struct address_space *mapping,
89 unsigned long index, filler_t *filler,
90 void *data);
91extern int read_cache_pages(struct address_space *mapping,
92 struct list_head *pages, filler_t *filler, void *data);
93
94int add_to_page_cache(struct page *page, struct address_space *mapping,
95 unsigned long index, int gfp_mask);
96int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
97 unsigned long index, int gfp_mask);
98extern void remove_from_page_cache(struct page *page);
99extern void __remove_from_page_cache(struct page *page);
100
101extern atomic_t nr_pagecache;
102
103#ifdef CONFIG_SMP
104
105#define PAGECACHE_ACCT_THRESHOLD max(16, NR_CPUS * 2)
106DECLARE_PER_CPU(long, nr_pagecache_local);
107
108/*
109 * pagecache_acct implements approximate accounting for pagecache.
110 * vm_enough_memory() do not need high accuracy. Writers will keep
111 * an offset in their per-cpu arena and will spill that into the
112 * global count whenever the absolute value of the local count
113 * exceeds the counter's threshold.
114 *
115 * MUST be protected from preemption.
116 * current protection is mapping->page_lock.
117 */
118static inline void pagecache_acct(int count)
119{
120 long *local;
121
122 local = &__get_cpu_var(nr_pagecache_local);
123 *local += count;
124 if (*local > PAGECACHE_ACCT_THRESHOLD || *local < -PAGECACHE_ACCT_THRESHOLD) {
125 atomic_add(*local, &nr_pagecache);
126 *local = 0;
127 }
128}
129
130#else
131
132static inline void pagecache_acct(int count)
133{
134 atomic_add(count, &nr_pagecache);
135}
136#endif
137
138static inline unsigned long get_page_cache_size(void)
139{
140 int ret = atomic_read(&nr_pagecache);
141 if (unlikely(ret < 0))
142 ret = 0;
143 return ret;
144}
145
146/*
147 * Return byte-offset into filesystem object for page.
148 */
149static inline loff_t page_offset(struct page *page)
150{
151 return ((loff_t)page->index) << PAGE_CACHE_SHIFT;
152}
153
154static inline pgoff_t linear_page_index(struct vm_area_struct *vma,
155 unsigned long address)
156{
157 pgoff_t pgoff = (address - vma->vm_start) >> PAGE_SHIFT;
158 pgoff += vma->vm_pgoff;
159 return pgoff >> (PAGE_CACHE_SHIFT - PAGE_SHIFT);
160}
161
162extern void FASTCALL(__lock_page(struct page *page));
163extern void FASTCALL(unlock_page(struct page *page));
164
165static inline void lock_page(struct page *page)
166{
167 might_sleep();
168 if (TestSetPageLocked(page))
169 __lock_page(page);
170}
171
172/*
173 * This is exported only for wait_on_page_locked/wait_on_page_writeback.
174 * Never use this directly!
175 */
176extern void FASTCALL(wait_on_page_bit(struct page *page, int bit_nr));
177
178/*
179 * Wait for a page to be unlocked.
180 *
181 * This must be called with the caller "holding" the page,
182 * ie with increased "page->count" so that the page won't
183 * go away during the wait..
184 */
185static inline void wait_on_page_locked(struct page *page)
186{
187 if (PageLocked(page))
188 wait_on_page_bit(page, PG_locked);
189}
190
191/*
192 * Wait for a page to complete writeback
193 */
194static inline void wait_on_page_writeback(struct page *page)
195{
196 if (PageWriteback(page))
197 wait_on_page_bit(page, PG_writeback);
198}
199
200extern void end_page_writeback(struct page *page);
201
202/*
203 * Fault a userspace page into pagetables. Return non-zero on a fault.
204 *
205 * This assumes that two userspace pages are always sufficient. That's
206 * not true if PAGE_CACHE_SIZE > PAGE_SIZE.
207 */
208static inline int fault_in_pages_writeable(char __user *uaddr, int size)
209{
210 int ret;
211
212 /*
213 * Writing zeroes into userspace here is OK, because we know that if
214 * the zero gets there, we'll be overwriting it.
215 */
216 ret = __put_user(0, uaddr);
217 if (ret == 0) {
218 char __user *end = uaddr + size - 1;
219
220 /*
221 * If the page was already mapped, this will get a cache miss
222 * for sure, so try to avoid doing it.
223 */
224 if (((unsigned long)uaddr & PAGE_MASK) !=
225 ((unsigned long)end & PAGE_MASK))
226 ret = __put_user(0, end);
227 }
228 return ret;
229}
230
231static inline void fault_in_pages_readable(const char __user *uaddr, int size)
232{
233 volatile char c;
234 int ret;
235
236 ret = __get_user(c, uaddr);
237 if (ret == 0) {
238 const char __user *end = uaddr + size - 1;
239
240 if (((unsigned long)uaddr & PAGE_MASK) !=
241 ((unsigned long)end & PAGE_MASK))
242 __get_user(c, end);
243 }
244}
245
246#endif /* _LINUX_PAGEMAP_H */
diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h
new file mode 100644
index 000000000000..def32c5715be
--- /dev/null
+++ b/include/linux/pagevec.h
@@ -0,0 +1,85 @@
1/*
2 * include/linux/pagevec.h
3 *
4 * In many places it is efficient to batch an operation up against multiple
5 * pages. A pagevec is a multipage container which is used for that.
6 */
7
8/* 14 pointers + two long's align the pagevec structure to a power of two */
9#define PAGEVEC_SIZE 14
10
11struct page;
12struct address_space;
13
14struct pagevec {
15 unsigned long nr;
16 unsigned long cold;
17 struct page *pages[PAGEVEC_SIZE];
18};
19
20void __pagevec_release(struct pagevec *pvec);
21void __pagevec_release_nonlru(struct pagevec *pvec);
22void __pagevec_free(struct pagevec *pvec);
23void __pagevec_lru_add(struct pagevec *pvec);
24void __pagevec_lru_add_active(struct pagevec *pvec);
25void pagevec_strip(struct pagevec *pvec);
26unsigned pagevec_lookup(struct pagevec *pvec, struct address_space *mapping,
27 pgoff_t start, unsigned nr_pages);
28unsigned pagevec_lookup_tag(struct pagevec *pvec,
29 struct address_space *mapping, pgoff_t *index, int tag,
30 unsigned nr_pages);
31
32static inline void pagevec_init(struct pagevec *pvec, int cold)
33{
34 pvec->nr = 0;
35 pvec->cold = cold;
36}
37
38static inline void pagevec_reinit(struct pagevec *pvec)
39{
40 pvec->nr = 0;
41}
42
43static inline unsigned pagevec_count(struct pagevec *pvec)
44{
45 return pvec->nr;
46}
47
48static inline unsigned pagevec_space(struct pagevec *pvec)
49{
50 return PAGEVEC_SIZE - pvec->nr;
51}
52
53/*
54 * Add a page to a pagevec. Returns the number of slots still available.
55 */
56static inline unsigned pagevec_add(struct pagevec *pvec, struct page *page)
57{
58 pvec->pages[pvec->nr++] = page;
59 return pagevec_space(pvec);
60}
61
62
63static inline void pagevec_release(struct pagevec *pvec)
64{
65 if (pagevec_count(pvec))
66 __pagevec_release(pvec);
67}
68
69static inline void pagevec_release_nonlru(struct pagevec *pvec)
70{
71 if (pagevec_count(pvec))
72 __pagevec_release_nonlru(pvec);
73}
74
75static inline void pagevec_free(struct pagevec *pvec)
76{
77 if (pagevec_count(pvec))
78 __pagevec_free(pvec);
79}
80
81static inline void pagevec_lru_add(struct pagevec *pvec)
82{
83 if (pagevec_count(pvec))
84 __pagevec_lru_add(pvec);
85}
diff --git a/include/linux/param.h b/include/linux/param.h
new file mode 100644
index 000000000000..092e92f67b50
--- /dev/null
+++ b/include/linux/param.h
@@ -0,0 +1,6 @@
1#ifndef _LINUX_PARAM_H
2#define _LINUX_PARAM_H
3
4#include <asm/param.h>
5
6#endif
diff --git a/include/linux/parport.h b/include/linux/parport.h
new file mode 100644
index 000000000000..d2a4d9e1e6d1
--- /dev/null
+++ b/include/linux/parport.h
@@ -0,0 +1,552 @@
1/* $Id: parport.h,v 1.1 1998/05/17 10:57:52 andrea Exp andrea $ */
2
3/*
4 * Any part of this program may be used in documents licensed under
5 * the GNU Free Documentation License, Version 1.1 or any later version
6 * published by the Free Software Foundation.
7 */
8
9#ifndef _PARPORT_H_
10#define _PARPORT_H_
11
12/* Start off with user-visible constants */
13
14/* Maximum of 16 ports per machine */
15#define PARPORT_MAX 16
16
17/* Magic numbers */
18#define PARPORT_IRQ_NONE -1
19#define PARPORT_DMA_NONE -1
20#define PARPORT_IRQ_AUTO -2
21#define PARPORT_DMA_AUTO -2
22#define PARPORT_DMA_NOFIFO -3
23#define PARPORT_DISABLE -2
24#define PARPORT_IRQ_PROBEONLY -3
25#define PARPORT_IOHI_AUTO -1
26
27#define PARPORT_CONTROL_STROBE 0x1
28#define PARPORT_CONTROL_AUTOFD 0x2
29#define PARPORT_CONTROL_INIT 0x4
30#define PARPORT_CONTROL_SELECT 0x8
31
32#define PARPORT_STATUS_ERROR 0x8
33#define PARPORT_STATUS_SELECT 0x10
34#define PARPORT_STATUS_PAPEROUT 0x20
35#define PARPORT_STATUS_ACK 0x40
36#define PARPORT_STATUS_BUSY 0x80
37
38/* Type classes for Plug-and-Play probe. */
39typedef enum {
40 PARPORT_CLASS_LEGACY = 0, /* Non-IEEE1284 device */
41 PARPORT_CLASS_PRINTER,
42 PARPORT_CLASS_MODEM,
43 PARPORT_CLASS_NET,
44 PARPORT_CLASS_HDC, /* Hard disk controller */
45 PARPORT_CLASS_PCMCIA,
46 PARPORT_CLASS_MEDIA, /* Multimedia device */
47 PARPORT_CLASS_FDC, /* Floppy disk controller */
48 PARPORT_CLASS_PORTS,
49 PARPORT_CLASS_SCANNER,
50 PARPORT_CLASS_DIGCAM,
51 PARPORT_CLASS_OTHER, /* Anything else */
52 PARPORT_CLASS_UNSPEC, /* No CLS field in ID */
53 PARPORT_CLASS_SCSIADAPTER
54} parport_device_class;
55
56/* The "modes" entry in parport is a bit field representing the
57 capabilities of the hardware. */
58#define PARPORT_MODE_PCSPP (1<<0) /* IBM PC registers available. */
59#define PARPORT_MODE_TRISTATE (1<<1) /* Can tristate. */
60#define PARPORT_MODE_EPP (1<<2) /* Hardware EPP. */
61#define PARPORT_MODE_ECP (1<<3) /* Hardware ECP. */
62#define PARPORT_MODE_COMPAT (1<<4) /* Hardware 'printer protocol'. */
63#define PARPORT_MODE_DMA (1<<5) /* Hardware can DMA. */
64#define PARPORT_MODE_SAFEININT (1<<6) /* SPP registers accessible in IRQ. */
65
66/* IEEE1284 modes:
67 Nibble mode, byte mode, ECP, ECPRLE and EPP are their own
68 'extensibility request' values. Others are special.
69 'Real' ECP modes must have the IEEE1284_MODE_ECP bit set. */
70#define IEEE1284_MODE_NIBBLE 0
71#define IEEE1284_MODE_BYTE (1<<0)
72#define IEEE1284_MODE_COMPAT (1<<8)
73#define IEEE1284_MODE_BECP (1<<9) /* Bounded ECP mode */
74#define IEEE1284_MODE_ECP (1<<4)
75#define IEEE1284_MODE_ECPRLE (IEEE1284_MODE_ECP | (1<<5))
76#define IEEE1284_MODE_ECPSWE (1<<10) /* Software-emulated */
77#define IEEE1284_MODE_EPP (1<<6)
78#define IEEE1284_MODE_EPPSL (1<<11) /* EPP 1.7 */
79#define IEEE1284_MODE_EPPSWE (1<<12) /* Software-emulated */
80#define IEEE1284_DEVICEID (1<<2) /* This is a flag */
81#define IEEE1284_EXT_LINK (1<<14) /* This flag causes the
82 * extensibility link to
83 * be requested, using
84 * bits 0-6. */
85
86/* For the benefit of parport_read/write, you can use these with
87 * parport_negotiate to use address operations. They have no effect
88 * other than to make parport_read/write use address transfers. */
89#define IEEE1284_ADDR (1<<13) /* This is a flag */
90#define IEEE1284_DATA 0 /* So is this */
91
92/* Flags for block transfer operations. */
93#define PARPORT_EPP_FAST (1<<0) /* Unreliable counts. */
94#define PARPORT_W91284PIC (1<<1) /* have a Warp9 w91284pic in the device */
95
96/* The rest is for the kernel only */
97#ifdef __KERNEL__
98
99#include <linux/config.h>
100#include <linux/jiffies.h>
101#include <linux/proc_fs.h>
102#include <linux/spinlock.h>
103#include <linux/wait.h>
104#include <asm/system.h>
105#include <asm/ptrace.h>
106#include <asm/semaphore.h>
107
108/* Define this later. */
109struct parport;
110struct pardevice;
111
112struct pc_parport_state {
113 unsigned int ctr;
114 unsigned int ecr;
115};
116
117struct ax_parport_state {
118 unsigned int ctr;
119 unsigned int ecr;
120 unsigned int dcsr;
121};
122
123/* used by both parport_amiga and parport_mfc3 */
124struct amiga_parport_state {
125 unsigned char data; /* ciaa.prb */
126 unsigned char datadir; /* ciaa.ddrb */
127 unsigned char status; /* ciab.pra & 7 */
128 unsigned char statusdir;/* ciab.ddrb & 7 */
129};
130
131struct parport_state {
132 union {
133 struct pc_parport_state pc;
134 /* ARC has no state. */
135 struct ax_parport_state ax;
136 struct amiga_parport_state amiga;
137 /* Atari has not state. */
138 void *misc;
139 } u;
140};
141
142struct parport_operations {
143 /* IBM PC-style virtual registers. */
144 void (*write_data)(struct parport *, unsigned char);
145 unsigned char (*read_data)(struct parport *);
146
147 void (*write_control)(struct parport *, unsigned char);
148 unsigned char (*read_control)(struct parport *);
149 unsigned char (*frob_control)(struct parport *, unsigned char mask,
150 unsigned char val);
151
152 unsigned char (*read_status)(struct parport *);
153
154 /* IRQs. */
155 void (*enable_irq)(struct parport *);
156 void (*disable_irq)(struct parport *);
157
158 /* Data direction. */
159 void (*data_forward) (struct parport *);
160 void (*data_reverse) (struct parport *);
161
162 /* For core parport code. */
163 void (*init_state)(struct pardevice *, struct parport_state *);
164 void (*save_state)(struct parport *, struct parport_state *);
165 void (*restore_state)(struct parport *, struct parport_state *);
166
167 /* Block read/write */
168 size_t (*epp_write_data) (struct parport *port, const void *buf,
169 size_t len, int flags);
170 size_t (*epp_read_data) (struct parport *port, void *buf, size_t len,
171 int flags);
172 size_t (*epp_write_addr) (struct parport *port, const void *buf,
173 size_t len, int flags);
174 size_t (*epp_read_addr) (struct parport *port, void *buf, size_t len,
175 int flags);
176
177 size_t (*ecp_write_data) (struct parport *port, const void *buf,
178 size_t len, int flags);
179 size_t (*ecp_read_data) (struct parport *port, void *buf, size_t len,
180 int flags);
181 size_t (*ecp_write_addr) (struct parport *port, const void *buf,
182 size_t len, int flags);
183
184 size_t (*compat_write_data) (struct parport *port, const void *buf,
185 size_t len, int flags);
186 size_t (*nibble_read_data) (struct parport *port, void *buf,
187 size_t len, int flags);
188 size_t (*byte_read_data) (struct parport *port, void *buf,
189 size_t len, int flags);
190 struct module *owner;
191};
192
193struct parport_device_info {
194 parport_device_class class;
195 const char *class_name;
196 const char *mfr;
197 const char *model;
198 const char *cmdset;
199 const char *description;
200};
201
202/* Each device can have two callback functions:
203 * 1) a preemption function, called by the resource manager to request
204 * that the driver relinquish control of the port. The driver should
205 * return zero if it agrees to release the port, and nonzero if it
206 * refuses. Do not call parport_release() - the kernel will do this
207 * implicitly.
208 *
209 * 2) a wake-up function, called by the resource manager to tell drivers
210 * that the port is available to be claimed. If a driver wants to use
211 * the port, it should call parport_claim() here.
212 */
213
214/* A parallel port device */
215struct pardevice {
216 const char *name;
217 struct parport *port;
218 int daisy;
219 int (*preempt)(void *);
220 void (*wakeup)(void *);
221 void *private;
222 void (*irq_func)(int, void *, struct pt_regs *);
223 unsigned int flags;
224 struct pardevice *next;
225 struct pardevice *prev;
226 struct parport_state *state; /* saved status over preemption */
227 wait_queue_head_t wait_q;
228 unsigned long int time;
229 unsigned long int timeslice;
230 volatile long int timeout;
231 unsigned long waiting; /* long req'd for set_bit --RR */
232 struct pardevice *waitprev;
233 struct pardevice *waitnext;
234 void * sysctl_table;
235};
236
237/* IEEE1284 information */
238
239/* IEEE1284 phases */
240enum ieee1284_phase {
241 IEEE1284_PH_FWD_DATA,
242 IEEE1284_PH_FWD_IDLE,
243 IEEE1284_PH_TERMINATE,
244 IEEE1284_PH_NEGOTIATION,
245 IEEE1284_PH_HBUSY_DNA,
246 IEEE1284_PH_REV_IDLE,
247 IEEE1284_PH_HBUSY_DAVAIL,
248 IEEE1284_PH_REV_DATA,
249 IEEE1284_PH_ECP_SETUP,
250 IEEE1284_PH_ECP_FWD_TO_REV,
251 IEEE1284_PH_ECP_REV_TO_FWD,
252 IEEE1284_PH_ECP_DIR_UNKNOWN,
253};
254struct ieee1284_info {
255 int mode;
256 volatile enum ieee1284_phase phase;
257 struct semaphore irq;
258};
259
260/* A parallel port */
261struct parport {
262 unsigned long base; /* base address */
263 unsigned long base_hi; /* base address (hi - ECR) */
264 unsigned int size; /* IO extent */
265 const char *name;
266 unsigned int modes;
267 int irq; /* interrupt (or -1 for none) */
268 int dma;
269 int muxport; /* which muxport (if any) this is */
270 int portnum; /* which physical parallel port (not mux) */
271
272 struct parport *physport;
273 /* If this is a non-default mux
274 parport, i.e. we're a clone of a real
275 physical port, this is a pointer to that
276 port. The locking is only done in the
277 real port. For a clone port, the
278 following structure members are
279 meaningless: devices, cad, muxsel,
280 waithead, waittail, flags, pdir,
281 ieee1284, *_lock.
282
283 It this is a default mux parport, or
284 there is no mux involved, this points to
285 ourself. */
286
287 struct pardevice *devices;
288 struct pardevice *cad; /* port owner */
289 int daisy; /* currently selected daisy addr */
290 int muxsel; /* currently selected mux port */
291
292 struct pardevice *waithead;
293 struct pardevice *waittail;
294
295 struct list_head list;
296 unsigned int flags;
297
298 void *sysctl_table;
299 struct parport_device_info probe_info[5]; /* 0-3 + non-IEEE1284.3 */
300 struct ieee1284_info ieee1284;
301
302 struct parport_operations *ops;
303 void *private_data; /* for lowlevel driver */
304
305 int number; /* port index - the `n' in `parportn' */
306 spinlock_t pardevice_lock;
307 spinlock_t waitlist_lock;
308 rwlock_t cad_lock;
309
310 int spintime;
311 atomic_t ref_count;
312
313 struct list_head full_list;
314 struct parport *slaves[3];
315};
316
317#define DEFAULT_SPIN_TIME 500 /* us */
318
319struct parport_driver {
320 const char *name;
321 void (*attach) (struct parport *);
322 void (*detach) (struct parport *);
323 struct list_head list;
324};
325
326/* parport_register_port registers a new parallel port at the given
327 address (if one does not already exist) and returns a pointer to it.
328 This entails claiming the I/O region, IRQ and DMA. NULL is returned
329 if initialisation fails. */
330struct parport *parport_register_port(unsigned long base, int irq, int dma,
331 struct parport_operations *ops);
332
333/* Once a registered port is ready for high-level drivers to use, the
334 low-level driver that registered it should announce it. This will
335 call the high-level drivers' attach() functions (after things like
336 determining the IEEE 1284.3 topology of the port and collecting
337 DeviceIDs). */
338void parport_announce_port (struct parport *port);
339
340/* Unregister a port. */
341extern void parport_remove_port(struct parport *port);
342
343/* Register a new high-level driver. */
344extern int parport_register_driver (struct parport_driver *);
345
346/* Unregister a high-level driver. */
347extern void parport_unregister_driver (struct parport_driver *);
348
349/* If parport_register_driver doesn't fit your needs, perhaps
350 * parport_find_xxx does. */
351extern struct parport *parport_find_number (int);
352extern struct parport *parport_find_base (unsigned long);
353
354/* Reference counting for ports. */
355extern struct parport *parport_get_port (struct parport *);
356extern void parport_put_port (struct parport *);
357
358/* parport_register_device declares that a device is connected to a
359 port, and tells the kernel all it needs to know.
360 - pf is the preemption function (may be NULL for no callback)
361 - kf is the wake-up function (may be NULL for no callback)
362 - irq_func is the interrupt handler (may be NULL for no interrupts)
363 - handle is a user pointer that gets handed to callback functions. */
364struct pardevice *parport_register_device(struct parport *port,
365 const char *name,
366 int (*pf)(void *), void (*kf)(void *),
367 void (*irq_func)(int, void *, struct pt_regs *),
368 int flags, void *handle);
369
370/* parport_unregister unlinks a device from the chain. */
371extern void parport_unregister_device(struct pardevice *dev);
372
373/* parport_claim tries to gain ownership of the port for a particular
374 driver. This may fail (return non-zero) if another driver is busy.
375 If this driver has registered an interrupt handler, it will be
376 enabled. */
377extern int parport_claim(struct pardevice *dev);
378
379/* parport_claim_or_block is the same, but sleeps if the port cannot
380 be claimed. Return value is 1 if it slept, 0 normally and -errno
381 on error. */
382extern int parport_claim_or_block(struct pardevice *dev);
383
384/* parport_release reverses a previous parport_claim. This can never
385 fail, though the effects are undefined (except that they are bad)
386 if you didn't previously own the port. Once you have released the
387 port you should make sure that neither your code nor the hardware
388 on the port tries to initiate any communication without first
389 re-claiming the port. If you mess with the port state (enabling
390 ECP for example) you should clean up before releasing the port. */
391
392extern void parport_release(struct pardevice *dev);
393
394/**
395 * parport_yield - relinquish a parallel port temporarily
396 * @dev: a device on the parallel port
397 *
398 * This function relinquishes the port if it would be helpful to other
399 * drivers to do so. Afterwards it tries to reclaim the port using
400 * parport_claim(), and the return value is the same as for
401 * parport_claim(). If it fails, the port is left unclaimed and it is
402 * the driver's responsibility to reclaim the port.
403 *
404 * The parport_yield() and parport_yield_blocking() functions are for
405 * marking points in the driver at which other drivers may claim the
406 * port and use their devices. Yielding the port is similar to
407 * releasing it and reclaiming it, but is more efficient because no
408 * action is taken if there are no other devices needing the port. In
409 * fact, nothing is done even if there are other devices waiting but
410 * the current device is still within its "timeslice". The default
411 * timeslice is half a second, but it can be adjusted via the /proc
412 * interface.
413 **/
414static __inline__ int parport_yield(struct pardevice *dev)
415{
416 unsigned long int timeslip = (jiffies - dev->time);
417 if ((dev->port->waithead == NULL) || (timeslip < dev->timeslice))
418 return 0;
419 parport_release(dev);
420 return parport_claim(dev);
421}
422
423/**
424 * parport_yield_blocking - relinquish a parallel port temporarily
425 * @dev: a device on the parallel port
426 *
427 * This function relinquishes the port if it would be helpful to other
428 * drivers to do so. Afterwards it tries to reclaim the port using
429 * parport_claim_or_block(), and the return value is the same as for
430 * parport_claim_or_block().
431 **/
432static __inline__ int parport_yield_blocking(struct pardevice *dev)
433{
434 unsigned long int timeslip = (jiffies - dev->time);
435 if ((dev->port->waithead == NULL) || (timeslip < dev->timeslice))
436 return 0;
437 parport_release(dev);
438 return parport_claim_or_block(dev);
439}
440
441/* Flags used to identify what a device does. */
442#define PARPORT_DEV_TRAN 0 /* WARNING !! DEPRECATED !! */
443#define PARPORT_DEV_LURK (1<<0) /* WARNING !! DEPRECATED !! */
444#define PARPORT_DEV_EXCL (1<<1) /* Need exclusive access. */
445
446#define PARPORT_FLAG_EXCL (1<<1) /* EXCL driver registered. */
447
448/* IEEE1284 functions */
449extern void parport_ieee1284_interrupt (int, void *, struct pt_regs *);
450extern int parport_negotiate (struct parport *, int mode);
451extern ssize_t parport_write (struct parport *, const void *buf, size_t len);
452extern ssize_t parport_read (struct parport *, void *buf, size_t len);
453
454#define PARPORT_INACTIVITY_O_NONBLOCK 1
455extern long parport_set_timeout (struct pardevice *, long inactivity);
456
457extern int parport_wait_event (struct parport *, long timeout);
458extern int parport_wait_peripheral (struct parport *port,
459 unsigned char mask,
460 unsigned char val);
461extern int parport_poll_peripheral (struct parport *port,
462 unsigned char mask,
463 unsigned char val,
464 int usec);
465
466/* For architectural drivers */
467extern size_t parport_ieee1284_write_compat (struct parport *,
468 const void *, size_t, int);
469extern size_t parport_ieee1284_read_nibble (struct parport *,
470 void *, size_t, int);
471extern size_t parport_ieee1284_read_byte (struct parport *,
472 void *, size_t, int);
473extern size_t parport_ieee1284_ecp_read_data (struct parport *,
474 void *, size_t, int);
475extern size_t parport_ieee1284_ecp_write_data (struct parport *,
476 const void *, size_t, int);
477extern size_t parport_ieee1284_ecp_write_addr (struct parport *,
478 const void *, size_t, int);
479extern size_t parport_ieee1284_epp_write_data (struct parport *,
480 const void *, size_t, int);
481extern size_t parport_ieee1284_epp_read_data (struct parport *,
482 void *, size_t, int);
483extern size_t parport_ieee1284_epp_write_addr (struct parport *,
484 const void *, size_t, int);
485extern size_t parport_ieee1284_epp_read_addr (struct parport *,
486 void *, size_t, int);
487
488/* IEEE1284.3 functions */
489extern int parport_daisy_init (struct parport *port);
490extern void parport_daisy_fini (struct parport *port);
491extern struct pardevice *parport_open (int devnum, const char *name,
492 int (*pf) (void *),
493 void (*kf) (void *),
494 void (*irqf) (int, void *,
495 struct pt_regs *),
496 int flags, void *handle);
497extern void parport_close (struct pardevice *dev);
498extern ssize_t parport_device_id (int devnum, char *buffer, size_t len);
499extern int parport_device_num (int parport, int mux, int daisy);
500extern void parport_daisy_deselect_all (struct parport *port);
501extern int parport_daisy_select (struct parport *port, int daisy, int mode);
502
503/* Lowlevel drivers _can_ call this support function to handle irqs. */
504static __inline__ void parport_generic_irq(int irq, struct parport *port,
505 struct pt_regs *regs)
506{
507 parport_ieee1284_interrupt (irq, port, regs);
508 read_lock(&port->cad_lock);
509 if (port->cad && port->cad->irq_func)
510 port->cad->irq_func(irq, port->cad->private, regs);
511 read_unlock(&port->cad_lock);
512}
513
514/* Prototypes from parport_procfs */
515extern int parport_proc_register(struct parport *pp);
516extern int parport_proc_unregister(struct parport *pp);
517extern int parport_device_proc_register(struct pardevice *device);
518extern int parport_device_proc_unregister(struct pardevice *device);
519
520/* If PC hardware is the only type supported, we can optimise a bit. */
521#if !defined(CONFIG_PARPORT_NOT_PC)
522
523#include <linux/parport_pc.h>
524#define parport_write_data(p,x) parport_pc_write_data(p,x)
525#define parport_read_data(p) parport_pc_read_data(p)
526#define parport_write_control(p,x) parport_pc_write_control(p,x)
527#define parport_read_control(p) parport_pc_read_control(p)
528#define parport_frob_control(p,m,v) parport_pc_frob_control(p,m,v)
529#define parport_read_status(p) parport_pc_read_status(p)
530#define parport_enable_irq(p) parport_pc_enable_irq(p)
531#define parport_disable_irq(p) parport_pc_disable_irq(p)
532#define parport_data_forward(p) parport_pc_data_forward(p)
533#define parport_data_reverse(p) parport_pc_data_reverse(p)
534
535#else /* !CONFIG_PARPORT_NOT_PC */
536
537/* Generic operations vector through the dispatch table. */
538#define parport_write_data(p,x) (p)->ops->write_data(p,x)
539#define parport_read_data(p) (p)->ops->read_data(p)
540#define parport_write_control(p,x) (p)->ops->write_control(p,x)
541#define parport_read_control(p) (p)->ops->read_control(p)
542#define parport_frob_control(p,m,v) (p)->ops->frob_control(p,m,v)
543#define parport_read_status(p) (p)->ops->read_status(p)
544#define parport_enable_irq(p) (p)->ops->enable_irq(p)
545#define parport_disable_irq(p) (p)->ops->disable_irq(p)
546#define parport_data_forward(p) (p)->ops->data_forward(p)
547#define parport_data_reverse(p) (p)->ops->data_reverse(p)
548
549#endif /* !CONFIG_PARPORT_NOT_PC */
550
551#endif /* __KERNEL__ */
552#endif /* _PARPORT_H_ */
diff --git a/include/linux/parport_pc.h b/include/linux/parport_pc.h
new file mode 100644
index 000000000000..7825c76cbd00
--- /dev/null
+++ b/include/linux/parport_pc.h
@@ -0,0 +1,238 @@
1#ifndef __LINUX_PARPORT_PC_H
2#define __LINUX_PARPORT_PC_H
3
4#include <asm/io.h>
5
6/* --- register definitions ------------------------------- */
7
8#define ECONTROL(p) ((p)->base_hi + 0x2)
9#define CONFIGB(p) ((p)->base_hi + 0x1)
10#define CONFIGA(p) ((p)->base_hi + 0x0)
11#define FIFO(p) ((p)->base_hi + 0x0)
12#define EPPDATA(p) ((p)->base + 0x4)
13#define EPPADDR(p) ((p)->base + 0x3)
14#define CONTROL(p) ((p)->base + 0x2)
15#define STATUS(p) ((p)->base + 0x1)
16#define DATA(p) ((p)->base + 0x0)
17
18struct parport_pc_private {
19 /* Contents of CTR. */
20 unsigned char ctr;
21
22 /* Bitmask of writable CTR bits. */
23 unsigned char ctr_writable;
24
25 /* Whether or not there's an ECR. */
26 int ecr;
27
28 /* Number of PWords that FIFO will hold. */
29 int fifo_depth;
30
31 /* Number of bytes per portword. */
32 int pword;
33
34 /* Not used yet. */
35 int readIntrThreshold;
36 int writeIntrThreshold;
37
38 /* buffer suitable for DMA, if DMA enabled */
39 char *dma_buf;
40 dma_addr_t dma_handle;
41 struct pci_dev *dev;
42 struct list_head list;
43 struct parport *port;
44};
45
46struct parport_pc_via_data
47{
48 /* ISA PnP IRQ routing register 1 */
49 u8 via_pci_parport_irq_reg;
50 /* ISA PnP DMA request routing register */
51 u8 via_pci_parport_dma_reg;
52 /* Register and value to enable SuperIO configuration access */
53 u8 via_pci_superio_config_reg;
54 u8 via_pci_superio_config_data;
55 /* SuperIO function register number */
56 u8 viacfg_function;
57 /* parallel port control register number */
58 u8 viacfg_parport_control;
59 /* Parallel port base address register */
60 u8 viacfg_parport_base;
61};
62
63static __inline__ void parport_pc_write_data(struct parport *p, unsigned char d)
64{
65#ifdef DEBUG_PARPORT
66 printk (KERN_DEBUG "parport_pc_write_data(%p,0x%02x)\n", p, d);
67#endif
68 outb(d, DATA(p));
69}
70
71static __inline__ unsigned char parport_pc_read_data(struct parport *p)
72{
73 unsigned char val = inb (DATA (p));
74#ifdef DEBUG_PARPORT
75 printk (KERN_DEBUG "parport_pc_read_data(%p) = 0x%02x\n",
76 p, val);
77#endif
78 return val;
79}
80
81#ifdef DEBUG_PARPORT
82extern __inline__ void dump_parport_state (char *str, struct parport *p)
83{
84 /* here's hoping that reading these ports won't side-effect anything underneath */
85 unsigned char ecr = inb (ECONTROL (p));
86 unsigned char dcr = inb (CONTROL (p));
87 unsigned char dsr = inb (STATUS (p));
88 static char *ecr_modes[] = {"SPP", "PS2", "PPFIFO", "ECP", "xXx", "yYy", "TST", "CFG"};
89 const struct parport_pc_private *priv = (parport_pc_private *)p->physport->private_data;
90 int i;
91
92 printk (KERN_DEBUG "*** parport state (%s): ecr=[%s", str, ecr_modes[(ecr & 0xe0) >> 5]);
93 if (ecr & 0x10) printk (",nErrIntrEn");
94 if (ecr & 0x08) printk (",dmaEn");
95 if (ecr & 0x04) printk (",serviceIntr");
96 if (ecr & 0x02) printk (",f_full");
97 if (ecr & 0x01) printk (",f_empty");
98 for (i=0; i<2; i++) {
99 printk ("] dcr(%s)=[", i ? "soft" : "hard");
100 dcr = i ? priv->ctr : inb (CONTROL (p));
101
102 if (dcr & 0x20) {
103 printk ("rev");
104 } else {
105 printk ("fwd");
106 }
107 if (dcr & 0x10) printk (",ackIntEn");
108 if (!(dcr & 0x08)) printk (",N-SELECT-IN");
109 if (dcr & 0x04) printk (",N-INIT");
110 if (!(dcr & 0x02)) printk (",N-AUTOFD");
111 if (!(dcr & 0x01)) printk (",N-STROBE");
112 }
113 printk ("] dsr=[");
114 if (!(dsr & 0x80)) printk ("BUSY");
115 if (dsr & 0x40) printk (",N-ACK");
116 if (dsr & 0x20) printk (",PERROR");
117 if (dsr & 0x10) printk (",SELECT");
118 if (dsr & 0x08) printk (",N-FAULT");
119 printk ("]\n");
120 return;
121}
122#else /* !DEBUG_PARPORT */
123#define dump_parport_state(args...)
124#endif /* !DEBUG_PARPORT */
125
126/* __parport_pc_frob_control differs from parport_pc_frob_control in that
127 * it doesn't do any extra masking. */
128static __inline__ unsigned char __parport_pc_frob_control (struct parport *p,
129 unsigned char mask,
130 unsigned char val)
131{
132 struct parport_pc_private *priv = p->physport->private_data;
133 unsigned char ctr = priv->ctr;
134#ifdef DEBUG_PARPORT
135 printk (KERN_DEBUG
136 "__parport_pc_frob_control(%02x,%02x): %02x -> %02x\n",
137 mask, val, ctr, ((ctr & ~mask) ^ val) & priv->ctr_writable);
138#endif
139 ctr = (ctr & ~mask) ^ val;
140 ctr &= priv->ctr_writable; /* only write writable bits. */
141 outb (ctr, CONTROL (p));
142 priv->ctr = ctr; /* Update soft copy */
143 return ctr;
144}
145
146static __inline__ void parport_pc_data_reverse (struct parport *p)
147{
148 __parport_pc_frob_control (p, 0x20, 0x20);
149}
150
151static __inline__ void parport_pc_data_forward (struct parport *p)
152{
153 __parport_pc_frob_control (p, 0x20, 0x00);
154}
155
156static __inline__ void parport_pc_write_control (struct parport *p,
157 unsigned char d)
158{
159 const unsigned char wm = (PARPORT_CONTROL_STROBE |
160 PARPORT_CONTROL_AUTOFD |
161 PARPORT_CONTROL_INIT |
162 PARPORT_CONTROL_SELECT);
163
164 /* Take this out when drivers have adapted to newer interface. */
165 if (d & 0x20) {
166 printk (KERN_DEBUG "%s (%s): use data_reverse for this!\n",
167 p->name, p->cad->name);
168 parport_pc_data_reverse (p);
169 }
170
171 __parport_pc_frob_control (p, wm, d & wm);
172}
173
174static __inline__ unsigned char parport_pc_read_control(struct parport *p)
175{
176 const unsigned char rm = (PARPORT_CONTROL_STROBE |
177 PARPORT_CONTROL_AUTOFD |
178 PARPORT_CONTROL_INIT |
179 PARPORT_CONTROL_SELECT);
180 const struct parport_pc_private *priv = p->physport->private_data;
181 return priv->ctr & rm; /* Use soft copy */
182}
183
184static __inline__ unsigned char parport_pc_frob_control (struct parport *p,
185 unsigned char mask,
186 unsigned char val)
187{
188 const unsigned char wm = (PARPORT_CONTROL_STROBE |
189 PARPORT_CONTROL_AUTOFD |
190 PARPORT_CONTROL_INIT |
191 PARPORT_CONTROL_SELECT);
192
193 /* Take this out when drivers have adapted to newer interface. */
194 if (mask & 0x20) {
195 printk (KERN_DEBUG "%s (%s): use data_%s for this!\n",
196 p->name, p->cad->name,
197 (val & 0x20) ? "reverse" : "forward");
198 if (val & 0x20)
199 parport_pc_data_reverse (p);
200 else
201 parport_pc_data_forward (p);
202 }
203
204 /* Restrict mask and val to control lines. */
205 mask &= wm;
206 val &= wm;
207
208 return __parport_pc_frob_control (p, mask, val);
209}
210
211static __inline__ unsigned char parport_pc_read_status(struct parport *p)
212{
213 return inb(STATUS(p));
214}
215
216
217static __inline__ void parport_pc_disable_irq(struct parport *p)
218{
219 __parport_pc_frob_control (p, 0x10, 0x00);
220}
221
222static __inline__ void parport_pc_enable_irq(struct parport *p)
223{
224 __parport_pc_frob_control (p, 0x10, 0x10);
225}
226
227extern void parport_pc_release_resources(struct parport *p);
228
229extern int parport_pc_claim_resources(struct parport *p);
230
231/* PCMCIA code will want to get us to look at a port. Provide a mechanism. */
232extern struct parport *parport_pc_probe_port (unsigned long base,
233 unsigned long base_hi,
234 int irq, int dma,
235 struct pci_dev *dev);
236extern void parport_pc_unregister_port (struct parport *p);
237
238#endif
diff --git a/include/linux/parser.h b/include/linux/parser.h
new file mode 100644
index 000000000000..fa3332861a09
--- /dev/null
+++ b/include/linux/parser.h
@@ -0,0 +1,33 @@
1/*
2 * linux/include/linux/parser.h
3 *
4 * Header for lib/parser.c
5 * Intended use of these functions is parsing filesystem argument lists,
6 * but could potentially be used anywhere else that simple option=arg
7 * parsing is required.
8 */
9
10
11/* associates an integer enumerator with a pattern string. */
12struct match_token {
13 int token;
14 char *pattern;
15};
16
17typedef struct match_token match_table_t[];
18
19/* Maximum number of arguments that match_token will find in a pattern */
20enum {MAX_OPT_ARGS = 3};
21
22/* Describe the location within a string of a substring */
23typedef struct {
24 char *from;
25 char *to;
26} substring_t;
27
28int match_token(char *, match_table_t table, substring_t args[]);
29int match_int(substring_t *, int *result);
30int match_octal(substring_t *, int *result);
31int match_hex(substring_t *, int *result);
32void match_strcpy(char *, substring_t *);
33char *match_strdup(substring_t *);
diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h
new file mode 100644
index 000000000000..857126a36ecc
--- /dev/null
+++ b/include/linux/pci-acpi.h
@@ -0,0 +1,61 @@
1/*
2 * File pci-acpi.h
3 *
4 * Copyright (C) 2004 Intel
5 * Copyright (C) Tom Long Nguyen (tom.l.nguyen@intel.com)
6 */
7
8#ifndef _PCI_ACPI_H_
9#define _PCI_ACPI_H_
10
11#define OSC_QUERY_TYPE 0
12#define OSC_SUPPORT_TYPE 1
13#define OSC_CONTROL_TYPE 2
14#define OSC_SUPPORT_MASKS 0x1f
15
16/*
17 * _OSC DW0 Definition
18 */
19#define OSC_QUERY_ENABLE 1
20#define OSC_REQUEST_ERROR 2
21#define OSC_INVALID_UUID_ERROR 4
22#define OSC_INVALID_REVISION_ERROR 8
23#define OSC_CAPABILITIES_MASK_ERROR 16
24
25/*
26 * _OSC DW1 Definition (OS Support Fields)
27 */
28#define OSC_EXT_PCI_CONFIG_SUPPORT 1
29#define OSC_ACTIVE_STATE_PWR_SUPPORT 2
30#define OSC_CLOCK_PWR_CAPABILITY_SUPPORT 4
31#define OSC_PCI_SEGMENT_GROUPS_SUPPORT 8
32#define OSC_MSI_SUPPORT 16
33
34/*
35 * _OSC DW1 Definition (OS Control Fields)
36 */
37#define OSC_PCI_EXPRESS_NATIVE_HP_CONTROL 1
38#define OSC_SHPC_NATIVE_HP_CONTROL 2
39#define OSC_PCI_EXPRESS_PME_CONTROL 4
40#define OSC_PCI_EXPRESS_AER_CONTROL 8
41#define OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL 16
42
43#define OSC_CONTROL_MASKS (OSC_PCI_EXPRESS_NATIVE_HP_CONTROL | \
44 OSC_SHPC_NATIVE_HP_CONTROL | \
45 OSC_PCI_EXPRESS_PME_CONTROL | \
46 OSC_PCI_EXPRESS_AER_CONTROL | \
47 OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL)
48
49#ifdef CONFIG_ACPI
50extern acpi_status pci_osc_control_set(u32 flags);
51extern acpi_status pci_osc_support_set(u32 flags);
52#else
53#if !defined(acpi_status)
54typedef u32 acpi_status;
55#define AE_ERROR (acpi_status) (0x0001)
56#endif
57static inline acpi_status pci_osc_control_set(u32 flags) {return AE_ERROR;}
58static inline acpi_status pci_osc_support_set(u32 flags) {return AE_ERROR;}
59#endif
60
61#endif /* _PCI_ACPI_H_ */
diff --git a/include/linux/pci-dynids.h b/include/linux/pci-dynids.h
new file mode 100644
index 000000000000..183b6b0de81c
--- /dev/null
+++ b/include/linux/pci-dynids.h
@@ -0,0 +1,18 @@
1/*
2 * PCI defines and function prototypes
3 * Copyright 2003 Dell Inc.
4 * by Matt Domsch <Matt_Domsch@dell.com>
5 */
6
7#ifndef LINUX_PCI_DYNIDS_H
8#define LINUX_PCI_DYNIDS_H
9
10#include <linux/list.h>
11#include <linux/mod_devicetable.h>
12
13struct dynid {
14 struct list_head node;
15 struct pci_device_id id;
16};
17
18#endif
diff --git a/include/linux/pci.h b/include/linux/pci.h
new file mode 100644
index 000000000000..bea13a99e6fb
--- /dev/null
+++ b/include/linux/pci.h
@@ -0,0 +1,1067 @@
1/*
2 * pci.h
3 *
4 * PCI defines and function prototypes
5 * Copyright 1994, Drew Eckhardt
6 * Copyright 1997--1999 Martin Mares <mj@ucw.cz>
7 *
8 * For more information, please consult the following manuals (look at
9 * http://www.pcisig.com/ for how to get them):
10 *
11 * PCI BIOS Specification
12 * PCI Local Bus Specification
13 * PCI to PCI Bridge Specification
14 * PCI System Design Guide
15 */
16
17#ifndef LINUX_PCI_H
18#define LINUX_PCI_H
19
20#include <linux/mod_devicetable.h>
21
22/*
23 * Under PCI, each device has 256 bytes of configuration address space,
24 * of which the first 64 bytes are standardized as follows:
25 */
26#define PCI_VENDOR_ID 0x00 /* 16 bits */
27#define PCI_DEVICE_ID 0x02 /* 16 bits */
28#define PCI_COMMAND 0x04 /* 16 bits */
29#define PCI_COMMAND_IO 0x1 /* Enable response in I/O space */
30#define PCI_COMMAND_MEMORY 0x2 /* Enable response in Memory space */
31#define PCI_COMMAND_MASTER 0x4 /* Enable bus mastering */
32#define PCI_COMMAND_SPECIAL 0x8 /* Enable response to special cycles */
33#define PCI_COMMAND_INVALIDATE 0x10 /* Use memory write and invalidate */
34#define PCI_COMMAND_VGA_PALETTE 0x20 /* Enable palette snooping */
35#define PCI_COMMAND_PARITY 0x40 /* Enable parity checking */
36#define PCI_COMMAND_WAIT 0x80 /* Enable address/data stepping */
37#define PCI_COMMAND_SERR 0x100 /* Enable SERR */
38#define PCI_COMMAND_FAST_BACK 0x200 /* Enable back-to-back writes */
39#define PCI_COMMAND_INTX_DISABLE 0x400 /* INTx Emulation Disable */
40
41#define PCI_STATUS 0x06 /* 16 bits */
42#define PCI_STATUS_CAP_LIST 0x10 /* Support Capability List */
43#define PCI_STATUS_66MHZ 0x20 /* Support 66 Mhz PCI 2.1 bus */
44#define PCI_STATUS_UDF 0x40 /* Support User Definable Features [obsolete] */
45#define PCI_STATUS_FAST_BACK 0x80 /* Accept fast-back to back */
46#define PCI_STATUS_PARITY 0x100 /* Detected parity error */
47#define PCI_STATUS_DEVSEL_MASK 0x600 /* DEVSEL timing */
48#define PCI_STATUS_DEVSEL_FAST 0x000
49#define PCI_STATUS_DEVSEL_MEDIUM 0x200
50#define PCI_STATUS_DEVSEL_SLOW 0x400
51#define PCI_STATUS_SIG_TARGET_ABORT 0x800 /* Set on target abort */
52#define PCI_STATUS_REC_TARGET_ABORT 0x1000 /* Master ack of " */
53#define PCI_STATUS_REC_MASTER_ABORT 0x2000 /* Set on master abort */
54#define PCI_STATUS_SIG_SYSTEM_ERROR 0x4000 /* Set when we drive SERR */
55#define PCI_STATUS_DETECTED_PARITY 0x8000 /* Set on parity error */
56
57#define PCI_CLASS_REVISION 0x08 /* High 24 bits are class, low 8
58 revision */
59#define PCI_REVISION_ID 0x08 /* Revision ID */
60#define PCI_CLASS_PROG 0x09 /* Reg. Level Programming Interface */
61#define PCI_CLASS_DEVICE 0x0a /* Device class */
62
63#define PCI_CACHE_LINE_SIZE 0x0c /* 8 bits */
64#define PCI_LATENCY_TIMER 0x0d /* 8 bits */
65#define PCI_HEADER_TYPE 0x0e /* 8 bits */
66#define PCI_HEADER_TYPE_NORMAL 0
67#define PCI_HEADER_TYPE_BRIDGE 1
68#define PCI_HEADER_TYPE_CARDBUS 2
69
70#define PCI_BIST 0x0f /* 8 bits */
71#define PCI_BIST_CODE_MASK 0x0f /* Return result */
72#define PCI_BIST_START 0x40 /* 1 to start BIST, 2 secs or less */
73#define PCI_BIST_CAPABLE 0x80 /* 1 if BIST capable */
74
75/*
76 * Base addresses specify locations in memory or I/O space.
77 * Decoded size can be determined by writing a value of
78 * 0xffffffff to the register, and reading it back. Only
79 * 1 bits are decoded.
80 */
81#define PCI_BASE_ADDRESS_0 0x10 /* 32 bits */
82#define PCI_BASE_ADDRESS_1 0x14 /* 32 bits [htype 0,1 only] */
83#define PCI_BASE_ADDRESS_2 0x18 /* 32 bits [htype 0 only] */
84#define PCI_BASE_ADDRESS_3 0x1c /* 32 bits */
85#define PCI_BASE_ADDRESS_4 0x20 /* 32 bits */
86#define PCI_BASE_ADDRESS_5 0x24 /* 32 bits */
87#define PCI_BASE_ADDRESS_SPACE 0x01 /* 0 = memory, 1 = I/O */
88#define PCI_BASE_ADDRESS_SPACE_IO 0x01
89#define PCI_BASE_ADDRESS_SPACE_MEMORY 0x00
90#define PCI_BASE_ADDRESS_MEM_TYPE_MASK 0x06
91#define PCI_BASE_ADDRESS_MEM_TYPE_32 0x00 /* 32 bit address */
92#define PCI_BASE_ADDRESS_MEM_TYPE_1M 0x02 /* Below 1M [obsolete] */
93#define PCI_BASE_ADDRESS_MEM_TYPE_64 0x04 /* 64 bit address */
94#define PCI_BASE_ADDRESS_MEM_PREFETCH 0x08 /* prefetchable? */
95#define PCI_BASE_ADDRESS_MEM_MASK (~0x0fUL)
96#define PCI_BASE_ADDRESS_IO_MASK (~0x03UL)
97/* bit 1 is reserved if address_space = 1 */
98
99/* Header type 0 (normal devices) */
100#define PCI_CARDBUS_CIS 0x28
101#define PCI_SUBSYSTEM_VENDOR_ID 0x2c
102#define PCI_SUBSYSTEM_ID 0x2e
103#define PCI_ROM_ADDRESS 0x30 /* Bits 31..11 are address, 10..1 reserved */
104#define PCI_ROM_ADDRESS_ENABLE 0x01
105#define PCI_ROM_ADDRESS_MASK (~0x7ffUL)
106
107#define PCI_CAPABILITY_LIST 0x34 /* Offset of first capability list entry */
108
109/* 0x35-0x3b are reserved */
110#define PCI_INTERRUPT_LINE 0x3c /* 8 bits */
111#define PCI_INTERRUPT_PIN 0x3d /* 8 bits */
112#define PCI_MIN_GNT 0x3e /* 8 bits */
113#define PCI_MAX_LAT 0x3f /* 8 bits */
114
115/* Header type 1 (PCI-to-PCI bridges) */
116#define PCI_PRIMARY_BUS 0x18 /* Primary bus number */
117#define PCI_SECONDARY_BUS 0x19 /* Secondary bus number */
118#define PCI_SUBORDINATE_BUS 0x1a /* Highest bus number behind the bridge */
119#define PCI_SEC_LATENCY_TIMER 0x1b /* Latency timer for secondary interface */
120#define PCI_IO_BASE 0x1c /* I/O range behind the bridge */
121#define PCI_IO_LIMIT 0x1d
122#define PCI_IO_RANGE_TYPE_MASK 0x0fUL /* I/O bridging type */
123#define PCI_IO_RANGE_TYPE_16 0x00
124#define PCI_IO_RANGE_TYPE_32 0x01
125#define PCI_IO_RANGE_MASK (~0x0fUL)
126#define PCI_SEC_STATUS 0x1e /* Secondary status register, only bit 14 used */
127#define PCI_MEMORY_BASE 0x20 /* Memory range behind */
128#define PCI_MEMORY_LIMIT 0x22
129#define PCI_MEMORY_RANGE_TYPE_MASK 0x0fUL
130#define PCI_MEMORY_RANGE_MASK (~0x0fUL)
131#define PCI_PREF_MEMORY_BASE 0x24 /* Prefetchable memory range behind */
132#define PCI_PREF_MEMORY_LIMIT 0x26
133#define PCI_PREF_RANGE_TYPE_MASK 0x0fUL
134#define PCI_PREF_RANGE_TYPE_32 0x00
135#define PCI_PREF_RANGE_TYPE_64 0x01
136#define PCI_PREF_RANGE_MASK (~0x0fUL)
137#define PCI_PREF_BASE_UPPER32 0x28 /* Upper half of prefetchable memory range */
138#define PCI_PREF_LIMIT_UPPER32 0x2c
139#define PCI_IO_BASE_UPPER16 0x30 /* Upper half of I/O addresses */
140#define PCI_IO_LIMIT_UPPER16 0x32
141/* 0x34 same as for htype 0 */
142/* 0x35-0x3b is reserved */
143#define PCI_ROM_ADDRESS1 0x38 /* Same as PCI_ROM_ADDRESS, but for htype 1 */
144/* 0x3c-0x3d are same as for htype 0 */
145#define PCI_BRIDGE_CONTROL 0x3e
146#define PCI_BRIDGE_CTL_PARITY 0x01 /* Enable parity detection on secondary interface */
147#define PCI_BRIDGE_CTL_SERR 0x02 /* The same for SERR forwarding */
148#define PCI_BRIDGE_CTL_NO_ISA 0x04 /* Disable bridging of ISA ports */
149#define PCI_BRIDGE_CTL_VGA 0x08 /* Forward VGA addresses */
150#define PCI_BRIDGE_CTL_MASTER_ABORT 0x20 /* Report master aborts */
151#define PCI_BRIDGE_CTL_BUS_RESET 0x40 /* Secondary bus reset */
152#define PCI_BRIDGE_CTL_FAST_BACK 0x80 /* Fast Back2Back enabled on secondary interface */
153
154/* Header type 2 (CardBus bridges) */
155#define PCI_CB_CAPABILITY_LIST 0x14
156/* 0x15 reserved */
157#define PCI_CB_SEC_STATUS 0x16 /* Secondary status */
158#define PCI_CB_PRIMARY_BUS 0x18 /* PCI bus number */
159#define PCI_CB_CARD_BUS 0x19 /* CardBus bus number */
160#define PCI_CB_SUBORDINATE_BUS 0x1a /* Subordinate bus number */
161#define PCI_CB_LATENCY_TIMER 0x1b /* CardBus latency timer */
162#define PCI_CB_MEMORY_BASE_0 0x1c
163#define PCI_CB_MEMORY_LIMIT_0 0x20
164#define PCI_CB_MEMORY_BASE_1 0x24
165#define PCI_CB_MEMORY_LIMIT_1 0x28
166#define PCI_CB_IO_BASE_0 0x2c
167#define PCI_CB_IO_BASE_0_HI 0x2e
168#define PCI_CB_IO_LIMIT_0 0x30
169#define PCI_CB_IO_LIMIT_0_HI 0x32
170#define PCI_CB_IO_BASE_1 0x34
171#define PCI_CB_IO_BASE_1_HI 0x36
172#define PCI_CB_IO_LIMIT_1 0x38
173#define PCI_CB_IO_LIMIT_1_HI 0x3a
174#define PCI_CB_IO_RANGE_MASK (~0x03UL)
175/* 0x3c-0x3d are same as for htype 0 */
176#define PCI_CB_BRIDGE_CONTROL 0x3e
177#define PCI_CB_BRIDGE_CTL_PARITY 0x01 /* Similar to standard bridge control register */
178#define PCI_CB_BRIDGE_CTL_SERR 0x02
179#define PCI_CB_BRIDGE_CTL_ISA 0x04
180#define PCI_CB_BRIDGE_CTL_VGA 0x08
181#define PCI_CB_BRIDGE_CTL_MASTER_ABORT 0x20
182#define PCI_CB_BRIDGE_CTL_CB_RESET 0x40 /* CardBus reset */
183#define PCI_CB_BRIDGE_CTL_16BIT_INT 0x80 /* Enable interrupt for 16-bit cards */
184#define PCI_CB_BRIDGE_CTL_PREFETCH_MEM0 0x100 /* Prefetch enable for both memory regions */
185#define PCI_CB_BRIDGE_CTL_PREFETCH_MEM1 0x200
186#define PCI_CB_BRIDGE_CTL_POST_WRITES 0x400
187#define PCI_CB_SUBSYSTEM_VENDOR_ID 0x40
188#define PCI_CB_SUBSYSTEM_ID 0x42
189#define PCI_CB_LEGACY_MODE_BASE 0x44 /* 16-bit PC Card legacy mode base address (ExCa) */
190/* 0x48-0x7f reserved */
191
192/* Capability lists */
193
194#define PCI_CAP_LIST_ID 0 /* Capability ID */
195#define PCI_CAP_ID_PM 0x01 /* Power Management */
196#define PCI_CAP_ID_AGP 0x02 /* Accelerated Graphics Port */
197#define PCI_CAP_ID_VPD 0x03 /* Vital Product Data */
198#define PCI_CAP_ID_SLOTID 0x04 /* Slot Identification */
199#define PCI_CAP_ID_MSI 0x05 /* Message Signalled Interrupts */
200#define PCI_CAP_ID_CHSWP 0x06 /* CompactPCI HotSwap */
201#define PCI_CAP_ID_PCIX 0x07 /* PCI-X */
202#define PCI_CAP_ID_SHPC 0x0C /* PCI Standard Hot-Plug Controller */
203#define PCI_CAP_ID_EXP 0x10 /* PCI Express */
204#define PCI_CAP_ID_MSIX 0x11 /* MSI-X */
205#define PCI_CAP_LIST_NEXT 1 /* Next capability in the list */
206#define PCI_CAP_FLAGS 2 /* Capability defined flags (16 bits) */
207#define PCI_CAP_SIZEOF 4
208
209/* Power Management Registers */
210
211#define PCI_PM_PMC 2 /* PM Capabilities Register */
212#define PCI_PM_CAP_VER_MASK 0x0007 /* Version */
213#define PCI_PM_CAP_PME_CLOCK 0x0008 /* PME clock required */
214#define PCI_PM_CAP_RESERVED 0x0010 /* Reserved field */
215#define PCI_PM_CAP_DSI 0x0020 /* Device specific initialization */
216#define PCI_PM_CAP_AUX_POWER 0x01C0 /* Auxilliary power support mask */
217#define PCI_PM_CAP_D1 0x0200 /* D1 power state support */
218#define PCI_PM_CAP_D2 0x0400 /* D2 power state support */
219#define PCI_PM_CAP_PME 0x0800 /* PME pin supported */
220#define PCI_PM_CAP_PME_MASK 0xF800 /* PME Mask of all supported states */
221#define PCI_PM_CAP_PME_D0 0x0800 /* PME# from D0 */
222#define PCI_PM_CAP_PME_D1 0x1000 /* PME# from D1 */
223#define PCI_PM_CAP_PME_D2 0x2000 /* PME# from D2 */
224#define PCI_PM_CAP_PME_D3 0x4000 /* PME# from D3 (hot) */
225#define PCI_PM_CAP_PME_D3cold 0x8000 /* PME# from D3 (cold) */
226#define PCI_PM_CTRL 4 /* PM control and status register */
227#define PCI_PM_CTRL_STATE_MASK 0x0003 /* Current power state (D0 to D3) */
228#define PCI_PM_CTRL_PME_ENABLE 0x0100 /* PME pin enable */
229#define PCI_PM_CTRL_DATA_SEL_MASK 0x1e00 /* Data select (??) */
230#define PCI_PM_CTRL_DATA_SCALE_MASK 0x6000 /* Data scale (??) */
231#define PCI_PM_CTRL_PME_STATUS 0x8000 /* PME pin status */
232#define PCI_PM_PPB_EXTENSIONS 6 /* PPB support extensions (??) */
233#define PCI_PM_PPB_B2_B3 0x40 /* Stop clock when in D3hot (??) */
234#define PCI_PM_BPCC_ENABLE 0x80 /* Bus power/clock control enable (??) */
235#define PCI_PM_DATA_REGISTER 7 /* (??) */
236#define PCI_PM_SIZEOF 8
237
238/* AGP registers */
239
240#define PCI_AGP_VERSION 2 /* BCD version number */
241#define PCI_AGP_RFU 3 /* Rest of capability flags */
242#define PCI_AGP_STATUS 4 /* Status register */
243#define PCI_AGP_STATUS_RQ_MASK 0xff000000 /* Maximum number of requests - 1 */
244#define PCI_AGP_STATUS_SBA 0x0200 /* Sideband addressing supported */
245#define PCI_AGP_STATUS_64BIT 0x0020 /* 64-bit addressing supported */
246#define PCI_AGP_STATUS_FW 0x0010 /* FW transfers supported */
247#define PCI_AGP_STATUS_RATE4 0x0004 /* 4x transfer rate supported */
248#define PCI_AGP_STATUS_RATE2 0x0002 /* 2x transfer rate supported */
249#define PCI_AGP_STATUS_RATE1 0x0001 /* 1x transfer rate supported */
250#define PCI_AGP_COMMAND 8 /* Control register */
251#define PCI_AGP_COMMAND_RQ_MASK 0xff000000 /* Master: Maximum number of requests */
252#define PCI_AGP_COMMAND_SBA 0x0200 /* Sideband addressing enabled */
253#define PCI_AGP_COMMAND_AGP 0x0100 /* Allow processing of AGP transactions */
254#define PCI_AGP_COMMAND_64BIT 0x0020 /* Allow processing of 64-bit addresses */
255#define PCI_AGP_COMMAND_FW 0x0010 /* Force FW transfers */
256#define PCI_AGP_COMMAND_RATE4 0x0004 /* Use 4x rate */
257#define PCI_AGP_COMMAND_RATE2 0x0002 /* Use 2x rate */
258#define PCI_AGP_COMMAND_RATE1 0x0001 /* Use 1x rate */
259#define PCI_AGP_SIZEOF 12
260
261/* Vital Product Data */
262
263#define PCI_VPD_ADDR 2 /* Address to access (15 bits!) */
264#define PCI_VPD_ADDR_MASK 0x7fff /* Address mask */
265#define PCI_VPD_ADDR_F 0x8000 /* Write 0, 1 indicates completion */
266#define PCI_VPD_DATA 4 /* 32-bits of data returned here */
267
268/* Slot Identification */
269
270#define PCI_SID_ESR 2 /* Expansion Slot Register */
271#define PCI_SID_ESR_NSLOTS 0x1f /* Number of expansion slots available */
272#define PCI_SID_ESR_FIC 0x20 /* First In Chassis Flag */
273#define PCI_SID_CHASSIS_NR 3 /* Chassis Number */
274
275/* Message Signalled Interrupts registers */
276
277#define PCI_MSI_FLAGS 2 /* Various flags */
278#define PCI_MSI_FLAGS_64BIT 0x80 /* 64-bit addresses allowed */
279#define PCI_MSI_FLAGS_QSIZE 0x70 /* Message queue size configured */
280#define PCI_MSI_FLAGS_QMASK 0x0e /* Maximum queue size available */
281#define PCI_MSI_FLAGS_ENABLE 0x01 /* MSI feature enabled */
282#define PCI_MSI_FLAGS_MASKBIT 0x100 /* 64-bit mask bits allowed */
283#define PCI_MSI_RFU 3 /* Rest of capability flags */
284#define PCI_MSI_ADDRESS_LO 4 /* Lower 32 bits */
285#define PCI_MSI_ADDRESS_HI 8 /* Upper 32 bits (if PCI_MSI_FLAGS_64BIT set) */
286#define PCI_MSI_DATA_32 8 /* 16 bits of data for 32-bit devices */
287#define PCI_MSI_DATA_64 12 /* 16 bits of data for 64-bit devices */
288#define PCI_MSI_MASK_BIT 16 /* Mask bits register */
289
290/* CompactPCI Hotswap Register */
291
292#define PCI_CHSWP_CSR 2 /* Control and Status Register */
293#define PCI_CHSWP_DHA 0x01 /* Device Hiding Arm */
294#define PCI_CHSWP_EIM 0x02 /* ENUM# Signal Mask */
295#define PCI_CHSWP_PIE 0x04 /* Pending Insert or Extract */
296#define PCI_CHSWP_LOO 0x08 /* LED On / Off */
297#define PCI_CHSWP_PI 0x30 /* Programming Interface */
298#define PCI_CHSWP_EXT 0x40 /* ENUM# status - extraction */
299#define PCI_CHSWP_INS 0x80 /* ENUM# status - insertion */
300
301/* PCI-X registers */
302
303#define PCI_X_CMD 2 /* Modes & Features */
304#define PCI_X_CMD_DPERR_E 0x0001 /* Data Parity Error Recovery Enable */
305#define PCI_X_CMD_ERO 0x0002 /* Enable Relaxed Ordering */
306#define PCI_X_CMD_MAX_READ 0x000c /* Max Memory Read Byte Count */
307#define PCI_X_CMD_MAX_SPLIT 0x0070 /* Max Outstanding Split Transactions */
308#define PCI_X_CMD_VERSION(x) (((x) >> 12) & 3) /* Version */
309#define PCI_X_STATUS 4 /* PCI-X capabilities */
310#define PCI_X_STATUS_DEVFN 0x000000ff /* A copy of devfn */
311#define PCI_X_STATUS_BUS 0x0000ff00 /* A copy of bus nr */
312#define PCI_X_STATUS_64BIT 0x00010000 /* 64-bit device */
313#define PCI_X_STATUS_133MHZ 0x00020000 /* 133 MHz capable */
314#define PCI_X_STATUS_SPL_DISC 0x00040000 /* Split Completion Discarded */
315#define PCI_X_STATUS_UNX_SPL 0x00080000 /* Unexpected Split Completion */
316#define PCI_X_STATUS_COMPLEX 0x00100000 /* Device Complexity */
317#define PCI_X_STATUS_MAX_READ 0x00600000 /* Designed Max Memory Read Count */
318#define PCI_X_STATUS_MAX_SPLIT 0x03800000 /* Designed Max Outstanding Split Transactions */
319#define PCI_X_STATUS_MAX_CUM 0x1c000000 /* Designed Max Cumulative Read Size */
320#define PCI_X_STATUS_SPL_ERR 0x20000000 /* Rcvd Split Completion Error Msg */
321#define PCI_X_STATUS_266MHZ 0x40000000 /* 266 MHz capable */
322#define PCI_X_STATUS_533MHZ 0x80000000 /* 533 MHz capable */
323
324/* PCI Express capability registers */
325
326#define PCI_EXP_FLAGS 2 /* Capabilities register */
327#define PCI_EXP_FLAGS_VERS 0x000f /* Capability version */
328#define PCI_EXP_FLAGS_TYPE 0x00f0 /* Device/Port type */
329#define PCI_EXP_TYPE_ENDPOINT 0x0 /* Express Endpoint */
330#define PCI_EXP_TYPE_LEG_END 0x1 /* Legacy Endpoint */
331#define PCI_EXP_TYPE_ROOT_PORT 0x4 /* Root Port */
332#define PCI_EXP_TYPE_UPSTREAM 0x5 /* Upstream Port */
333#define PCI_EXP_TYPE_DOWNSTREAM 0x6 /* Downstream Port */
334#define PCI_EXP_TYPE_PCI_BRIDGE 0x7 /* PCI/PCI-X Bridge */
335#define PCI_EXP_FLAGS_SLOT 0x0100 /* Slot implemented */
336#define PCI_EXP_FLAGS_IRQ 0x3e00 /* Interrupt message number */
337#define PCI_EXP_DEVCAP 4 /* Device capabilities */
338#define PCI_EXP_DEVCAP_PAYLOAD 0x07 /* Max_Payload_Size */
339#define PCI_EXP_DEVCAP_PHANTOM 0x18 /* Phantom functions */
340#define PCI_EXP_DEVCAP_EXT_TAG 0x20 /* Extended tags */
341#define PCI_EXP_DEVCAP_L0S 0x1c0 /* L0s Acceptable Latency */
342#define PCI_EXP_DEVCAP_L1 0xe00 /* L1 Acceptable Latency */
343#define PCI_EXP_DEVCAP_ATN_BUT 0x1000 /* Attention Button Present */
344#define PCI_EXP_DEVCAP_ATN_IND 0x2000 /* Attention Indicator Present */
345#define PCI_EXP_DEVCAP_PWR_IND 0x4000 /* Power Indicator Present */
346#define PCI_EXP_DEVCAP_PWR_VAL 0x3fc0000 /* Slot Power Limit Value */
347#define PCI_EXP_DEVCAP_PWR_SCL 0xc000000 /* Slot Power Limit Scale */
348#define PCI_EXP_DEVCTL 8 /* Device Control */
349#define PCI_EXP_DEVCTL_CERE 0x0001 /* Correctable Error Reporting En. */
350#define PCI_EXP_DEVCTL_NFERE 0x0002 /* Non-Fatal Error Reporting Enable */
351#define PCI_EXP_DEVCTL_FERE 0x0004 /* Fatal Error Reporting Enable */
352#define PCI_EXP_DEVCTL_URRE 0x0008 /* Unsupported Request Reporting En. */
353#define PCI_EXP_DEVCTL_RELAX_EN 0x0010 /* Enable relaxed ordering */
354#define PCI_EXP_DEVCTL_PAYLOAD 0x00e0 /* Max_Payload_Size */
355#define PCI_EXP_DEVCTL_EXT_TAG 0x0100 /* Extended Tag Field Enable */
356#define PCI_EXP_DEVCTL_PHANTOM 0x0200 /* Phantom Functions Enable */
357#define PCI_EXP_DEVCTL_AUX_PME 0x0400 /* Auxiliary Power PM Enable */
358#define PCI_EXP_DEVCTL_NOSNOOP_EN 0x0800 /* Enable No Snoop */
359#define PCI_EXP_DEVCTL_READRQ 0x7000 /* Max_Read_Request_Size */
360#define PCI_EXP_DEVSTA 10 /* Device Status */
361#define PCI_EXP_DEVSTA_CED 0x01 /* Correctable Error Detected */
362#define PCI_EXP_DEVSTA_NFED 0x02 /* Non-Fatal Error Detected */
363#define PCI_EXP_DEVSTA_FED 0x04 /* Fatal Error Detected */
364#define PCI_EXP_DEVSTA_URD 0x08 /* Unsupported Request Detected */
365#define PCI_EXP_DEVSTA_AUXPD 0x10 /* AUX Power Detected */
366#define PCI_EXP_DEVSTA_TRPND 0x20 /* Transactions Pending */
367#define PCI_EXP_LNKCAP 12 /* Link Capabilities */
368#define PCI_EXP_LNKCTL 16 /* Link Control */
369#define PCI_EXP_LNKSTA 18 /* Link Status */
370#define PCI_EXP_SLTCAP 20 /* Slot Capabilities */
371#define PCI_EXP_SLTCTL 24 /* Slot Control */
372#define PCI_EXP_SLTSTA 26 /* Slot Status */
373#define PCI_EXP_RTCTL 28 /* Root Control */
374#define PCI_EXP_RTCTL_SECEE 0x01 /* System Error on Correctable Error */
375#define PCI_EXP_RTCTL_SENFEE 0x02 /* System Error on Non-Fatal Error */
376#define PCI_EXP_RTCTL_SEFEE 0x04 /* System Error on Fatal Error */
377#define PCI_EXP_RTCTL_PMEIE 0x08 /* PME Interrupt Enable */
378#define PCI_EXP_RTCTL_CRSSVE 0x10 /* CRS Software Visibility Enable */
379#define PCI_EXP_RTCAP 30 /* Root Capabilities */
380#define PCI_EXP_RTSTA 32 /* Root Status */
381
382/* Extended Capabilities (PCI-X 2.0 and Express) */
383#define PCI_EXT_CAP_ID(header) (header & 0x0000ffff)
384#define PCI_EXT_CAP_VER(header) ((header >> 16) & 0xf)
385#define PCI_EXT_CAP_NEXT(header) ((header >> 20) & 0xffc)
386
387#define PCI_EXT_CAP_ID_ERR 1
388#define PCI_EXT_CAP_ID_VC 2
389#define PCI_EXT_CAP_ID_DSN 3
390#define PCI_EXT_CAP_ID_PWR 4
391
392/* Advanced Error Reporting */
393#define PCI_ERR_UNCOR_STATUS 4 /* Uncorrectable Error Status */
394#define PCI_ERR_UNC_TRAIN 0x00000001 /* Training */
395#define PCI_ERR_UNC_DLP 0x00000010 /* Data Link Protocol */
396#define PCI_ERR_UNC_POISON_TLP 0x00001000 /* Poisoned TLP */
397#define PCI_ERR_UNC_FCP 0x00002000 /* Flow Control Protocol */
398#define PCI_ERR_UNC_COMP_TIME 0x00004000 /* Completion Timeout */
399#define PCI_ERR_UNC_COMP_ABORT 0x00008000 /* Completer Abort */
400#define PCI_ERR_UNC_UNX_COMP 0x00010000 /* Unexpected Completion */
401#define PCI_ERR_UNC_RX_OVER 0x00020000 /* Receiver Overflow */
402#define PCI_ERR_UNC_MALF_TLP 0x00040000 /* Malformed TLP */
403#define PCI_ERR_UNC_ECRC 0x00080000 /* ECRC Error Status */
404#define PCI_ERR_UNC_UNSUP 0x00100000 /* Unsupported Request */
405#define PCI_ERR_UNCOR_MASK 8 /* Uncorrectable Error Mask */
406 /* Same bits as above */
407#define PCI_ERR_UNCOR_SEVER 12 /* Uncorrectable Error Severity */
408 /* Same bits as above */
409#define PCI_ERR_COR_STATUS 16 /* Correctable Error Status */
410#define PCI_ERR_COR_RCVR 0x00000001 /* Receiver Error Status */
411#define PCI_ERR_COR_BAD_TLP 0x00000040 /* Bad TLP Status */
412#define PCI_ERR_COR_BAD_DLLP 0x00000080 /* Bad DLLP Status */
413#define PCI_ERR_COR_REP_ROLL 0x00000100 /* REPLAY_NUM Rollover */
414#define PCI_ERR_COR_REP_TIMER 0x00001000 /* Replay Timer Timeout */
415#define PCI_ERR_COR_MASK 20 /* Correctable Error Mask */
416 /* Same bits as above */
417#define PCI_ERR_CAP 24 /* Advanced Error Capabilities */
418#define PCI_ERR_CAP_FEP(x) ((x) & 31) /* First Error Pointer */
419#define PCI_ERR_CAP_ECRC_GENC 0x00000020 /* ECRC Generation Capable */
420#define PCI_ERR_CAP_ECRC_GENE 0x00000040 /* ECRC Generation Enable */
421#define PCI_ERR_CAP_ECRC_CHKC 0x00000080 /* ECRC Check Capable */
422#define PCI_ERR_CAP_ECRC_CHKE 0x00000100 /* ECRC Check Enable */
423#define PCI_ERR_HEADER_LOG 28 /* Header Log Register (16 bytes) */
424#define PCI_ERR_ROOT_COMMAND 44 /* Root Error Command */
425#define PCI_ERR_ROOT_STATUS 48
426#define PCI_ERR_ROOT_COR_SRC 52
427#define PCI_ERR_ROOT_SRC 54
428
429/* Virtual Channel */
430#define PCI_VC_PORT_REG1 4
431#define PCI_VC_PORT_REG2 8
432#define PCI_VC_PORT_CTRL 12
433#define PCI_VC_PORT_STATUS 14
434#define PCI_VC_RES_CAP 16
435#define PCI_VC_RES_CTRL 20
436#define PCI_VC_RES_STATUS 26
437
438/* Power Budgeting */
439#define PCI_PWR_DSR 4 /* Data Select Register */
440#define PCI_PWR_DATA 8 /* Data Register */
441#define PCI_PWR_DATA_BASE(x) ((x) & 0xff) /* Base Power */
442#define PCI_PWR_DATA_SCALE(x) (((x) >> 8) & 3) /* Data Scale */
443#define PCI_PWR_DATA_PM_SUB(x) (((x) >> 10) & 7) /* PM Sub State */
444#define PCI_PWR_DATA_PM_STATE(x) (((x) >> 13) & 3) /* PM State */
445#define PCI_PWR_DATA_TYPE(x) (((x) >> 15) & 7) /* Type */
446#define PCI_PWR_DATA_RAIL(x) (((x) >> 18) & 7) /* Power Rail */
447#define PCI_PWR_CAP 12 /* Capability */
448#define PCI_PWR_CAP_BUDGET(x) ((x) & 1) /* Included in system budget */
449
450/* Include the ID list */
451
452#include <linux/pci_ids.h>
453
454/*
455 * The PCI interface treats multi-function devices as independent
456 * devices. The slot/function address of each device is encoded
457 * in a single byte as follows:
458 *
459 * 7:3 = slot
460 * 2:0 = function
461 */
462#define PCI_DEVFN(slot,func) ((((slot) & 0x1f) << 3) | ((func) & 0x07))
463#define PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f)
464#define PCI_FUNC(devfn) ((devfn) & 0x07)
465
466/* Ioctls for /proc/bus/pci/X/Y nodes. */
467#define PCIIOC_BASE ('P' << 24 | 'C' << 16 | 'I' << 8)
468#define PCIIOC_CONTROLLER (PCIIOC_BASE | 0x00) /* Get controller for PCI device. */
469#define PCIIOC_MMAP_IS_IO (PCIIOC_BASE | 0x01) /* Set mmap state to I/O space. */
470#define PCIIOC_MMAP_IS_MEM (PCIIOC_BASE | 0x02) /* Set mmap state to MEM space. */
471#define PCIIOC_WRITE_COMBINE (PCIIOC_BASE | 0x03) /* Enable/disable write-combining. */
472
473#ifdef __KERNEL__
474
475#include <linux/types.h>
476#include <linux/config.h>
477#include <linux/ioport.h>
478#include <linux/list.h>
479#include <linux/errno.h>
480#include <linux/device.h>
481
482/* File state for mmap()s on /proc/bus/pci/X/Y */
483enum pci_mmap_state {
484 pci_mmap_io,
485 pci_mmap_mem
486};
487
488/* This defines the direction arg to the DMA mapping routines. */
489#define PCI_DMA_BIDIRECTIONAL 0
490#define PCI_DMA_TODEVICE 1
491#define PCI_DMA_FROMDEVICE 2
492#define PCI_DMA_NONE 3
493
494#define DEVICE_COUNT_COMPATIBLE 4
495#define DEVICE_COUNT_RESOURCE 12
496
497typedef int __bitwise pci_power_t;
498
499#define PCI_D0 ((pci_power_t __force) 0)
500#define PCI_D1 ((pci_power_t __force) 1)
501#define PCI_D2 ((pci_power_t __force) 2)
502#define PCI_D3hot ((pci_power_t __force) 3)
503#define PCI_D3cold ((pci_power_t __force) 4)
504
505/*
506 * The pci_dev structure is used to describe PCI devices.
507 */
508struct pci_dev {
509 struct list_head global_list; /* node in list of all PCI devices */
510 struct list_head bus_list; /* node in per-bus list */
511 struct pci_bus *bus; /* bus this device is on */
512 struct pci_bus *subordinate; /* bus this device bridges to */
513
514 void *sysdata; /* hook for sys-specific extension */
515 struct proc_dir_entry *procent; /* device entry in /proc/bus/pci */
516
517 unsigned int devfn; /* encoded device & function index */
518 unsigned short vendor;
519 unsigned short device;
520 unsigned short subsystem_vendor;
521 unsigned short subsystem_device;
522 unsigned int class; /* 3 bytes: (base,sub,prog-if) */
523 u8 hdr_type; /* PCI header type (`multi' flag masked out) */
524 u8 rom_base_reg; /* which config register controls the ROM */
525
526 struct pci_driver *driver; /* which driver has allocated this device */
527 u64 dma_mask; /* Mask of the bits of bus address this
528 device implements. Normally this is
529 0xffffffff. You only need to change
530 this if your device has broken DMA
531 or supports 64-bit transfers. */
532
533 pci_power_t current_state; /* Current operating state. In ACPI-speak,
534 this is D0-D3, D0 being fully functional,
535 and D3 being off. */
536
537 struct device dev; /* Generic device interface */
538
539 /* device is compatible with these IDs */
540 unsigned short vendor_compatible[DEVICE_COUNT_COMPATIBLE];
541 unsigned short device_compatible[DEVICE_COUNT_COMPATIBLE];
542
543 int cfg_size; /* Size of configuration space */
544
545 /*
546 * Instead of touching interrupt line and base address registers
547 * directly, use the values stored here. They might be different!
548 */
549 unsigned int irq;
550 struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */
551
552 /* These fields are used by common fixups */
553 unsigned int transparent:1; /* Transparent PCI bridge */
554 unsigned int multifunction:1;/* Part of multi-function device */
555 /* keep track of device state */
556 unsigned int is_enabled:1; /* pci_enable_device has been called */
557 unsigned int is_busmaster:1; /* device is busmaster */
558
559 u32 saved_config_space[16]; /* config space saved at suspend time */
560 struct bin_attribute *rom_attr; /* attribute descriptor for sysfs ROM entry */
561 int rom_attr_enabled; /* has display of the rom attribute been enabled? */
562 struct bin_attribute *res_attr[DEVICE_COUNT_RESOURCE]; /* sysfs file for resources */
563#ifdef CONFIG_PCI_NAMES
564#define PCI_NAME_SIZE 255
565#define PCI_NAME_HALF __stringify(43) /* less than half to handle slop */
566 char pretty_name[PCI_NAME_SIZE]; /* pretty name for users to see */
567#endif
568};
569
570#define pci_dev_g(n) list_entry(n, struct pci_dev, global_list)
571#define pci_dev_b(n) list_entry(n, struct pci_dev, bus_list)
572#define to_pci_dev(n) container_of(n, struct pci_dev, dev)
573#define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL)
574
575/*
576 * For PCI devices, the region numbers are assigned this way:
577 *
578 * 0-5 standard PCI regions
579 * 6 expansion ROM
580 * 7-10 bridges: address space assigned to buses behind the bridge
581 */
582
583#define PCI_ROM_RESOURCE 6
584#define PCI_BRIDGE_RESOURCES 7
585#define PCI_NUM_RESOURCES 11
586
587#ifndef PCI_BUS_NUM_RESOURCES
588#define PCI_BUS_NUM_RESOURCES 4
589#endif
590
591#define PCI_REGION_FLAG_MASK 0x0fU /* These bits of resource flags tell us the PCI region flags */
592
593struct pci_bus {
594 struct list_head node; /* node in list of buses */
595 struct pci_bus *parent; /* parent bus this bridge is on */
596 struct list_head children; /* list of child buses */
597 struct list_head devices; /* list of devices on this bus */
598 struct pci_dev *self; /* bridge device as seen by parent */
599 struct resource *resource[PCI_BUS_NUM_RESOURCES];
600 /* address space routed to this bus */
601
602 struct pci_ops *ops; /* configuration access functions */
603 void *sysdata; /* hook for sys-specific extension */
604 struct proc_dir_entry *procdir; /* directory entry in /proc/bus/pci */
605
606 unsigned char number; /* bus number */
607 unsigned char primary; /* number of primary bridge */
608 unsigned char secondary; /* number of secondary bridge */
609 unsigned char subordinate; /* max number of subordinate buses */
610
611 char name[48];
612
613 unsigned short bridge_ctl; /* manage NO_ISA/FBB/et al behaviors */
614 unsigned short pad2;
615 struct device *bridge;
616 struct class_device class_dev;
617 struct bin_attribute *legacy_io; /* legacy I/O for this bus */
618 struct bin_attribute *legacy_mem; /* legacy mem */
619};
620
621#define pci_bus_b(n) list_entry(n, struct pci_bus, node)
622#define to_pci_bus(n) container_of(n, struct pci_bus, class_dev)
623
624/*
625 * Error values that may be returned by PCI functions.
626 */
627#define PCIBIOS_SUCCESSFUL 0x00
628#define PCIBIOS_FUNC_NOT_SUPPORTED 0x81
629#define PCIBIOS_BAD_VENDOR_ID 0x83
630#define PCIBIOS_DEVICE_NOT_FOUND 0x86
631#define PCIBIOS_BAD_REGISTER_NUMBER 0x87
632#define PCIBIOS_SET_FAILED 0x88
633#define PCIBIOS_BUFFER_TOO_SMALL 0x89
634
635/* Low-level architecture-dependent routines */
636
637struct pci_ops {
638 int (*read)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val);
639 int (*write)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val);
640};
641
642struct pci_raw_ops {
643 int (*read)(unsigned int domain, unsigned int bus, unsigned int devfn,
644 int reg, int len, u32 *val);
645 int (*write)(unsigned int domain, unsigned int bus, unsigned int devfn,
646 int reg, int len, u32 val);
647};
648
649extern struct pci_raw_ops *raw_pci_ops;
650
651struct pci_bus_region {
652 unsigned long start;
653 unsigned long end;
654};
655
656struct pci_dynids {
657 spinlock_t lock; /* protects list, index */
658 struct list_head list; /* for IDs added at runtime */
659 unsigned int use_driver_data:1; /* pci_driver->driver_data is used */
660};
661
662struct module;
663struct pci_driver {
664 struct list_head node;
665 char *name;
666 struct module *owner;
667 const struct pci_device_id *id_table; /* must be non-NULL for probe to be called */
668 int (*probe) (struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */
669 void (*remove) (struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */
670 int (*suspend) (struct pci_dev *dev, pm_message_t state); /* Device suspended */
671 int (*resume) (struct pci_dev *dev); /* Device woken up */
672 int (*enable_wake) (struct pci_dev *dev, u32 state, int enable); /* Enable wake event */
673
674 struct device_driver driver;
675 struct pci_dynids dynids;
676};
677
678#define to_pci_driver(drv) container_of(drv,struct pci_driver, driver)
679
680/**
681 * PCI_DEVICE - macro used to describe a specific pci device
682 * @vend: the 16 bit PCI Vendor ID
683 * @dev: the 16 bit PCI Device ID
684 *
685 * This macro is used to create a struct pci_device_id that matches a
686 * specific device. The subvendor and subdevice fields will be set to
687 * PCI_ANY_ID.
688 */
689#define PCI_DEVICE(vend,dev) \
690 .vendor = (vend), .device = (dev), \
691 .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
692
693/**
694 * PCI_DEVICE_CLASS - macro used to describe a specific pci device class
695 * @dev_class: the class, subclass, prog-if triple for this device
696 * @dev_class_mask: the class mask for this device
697 *
698 * This macro is used to create a struct pci_device_id that matches a
699 * specific PCI class. The vendor, device, subvendor, and subdevice
700 * fields will be set to PCI_ANY_ID.
701 */
702#define PCI_DEVICE_CLASS(dev_class,dev_class_mask) \
703 .class = (dev_class), .class_mask = (dev_class_mask), \
704 .vendor = PCI_ANY_ID, .device = PCI_ANY_ID, \
705 .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
706
707/*
708 * pci_module_init is obsolete, this stays here till we fix up all usages of it
709 * in the tree.
710 */
711#define pci_module_init pci_register_driver
712
713/* these external functions are only available when PCI support is enabled */
714#ifdef CONFIG_PCI
715
716extern struct bus_type pci_bus_type;
717
718/* Do NOT directly access these two variables, unless you are arch specific pci
719 * code, or pci core code. */
720extern struct list_head pci_root_buses; /* list of all known PCI buses */
721extern struct list_head pci_devices; /* list of all devices */
722
723void pcibios_fixup_bus(struct pci_bus *);
724int pcibios_enable_device(struct pci_dev *, int mask);
725char *pcibios_setup (char *str);
726
727/* Used only when drivers/pci/setup.c is used */
728void pcibios_align_resource(void *, struct resource *,
729 unsigned long, unsigned long);
730void pcibios_update_irq(struct pci_dev *, int irq);
731
732/* Generic PCI functions used internally */
733
734extern struct pci_bus *pci_find_bus(int domain, int busnr);
735struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus, struct pci_ops *ops, void *sysdata);
736static inline struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata)
737{
738 return pci_scan_bus_parented(NULL, bus, ops, sysdata);
739}
740int pci_scan_slot(struct pci_bus *bus, int devfn);
741struct pci_dev * pci_scan_single_device(struct pci_bus *bus, int devfn);
742unsigned int pci_scan_child_bus(struct pci_bus *bus);
743void pci_bus_add_device(struct pci_dev *dev);
744void pci_bus_add_devices(struct pci_bus *bus);
745void pci_name_device(struct pci_dev *dev);
746char *pci_class_name(u32 class);
747void pci_read_bridge_bases(struct pci_bus *child);
748struct resource *pci_find_parent_resource(const struct pci_dev *dev, struct resource *res);
749int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge);
750extern struct pci_dev *pci_dev_get(struct pci_dev *dev);
751extern void pci_dev_put(struct pci_dev *dev);
752extern void pci_remove_bus(struct pci_bus *b);
753extern void pci_remove_bus_device(struct pci_dev *dev);
754
755/* Generic PCI functions exported to card drivers */
756
757struct pci_dev *pci_find_device (unsigned int vendor, unsigned int device, const struct pci_dev *from);
758struct pci_dev *pci_find_device_reverse (unsigned int vendor, unsigned int device, const struct pci_dev *from);
759struct pci_dev *pci_find_slot (unsigned int bus, unsigned int devfn);
760int pci_find_capability (struct pci_dev *dev, int cap);
761int pci_find_ext_capability (struct pci_dev *dev, int cap);
762struct pci_bus * pci_find_next_bus(const struct pci_bus *from);
763
764struct pci_dev *pci_get_device (unsigned int vendor, unsigned int device, struct pci_dev *from);
765struct pci_dev *pci_get_subsys (unsigned int vendor, unsigned int device,
766 unsigned int ss_vendor, unsigned int ss_device,
767 struct pci_dev *from);
768struct pci_dev *pci_get_slot (struct pci_bus *bus, unsigned int devfn);
769struct pci_dev *pci_get_class (unsigned int class, struct pci_dev *from);
770int pci_dev_present(const struct pci_device_id *ids);
771
772int pci_bus_read_config_byte (struct pci_bus *bus, unsigned int devfn, int where, u8 *val);
773int pci_bus_read_config_word (struct pci_bus *bus, unsigned int devfn, int where, u16 *val);
774int pci_bus_read_config_dword (struct pci_bus *bus, unsigned int devfn, int where, u32 *val);
775int pci_bus_write_config_byte (struct pci_bus *bus, unsigned int devfn, int where, u8 val);
776int pci_bus_write_config_word (struct pci_bus *bus, unsigned int devfn, int where, u16 val);
777int pci_bus_write_config_dword (struct pci_bus *bus, unsigned int devfn, int where, u32 val);
778
779static inline int pci_read_config_byte(struct pci_dev *dev, int where, u8 *val)
780{
781 return pci_bus_read_config_byte (dev->bus, dev->devfn, where, val);
782}
783static inline int pci_read_config_word(struct pci_dev *dev, int where, u16 *val)
784{
785 return pci_bus_read_config_word (dev->bus, dev->devfn, where, val);
786}
787static inline int pci_read_config_dword(struct pci_dev *dev, int where, u32 *val)
788{
789 return pci_bus_read_config_dword (dev->bus, dev->devfn, where, val);
790}
791static inline int pci_write_config_byte(struct pci_dev *dev, int where, u8 val)
792{
793 return pci_bus_write_config_byte (dev->bus, dev->devfn, where, val);
794}
795static inline int pci_write_config_word(struct pci_dev *dev, int where, u16 val)
796{
797 return pci_bus_write_config_word (dev->bus, dev->devfn, where, val);
798}
799static inline int pci_write_config_dword(struct pci_dev *dev, int where, u32 val)
800{
801 return pci_bus_write_config_dword (dev->bus, dev->devfn, where, val);
802}
803
804int pci_enable_device(struct pci_dev *dev);
805int pci_enable_device_bars(struct pci_dev *dev, int mask);
806void pci_disable_device(struct pci_dev *dev);
807void pci_set_master(struct pci_dev *dev);
808#define HAVE_PCI_SET_MWI
809int pci_set_mwi(struct pci_dev *dev);
810void pci_clear_mwi(struct pci_dev *dev);
811int pci_set_dma_mask(struct pci_dev *dev, u64 mask);
812int pci_dac_set_dma_mask(struct pci_dev *dev, u64 mask);
813int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask);
814int pci_assign_resource(struct pci_dev *dev, int i);
815
816/* ROM control related routines */
817void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size);
818void __iomem *pci_map_rom_copy(struct pci_dev *pdev, size_t *size);
819void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom);
820void pci_remove_rom(struct pci_dev *pdev);
821
822/* Power management related routines */
823int pci_save_state(struct pci_dev *dev);
824int pci_restore_state(struct pci_dev *dev);
825int pci_set_power_state(struct pci_dev *dev, pci_power_t state);
826pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state);
827int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable);
828
829/* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */
830void pci_bus_assign_resources(struct pci_bus *bus);
831void pci_bus_size_bridges(struct pci_bus *bus);
832int pci_claim_resource(struct pci_dev *, int);
833void pci_assign_unassigned_resources(void);
834void pdev_enable_device(struct pci_dev *);
835void pdev_sort_resources(struct pci_dev *, struct resource_list *);
836void pci_fixup_irqs(u8 (*)(struct pci_dev *, u8 *),
837 int (*)(struct pci_dev *, u8, u8));
838#define HAVE_PCI_REQ_REGIONS 2
839int pci_request_regions(struct pci_dev *, char *);
840void pci_release_regions(struct pci_dev *);
841int pci_request_region(struct pci_dev *, int, char *);
842void pci_release_region(struct pci_dev *, int);
843
844/* drivers/pci/bus.c */
845int pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
846 unsigned long size, unsigned long align,
847 unsigned long min, unsigned int type_mask,
848 void (*alignf)(void *, struct resource *,
849 unsigned long, unsigned long),
850 void *alignf_data);
851void pci_enable_bridges(struct pci_bus *bus);
852
853/* New-style probing supporting hot-pluggable devices */
854int pci_register_driver(struct pci_driver *);
855void pci_unregister_driver(struct pci_driver *);
856void pci_remove_behind_bridge(struct pci_dev *);
857struct pci_driver *pci_dev_driver(const struct pci_dev *);
858const struct pci_device_id *pci_match_device(const struct pci_device_id *ids, const struct pci_dev *dev);
859int pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max, int pass);
860
861/* kmem_cache style wrapper around pci_alloc_consistent() */
862
863#include <linux/dmapool.h>
864
865#define pci_pool dma_pool
866#define pci_pool_create(name, pdev, size, align, allocation) \
867 dma_pool_create(name, &pdev->dev, size, align, allocation)
868#define pci_pool_destroy(pool) dma_pool_destroy(pool)
869#define pci_pool_alloc(pool, flags, handle) dma_pool_alloc(pool, flags, handle)
870#define pci_pool_free(pool, vaddr, addr) dma_pool_free(pool, vaddr, addr)
871
872#if defined(CONFIG_ISA) || defined(CONFIG_EISA)
873extern struct pci_dev *isa_bridge;
874#endif
875
876struct msix_entry {
877 u16 vector; /* kernel uses to write allocated vector */
878 u16 entry; /* driver uses to specify entry, OS writes */
879};
880
881#ifndef CONFIG_PCI_MSI
882static inline void pci_scan_msi_device(struct pci_dev *dev) {}
883static inline int pci_enable_msi(struct pci_dev *dev) {return -1;}
884static inline void pci_disable_msi(struct pci_dev *dev) {}
885static inline int pci_enable_msix(struct pci_dev* dev,
886 struct msix_entry *entries, int nvec) {return -1;}
887static inline void pci_disable_msix(struct pci_dev *dev) {}
888static inline void msi_remove_pci_irq_vectors(struct pci_dev *dev) {}
889#else
890extern void pci_scan_msi_device(struct pci_dev *dev);
891extern int pci_enable_msi(struct pci_dev *dev);
892extern void pci_disable_msi(struct pci_dev *dev);
893extern int pci_enable_msix(struct pci_dev* dev,
894 struct msix_entry *entries, int nvec);
895extern void pci_disable_msix(struct pci_dev *dev);
896extern void msi_remove_pci_irq_vectors(struct pci_dev *dev);
897#endif
898
899#endif /* CONFIG_PCI */
900
901/* Include architecture-dependent settings and functions */
902
903#include <asm/pci.h>
904
905/*
906 * If the system does not have PCI, clearly these return errors. Define
907 * these as simple inline functions to avoid hair in drivers.
908 */
909
910#ifndef CONFIG_PCI
911#define _PCI_NOP(o,s,t) \
912 static inline int pci_##o##_config_##s (struct pci_dev *dev, int where, t val) \
913 { return PCIBIOS_FUNC_NOT_SUPPORTED; }
914#define _PCI_NOP_ALL(o,x) _PCI_NOP(o,byte,u8 x) \
915 _PCI_NOP(o,word,u16 x) \
916 _PCI_NOP(o,dword,u32 x)
917_PCI_NOP_ALL(read, *)
918_PCI_NOP_ALL(write,)
919
920static inline struct pci_dev *pci_find_device(unsigned int vendor, unsigned int device, const struct pci_dev *from)
921{ return NULL; }
922
923static inline struct pci_dev *pci_find_slot(unsigned int bus, unsigned int devfn)
924{ return NULL; }
925
926static inline struct pci_dev *pci_get_device (unsigned int vendor, unsigned int device, struct pci_dev *from)
927{ return NULL; }
928
929static inline struct pci_dev *pci_get_subsys (unsigned int vendor, unsigned int device,
930unsigned int ss_vendor, unsigned int ss_device, struct pci_dev *from)
931{ return NULL; }
932
933static inline struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from)
934{ return NULL; }
935
936#define pci_dev_present(ids) (0)
937#define pci_dev_put(dev) do { } while (0)
938
939static inline void pci_set_master(struct pci_dev *dev) { }
940static inline int pci_enable_device(struct pci_dev *dev) { return -EIO; }
941static inline void pci_disable_device(struct pci_dev *dev) { }
942static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask) { return -EIO; }
943static inline int pci_dac_set_dma_mask(struct pci_dev *dev, u64 mask) { return -EIO; }
944static inline int pci_assign_resource(struct pci_dev *dev, int i) { return -EBUSY;}
945static inline int pci_register_driver(struct pci_driver *drv) { return 0;}
946static inline void pci_unregister_driver(struct pci_driver *drv) { }
947static inline int pci_find_capability (struct pci_dev *dev, int cap) {return 0; }
948static inline int pci_find_ext_capability (struct pci_dev *dev, int cap) {return 0; }
949static inline const struct pci_device_id *pci_match_device(const struct pci_device_id *ids, const struct pci_dev *dev) { return NULL; }
950
951/* Power management related routines */
952static inline int pci_save_state(struct pci_dev *dev) { return 0; }
953static inline int pci_restore_state(struct pci_dev *dev) { return 0; }
954static inline int pci_set_power_state(struct pci_dev *dev, pci_power_t state) { return 0; }
955static inline pci_power_t pci_choose_state(struct pci_dev *dev, u32 state) { return PCI_D0; }
956static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable) { return 0; }
957
958#define isa_bridge ((struct pci_dev *)NULL)
959
960#else
961
962/*
963 * PCI domain support. Sometimes called PCI segment (eg by ACPI),
964 * a PCI domain is defined to be a set of PCI busses which share
965 * configuration space.
966 */
967#ifndef CONFIG_PCI_DOMAINS
968static inline int pci_domain_nr(struct pci_bus *bus) { return 0; }
969static inline int pci_proc_domain(struct pci_bus *bus)
970{
971 return 0;
972}
973#endif
974
975#endif /* !CONFIG_PCI */
976
977/* these helpers provide future and backwards compatibility
978 * for accessing popular PCI BAR info */
979#define pci_resource_start(dev,bar) ((dev)->resource[(bar)].start)
980#define pci_resource_end(dev,bar) ((dev)->resource[(bar)].end)
981#define pci_resource_flags(dev,bar) ((dev)->resource[(bar)].flags)
982#define pci_resource_len(dev,bar) \
983 ((pci_resource_start((dev),(bar)) == 0 && \
984 pci_resource_end((dev),(bar)) == \
985 pci_resource_start((dev),(bar))) ? 0 : \
986 \
987 (pci_resource_end((dev),(bar)) - \
988 pci_resource_start((dev),(bar)) + 1))
989
990/* Similar to the helpers above, these manipulate per-pci_dev
991 * driver-specific data. They are really just a wrapper around
992 * the generic device structure functions of these calls.
993 */
994static inline void *pci_get_drvdata (struct pci_dev *pdev)
995{
996 return dev_get_drvdata(&pdev->dev);
997}
998
999static inline void pci_set_drvdata (struct pci_dev *pdev, void *data)
1000{
1001 dev_set_drvdata(&pdev->dev, data);
1002}
1003
1004/* If you want to know what to call your pci_dev, ask this function.
1005 * Again, it's a wrapper around the generic device.
1006 */
1007static inline char *pci_name(struct pci_dev *pdev)
1008{
1009 return pdev->dev.bus_id;
1010}
1011
1012/* Some archs want to see the pretty pci name, so use this macro */
1013#ifdef CONFIG_PCI_NAMES
1014#define pci_pretty_name(dev) ((dev)->pretty_name)
1015#else
1016#define pci_pretty_name(dev) ""
1017#endif
1018
1019/*
1020 * The world is not perfect and supplies us with broken PCI devices.
1021 * For at least a part of these bugs we need a work-around, so both
1022 * generic (drivers/pci/quirks.c) and per-architecture code can define
1023 * fixup hooks to be called for particular buggy devices.
1024 */
1025
1026struct pci_fixup {
1027 u16 vendor, device; /* You can use PCI_ANY_ID here of course */
1028 void (*hook)(struct pci_dev *dev);
1029};
1030
1031enum pci_fixup_pass {
1032 pci_fixup_early, /* Before probing BARs */
1033 pci_fixup_header, /* After reading configuration header */
1034 pci_fixup_final, /* Final phase of device fixups */
1035 pci_fixup_enable, /* pci_enable_device() time */
1036};
1037
1038/* Anonymous variables would be nice... */
1039#define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, hook) \
1040 static struct pci_fixup __pci_fixup_##name __attribute_used__ \
1041 __attribute__((__section__(#section))) = { vendor, device, hook };
1042#define DECLARE_PCI_FIXUP_EARLY(vendor, device, hook) \
1043 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early, \
1044 vendor##device##hook, vendor, device, hook)
1045#define DECLARE_PCI_FIXUP_HEADER(vendor, device, hook) \
1046 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_header, \
1047 vendor##device##hook, vendor, device, hook)
1048#define DECLARE_PCI_FIXUP_FINAL(vendor, device, hook) \
1049 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_final, \
1050 vendor##device##hook, vendor, device, hook)
1051#define DECLARE_PCI_FIXUP_ENABLE(vendor, device, hook) \
1052 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_enable, \
1053 vendor##device##hook, vendor, device, hook)
1054
1055
1056void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev);
1057
1058extern int pci_pci_problems;
1059#define PCIPCI_FAIL 1
1060#define PCIPCI_TRITON 2
1061#define PCIPCI_NATOMA 4
1062#define PCIPCI_VIAETBF 8
1063#define PCIPCI_VSFX 16
1064#define PCIPCI_ALIMAGIK 32
1065
1066#endif /* __KERNEL__ */
1067#endif /* LINUX_PCI_H */
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
new file mode 100644
index 000000000000..de33f6724867
--- /dev/null
+++ b/include/linux/pci_ids.h
@@ -0,0 +1,2562 @@
1/*
2 * PCI Class, Vendor and Device IDs
3 *
4 * Please keep sorted.
5 */
6
7/* Device classes and subclasses */
8
9#define PCI_CLASS_NOT_DEFINED 0x0000
10#define PCI_CLASS_NOT_DEFINED_VGA 0x0001
11
12#define PCI_BASE_CLASS_STORAGE 0x01
13#define PCI_CLASS_STORAGE_SCSI 0x0100
14#define PCI_CLASS_STORAGE_IDE 0x0101
15#define PCI_CLASS_STORAGE_FLOPPY 0x0102
16#define PCI_CLASS_STORAGE_IPI 0x0103
17#define PCI_CLASS_STORAGE_RAID 0x0104
18#define PCI_CLASS_STORAGE_OTHER 0x0180
19
20#define PCI_BASE_CLASS_NETWORK 0x02
21#define PCI_CLASS_NETWORK_ETHERNET 0x0200
22#define PCI_CLASS_NETWORK_TOKEN_RING 0x0201
23#define PCI_CLASS_NETWORK_FDDI 0x0202
24#define PCI_CLASS_NETWORK_ATM 0x0203
25#define PCI_CLASS_NETWORK_OTHER 0x0280
26
27#define PCI_BASE_CLASS_DISPLAY 0x03
28#define PCI_CLASS_DISPLAY_VGA 0x0300
29#define PCI_CLASS_DISPLAY_XGA 0x0301
30#define PCI_CLASS_DISPLAY_3D 0x0302
31#define PCI_CLASS_DISPLAY_OTHER 0x0380
32
33#define PCI_BASE_CLASS_MULTIMEDIA 0x04
34#define PCI_CLASS_MULTIMEDIA_VIDEO 0x0400
35#define PCI_CLASS_MULTIMEDIA_AUDIO 0x0401
36#define PCI_CLASS_MULTIMEDIA_PHONE 0x0402
37#define PCI_CLASS_MULTIMEDIA_OTHER 0x0480
38
39#define PCI_BASE_CLASS_MEMORY 0x05
40#define PCI_CLASS_MEMORY_RAM 0x0500
41#define PCI_CLASS_MEMORY_FLASH 0x0501
42#define PCI_CLASS_MEMORY_OTHER 0x0580
43
44#define PCI_BASE_CLASS_BRIDGE 0x06
45#define PCI_CLASS_BRIDGE_HOST 0x0600
46#define PCI_CLASS_BRIDGE_ISA 0x0601
47#define PCI_CLASS_BRIDGE_EISA 0x0602
48#define PCI_CLASS_BRIDGE_MC 0x0603
49#define PCI_CLASS_BRIDGE_PCI 0x0604
50#define PCI_CLASS_BRIDGE_PCMCIA 0x0605
51#define PCI_CLASS_BRIDGE_NUBUS 0x0606
52#define PCI_CLASS_BRIDGE_CARDBUS 0x0607
53#define PCI_CLASS_BRIDGE_RACEWAY 0x0608
54#define PCI_CLASS_BRIDGE_OTHER 0x0680
55
56#define PCI_BASE_CLASS_COMMUNICATION 0x07
57#define PCI_CLASS_COMMUNICATION_SERIAL 0x0700
58#define PCI_CLASS_COMMUNICATION_PARALLEL 0x0701
59#define PCI_CLASS_COMMUNICATION_MULTISERIAL 0x0702
60#define PCI_CLASS_COMMUNICATION_MODEM 0x0703
61#define PCI_CLASS_COMMUNICATION_OTHER 0x0780
62
63#define PCI_BASE_CLASS_SYSTEM 0x08
64#define PCI_CLASS_SYSTEM_PIC 0x0800
65#define PCI_CLASS_SYSTEM_DMA 0x0801
66#define PCI_CLASS_SYSTEM_TIMER 0x0802
67#define PCI_CLASS_SYSTEM_RTC 0x0803
68#define PCI_CLASS_SYSTEM_PCI_HOTPLUG 0x0804
69#define PCI_CLASS_SYSTEM_OTHER 0x0880
70
71#define PCI_BASE_CLASS_INPUT 0x09
72#define PCI_CLASS_INPUT_KEYBOARD 0x0900
73#define PCI_CLASS_INPUT_PEN 0x0901
74#define PCI_CLASS_INPUT_MOUSE 0x0902
75#define PCI_CLASS_INPUT_SCANNER 0x0903
76#define PCI_CLASS_INPUT_GAMEPORT 0x0904
77#define PCI_CLASS_INPUT_OTHER 0x0980
78
79#define PCI_BASE_CLASS_DOCKING 0x0a
80#define PCI_CLASS_DOCKING_GENERIC 0x0a00
81#define PCI_CLASS_DOCKING_OTHER 0x0a80
82
83#define PCI_BASE_CLASS_PROCESSOR 0x0b
84#define PCI_CLASS_PROCESSOR_386 0x0b00
85#define PCI_CLASS_PROCESSOR_486 0x0b01
86#define PCI_CLASS_PROCESSOR_PENTIUM 0x0b02
87#define PCI_CLASS_PROCESSOR_ALPHA 0x0b10
88#define PCI_CLASS_PROCESSOR_POWERPC 0x0b20
89#define PCI_CLASS_PROCESSOR_MIPS 0x0b30
90#define PCI_CLASS_PROCESSOR_CO 0x0b40
91
92#define PCI_BASE_CLASS_SERIAL 0x0c
93#define PCI_CLASS_SERIAL_FIREWIRE 0x0c00
94#define PCI_CLASS_SERIAL_ACCESS 0x0c01
95#define PCI_CLASS_SERIAL_SSA 0x0c02
96#define PCI_CLASS_SERIAL_USB 0x0c03
97#define PCI_CLASS_SERIAL_FIBER 0x0c04
98#define PCI_CLASS_SERIAL_SMBUS 0x0c05
99
100#define PCI_BASE_CLASS_INTELLIGENT 0x0e
101#define PCI_CLASS_INTELLIGENT_I2O 0x0e00
102
103#define PCI_BASE_CLASS_SATELLITE 0x0f
104#define PCI_CLASS_SATELLITE_TV 0x0f00
105#define PCI_CLASS_SATELLITE_AUDIO 0x0f01
106#define PCI_CLASS_SATELLITE_VOICE 0x0f03
107#define PCI_CLASS_SATELLITE_DATA 0x0f04
108
109#define PCI_BASE_CLASS_CRYPT 0x10
110#define PCI_CLASS_CRYPT_NETWORK 0x1000
111#define PCI_CLASS_CRYPT_ENTERTAINMENT 0x1001
112#define PCI_CLASS_CRYPT_OTHER 0x1080
113
114#define PCI_BASE_CLASS_SIGNAL_PROCESSING 0x11
115#define PCI_CLASS_SP_DPIO 0x1100
116#define PCI_CLASS_SP_OTHER 0x1180
117
118#define PCI_CLASS_OTHERS 0xff
119
120/* Vendors and devices. Sort key: vendor first, device next. */
121
122#define PCI_VENDOR_ID_DYNALINK 0x0675
123#define PCI_DEVICE_ID_DYNALINK_IS64PH 0x1702
124
125#define PCI_VENDOR_ID_BERKOM 0x0871
126#define PCI_DEVICE_ID_BERKOM_A1T 0xffa1
127#define PCI_DEVICE_ID_BERKOM_T_CONCEPT 0xffa2
128#define PCI_DEVICE_ID_BERKOM_A4T 0xffa4
129#define PCI_DEVICE_ID_BERKOM_SCITEL_QUADRO 0xffa8
130
131#define PCI_VENDOR_ID_COMPAQ 0x0e11
132#define PCI_DEVICE_ID_COMPAQ_TOKENRING 0x0508
133#define PCI_DEVICE_ID_COMPAQ_1280 0x3033
134#define PCI_DEVICE_ID_COMPAQ_TRIFLEX 0x4000
135#define PCI_DEVICE_ID_COMPAQ_6010 0x6010
136#define PCI_DEVICE_ID_COMPAQ_TACHYON 0xa0fc
137#define PCI_DEVICE_ID_COMPAQ_SMART2P 0xae10
138#define PCI_DEVICE_ID_COMPAQ_NETEL100 0xae32
139#define PCI_DEVICE_ID_COMPAQ_NETEL10 0xae34
140#define PCI_DEVICE_ID_COMPAQ_TRIFLEX_IDE 0xae33
141#define PCI_DEVICE_ID_COMPAQ_NETFLEX3I 0xae35
142#define PCI_DEVICE_ID_COMPAQ_NETEL100D 0xae40
143#define PCI_DEVICE_ID_COMPAQ_NETEL100PI 0xae43
144#define PCI_DEVICE_ID_COMPAQ_NETEL100I 0xb011
145#define PCI_DEVICE_ID_COMPAQ_CISS 0xb060
146#define PCI_DEVICE_ID_COMPAQ_CISSB 0xb178
147#define PCI_DEVICE_ID_COMPAQ_CISSC 0x46
148#define PCI_DEVICE_ID_COMPAQ_THUNDER 0xf130
149#define PCI_DEVICE_ID_COMPAQ_NETFLEX3B 0xf150
150
151#define PCI_VENDOR_ID_NCR 0x1000
152#define PCI_VENDOR_ID_LSI_LOGIC 0x1000
153#define PCI_DEVICE_ID_NCR_53C810 0x0001
154#define PCI_DEVICE_ID_NCR_53C820 0x0002
155#define PCI_DEVICE_ID_NCR_53C825 0x0003
156#define PCI_DEVICE_ID_NCR_53C815 0x0004
157#define PCI_DEVICE_ID_LSI_53C810AP 0x0005
158#define PCI_DEVICE_ID_NCR_53C860 0x0006
159#define PCI_DEVICE_ID_LSI_53C1510 0x000a
160#define PCI_DEVICE_ID_NCR_53C896 0x000b
161#define PCI_DEVICE_ID_NCR_53C895 0x000c
162#define PCI_DEVICE_ID_NCR_53C885 0x000d
163#define PCI_DEVICE_ID_NCR_53C875 0x000f
164#define PCI_DEVICE_ID_NCR_53C1510 0x0010
165#define PCI_DEVICE_ID_LSI_53C895A 0x0012
166#define PCI_DEVICE_ID_LSI_53C875A 0x0013
167#define PCI_DEVICE_ID_LSI_53C1010_33 0x0020
168#define PCI_DEVICE_ID_LSI_53C1010_66 0x0021
169#define PCI_DEVICE_ID_LSI_53C1030 0x0030
170#define PCI_DEVICE_ID_LSI_1030_53C1035 0x0032
171#define PCI_DEVICE_ID_LSI_53C1035 0x0040
172#define PCI_DEVICE_ID_NCR_53C875J 0x008f
173#define PCI_DEVICE_ID_LSI_FC909 0x0621
174#define PCI_DEVICE_ID_LSI_FC929 0x0622
175#define PCI_DEVICE_ID_LSI_FC929_LAN 0x0623
176#define PCI_DEVICE_ID_LSI_FC919 0x0624
177#define PCI_DEVICE_ID_LSI_FC919_LAN 0x0625
178#define PCI_DEVICE_ID_LSI_FC929X 0x0626
179#define PCI_DEVICE_ID_LSI_FC939X 0x0642
180#define PCI_DEVICE_ID_LSI_FC949X 0x0640
181#define PCI_DEVICE_ID_LSI_FC919X 0x0628
182#define PCI_DEVICE_ID_NCR_YELLOWFIN 0x0701
183#define PCI_DEVICE_ID_LSI_61C102 0x0901
184#define PCI_DEVICE_ID_LSI_63C815 0x1000
185#define PCI_DEVICE_ID_LSI_SAS1064 0x0050
186#define PCI_DEVICE_ID_LSI_SAS1066 0x005E
187#define PCI_DEVICE_ID_LSI_SAS1068 0x0054
188#define PCI_DEVICE_ID_LSI_SAS1064A 0x005C
189#define PCI_DEVICE_ID_LSI_SAS1064E 0x0056
190#define PCI_DEVICE_ID_LSI_SAS1066E 0x005A
191#define PCI_DEVICE_ID_LSI_SAS1068E 0x0058
192#define PCI_DEVICE_ID_LSI_SAS1078 0x0060
193
194#define PCI_VENDOR_ID_ATI 0x1002
195/* Mach64 */
196#define PCI_DEVICE_ID_ATI_68800 0x4158
197#define PCI_DEVICE_ID_ATI_215CT222 0x4354
198#define PCI_DEVICE_ID_ATI_210888CX 0x4358
199#define PCI_DEVICE_ID_ATI_215ET222 0x4554
200/* Mach64 / Rage */
201#define PCI_DEVICE_ID_ATI_215GB 0x4742
202#define PCI_DEVICE_ID_ATI_215GD 0x4744
203#define PCI_DEVICE_ID_ATI_215GI 0x4749
204#define PCI_DEVICE_ID_ATI_215GP 0x4750
205#define PCI_DEVICE_ID_ATI_215GQ 0x4751
206#define PCI_DEVICE_ID_ATI_215XL 0x4752
207#define PCI_DEVICE_ID_ATI_215GT 0x4754
208#define PCI_DEVICE_ID_ATI_215GTB 0x4755
209#define PCI_DEVICE_ID_ATI_215_IV 0x4756
210#define PCI_DEVICE_ID_ATI_215_IW 0x4757
211#define PCI_DEVICE_ID_ATI_215_IZ 0x475A
212#define PCI_DEVICE_ID_ATI_210888GX 0x4758
213#define PCI_DEVICE_ID_ATI_215_LB 0x4c42
214#define PCI_DEVICE_ID_ATI_215_LD 0x4c44
215#define PCI_DEVICE_ID_ATI_215_LG 0x4c47
216#define PCI_DEVICE_ID_ATI_215_LI 0x4c49
217#define PCI_DEVICE_ID_ATI_215_LM 0x4c4D
218#define PCI_DEVICE_ID_ATI_215_LN 0x4c4E
219#define PCI_DEVICE_ID_ATI_215_LR 0x4c52
220#define PCI_DEVICE_ID_ATI_215_LS 0x4c53
221#define PCI_DEVICE_ID_ATI_264_LT 0x4c54
222/* Mach64 VT */
223#define PCI_DEVICE_ID_ATI_264VT 0x5654
224#define PCI_DEVICE_ID_ATI_264VU 0x5655
225#define PCI_DEVICE_ID_ATI_264VV 0x5656
226/* Rage128 GL */
227#define PCI_DEVICE_ID_ATI_RAGE128_RE 0x5245
228#define PCI_DEVICE_ID_ATI_RAGE128_RF 0x5246
229#define PCI_DEVICE_ID_ATI_RAGE128_RG 0x5247
230/* Rage128 VR */
231#define PCI_DEVICE_ID_ATI_RAGE128_RK 0x524b
232#define PCI_DEVICE_ID_ATI_RAGE128_RL 0x524c
233#define PCI_DEVICE_ID_ATI_RAGE128_SE 0x5345
234#define PCI_DEVICE_ID_ATI_RAGE128_SF 0x5346
235#define PCI_DEVICE_ID_ATI_RAGE128_SG 0x5347
236#define PCI_DEVICE_ID_ATI_RAGE128_SH 0x5348
237#define PCI_DEVICE_ID_ATI_RAGE128_SK 0x534b
238#define PCI_DEVICE_ID_ATI_RAGE128_SL 0x534c
239#define PCI_DEVICE_ID_ATI_RAGE128_SM 0x534d
240#define PCI_DEVICE_ID_ATI_RAGE128_SN 0x534e
241/* Rage128 Ultra */
242#define PCI_DEVICE_ID_ATI_RAGE128_TF 0x5446
243#define PCI_DEVICE_ID_ATI_RAGE128_TL 0x544c
244#define PCI_DEVICE_ID_ATI_RAGE128_TR 0x5452
245#define PCI_DEVICE_ID_ATI_RAGE128_TS 0x5453
246#define PCI_DEVICE_ID_ATI_RAGE128_TT 0x5454
247#define PCI_DEVICE_ID_ATI_RAGE128_TU 0x5455
248/* Rage128 M3 */
249#define PCI_DEVICE_ID_ATI_RAGE128_LE 0x4c45
250#define PCI_DEVICE_ID_ATI_RAGE128_LF 0x4c46
251/* Rage128 M4 */
252#define PCI_DEVICE_ID_ATI_RAGE128_MF 0x4d46
253#define PCI_DEVICE_ID_ATI_RAGE128_ML 0x4d4c
254/* Rage128 Pro GL */
255#define PCI_DEVICE_ID_ATI_RAGE128_PA 0x5041
256#define PCI_DEVICE_ID_ATI_RAGE128_PB 0x5042
257#define PCI_DEVICE_ID_ATI_RAGE128_PC 0x5043
258#define PCI_DEVICE_ID_ATI_RAGE128_PD 0x5044
259#define PCI_DEVICE_ID_ATI_RAGE128_PE 0x5045
260#define PCI_DEVICE_ID_ATI_RAGE128_PF 0x5046
261/* Rage128 Pro VR */
262#define PCI_DEVICE_ID_ATI_RAGE128_PG 0x5047
263#define PCI_DEVICE_ID_ATI_RAGE128_PH 0x5048
264#define PCI_DEVICE_ID_ATI_RAGE128_PI 0x5049
265#define PCI_DEVICE_ID_ATI_RAGE128_PJ 0x504A
266#define PCI_DEVICE_ID_ATI_RAGE128_PK 0x504B
267#define PCI_DEVICE_ID_ATI_RAGE128_PL 0x504C
268#define PCI_DEVICE_ID_ATI_RAGE128_PM 0x504D
269#define PCI_DEVICE_ID_ATI_RAGE128_PN 0x504E
270#define PCI_DEVICE_ID_ATI_RAGE128_PO 0x504F
271#define PCI_DEVICE_ID_ATI_RAGE128_PP 0x5050
272#define PCI_DEVICE_ID_ATI_RAGE128_PQ 0x5051
273#define PCI_DEVICE_ID_ATI_RAGE128_PR 0x5052
274#define PCI_DEVICE_ID_ATI_RAGE128_TR 0x5452
275#define PCI_DEVICE_ID_ATI_RAGE128_PS 0x5053
276#define PCI_DEVICE_ID_ATI_RAGE128_PT 0x5054
277#define PCI_DEVICE_ID_ATI_RAGE128_PU 0x5055
278#define PCI_DEVICE_ID_ATI_RAGE128_PV 0x5056
279#define PCI_DEVICE_ID_ATI_RAGE128_PW 0x5057
280#define PCI_DEVICE_ID_ATI_RAGE128_PX 0x5058
281/* Rage128 M4 */
282#define PCI_DEVICE_ID_ATI_RADEON_LE 0x4d45
283#define PCI_DEVICE_ID_ATI_RADEON_LF 0x4d46
284/* Radeon R100 */
285#define PCI_DEVICE_ID_ATI_RADEON_QD 0x5144
286#define PCI_DEVICE_ID_ATI_RADEON_QE 0x5145
287#define PCI_DEVICE_ID_ATI_RADEON_QF 0x5146
288#define PCI_DEVICE_ID_ATI_RADEON_QG 0x5147
289/* Radeon RV100 (VE) */
290#define PCI_DEVICE_ID_ATI_RADEON_QY 0x5159
291#define PCI_DEVICE_ID_ATI_RADEON_QZ 0x515a
292/* Radeon R200 (8500) */
293#define PCI_DEVICE_ID_ATI_RADEON_QL 0x514c
294#define PCI_DEVICE_ID_ATI_RADEON_QN 0x514e
295#define PCI_DEVICE_ID_ATI_RADEON_QO 0x514f
296#define PCI_DEVICE_ID_ATI_RADEON_Ql 0x516c
297#define PCI_DEVICE_ID_ATI_RADEON_BB 0x4242
298/* Radeon R200 (9100) */
299#define PCI_DEVICE_ID_ATI_RADEON_QM 0x514d
300/* Radeon RV200 (7500) */
301#define PCI_DEVICE_ID_ATI_RADEON_QW 0x5157
302#define PCI_DEVICE_ID_ATI_RADEON_QX 0x5158
303/* Radeon NV-100 */
304#define PCI_DEVICE_ID_ATI_RADEON_N1 0x5159
305#define PCI_DEVICE_ID_ATI_RADEON_N2 0x515a
306/* Radeon RV250 (9000) */
307#define PCI_DEVICE_ID_ATI_RADEON_Id 0x4964
308#define PCI_DEVICE_ID_ATI_RADEON_Ie 0x4965
309#define PCI_DEVICE_ID_ATI_RADEON_If 0x4966
310#define PCI_DEVICE_ID_ATI_RADEON_Ig 0x4967
311/* Radeon RV280 (9200) */
312#define PCI_DEVICE_ID_ATI_RADEON_Y_ 0x5960
313#define PCI_DEVICE_ID_ATI_RADEON_Ya 0x5961
314#define PCI_DEVICE_ID_ATI_RADEON_Yd 0x5964
315/* Radeon R300 (9500) */
316#define PCI_DEVICE_ID_ATI_RADEON_AD 0x4144
317/* Radeon R300 (9700) */
318#define PCI_DEVICE_ID_ATI_RADEON_ND 0x4e44
319#define PCI_DEVICE_ID_ATI_RADEON_NE 0x4e45
320#define PCI_DEVICE_ID_ATI_RADEON_NF 0x4e46
321#define PCI_DEVICE_ID_ATI_RADEON_NG 0x4e47
322#define PCI_DEVICE_ID_ATI_RADEON_AE 0x4145
323#define PCI_DEVICE_ID_ATI_RADEON_AF 0x4146
324/* Radeon R350 (9800) */
325#define PCI_DEVICE_ID_ATI_RADEON_NH 0x4e48
326#define PCI_DEVICE_ID_ATI_RADEON_NI 0x4e49
327/* Radeon RV350 (9600) */
328#define PCI_DEVICE_ID_ATI_RADEON_AP 0x4150
329#define PCI_DEVICE_ID_ATI_RADEON_AR 0x4152
330/* Radeon M6 */
331#define PCI_DEVICE_ID_ATI_RADEON_LY 0x4c59
332#define PCI_DEVICE_ID_ATI_RADEON_LZ 0x4c5a
333/* Radeon M7 */
334#define PCI_DEVICE_ID_ATI_RADEON_LW 0x4c57
335#define PCI_DEVICE_ID_ATI_RADEON_LX 0x4c58
336/* Radeon M9 */
337#define PCI_DEVICE_ID_ATI_RADEON_Ld 0x4c64
338#define PCI_DEVICE_ID_ATI_RADEON_Le 0x4c65
339#define PCI_DEVICE_ID_ATI_RADEON_Lf 0x4c66
340#define PCI_DEVICE_ID_ATI_RADEON_Lg 0x4c67
341/* Radeon */
342#define PCI_DEVICE_ID_ATI_RADEON_RA 0x5144
343#define PCI_DEVICE_ID_ATI_RADEON_RB 0x5145
344#define PCI_DEVICE_ID_ATI_RADEON_RC 0x5146
345#define PCI_DEVICE_ID_ATI_RADEON_RD 0x5147
346/* RadeonIGP */
347#define PCI_DEVICE_ID_ATI_RS100 0xcab0
348#define PCI_DEVICE_ID_ATI_RS200 0xcab2
349#define PCI_DEVICE_ID_ATI_RS200_B 0xcbb2
350#define PCI_DEVICE_ID_ATI_RS250 0xcab3
351#define PCI_DEVICE_ID_ATI_RS300_100 0x5830
352#define PCI_DEVICE_ID_ATI_RS300_133 0x5831
353#define PCI_DEVICE_ID_ATI_RS300_166 0x5832
354#define PCI_DEVICE_ID_ATI_RS300_200 0x5833
355#define PCI_DEVICE_ID_ATI_RS350_100 0x7830
356#define PCI_DEVICE_ID_ATI_RS350_133 0x7831
357#define PCI_DEVICE_ID_ATI_RS350_166 0x7832
358#define PCI_DEVICE_ID_ATI_RS350_200 0x7833
359#define PCI_DEVICE_ID_ATI_RS400_100 0x5a30
360#define PCI_DEVICE_ID_ATI_RS400_133 0x5a31
361#define PCI_DEVICE_ID_ATI_RS400_166 0x5a32
362#define PCI_DEVICE_ID_ATI_RS400_200 0x5a33
363#define PCI_DEVICE_ID_ATI_RS480 0x5950
364/* ATI IXP Chipset */
365#define PCI_DEVICE_ID_ATI_IXP200_IDE 0x4349
366#define PCI_DEVICE_ID_ATI_IXP300_IDE 0x4369
367#define PCI_DEVICE_ID_ATI_IXP300_SATA 0x436e
368#define PCI_DEVICE_ID_ATI_IXP400_IDE 0x4376
369#define PCI_DEVICE_ID_ATI_IXP400_SATA 0x4379
370
371#define PCI_VENDOR_ID_VLSI 0x1004
372#define PCI_DEVICE_ID_VLSI_82C592 0x0005
373#define PCI_DEVICE_ID_VLSI_82C593 0x0006
374#define PCI_DEVICE_ID_VLSI_82C594 0x0007
375#define PCI_DEVICE_ID_VLSI_82C597 0x0009
376#define PCI_DEVICE_ID_VLSI_82C541 0x000c
377#define PCI_DEVICE_ID_VLSI_82C543 0x000d
378#define PCI_DEVICE_ID_VLSI_82C532 0x0101
379#define PCI_DEVICE_ID_VLSI_82C534 0x0102
380#define PCI_DEVICE_ID_VLSI_82C535 0x0104
381#define PCI_DEVICE_ID_VLSI_82C147 0x0105
382#define PCI_DEVICE_ID_VLSI_VAS96011 0x0702
383
384#define PCI_VENDOR_ID_ADL 0x1005
385#define PCI_DEVICE_ID_ADL_2301 0x2301
386
387#define PCI_VENDOR_ID_NS 0x100b
388#define PCI_DEVICE_ID_NS_87415 0x0002
389#define PCI_DEVICE_ID_NS_87560_LIO 0x000e
390#define PCI_DEVICE_ID_NS_87560_USB 0x0012
391#define PCI_DEVICE_ID_NS_83815 0x0020
392#define PCI_DEVICE_ID_NS_83820 0x0022
393#define PCI_DEVICE_ID_NS_SCx200_BRIDGE 0x0500
394#define PCI_DEVICE_ID_NS_SCx200_SMI 0x0501
395#define PCI_DEVICE_ID_NS_SCx200_IDE 0x0502
396#define PCI_DEVICE_ID_NS_SCx200_AUDIO 0x0503
397#define PCI_DEVICE_ID_NS_SCx200_VIDEO 0x0504
398#define PCI_DEVICE_ID_NS_SCx200_XBUS 0x0505
399#define PCI_DEVICE_ID_NS_SC1100_BRIDGE 0x0510
400#define PCI_DEVICE_ID_NS_SC1100_SMI 0x0511
401#define PCI_DEVICE_ID_NS_SC1100_XBUS 0x0515
402#define PCI_DEVICE_ID_NS_87410 0xd001
403
404#define PCI_VENDOR_ID_TSENG 0x100c
405#define PCI_DEVICE_ID_TSENG_W32P_2 0x3202
406#define PCI_DEVICE_ID_TSENG_W32P_b 0x3205
407#define PCI_DEVICE_ID_TSENG_W32P_c 0x3206
408#define PCI_DEVICE_ID_TSENG_W32P_d 0x3207
409#define PCI_DEVICE_ID_TSENG_ET6000 0x3208
410
411#define PCI_VENDOR_ID_WEITEK 0x100e
412#define PCI_DEVICE_ID_WEITEK_P9000 0x9001
413#define PCI_DEVICE_ID_WEITEK_P9100 0x9100
414
415#define PCI_VENDOR_ID_DEC 0x1011
416#define PCI_DEVICE_ID_DEC_BRD 0x0001
417#define PCI_DEVICE_ID_DEC_TULIP 0x0002
418#define PCI_DEVICE_ID_DEC_TGA 0x0004
419#define PCI_DEVICE_ID_DEC_TULIP_FAST 0x0009
420#define PCI_DEVICE_ID_DEC_TGA2 0x000D
421#define PCI_DEVICE_ID_DEC_FDDI 0x000F
422#define PCI_DEVICE_ID_DEC_TULIP_PLUS 0x0014
423#define PCI_DEVICE_ID_DEC_21142 0x0019
424#define PCI_DEVICE_ID_DEC_21052 0x0021
425#define PCI_DEVICE_ID_DEC_21150 0x0022
426#define PCI_DEVICE_ID_DEC_21152 0x0024
427#define PCI_DEVICE_ID_DEC_21153 0x0025
428#define PCI_DEVICE_ID_DEC_21154 0x0026
429#define PCI_DEVICE_ID_DEC_21285 0x1065
430#define PCI_DEVICE_ID_COMPAQ_42XX 0x0046
431
432#define PCI_VENDOR_ID_CIRRUS 0x1013
433#define PCI_DEVICE_ID_CIRRUS_7548 0x0038
434#define PCI_DEVICE_ID_CIRRUS_5430 0x00a0
435#define PCI_DEVICE_ID_CIRRUS_5434_4 0x00a4
436#define PCI_DEVICE_ID_CIRRUS_5434_8 0x00a8
437#define PCI_DEVICE_ID_CIRRUS_5436 0x00ac
438#define PCI_DEVICE_ID_CIRRUS_5446 0x00b8
439#define PCI_DEVICE_ID_CIRRUS_5480 0x00bc
440#define PCI_DEVICE_ID_CIRRUS_5462 0x00d0
441#define PCI_DEVICE_ID_CIRRUS_5464 0x00d4
442#define PCI_DEVICE_ID_CIRRUS_5465 0x00d6
443#define PCI_DEVICE_ID_CIRRUS_6729 0x1100
444#define PCI_DEVICE_ID_CIRRUS_6832 0x1110
445#define PCI_DEVICE_ID_CIRRUS_7542 0x1200
446#define PCI_DEVICE_ID_CIRRUS_7543 0x1202
447#define PCI_DEVICE_ID_CIRRUS_7541 0x1204
448
449#define PCI_VENDOR_ID_IBM 0x1014
450#define PCI_DEVICE_ID_IBM_FIRE_CORAL 0x000a
451#define PCI_DEVICE_ID_IBM_TR 0x0018
452#define PCI_DEVICE_ID_IBM_82G2675 0x001d
453#define PCI_DEVICE_ID_IBM_MCA 0x0020
454#define PCI_DEVICE_ID_IBM_82351 0x0022
455#define PCI_DEVICE_ID_IBM_PYTHON 0x002d
456#define PCI_DEVICE_ID_IBM_SERVERAID 0x002e
457#define PCI_DEVICE_ID_IBM_TR_WAKE 0x003e
458#define PCI_DEVICE_ID_IBM_MPIC 0x0046
459#define PCI_DEVICE_ID_IBM_3780IDSP 0x007d
460#define PCI_DEVICE_ID_IBM_CHUKAR 0x0096
461#define PCI_DEVICE_ID_IBM_CPC710_PCI64 0x00fc
462#define PCI_DEVICE_ID_IBM_CPC710_PCI32 0x0105
463#define PCI_DEVICE_ID_IBM_405GP 0x0156
464#define PCI_DEVICE_ID_IBM_SNIPE 0x0180
465#define PCI_DEVICE_ID_IBM_SERVERAIDI960 0x01bd
466#define PCI_DEVICE_ID_IBM_CITRINE 0x028C
467#define PCI_DEVICE_ID_IBM_GEMSTONE 0xB166
468#define PCI_DEVICE_ID_IBM_MPIC_2 0xffff
469#define PCI_DEVICE_ID_IBM_ICOM_DEV_ID_1 0x0031
470#define PCI_DEVICE_ID_IBM_ICOM_DEV_ID_2 0x0219
471#define PCI_DEVICE_ID_IBM_ICOM_V2_TWO_PORTS_RVX 0x021A
472#define PCI_DEVICE_ID_IBM_ICOM_V2_ONE_PORT_RVX_ONE_PORT_MDM 0x0251
473#define PCI_DEVICE_ID_IBM_ICOM_FOUR_PORT_MODEL 0x252
474
475#define PCI_VENDOR_ID_COMPEX2 0x101a // pci.ids says "AT&T GIS (NCR)"
476#define PCI_DEVICE_ID_COMPEX2_100VG 0x0005
477
478#define PCI_VENDOR_ID_WD 0x101c
479#define PCI_DEVICE_ID_WD_7197 0x3296
480#define PCI_DEVICE_ID_WD_90C 0xc24a
481
482#define PCI_VENDOR_ID_AMI 0x101e
483#define PCI_DEVICE_ID_AMI_MEGARAID3 0x1960
484#define PCI_DEVICE_ID_AMI_MEGARAID 0x9010
485#define PCI_DEVICE_ID_AMI_MEGARAID2 0x9060
486
487#define PCI_VENDOR_ID_AMD 0x1022
488#define PCI_DEVICE_ID_AMD_LANCE 0x2000
489#define PCI_DEVICE_ID_AMD_LANCE_HOME 0x2001
490#define PCI_DEVICE_ID_AMD_SCSI 0x2020
491#define PCI_DEVICE_ID_AMD_SERENADE 0x36c0
492#define PCI_DEVICE_ID_AMD_FE_GATE_7006 0x7006
493#define PCI_DEVICE_ID_AMD_FE_GATE_7007 0x7007
494#define PCI_DEVICE_ID_AMD_FE_GATE_700C 0x700C
495#define PCI_DEVICE_ID_AMD_FE_GATE_700D 0x700D
496#define PCI_DEVICE_ID_AMD_FE_GATE_700E 0x700E
497#define PCI_DEVICE_ID_AMD_FE_GATE_700F 0x700F
498#define PCI_DEVICE_ID_AMD_COBRA_7400 0x7400
499#define PCI_DEVICE_ID_AMD_COBRA_7401 0x7401
500#define PCI_DEVICE_ID_AMD_COBRA_7403 0x7403
501#define PCI_DEVICE_ID_AMD_COBRA_7404 0x7404
502#define PCI_DEVICE_ID_AMD_VIPER_7408 0x7408
503#define PCI_DEVICE_ID_AMD_VIPER_7409 0x7409
504#define PCI_DEVICE_ID_AMD_VIPER_740B 0x740B
505#define PCI_DEVICE_ID_AMD_VIPER_740C 0x740C
506#define PCI_DEVICE_ID_AMD_VIPER_7410 0x7410
507#define PCI_DEVICE_ID_AMD_VIPER_7411 0x7411
508#define PCI_DEVICE_ID_AMD_VIPER_7413 0x7413
509#define PCI_DEVICE_ID_AMD_VIPER_7414 0x7414
510#define PCI_DEVICE_ID_AMD_OPUS_7440 0x7440
511# define PCI_DEVICE_ID_AMD_VIPER_7440 PCI_DEVICE_ID_AMD_OPUS_7440
512#define PCI_DEVICE_ID_AMD_OPUS_7441 0x7441
513# define PCI_DEVICE_ID_AMD_VIPER_7441 PCI_DEVICE_ID_AMD_OPUS_7441
514#define PCI_DEVICE_ID_AMD_OPUS_7443 0x7443
515# define PCI_DEVICE_ID_AMD_VIPER_7443 PCI_DEVICE_ID_AMD_OPUS_7443
516#define PCI_DEVICE_ID_AMD_OPUS_7445 0x7445
517#define PCI_DEVICE_ID_AMD_OPUS_7448 0x7448
518# define PCI_DEVICE_ID_AMD_VIPER_7448 PCI_DEVICE_ID_AMD_OPUS_7448
519#define PCI_DEVICE_ID_AMD_OPUS_7449 0x7449
520# define PCI_DEVICE_ID_AMD_VIPER_7449 PCI_DEVICE_ID_AMD_OPUS_7449
521#define PCI_DEVICE_ID_AMD_8111_LAN 0x7462
522#define PCI_DEVICE_ID_AMD_8111_LPC 0x7468
523#define PCI_DEVICE_ID_AMD_8111_IDE 0x7469
524#define PCI_DEVICE_ID_AMD_8111_SMBUS2 0x746a
525#define PCI_DEVICE_ID_AMD_8111_SMBUS 0x746b
526#define PCI_DEVICE_ID_AMD_8111_AUDIO 0x746d
527#define PCI_DEVICE_ID_AMD_8151_0 0x7454
528#define PCI_DEVICE_ID_AMD_8131_APIC 0x7450
529
530#define PCI_VENDOR_ID_TRIDENT 0x1023
531#define PCI_DEVICE_ID_TRIDENT_4DWAVE_DX 0x2000
532#define PCI_DEVICE_ID_TRIDENT_4DWAVE_NX 0x2001
533#define PCI_DEVICE_ID_TRIDENT_9320 0x9320
534#define PCI_DEVICE_ID_TRIDENT_9388 0x9388
535#define PCI_DEVICE_ID_TRIDENT_9397 0x9397
536#define PCI_DEVICE_ID_TRIDENT_939A 0x939A
537#define PCI_DEVICE_ID_TRIDENT_9520 0x9520
538#define PCI_DEVICE_ID_TRIDENT_9525 0x9525
539#define PCI_DEVICE_ID_TRIDENT_9420 0x9420
540#define PCI_DEVICE_ID_TRIDENT_9440 0x9440
541#define PCI_DEVICE_ID_TRIDENT_9660 0x9660
542#define PCI_DEVICE_ID_TRIDENT_9750 0x9750
543#define PCI_DEVICE_ID_TRIDENT_9850 0x9850
544#define PCI_DEVICE_ID_TRIDENT_9880 0x9880
545#define PCI_DEVICE_ID_TRIDENT_8400 0x8400
546#define PCI_DEVICE_ID_TRIDENT_8420 0x8420
547#define PCI_DEVICE_ID_TRIDENT_8500 0x8500
548
549#define PCI_VENDOR_ID_AI 0x1025
550#define PCI_DEVICE_ID_AI_M1435 0x1435
551
552#define PCI_VENDOR_ID_DELL 0x1028
553#define PCI_DEVICE_ID_DELL_RACIII 0x0008
554#define PCI_DEVICE_ID_DELL_RAC4 0x0012
555
556#define PCI_VENDOR_ID_MATROX 0x102B
557#define PCI_DEVICE_ID_MATROX_MGA_2 0x0518
558#define PCI_DEVICE_ID_MATROX_MIL 0x0519
559#define PCI_DEVICE_ID_MATROX_MYS 0x051A
560#define PCI_DEVICE_ID_MATROX_MIL_2 0x051b
561#define PCI_DEVICE_ID_MATROX_MIL_2_AGP 0x051f
562#define PCI_DEVICE_ID_MATROX_MGA_IMP 0x0d10
563#define PCI_DEVICE_ID_MATROX_G100_MM 0x1000
564#define PCI_DEVICE_ID_MATROX_G100_AGP 0x1001
565#define PCI_DEVICE_ID_MATROX_G200_PCI 0x0520
566#define PCI_DEVICE_ID_MATROX_G200_AGP 0x0521
567#define PCI_DEVICE_ID_MATROX_G400 0x0525
568#define PCI_DEVICE_ID_MATROX_G550 0x2527
569#define PCI_DEVICE_ID_MATROX_VIA 0x4536
570
571#define PCI_VENDOR_ID_CT 0x102c
572#define PCI_DEVICE_ID_CT_69000 0x00c0
573#define PCI_DEVICE_ID_CT_65545 0x00d8
574#define PCI_DEVICE_ID_CT_65548 0x00dc
575#define PCI_DEVICE_ID_CT_65550 0x00e0
576#define PCI_DEVICE_ID_CT_65554 0x00e4
577#define PCI_DEVICE_ID_CT_65555 0x00e5
578
579#define PCI_VENDOR_ID_MIRO 0x1031
580#define PCI_DEVICE_ID_MIRO_36050 0x5601
581#define PCI_DEVICE_ID_MIRO_DC10PLUS 0x7efe
582#define PCI_DEVICE_ID_MIRO_DC30PLUS 0xd801
583
584#define PCI_VENDOR_ID_NEC 0x1033
585#define PCI_DEVICE_ID_NEC_CBUS_1 0x0001 /* PCI-Cbus Bridge */
586#define PCI_DEVICE_ID_NEC_LOCAL 0x0002 /* Local Bridge */
587#define PCI_DEVICE_ID_NEC_ATM 0x0003 /* ATM LAN Controller */
588#define PCI_DEVICE_ID_NEC_R4000 0x0004 /* R4000 Bridge */
589#define PCI_DEVICE_ID_NEC_486 0x0005 /* 486 Like Peripheral Bus Bridge */
590#define PCI_DEVICE_ID_NEC_ACCEL_1 0x0006 /* Graphic Accelerator */
591#define PCI_DEVICE_ID_NEC_UXBUS 0x0007 /* UX-Bus Bridge */
592#define PCI_DEVICE_ID_NEC_ACCEL_2 0x0008 /* Graphic Accelerator */
593#define PCI_DEVICE_ID_NEC_GRAPH 0x0009 /* PCI-CoreGraph Bridge */
594#define PCI_DEVICE_ID_NEC_VL 0x0016 /* PCI-VL Bridge */
595#define PCI_DEVICE_ID_NEC_STARALPHA2 0x002c /* STAR ALPHA2 */
596#define PCI_DEVICE_ID_NEC_CBUS_2 0x002d /* PCI-Cbus Bridge */
597#define PCI_DEVICE_ID_NEC_USB 0x0035 /* PCI-USB Host */
598#define PCI_DEVICE_ID_NEC_CBUS_3 0x003b
599#define PCI_DEVICE_ID_NEC_NAPCCARD 0x003e
600#define PCI_DEVICE_ID_NEC_PCX2 0x0046 /* PowerVR */
601#define PCI_DEVICE_ID_NEC_NILE4 0x005a
602#define PCI_DEVICE_ID_NEC_VRC5476 0x009b
603#define PCI_DEVICE_ID_NEC_VRC4173 0x00a5
604#define PCI_DEVICE_ID_NEC_VRC5477_AC97 0x00a6
605#define PCI_DEVICE_ID_NEC_PC9821CS01 0x800c /* PC-9821-CS01 */
606#define PCI_DEVICE_ID_NEC_PC9821NRB06 0x800d /* PC-9821NR-B06 */
607
608#define PCI_VENDOR_ID_FD 0x1036
609#define PCI_DEVICE_ID_FD_36C70 0x0000
610
611#define PCI_VENDOR_ID_SI 0x1039
612#define PCI_DEVICE_ID_SI_5591_AGP 0x0001
613#define PCI_DEVICE_ID_SI_6202 0x0002
614#define PCI_DEVICE_ID_SI_503 0x0008
615#define PCI_DEVICE_ID_SI_ACPI 0x0009
616#define PCI_DEVICE_ID_SI_SMBUS 0x0016
617#define PCI_DEVICE_ID_SI_LPC 0x0018
618#define PCI_DEVICE_ID_SI_5597_VGA 0x0200
619#define PCI_DEVICE_ID_SI_6205 0x0205
620#define PCI_DEVICE_ID_SI_501 0x0406
621#define PCI_DEVICE_ID_SI_496 0x0496
622#define PCI_DEVICE_ID_SI_300 0x0300
623#define PCI_DEVICE_ID_SI_315H 0x0310
624#define PCI_DEVICE_ID_SI_315 0x0315
625#define PCI_DEVICE_ID_SI_315PRO 0x0325
626#define PCI_DEVICE_ID_SI_530 0x0530
627#define PCI_DEVICE_ID_SI_540 0x0540
628#define PCI_DEVICE_ID_SI_550 0x0550
629#define PCI_DEVICE_ID_SI_540_VGA 0x5300
630#define PCI_DEVICE_ID_SI_550_VGA 0x5315
631#define PCI_DEVICE_ID_SI_601 0x0601
632#define PCI_DEVICE_ID_SI_620 0x0620
633#define PCI_DEVICE_ID_SI_630 0x0630
634#define PCI_DEVICE_ID_SI_633 0x0633
635#define PCI_DEVICE_ID_SI_635 0x0635
636#define PCI_DEVICE_ID_SI_640 0x0640
637#define PCI_DEVICE_ID_SI_645 0x0645
638#define PCI_DEVICE_ID_SI_646 0x0646
639#define PCI_DEVICE_ID_SI_648 0x0648
640#define PCI_DEVICE_ID_SI_650 0x0650
641#define PCI_DEVICE_ID_SI_651 0x0651
642#define PCI_DEVICE_ID_SI_652 0x0652
643#define PCI_DEVICE_ID_SI_655 0x0655
644#define PCI_DEVICE_ID_SI_661 0x0661
645#define PCI_DEVICE_ID_SI_730 0x0730
646#define PCI_DEVICE_ID_SI_733 0x0733
647#define PCI_DEVICE_ID_SI_630_VGA 0x6300
648#define PCI_DEVICE_ID_SI_730_VGA 0x7300
649#define PCI_DEVICE_ID_SI_735 0x0735
650#define PCI_DEVICE_ID_SI_740 0x0740
651#define PCI_DEVICE_ID_SI_741 0x0741
652#define PCI_DEVICE_ID_SI_745 0x0745
653#define PCI_DEVICE_ID_SI_746 0x0746
654#define PCI_DEVICE_ID_SI_748 0x0748
655#define PCI_DEVICE_ID_SI_750 0x0750
656#define PCI_DEVICE_ID_SI_751 0x0751
657#define PCI_DEVICE_ID_SI_752 0x0752
658#define PCI_DEVICE_ID_SI_755 0x0755
659#define PCI_DEVICE_ID_SI_760 0x0760
660#define PCI_DEVICE_ID_SI_900 0x0900
661#define PCI_DEVICE_ID_SI_961 0x0961
662#define PCI_DEVICE_ID_SI_962 0x0962
663#define PCI_DEVICE_ID_SI_963 0x0963
664#define PCI_DEVICE_ID_SI_5107 0x5107
665#define PCI_DEVICE_ID_SI_5300 0x5300
666#define PCI_DEVICE_ID_SI_5511 0x5511
667#define PCI_DEVICE_ID_SI_5513 0x5513
668#define PCI_DEVICE_ID_SI_5518 0x5518
669#define PCI_DEVICE_ID_SI_5571 0x5571
670#define PCI_DEVICE_ID_SI_5581 0x5581
671#define PCI_DEVICE_ID_SI_5582 0x5582
672#define PCI_DEVICE_ID_SI_5591 0x5591
673#define PCI_DEVICE_ID_SI_5596 0x5596
674#define PCI_DEVICE_ID_SI_5597 0x5597
675#define PCI_DEVICE_ID_SI_5598 0x5598
676#define PCI_DEVICE_ID_SI_5600 0x5600
677#define PCI_DEVICE_ID_SI_6300 0x6300
678#define PCI_DEVICE_ID_SI_6306 0x6306
679#define PCI_DEVICE_ID_SI_6326 0x6326
680#define PCI_DEVICE_ID_SI_7001 0x7001
681#define PCI_DEVICE_ID_SI_7012 0x7012
682#define PCI_DEVICE_ID_SI_7016 0x7016
683
684#define PCI_VENDOR_ID_HP 0x103c
685#define PCI_DEVICE_ID_HP_VISUALIZE_EG 0x1005
686#define PCI_DEVICE_ID_HP_VISUALIZE_FX6 0x1006
687#define PCI_DEVICE_ID_HP_VISUALIZE_FX4 0x1008
688#define PCI_DEVICE_ID_HP_VISUALIZE_FX2 0x100a
689#define PCI_DEVICE_ID_HP_TACHYON 0x1028
690#define PCI_DEVICE_ID_HP_TACHLITE 0x1029
691#define PCI_DEVICE_ID_HP_J2585A 0x1030
692#define PCI_DEVICE_ID_HP_J2585B 0x1031
693#define PCI_DEVICE_ID_HP_J2973A 0x1040
694#define PCI_DEVICE_ID_HP_J2970A 0x1042
695#define PCI_DEVICE_ID_HP_DIVA 0x1048
696#define PCI_DEVICE_ID_HP_DIVA_TOSCA1 0x1049
697#define PCI_DEVICE_ID_HP_DIVA_TOSCA2 0x104A
698#define PCI_DEVICE_ID_HP_DIVA_MAESTRO 0x104B
699#define PCI_DEVICE_ID_HP_PCI_LBA 0x1054
700#define PCI_DEVICE_ID_HP_REO_SBA 0x10f0
701#define PCI_DEVICE_ID_HP_REO_IOC 0x10f1
702#define PCI_DEVICE_ID_HP_VISUALIZE_FXE 0x108b
703#define PCI_DEVICE_ID_HP_DIVA_HALFDOME 0x1223
704#define PCI_DEVICE_ID_HP_DIVA_KEYSTONE 0x1226
705#define PCI_DEVICE_ID_HP_DIVA_POWERBAR 0x1227
706#define PCI_DEVICE_ID_HP_ZX1_SBA 0x1229
707#define PCI_DEVICE_ID_HP_ZX1_IOC 0x122a
708#define PCI_DEVICE_ID_HP_PCIX_LBA 0x122e
709#define PCI_DEVICE_ID_HP_SX1000_IOC 0x127c
710#define PCI_DEVICE_ID_HP_DIVA_EVEREST 0x1282
711#define PCI_DEVICE_ID_HP_DIVA_AUX 0x1290
712#define PCI_DEVICE_ID_HP_DIVA_RMP3 0x1301
713#define PCI_DEVICE_ID_HP_CISSA 0x3220
714#define PCI_DEVICE_ID_HP_CISSB 0x3230
715#define PCI_DEVICE_ID_HP_ZX2_IOC 0x4031
716
717#define PCI_VENDOR_ID_PCTECH 0x1042
718#define PCI_DEVICE_ID_PCTECH_RZ1000 0x1000
719#define PCI_DEVICE_ID_PCTECH_RZ1001 0x1001
720#define PCI_DEVICE_ID_PCTECH_SAMURAI_0 0x3000
721#define PCI_DEVICE_ID_PCTECH_SAMURAI_1 0x3010
722#define PCI_DEVICE_ID_PCTECH_SAMURAI_IDE 0x3020
723
724#define PCI_VENDOR_ID_ASUSTEK 0x1043
725#define PCI_DEVICE_ID_ASUSTEK_0675 0x0675
726
727#define PCI_VENDOR_ID_DPT 0x1044
728#define PCI_DEVICE_ID_DPT 0xa400
729
730#define PCI_VENDOR_ID_OPTI 0x1045
731#define PCI_DEVICE_ID_OPTI_92C178 0xc178
732#define PCI_DEVICE_ID_OPTI_82C557 0xc557
733#define PCI_DEVICE_ID_OPTI_82C558 0xc558
734#define PCI_DEVICE_ID_OPTI_82C621 0xc621
735#define PCI_DEVICE_ID_OPTI_82C700 0xc700
736#define PCI_DEVICE_ID_OPTI_82C701 0xc701
737#define PCI_DEVICE_ID_OPTI_82C814 0xc814
738#define PCI_DEVICE_ID_OPTI_82C822 0xc822
739#define PCI_DEVICE_ID_OPTI_82C861 0xc861
740#define PCI_DEVICE_ID_OPTI_82C825 0xd568
741
742#define PCI_VENDOR_ID_ELSA 0x1048
743#define PCI_DEVICE_ID_ELSA_MICROLINK 0x1000
744#define PCI_DEVICE_ID_ELSA_QS3000 0x3000
745
746#define PCI_VENDOR_ID_SGS 0x104a
747#define PCI_DEVICE_ID_SGS_2000 0x0008
748#define PCI_DEVICE_ID_SGS_1764 0x0009
749
750#define PCI_VENDOR_ID_BUSLOGIC 0x104B
751#define PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC 0x0140
752#define PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER 0x1040
753#define PCI_DEVICE_ID_BUSLOGIC_FLASHPOINT 0x8130
754
755#define PCI_VENDOR_ID_TI 0x104c
756#define PCI_DEVICE_ID_TI_TVP4010 0x3d04
757#define PCI_DEVICE_ID_TI_TVP4020 0x3d07
758#define PCI_DEVICE_ID_TI_4450 0x8011
759#define PCI_DEVICE_ID_TI_1130 0xac12
760#define PCI_DEVICE_ID_TI_1031 0xac13
761#define PCI_DEVICE_ID_TI_1131 0xac15
762#define PCI_DEVICE_ID_TI_1250 0xac16
763#define PCI_DEVICE_ID_TI_1220 0xac17
764#define PCI_DEVICE_ID_TI_1221 0xac19
765#define PCI_DEVICE_ID_TI_1210 0xac1a
766#define PCI_DEVICE_ID_TI_1450 0xac1b
767#define PCI_DEVICE_ID_TI_1225 0xac1c
768#define PCI_DEVICE_ID_TI_1251A 0xac1d
769#define PCI_DEVICE_ID_TI_1211 0xac1e
770#define PCI_DEVICE_ID_TI_1251B 0xac1f
771#define PCI_DEVICE_ID_TI_4410 0xac41
772#define PCI_DEVICE_ID_TI_4451 0xac42
773#define PCI_DEVICE_ID_TI_4510 0xac44
774#define PCI_DEVICE_ID_TI_4520 0xac46
775#define PCI_DEVICE_ID_TI_1410 0xac50
776#define PCI_DEVICE_ID_TI_1420 0xac51
777#define PCI_DEVICE_ID_TI_1451A 0xac52
778#define PCI_DEVICE_ID_TI_1620 0xac54
779#define PCI_DEVICE_ID_TI_1520 0xac55
780#define PCI_DEVICE_ID_TI_1510 0xac56
781
782#define PCI_VENDOR_ID_SONY 0x104d
783#define PCI_DEVICE_ID_SONY_CXD3222 0x8039
784
785#define PCI_VENDOR_ID_OAK 0x104e
786#define PCI_DEVICE_ID_OAK_OTI107 0x0107
787
788/* Winbond have two vendor IDs! See 0x10ad as well */
789#define PCI_VENDOR_ID_WINBOND2 0x1050
790#define PCI_DEVICE_ID_WINBOND2_89C940 0x0940
791#define PCI_DEVICE_ID_WINBOND2_89C940F 0x5a5a
792#define PCI_DEVICE_ID_WINBOND2_6692 0x6692
793
794#define PCI_VENDOR_ID_ANIGMA 0x1051
795#define PCI_DEVICE_ID_ANIGMA_MC145575 0x0100
796
797#define PCI_VENDOR_ID_EFAR 0x1055
798#define PCI_DEVICE_ID_EFAR_SLC90E66_1 0x9130
799#define PCI_DEVICE_ID_EFAR_SLC90E66_0 0x9460
800#define PCI_DEVICE_ID_EFAR_SLC90E66_2 0x9462
801#define PCI_DEVICE_ID_EFAR_SLC90E66_3 0x9463
802
803#define PCI_VENDOR_ID_MOTOROLA 0x1057
804#define PCI_VENDOR_ID_MOTOROLA_OOPS 0x1507
805#define PCI_DEVICE_ID_MOTOROLA_MPC105 0x0001
806#define PCI_DEVICE_ID_MOTOROLA_MPC106 0x0002
807#define PCI_DEVICE_ID_MOTOROLA_MPC107 0x0004
808#define PCI_DEVICE_ID_MOTOROLA_RAVEN 0x4801
809#define PCI_DEVICE_ID_MOTOROLA_FALCON 0x4802
810#define PCI_DEVICE_ID_MOTOROLA_HAWK 0x4803
811#define PCI_DEVICE_ID_MOTOROLA_CPX8216 0x4806
812#define PCI_DEVICE_ID_MOTOROLA_HARRIER 0x480b
813#define PCI_DEVICE_ID_MOTOROLA_MPC5200 0x5803
814
815#define PCI_VENDOR_ID_PROMISE 0x105a
816#define PCI_DEVICE_ID_PROMISE_20265 0x0d30
817#define PCI_DEVICE_ID_PROMISE_20267 0x4d30
818#define PCI_DEVICE_ID_PROMISE_20246 0x4d33
819#define PCI_DEVICE_ID_PROMISE_20262 0x4d38
820#define PCI_DEVICE_ID_PROMISE_20263 0x0D38
821#define PCI_DEVICE_ID_PROMISE_20268 0x4d68
822#define PCI_DEVICE_ID_PROMISE_20268R 0x6268
823#define PCI_DEVICE_ID_PROMISE_20269 0x4d69
824#define PCI_DEVICE_ID_PROMISE_20270 0x6268
825#define PCI_DEVICE_ID_PROMISE_20271 0x6269
826#define PCI_DEVICE_ID_PROMISE_20275 0x1275
827#define PCI_DEVICE_ID_PROMISE_20276 0x5275
828#define PCI_DEVICE_ID_PROMISE_20277 0x7275
829#define PCI_DEVICE_ID_PROMISE_5300 0x5300
830
831#define PCI_VENDOR_ID_N9 0x105d
832#define PCI_DEVICE_ID_N9_I128 0x2309
833#define PCI_DEVICE_ID_N9_I128_2 0x2339
834#define PCI_DEVICE_ID_N9_I128_T2R 0x493d
835
836#define PCI_VENDOR_ID_UMC 0x1060
837#define PCI_DEVICE_ID_UMC_UM8673F 0x0101
838#define PCI_DEVICE_ID_UMC_UM8891A 0x0891
839#define PCI_DEVICE_ID_UMC_UM8886BF 0x673a
840#define PCI_DEVICE_ID_UMC_UM8886A 0x886a
841#define PCI_DEVICE_ID_UMC_UM8881F 0x8881
842#define PCI_DEVICE_ID_UMC_UM8886F 0x8886
843#define PCI_DEVICE_ID_UMC_UM9017F 0x9017
844#define PCI_DEVICE_ID_UMC_UM8886N 0xe886
845#define PCI_DEVICE_ID_UMC_UM8891N 0xe891
846
847#define PCI_VENDOR_ID_X 0x1061
848#define PCI_DEVICE_ID_X_AGX016 0x0001
849
850#define PCI_VENDOR_ID_MYLEX 0x1069
851#define PCI_DEVICE_ID_MYLEX_DAC960_P 0x0001
852#define PCI_DEVICE_ID_MYLEX_DAC960_PD 0x0002
853#define PCI_DEVICE_ID_MYLEX_DAC960_PG 0x0010
854#define PCI_DEVICE_ID_MYLEX_DAC960_LA 0x0020
855#define PCI_DEVICE_ID_MYLEX_DAC960_LP 0x0050
856#define PCI_DEVICE_ID_MYLEX_DAC960_BA 0xBA56
857
858#define PCI_VENDOR_ID_PICOP 0x1066
859#define PCI_DEVICE_ID_PICOP_PT86C52X 0x0001
860#define PCI_DEVICE_ID_PICOP_PT80C524 0x8002
861
862#define PCI_VENDOR_ID_APPLE 0x106b
863#define PCI_DEVICE_ID_APPLE_BANDIT 0x0001
864#define PCI_DEVICE_ID_APPLE_GC 0x0002
865#define PCI_DEVICE_ID_APPLE_HYDRA 0x000e
866#define PCI_DEVICE_ID_APPLE_UNI_N_FW 0x0018
867#define PCI_DEVICE_ID_APPLE_KL_USB 0x0019
868#define PCI_DEVICE_ID_APPLE_UNI_N_AGP 0x0020
869#define PCI_DEVICE_ID_APPLE_UNI_N_GMAC 0x0021
870#define PCI_DEVICE_ID_APPLE_KEYLARGO 0x0022
871#define PCI_DEVICE_ID_APPLE_UNI_N_GMACP 0x0024
872#define PCI_DEVICE_ID_APPLE_KEYLARGO_P 0x0025
873#define PCI_DEVICE_ID_APPLE_KL_USB_P 0x0026
874#define PCI_DEVICE_ID_APPLE_UNI_N_AGP_P 0x0027
875#define PCI_DEVICE_ID_APPLE_UNI_N_AGP15 0x002d
876#define PCI_DEVICE_ID_APPLE_UNI_N_FW2 0x0030
877#define PCI_DEVICE_ID_APPLE_UNI_N_GMAC2 0x0032
878#define PCI_DEVIEC_ID_APPLE_UNI_N_ATA 0x0033
879#define PCI_DEVICE_ID_APPLE_UNI_N_AGP2 0x0034
880#define PCI_DEVICE_ID_APPLE_IPID_ATA100 0x003b
881#define PCI_DEVICE_ID_APPLE_KEYLARGO_I 0x003e
882#define PCI_DEVICE_ID_APPLE_K2_ATA100 0x0043
883#define PCI_DEVICE_ID_APPLE_U3_AGP 0x004b
884#define PCI_DEVICE_ID_APPLE_K2_GMAC 0x004c
885#define PCI_DEVICE_ID_APPLE_SH_ATA 0x0050
886#define PCI_DEVICE_ID_APPLE_SH_SUNGEM 0x0051
887#define PCI_DEVICE_ID_APPLE_SH_FW 0x0052
888#define PCI_DEVICE_ID_APPLE_U3L_AGP 0x0058
889#define PCI_DEVICE_ID_APPLE_U3H_AGP 0x0059
890#define PCI_DEVICE_ID_APPLE_TIGON3 0x1645
891
892#define PCI_VENDOR_ID_YAMAHA 0x1073
893#define PCI_DEVICE_ID_YAMAHA_724 0x0004
894#define PCI_DEVICE_ID_YAMAHA_724F 0x000d
895#define PCI_DEVICE_ID_YAMAHA_740 0x000a
896#define PCI_DEVICE_ID_YAMAHA_740C 0x000c
897#define PCI_DEVICE_ID_YAMAHA_744 0x0010
898#define PCI_DEVICE_ID_YAMAHA_754 0x0012
899
900#define PCI_VENDOR_ID_NEXGEN 0x1074
901#define PCI_DEVICE_ID_NEXGEN_82C501 0x4e78
902
903#define PCI_VENDOR_ID_QLOGIC 0x1077
904#define PCI_DEVICE_ID_QLOGIC_ISP1020 0x1020
905#define PCI_DEVICE_ID_QLOGIC_ISP1022 0x1022
906#define PCI_DEVICE_ID_QLOGIC_ISP2100 0x2100
907#define PCI_DEVICE_ID_QLOGIC_ISP2200 0x2200
908
909#define PCI_VENDOR_ID_CYRIX 0x1078
910#define PCI_DEVICE_ID_CYRIX_5510 0x0000
911#define PCI_DEVICE_ID_CYRIX_PCI_MASTER 0x0001
912#define PCI_DEVICE_ID_CYRIX_5520 0x0002
913#define PCI_DEVICE_ID_CYRIX_5530_LEGACY 0x0100
914#define PCI_DEVICE_ID_CYRIX_5530_SMI 0x0101
915#define PCI_DEVICE_ID_CYRIX_5530_IDE 0x0102
916#define PCI_DEVICE_ID_CYRIX_5530_AUDIO 0x0103
917#define PCI_DEVICE_ID_CYRIX_5530_VIDEO 0x0104
918
919#define PCI_VENDOR_ID_LEADTEK 0x107d
920#define PCI_DEVICE_ID_LEADTEK_805 0x0000
921
922#define PCI_VENDOR_ID_INTERPHASE 0x107e
923#define PCI_DEVICE_ID_INTERPHASE_5526 0x0004
924#define PCI_DEVICE_ID_INTERPHASE_55x6 0x0005
925#define PCI_DEVICE_ID_INTERPHASE_5575 0x0008
926
927#define PCI_VENDOR_ID_CONTAQ 0x1080
928#define PCI_DEVICE_ID_CONTAQ_82C599 0x0600
929#define PCI_DEVICE_ID_CONTAQ_82C693 0xc693
930
931#define PCI_VENDOR_ID_FOREX 0x1083
932
933#define PCI_VENDOR_ID_OLICOM 0x108d
934#define PCI_DEVICE_ID_OLICOM_OC3136 0x0001
935#define PCI_DEVICE_ID_OLICOM_OC2315 0x0011
936#define PCI_DEVICE_ID_OLICOM_OC2325 0x0012
937#define PCI_DEVICE_ID_OLICOM_OC2183 0x0013
938#define PCI_DEVICE_ID_OLICOM_OC2326 0x0014
939#define PCI_DEVICE_ID_OLICOM_OC6151 0x0021
940
941#define PCI_VENDOR_ID_SUN 0x108e
942#define PCI_DEVICE_ID_SUN_EBUS 0x1000
943#define PCI_DEVICE_ID_SUN_HAPPYMEAL 0x1001
944#define PCI_DEVICE_ID_SUN_RIO_EBUS 0x1100
945#define PCI_DEVICE_ID_SUN_RIO_GEM 0x1101
946#define PCI_DEVICE_ID_SUN_RIO_1394 0x1102
947#define PCI_DEVICE_ID_SUN_RIO_USB 0x1103
948#define PCI_DEVICE_ID_SUN_GEM 0x2bad
949#define PCI_DEVICE_ID_SUN_SIMBA 0x5000
950#define PCI_DEVICE_ID_SUN_PBM 0x8000
951#define PCI_DEVICE_ID_SUN_SCHIZO 0x8001
952#define PCI_DEVICE_ID_SUN_SABRE 0xa000
953#define PCI_DEVICE_ID_SUN_HUMMINGBIRD 0xa001
954#define PCI_DEVICE_ID_SUN_TOMATILLO 0xa801
955
956#define PCI_VENDOR_ID_CMD 0x1095
957#define PCI_DEVICE_ID_CMD_640 0x0640
958#define PCI_DEVICE_ID_CMD_643 0x0643
959#define PCI_DEVICE_ID_CMD_646 0x0646
960#define PCI_DEVICE_ID_CMD_647 0x0647
961#define PCI_DEVICE_ID_CMD_648 0x0648
962#define PCI_DEVICE_ID_CMD_649 0x0649
963#define PCI_DEVICE_ID_CMD_670 0x0670
964#define PCI_DEVICE_ID_CMD_680 0x0680
965
966#define PCI_DEVICE_ID_SII_680 0x0680
967#define PCI_DEVICE_ID_SII_3112 0x3112
968#define PCI_DEVICE_ID_SII_1210SA 0x0240
969
970#define PCI_VENDOR_ID_VISION 0x1098
971#define PCI_DEVICE_ID_VISION_QD8500 0x0001
972#define PCI_DEVICE_ID_VISION_QD8580 0x0002
973
974#define PCI_VENDOR_ID_BROOKTREE 0x109e
975#define PCI_DEVICE_ID_BROOKTREE_848 0x0350
976#define PCI_DEVICE_ID_BROOKTREE_849A 0x0351
977#define PCI_DEVICE_ID_BROOKTREE_878_1 0x036e
978#define PCI_DEVICE_ID_BROOKTREE_878 0x0878
979#define PCI_DEVICE_ID_BROOKTREE_8474 0x8474
980
981#define PCI_VENDOR_ID_SIERRA 0x10a8
982#define PCI_DEVICE_ID_SIERRA_STB 0x0000
983
984#define PCI_VENDOR_ID_SGI 0x10a9
985#define PCI_DEVICE_ID_SGI_IOC3 0x0003
986#define PCI_DEVICE_ID_SGI_IOC4 0x100a
987#define PCI_VENDOR_ID_SGI_LITHIUM 0x1002
988
989#define PCI_VENDOR_ID_ACC 0x10aa
990#define PCI_DEVICE_ID_ACC_2056 0x0000
991
992#define PCI_VENDOR_ID_WINBOND 0x10ad
993#define PCI_DEVICE_ID_WINBOND_83769 0x0001
994#define PCI_DEVICE_ID_WINBOND_82C105 0x0105
995#define PCI_DEVICE_ID_WINBOND_83C553 0x0565
996
997#define PCI_VENDOR_ID_DATABOOK 0x10b3
998#define PCI_DEVICE_ID_DATABOOK_87144 0xb106
999
1000#define PCI_VENDOR_ID_PLX 0x10b5
1001#define PCI_DEVICE_ID_PLX_R685 0x1030
1002#define PCI_DEVICE_ID_PLX_ROMULUS 0x106a
1003#define PCI_DEVICE_ID_PLX_SPCOM800 0x1076
1004#define PCI_DEVICE_ID_PLX_1077 0x1077
1005#define PCI_DEVICE_ID_PLX_SPCOM200 0x1103
1006#define PCI_DEVICE_ID_PLX_DJINN_ITOO 0x1151
1007#define PCI_DEVICE_ID_PLX_R753 0x1152
1008#define PCI_DEVICE_ID_PLX_9030 0x9030
1009#define PCI_DEVICE_ID_PLX_9050 0x9050
1010#define PCI_DEVICE_ID_PLX_9060 0x9060
1011#define PCI_DEVICE_ID_PLX_9060ES 0x906E
1012#define PCI_DEVICE_ID_PLX_9060SD 0x906D
1013#define PCI_DEVICE_ID_PLX_9080 0x9080
1014#define PCI_DEVICE_ID_PLX_GTEK_SERIAL2 0xa001
1015
1016#define PCI_VENDOR_ID_MADGE 0x10b6
1017#define PCI_DEVICE_ID_MADGE_MK2 0x0002
1018#define PCI_DEVICE_ID_MADGE_C155S 0x1001
1019
1020#define PCI_VENDOR_ID_3COM 0x10b7
1021#define PCI_DEVICE_ID_3COM_3C985 0x0001
1022#define PCI_DEVICE_ID_3COM_3C940 0x1700
1023#define PCI_DEVICE_ID_3COM_3C339 0x3390
1024#define PCI_DEVICE_ID_3COM_3C359 0x3590
1025#define PCI_DEVICE_ID_3COM_3C590 0x5900
1026#define PCI_DEVICE_ID_3COM_3C595TX 0x5950
1027#define PCI_DEVICE_ID_3COM_3C595T4 0x5951
1028#define PCI_DEVICE_ID_3COM_3C595MII 0x5952
1029#define PCI_DEVICE_ID_3COM_3C940B 0x80eb
1030#define PCI_DEVICE_ID_3COM_3C900TPO 0x9000
1031#define PCI_DEVICE_ID_3COM_3C900COMBO 0x9001
1032#define PCI_DEVICE_ID_3COM_3C905TX 0x9050
1033#define PCI_DEVICE_ID_3COM_3C905T4 0x9051
1034#define PCI_DEVICE_ID_3COM_3C905B_TX 0x9055
1035#define PCI_DEVICE_ID_3COM_3CR990 0x9900
1036#define PCI_DEVICE_ID_3COM_3CR990_TX_95 0x9902
1037#define PCI_DEVICE_ID_3COM_3CR990_TX_97 0x9903
1038#define PCI_DEVICE_ID_3COM_3CR990B 0x9904
1039#define PCI_DEVICE_ID_3COM_3CR990_FX 0x9905
1040#define PCI_DEVICE_ID_3COM_3CR990SVR95 0x9908
1041#define PCI_DEVICE_ID_3COM_3CR990SVR97 0x9909
1042#define PCI_DEVICE_ID_3COM_3CR990SVR 0x990a
1043
1044#define PCI_VENDOR_ID_SMC 0x10b8
1045#define PCI_DEVICE_ID_SMC_EPIC100 0x0005
1046
1047#define PCI_VENDOR_ID_AL 0x10b9
1048#define PCI_DEVICE_ID_AL_M1445 0x1445
1049#define PCI_DEVICE_ID_AL_M1449 0x1449
1050#define PCI_DEVICE_ID_AL_M1451 0x1451
1051#define PCI_DEVICE_ID_AL_M1461 0x1461
1052#define PCI_DEVICE_ID_AL_M1489 0x1489
1053#define PCI_DEVICE_ID_AL_M1511 0x1511
1054#define PCI_DEVICE_ID_AL_M1513 0x1513
1055#define PCI_DEVICE_ID_AL_M1521 0x1521
1056#define PCI_DEVICE_ID_AL_M1523 0x1523
1057#define PCI_DEVICE_ID_AL_M1531 0x1531
1058#define PCI_DEVICE_ID_AL_M1533 0x1533
1059#define PCI_DEVICE_ID_AL_M1535 0x1535
1060#define PCI_DEVICE_ID_AL_M1541 0x1541
1061#define PCI_DEVICE_ID_AL_M1543 0x1543
1062#define PCI_DEVICE_ID_AL_M1563 0x1563
1063#define PCI_DEVICE_ID_AL_M1621 0x1621
1064#define PCI_DEVICE_ID_AL_M1631 0x1631
1065#define PCI_DEVICE_ID_AL_M1632 0x1632
1066#define PCI_DEVICE_ID_AL_M1641 0x1641
1067#define PCI_DEVICE_ID_AL_M1644 0x1644
1068#define PCI_DEVICE_ID_AL_M1647 0x1647
1069#define PCI_DEVICE_ID_AL_M1651 0x1651
1070#define PCI_DEVICE_ID_AL_M1671 0x1671
1071#define PCI_DEVICE_ID_AL_M1681 0x1681
1072#define PCI_DEVICE_ID_AL_M1683 0x1683
1073#define PCI_DEVICE_ID_AL_M1689 0x1689
1074#define PCI_DEVICE_ID_AL_M3307 0x3307
1075#define PCI_DEVICE_ID_AL_M4803 0x5215
1076#define PCI_DEVICE_ID_AL_M5219 0x5219
1077#define PCI_DEVICE_ID_AL_M5228 0x5228
1078#define PCI_DEVICE_ID_AL_M5229 0x5229
1079#define PCI_DEVICE_ID_AL_M5237 0x5237
1080#define PCI_DEVICE_ID_AL_M5243 0x5243
1081#define PCI_DEVICE_ID_AL_M5451 0x5451
1082#define PCI_DEVICE_ID_AL_M7101 0x7101
1083
1084#define PCI_VENDOR_ID_MITSUBISHI 0x10ba
1085
1086#define PCI_VENDOR_ID_SURECOM 0x10bd
1087#define PCI_DEVICE_ID_SURECOM_NE34 0x0e34
1088
1089#define PCI_VENDOR_ID_NEOMAGIC 0x10c8
1090#define PCI_DEVICE_ID_NEOMAGIC_MAGICGRAPH_NM2070 0x0001
1091#define PCI_DEVICE_ID_NEOMAGIC_MAGICGRAPH_128V 0x0002
1092#define PCI_DEVICE_ID_NEOMAGIC_MAGICGRAPH_128ZV 0x0003
1093#define PCI_DEVICE_ID_NEOMAGIC_MAGICGRAPH_NM2160 0x0004
1094#define PCI_DEVICE_ID_NEOMAGIC_MAGICMEDIA_256AV 0x0005
1095#define PCI_DEVICE_ID_NEOMAGIC_MAGICGRAPH_128ZVPLUS 0x0083
1096
1097#define PCI_VENDOR_ID_ASP 0x10cd
1098#define PCI_DEVICE_ID_ASP_ABP940 0x1200
1099#define PCI_DEVICE_ID_ASP_ABP940U 0x1300
1100#define PCI_DEVICE_ID_ASP_ABP940UW 0x2300
1101
1102#define PCI_VENDOR_ID_MACRONIX 0x10d9
1103#define PCI_DEVICE_ID_MACRONIX_MX98713 0x0512
1104#define PCI_DEVICE_ID_MACRONIX_MX987x5 0x0531
1105
1106#define PCI_VENDOR_ID_TCONRAD 0x10da
1107#define PCI_DEVICE_ID_TCONRAD_TOKENRING 0x0508
1108
1109#define PCI_VENDOR_ID_CERN 0x10dc
1110#define PCI_DEVICE_ID_CERN_SPSB_PMC 0x0001
1111#define PCI_DEVICE_ID_CERN_SPSB_PCI 0x0002
1112#define PCI_DEVICE_ID_CERN_HIPPI_DST 0x0021
1113#define PCI_DEVICE_ID_CERN_HIPPI_SRC 0x0022
1114
1115#define PCI_VENDOR_ID_NVIDIA 0x10de
1116#define PCI_DEVICE_ID_NVIDIA_TNT 0x0020
1117#define PCI_DEVICE_ID_NVIDIA_TNT2 0x0028
1118#define PCI_DEVICE_ID_NVIDIA_UTNT2 0x0029
1119#define PCI_DEVICE_ID_NVIDIA_TNT_UNKNOWN 0x002a
1120#define PCI_DEVICE_ID_NVIDIA_VTNT2 0x002C
1121#define PCI_DEVICE_ID_NVIDIA_UVTNT2 0x002D
1122#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE 0x0035
1123#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SATA 0x0036
1124#define PCI_DEVICE_ID_NVIDIA_NVENET_10 0x0037
1125#define PCI_DEVICE_ID_NVIDIA_NVENET_11 0x0038
1126#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SATA2 0x003e
1127#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800_ULTRA 0x0040
1128#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800 0x0041
1129#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800_LE 0x0042
1130#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800_GT 0x0045
1131#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_4000 0x004E
1132#define PCI_DEVICE_ID_NVIDIA_NFORCE4_SMBUS 0x0052
1133#define PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE 0x0053
1134#define PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_SATA 0x0054
1135#define PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_SATA2 0x0055
1136#define PCI_DEVICE_ID_NVIDIA_NVENET_8 0x0056
1137#define PCI_DEVICE_ID_NVIDIA_NVENET_9 0x0057
1138#define PCI_DEVICE_ID_NVIDIA_CK804_AUDIO 0x0059
1139#define PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS 0x0064
1140#define PCI_DEVICE_ID_NVIDIA_NFORCE2_IDE 0x0065
1141#define PCI_DEVICE_ID_NVIDIA_NVENET_2 0x0066
1142#define PCI_DEVICE_ID_NVIDIA_MCP2_AUDIO 0x006a
1143#define PCI_DEVICE_ID_NVIDIA_NFORCE2S_SMBUS 0x0084
1144#define PCI_DEVICE_ID_NVIDIA_NFORCE2S_IDE 0x0085
1145#define PCI_DEVICE_ID_NVIDIA_NVENET_4 0x0086
1146#define PCI_DEVICE_ID_NVIDIA_NVENET_5 0x008c
1147#define PCI_DEVICE_ID_NVIDIA_NFORCE2S_SATA 0x008e
1148#define PCI_DEVICE_ID_NVIDIA_ITNT2 0x00A0
1149#define PCI_DEVICE_ID_GEFORCE_6800A 0x00c1
1150#define PCI_DEVICE_ID_GEFORCE_6800A_LE 0x00c2
1151#define PCI_DEVICE_ID_GEFORCE_GO_6800 0x00c8
1152#define PCI_DEVICE_ID_GEFORCE_GO_6800_ULTRA 0x00c9
1153#define PCI_DEVICE_ID_QUADRO_FX_GO1400 0x00cc
1154#define PCI_DEVICE_ID_QUADRO_FX_1400 0x00ce
1155#define PCI_DEVICE_ID_NVIDIA_NFORCE3 0x00d1
1156#define PCI_DEVICE_ID_NVIDIA_MCP3_AUDIO 0x00da
1157#define PCI_DEVICE_ID_NVIDIA_NFORCE3_SMBUS 0x00d4
1158#define PCI_DEVICE_ID_NVIDIA_NFORCE3_IDE 0x00d5
1159#define PCI_DEVICE_ID_NVIDIA_NVENET_3 0x00d6
1160#define PCI_DEVICE_ID_NVIDIA_MCP3_AUDIO 0x00da
1161#define PCI_DEVICE_ID_NVIDIA_NVENET_7 0x00df
1162#define PCI_DEVICE_ID_NVIDIA_NFORCE3S 0x00e1
1163#define PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA 0x00e3
1164#define PCI_DEVICE_ID_NVIDIA_NFORCE3S_SMBUS 0x00e4
1165#define PCI_DEVICE_ID_NVIDIA_NFORCE3S_IDE 0x00e5
1166#define PCI_DEVICE_ID_NVIDIA_NVENET_6 0x00e6
1167#define PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2 0x00ee
1168#define PCI_DEVICE_ID_NVIDIA_GEFORCE_SDR 0x0100
1169#define PCI_DEVICE_ID_NVIDIA_GEFORCE_DDR 0x0101
1170#define PCI_DEVICE_ID_NVIDIA_QUADRO 0x0103
1171#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX 0x0110
1172#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX2 0x0111
1173#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_GO 0x0112
1174#define PCI_DEVICE_ID_NVIDIA_QUADRO2_MXR 0x0113
1175#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6600_GT 0x0140
1176#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6600 0x0141
1177#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6610_XL 0x0145
1178#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_540 0x014E
1179#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6200 0x014F
1180#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS 0x0150
1181#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS2 0x0151
1182#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_ULTRA 0x0152
1183#define PCI_DEVICE_ID_NVIDIA_QUADRO2_PRO 0x0153
1184#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6200_TURBOCACHE 0x0161
1185#define PCI_DEVICE_ID_NVIDIA_GEFORCE_GO_6200 0x0164
1186#define PCI_DEVICE_ID_NVIDIA_GEFORCE_GO_6250 0x0166
1187#define PCI_DEVICE_ID_NVIDIA_GEFORCE_GO_6200_1 0x0167
1188#define PCI_DEVICE_ID_NVIDIA_GEFORCE_GO_6250_1 0x0168
1189#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_460 0x0170
1190#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_440 0x0171
1191#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_420 0x0172
1192#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_440_SE 0x0173
1193#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_440_GO 0x0174
1194#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_420_GO 0x0175
1195#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_420_GO_M32 0x0176
1196#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_460_GO 0x0177
1197#define PCI_DEVICE_ID_NVIDIA_QUADRO4_500XGL 0x0178
1198#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_440_GO_M64 0x0179
1199#define PCI_DEVICE_ID_NVIDIA_QUADRO4_200 0x017A
1200#define PCI_DEVICE_ID_NVIDIA_QUADRO4_550XGL 0x017B
1201#define PCI_DEVICE_ID_NVIDIA_QUADRO4_500_GOGL 0x017C
1202#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_410_GO_M16 0x017D
1203#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_440_8X 0x0181
1204#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_440SE_8X 0x0182
1205#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_420_8X 0x0183
1206#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_448_GO 0x0186
1207#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_488_GO 0x0187
1208#define PCI_DEVICE_ID_NVIDIA_QUADRO4_580_XGL 0x0188
1209#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_MAC 0x0189
1210#define PCI_DEVICE_ID_NVIDIA_QUADRO4_280_NVS 0x018A
1211#define PCI_DEVICE_ID_NVIDIA_QUADRO4_380_XGL 0x018B
1212#define PCI_DEVICE_ID_NVIDIA_IGEFORCE2 0x01a0
1213#define PCI_DEVICE_ID_NVIDIA_NFORCE 0x01a4
1214#define PCI_DEVICE_ID_NVIDIA_MCP1_AUDIO 0x01b1
1215#define PCI_DEVICE_ID_NVIDIA_NFORCE_SMBUS 0x01b4
1216#define PCI_DEVICE_ID_NVIDIA_NFORCE_IDE 0x01bc
1217#define PCI_DEVICE_ID_NVIDIA_NVENET_1 0x01c3
1218#define PCI_DEVICE_ID_NVIDIA_NFORCE2 0x01e0
1219#define PCI_DEVICE_ID_NVIDIA_GEFORCE3 0x0200
1220#define PCI_DEVICE_ID_NVIDIA_GEFORCE3_1 0x0201
1221#define PCI_DEVICE_ID_NVIDIA_GEFORCE3_2 0x0202
1222#define PCI_DEVICE_ID_NVIDIA_QUADRO_DDC 0x0203
1223#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800B 0x0211
1224#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800B_LE 0x0212
1225#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800B_GT 0x0215
1226#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4600 0x0250
1227#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4400 0x0251
1228#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4200 0x0253
1229#define PCI_DEVICE_ID_NVIDIA_QUADRO4_900XGL 0x0258
1230#define PCI_DEVICE_ID_NVIDIA_QUADRO4_750XGL 0x0259
1231#define PCI_DEVICE_ID_NVIDIA_QUADRO4_700XGL 0x025B
1232#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800 0x0280
1233#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800_8X 0x0281
1234#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800SE 0x0282
1235#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_4200_GO 0x0286
1236#define PCI_DEVICE_ID_NVIDIA_QUADRO4_980_XGL 0x0288
1237#define PCI_DEVICE_ID_NVIDIA_QUADRO4_780_XGL 0x0289
1238#define PCI_DEVICE_ID_NVIDIA_QUADRO4_700_GOGL 0x028C
1239#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5800_ULTRA 0x0301
1240#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5800 0x0302
1241#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_2000 0x0308
1242#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_1000 0x0309
1243#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5600_ULTRA 0x0311
1244#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5600 0x0312
1245#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5600SE 0x0314
1246#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5600 0x031A
1247#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5650 0x031B
1248#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_GO700 0x031C
1249#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5200 0x0320
1250#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5200_ULTRA 0x0321
1251#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5200_1 0x0322
1252#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5200SE 0x0323
1253#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5200 0x0324
1254#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5250 0x0325
1255#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5500 0x0326
1256#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5100 0x0327
1257#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5250_32 0x0328
1258#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO_5200 0x0329
1259#define PCI_DEVICE_ID_NVIDIA_QUADRO_NVS_280_PCI 0x032A
1260#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_500 0x032B
1261#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5300 0x032C
1262#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5100 0x032D
1263#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5900_ULTRA 0x0330
1264#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5900 0x0331
1265#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5900XT 0x0332
1266#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5950_ULTRA 0x0333
1267#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5900ZT 0x0334
1268#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_3000 0x0338
1269#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_700 0x033F
1270#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5700_ULTRA 0x0341
1271#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5700 0x0342
1272#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5700LE 0x0343
1273#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5700VE 0x0344
1274#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5700_1 0x0347
1275#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5700_2 0x0348
1276#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_GO1000 0x034C
1277#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_1100 0x034E
1278
1279#define PCI_VENDOR_ID_IMS 0x10e0
1280#define PCI_DEVICE_ID_IMS_8849 0x8849
1281#define PCI_DEVICE_ID_IMS_TT128 0x9128
1282#define PCI_DEVICE_ID_IMS_TT3D 0x9135
1283
1284#define PCI_VENDOR_ID_TEKRAM2 0x10e1
1285#define PCI_DEVICE_ID_TEKRAM2_690c 0x690c
1286
1287#define PCI_VENDOR_ID_TUNDRA 0x10e3
1288#define PCI_DEVICE_ID_TUNDRA_CA91C042 0x0000
1289
1290#define PCI_VENDOR_ID_AMCC 0x10e8
1291#define PCI_DEVICE_ID_AMCC_MYRINET 0x8043
1292#define PCI_DEVICE_ID_AMCC_PARASTATION 0x8062
1293#define PCI_DEVICE_ID_AMCC_S5933 0x807d
1294#define PCI_DEVICE_ID_AMCC_S5933_HEPC3 0x809c
1295
1296#define PCI_VENDOR_ID_INTERG 0x10ea
1297#define PCI_DEVICE_ID_INTERG_1680 0x1680
1298#define PCI_DEVICE_ID_INTERG_1682 0x1682
1299#define PCI_DEVICE_ID_INTERG_2000 0x2000
1300#define PCI_DEVICE_ID_INTERG_2010 0x2010
1301#define PCI_DEVICE_ID_INTERG_5000 0x5000
1302#define PCI_DEVICE_ID_INTERG_5050 0x5050
1303
1304#define PCI_VENDOR_ID_REALTEK 0x10ec
1305#define PCI_DEVICE_ID_REALTEK_8029 0x8029
1306#define PCI_DEVICE_ID_REALTEK_8129 0x8129
1307#define PCI_DEVICE_ID_REALTEK_8139 0x8139
1308#define PCI_DEVICE_ID_REALTEK_8169 0x8169
1309
1310#define PCI_VENDOR_ID_XILINX 0x10ee
1311#define PCI_DEVICE_ID_TURBOPAM 0x4020
1312
1313#define PCI_VENDOR_ID_TRUEVISION 0x10fa
1314#define PCI_DEVICE_ID_TRUEVISION_T1000 0x000c
1315
1316#define PCI_VENDOR_ID_INIT 0x1101
1317#define PCI_DEVICE_ID_INIT_320P 0x9100
1318#define PCI_DEVICE_ID_INIT_360P 0x9500
1319
1320#define PCI_VENDOR_ID_CREATIVE 0x1102 // duplicate: ECTIVA
1321#define PCI_DEVICE_ID_CREATIVE_EMU10K1 0x0002
1322
1323#define PCI_VENDOR_ID_ECTIVA 0x1102 // duplicate: CREATIVE
1324#define PCI_DEVICE_ID_ECTIVA_EV1938 0x8938
1325
1326#define PCI_VENDOR_ID_TTI 0x1103
1327#define PCI_DEVICE_ID_TTI_HPT343 0x0003
1328#define PCI_DEVICE_ID_TTI_HPT366 0x0004
1329#define PCI_DEVICE_ID_TTI_HPT372 0x0005
1330#define PCI_DEVICE_ID_TTI_HPT302 0x0006
1331#define PCI_DEVICE_ID_TTI_HPT371 0x0007
1332#define PCI_DEVICE_ID_TTI_HPT374 0x0008
1333#define PCI_DEVICE_ID_TTI_HPT372N 0x0009 // apparently a 372N variant?
1334
1335#define PCI_VENDOR_ID_VIA 0x1106
1336#define PCI_DEVICE_ID_VIA_8763_0 0x0198
1337#define PCI_DEVICE_ID_VIA_8380_0 0x0204
1338#define PCI_DEVICE_ID_VIA_3238_0 0x0238
1339#define PCI_DEVICE_ID_VIA_PT880 0x0258
1340#define PCI_DEVICE_ID_VIA_PX8X0_0 0x0259
1341#define PCI_DEVICE_ID_VIA_3269_0 0x0269
1342#define PCI_DEVICE_ID_VIA_K8T800PRO_0 0x0282
1343#define PCI_DEVICE_ID_VIA_8363_0 0x0305
1344#define PCI_DEVICE_ID_VIA_8371_0 0x0391
1345#define PCI_DEVICE_ID_VIA_8501_0 0x0501
1346#define PCI_DEVICE_ID_VIA_82C505 0x0505
1347#define PCI_DEVICE_ID_VIA_82C561 0x0561
1348#define PCI_DEVICE_ID_VIA_82C586_1 0x0571
1349#define PCI_DEVICE_ID_VIA_82C576 0x0576
1350#define PCI_DEVICE_ID_VIA_82C585 0x0585
1351#define PCI_DEVICE_ID_VIA_82C586_0 0x0586
1352#define PCI_DEVICE_ID_VIA_82C595 0x0595
1353#define PCI_DEVICE_ID_VIA_82C596 0x0596
1354#define PCI_DEVICE_ID_VIA_82C597_0 0x0597
1355#define PCI_DEVICE_ID_VIA_82C598_0 0x0598
1356#define PCI_DEVICE_ID_VIA_8601_0 0x0601
1357#define PCI_DEVICE_ID_VIA_8605_0 0x0605
1358#define PCI_DEVICE_ID_VIA_82C680 0x0680
1359#define PCI_DEVICE_ID_VIA_82C686 0x0686
1360#define PCI_DEVICE_ID_VIA_82C691_0 0x0691
1361#define PCI_DEVICE_ID_VIA_82C693 0x0693
1362#define PCI_DEVICE_ID_VIA_82C693_1 0x0698
1363#define PCI_DEVICE_ID_VIA_82C926 0x0926
1364#define PCI_DEVICE_ID_VIA_82C576_1 0x1571
1365#define PCI_DEVICE_ID_VIA_82C595_97 0x1595
1366#define PCI_DEVICE_ID_VIA_82C586_2 0x3038
1367#define PCI_DEVICE_ID_VIA_82C586_3 0x3040
1368#define PCI_DEVICE_ID_VIA_6305 0x3044
1369#define PCI_DEVICE_ID_VIA_82C596_3 0x3050
1370#define PCI_DEVICE_ID_VIA_82C596B_3 0x3051
1371#define PCI_DEVICE_ID_VIA_82C686_4 0x3057
1372#define PCI_DEVICE_ID_VIA_82C686_5 0x3058
1373#define PCI_DEVICE_ID_VIA_8233_5 0x3059
1374#define PCI_DEVICE_ID_VIA_8233_7 0x3065
1375#define PCI_DEVICE_ID_VIA_82C686_6 0x3068
1376#define PCI_DEVICE_ID_VIA_8233_0 0x3074
1377#define PCI_DEVICE_ID_VIA_8633_0 0x3091
1378#define PCI_DEVICE_ID_VIA_8367_0 0x3099
1379#define PCI_DEVICE_ID_VIA_8653_0 0x3101
1380#define PCI_DEVICE_ID_VIA_8622 0x3102
1381#define PCI_DEVICE_ID_VIA_8233C_0 0x3109
1382#define PCI_DEVICE_ID_VIA_8361 0x3112
1383#define PCI_DEVICE_ID_VIA_XM266 0x3116
1384#define PCI_DEVICE_ID_VIA_612X 0x3119
1385#define PCI_DEVICE_ID_VIA_862X_0 0x3123
1386#define PCI_DEVICE_ID_VIA_8753_0 0x3128
1387#define PCI_DEVICE_ID_VIA_8233A 0x3147
1388#define PCI_DEVICE_ID_VIA_8703_51_0 0x3148
1389#define PCI_DEVICE_ID_VIA_8237_SATA 0x3149
1390#define PCI_DEVICE_ID_VIA_XN266 0x3156
1391#define PCI_DEVICE_ID_VIA_8754C_0 0x3168
1392#define PCI_DEVICE_ID_VIA_8235 0x3177
1393#define PCI_DEVICE_ID_VIA_P4N333 0x3178
1394#define PCI_DEVICE_ID_VIA_8385_0 0x3188
1395#define PCI_DEVICE_ID_VIA_8377_0 0x3189
1396#define PCI_DEVICE_ID_VIA_8378_0 0x3205
1397#define PCI_DEVICE_ID_VIA_8783_0 0x3208
1398#define PCI_DEVICE_ID_VIA_P4M400 0x3209
1399#define PCI_DEVICE_ID_VIA_8237 0x3227
1400#define PCI_DEVICE_ID_VIA_3296_0 0x0296
1401#define PCI_DEVICE_ID_VIA_86C100A 0x6100
1402#define PCI_DEVICE_ID_VIA_8231 0x8231
1403#define PCI_DEVICE_ID_VIA_8231_4 0x8235
1404#define PCI_DEVICE_ID_VIA_8365_1 0x8305
1405#define PCI_DEVICE_ID_VIA_8371_1 0x8391
1406#define PCI_DEVICE_ID_VIA_8501_1 0x8501
1407#define PCI_DEVICE_ID_VIA_82C597_1 0x8597
1408#define PCI_DEVICE_ID_VIA_82C598_1 0x8598
1409#define PCI_DEVICE_ID_VIA_8601_1 0x8601
1410#define PCI_DEVICE_ID_VIA_8505_1 0x8605
1411#define PCI_DEVICE_ID_VIA_8633_1 0xB091
1412#define PCI_DEVICE_ID_VIA_8367_1 0xB099
1413#define PCI_DEVICE_ID_VIA_P4X266_1 0xB101
1414#define PCI_DEVICE_ID_VIA_8615_1 0xB103
1415#define PCI_DEVICE_ID_VIA_8361_1 0xB112
1416#define PCI_DEVICE_ID_VIA_8235_1 0xB168
1417#define PCI_DEVICE_ID_VIA_838X_1 0xB188
1418#define PCI_DEVICE_ID_VIA_83_87XX_1 0xB198
1419
1420#define PCI_VENDOR_ID_SIEMENS 0x110A
1421#define PCI_DEVICE_ID_SIEMENS_DSCC4 0x2102
1422
1423#define PCI_VENDOR_ID_SMC2 0x1113
1424#define PCI_DEVICE_ID_SMC2_1211TX 0x1211
1425
1426#define PCI_VENDOR_ID_VORTEX 0x1119
1427#define PCI_DEVICE_ID_VORTEX_GDT60x0 0x0000
1428#define PCI_DEVICE_ID_VORTEX_GDT6000B 0x0001
1429#define PCI_DEVICE_ID_VORTEX_GDT6x10 0x0002
1430#define PCI_DEVICE_ID_VORTEX_GDT6x20 0x0003
1431#define PCI_DEVICE_ID_VORTEX_GDT6530 0x0004
1432#define PCI_DEVICE_ID_VORTEX_GDT6550 0x0005
1433#define PCI_DEVICE_ID_VORTEX_GDT6x17 0x0006
1434#define PCI_DEVICE_ID_VORTEX_GDT6x27 0x0007
1435#define PCI_DEVICE_ID_VORTEX_GDT6537 0x0008
1436#define PCI_DEVICE_ID_VORTEX_GDT6557 0x0009
1437#define PCI_DEVICE_ID_VORTEX_GDT6x15 0x000a
1438#define PCI_DEVICE_ID_VORTEX_GDT6x25 0x000b
1439#define PCI_DEVICE_ID_VORTEX_GDT6535 0x000c
1440#define PCI_DEVICE_ID_VORTEX_GDT6555 0x000d
1441#define PCI_DEVICE_ID_VORTEX_GDT6x17RP 0x0100
1442#define PCI_DEVICE_ID_VORTEX_GDT6x27RP 0x0101
1443#define PCI_DEVICE_ID_VORTEX_GDT6537RP 0x0102
1444#define PCI_DEVICE_ID_VORTEX_GDT6557RP 0x0103
1445#define PCI_DEVICE_ID_VORTEX_GDT6x11RP 0x0104
1446#define PCI_DEVICE_ID_VORTEX_GDT6x21RP 0x0105
1447#define PCI_DEVICE_ID_VORTEX_GDT6x17RP1 0x0110
1448#define PCI_DEVICE_ID_VORTEX_GDT6x27RP1 0x0111
1449#define PCI_DEVICE_ID_VORTEX_GDT6537RP1 0x0112
1450#define PCI_DEVICE_ID_VORTEX_GDT6557RP1 0x0113
1451#define PCI_DEVICE_ID_VORTEX_GDT6x11RP1 0x0114
1452#define PCI_DEVICE_ID_VORTEX_GDT6x21RP1 0x0115
1453#define PCI_DEVICE_ID_VORTEX_GDT6x17RP2 0x0120
1454#define PCI_DEVICE_ID_VORTEX_GDT6x27RP2 0x0121
1455#define PCI_DEVICE_ID_VORTEX_GDT6537RP2 0x0122
1456#define PCI_DEVICE_ID_VORTEX_GDT6557RP2 0x0123
1457#define PCI_DEVICE_ID_VORTEX_GDT6x11RP2 0x0124
1458#define PCI_DEVICE_ID_VORTEX_GDT6x21RP2 0x0125
1459
1460#define PCI_VENDOR_ID_EF 0x111a
1461#define PCI_DEVICE_ID_EF_ATM_FPGA 0x0000
1462#define PCI_DEVICE_ID_EF_ATM_ASIC 0x0002
1463#define PCI_VENDOR_ID_EF_ATM_LANAI2 0x0003
1464#define PCI_VENDOR_ID_EF_ATM_LANAIHB 0x0005
1465
1466#define PCI_VENDOR_ID_IDT 0x111d
1467#define PCI_DEVICE_ID_IDT_IDT77201 0x0001
1468
1469#define PCI_VENDOR_ID_FORE 0x1127
1470#define PCI_DEVICE_ID_FORE_PCA200PC 0x0210
1471#define PCI_DEVICE_ID_FORE_PCA200E 0x0300
1472
1473#define PCI_VENDOR_ID_IMAGINGTECH 0x112f
1474#define PCI_DEVICE_ID_IMAGINGTECH_ICPCI 0x0000
1475
1476#define PCI_VENDOR_ID_PHILIPS 0x1131
1477#define PCI_DEVICE_ID_PHILIPS_SAA7145 0x7145
1478#define PCI_DEVICE_ID_PHILIPS_SAA7146 0x7146
1479#define PCI_DEVICE_ID_PHILIPS_SAA9730 0x9730
1480
1481#define PCI_VENDOR_ID_EICON 0x1133
1482#define PCI_DEVICE_ID_EICON_DIVA20PRO 0xe001
1483#define PCI_DEVICE_ID_EICON_DIVA20 0xe002
1484#define PCI_DEVICE_ID_EICON_DIVA20PRO_U 0xe003
1485#define PCI_DEVICE_ID_EICON_DIVA20_U 0xe004
1486#define PCI_DEVICE_ID_EICON_DIVA201 0xe005
1487#define PCI_DEVICE_ID_EICON_DIVA202 0xe00b
1488#define PCI_DEVICE_ID_EICON_MAESTRA 0xe010
1489#define PCI_DEVICE_ID_EICON_MAESTRAQ 0xe012
1490#define PCI_DEVICE_ID_EICON_MAESTRAQ_U 0xe013
1491#define PCI_DEVICE_ID_EICON_MAESTRAP 0xe014
1492
1493#define PCI_VENDOR_ID_ZIATECH 0x1138
1494#define PCI_DEVICE_ID_ZIATECH_5550_HC 0x5550
1495
1496#define PCI_VENDOR_ID_CYCLONE 0x113c
1497#define PCI_DEVICE_ID_CYCLONE_SDK 0x0001
1498
1499#define PCI_VENDOR_ID_ALLIANCE 0x1142
1500#define PCI_DEVICE_ID_ALLIANCE_PROMOTIO 0x3210
1501#define PCI_DEVICE_ID_ALLIANCE_PROVIDEO 0x6422
1502#define PCI_DEVICE_ID_ALLIANCE_AT24 0x6424
1503#define PCI_DEVICE_ID_ALLIANCE_AT3D 0x643d
1504
1505#define PCI_VENDOR_ID_SYSKONNECT 0x1148
1506#define PCI_DEVICE_ID_SYSKONNECT_FP 0x4000
1507#define PCI_DEVICE_ID_SYSKONNECT_TR 0x4200
1508#define PCI_DEVICE_ID_SYSKONNECT_GE 0x4300
1509#define PCI_DEVICE_ID_SYSKONNECT_YU 0x4320
1510#define PCI_DEVICE_ID_SYSKONNECT_9DXX 0x4400
1511#define PCI_DEVICE_ID_SYSKONNECT_9MXX 0x4500
1512
1513#define PCI_VENDOR_ID_VMIC 0x114a
1514#define PCI_DEVICE_ID_VMIC_VME 0x7587
1515
1516#define PCI_VENDOR_ID_DIGI 0x114f
1517#define PCI_DEVICE_ID_DIGI_EPC 0x0002
1518#define PCI_DEVICE_ID_DIGI_RIGHTSWITCH 0x0003
1519#define PCI_DEVICE_ID_DIGI_XEM 0x0004
1520#define PCI_DEVICE_ID_DIGI_XR 0x0005
1521#define PCI_DEVICE_ID_DIGI_CX 0x0006
1522#define PCI_DEVICE_ID_DIGI_XRJ 0x0009
1523#define PCI_DEVICE_ID_DIGI_EPCJ 0x000a
1524#define PCI_DEVICE_ID_DIGI_XR_920 0x0027
1525#define PCI_DEVICE_ID_DIGI_DF_M_IOM2_E 0x0070
1526#define PCI_DEVICE_ID_DIGI_DF_M_E 0x0071
1527#define PCI_DEVICE_ID_DIGI_DF_M_IOM2_A 0x0072
1528#define PCI_DEVICE_ID_DIGI_DF_M_A 0x0073
1529#define PCI_DEVICE_ID_NEO_2DB9 0x00C8
1530#define PCI_DEVICE_ID_NEO_2DB9PRI 0x00C9
1531#define PCI_DEVICE_ID_NEO_2RJ45 0x00CA
1532#define PCI_DEVICE_ID_NEO_2RJ45PRI 0x00CB
1533
1534#define PCI_VENDOR_ID_MUTECH 0x1159
1535#define PCI_DEVICE_ID_MUTECH_MV1000 0x0001
1536
1537#define PCI_VENDOR_ID_XIRCOM 0x115d
1538#define PCI_DEVICE_ID_XIRCOM_X3201_ETH 0x0003
1539#define PCI_DEVICE_ID_XIRCOM_RBM56G 0x0101
1540#define PCI_DEVICE_ID_XIRCOM_X3201_MDM 0x0103
1541
1542#define PCI_VENDOR_ID_RENDITION 0x1163
1543#define PCI_DEVICE_ID_RENDITION_VERITE 0x0001
1544#define PCI_DEVICE_ID_RENDITION_VERITE2100 0x2000
1545
1546#define PCI_VENDOR_ID_SERVERWORKS 0x1166
1547#define PCI_DEVICE_ID_SERVERWORKS_HE 0x0008
1548#define PCI_DEVICE_ID_SERVERWORKS_LE 0x0009
1549#define PCI_DEVICE_ID_SERVERWORKS_CIOB30 0x0010
1550#define PCI_DEVICE_ID_SERVERWORKS_CMIC_HE 0x0011
1551#define PCI_DEVICE_ID_SERVERWORKS_GCNB_LE 0x0017
1552#define PCI_DEVICE_ID_SERVERWORKS_OSB4 0x0200
1553#define PCI_DEVICE_ID_SERVERWORKS_CSB5 0x0201
1554#define PCI_DEVICE_ID_SERVERWORKS_CSB6 0x0203
1555#define PCI_DEVICE_ID_SERVERWORKS_OSB4IDE 0x0211
1556#define PCI_DEVICE_ID_SERVERWORKS_CSB5IDE 0x0212
1557#define PCI_DEVICE_ID_SERVERWORKS_CSB6IDE 0x0213
1558#define PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2 0x0217
1559#define PCI_DEVICE_ID_SERVERWORKS_OSB4USB 0x0220
1560#define PCI_DEVICE_ID_SERVERWORKS_CSB5USB PCI_DEVICE_ID_SERVERWORKS_OSB4USB
1561#define PCI_DEVICE_ID_SERVERWORKS_CSB6USB 0x0221
1562#define PCI_DEVICE_ID_SERVERWORKS_GCLE 0x0225
1563#define PCI_DEVICE_ID_SERVERWORKS_GCLE2 0x0227
1564#define PCI_DEVICE_ID_SERVERWORKS_CSB5ISA 0x0230
1565
1566#define PCI_VENDOR_ID_SBE 0x1176
1567#define PCI_DEVICE_ID_SBE_WANXL100 0x0301
1568#define PCI_DEVICE_ID_SBE_WANXL200 0x0302
1569#define PCI_DEVICE_ID_SBE_WANXL400 0x0104
1570
1571#define PCI_VENDOR_ID_TOSHIBA 0x1179
1572#define PCI_DEVICE_ID_TOSHIBA_PICCOLO 0x0102
1573#define PCI_DEVICE_ID_TOSHIBA_PICCOLO_1 0x0103
1574#define PCI_DEVICE_ID_TOSHIBA_PICCOLO_2 0x0105
1575#define PCI_DEVICE_ID_TOSHIBA_601 0x0601
1576#define PCI_DEVICE_ID_TOSHIBA_TOPIC95 0x060a
1577#define PCI_DEVICE_ID_TOSHIBA_TOPIC95_A 0x0603
1578#define PCI_DEVICE_ID_TOSHIBA_TOPIC95_B 0x060a
1579#define PCI_DEVICE_ID_TOSHIBA_TOPIC97 0x060f
1580#define PCI_DEVICE_ID_TOSHIBA_TOPIC100 0x0617
1581
1582#define PCI_VENDOR_ID_TOSHIBA_2 0x102f
1583#define PCI_DEVICE_ID_TOSHIBA_TX3927 0x000a
1584#define PCI_DEVICE_ID_TOSHIBA_TC35815CF 0x0030
1585#define PCI_DEVICE_ID_TOSHIBA_TX4927 0x0180
1586#define PCI_DEVICE_ID_TOSHIBA_TC86C001_MISC 0x0108
1587
1588#define PCI_VENDOR_ID_RICOH 0x1180
1589#define PCI_DEVICE_ID_RICOH_RL5C465 0x0465
1590#define PCI_DEVICE_ID_RICOH_RL5C466 0x0466
1591#define PCI_DEVICE_ID_RICOH_RL5C475 0x0475
1592#define PCI_DEVICE_ID_RICOH_RL5C476 0x0476
1593#define PCI_DEVICE_ID_RICOH_RL5C478 0x0478
1594
1595#define PCI_VENDOR_ID_DLINK 0x1186
1596#define PCI_DEVICE_ID_DLINK_DGE510T 0x4c00
1597
1598#define PCI_VENDOR_ID_ARTOP 0x1191
1599#define PCI_DEVICE_ID_ARTOP_ATP8400 0x0004
1600#define PCI_DEVICE_ID_ARTOP_ATP850UF 0x0005
1601#define PCI_DEVICE_ID_ARTOP_ATP860 0x0006
1602#define PCI_DEVICE_ID_ARTOP_ATP860R 0x0007
1603#define PCI_DEVICE_ID_ARTOP_ATP865 0x0008
1604#define PCI_DEVICE_ID_ARTOP_ATP865R 0x0009
1605#define PCI_DEVICE_ID_ARTOP_AEC7610 0x8002
1606#define PCI_DEVICE_ID_ARTOP_AEC7612UW 0x8010
1607#define PCI_DEVICE_ID_ARTOP_AEC7612U 0x8020
1608#define PCI_DEVICE_ID_ARTOP_AEC7612S 0x8030
1609#define PCI_DEVICE_ID_ARTOP_AEC7612D 0x8040
1610#define PCI_DEVICE_ID_ARTOP_AEC7612SUW 0x8050
1611#define PCI_DEVICE_ID_ARTOP_8060 0x8060
1612#define PCI_DEVICE_ID_ARTOP_AEC67160 0x8080
1613#define PCI_DEVICE_ID_ARTOP_AEC67160_2 0x8081
1614#define PCI_DEVICE_ID_ARTOP_AEC67162 0x808a
1615
1616#define PCI_VENDOR_ID_ZEITNET 0x1193
1617#define PCI_DEVICE_ID_ZEITNET_1221 0x0001
1618#define PCI_DEVICE_ID_ZEITNET_1225 0x0002
1619
1620#define PCI_VENDOR_ID_OMEGA 0x119b
1621#define PCI_DEVICE_ID_OMEGA_82C092G 0x1221
1622
1623#define PCI_VENDOR_ID_FUJITSU_ME 0x119e
1624#define PCI_DEVICE_ID_FUJITSU_FS155 0x0001
1625#define PCI_DEVICE_ID_FUJITSU_FS50 0x0003
1626
1627#define PCI_SUBVENDOR_ID_KEYSPAN 0x11a9
1628#define PCI_SUBDEVICE_ID_KEYSPAN_SX2 0x5334
1629
1630#define PCI_VENDOR_ID_MARVELL 0x11ab
1631#define PCI_DEVICE_ID_MARVELL_GT64011 0x4146
1632#define PCI_DEVICE_ID_MARVELL_GT64111 0x4146
1633#define PCI_DEVICE_ID_MARVELL_GT64260 0x6430
1634#define PCI_DEVICE_ID_MARVELL_MV64360 0x6460
1635#define PCI_DEVICE_ID_MARVELL_MV64460 0x6480
1636#define PCI_DEVICE_ID_MARVELL_GT96100 0x9652
1637#define PCI_DEVICE_ID_MARVELL_GT96100A 0x9653
1638
1639#define PCI_VENDOR_ID_LITEON 0x11ad
1640#define PCI_DEVICE_ID_LITEON_LNE100TX 0x0002
1641
1642#define PCI_VENDOR_ID_V3 0x11b0
1643#define PCI_DEVICE_ID_V3_V960 0x0001
1644#define PCI_DEVICE_ID_V3_V350 0x0001
1645#define PCI_DEVICE_ID_V3_V961 0x0002
1646#define PCI_DEVICE_ID_V3_V351 0x0002
1647
1648#define PCI_VENDOR_ID_NP 0x11bc
1649#define PCI_DEVICE_ID_NP_PCI_FDDI 0x0001
1650
1651#define PCI_VENDOR_ID_ATT 0x11c1
1652#define PCI_DEVICE_ID_ATT_L56XMF 0x0440
1653#define PCI_DEVICE_ID_ATT_VENUS_MODEM 0x480
1654
1655#define PCI_VENDOR_ID_NEC2 0x11c3 /* NEC (2nd) */
1656
1657#define PCI_VENDOR_ID_SPECIALIX 0x11cb
1658#define PCI_DEVICE_ID_SPECIALIX_IO8 0x2000
1659#define PCI_DEVICE_ID_SPECIALIX_XIO 0x4000
1660#define PCI_DEVICE_ID_SPECIALIX_RIO 0x8000
1661#define PCI_SUBDEVICE_ID_SPECIALIX_SPEED4 0xa004
1662
1663#define PCI_VENDOR_ID_AURAVISION 0x11d1
1664#define PCI_DEVICE_ID_AURAVISION_VXP524 0x01f7
1665
1666#define PCI_VENDOR_ID_ANALOG_DEVICES 0x11d4
1667#define PCI_DEVICE_ID_AD1889JS 0x1889
1668
1669#define PCI_VENDOR_ID_IKON 0x11d5
1670#define PCI_DEVICE_ID_IKON_10115 0x0115
1671#define PCI_DEVICE_ID_IKON_10117 0x0117
1672
1673#define PCI_VENDOR_ID_SEGA 0x11db
1674#define PCI_DEVICE_ID_SEGA_BBA 0x1234
1675
1676#define PCI_VENDOR_ID_ZORAN 0x11de
1677#define PCI_DEVICE_ID_ZORAN_36057 0x6057
1678#define PCI_DEVICE_ID_ZORAN_36120 0x6120
1679
1680#define PCI_VENDOR_ID_KINETIC 0x11f4
1681#define PCI_DEVICE_ID_KINETIC_2915 0x2915
1682
1683#define PCI_VENDOR_ID_COMPEX 0x11f6
1684#define PCI_DEVICE_ID_COMPEX_ENET100VG4 0x0112
1685#define PCI_DEVICE_ID_COMPEX_RL2000 0x1401
1686
1687#define PCI_VENDOR_ID_RP 0x11fe
1688#define PCI_DEVICE_ID_RP32INTF 0x0001
1689#define PCI_DEVICE_ID_RP8INTF 0x0002
1690#define PCI_DEVICE_ID_RP16INTF 0x0003
1691#define PCI_DEVICE_ID_RP4QUAD 0x0004
1692#define PCI_DEVICE_ID_RP8OCTA 0x0005
1693#define PCI_DEVICE_ID_RP8J 0x0006
1694#define PCI_DEVICE_ID_RP4J 0x0007
1695#define PCI_DEVICE_ID_RP8SNI 0x0008
1696#define PCI_DEVICE_ID_RP16SNI 0x0009
1697#define PCI_DEVICE_ID_RPP4 0x000A
1698#define PCI_DEVICE_ID_RPP8 0x000B
1699#define PCI_DEVICE_ID_RP8M 0x000C
1700#define PCI_DEVICE_ID_RP4M 0x000D
1701#define PCI_DEVICE_ID_RP2_232 0x000E
1702#define PCI_DEVICE_ID_RP2_422 0x000F
1703#define PCI_DEVICE_ID_URP32INTF 0x0801
1704#define PCI_DEVICE_ID_URP8INTF 0x0802
1705#define PCI_DEVICE_ID_URP16INTF 0x0803
1706#define PCI_DEVICE_ID_URP8OCTA 0x0805
1707#define PCI_DEVICE_ID_UPCI_RM3_8PORT 0x080C
1708#define PCI_DEVICE_ID_UPCI_RM3_4PORT 0x080D
1709#define PCI_DEVICE_ID_CRP16INTF 0x0903
1710
1711#define PCI_VENDOR_ID_CYCLADES 0x120e
1712#define PCI_DEVICE_ID_CYCLOM_Y_Lo 0x0100
1713#define PCI_DEVICE_ID_CYCLOM_Y_Hi 0x0101
1714#define PCI_DEVICE_ID_CYCLOM_4Y_Lo 0x0102
1715#define PCI_DEVICE_ID_CYCLOM_4Y_Hi 0x0103
1716#define PCI_DEVICE_ID_CYCLOM_8Y_Lo 0x0104
1717#define PCI_DEVICE_ID_CYCLOM_8Y_Hi 0x0105
1718#define PCI_DEVICE_ID_CYCLOM_Z_Lo 0x0200
1719#define PCI_DEVICE_ID_CYCLOM_Z_Hi 0x0201
1720#define PCI_DEVICE_ID_PC300_RX_2 0x0300
1721#define PCI_DEVICE_ID_PC300_RX_1 0x0301
1722#define PCI_DEVICE_ID_PC300_TE_2 0x0310
1723#define PCI_DEVICE_ID_PC300_TE_1 0x0311
1724#define PCI_DEVICE_ID_PC300_TE_M_2 0x0320
1725#define PCI_DEVICE_ID_PC300_TE_M_1 0x0321
1726
1727/* Allied Telesyn */
1728#define PCI_VENDOR_ID_AT 0x1259
1729#define PCI_SUBDEVICE_ID_AT_2701FX 0x2703
1730
1731#define PCI_VENDOR_ID_ESSENTIAL 0x120f
1732#define PCI_DEVICE_ID_ESSENTIAL_ROADRUNNER 0x0001
1733
1734#define PCI_VENDOR_ID_O2 0x1217
1735#define PCI_DEVICE_ID_O2_6729 0x6729
1736#define PCI_DEVICE_ID_O2_6730 0x673a
1737#define PCI_DEVICE_ID_O2_6832 0x6832
1738#define PCI_DEVICE_ID_O2_6836 0x6836
1739
1740#define PCI_VENDOR_ID_3DFX 0x121a
1741#define PCI_DEVICE_ID_3DFX_VOODOO 0x0001
1742#define PCI_DEVICE_ID_3DFX_VOODOO2 0x0002
1743#define PCI_DEVICE_ID_3DFX_BANSHEE 0x0003
1744#define PCI_DEVICE_ID_3DFX_VOODOO3 0x0005
1745#define PCI_DEVICE_ID_3DFX_VOODOO5 0x0009
1746
1747#define PCI_VENDOR_ID_SIGMADES 0x1236
1748#define PCI_DEVICE_ID_SIGMADES_6425 0x6401
1749
1750#define PCI_VENDOR_ID_CCUBE 0x123f
1751
1752#define PCI_VENDOR_ID_AVM 0x1244
1753#define PCI_DEVICE_ID_AVM_B1 0x0700
1754#define PCI_DEVICE_ID_AVM_C4 0x0800
1755#define PCI_DEVICE_ID_AVM_A1 0x0a00
1756#define PCI_DEVICE_ID_AVM_A1_V2 0x0e00
1757#define PCI_DEVICE_ID_AVM_C2 0x1100
1758#define PCI_DEVICE_ID_AVM_T1 0x1200
1759
1760#define PCI_VENDOR_ID_DIPIX 0x1246
1761
1762#define PCI_VENDOR_ID_STALLION 0x124d
1763#define PCI_DEVICE_ID_STALLION_ECHPCI832 0x0000
1764#define PCI_DEVICE_ID_STALLION_ECHPCI864 0x0002
1765#define PCI_DEVICE_ID_STALLION_EIOPCI 0x0003
1766
1767#define PCI_VENDOR_ID_OPTIBASE 0x1255
1768#define PCI_DEVICE_ID_OPTIBASE_FORGE 0x1110
1769#define PCI_DEVICE_ID_OPTIBASE_FUSION 0x1210
1770#define PCI_DEVICE_ID_OPTIBASE_VPLEX 0x2110
1771#define PCI_DEVICE_ID_OPTIBASE_VPLEXCC 0x2120
1772#define PCI_DEVICE_ID_OPTIBASE_VQUEST 0x2130
1773
1774/* Allied Telesyn */
1775#define PCI_VENDOR_ID_AT 0x1259
1776#define PCI_SUBDEVICE_ID_AT_2700FX 0x2701
1777#define PCI_SUBDEVICE_ID_AT_2701FX 0x2703
1778
1779#define PCI_VENDOR_ID_ESS 0x125d
1780#define PCI_DEVICE_ID_ESS_ESS1968 0x1968
1781#define PCI_DEVICE_ID_ESS_AUDIOPCI 0x1969
1782#define PCI_DEVICE_ID_ESS_ESS1978 0x1978
1783
1784#define PCI_VENDOR_ID_SATSAGEM 0x1267
1785#define PCI_DEVICE_ID_SATSAGEM_NICCY 0x1016
1786#define PCI_DEVICE_ID_SATSAGEM_PCR2101 0x5352
1787#define PCI_DEVICE_ID_SATSAGEM_TELSATTURBO 0x5a4b
1788
1789#define PCI_VENDOR_ID_HUGHES 0x1273
1790#define PCI_DEVICE_ID_HUGHES_DIRECPC 0x0002
1791
1792#define PCI_VENDOR_ID_ENSONIQ 0x1274
1793#define PCI_DEVICE_ID_ENSONIQ_CT5880 0x5880
1794#define PCI_DEVICE_ID_ENSONIQ_ES1370 0x5000
1795#define PCI_DEVICE_ID_ENSONIQ_ES1371 0x1371
1796
1797#define PCI_VENDOR_ID_TRANSMETA 0x1279
1798#define PCI_DEVICE_ID_EFFICEON 0x0060
1799
1800#define PCI_VENDOR_ID_ROCKWELL 0x127A
1801
1802#define PCI_VENDOR_ID_ITE 0x1283
1803#define PCI_DEVICE_ID_ITE_IT8172G 0x8172
1804#define PCI_DEVICE_ID_ITE_IT8172G_AUDIO 0x0801
1805#define PCI_DEVICE_ID_ITE_8872 0x8872
1806#define PCI_DEVICE_ID_ITE_IT8330G_0 0xe886
1807
1808/* formerly Platform Tech */
1809#define PCI_VENDOR_ID_ESS_OLD 0x1285
1810#define PCI_DEVICE_ID_ESS_ESS0100 0x0100
1811
1812#define PCI_VENDOR_ID_ALTEON 0x12ae
1813#define PCI_DEVICE_ID_ALTEON_ACENIC 0x0001
1814
1815#define PCI_VENDOR_ID_USR 0x12B9
1816
1817#define PCI_SUBVENDOR_ID_CONNECT_TECH 0x12c4
1818#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_232 0x0001
1819#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH4_232 0x0002
1820#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH2_232 0x0003
1821#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_485 0x0004
1822#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_485_4_4 0x0005
1823#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH4_485 0x0006
1824#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH4_485_2_2 0x0007
1825#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH2_485 0x0008
1826#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_485_2_6 0x0009
1827#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH081101V1 0x000A
1828#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH041101V1 0x000B
1829
1830#define PCI_VENDOR_ID_PICTUREL 0x12c5
1831#define PCI_DEVICE_ID_PICTUREL_PCIVST 0x0081
1832
1833#define PCI_VENDOR_ID_NVIDIA_SGS 0x12d2
1834#define PCI_DEVICE_ID_NVIDIA_SGS_RIVA128 0x0018
1835
1836#define PCI_SUBVENDOR_ID_CHASE_PCIFAST 0x12E0
1837#define PCI_SUBDEVICE_ID_CHASE_PCIFAST4 0x0031
1838#define PCI_SUBDEVICE_ID_CHASE_PCIFAST8 0x0021
1839#define PCI_SUBDEVICE_ID_CHASE_PCIFAST16 0x0011
1840#define PCI_SUBDEVICE_ID_CHASE_PCIFAST16FMC 0x0041
1841#define PCI_SUBVENDOR_ID_CHASE_PCIRAS 0x124D
1842#define PCI_SUBDEVICE_ID_CHASE_PCIRAS4 0xF001
1843#define PCI_SUBDEVICE_ID_CHASE_PCIRAS8 0xF010
1844
1845#define PCI_VENDOR_ID_AUREAL 0x12eb
1846#define PCI_DEVICE_ID_AUREAL_VORTEX_1 0x0001
1847#define PCI_DEVICE_ID_AUREAL_VORTEX_2 0x0002
1848#define PCI_DEVICE_ID_AUREAL_ADVANTAGE 0x0003
1849
1850#define PCI_VENDOR_ID_ELECTRONICDESIGNGMBH 0x12f8
1851#define PCI_DEVICE_ID_LML_33R10 0x8a02
1852
1853#define PCI_VENDOR_ID_CBOARDS 0x1307
1854#define PCI_DEVICE_ID_CBOARDS_DAS1602_16 0x0001
1855
1856#define PCI_VENDOR_ID_SIIG 0x131f
1857#define PCI_DEVICE_ID_SIIG_1S_10x_550 0x1000
1858#define PCI_DEVICE_ID_SIIG_1S_10x_650 0x1001
1859#define PCI_DEVICE_ID_SIIG_1S_10x_850 0x1002
1860#define PCI_DEVICE_ID_SIIG_1S1P_10x_550 0x1010
1861#define PCI_DEVICE_ID_SIIG_1S1P_10x_650 0x1011
1862#define PCI_DEVICE_ID_SIIG_1S1P_10x_850 0x1012
1863#define PCI_DEVICE_ID_SIIG_1P_10x 0x1020
1864#define PCI_DEVICE_ID_SIIG_2P_10x 0x1021
1865#define PCI_DEVICE_ID_SIIG_2S_10x_550 0x1030
1866#define PCI_DEVICE_ID_SIIG_2S_10x_650 0x1031
1867#define PCI_DEVICE_ID_SIIG_2S_10x_850 0x1032
1868#define PCI_DEVICE_ID_SIIG_2S1P_10x_550 0x1034
1869#define PCI_DEVICE_ID_SIIG_2S1P_10x_650 0x1035
1870#define PCI_DEVICE_ID_SIIG_2S1P_10x_850 0x1036
1871#define PCI_DEVICE_ID_SIIG_4S_10x_550 0x1050
1872#define PCI_DEVICE_ID_SIIG_4S_10x_650 0x1051
1873#define PCI_DEVICE_ID_SIIG_4S_10x_850 0x1052
1874#define PCI_DEVICE_ID_SIIG_1S_20x_550 0x2000
1875#define PCI_DEVICE_ID_SIIG_1S_20x_650 0x2001
1876#define PCI_DEVICE_ID_SIIG_1S_20x_850 0x2002
1877#define PCI_DEVICE_ID_SIIG_1P_20x 0x2020
1878#define PCI_DEVICE_ID_SIIG_2P_20x 0x2021
1879#define PCI_DEVICE_ID_SIIG_2S_20x_550 0x2030
1880#define PCI_DEVICE_ID_SIIG_2S_20x_650 0x2031
1881#define PCI_DEVICE_ID_SIIG_2S_20x_850 0x2032
1882#define PCI_DEVICE_ID_SIIG_2P1S_20x_550 0x2040
1883#define PCI_DEVICE_ID_SIIG_2P1S_20x_650 0x2041
1884#define PCI_DEVICE_ID_SIIG_2P1S_20x_850 0x2042
1885#define PCI_DEVICE_ID_SIIG_1S1P_20x_550 0x2010
1886#define PCI_DEVICE_ID_SIIG_1S1P_20x_650 0x2011
1887#define PCI_DEVICE_ID_SIIG_1S1P_20x_850 0x2012
1888#define PCI_DEVICE_ID_SIIG_4S_20x_550 0x2050
1889#define PCI_DEVICE_ID_SIIG_4S_20x_650 0x2051
1890#define PCI_DEVICE_ID_SIIG_4S_20x_850 0x2052
1891#define PCI_DEVICE_ID_SIIG_2S1P_20x_550 0x2060
1892#define PCI_DEVICE_ID_SIIG_2S1P_20x_650 0x2061
1893#define PCI_DEVICE_ID_SIIG_2S1P_20x_850 0x2062
1894
1895#define PCI_VENDOR_ID_RADISYS 0x1331
1896#define PCI_DEVICE_ID_RADISYS_ENP2611 0x0030
1897
1898#define PCI_VENDOR_ID_DOMEX 0x134a
1899#define PCI_DEVICE_ID_DOMEX_DMX3191D 0x0001
1900
1901#define PCI_VENDOR_ID_QUATECH 0x135C
1902#define PCI_DEVICE_ID_QUATECH_QSC100 0x0010
1903#define PCI_DEVICE_ID_QUATECH_DSC100 0x0020
1904#define PCI_DEVICE_ID_QUATECH_DSC200 0x0030
1905#define PCI_DEVICE_ID_QUATECH_QSC200 0x0040
1906#define PCI_DEVICE_ID_QUATECH_ESC100D 0x0050
1907#define PCI_DEVICE_ID_QUATECH_ESC100M 0x0060
1908
1909#define PCI_VENDOR_ID_SEALEVEL 0x135e
1910#define PCI_DEVICE_ID_SEALEVEL_U530 0x7101
1911#define PCI_DEVICE_ID_SEALEVEL_UCOMM2 0x7201
1912#define PCI_DEVICE_ID_SEALEVEL_UCOMM422 0x7402
1913#define PCI_DEVICE_ID_SEALEVEL_UCOMM232 0x7202
1914#define PCI_DEVICE_ID_SEALEVEL_COMM4 0x7401
1915#define PCI_DEVICE_ID_SEALEVEL_COMM8 0x7801
1916#define PCI_DEVICE_ID_SEALEVEL_UCOMM8 0x7804
1917
1918#define PCI_VENDOR_ID_HYPERCOPE 0x1365
1919#define PCI_DEVICE_ID_HYPERCOPE_PLX 0x9050
1920#define PCI_SUBDEVICE_ID_HYPERCOPE_OLD_ERGO 0x0104
1921#define PCI_SUBDEVICE_ID_HYPERCOPE_ERGO 0x0106
1922#define PCI_SUBDEVICE_ID_HYPERCOPE_METRO 0x0107
1923#define PCI_SUBDEVICE_ID_HYPERCOPE_CHAMP2 0x0108
1924#define PCI_SUBDEVICE_ID_HYPERCOPE_PLEXUS 0x0109
1925
1926#define PCI_VENDOR_ID_KAWASAKI 0x136b
1927#define PCI_DEVICE_ID_MCHIP_KL5A72002 0xff01
1928
1929#define PCI_VENDOR_ID_CNET 0x1371
1930#define PCI_DEVICE_ID_CNET_GIGACARD 0x434e
1931
1932#define PCI_VENDOR_ID_LMC 0x1376
1933#define PCI_DEVICE_ID_LMC_HSSI 0x0003
1934#define PCI_DEVICE_ID_LMC_DS3 0x0004
1935#define PCI_DEVICE_ID_LMC_SSI 0x0005
1936#define PCI_DEVICE_ID_LMC_T1 0x0006
1937
1938#define PCI_VENDOR_ID_NETGEAR 0x1385
1939#define PCI_DEVICE_ID_NETGEAR_GA620 0x620a
1940#define PCI_DEVICE_ID_NETGEAR_GA622 0x622a
1941
1942#define PCI_VENDOR_ID_APPLICOM 0x1389
1943#define PCI_DEVICE_ID_APPLICOM_PCIGENERIC 0x0001
1944#define PCI_DEVICE_ID_APPLICOM_PCI2000IBS_CAN 0x0002
1945#define PCI_DEVICE_ID_APPLICOM_PCI2000PFB 0x0003
1946
1947#define PCI_VENDOR_ID_MOXA 0x1393
1948#define PCI_DEVICE_ID_MOXA_RC7000 0x0001
1949#define PCI_DEVICE_ID_MOXA_CP102 0x1020
1950#define PCI_DEVICE_ID_MOXA_CP102UL 0x1021
1951#define PCI_DEVICE_ID_MOXA_CP102U 0x1022
1952#define PCI_DEVICE_ID_MOXA_C104 0x1040
1953#define PCI_DEVICE_ID_MOXA_CP104U 0x1041
1954#define PCI_DEVICE_ID_MOXA_CP104JU 0x1042
1955#define PCI_DEVICE_ID_MOXA_CT114 0x1140
1956#define PCI_DEVICE_ID_MOXA_CP114 0x1141
1957#define PCI_DEVICE_ID_MOXA_CP118U 0x1180
1958#define PCI_DEVICE_ID_MOXA_CP132 0x1320
1959#define PCI_DEVICE_ID_MOXA_CP132U 0x1321
1960#define PCI_DEVICE_ID_MOXA_CP134U 0x1340
1961#define PCI_DEVICE_ID_MOXA_C168 0x1680
1962#define PCI_DEVICE_ID_MOXA_CP168U 0x1681
1963#define PCI_DEVICE_ID_MOXA_CP204J 0x2040
1964#define PCI_DEVICE_ID_MOXA_C218 0x2180
1965#define PCI_DEVICE_ID_MOXA_C320 0x3200
1966
1967#define PCI_VENDOR_ID_CCD 0x1397
1968#define PCI_DEVICE_ID_CCD_2BD0 0x2bd0
1969#define PCI_DEVICE_ID_CCD_B000 0xb000
1970#define PCI_DEVICE_ID_CCD_B006 0xb006
1971#define PCI_DEVICE_ID_CCD_B007 0xb007
1972#define PCI_DEVICE_ID_CCD_B008 0xb008
1973#define PCI_DEVICE_ID_CCD_B009 0xb009
1974#define PCI_DEVICE_ID_CCD_B00A 0xb00a
1975#define PCI_DEVICE_ID_CCD_B00B 0xb00b
1976#define PCI_DEVICE_ID_CCD_B00C 0xb00c
1977#define PCI_DEVICE_ID_CCD_B100 0xb100
1978
1979#define PCI_VENDOR_ID_EXAR 0x13a8
1980#define PCI_DEVICE_ID_EXAR_XR17C152 0x0152
1981#define PCI_DEVICE_ID_EXAR_XR17C154 0x0154
1982#define PCI_DEVICE_ID_EXAR_XR17C158 0x0158
1983
1984#define PCI_VENDOR_ID_MICROGATE 0x13c0
1985#define PCI_DEVICE_ID_MICROGATE_USC 0x0010
1986#define PCI_DEVICE_ID_MICROGATE_SCC 0x0020
1987#define PCI_DEVICE_ID_MICROGATE_SCA 0x0030
1988#define PCI_DEVICE_ID_MICROGATE_USC2 0x0210
1989
1990#define PCI_VENDOR_ID_3WARE 0x13C1
1991#define PCI_DEVICE_ID_3WARE_1000 0x1000
1992#define PCI_DEVICE_ID_3WARE_7000 0x1001
1993#define PCI_DEVICE_ID_3WARE_9000 0x1002
1994
1995#define PCI_VENDOR_ID_IOMEGA 0x13ca
1996#define PCI_DEVICE_ID_IOMEGA_BUZ 0x4231
1997
1998#define PCI_VENDOR_ID_ABOCOM 0x13D1
1999#define PCI_DEVICE_ID_ABOCOM_2BD1 0x2BD1
2000
2001#define PCI_VENDOR_ID_CMEDIA 0x13f6
2002#define PCI_DEVICE_ID_CMEDIA_CM8338A 0x0100
2003#define PCI_DEVICE_ID_CMEDIA_CM8338B 0x0101
2004#define PCI_DEVICE_ID_CMEDIA_CM8738 0x0111
2005#define PCI_DEVICE_ID_CMEDIA_CM8738B 0x0112
2006
2007#define PCI_VENDOR_ID_LAVA 0x1407
2008#define PCI_DEVICE_ID_LAVA_DSERIAL 0x0100 /* 2x 16550 */
2009#define PCI_DEVICE_ID_LAVA_QUATRO_A 0x0101 /* 2x 16550, half of 4 port */
2010#define PCI_DEVICE_ID_LAVA_QUATRO_B 0x0102 /* 2x 16550, half of 4 port */
2011#define PCI_DEVICE_ID_LAVA_OCTO_A 0x0180 /* 4x 16550A, half of 8 port */
2012#define PCI_DEVICE_ID_LAVA_OCTO_B 0x0181 /* 4x 16550A, half of 8 port */
2013#define PCI_DEVICE_ID_LAVA_PORT_PLUS 0x0200 /* 2x 16650 */
2014#define PCI_DEVICE_ID_LAVA_QUAD_A 0x0201 /* 2x 16650, half of 4 port */
2015#define PCI_DEVICE_ID_LAVA_QUAD_B 0x0202 /* 2x 16650, half of 4 port */
2016#define PCI_DEVICE_ID_LAVA_SSERIAL 0x0500 /* 1x 16550 */
2017#define PCI_DEVICE_ID_LAVA_PORT_650 0x0600 /* 1x 16650 */
2018#define PCI_DEVICE_ID_LAVA_PARALLEL 0x8000
2019#define PCI_DEVICE_ID_LAVA_DUAL_PAR_A 0x8002 /* The Lava Dual Parallel is */
2020#define PCI_DEVICE_ID_LAVA_DUAL_PAR_B 0x8003 /* two PCI devices on a card */
2021#define PCI_DEVICE_ID_LAVA_BOCA_IOPPAR 0x8800
2022
2023#define PCI_VENDOR_ID_TIMEDIA 0x1409
2024#define PCI_DEVICE_ID_TIMEDIA_1889 0x7168
2025
2026#define PCI_VENDOR_ID_OXSEMI 0x1415
2027#define PCI_DEVICE_ID_OXSEMI_12PCI840 0x8403
2028#define PCI_DEVICE_ID_OXSEMI_16PCI954 0x9501
2029#define PCI_DEVICE_ID_OXSEMI_16PCI95N 0x9511
2030#define PCI_DEVICE_ID_OXSEMI_16PCI954PP 0x9513
2031#define PCI_DEVICE_ID_OXSEMI_16PCI952 0x9521
2032
2033#define PCI_VENDOR_ID_SAMSUNG 0x144d
2034
2035#define PCI_VENDOR_ID_AIRONET 0x14b9
2036#define PCI_DEVICE_ID_AIRONET_4800_1 0x0001
2037#define PCI_DEVICE_ID_AIRONET_4800 0x4500 // values switched? see
2038#define PCI_DEVICE_ID_AIRONET_4500 0x4800 // drivers/net/aironet4500_card.c
2039
2040#define PCI_VENDOR_ID_TITAN 0x14D2
2041#define PCI_DEVICE_ID_TITAN_010L 0x8001
2042#define PCI_DEVICE_ID_TITAN_100L 0x8010
2043#define PCI_DEVICE_ID_TITAN_110L 0x8011
2044#define PCI_DEVICE_ID_TITAN_200L 0x8020
2045#define PCI_DEVICE_ID_TITAN_210L 0x8021
2046#define PCI_DEVICE_ID_TITAN_400L 0x8040
2047#define PCI_DEVICE_ID_TITAN_800L 0x8080
2048#define PCI_DEVICE_ID_TITAN_100 0xA001
2049#define PCI_DEVICE_ID_TITAN_200 0xA005
2050#define PCI_DEVICE_ID_TITAN_400 0xA003
2051#define PCI_DEVICE_ID_TITAN_800B 0xA004
2052
2053#define PCI_VENDOR_ID_PANACOM 0x14d4
2054#define PCI_DEVICE_ID_PANACOM_QUADMODEM 0x0400
2055#define PCI_DEVICE_ID_PANACOM_DUALMODEM 0x0402
2056
2057#define PCI_VENDOR_ID_SIPACKETS 0x14d9
2058#define PCI_DEVICE_ID_SP_HT 0x0010
2059
2060#define PCI_VENDOR_ID_AFAVLAB 0x14db
2061#define PCI_DEVICE_ID_AFAVLAB_P028 0x2180
2062#define PCI_DEVICE_ID_AFAVLAB_P030 0x2182
2063
2064#define PCI_VENDOR_ID_BROADCOM 0x14e4
2065#define PCI_DEVICE_ID_TIGON3_5700 0x1644
2066#define PCI_DEVICE_ID_TIGON3_5701 0x1645
2067#define PCI_DEVICE_ID_TIGON3_5702 0x1646
2068#define PCI_DEVICE_ID_TIGON3_5703 0x1647
2069#define PCI_DEVICE_ID_TIGON3_5704 0x1648
2070#define PCI_DEVICE_ID_TIGON3_5704S_2 0x1649
2071#define PCI_DEVICE_ID_TIGON3_5702FE 0x164d
2072#define PCI_DEVICE_ID_TIGON3_5705 0x1653
2073#define PCI_DEVICE_ID_TIGON3_5705_2 0x1654
2074#define PCI_DEVICE_ID_TIGON3_5720 0x1658
2075#define PCI_DEVICE_ID_TIGON3_5721 0x1659
2076#define PCI_DEVICE_ID_TIGON3_5705M 0x165d
2077#define PCI_DEVICE_ID_TIGON3_5705M_2 0x165e
2078#define PCI_DEVICE_ID_TIGON3_5705F 0x166e
2079#define PCI_DEVICE_ID_TIGON3_5750 0x1676
2080#define PCI_DEVICE_ID_TIGON3_5751 0x1677
2081#define PCI_DEVICE_ID_TIGON3_5750M 0x167c
2082#define PCI_DEVICE_ID_TIGON3_5751M 0x167d
2083#define PCI_DEVICE_ID_TIGON3_5751F 0x167e
2084#define PCI_DEVICE_ID_TIGON3_5782 0x1696
2085#define PCI_DEVICE_ID_TIGON3_5788 0x169c
2086#define PCI_DEVICE_ID_TIGON3_5789 0x169d
2087#define PCI_DEVICE_ID_TIGON3_5702X 0x16a6
2088#define PCI_DEVICE_ID_TIGON3_5703X 0x16a7
2089#define PCI_DEVICE_ID_TIGON3_5704S 0x16a8
2090#define PCI_DEVICE_ID_TIGON3_5702A3 0x16c6
2091#define PCI_DEVICE_ID_TIGON3_5703A3 0x16c7
2092#define PCI_DEVICE_ID_TIGON3_5781 0x16dd
2093#define PCI_DEVICE_ID_TIGON3_5753 0x16f7
2094#define PCI_DEVICE_ID_TIGON3_5753M 0x16fd
2095#define PCI_DEVICE_ID_TIGON3_5753F 0x16fe
2096#define PCI_DEVICE_ID_TIGON3_5901 0x170d
2097#define PCI_DEVICE_ID_BCM4401B1 0x170c
2098#define PCI_DEVICE_ID_TIGON3_5901_2 0x170e
2099#define PCI_DEVICE_ID_BCM4401 0x4401
2100#define PCI_DEVICE_ID_BCM4401B0 0x4402
2101
2102#define PCI_VENDOR_ID_TOPIC 0x151f
2103#define PCI_DEVICE_ID_TOPIC_TP560 0x0000
2104
2105#define PCI_VENDOR_ID_ENE 0x1524
2106#define PCI_DEVICE_ID_ENE_1211 0x1211
2107#define PCI_DEVICE_ID_ENE_1225 0x1225
2108#define PCI_DEVICE_ID_ENE_1410 0x1410
2109#define PCI_DEVICE_ID_ENE_1420 0x1420
2110
2111#define PCI_VENDOR_ID_SYBA 0x1592
2112#define PCI_DEVICE_ID_SYBA_2P_EPP 0x0782
2113#define PCI_DEVICE_ID_SYBA_1P_ECP 0x0783
2114
2115#define PCI_VENDOR_ID_MORETON 0x15aa
2116#define PCI_DEVICE_ID_RASTEL_2PORT 0x2000
2117
2118#define PCI_VENDOR_ID_ZOLTRIX 0x15b0
2119#define PCI_DEVICE_ID_ZOLTRIX_2BD0 0x2bd0
2120
2121#define PCI_VENDOR_ID_MELLANOX 0x15b3
2122#define PCI_DEVICE_ID_MELLANOX_TAVOR 0x5a44
2123#define PCI_DEVICE_ID_MELLANOX_ARBEL_COMPAT 0x6278
2124#define PCI_DEVICE_ID_MELLANOX_ARBEL 0x6282
2125#define PCI_DEVICE_ID_MELLANOX_SINAI_OLD 0x5e8c
2126#define PCI_DEVICE_ID_MELLANOX_SINAI 0x6274
2127
2128#define PCI_VENDOR_ID_PDC 0x15e9
2129#define PCI_DEVICE_ID_PDC_1841 0x1841
2130
2131#define PCI_VENDOR_ID_MACROLINK 0x15ed
2132#define PCI_DEVICE_ID_MACROLINK_MCCS8 0x1000
2133#define PCI_DEVICE_ID_MACROLINK_MCCS 0x1001
2134#define PCI_DEVICE_ID_MACROLINK_MCCS8H 0x1002
2135#define PCI_DEVICE_ID_MACROLINK_MCCSH 0x1003
2136#define PCI_DEVICE_ID_MACROLINK_MCCR8 0x2000
2137#define PCI_DEVICE_ID_MACROLINK_MCCR 0x2001
2138
2139#define PCI_VENDOR_ID_FARSITE 0x1619
2140#define PCI_DEVICE_ID_FARSITE_T2P 0x0400
2141#define PCI_DEVICE_ID_FARSITE_T4P 0x0440
2142#define PCI_DEVICE_ID_FARSITE_T1U 0x0610
2143#define PCI_DEVICE_ID_FARSITE_T2U 0x0620
2144#define PCI_DEVICE_ID_FARSITE_T4U 0x0640
2145#define PCI_DEVICE_ID_FARSITE_TE1 0x1610
2146#define PCI_DEVICE_ID_FARSITE_TE1C 0x1612
2147
2148#define PCI_VENDOR_ID_SIBYTE 0x166d
2149#define PCI_DEVICE_ID_BCM1250_HT 0x0002
2150
2151#define PCI_VENDOR_ID_LINKSYS 0x1737
2152#define PCI_DEVICE_ID_LINKSYS_EG1032 0x1032
2153#define PCI_DEVICE_ID_LINKSYS_EG1064 0x1064
2154
2155#define PCI_VENDOR_ID_ALTIMA 0x173b
2156#define PCI_DEVICE_ID_ALTIMA_AC1000 0x03e8
2157#define PCI_DEVICE_ID_ALTIMA_AC1001 0x03e9
2158#define PCI_DEVICE_ID_ALTIMA_AC9100 0x03ea
2159#define PCI_DEVICE_ID_ALTIMA_AC1003 0x03eb
2160
2161#define PCI_VENDOR_ID_S2IO 0x17d5
2162#define PCI_DEVICE_ID_S2IO_WIN 0x5731
2163#define PCI_DEVICE_ID_S2IO_UNI 0x5831
2164#define PCI_DEVICE_ID_HERC_WIN 0x5732
2165#define PCI_DEVICE_ID_HERC_UNI 0x5832
2166
2167#define PCI_VENDOR_ID_INFINICON 0x1820
2168
2169#define PCI_VENDOR_ID_TOPSPIN 0x1867
2170
2171#define PCI_VENDOR_ID_TDI 0x192E
2172#define PCI_DEVICE_ID_TDI_EHCI 0x0101
2173
2174#define PCI_VENDOR_ID_SYMPHONY 0x1c1c
2175#define PCI_DEVICE_ID_SYMPHONY_101 0x0001
2176
2177#define PCI_VENDOR_ID_TEKRAM 0x1de1
2178#define PCI_DEVICE_ID_TEKRAM_DC290 0xdc29
2179
2180#define PCI_VENDOR_ID_HINT 0x3388
2181#define PCI_DEVICE_ID_HINT_VXPROII_IDE 0x8013
2182
2183#define PCI_VENDOR_ID_3DLABS 0x3d3d
2184#define PCI_DEVICE_ID_3DLABS_300SX 0x0001
2185#define PCI_DEVICE_ID_3DLABS_500TX 0x0002
2186#define PCI_DEVICE_ID_3DLABS_DELTA 0x0003
2187#define PCI_DEVICE_ID_3DLABS_PERMEDIA 0x0004
2188#define PCI_DEVICE_ID_3DLABS_MX 0x0006
2189#define PCI_DEVICE_ID_3DLABS_PERMEDIA2 0x0007
2190#define PCI_DEVICE_ID_3DLABS_GAMMA 0x0008
2191#define PCI_DEVICE_ID_3DLABS_PERMEDIA2V 0x0009
2192
2193#define PCI_VENDOR_ID_AVANCE 0x4005
2194#define PCI_DEVICE_ID_AVANCE_ALG2064 0x2064
2195#define PCI_DEVICE_ID_AVANCE_2302 0x2302
2196
2197#define PCI_VENDOR_ID_AKS 0x416c
2198#define PCI_DEVICE_ID_AKS_ALADDINCARD 0x0100
2199#define PCI_DEVICE_ID_AKS_CPC 0x0200
2200
2201#define PCI_VENDOR_ID_REDCREEK 0x4916
2202#define PCI_DEVICE_ID_RC45 0x1960
2203
2204#define PCI_VENDOR_ID_NETVIN 0x4a14
2205#define PCI_DEVICE_ID_NETVIN_NV5000SC 0x5000
2206
2207#define PCI_VENDOR_ID_S3 0x5333
2208#define PCI_DEVICE_ID_S3_PLATO_PXS 0x0551
2209#define PCI_DEVICE_ID_S3_ViRGE 0x5631
2210#define PCI_DEVICE_ID_S3_TRIO 0x8811
2211#define PCI_DEVICE_ID_S3_AURORA64VP 0x8812
2212#define PCI_DEVICE_ID_S3_TRIO64UVP 0x8814
2213#define PCI_DEVICE_ID_S3_ViRGE_VX 0x883d
2214#define PCI_DEVICE_ID_S3_868 0x8880
2215#define PCI_DEVICE_ID_S3_928 0x88b0
2216#define PCI_DEVICE_ID_S3_864_1 0x88c0
2217#define PCI_DEVICE_ID_S3_864_2 0x88c1
2218#define PCI_DEVICE_ID_S3_964_1 0x88d0
2219#define PCI_DEVICE_ID_S3_964_2 0x88d1
2220#define PCI_DEVICE_ID_S3_968 0x88f0
2221#define PCI_DEVICE_ID_S3_TRIO64V2 0x8901
2222#define PCI_DEVICE_ID_S3_PLATO_PXG 0x8902
2223#define PCI_DEVICE_ID_S3_ViRGE_DXGX 0x8a01
2224#define PCI_DEVICE_ID_S3_ViRGE_GX2 0x8a10
2225#define PCI_DEVICE_ID_S3_SAVAGE4 0x8a25
2226#define PCI_DEVICE_ID_S3_ViRGE_MX 0x8c01
2227#define PCI_DEVICE_ID_S3_ViRGE_MXP 0x8c02
2228#define PCI_DEVICE_ID_S3_ViRGE_MXPMV 0x8c03
2229#define PCI_DEVICE_ID_S3_PROSAVAGE8 0x8d04
2230#define PCI_DEVICE_ID_S3_SONICVIBES 0xca00
2231
2232#define PCI_VENDOR_ID_DUNORD 0x5544
2233#define PCI_DEVICE_ID_DUNORD_I3000 0x0001
2234
2235#define PCI_VENDOR_ID_DCI 0x6666
2236#define PCI_DEVICE_ID_DCI_PCCOM4 0x0001
2237#define PCI_DEVICE_ID_DCI_PCCOM8 0x0002
2238
2239#define PCI_VENDOR_ID_DUNORD 0x5544
2240#define PCI_DEVICE_ID_DUNORD_I3000 0x0001
2241
2242#define PCI_VENDOR_ID_GENROCO 0x5555
2243#define PCI_DEVICE_ID_GENROCO_HFP832 0x0003
2244
2245#define PCI_VENDOR_ID_INTEL 0x8086
2246#define PCI_DEVICE_ID_INTEL_EESSC 0x0008
2247#define PCI_DEVICE_ID_INTEL_21145 0x0039
2248#define PCI_DEVICE_ID_INTEL_82375 0x0482
2249#define PCI_DEVICE_ID_INTEL_82424 0x0483
2250#define PCI_DEVICE_ID_INTEL_82378 0x0484
2251#define PCI_DEVICE_ID_INTEL_82430 0x0486
2252#define PCI_DEVICE_ID_INTEL_82434 0x04a3
2253#define PCI_DEVICE_ID_INTEL_I960 0x0960
2254#define PCI_DEVICE_ID_INTEL_I960RM 0x0962
2255#define PCI_DEVICE_ID_INTEL_82562ET 0x1031
2256#define PCI_DEVICE_ID_INTEL_82801CAM 0x1038
2257#define PCI_DEVICE_ID_INTEL_82815_MC 0x1130
2258#define PCI_DEVICE_ID_INTEL_82815_AB 0x1131
2259#define PCI_DEVICE_ID_INTEL_82815_CGC 0x1132
2260#define PCI_DEVICE_ID_INTEL_82559ER 0x1209
2261#define PCI_DEVICE_ID_INTEL_82092AA_0 0x1221
2262#define PCI_DEVICE_ID_INTEL_82092AA_1 0x1222
2263#define PCI_DEVICE_ID_INTEL_7116 0x1223
2264#define PCI_DEVICE_ID_INTEL_7505_0 0x2550
2265#define PCI_DEVICE_ID_INTEL_7505_1 0x2552
2266#define PCI_DEVICE_ID_INTEL_7205_0 0x255d
2267#define PCI_DEVICE_ID_INTEL_82596 0x1226
2268#define PCI_DEVICE_ID_INTEL_82865 0x1227
2269#define PCI_DEVICE_ID_INTEL_82557 0x1229
2270#define PCI_DEVICE_ID_INTEL_82437 0x122d
2271#define PCI_DEVICE_ID_INTEL_82371FB_0 0x122e
2272#define PCI_DEVICE_ID_INTEL_82371FB_1 0x1230
2273#define PCI_DEVICE_ID_INTEL_82371MX 0x1234
2274#define PCI_DEVICE_ID_INTEL_82437MX 0x1235
2275#define PCI_DEVICE_ID_INTEL_82441 0x1237
2276#define PCI_DEVICE_ID_INTEL_82380FB 0x124b
2277#define PCI_DEVICE_ID_INTEL_82439 0x1250
2278#define PCI_DEVICE_ID_INTEL_80960_RP 0x1960
2279#define PCI_DEVICE_ID_INTEL_82840_HB 0x1a21
2280#define PCI_DEVICE_ID_INTEL_82845_HB 0x1a30
2281#define PCI_DEVICE_ID_INTEL_82801AA_0 0x2410
2282#define PCI_DEVICE_ID_INTEL_82801AA_1 0x2411
2283#define PCI_DEVICE_ID_INTEL_82801AA_2 0x2412
2284#define PCI_DEVICE_ID_INTEL_82801AA_3 0x2413
2285#define PCI_DEVICE_ID_INTEL_82801AA_5 0x2415
2286#define PCI_DEVICE_ID_INTEL_82801AA_6 0x2416
2287#define PCI_DEVICE_ID_INTEL_82801AA_8 0x2418
2288#define PCI_DEVICE_ID_INTEL_82801AB_0 0x2420
2289#define PCI_DEVICE_ID_INTEL_82801AB_1 0x2421
2290#define PCI_DEVICE_ID_INTEL_82801AB_2 0x2422
2291#define PCI_DEVICE_ID_INTEL_82801AB_3 0x2423
2292#define PCI_DEVICE_ID_INTEL_82801AB_5 0x2425
2293#define PCI_DEVICE_ID_INTEL_82801AB_6 0x2426
2294#define PCI_DEVICE_ID_INTEL_82801AB_8 0x2428
2295#define PCI_DEVICE_ID_INTEL_82801BA_0 0x2440
2296#define PCI_DEVICE_ID_INTEL_82801BA_1 0x2442
2297#define PCI_DEVICE_ID_INTEL_82801BA_2 0x2443
2298#define PCI_DEVICE_ID_INTEL_82801BA_3 0x2444
2299#define PCI_DEVICE_ID_INTEL_82801BA_4 0x2445
2300#define PCI_DEVICE_ID_INTEL_82801BA_5 0x2446
2301#define PCI_DEVICE_ID_INTEL_82801BA_6 0x2448
2302#define PCI_DEVICE_ID_INTEL_82801BA_7 0x2449
2303#define PCI_DEVICE_ID_INTEL_82801BA_8 0x244a
2304#define PCI_DEVICE_ID_INTEL_82801BA_9 0x244b
2305#define PCI_DEVICE_ID_INTEL_82801BA_10 0x244c
2306#define PCI_DEVICE_ID_INTEL_82801BA_11 0x244e
2307#define PCI_DEVICE_ID_INTEL_82801E_0 0x2450
2308#define PCI_DEVICE_ID_INTEL_82801E_2 0x2452
2309#define PCI_DEVICE_ID_INTEL_82801E_3 0x2453
2310#define PCI_DEVICE_ID_INTEL_82801E_9 0x2459
2311#define PCI_DEVICE_ID_INTEL_82801E_11 0x245b
2312#define PCI_DEVICE_ID_INTEL_82801E_13 0x245d
2313#define PCI_DEVICE_ID_INTEL_82801E_14 0x245e
2314#define PCI_DEVICE_ID_INTEL_82801CA_0 0x2480
2315#define PCI_DEVICE_ID_INTEL_82801CA_2 0x2482
2316#define PCI_DEVICE_ID_INTEL_82801CA_3 0x2483
2317#define PCI_DEVICE_ID_INTEL_82801CA_4 0x2484
2318#define PCI_DEVICE_ID_INTEL_82801CA_5 0x2485
2319#define PCI_DEVICE_ID_INTEL_82801CA_6 0x2486
2320#define PCI_DEVICE_ID_INTEL_82801CA_7 0x2487
2321#define PCI_DEVICE_ID_INTEL_82801CA_10 0x248a
2322#define PCI_DEVICE_ID_INTEL_82801CA_11 0x248b
2323#define PCI_DEVICE_ID_INTEL_82801CA_12 0x248c
2324#define PCI_DEVICE_ID_INTEL_82801DB_0 0x24c0
2325#define PCI_DEVICE_ID_INTEL_82801DB_1 0x24c1
2326#define PCI_DEVICE_ID_INTEL_82801DB_2 0x24c2
2327#define PCI_DEVICE_ID_INTEL_82801DB_3 0x24c3
2328#define PCI_DEVICE_ID_INTEL_82801DB_4 0x24c4
2329#define PCI_DEVICE_ID_INTEL_82801DB_5 0x24c5
2330#define PCI_DEVICE_ID_INTEL_82801DB_6 0x24c6
2331#define PCI_DEVICE_ID_INTEL_82801DB_7 0x24c7
2332#define PCI_DEVICE_ID_INTEL_82801DB_9 0x24c9
2333#define PCI_DEVICE_ID_INTEL_82801DB_10 0x24ca
2334#define PCI_DEVICE_ID_INTEL_82801DB_11 0x24cb
2335#define PCI_DEVICE_ID_INTEL_82801DB_12 0x24cc
2336#define PCI_DEVICE_ID_INTEL_82801DB_13 0x24cd
2337#define PCI_DEVICE_ID_INTEL_82801EB_0 0x24d0
2338#define PCI_DEVICE_ID_INTEL_82801EB_1 0x24d1
2339#define PCI_DEVICE_ID_INTEL_82801EB_2 0x24d2
2340#define PCI_DEVICE_ID_INTEL_82801EB_3 0x24d3
2341#define PCI_DEVICE_ID_INTEL_82801EB_4 0x24d4
2342#define PCI_DEVICE_ID_INTEL_82801EB_5 0x24d5
2343#define PCI_DEVICE_ID_INTEL_82801EB_6 0x24d6
2344#define PCI_DEVICE_ID_INTEL_82801EB_7 0x24d7
2345#define PCI_DEVICE_ID_INTEL_82801EB_11 0x24db
2346#define PCI_DEVICE_ID_INTEL_82801EB_13 0x24dd
2347#define PCI_DEVICE_ID_INTEL_ESB_1 0x25a1
2348#define PCI_DEVICE_ID_INTEL_ESB_2 0x25a2
2349#define PCI_DEVICE_ID_INTEL_ESB_3 0x25a3
2350#define PCI_DEVICE_ID_INTEL_ESB_31 0x25b0
2351#define PCI_DEVICE_ID_INTEL_ESB_4 0x25a4
2352#define PCI_DEVICE_ID_INTEL_ESB_5 0x25a6
2353#define PCI_DEVICE_ID_INTEL_ESB_6 0x25a7
2354#define PCI_DEVICE_ID_INTEL_ESB_7 0x25a9
2355#define PCI_DEVICE_ID_INTEL_ESB_8 0x25aa
2356#define PCI_DEVICE_ID_INTEL_ESB_9 0x25ab
2357#define PCI_DEVICE_ID_INTEL_ESB_11 0x25ac
2358#define PCI_DEVICE_ID_INTEL_ESB_12 0x25ad
2359#define PCI_DEVICE_ID_INTEL_ESB_13 0x25ae
2360#define PCI_DEVICE_ID_INTEL_82820_HB 0x2500
2361#define PCI_DEVICE_ID_INTEL_82820_UP_HB 0x2501
2362#define PCI_DEVICE_ID_INTEL_82850_HB 0x2530
2363#define PCI_DEVICE_ID_INTEL_82860_HB 0x2531
2364#define PCI_DEVICE_ID_INTEL_82845G_HB 0x2560
2365#define PCI_DEVICE_ID_INTEL_82845G_IG 0x2562
2366#define PCI_DEVICE_ID_INTEL_82865_HB 0x2570
2367#define PCI_DEVICE_ID_INTEL_82865_IG 0x2572
2368#define PCI_DEVICE_ID_INTEL_82875_HB 0x2578
2369#define PCI_DEVICE_ID_INTEL_82875_IG 0x257b
2370#define PCI_DEVICE_ID_INTEL_82915G_HB 0x2580
2371#define PCI_DEVICE_ID_INTEL_82915G_IG 0x2582
2372#define PCI_DEVICE_ID_INTEL_82915GM_HB 0x2590
2373#define PCI_DEVICE_ID_INTEL_82915GM_IG 0x2592
2374#define PCI_DEVICE_ID_INTEL_ICH6_0 0x2640
2375#define PCI_DEVICE_ID_INTEL_ICH6_1 0x2641
2376#define PCI_DEVICE_ID_INTEL_ICH6_2 0x2642
2377#define PCI_DEVICE_ID_INTEL_ICH6_3 0x2651
2378#define PCI_DEVICE_ID_INTEL_ICH6_4 0x2652
2379#define PCI_DEVICE_ID_INTEL_ICH6_5 0x2653
2380#define PCI_DEVICE_ID_INTEL_ICH6_6 0x2658
2381#define PCI_DEVICE_ID_INTEL_ICH6_7 0x2659
2382#define PCI_DEVICE_ID_INTEL_ICH6_8 0x265a
2383#define PCI_DEVICE_ID_INTEL_ICH6_9 0x265b
2384#define PCI_DEVICE_ID_INTEL_ICH6_10 0x265c
2385#define PCI_DEVICE_ID_INTEL_ICH6_11 0x2660
2386#define PCI_DEVICE_ID_INTEL_ICH6_12 0x2662
2387#define PCI_DEVICE_ID_INTEL_ICH6_13 0x2664
2388#define PCI_DEVICE_ID_INTEL_ICH6_14 0x2666
2389#define PCI_DEVICE_ID_INTEL_ICH6_15 0x2668
2390#define PCI_DEVICE_ID_INTEL_ICH6_16 0x266a
2391#define PCI_DEVICE_ID_INTEL_ICH6_17 0x266d
2392#define PCI_DEVICE_ID_INTEL_ICH6_18 0x266e
2393#define PCI_DEVICE_ID_INTEL_ICH6_19 0x266f
2394#define PCI_DEVICE_ID_INTEL_ICH7_0 0x27b8
2395#define PCI_DEVICE_ID_INTEL_ICH7_1 0x27b9
2396#define PCI_DEVICE_ID_INTEL_ICH7_2 0x27c0
2397#define PCI_DEVICE_ID_INTEL_ICH7_3 0x27c1
2398#define PCI_DEVICE_ID_INTEL_ICH7_5 0x27c4
2399#define PCI_DEVICE_ID_INTEL_ICH7_6 0x27c5
2400#define PCI_DEVICE_ID_INTEL_ICH7_7 0x27c8
2401#define PCI_DEVICE_ID_INTEL_ICH7_8 0x27c9
2402#define PCI_DEVICE_ID_INTEL_ICH7_9 0x27ca
2403#define PCI_DEVICE_ID_INTEL_ICH7_10 0x27cb
2404#define PCI_DEVICE_ID_INTEL_ICH7_11 0x27cc
2405#define PCI_DEVICE_ID_INTEL_ICH7_12 0x27d0
2406#define PCI_DEVICE_ID_INTEL_ICH7_13 0x27d2
2407#define PCI_DEVICE_ID_INTEL_ICH7_14 0x27d4
2408#define PCI_DEVICE_ID_INTEL_ICH7_15 0x27d6
2409#define PCI_DEVICE_ID_INTEL_ICH7_16 0x27d8
2410#define PCI_DEVICE_ID_INTEL_ICH7_17 0x27da
2411#define PCI_DEVICE_ID_INTEL_ICH7_18 0x27dc
2412#define PCI_DEVICE_ID_INTEL_ICH7_19 0x27dd
2413#define PCI_DEVICE_ID_INTEL_ICH7_20 0x27de
2414#define PCI_DEVICE_ID_INTEL_ICH7_21 0x27df
2415#define PCI_DEVICE_ID_INTEL_ICH7_22 0x27e0
2416#define PCI_DEVICE_ID_INTEL_ICH7_23 0x27e2
2417#define PCI_DEVICE_ID_INTEL_82855PM_HB 0x3340
2418#define PCI_DEVICE_ID_INTEL_82830_HB 0x3575
2419#define PCI_DEVICE_ID_INTEL_82830_CGC 0x3577
2420#define PCI_DEVICE_ID_INTEL_82855GM_HB 0x3580
2421#define PCI_DEVICE_ID_INTEL_82855GM_IG 0x3582
2422#define PCI_DEVICE_ID_INTEL_E7520_MCH 0x3590
2423#define PCI_DEVICE_ID_INTEL_E7320_MCH 0x3592
2424#define PCI_DEVICE_ID_INTEL_MCH_PA 0x3595
2425#define PCI_DEVICE_ID_INTEL_MCH_PA1 0x3596
2426#define PCI_DEVICE_ID_INTEL_MCH_PB 0x3597
2427#define PCI_DEVICE_ID_INTEL_MCH_PB1 0x3598
2428#define PCI_DEVICE_ID_INTEL_MCH_PC 0x3599
2429#define PCI_DEVICE_ID_INTEL_MCH_PC1 0x359a
2430#define PCI_DEVICE_ID_INTEL_E7525_MCH 0x359e
2431#define PCI_DEVICE_ID_INTEL_80310 0x530d
2432#define PCI_DEVICE_ID_INTEL_82371SB_0 0x7000
2433#define PCI_DEVICE_ID_INTEL_82371SB_1 0x7010
2434#define PCI_DEVICE_ID_INTEL_82371SB_2 0x7020
2435#define PCI_DEVICE_ID_INTEL_82437VX 0x7030
2436#define PCI_DEVICE_ID_INTEL_82439TX 0x7100
2437#define PCI_DEVICE_ID_INTEL_82371AB_0 0x7110
2438#define PCI_DEVICE_ID_INTEL_82371AB 0x7111
2439#define PCI_DEVICE_ID_INTEL_82371AB_2 0x7112
2440#define PCI_DEVICE_ID_INTEL_82371AB_3 0x7113
2441#define PCI_DEVICE_ID_INTEL_82810_MC1 0x7120
2442#define PCI_DEVICE_ID_INTEL_82810_IG1 0x7121
2443#define PCI_DEVICE_ID_INTEL_82810_MC3 0x7122
2444#define PCI_DEVICE_ID_INTEL_82810_IG3 0x7123
2445#define PCI_DEVICE_ID_INTEL_82810E_MC 0x7124
2446#define PCI_DEVICE_ID_INTEL_82810E_IG 0x7125
2447#define PCI_DEVICE_ID_INTEL_82443LX_0 0x7180
2448#define PCI_DEVICE_ID_INTEL_82443LX_1 0x7181
2449#define PCI_DEVICE_ID_INTEL_82443BX_0 0x7190
2450#define PCI_DEVICE_ID_INTEL_82443BX_1 0x7191
2451#define PCI_DEVICE_ID_INTEL_82443BX_2 0x7192
2452#define PCI_DEVICE_ID_INTEL_440MX 0x7195
2453#define PCI_DEVICE_ID_INTEL_82443MX_0 0x7198
2454#define PCI_DEVICE_ID_INTEL_82443MX_1 0x7199
2455#define PCI_DEVICE_ID_INTEL_82443MX_2 0x719a
2456#define PCI_DEVICE_ID_INTEL_82443MX_3 0x719b
2457#define PCI_DEVICE_ID_INTEL_82443GX_0 0x71a0
2458#define PCI_DEVICE_ID_INTEL_82443GX_1 0x71a1
2459#define PCI_DEVICE_ID_INTEL_82443GX_2 0x71a2
2460#define PCI_DEVICE_ID_INTEL_82372FB_0 0x7600
2461#define PCI_DEVICE_ID_INTEL_82372FB_1 0x7601
2462#define PCI_DEVICE_ID_INTEL_82372FB_2 0x7602
2463#define PCI_DEVICE_ID_INTEL_82372FB_3 0x7603
2464#define PCI_DEVICE_ID_INTEL_82454GX 0x84c4
2465#define PCI_DEVICE_ID_INTEL_82450GX 0x84c5
2466#define PCI_DEVICE_ID_INTEL_82451NX 0x84ca
2467#define PCI_DEVICE_ID_INTEL_82454NX 0x84cb
2468#define PCI_DEVICE_ID_INTEL_84460GX 0x84ea
2469#define PCI_DEVICE_ID_INTEL_IXP4XX 0x8500
2470#define PCI_DEVICE_ID_INTEL_IXP2400 0x9001
2471#define PCI_DEVICE_ID_INTEL_IXP2800 0x9004
2472#define PCI_DEVICE_ID_INTEL_S21152BB 0xb152
2473
2474#define PCI_VENDOR_ID_COMPUTONE 0x8e0e
2475#define PCI_DEVICE_ID_COMPUTONE_IP2EX 0x0291
2476#define PCI_DEVICE_ID_COMPUTONE_PG 0x0302
2477#define PCI_SUBVENDOR_ID_COMPUTONE 0x8e0e
2478#define PCI_SUBDEVICE_ID_COMPUTONE_PG4 0x0001
2479#define PCI_SUBDEVICE_ID_COMPUTONE_PG8 0x0002
2480#define PCI_SUBDEVICE_ID_COMPUTONE_PG6 0x0003
2481
2482#define PCI_VENDOR_ID_KTI 0x8e2e
2483#define PCI_DEVICE_ID_KTI_ET32P2 0x3000
2484
2485#define PCI_VENDOR_ID_ADAPTEC 0x9004
2486#define PCI_DEVICE_ID_ADAPTEC_7810 0x1078
2487#define PCI_DEVICE_ID_ADAPTEC_7821 0x2178
2488#define PCI_DEVICE_ID_ADAPTEC_38602 0x3860
2489#define PCI_DEVICE_ID_ADAPTEC_7850 0x5078
2490#define PCI_DEVICE_ID_ADAPTEC_7855 0x5578
2491#define PCI_DEVICE_ID_ADAPTEC_5800 0x5800
2492#define PCI_DEVICE_ID_ADAPTEC_3860 0x6038
2493#define PCI_DEVICE_ID_ADAPTEC_1480A 0x6075
2494#define PCI_DEVICE_ID_ADAPTEC_7860 0x6078
2495#define PCI_DEVICE_ID_ADAPTEC_7861 0x6178
2496#define PCI_DEVICE_ID_ADAPTEC_7870 0x7078
2497#define PCI_DEVICE_ID_ADAPTEC_7871 0x7178
2498#define PCI_DEVICE_ID_ADAPTEC_7872 0x7278
2499#define PCI_DEVICE_ID_ADAPTEC_7873 0x7378
2500#define PCI_DEVICE_ID_ADAPTEC_7874 0x7478
2501#define PCI_DEVICE_ID_ADAPTEC_7895 0x7895
2502#define PCI_DEVICE_ID_ADAPTEC_7880 0x8078
2503#define PCI_DEVICE_ID_ADAPTEC_7881 0x8178
2504#define PCI_DEVICE_ID_ADAPTEC_7882 0x8278
2505#define PCI_DEVICE_ID_ADAPTEC_7883 0x8378
2506#define PCI_DEVICE_ID_ADAPTEC_7884 0x8478
2507#define PCI_DEVICE_ID_ADAPTEC_7885 0x8578
2508#define PCI_DEVICE_ID_ADAPTEC_7886 0x8678
2509#define PCI_DEVICE_ID_ADAPTEC_7887 0x8778
2510#define PCI_DEVICE_ID_ADAPTEC_7888 0x8878
2511#define PCI_DEVICE_ID_ADAPTEC_1030 0x8b78
2512
2513#define PCI_VENDOR_ID_ADAPTEC2 0x9005
2514#define PCI_DEVICE_ID_ADAPTEC2_2940U2 0x0010
2515#define PCI_DEVICE_ID_ADAPTEC2_2930U2 0x0011
2516#define PCI_DEVICE_ID_ADAPTEC2_7890B 0x0013
2517#define PCI_DEVICE_ID_ADAPTEC2_7890 0x001f
2518#define PCI_DEVICE_ID_ADAPTEC2_3940U2 0x0050
2519#define PCI_DEVICE_ID_ADAPTEC2_3950U2D 0x0051
2520#define PCI_DEVICE_ID_ADAPTEC2_7896 0x005f
2521#define PCI_DEVICE_ID_ADAPTEC2_7892A 0x0080
2522#define PCI_DEVICE_ID_ADAPTEC2_7892B 0x0081
2523#define PCI_DEVICE_ID_ADAPTEC2_7892D 0x0083
2524#define PCI_DEVICE_ID_ADAPTEC2_7892P 0x008f
2525#define PCI_DEVICE_ID_ADAPTEC2_7899A 0x00c0
2526#define PCI_DEVICE_ID_ADAPTEC2_7899B 0x00c1
2527#define PCI_DEVICE_ID_ADAPTEC2_7899D 0x00c3
2528#define PCI_DEVICE_ID_ADAPTEC2_7899P 0x00cf
2529#define PCI_DEVICE_ID_ADAPTEC2_SCAMP 0x0503
2530
2531#define PCI_VENDOR_ID_ATRONICS 0x907f
2532#define PCI_DEVICE_ID_ATRONICS_2015 0x2015
2533
2534#define PCI_VENDOR_ID_HOLTEK 0x9412
2535#define PCI_DEVICE_ID_HOLTEK_6565 0x6565
2536
2537#define PCI_VENDOR_ID_NETMOS 0x9710
2538#define PCI_DEVICE_ID_NETMOS_9705 0x9705
2539#define PCI_DEVICE_ID_NETMOS_9715 0x9715
2540#define PCI_DEVICE_ID_NETMOS_9735 0x9735
2541#define PCI_DEVICE_ID_NETMOS_9745 0x9745
2542#define PCI_DEVICE_ID_NETMOS_9755 0x9755
2543#define PCI_DEVICE_ID_NETMOS_9805 0x9805
2544#define PCI_DEVICE_ID_NETMOS_9815 0x9815
2545#define PCI_DEVICE_ID_NETMOS_9835 0x9835
2546#define PCI_DEVICE_ID_NETMOS_9845 0x9845
2547#define PCI_DEVICE_ID_NETMOS_9855 0x9855
2548
2549#define PCI_SUBVENDOR_ID_EXSYS 0xd84d
2550#define PCI_SUBDEVICE_ID_EXSYS_4014 0x4014
2551
2552#define PCI_VENDOR_ID_TIGERJET 0xe159
2553#define PCI_DEVICE_ID_TIGERJET_300 0x0001
2554#define PCI_DEVICE_ID_TIGERJET_100 0x0002
2555
2556#define PCI_VENDOR_ID_TTTECH 0x0357
2557#define PCI_DEVICE_ID_TTTECH_MC322 0x000A
2558
2559#define PCI_VENDOR_ID_ARK 0xedd8
2560#define PCI_DEVICE_ID_ARK_STING 0xa091
2561#define PCI_DEVICE_ID_ARK_STINGARK 0xa099
2562#define PCI_DEVICE_ID_ARK_2000MT 0xa0a1
diff --git a/include/linux/pcieport_if.h b/include/linux/pcieport_if.h
new file mode 100644
index 000000000000..cd3eafc2c233
--- /dev/null
+++ b/include/linux/pcieport_if.h
@@ -0,0 +1,74 @@
1/*
2 * File: pcieport_if.h
3 * Purpose: PCI Express Port Bus Driver's IF Data Structure
4 *
5 * Copyright (C) 2004 Intel
6 * Copyright (C) Tom Long Nguyen (tom.l.nguyen@intel.com)
7 */
8
9#ifndef _PCIEPORT_IF_H_
10#define _PCIEPORT_IF_H_
11
12/* Port Type */
13#define PCIE_RC_PORT 4 /* Root port of RC */
14#define PCIE_SW_UPSTREAM_PORT 5 /* Upstream port of Switch */
15#define PCIE_SW_DOWNSTREAM_PORT 6 /* Downstream port of Switch */
16#define PCIE_ANY_PORT 7
17
18/* Service Type */
19#define PCIE_PORT_SERVICE_PME 1 /* Power Management Event */
20#define PCIE_PORT_SERVICE_AER 2 /* Advanced Error Reporting */
21#define PCIE_PORT_SERVICE_HP 4 /* Native Hotplug */
22#define PCIE_PORT_SERVICE_VC 8 /* Virtual Channel */
23
24/* Root/Upstream/Downstream Port's Interrupt Mode */
25#define PCIE_PORT_INTx_MODE 0
26#define PCIE_PORT_MSI_MODE 1
27#define PCIE_PORT_MSIX_MODE 2
28
29struct pcie_port_service_id {
30 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
31 __u32 subvendor, subdevice; /* Subsystem ID's or PCI_ANY_ID */
32 __u32 class, class_mask; /* (class,subclass,prog-if) triplet */
33 __u32 port_type, service_type; /* Port Entity */
34 kernel_ulong_t driver_data;
35};
36
37struct pcie_device {
38 int irq; /* Service IRQ/MSI/MSI-X Vector */
39 int interrupt_mode; /* [0:INTx | 1:MSI | 2:MSI-X] */
40 struct pcie_port_service_id id; /* Service ID */
41 struct pci_dev *port; /* Root/Upstream/Downstream Port */
42 void *priv_data; /* Service Private Data */
43 struct device device; /* Generic Device Interface */
44};
45#define to_pcie_device(d) container_of(d, struct pcie_device, device)
46
47static inline void set_service_data(struct pcie_device *dev, void *data)
48{
49 dev->priv_data = data;
50}
51
52static inline void* get_service_data(struct pcie_device *dev)
53{
54 return dev->priv_data;
55}
56
57struct pcie_port_service_driver {
58 const char *name;
59 int (*probe) (struct pcie_device *dev,
60 const struct pcie_port_service_id *id);
61 void (*remove) (struct pcie_device *dev);
62 int (*suspend) (struct pcie_device *dev, u32 state);
63 int (*resume) (struct pcie_device *dev);
64
65 const struct pcie_port_service_id *id_table;
66 struct device_driver driver;
67};
68#define to_service_driver(d) \
69 container_of(d, struct pcie_port_service_driver, driver)
70
71extern int pcie_port_service_register(struct pcie_port_service_driver *new);
72extern void pcie_port_service_unregister(struct pcie_port_service_driver *new);
73
74#endif /* _PCIEPORT_IF_H_ */
diff --git a/include/linux/percpu.h b/include/linux/percpu.h
new file mode 100644
index 000000000000..5451eb1e781d
--- /dev/null
+++ b/include/linux/percpu.h
@@ -0,0 +1,61 @@
1#ifndef __LINUX_PERCPU_H
2#define __LINUX_PERCPU_H
3#include <linux/spinlock.h> /* For preempt_disable() */
4#include <linux/slab.h> /* For kmalloc() */
5#include <linux/smp.h>
6#include <linux/string.h> /* For memset() */
7#include <asm/percpu.h>
8
9/* Enough to cover all DEFINE_PER_CPUs in kernel, including modules. */
10#ifndef PERCPU_ENOUGH_ROOM
11#define PERCPU_ENOUGH_ROOM 32768
12#endif
13
14/* Must be an lvalue. */
15#define get_cpu_var(var) (*({ preempt_disable(); &__get_cpu_var(var); }))
16#define put_cpu_var(var) preempt_enable()
17
18#ifdef CONFIG_SMP
19
20struct percpu_data {
21 void *ptrs[NR_CPUS];
22 void *blkp;
23};
24
25/*
26 * Use this to get to a cpu's version of the per-cpu object allocated using
27 * alloc_percpu. Non-atomic access to the current CPU's version should
28 * probably be combined with get_cpu()/put_cpu().
29 */
30#define per_cpu_ptr(ptr, cpu) \
31({ \
32 struct percpu_data *__p = (struct percpu_data *)~(unsigned long)(ptr); \
33 (__typeof__(ptr))__p->ptrs[(cpu)]; \
34})
35
36extern void *__alloc_percpu(size_t size, size_t align);
37extern void free_percpu(const void *);
38
39#else /* CONFIG_SMP */
40
41#define per_cpu_ptr(ptr, cpu) (ptr)
42
43static inline void *__alloc_percpu(size_t size, size_t align)
44{
45 void *ret = kmalloc(size, GFP_KERNEL);
46 if (ret)
47 memset(ret, 0, size);
48 return ret;
49}
50static inline void free_percpu(const void *ptr)
51{
52 kfree(ptr);
53}
54
55#endif /* CONFIG_SMP */
56
57/* Simple wrapper for the common case: zeros memory. */
58#define alloc_percpu(type) \
59 ((type *)(__alloc_percpu(sizeof(type), __alignof__(type))))
60
61#endif /* __LINUX_PERCPU_H */
diff --git a/include/linux/percpu_counter.h b/include/linux/percpu_counter.h
new file mode 100644
index 000000000000..bd6708e2c027
--- /dev/null
+++ b/include/linux/percpu_counter.h
@@ -0,0 +1,107 @@
1#ifndef _LINUX_PERCPU_COUNTER_H
2#define _LINUX_PERCPU_COUNTER_H
3/*
4 * A simple "approximate counter" for use in ext2 and ext3 superblocks.
5 *
6 * WARNING: these things are HUGE. 4 kbytes per counter on 32-way P4.
7 */
8
9#include <linux/config.h>
10#include <linux/spinlock.h>
11#include <linux/smp.h>
12#include <linux/threads.h>
13#include <linux/percpu.h>
14
15#ifdef CONFIG_SMP
16
17struct percpu_counter {
18 spinlock_t lock;
19 long count;
20 long *counters;
21};
22
23#if NR_CPUS >= 16
24#define FBC_BATCH (NR_CPUS*2)
25#else
26#define FBC_BATCH (NR_CPUS*4)
27#endif
28
29static inline void percpu_counter_init(struct percpu_counter *fbc)
30{
31 spin_lock_init(&fbc->lock);
32 fbc->count = 0;
33 fbc->counters = alloc_percpu(long);
34}
35
36static inline void percpu_counter_destroy(struct percpu_counter *fbc)
37{
38 free_percpu(fbc->counters);
39}
40
41void percpu_counter_mod(struct percpu_counter *fbc, long amount);
42
43static inline long percpu_counter_read(struct percpu_counter *fbc)
44{
45 return fbc->count;
46}
47
48/*
49 * It is possible for the percpu_counter_read() to return a small negative
50 * number for some counter which should never be negative.
51 */
52static inline long percpu_counter_read_positive(struct percpu_counter *fbc)
53{
54 long ret = fbc->count;
55
56 barrier(); /* Prevent reloads of fbc->count */
57 if (ret > 0)
58 return ret;
59 return 1;
60}
61
62#else
63
64struct percpu_counter {
65 long count;
66};
67
68static inline void percpu_counter_init(struct percpu_counter *fbc)
69{
70 fbc->count = 0;
71}
72
73static inline void percpu_counter_destroy(struct percpu_counter *fbc)
74{
75}
76
77static inline void
78percpu_counter_mod(struct percpu_counter *fbc, long amount)
79{
80 preempt_disable();
81 fbc->count += amount;
82 preempt_enable();
83}
84
85static inline long percpu_counter_read(struct percpu_counter *fbc)
86{
87 return fbc->count;
88}
89
90static inline long percpu_counter_read_positive(struct percpu_counter *fbc)
91{
92 return fbc->count;
93}
94
95#endif /* CONFIG_SMP */
96
97static inline void percpu_counter_inc(struct percpu_counter *fbc)
98{
99 percpu_counter_mod(fbc, 1);
100}
101
102static inline void percpu_counter_dec(struct percpu_counter *fbc)
103{
104 percpu_counter_mod(fbc, -1);
105}
106
107#endif /* _LINUX_PERCPU_COUNTER_H */
diff --git a/include/linux/personality.h b/include/linux/personality.h
new file mode 100644
index 000000000000..80d780e5a8f5
--- /dev/null
+++ b/include/linux/personality.h
@@ -0,0 +1,114 @@
1#ifndef _LINUX_PERSONALITY_H
2#define _LINUX_PERSONALITY_H
3
4/*
5 * Handling of different ABIs (personalities).
6 */
7
8struct exec_domain;
9struct pt_regs;
10
11extern int register_exec_domain(struct exec_domain *);
12extern int unregister_exec_domain(struct exec_domain *);
13extern int __set_personality(unsigned long);
14
15/*
16 * Flags for bug emulation.
17 *
18 * These occupy the top three bytes.
19 */
20enum {
21 ADDR_NO_RANDOMIZE = 0x0040000, /* disable randomization of VA space */
22 FDPIC_FUNCPTRS = 0x0080000, /* userspace function ptrs point to descriptors
23 * (signal handling)
24 */
25 MMAP_PAGE_ZERO = 0x0100000,
26 ADDR_COMPAT_LAYOUT = 0x0200000,
27 READ_IMPLIES_EXEC = 0x0400000,
28 ADDR_LIMIT_32BIT = 0x0800000,
29 SHORT_INODE = 0x1000000,
30 WHOLE_SECONDS = 0x2000000,
31 STICKY_TIMEOUTS = 0x4000000,
32 ADDR_LIMIT_3GB = 0x8000000,
33};
34
35/*
36 * Security-relevant compatibility flags that must be
37 * cleared upon setuid or setgid exec:
38 */
39#define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC|ADDR_NO_RANDOMIZE)
40
41/*
42 * Personality types.
43 *
44 * These go in the low byte. Avoid using the top bit, it will
45 * conflict with error returns.
46 */
47enum {
48 PER_LINUX = 0x0000,
49 PER_LINUX_32BIT = 0x0000 | ADDR_LIMIT_32BIT,
50 PER_LINUX_FDPIC = 0x0000 | FDPIC_FUNCPTRS,
51 PER_SVR4 = 0x0001 | STICKY_TIMEOUTS | MMAP_PAGE_ZERO,
52 PER_SVR3 = 0x0002 | STICKY_TIMEOUTS | SHORT_INODE,
53 PER_SCOSVR3 = 0x0003 | STICKY_TIMEOUTS |
54 WHOLE_SECONDS | SHORT_INODE,
55 PER_OSR5 = 0x0003 | STICKY_TIMEOUTS | WHOLE_SECONDS,
56 PER_WYSEV386 = 0x0004 | STICKY_TIMEOUTS | SHORT_INODE,
57 PER_ISCR4 = 0x0005 | STICKY_TIMEOUTS,
58 PER_BSD = 0x0006,
59 PER_SUNOS = 0x0006 | STICKY_TIMEOUTS,
60 PER_XENIX = 0x0007 | STICKY_TIMEOUTS | SHORT_INODE,
61 PER_LINUX32 = 0x0008,
62 PER_LINUX32_3GB = 0x0008 | ADDR_LIMIT_3GB,
63 PER_IRIX32 = 0x0009 | STICKY_TIMEOUTS,/* IRIX5 32-bit */
64 PER_IRIXN32 = 0x000a | STICKY_TIMEOUTS,/* IRIX6 new 32-bit */
65 PER_IRIX64 = 0x000b | STICKY_TIMEOUTS,/* IRIX6 64-bit */
66 PER_RISCOS = 0x000c,
67 PER_SOLARIS = 0x000d | STICKY_TIMEOUTS,
68 PER_UW7 = 0x000e | STICKY_TIMEOUTS | MMAP_PAGE_ZERO,
69 PER_OSF4 = 0x000f, /* OSF/1 v4 */
70 PER_HPUX = 0x0010,
71 PER_MASK = 0x00ff,
72};
73
74
75/*
76 * Description of an execution domain.
77 *
78 * The first two members are refernced from assembly source
79 * and should stay where they are unless explicitly needed.
80 */
81typedef void (*handler_t)(int, struct pt_regs *);
82
83struct exec_domain {
84 const char *name; /* name of the execdomain */
85 handler_t handler; /* handler for syscalls */
86 unsigned char pers_low; /* lowest personality */
87 unsigned char pers_high; /* highest personality */
88 unsigned long *signal_map; /* signal mapping */
89 unsigned long *signal_invmap; /* reverse signal mapping */
90 struct map_segment *err_map; /* error mapping */
91 struct map_segment *socktype_map; /* socket type mapping */
92 struct map_segment *sockopt_map; /* socket option mapping */
93 struct map_segment *af_map; /* address family mapping */
94 struct module *module; /* module context of the ed. */
95 struct exec_domain *next; /* linked list (internal) */
96};
97
98/*
99 * Return the base personality without flags.
100 */
101#define personality(pers) (pers & PER_MASK)
102
103/*
104 * Personality of the currently running process.
105 */
106#define get_personality (current->personality)
107
108/*
109 * Change personality of the currently running process.
110 */
111#define set_personality(pers) \
112 ((current->personality == pers) ? 0 : __set_personality(pers))
113
114#endif /* _LINUX_PERSONALITY_H */
diff --git a/include/linux/pfkeyv2.h b/include/linux/pfkeyv2.h
new file mode 100644
index 000000000000..e6b519220245
--- /dev/null
+++ b/include/linux/pfkeyv2.h
@@ -0,0 +1,336 @@
1/* PF_KEY user interface, this is defined by rfc2367 so
2 * do not make arbitrary modifications or else this header
3 * file will not be compliant.
4 */
5
6#ifndef _LINUX_PFKEY2_H
7#define _LINUX_PFKEY2_H
8
9#include <linux/types.h>
10
11#define PF_KEY_V2 2
12#define PFKEYV2_REVISION 199806L
13
14struct sadb_msg {
15 uint8_t sadb_msg_version;
16 uint8_t sadb_msg_type;
17 uint8_t sadb_msg_errno;
18 uint8_t sadb_msg_satype;
19 uint16_t sadb_msg_len;
20 uint16_t sadb_msg_reserved;
21 uint32_t sadb_msg_seq;
22 uint32_t sadb_msg_pid;
23} __attribute__((packed));
24/* sizeof(struct sadb_msg) == 16 */
25
26struct sadb_ext {
27 uint16_t sadb_ext_len;
28 uint16_t sadb_ext_type;
29} __attribute__((packed));
30/* sizeof(struct sadb_ext) == 4 */
31
32struct sadb_sa {
33 uint16_t sadb_sa_len;
34 uint16_t sadb_sa_exttype;
35 uint32_t sadb_sa_spi;
36 uint8_t sadb_sa_replay;
37 uint8_t sadb_sa_state;
38 uint8_t sadb_sa_auth;
39 uint8_t sadb_sa_encrypt;
40 uint32_t sadb_sa_flags;
41} __attribute__((packed));
42/* sizeof(struct sadb_sa) == 16 */
43
44struct sadb_lifetime {
45 uint16_t sadb_lifetime_len;
46 uint16_t sadb_lifetime_exttype;
47 uint32_t sadb_lifetime_allocations;
48 uint64_t sadb_lifetime_bytes;
49 uint64_t sadb_lifetime_addtime;
50 uint64_t sadb_lifetime_usetime;
51} __attribute__((packed));
52/* sizeof(struct sadb_lifetime) == 32 */
53
54struct sadb_address {
55 uint16_t sadb_address_len;
56 uint16_t sadb_address_exttype;
57 uint8_t sadb_address_proto;
58 uint8_t sadb_address_prefixlen;
59 uint16_t sadb_address_reserved;
60} __attribute__((packed));
61/* sizeof(struct sadb_address) == 8 */
62
63struct sadb_key {
64 uint16_t sadb_key_len;
65 uint16_t sadb_key_exttype;
66 uint16_t sadb_key_bits;
67 uint16_t sadb_key_reserved;
68} __attribute__((packed));
69/* sizeof(struct sadb_key) == 8 */
70
71struct sadb_ident {
72 uint16_t sadb_ident_len;
73 uint16_t sadb_ident_exttype;
74 uint16_t sadb_ident_type;
75 uint16_t sadb_ident_reserved;
76 uint64_t sadb_ident_id;
77} __attribute__((packed));
78/* sizeof(struct sadb_ident) == 16 */
79
80struct sadb_sens {
81 uint16_t sadb_sens_len;
82 uint16_t sadb_sens_exttype;
83 uint32_t sadb_sens_dpd;
84 uint8_t sadb_sens_sens_level;
85 uint8_t sadb_sens_sens_len;
86 uint8_t sadb_sens_integ_level;
87 uint8_t sadb_sens_integ_len;
88 uint32_t sadb_sens_reserved;
89} __attribute__((packed));
90/* sizeof(struct sadb_sens) == 16 */
91
92/* followed by:
93 uint64_t sadb_sens_bitmap[sens_len];
94 uint64_t sadb_integ_bitmap[integ_len]; */
95
96struct sadb_prop {
97 uint16_t sadb_prop_len;
98 uint16_t sadb_prop_exttype;
99 uint8_t sadb_prop_replay;
100 uint8_t sadb_prop_reserved[3];
101} __attribute__((packed));
102/* sizeof(struct sadb_prop) == 8 */
103
104/* followed by:
105 struct sadb_comb sadb_combs[(sadb_prop_len +
106 sizeof(uint64_t) - sizeof(struct sadb_prop)) /
107 sizeof(strut sadb_comb)]; */
108
109struct sadb_comb {
110 uint8_t sadb_comb_auth;
111 uint8_t sadb_comb_encrypt;
112 uint16_t sadb_comb_flags;
113 uint16_t sadb_comb_auth_minbits;
114 uint16_t sadb_comb_auth_maxbits;
115 uint16_t sadb_comb_encrypt_minbits;
116 uint16_t sadb_comb_encrypt_maxbits;
117 uint32_t sadb_comb_reserved;
118 uint32_t sadb_comb_soft_allocations;
119 uint32_t sadb_comb_hard_allocations;
120 uint64_t sadb_comb_soft_bytes;
121 uint64_t sadb_comb_hard_bytes;
122 uint64_t sadb_comb_soft_addtime;
123 uint64_t sadb_comb_hard_addtime;
124 uint64_t sadb_comb_soft_usetime;
125 uint64_t sadb_comb_hard_usetime;
126} __attribute__((packed));
127/* sizeof(struct sadb_comb) == 72 */
128
129struct sadb_supported {
130 uint16_t sadb_supported_len;
131 uint16_t sadb_supported_exttype;
132 uint32_t sadb_supported_reserved;
133} __attribute__((packed));
134/* sizeof(struct sadb_supported) == 8 */
135
136/* followed by:
137 struct sadb_alg sadb_algs[(sadb_supported_len +
138 sizeof(uint64_t) - sizeof(struct sadb_supported)) /
139 sizeof(struct sadb_alg)]; */
140
141struct sadb_alg {
142 uint8_t sadb_alg_id;
143 uint8_t sadb_alg_ivlen;
144 uint16_t sadb_alg_minbits;
145 uint16_t sadb_alg_maxbits;
146 uint16_t sadb_alg_reserved;
147} __attribute__((packed));
148/* sizeof(struct sadb_alg) == 8 */
149
150struct sadb_spirange {
151 uint16_t sadb_spirange_len;
152 uint16_t sadb_spirange_exttype;
153 uint32_t sadb_spirange_min;
154 uint32_t sadb_spirange_max;
155 uint32_t sadb_spirange_reserved;
156} __attribute__((packed));
157/* sizeof(struct sadb_spirange) == 16 */
158
159struct sadb_x_kmprivate {
160 uint16_t sadb_x_kmprivate_len;
161 uint16_t sadb_x_kmprivate_exttype;
162 u_int32_t sadb_x_kmprivate_reserved;
163} __attribute__((packed));
164/* sizeof(struct sadb_x_kmprivate) == 8 */
165
166struct sadb_x_sa2 {
167 uint16_t sadb_x_sa2_len;
168 uint16_t sadb_x_sa2_exttype;
169 uint8_t sadb_x_sa2_mode;
170 uint8_t sadb_x_sa2_reserved1;
171 uint16_t sadb_x_sa2_reserved2;
172 uint32_t sadb_x_sa2_sequence;
173 uint32_t sadb_x_sa2_reqid;
174} __attribute__((packed));
175/* sizeof(struct sadb_x_sa2) == 16 */
176
177struct sadb_x_policy {
178 uint16_t sadb_x_policy_len;
179 uint16_t sadb_x_policy_exttype;
180 uint16_t sadb_x_policy_type;
181 uint8_t sadb_x_policy_dir;
182 uint8_t sadb_x_policy_reserved;
183 uint32_t sadb_x_policy_id;
184 uint32_t sadb_x_policy_priority;
185} __attribute__((packed));
186/* sizeof(struct sadb_x_policy) == 16 */
187
188struct sadb_x_ipsecrequest {
189 uint16_t sadb_x_ipsecrequest_len;
190 uint16_t sadb_x_ipsecrequest_proto;
191 uint8_t sadb_x_ipsecrequest_mode;
192 uint8_t sadb_x_ipsecrequest_level;
193 uint16_t sadb_x_ipsecrequest_reserved1;
194 uint32_t sadb_x_ipsecrequest_reqid;
195 uint32_t sadb_x_ipsecrequest_reserved2;
196} __attribute__((packed));
197/* sizeof(struct sadb_x_ipsecrequest) == 16 */
198
199/* This defines the TYPE of Nat Traversal in use. Currently only one
200 * type of NAT-T is supported, draft-ietf-ipsec-udp-encaps-06
201 */
202struct sadb_x_nat_t_type {
203 uint16_t sadb_x_nat_t_type_len;
204 uint16_t sadb_x_nat_t_type_exttype;
205 uint8_t sadb_x_nat_t_type_type;
206 uint8_t sadb_x_nat_t_type_reserved[3];
207} __attribute__((packed));
208/* sizeof(struct sadb_x_nat_t_type) == 8 */
209
210/* Pass a NAT Traversal port (Source or Dest port) */
211struct sadb_x_nat_t_port {
212 uint16_t sadb_x_nat_t_port_len;
213 uint16_t sadb_x_nat_t_port_exttype;
214 uint16_t sadb_x_nat_t_port_port;
215 uint16_t sadb_x_nat_t_port_reserved;
216} __attribute__((packed));
217/* sizeof(struct sadb_x_nat_t_port) == 8 */
218
219/* Message types */
220#define SADB_RESERVED 0
221#define SADB_GETSPI 1
222#define SADB_UPDATE 2
223#define SADB_ADD 3
224#define SADB_DELETE 4
225#define SADB_GET 5
226#define SADB_ACQUIRE 6
227#define SADB_REGISTER 7
228#define SADB_EXPIRE 8
229#define SADB_FLUSH 9
230#define SADB_DUMP 10
231#define SADB_X_PROMISC 11
232#define SADB_X_PCHANGE 12
233#define SADB_X_SPDUPDATE 13
234#define SADB_X_SPDADD 14
235#define SADB_X_SPDDELETE 15
236#define SADB_X_SPDGET 16
237#define SADB_X_SPDACQUIRE 17
238#define SADB_X_SPDDUMP 18
239#define SADB_X_SPDFLUSH 19
240#define SADB_X_SPDSETIDX 20
241#define SADB_X_SPDEXPIRE 21
242#define SADB_X_SPDDELETE2 22
243#define SADB_X_NAT_T_NEW_MAPPING 23
244#define SADB_MAX 23
245
246/* Security Association flags */
247#define SADB_SAFLAGS_PFS 1
248#define SADB_SAFLAGS_DECAP_DSCP 0x40000000
249#define SADB_SAFLAGS_NOECN 0x80000000
250
251/* Security Association states */
252#define SADB_SASTATE_LARVAL 0
253#define SADB_SASTATE_MATURE 1
254#define SADB_SASTATE_DYING 2
255#define SADB_SASTATE_DEAD 3
256#define SADB_SASTATE_MAX 3
257
258/* Security Association types */
259#define SADB_SATYPE_UNSPEC 0
260#define SADB_SATYPE_AH 2
261#define SADB_SATYPE_ESP 3
262#define SADB_SATYPE_RSVP 5
263#define SADB_SATYPE_OSPFV2 6
264#define SADB_SATYPE_RIPV2 7
265#define SADB_SATYPE_MIP 8
266#define SADB_X_SATYPE_IPCOMP 9
267#define SADB_SATYPE_MAX 9
268
269/* Authentication algorithms */
270#define SADB_AALG_NONE 0
271#define SADB_AALG_MD5HMAC 2
272#define SADB_AALG_SHA1HMAC 3
273#define SADB_X_AALG_SHA2_256HMAC 5
274#define SADB_X_AALG_SHA2_384HMAC 6
275#define SADB_X_AALG_SHA2_512HMAC 7
276#define SADB_X_AALG_RIPEMD160HMAC 8
277#define SADB_X_AALG_NULL 251 /* kame */
278#define SADB_AALG_MAX 251
279
280/* Encryption algorithms */
281#define SADB_EALG_NONE 0
282#define SADB_EALG_DESCBC 2
283#define SADB_EALG_3DESCBC 3
284#define SADB_X_EALG_CASTCBC 6
285#define SADB_X_EALG_BLOWFISHCBC 7
286#define SADB_EALG_NULL 11
287#define SADB_X_EALG_AESCBC 12
288#define SADB_EALG_MAX 253 /* last EALG */
289/* private allocations should use 249-255 (RFC2407) */
290#define SADB_X_EALG_SERPENTCBC 252 /* draft-ietf-ipsec-ciph-aes-cbc-00 */
291#define SADB_X_EALG_TWOFISHCBC 253 /* draft-ietf-ipsec-ciph-aes-cbc-00 */
292
293/* Compression algorithms */
294#define SADB_X_CALG_NONE 0
295#define SADB_X_CALG_OUI 1
296#define SADB_X_CALG_DEFLATE 2
297#define SADB_X_CALG_LZS 3
298#define SADB_X_CALG_LZJH 4
299#define SADB_X_CALG_MAX 4
300
301/* Extension Header values */
302#define SADB_EXT_RESERVED 0
303#define SADB_EXT_SA 1
304#define SADB_EXT_LIFETIME_CURRENT 2
305#define SADB_EXT_LIFETIME_HARD 3
306#define SADB_EXT_LIFETIME_SOFT 4
307#define SADB_EXT_ADDRESS_SRC 5
308#define SADB_EXT_ADDRESS_DST 6
309#define SADB_EXT_ADDRESS_PROXY 7
310#define SADB_EXT_KEY_AUTH 8
311#define SADB_EXT_KEY_ENCRYPT 9
312#define SADB_EXT_IDENTITY_SRC 10
313#define SADB_EXT_IDENTITY_DST 11
314#define SADB_EXT_SENSITIVITY 12
315#define SADB_EXT_PROPOSAL 13
316#define SADB_EXT_SUPPORTED_AUTH 14
317#define SADB_EXT_SUPPORTED_ENCRYPT 15
318#define SADB_EXT_SPIRANGE 16
319#define SADB_X_EXT_KMPRIVATE 17
320#define SADB_X_EXT_POLICY 18
321#define SADB_X_EXT_SA2 19
322/* The next four entries are for setting up NAT Traversal */
323#define SADB_X_EXT_NAT_T_TYPE 20
324#define SADB_X_EXT_NAT_T_SPORT 21
325#define SADB_X_EXT_NAT_T_DPORT 22
326#define SADB_X_EXT_NAT_T_OA 23
327#define SADB_EXT_MAX 23
328
329/* Identity Extension values */
330#define SADB_IDENTTYPE_RESERVED 0
331#define SADB_IDENTTYPE_PREFIX 1
332#define SADB_IDENTTYPE_FQDN 2
333#define SADB_IDENTTYPE_USERFQDN 3
334#define SADB_IDENTTYPE_MAX 3
335
336#endif /* !(_LINUX_PFKEY2_H) */
diff --git a/include/linux/pg.h b/include/linux/pg.h
new file mode 100644
index 000000000000..db994bb0c794
--- /dev/null
+++ b/include/linux/pg.h
@@ -0,0 +1,63 @@
1/* pg.h (c) 1998 Grant R. Guenther <grant@torque.net>
2 Under the terms of the GNU General Public License
3
4
5 pg.h defines the user interface to the generic ATAPI packet
6 command driver for parallel port ATAPI devices (pg). The
7 driver is loosely modelled after the generic SCSI driver, sg,
8 although the actual interface is different.
9
10 The pg driver provides a simple character device interface for
11 sending ATAPI commands to a device. With the exception of the
12 ATAPI reset operation, all operations are performed by a pair
13 of read and write operations to the appropriate /dev/pgN device.
14 A write operation delivers a command and any outbound data in
15 a single buffer. Normally, the write will succeed unless the
16 device is offline or malfunctioning, or there is already another
17 command pending. If the write succeeds, it should be followed
18 immediately by a read operation, to obtain any returned data and
19 status information. A read will fail if there is no operation
20 in progress.
21
22 As a special case, the device can be reset with a write operation,
23 and in this case, no following read is expected, or permitted.
24
25 There are no ioctl() operations. Any single operation
26 may transfer at most PG_MAX_DATA bytes. Note that the driver must
27 copy the data through an internal buffer. In keeping with all
28 current ATAPI devices, command packets are assumed to be exactly
29 12 bytes in length.
30
31 To permit future changes to this interface, the headers in the
32 read and write buffers contain a single character "magic" flag.
33 Currently this flag must be the character "P".
34
35*/
36
37#define PG_MAGIC 'P'
38#define PG_RESET 'Z'
39#define PG_COMMAND 'C'
40
41#define PG_MAX_DATA 32768
42
43struct pg_write_hdr {
44
45 char magic; /* == PG_MAGIC */
46 char func; /* PG_RESET or PG_COMMAND */
47 int dlen; /* number of bytes expected to transfer */
48 int timeout; /* number of seconds before timeout */
49 char packet[12]; /* packet command */
50
51};
52
53struct pg_read_hdr {
54
55 char magic; /* == PG_MAGIC */
56 char scsi; /* "scsi" status == sense key */
57 int dlen; /* size of device transfer request */
58 int duration; /* time in seconds command took */
59 char pad[12]; /* not used */
60
61};
62
63/* end of pg.h */
diff --git a/include/linux/phonedev.h b/include/linux/phonedev.h
new file mode 100644
index 000000000000..d54049eed0c3
--- /dev/null
+++ b/include/linux/phonedev.h
@@ -0,0 +1,26 @@
1#ifndef __LINUX_PHONEDEV_H
2#define __LINUX_PHONEDEV_H
3
4#include <linux/types.h>
5#include <linux/version.h>
6
7#ifdef __KERNEL__
8
9#include <linux/poll.h>
10
11struct phone_device {
12 struct phone_device *next;
13 struct file_operations *f_op;
14 int (*open) (struct phone_device *, struct file *);
15 int board; /* Device private index */
16 int minor;
17};
18
19extern int phonedev_init(void);
20#define PHONE_MAJOR 100
21extern int phone_register_device(struct phone_device *, int unit);
22#define PHONE_UNIT_ANY -1
23extern void phone_unregister_device(struct phone_device *);
24
25#endif
26#endif
diff --git a/include/linux/pid.h b/include/linux/pid.h
new file mode 100644
index 000000000000..5b2fcb19d2da
--- /dev/null
+++ b/include/linux/pid.h
@@ -0,0 +1,55 @@
1#ifndef _LINUX_PID_H
2#define _LINUX_PID_H
3
4enum pid_type
5{
6 PIDTYPE_PID,
7 PIDTYPE_TGID,
8 PIDTYPE_PGID,
9 PIDTYPE_SID,
10 PIDTYPE_MAX
11};
12
13struct pid
14{
15 /* Try to keep pid_chain in the same cacheline as nr for find_pid */
16 int nr;
17 struct hlist_node pid_chain;
18 /* list of pids with the same nr, only one of them is in the hash */
19 struct list_head pid_list;
20};
21
22#define pid_task(elem, type) \
23 list_entry(elem, struct task_struct, pids[type].pid_list)
24
25/*
26 * attach_pid() and detach_pid() must be called with the tasklist_lock
27 * write-held.
28 */
29extern int FASTCALL(attach_pid(struct task_struct *task, enum pid_type type, int nr));
30
31extern void FASTCALL(detach_pid(struct task_struct *task, enum pid_type));
32
33/*
34 * look up a PID in the hash table. Must be called with the tasklist_lock
35 * held.
36 */
37extern struct pid *FASTCALL(find_pid(enum pid_type, int));
38
39extern int alloc_pidmap(void);
40extern void FASTCALL(free_pidmap(int));
41extern void switch_exec_pids(struct task_struct *leader, struct task_struct *thread);
42
43#define do_each_task_pid(who, type, task) \
44 if ((task = find_task_by_pid_type(type, who))) { \
45 prefetch((task)->pids[type].pid_list.next); \
46 do {
47
48#define while_each_task_pid(who, type, task) \
49 } while (task = pid_task((task)->pids[type].pid_list.next,\
50 type), \
51 prefetch((task)->pids[type].pid_list.next), \
52 hlist_unhashed(&(task)->pids[type].pid_chain)); \
53 } \
54
55#endif /* _LINUX_PID_H */
diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
new file mode 100644
index 000000000000..36725e7c02c6
--- /dev/null
+++ b/include/linux/pipe_fs_i.h
@@ -0,0 +1,59 @@
1#ifndef _LINUX_PIPE_FS_I_H
2#define _LINUX_PIPE_FS_I_H
3
4#define PIPEFS_MAGIC 0x50495045
5
6#define PIPE_BUFFERS (16)
7
8struct pipe_buffer {
9 struct page *page;
10 unsigned int offset, len;
11 struct pipe_buf_operations *ops;
12};
13
14struct pipe_buf_operations {
15 int can_merge;
16 void * (*map)(struct file *, struct pipe_inode_info *, struct pipe_buffer *);
17 void (*unmap)(struct pipe_inode_info *, struct pipe_buffer *);
18 void (*release)(struct pipe_inode_info *, struct pipe_buffer *);
19};
20
21struct pipe_inode_info {
22 wait_queue_head_t wait;
23 unsigned int nrbufs, curbuf;
24 struct pipe_buffer bufs[PIPE_BUFFERS];
25 struct page *tmp_page;
26 unsigned int start;
27 unsigned int readers;
28 unsigned int writers;
29 unsigned int waiting_writers;
30 unsigned int r_counter;
31 unsigned int w_counter;
32 struct fasync_struct *fasync_readers;
33 struct fasync_struct *fasync_writers;
34};
35
36/* Differs from PIPE_BUF in that PIPE_SIZE is the length of the actual
37 memory allocation, whereas PIPE_BUF makes atomicity guarantees. */
38#define PIPE_SIZE PAGE_SIZE
39
40#define PIPE_SEM(inode) (&(inode).i_sem)
41#define PIPE_WAIT(inode) (&(inode).i_pipe->wait)
42#define PIPE_BASE(inode) ((inode).i_pipe->base)
43#define PIPE_START(inode) ((inode).i_pipe->start)
44#define PIPE_LEN(inode) ((inode).i_pipe->len)
45#define PIPE_READERS(inode) ((inode).i_pipe->readers)
46#define PIPE_WRITERS(inode) ((inode).i_pipe->writers)
47#define PIPE_WAITING_WRITERS(inode) ((inode).i_pipe->waiting_writers)
48#define PIPE_RCOUNTER(inode) ((inode).i_pipe->r_counter)
49#define PIPE_WCOUNTER(inode) ((inode).i_pipe->w_counter)
50#define PIPE_FASYNC_READERS(inode) (&((inode).i_pipe->fasync_readers))
51#define PIPE_FASYNC_WRITERS(inode) (&((inode).i_pipe->fasync_writers))
52
53/* Drop the inode semaphore and wait for a pipe event, atomically */
54void pipe_wait(struct inode * inode);
55
56struct inode* pipe_new(struct inode* inode);
57void free_pipe_info(struct inode* inode);
58
59#endif
diff --git a/include/linux/pkt_cls.h b/include/linux/pkt_cls.h
new file mode 100644
index 000000000000..d2aa214d6803
--- /dev/null
+++ b/include/linux/pkt_cls.h
@@ -0,0 +1,426 @@
1#ifndef __LINUX_PKT_CLS_H
2#define __LINUX_PKT_CLS_H
3
4#include <linux/pkt_sched.h>
5
6/* I think i could have done better macros ; for now this is stolen from
7 * some arch/mips code - jhs
8*/
9#define _TC_MAKE32(x) ((x))
10
11#define _TC_MAKEMASK1(n) (_TC_MAKE32(1) << _TC_MAKE32(n))
12#define _TC_MAKEMASK(v,n) (_TC_MAKE32((_TC_MAKE32(1)<<(v))-1) << _TC_MAKE32(n))
13#define _TC_MAKEVALUE(v,n) (_TC_MAKE32(v) << _TC_MAKE32(n))
14#define _TC_GETVALUE(v,n,m) ((_TC_MAKE32(v) & _TC_MAKE32(m)) >> _TC_MAKE32(n))
15
16/* verdict bit breakdown
17 *
18bit 0: when set -> this packet has been munged already
19
20bit 1: when set -> It is ok to munge this packet
21
22bit 2,3,4,5: Reclassify counter - sort of reverse TTL - if exceeded
23assume loop
24
25bit 6,7: Where this packet was last seen
260: Above the transmit example at the socket level
271: on the Ingress
282: on the Egress
29
30bit 8: when set --> Request not to classify on ingress.
31
32bits 9,10,11: redirect counter - redirect TTL. Loop avoidance
33
34 *
35 * */
36
37#define TC_MUNGED _TC_MAKEMASK1(0)
38#define SET_TC_MUNGED(v) ( TC_MUNGED | (v & ~TC_MUNGED))
39#define CLR_TC_MUNGED(v) ( v & ~TC_MUNGED)
40
41#define TC_OK2MUNGE _TC_MAKEMASK1(1)
42#define SET_TC_OK2MUNGE(v) ( TC_OK2MUNGE | (v & ~TC_OK2MUNGE))
43#define CLR_TC_OK2MUNGE(v) ( v & ~TC_OK2MUNGE)
44
45#define S_TC_VERD _TC_MAKE32(2)
46#define M_TC_VERD _TC_MAKEMASK(4,S_TC_VERD)
47#define G_TC_VERD(x) _TC_GETVALUE(x,S_TC_VERD,M_TC_VERD)
48#define V_TC_VERD(x) _TC_MAKEVALUE(x,S_TC_VERD)
49#define SET_TC_VERD(v,n) ((V_TC_VERD(n)) | (v & ~M_TC_VERD))
50
51#define S_TC_FROM _TC_MAKE32(6)
52#define M_TC_FROM _TC_MAKEMASK(2,S_TC_FROM)
53#define G_TC_FROM(x) _TC_GETVALUE(x,S_TC_FROM,M_TC_FROM)
54#define V_TC_FROM(x) _TC_MAKEVALUE(x,S_TC_FROM)
55#define SET_TC_FROM(v,n) ((V_TC_FROM(n)) | (v & ~M_TC_FROM))
56#define AT_STACK 0x0
57#define AT_INGRESS 0x1
58#define AT_EGRESS 0x2
59
60#define TC_NCLS _TC_MAKEMASK1(8)
61#define SET_TC_NCLS(v) ( TC_NCLS | (v & ~TC_NCLS))
62#define CLR_TC_NCLS(v) ( v & ~TC_NCLS)
63
64#define S_TC_RTTL _TC_MAKE32(9)
65#define M_TC_RTTL _TC_MAKEMASK(3,S_TC_RTTL)
66#define G_TC_RTTL(x) _TC_GETVALUE(x,S_TC_RTTL,M_TC_RTTL)
67#define V_TC_RTTL(x) _TC_MAKEVALUE(x,S_TC_RTTL)
68#define SET_TC_RTTL(v,n) ((V_TC_RTTL(n)) | (v & ~M_TC_RTTL))
69
70#define S_TC_AT _TC_MAKE32(12)
71#define M_TC_AT _TC_MAKEMASK(2,S_TC_AT)
72#define G_TC_AT(x) _TC_GETVALUE(x,S_TC_AT,M_TC_AT)
73#define V_TC_AT(x) _TC_MAKEVALUE(x,S_TC_AT)
74#define SET_TC_AT(v,n) ((V_TC_AT(n)) | (v & ~M_TC_AT))
75
76/* Action attributes */
77enum
78{
79 TCA_ACT_UNSPEC,
80 TCA_ACT_KIND,
81 TCA_ACT_OPTIONS,
82 TCA_ACT_INDEX,
83 TCA_ACT_STATS,
84 __TCA_ACT_MAX
85};
86
87#define TCA_ACT_MAX __TCA_ACT_MAX
88#define TCA_OLD_COMPAT (TCA_ACT_MAX+1)
89#define TCA_ACT_MAX_PRIO 32
90#define TCA_ACT_BIND 1
91#define TCA_ACT_NOBIND 0
92#define TCA_ACT_UNBIND 1
93#define TCA_ACT_NOUNBIND 0
94#define TCA_ACT_REPLACE 1
95#define TCA_ACT_NOREPLACE 0
96#define MAX_REC_LOOP 4
97#define MAX_RED_LOOP 4
98
99#define TC_ACT_UNSPEC (-1)
100#define TC_ACT_OK 0
101#define TC_ACT_RECLASSIFY 1
102#define TC_ACT_SHOT 2
103#define TC_ACT_PIPE 3
104#define TC_ACT_STOLEN 4
105#define TC_ACT_QUEUED 5
106#define TC_ACT_REPEAT 6
107#define TC_ACT_JUMP 0x10000000
108
109/* Action type identifiers*/
110enum
111{
112 TCA_ID_UNSPEC=0,
113 TCA_ID_POLICE=1,
114 /* other actions go here */
115 __TCA_ID_MAX=255
116};
117
118#define TCA_ID_MAX __TCA_ID_MAX
119
120struct tc_police
121{
122 __u32 index;
123 int action;
124#define TC_POLICE_UNSPEC TC_ACT_UNSPEC
125#define TC_POLICE_OK TC_ACT_OK
126#define TC_POLICE_RECLASSIFY TC_ACT_RECLASSIFY
127#define TC_POLICE_SHOT TC_ACT_SHOT
128#define TC_POLICE_PIPE TC_ACT_PIPE
129
130 __u32 limit;
131 __u32 burst;
132 __u32 mtu;
133 struct tc_ratespec rate;
134 struct tc_ratespec peakrate;
135 int refcnt;
136 int bindcnt;
137 __u32 capab;
138};
139
140struct tcf_t
141{
142 __u64 install;
143 __u64 lastuse;
144 __u64 expires;
145};
146
147struct tc_cnt
148{
149 int refcnt;
150 int bindcnt;
151};
152
153#define tc_gen \
154 __u32 index; \
155 __u32 capab; \
156 int action; \
157 int refcnt; \
158 int bindcnt
159
160enum
161{
162 TCA_POLICE_UNSPEC,
163 TCA_POLICE_TBF,
164 TCA_POLICE_RATE,
165 TCA_POLICE_PEAKRATE,
166 TCA_POLICE_AVRATE,
167 TCA_POLICE_RESULT,
168 __TCA_POLICE_MAX
169#define TCA_POLICE_RESULT TCA_POLICE_RESULT
170};
171
172#define TCA_POLICE_MAX (__TCA_POLICE_MAX - 1)
173
174/* U32 filters */
175
176#define TC_U32_HTID(h) ((h)&0xFFF00000)
177#define TC_U32_USERHTID(h) (TC_U32_HTID(h)>>20)
178#define TC_U32_HASH(h) (((h)>>12)&0xFF)
179#define TC_U32_NODE(h) ((h)&0xFFF)
180#define TC_U32_KEY(h) ((h)&0xFFFFF)
181#define TC_U32_UNSPEC 0
182#define TC_U32_ROOT (0xFFF00000)
183
184enum
185{
186 TCA_U32_UNSPEC,
187 TCA_U32_CLASSID,
188 TCA_U32_HASH,
189 TCA_U32_LINK,
190 TCA_U32_DIVISOR,
191 TCA_U32_SEL,
192 TCA_U32_POLICE,
193 TCA_U32_ACT,
194 TCA_U32_INDEV,
195 TCA_U32_PCNT,
196 TCA_U32_MARK,
197 __TCA_U32_MAX
198};
199
200#define TCA_U32_MAX (__TCA_U32_MAX - 1)
201
202struct tc_u32_key
203{
204 __u32 mask;
205 __u32 val;
206 int off;
207 int offmask;
208};
209
210struct tc_u32_sel
211{
212 unsigned char flags;
213 unsigned char offshift;
214 unsigned char nkeys;
215
216 __u16 offmask;
217 __u16 off;
218 short offoff;
219
220 short hoff;
221 __u32 hmask;
222 struct tc_u32_key keys[0];
223};
224
225struct tc_u32_mark
226{
227 __u32 val;
228 __u32 mask;
229 __u32 success;
230};
231
232struct tc_u32_pcnt
233{
234 __u64 rcnt;
235 __u64 rhit;
236 __u64 kcnts[0];
237};
238
239/* Flags */
240
241#define TC_U32_TERMINAL 1
242#define TC_U32_OFFSET 2
243#define TC_U32_VAROFFSET 4
244#define TC_U32_EAT 8
245
246#define TC_U32_MAXDEPTH 8
247
248
249/* RSVP filter */
250
251enum
252{
253 TCA_RSVP_UNSPEC,
254 TCA_RSVP_CLASSID,
255 TCA_RSVP_DST,
256 TCA_RSVP_SRC,
257 TCA_RSVP_PINFO,
258 TCA_RSVP_POLICE,
259 TCA_RSVP_ACT,
260 __TCA_RSVP_MAX
261};
262
263#define TCA_RSVP_MAX (__TCA_RSVP_MAX - 1 )
264
265struct tc_rsvp_gpi
266{
267 __u32 key;
268 __u32 mask;
269 int offset;
270};
271
272struct tc_rsvp_pinfo
273{
274 struct tc_rsvp_gpi dpi;
275 struct tc_rsvp_gpi spi;
276 __u8 protocol;
277 __u8 tunnelid;
278 __u8 tunnelhdr;
279};
280
281/* ROUTE filter */
282
283enum
284{
285 TCA_ROUTE4_UNSPEC,
286 TCA_ROUTE4_CLASSID,
287 TCA_ROUTE4_TO,
288 TCA_ROUTE4_FROM,
289 TCA_ROUTE4_IIF,
290 TCA_ROUTE4_POLICE,
291 TCA_ROUTE4_ACT,
292 __TCA_ROUTE4_MAX
293};
294
295#define TCA_ROUTE4_MAX (__TCA_ROUTE4_MAX - 1)
296
297
298/* FW filter */
299
300enum
301{
302 TCA_FW_UNSPEC,
303 TCA_FW_CLASSID,
304 TCA_FW_POLICE,
305 TCA_FW_INDEV, /* used by CONFIG_NET_CLS_IND */
306 TCA_FW_ACT, /* used by CONFIG_NET_CLS_ACT */
307 __TCA_FW_MAX
308};
309
310#define TCA_FW_MAX (__TCA_FW_MAX - 1)
311
312/* TC index filter */
313
314enum
315{
316 TCA_TCINDEX_UNSPEC,
317 TCA_TCINDEX_HASH,
318 TCA_TCINDEX_MASK,
319 TCA_TCINDEX_SHIFT,
320 TCA_TCINDEX_FALL_THROUGH,
321 TCA_TCINDEX_CLASSID,
322 TCA_TCINDEX_POLICE,
323 TCA_TCINDEX_ACT,
324 __TCA_TCINDEX_MAX
325};
326
327#define TCA_TCINDEX_MAX (__TCA_TCINDEX_MAX - 1)
328
329/* Basic filter */
330
331enum
332{
333 TCA_BASIC_UNSPEC,
334 TCA_BASIC_CLASSID,
335 TCA_BASIC_EMATCHES,
336 TCA_BASIC_ACT,
337 TCA_BASIC_POLICE,
338 __TCA_BASIC_MAX
339};
340
341#define TCA_BASIC_MAX (__TCA_BASIC_MAX - 1)
342
343/* Extended Matches */
344
345struct tcf_ematch_tree_hdr
346{
347 __u16 nmatches;
348 __u16 progid;
349};
350
351enum
352{
353 TCA_EMATCH_TREE_UNSPEC,
354 TCA_EMATCH_TREE_HDR,
355 TCA_EMATCH_TREE_LIST,
356 __TCA_EMATCH_TREE_MAX
357};
358#define TCA_EMATCH_TREE_MAX (__TCA_EMATCH_TREE_MAX - 1)
359
360struct tcf_ematch_hdr
361{
362 __u16 matchid;
363 __u16 kind;
364 __u16 flags;
365 __u16 pad; /* currently unused */
366};
367
368/* 0 1
369 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
370 * +-----------------------+-+-+---+
371 * | Unused |S|I| R |
372 * +-----------------------+-+-+---+
373 *
374 * R(2) ::= relation to next ematch
375 * where: 0 0 END (last ematch)
376 * 0 1 AND
377 * 1 0 OR
378 * 1 1 Unused (invalid)
379 * I(1) ::= invert result
380 * S(1) ::= simple payload
381 */
382#define TCF_EM_REL_END 0
383#define TCF_EM_REL_AND (1<<0)
384#define TCF_EM_REL_OR (1<<1)
385#define TCF_EM_INVERT (1<<2)
386#define TCF_EM_SIMPLE (1<<3)
387
388#define TCF_EM_REL_MASK 3
389#define TCF_EM_REL_VALID(v) (((v) & TCF_EM_REL_MASK) != TCF_EM_REL_MASK)
390
391enum
392{
393 TCF_LAYER_LINK,
394 TCF_LAYER_NETWORK,
395 TCF_LAYER_TRANSPORT,
396 __TCF_LAYER_MAX
397};
398#define TCF_LAYER_MAX (__TCF_LAYER_MAX - 1)
399
400/* Ematch type assignments
401 * 1..32767 Reserved for ematches inside kernel tree
402 * 32768..65535 Free to use, not reliable
403 */
404enum
405{
406 TCF_EM_CONTAINER,
407 TCF_EM_CMP,
408 TCF_EM_NBYTE,
409 TCF_EM_U32,
410 TCF_EM_META,
411 __TCF_EM_MAX
412};
413
414enum
415{
416 TCF_EM_PROG_TC
417};
418
419enum
420{
421 TCF_EM_OPND_EQ,
422 TCF_EM_OPND_GT,
423 TCF_EM_OPND_LT
424};
425
426#endif
diff --git a/include/linux/pkt_sched.h b/include/linux/pkt_sched.h
new file mode 100644
index 000000000000..73d84c071cb1
--- /dev/null
+++ b/include/linux/pkt_sched.h
@@ -0,0 +1,454 @@
1#ifndef __LINUX_PKT_SCHED_H
2#define __LINUX_PKT_SCHED_H
3
4/* Logical priority bands not depending on specific packet scheduler.
5 Every scheduler will map them to real traffic classes, if it has
6 no more precise mechanism to classify packets.
7
8 These numbers have no special meaning, though their coincidence
9 with obsolete IPv6 values is not occasional :-). New IPv6 drafts
10 preferred full anarchy inspired by diffserv group.
11
12 Note: TC_PRIO_BESTEFFORT does not mean that it is the most unhappy
13 class, actually, as rule it will be handled with more care than
14 filler or even bulk.
15 */
16
17#define TC_PRIO_BESTEFFORT 0
18#define TC_PRIO_FILLER 1
19#define TC_PRIO_BULK 2
20#define TC_PRIO_INTERACTIVE_BULK 4
21#define TC_PRIO_INTERACTIVE 6
22#define TC_PRIO_CONTROL 7
23
24#define TC_PRIO_MAX 15
25
26/* Generic queue statistics, available for all the elements.
27 Particular schedulers may have also their private records.
28 */
29
30struct tc_stats
31{
32 __u64 bytes; /* NUmber of enqueues bytes */
33 __u32 packets; /* Number of enqueued packets */
34 __u32 drops; /* Packets dropped because of lack of resources */
35 __u32 overlimits; /* Number of throttle events when this
36 * flow goes out of allocated bandwidth */
37 __u32 bps; /* Current flow byte rate */
38 __u32 pps; /* Current flow packet rate */
39 __u32 qlen;
40 __u32 backlog;
41};
42
43struct tc_estimator
44{
45 signed char interval;
46 unsigned char ewma_log;
47};
48
49/* "Handles"
50 ---------
51
52 All the traffic control objects have 32bit identifiers, or "handles".
53
54 They can be considered as opaque numbers from user API viewpoint,
55 but actually they always consist of two fields: major and
56 minor numbers, which are interpreted by kernel specially,
57 that may be used by applications, though not recommended.
58
59 F.e. qdisc handles always have minor number equal to zero,
60 classes (or flows) have major equal to parent qdisc major, and
61 minor uniquely identifying class inside qdisc.
62
63 Macros to manipulate handles:
64 */
65
66#define TC_H_MAJ_MASK (0xFFFF0000U)
67#define TC_H_MIN_MASK (0x0000FFFFU)
68#define TC_H_MAJ(h) ((h)&TC_H_MAJ_MASK)
69#define TC_H_MIN(h) ((h)&TC_H_MIN_MASK)
70#define TC_H_MAKE(maj,min) (((maj)&TC_H_MAJ_MASK)|((min)&TC_H_MIN_MASK))
71
72#define TC_H_UNSPEC (0U)
73#define TC_H_ROOT (0xFFFFFFFFU)
74#define TC_H_INGRESS (0xFFFFFFF1U)
75
76struct tc_ratespec
77{
78 unsigned char cell_log;
79 unsigned char __reserved;
80 unsigned short feature;
81 short addend;
82 unsigned short mpu;
83 __u32 rate;
84};
85
86/* FIFO section */
87
88struct tc_fifo_qopt
89{
90 __u32 limit; /* Queue length: bytes for bfifo, packets for pfifo */
91};
92
93/* PRIO section */
94
95#define TCQ_PRIO_BANDS 16
96
97struct tc_prio_qopt
98{
99 int bands; /* Number of bands */
100 __u8 priomap[TC_PRIO_MAX+1]; /* Map: logical priority -> PRIO band */
101};
102
103/* TBF section */
104
105struct tc_tbf_qopt
106{
107 struct tc_ratespec rate;
108 struct tc_ratespec peakrate;
109 __u32 limit;
110 __u32 buffer;
111 __u32 mtu;
112};
113
114enum
115{
116 TCA_TBF_UNSPEC,
117 TCA_TBF_PARMS,
118 TCA_TBF_RTAB,
119 TCA_TBF_PTAB,
120 __TCA_TBF_MAX,
121};
122
123#define TCA_TBF_MAX (__TCA_TBF_MAX - 1)
124
125
126/* TEQL section */
127
128/* TEQL does not require any parameters */
129
130/* SFQ section */
131
132struct tc_sfq_qopt
133{
134 unsigned quantum; /* Bytes per round allocated to flow */
135 int perturb_period; /* Period of hash perturbation */
136 __u32 limit; /* Maximal packets in queue */
137 unsigned divisor; /* Hash divisor */
138 unsigned flows; /* Maximal number of flows */
139};
140
141/*
142 * NOTE: limit, divisor and flows are hardwired to code at the moment.
143 *
144 * limit=flows=128, divisor=1024;
145 *
146 * The only reason for this is efficiency, it is possible
147 * to change these parameters in compile time.
148 */
149
150/* RED section */
151
152enum
153{
154 TCA_RED_UNSPEC,
155 TCA_RED_PARMS,
156 TCA_RED_STAB,
157 __TCA_RED_MAX,
158};
159
160#define TCA_RED_MAX (__TCA_RED_MAX - 1)
161
162struct tc_red_qopt
163{
164 __u32 limit; /* HARD maximal queue length (bytes) */
165 __u32 qth_min; /* Min average length threshold (bytes) */
166 __u32 qth_max; /* Max average length threshold (bytes) */
167 unsigned char Wlog; /* log(W) */
168 unsigned char Plog; /* log(P_max/(qth_max-qth_min)) */
169 unsigned char Scell_log; /* cell size for idle damping */
170 unsigned char flags;
171#define TC_RED_ECN 1
172};
173
174struct tc_red_xstats
175{
176 __u32 early; /* Early drops */
177 __u32 pdrop; /* Drops due to queue limits */
178 __u32 other; /* Drops due to drop() calls */
179 __u32 marked; /* Marked packets */
180};
181
182/* GRED section */
183
184#define MAX_DPs 16
185
186enum
187{
188 TCA_GRED_UNSPEC,
189 TCA_GRED_PARMS,
190 TCA_GRED_STAB,
191 TCA_GRED_DPS,
192 __TCA_GRED_MAX,
193};
194
195#define TCA_GRED_MAX (__TCA_GRED_MAX - 1)
196
197#define TCA_SET_OFF TCA_GRED_PARMS
198struct tc_gred_qopt
199{
200 __u32 limit; /* HARD maximal queue length (bytes)
201*/
202 __u32 qth_min; /* Min average length threshold (bytes)
203*/
204 __u32 qth_max; /* Max average length threshold (bytes)
205*/
206 __u32 DP; /* upto 2^32 DPs */
207 __u32 backlog;
208 __u32 qave;
209 __u32 forced;
210 __u32 early;
211 __u32 other;
212 __u32 pdrop;
213
214 unsigned char Wlog; /* log(W) */
215 unsigned char Plog; /* log(P_max/(qth_max-qth_min)) */
216 unsigned char Scell_log; /* cell size for idle damping */
217 __u8 prio; /* prio of this VQ */
218 __u32 packets;
219 __u32 bytesin;
220};
221/* gred setup */
222struct tc_gred_sopt
223{
224 __u32 DPs;
225 __u32 def_DP;
226 __u8 grio;
227};
228
229/* HTB section */
230#define TC_HTB_NUMPRIO 8
231#define TC_HTB_MAXDEPTH 8
232#define TC_HTB_PROTOVER 3 /* the same as HTB and TC's major */
233
234struct tc_htb_opt
235{
236 struct tc_ratespec rate;
237 struct tc_ratespec ceil;
238 __u32 buffer;
239 __u32 cbuffer;
240 __u32 quantum;
241 __u32 level; /* out only */
242 __u32 prio;
243};
244struct tc_htb_glob
245{
246 __u32 version; /* to match HTB/TC */
247 __u32 rate2quantum; /* bps->quantum divisor */
248 __u32 defcls; /* default class number */
249 __u32 debug; /* debug flags */
250
251 /* stats */
252 __u32 direct_pkts; /* count of non shapped packets */
253};
254enum
255{
256 TCA_HTB_UNSPEC,
257 TCA_HTB_PARMS,
258 TCA_HTB_INIT,
259 TCA_HTB_CTAB,
260 TCA_HTB_RTAB,
261 __TCA_HTB_MAX,
262};
263
264#define TCA_HTB_MAX (__TCA_HTB_MAX - 1)
265
266struct tc_htb_xstats
267{
268 __u32 lends;
269 __u32 borrows;
270 __u32 giants; /* too big packets (rate will not be accurate) */
271 __u32 tokens;
272 __u32 ctokens;
273};
274
275/* HFSC section */
276
277struct tc_hfsc_qopt
278{
279 __u16 defcls; /* default class */
280};
281
282struct tc_service_curve
283{
284 __u32 m1; /* slope of the first segment in bps */
285 __u32 d; /* x-projection of the first segment in us */
286 __u32 m2; /* slope of the second segment in bps */
287};
288
289struct tc_hfsc_stats
290{
291 __u64 work; /* total work done */
292 __u64 rtwork; /* work done by real-time criteria */
293 __u32 period; /* current period */
294 __u32 level; /* class level in hierarchy */
295};
296
297enum
298{
299 TCA_HFSC_UNSPEC,
300 TCA_HFSC_RSC,
301 TCA_HFSC_FSC,
302 TCA_HFSC_USC,
303 __TCA_HFSC_MAX,
304};
305
306#define TCA_HFSC_MAX (__TCA_HFSC_MAX - 1)
307
308
309/* CBQ section */
310
311#define TC_CBQ_MAXPRIO 8
312#define TC_CBQ_MAXLEVEL 8
313#define TC_CBQ_DEF_EWMA 5
314
315struct tc_cbq_lssopt
316{
317 unsigned char change;
318 unsigned char flags;
319#define TCF_CBQ_LSS_BOUNDED 1
320#define TCF_CBQ_LSS_ISOLATED 2
321 unsigned char ewma_log;
322 unsigned char level;
323#define TCF_CBQ_LSS_FLAGS 1
324#define TCF_CBQ_LSS_EWMA 2
325#define TCF_CBQ_LSS_MAXIDLE 4
326#define TCF_CBQ_LSS_MINIDLE 8
327#define TCF_CBQ_LSS_OFFTIME 0x10
328#define TCF_CBQ_LSS_AVPKT 0x20
329 __u32 maxidle;
330 __u32 minidle;
331 __u32 offtime;
332 __u32 avpkt;
333};
334
335struct tc_cbq_wrropt
336{
337 unsigned char flags;
338 unsigned char priority;
339 unsigned char cpriority;
340 unsigned char __reserved;
341 __u32 allot;
342 __u32 weight;
343};
344
345struct tc_cbq_ovl
346{
347 unsigned char strategy;
348#define TC_CBQ_OVL_CLASSIC 0
349#define TC_CBQ_OVL_DELAY 1
350#define TC_CBQ_OVL_LOWPRIO 2
351#define TC_CBQ_OVL_DROP 3
352#define TC_CBQ_OVL_RCLASSIC 4
353 unsigned char priority2;
354 __u32 penalty;
355};
356
357struct tc_cbq_police
358{
359 unsigned char police;
360 unsigned char __res1;
361 unsigned short __res2;
362};
363
364struct tc_cbq_fopt
365{
366 __u32 split;
367 __u32 defmap;
368 __u32 defchange;
369};
370
371struct tc_cbq_xstats
372{
373 __u32 borrows;
374 __u32 overactions;
375 __s32 avgidle;
376 __s32 undertime;
377};
378
379enum
380{
381 TCA_CBQ_UNSPEC,
382 TCA_CBQ_LSSOPT,
383 TCA_CBQ_WRROPT,
384 TCA_CBQ_FOPT,
385 TCA_CBQ_OVL_STRATEGY,
386 TCA_CBQ_RATE,
387 TCA_CBQ_RTAB,
388 TCA_CBQ_POLICE,
389 __TCA_CBQ_MAX,
390};
391
392#define TCA_CBQ_MAX (__TCA_CBQ_MAX - 1)
393
394/* dsmark section */
395
396enum {
397 TCA_DSMARK_UNSPEC,
398 TCA_DSMARK_INDICES,
399 TCA_DSMARK_DEFAULT_INDEX,
400 TCA_DSMARK_SET_TC_INDEX,
401 TCA_DSMARK_MASK,
402 TCA_DSMARK_VALUE,
403 __TCA_DSMARK_MAX,
404};
405
406#define TCA_DSMARK_MAX (__TCA_DSMARK_MAX - 1)
407
408/* ATM section */
409
410enum {
411 TCA_ATM_UNSPEC,
412 TCA_ATM_FD, /* file/socket descriptor */
413 TCA_ATM_PTR, /* pointer to descriptor - later */
414 TCA_ATM_HDR, /* LL header */
415 TCA_ATM_EXCESS, /* excess traffic class (0 for CLP) */
416 TCA_ATM_ADDR, /* PVC address (for output only) */
417 TCA_ATM_STATE, /* VC state (ATM_VS_*; for output only) */
418 __TCA_ATM_MAX,
419};
420
421#define TCA_ATM_MAX (__TCA_ATM_MAX - 1)
422
423/* Network emulator */
424
425enum
426{
427 TCA_NETEM_UNSPEC,
428 TCA_NETEM_CORR,
429 TCA_NETEM_DELAY_DIST,
430 __TCA_NETEM_MAX,
431};
432
433#define TCA_NETEM_MAX (__TCA_NETEM_MAX - 1)
434
435struct tc_netem_qopt
436{
437 __u32 latency; /* added delay (us) */
438 __u32 limit; /* fifo limit (packets) */
439 __u32 loss; /* random packet loss (0=none ~0=100%) */
440 __u32 gap; /* re-ordering gap (0 for delay all) */
441 __u32 duplicate; /* random packet dup (0=none ~0=100%) */
442 __u32 jitter; /* random jitter in latency (us) */
443};
444
445struct tc_netem_corr
446{
447 __u32 delay_corr; /* delay correlation */
448 __u32 loss_corr; /* packet loss correlation */
449 __u32 dup_corr; /* duplicate correlation */
450};
451
452#define NETEM_DIST_SCALE 8192
453
454#endif
diff --git a/include/linux/pktcdvd.h b/include/linux/pktcdvd.h
new file mode 100644
index 000000000000..4e2d2a942ecb
--- /dev/null
+++ b/include/linux/pktcdvd.h
@@ -0,0 +1,275 @@
1/*
2 * Copyright (C) 2000 Jens Axboe <axboe@suse.de>
3 * Copyright (C) 2001-2004 Peter Osterlund <petero2@telia.com>
4 *
5 * May be copied or modified under the terms of the GNU General Public
6 * License. See linux/COPYING for more information.
7 *
8 * Packet writing layer for ATAPI and SCSI CD-R, CD-RW, DVD-R, and
9 * DVD-RW devices.
10 *
11 */
12#ifndef __PKTCDVD_H
13#define __PKTCDVD_H
14
15#include <linux/types.h>
16
17/*
18 * 1 for normal debug messages, 2 is very verbose. 0 to turn it off.
19 */
20#define PACKET_DEBUG 1
21
22#define MAX_WRITERS 8
23
24#define PKT_RB_POOL_SIZE 512
25
26/*
27 * How long we should hold a non-full packet before starting data gathering.
28 */
29#define PACKET_WAIT_TIME (HZ * 5 / 1000)
30
31/*
32 * use drive write caching -- we need deferred error handling to be
33 * able to sucessfully recover with this option (drive will return good
34 * status as soon as the cdb is validated).
35 */
36#if defined(CONFIG_CDROM_PKTCDVD_WCACHE)
37#define USE_WCACHING 1
38#else
39#define USE_WCACHING 0
40#endif
41
42/*
43 * No user-servicable parts beyond this point ->
44 */
45
46/*
47 * device types
48 */
49#define PACKET_CDR 1
50#define PACKET_CDRW 2
51#define PACKET_DVDR 3
52#define PACKET_DVDRW 4
53
54/*
55 * flags
56 */
57#define PACKET_WRITABLE 1 /* pd is writable */
58#define PACKET_NWA_VALID 2 /* next writable address valid */
59#define PACKET_LRA_VALID 3 /* last recorded address valid */
60#define PACKET_MERGE_SEGS 4 /* perform segment merging to keep */
61 /* underlying cdrom device happy */
62
63/*
64 * Disc status -- from READ_DISC_INFO
65 */
66#define PACKET_DISC_EMPTY 0
67#define PACKET_DISC_INCOMPLETE 1
68#define PACKET_DISC_COMPLETE 2
69#define PACKET_DISC_OTHER 3
70
71/*
72 * write type, and corresponding data block type
73 */
74#define PACKET_MODE1 1
75#define PACKET_MODE2 2
76#define PACKET_BLOCK_MODE1 8
77#define PACKET_BLOCK_MODE2 10
78
79/*
80 * Last session/border status
81 */
82#define PACKET_SESSION_EMPTY 0
83#define PACKET_SESSION_INCOMPLETE 1
84#define PACKET_SESSION_RESERVED 2
85#define PACKET_SESSION_COMPLETE 3
86
87#define PACKET_MCN "4a656e734178626f65323030300000"
88
89#undef PACKET_USE_LS
90
91#define PKT_CTRL_CMD_SETUP 0
92#define PKT_CTRL_CMD_TEARDOWN 1
93#define PKT_CTRL_CMD_STATUS 2
94
95struct pkt_ctrl_command {
96 __u32 command; /* in: Setup, teardown, status */
97 __u32 dev_index; /* in/out: Device index */
98 __u32 dev; /* in/out: Device nr for cdrw device */
99 __u32 pkt_dev; /* in/out: Device nr for packet device */
100 __u32 num_devices; /* out: Largest device index + 1 */
101 __u32 padding; /* Not used */
102};
103
104/*
105 * packet ioctls
106 */
107#define PACKET_IOCTL_MAGIC ('X')
108#define PACKET_CTRL_CMD _IOWR(PACKET_IOCTL_MAGIC, 1, struct pkt_ctrl_command)
109
110#ifdef __KERNEL__
111#include <linux/blkdev.h>
112#include <linux/completion.h>
113#include <linux/cdrom.h>
114
115struct packet_settings
116{
117 __u8 size; /* packet size in (512 byte) sectors */
118 __u8 fp; /* fixed packets */
119 __u8 link_loss; /* the rest is specified
120 * as per Mt Fuji */
121 __u8 write_type;
122 __u8 track_mode;
123 __u8 block_mode;
124};
125
126/*
127 * Very crude stats for now
128 */
129struct packet_stats
130{
131 unsigned long pkt_started;
132 unsigned long pkt_ended;
133 unsigned long secs_w;
134 unsigned long secs_rg;
135 unsigned long secs_r;
136};
137
138struct packet_cdrw
139{
140 struct list_head pkt_free_list;
141 struct list_head pkt_active_list;
142 spinlock_t active_list_lock; /* Serialize access to pkt_active_list */
143 struct task_struct *thread;
144 atomic_t pending_bios;
145};
146
147/*
148 * Switch to high speed reading after reading this many kilobytes
149 * with no interspersed writes.
150 */
151#define HI_SPEED_SWITCH 512
152
153struct packet_iosched
154{
155 atomic_t attention; /* Set to non-zero when queue processing is needed */
156 int writing; /* Non-zero when writing, zero when reading */
157 spinlock_t lock; /* Protecting read/write queue manipulations */
158 struct bio *read_queue;
159 struct bio *read_queue_tail;
160 struct bio *write_queue;
161 struct bio *write_queue_tail;
162 int high_prio_read; /* An important read request has been queued */
163 int successive_reads;
164};
165
166/*
167 * 32 buffers of 2048 bytes
168 */
169#define PACKET_MAX_SIZE 32
170#define PAGES_PER_PACKET (PACKET_MAX_SIZE * CD_FRAMESIZE / PAGE_SIZE)
171#define PACKET_MAX_SECTORS (PACKET_MAX_SIZE * CD_FRAMESIZE >> 9)
172
173enum packet_data_state {
174 PACKET_IDLE_STATE, /* Not used at the moment */
175 PACKET_WAITING_STATE, /* Waiting for more bios to arrive, so */
176 /* we don't have to do as much */
177 /* data gathering */
178 PACKET_READ_WAIT_STATE, /* Waiting for reads to fill in holes */
179 PACKET_WRITE_WAIT_STATE, /* Waiting for the write to complete */
180 PACKET_RECOVERY_STATE, /* Recover after read/write errors */
181 PACKET_FINISHED_STATE, /* After write has finished */
182
183 PACKET_NUM_STATES /* Number of possible states */
184};
185
186/*
187 * Information needed for writing a single packet
188 */
189struct pktcdvd_device;
190
191struct packet_data
192{
193 struct list_head list;
194
195 spinlock_t lock; /* Lock protecting state transitions and */
196 /* orig_bios list */
197
198 struct bio *orig_bios; /* Original bios passed to pkt_make_request */
199 struct bio *orig_bios_tail;/* that will be handled by this packet */
200 int write_size; /* Total size of all bios in the orig_bios */
201 /* list, measured in number of frames */
202
203 struct bio *w_bio; /* The bio we will send to the real CD */
204 /* device once we have all data for the */
205 /* packet we are going to write */
206 sector_t sector; /* First sector in this packet */
207 int frames; /* Number of frames in this packet */
208
209 enum packet_data_state state; /* Current state */
210 atomic_t run_sm; /* Incremented whenever the state */
211 /* machine needs to be run */
212 long sleep_time; /* Set this to non-zero to make the state */
213 /* machine run after this many jiffies. */
214
215 atomic_t io_wait; /* Number of pending IO operations */
216 atomic_t io_errors; /* Number of read/write errors during IO */
217
218 struct bio *r_bios[PACKET_MAX_SIZE]; /* bios to use during data gathering */
219 struct page *pages[PAGES_PER_PACKET];
220
221 int cache_valid; /* If non-zero, the data for the zone defined */
222 /* by the sector variable is completely cached */
223 /* in the pages[] vector. */
224
225 int id; /* ID number for debugging */
226 struct pktcdvd_device *pd;
227};
228
229struct pkt_rb_node {
230 struct rb_node rb_node;
231 struct bio *bio;
232};
233
234struct packet_stacked_data
235{
236 struct bio *bio; /* Original read request bio */
237 struct pktcdvd_device *pd;
238};
239#define PSD_POOL_SIZE 64
240
241struct pktcdvd_device
242{
243 struct block_device *bdev; /* dev attached */
244 dev_t pkt_dev; /* our dev */
245 char name[20];
246 struct packet_settings settings;
247 struct packet_stats stats;
248 int refcnt; /* Open count */
249 int write_speed; /* current write speed, kB/s */
250 int read_speed; /* current read speed, kB/s */
251 unsigned long offset; /* start offset */
252 __u8 mode_offset; /* 0 / 8 */
253 __u8 type;
254 unsigned long flags;
255 __u16 mmc3_profile;
256 __u32 nwa; /* next writable address */
257 __u32 lra; /* last recorded address */
258 struct packet_cdrw cdrw;
259 wait_queue_head_t wqueue;
260
261 spinlock_t lock; /* Serialize access to bio_queue */
262 struct rb_root bio_queue; /* Work queue of bios we need to handle */
263 int bio_queue_size; /* Number of nodes in bio_queue */
264 sector_t current_sector; /* Keep track of where the elevator is */
265 atomic_t scan_queue; /* Set to non-zero when pkt_handle_queue */
266 /* needs to be run. */
267 mempool_t *rb_pool; /* mempool for pkt_rb_node allocations */
268
269 struct packet_iosched iosched;
270 struct gendisk *disk;
271};
272
273#endif /* __KERNEL__ */
274
275#endif /* __PKTCDVD_H */
diff --git a/include/linux/platform.h b/include/linux/platform.h
new file mode 100644
index 000000000000..3c33084a6ec2
--- /dev/null
+++ b/include/linux/platform.h
@@ -0,0 +1,43 @@
1/*
2 * include/linux/platform.h - platform driver definitions
3 *
4 * Because of the prolific consumerism of the average American,
5 * and the dominant marketing budgets of PC OEMs, we have been
6 * blessed with frequent updates of the PC architecture.
7 *
8 * While most of these calls are singular per architecture, they
9 * require an extra layer of abstraction on the x86 so the right
10 * subsystem gets the right call.
11 *
12 * Basically, this consolidates the power off and reboot callbacks
13 * into one structure, as well as adding power management hooks.
14 *
15 * When adding a platform driver, please make sure all callbacks are
16 * filled. There are defaults defined below that do nothing; use those
17 * if you do not support that callback.
18 */
19
20#ifndef _PLATFORM_H_
21#define _PLATFORM_H_
22#ifdef __KERNEL__
23
24#include <linux/types.h>
25
26struct platform_t {
27 char * name;
28 u32 suspend_states;
29 void (*reboot)(char * cmd);
30 void (*halt)(void);
31 void (*power_off)(void);
32 int (*suspend)(int state, int flags);
33 void (*idle)(void);
34};
35
36extern struct platform_t * platform;
37extern void default_reboot(char * cmd);
38extern void default_halt(void);
39extern int default_suspend(int state, int flags);
40extern void default_idle(void);
41
42#endif /* __KERNEL__ */
43#endif /* _PLATFORM_H */
diff --git a/include/linux/pm.h b/include/linux/pm.h
new file mode 100644
index 000000000000..ed2b76e75199
--- /dev/null
+++ b/include/linux/pm.h
@@ -0,0 +1,233 @@
1/*
2 * pm.h - Power management interface
3 *
4 * Copyright (C) 2000 Andrew Henroid
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_H
22#define _LINUX_PM_H
23
24#ifdef __KERNEL__
25
26#include <linux/config.h>
27#include <linux/list.h>
28#include <asm/atomic.h>
29
30/*
31 * Power management requests... these are passed to pm_send_all() and friends.
32 *
33 * these functions are old and deprecated, see below.
34 */
35typedef int __bitwise pm_request_t;
36
37#define PM_SUSPEND ((__force pm_request_t) 1) /* enter D1-D3 */
38#define PM_RESUME ((__force pm_request_t) 2) /* enter D0 */
39
40
41/*
42 * Device types... these are passed to pm_register
43 */
44typedef int __bitwise pm_dev_t;
45
46#define PM_UNKNOWN_DEV ((__force pm_dev_t) 0) /* generic */
47#define PM_SYS_DEV ((__force pm_dev_t) 1) /* system device (fan, KB controller, ...) */
48#define PM_PCI_DEV ((__force pm_dev_t) 2) /* PCI device */
49#define PM_USB_DEV ((__force pm_dev_t) 3) /* USB device */
50#define PM_SCSI_DEV ((__force pm_dev_t) 4) /* SCSI device */
51#define PM_ISA_DEV ((__force pm_dev_t) 5) /* ISA device */
52#define PM_MTD_DEV ((__force pm_dev_t) 6) /* Memory Technology Device */
53
54/*
55 * System device hardware ID (PnP) values
56 */
57enum
58{
59 PM_SYS_UNKNOWN = 0x00000000, /* generic */
60 PM_SYS_KBC = 0x41d00303, /* keyboard controller */
61 PM_SYS_COM = 0x41d00500, /* serial port */
62 PM_SYS_IRDA = 0x41d00510, /* IRDA controller */
63 PM_SYS_FDC = 0x41d00700, /* floppy controller */
64 PM_SYS_VGA = 0x41d00900, /* VGA controller */
65 PM_SYS_PCMCIA = 0x41d00e00, /* PCMCIA controller */
66};
67
68/*
69 * Device identifier
70 */
71#define PM_PCI_ID(dev) ((dev)->bus->number << 16 | (dev)->devfn)
72
73/*
74 * Request handler callback
75 */
76struct pm_dev;
77
78typedef int (*pm_callback)(struct pm_dev *dev, pm_request_t rqst, void *data);
79
80/*
81 * Dynamic device information
82 */
83struct pm_dev
84{
85 pm_dev_t type;
86 unsigned long id;
87 pm_callback callback;
88 void *data;
89
90 unsigned long flags;
91 unsigned long state;
92 unsigned long prev_state;
93
94 struct list_head entry;
95};
96
97#ifdef CONFIG_PM
98
99extern int pm_active;
100
101#define PM_IS_ACTIVE() (pm_active != 0)
102
103/*
104 * Register a device with power management
105 */
106struct pm_dev __deprecated *pm_register(pm_dev_t type, unsigned long id, pm_callback callback);
107
108/*
109 * Unregister a device with power management
110 */
111void __deprecated pm_unregister(struct pm_dev *dev);
112
113/*
114 * Unregister all devices with matching callback
115 */
116void __deprecated pm_unregister_all(pm_callback callback);
117
118/*
119 * Send a request to all devices
120 */
121int __deprecated pm_send_all(pm_request_t rqst, void *data);
122
123#else /* CONFIG_PM */
124
125#define PM_IS_ACTIVE() 0
126
127static inline struct pm_dev *pm_register(pm_dev_t type,
128 unsigned long id,
129 pm_callback callback)
130{
131 return NULL;
132}
133
134static inline void pm_unregister(struct pm_dev *dev) {}
135
136static inline void pm_unregister_all(pm_callback callback) {}
137
138static inline int pm_send_all(pm_request_t rqst, void *data)
139{
140 return 0;
141}
142
143#endif /* CONFIG_PM */
144
145/* Functions above this comment are list-based old-style power
146 * managment. Please avoid using them. */
147
148/*
149 * Callbacks for platform drivers to implement.
150 */
151extern void (*pm_idle)(void);
152extern void (*pm_power_off)(void);
153
154typedef int __bitwise suspend_state_t;
155
156#define PM_SUSPEND_ON ((__force suspend_state_t) 0)
157#define PM_SUSPEND_STANDBY ((__force suspend_state_t) 1)
158#define PM_SUSPEND_MEM ((__force suspend_state_t) 3)
159#define PM_SUSPEND_DISK ((__force suspend_state_t) 4)
160#define PM_SUSPEND_MAX ((__force suspend_state_t) 5)
161
162typedef int __bitwise suspend_disk_method_t;
163
164#define PM_DISK_FIRMWARE ((__force suspend_disk_method_t) 1)
165#define PM_DISK_PLATFORM ((__force suspend_disk_method_t) 2)
166#define PM_DISK_SHUTDOWN ((__force suspend_disk_method_t) 3)
167#define PM_DISK_REBOOT ((__force suspend_disk_method_t) 4)
168#define PM_DISK_MAX ((__force suspend_disk_method_t) 5)
169
170struct pm_ops {
171 suspend_disk_method_t pm_disk_mode;
172 int (*prepare)(suspend_state_t state);
173 int (*enter)(suspend_state_t state);
174 int (*finish)(suspend_state_t state);
175};
176
177extern void pm_set_ops(struct pm_ops *);
178
179extern int pm_suspend(suspend_state_t state);
180
181
182/*
183 * Device power management
184 */
185
186struct device;
187
188typedef u32 __bitwise pm_message_t;
189
190/*
191 * There are 4 important states driver can be in:
192 * ON -- driver is working
193 * FREEZE -- stop operations and apply whatever policy is applicable to a suspended driver
194 * of that class, freeze queues for block like IDE does, drop packets for
195 * ethernet, etc... stop DMA engine too etc... so a consistent image can be
196 * saved; but do not power any hardware down.
197 * SUSPEND - like FREEZE, but hardware is doing as much powersaving as possible. Roughly
198 * pci D3.
199 *
200 * Unfortunately, current drivers only recognize numeric values 0 (ON) and 3 (SUSPEND).
201 * We'll need to fix the drivers. So yes, putting 3 to all diferent defines is intentional,
202 * and will go away as soon as drivers are fixed. Also note that typedef is neccessary,
203 * we'll probably want to switch to
204 * typedef struct pm_message_t { int event; int flags; } pm_message_t
205 * or something similar soon.
206 */
207
208#define PMSG_FREEZE ((__force pm_message_t) 3)
209#define PMSG_SUSPEND ((__force pm_message_t) 3)
210#define PMSG_ON ((__force pm_message_t) 0)
211
212struct dev_pm_info {
213 pm_message_t power_state;
214#ifdef CONFIG_PM
215 pm_message_t prev_state;
216 void * saved_state;
217 atomic_t pm_users;
218 struct device * pm_parent;
219 struct list_head entry;
220#endif
221};
222
223extern void device_pm_set_parent(struct device * dev, struct device * parent);
224
225extern int device_suspend(pm_message_t state);
226extern int device_power_down(pm_message_t state);
227extern void device_power_up(void);
228extern void device_resume(void);
229
230
231#endif /* __KERNEL__ */
232
233#endif /* _LINUX_PM_H */
diff --git a/include/linux/pmu.h b/include/linux/pmu.h
new file mode 100644
index 000000000000..6d73eada277e
--- /dev/null
+++ b/include/linux/pmu.h
@@ -0,0 +1,240 @@
1/*
2 * Definitions for talking to the PMU. The PMU is a microcontroller
3 * which controls battery charging and system power on PowerBook 3400
4 * and 2400 models as well as the RTC and various other things.
5 *
6 * Copyright (C) 1998 Paul Mackerras.
7 */
8
9#include <linux/config.h>
10
11#define PMU_DRIVER_VERSION 2
12
13/*
14 * PMU commands
15 */
16#define PMU_POWER_CTRL0 0x10 /* control power of some devices */
17#define PMU_POWER_CTRL 0x11 /* control power of some devices */
18#define PMU_ADB_CMD 0x20 /* send ADB packet */
19#define PMU_ADB_POLL_OFF 0x21 /* disable ADB auto-poll */
20#define PMU_WRITE_NVRAM 0x33 /* write non-volatile RAM */
21#define PMU_READ_NVRAM 0x3b /* read non-volatile RAM */
22#define PMU_SET_RTC 0x30 /* set real-time clock */
23#define PMU_READ_RTC 0x38 /* read real-time clock */
24#define PMU_SET_VOLBUTTON 0x40 /* set volume up/down position */
25#define PMU_BACKLIGHT_BRIGHT 0x41 /* set backlight brightness */
26#define PMU_GET_VOLBUTTON 0x48 /* get volume up/down position */
27#define PMU_PCEJECT 0x4c /* eject PC-card from slot */
28#define PMU_BATTERY_STATE 0x6b /* report battery state etc. */
29#define PMU_SMART_BATTERY_STATE 0x6f /* report battery state (new way) */
30#define PMU_SET_INTR_MASK 0x70 /* set PMU interrupt mask */
31#define PMU_INT_ACK 0x78 /* read interrupt bits */
32#define PMU_SHUTDOWN 0x7e /* turn power off */
33#define PMU_CPU_SPEED 0x7d /* control CPU speed on some models */
34#define PMU_SLEEP 0x7f /* put CPU to sleep */
35#define PMU_POWER_EVENTS 0x8f /* Send power-event commands to PMU */
36#define PMU_I2C_CMD 0x9a /* I2C operations */
37#define PMU_RESET 0xd0 /* reset CPU */
38#define PMU_GET_BRIGHTBUTTON 0xd9 /* report brightness up/down pos */
39#define PMU_GET_COVER 0xdc /* report cover open/closed */
40#define PMU_SYSTEM_READY 0xdf /* tell PMU we are awake */
41#define PMU_GET_VERSION 0xea /* read the PMU version */
42
43/* Bits to use with the PMU_POWER_CTRL0 command */
44#define PMU_POW0_ON 0x80 /* OR this to power ON the device */
45#define PMU_POW0_OFF 0x00 /* leave bit 7 to 0 to power it OFF */
46#define PMU_POW0_HARD_DRIVE 0x04 /* Hard drive power (on wallstreet/lombard ?) */
47
48/* Bits to use with the PMU_POWER_CTRL command */
49#define PMU_POW_ON 0x80 /* OR this to power ON the device */
50#define PMU_POW_OFF 0x00 /* leave bit 7 to 0 to power it OFF */
51#define PMU_POW_BACKLIGHT 0x01 /* backlight power */
52#define PMU_POW_CHARGER 0x02 /* battery charger power */
53#define PMU_POW_IRLED 0x04 /* IR led power (on wallstreet) */
54#define PMU_POW_MEDIABAY 0x08 /* media bay power (wallstreet/lombard ?) */
55
56/* Bits in PMU interrupt and interrupt mask bytes */
57#define PMU_INT_PCEJECT 0x04 /* PC-card eject buttons */
58#define PMU_INT_SNDBRT 0x08 /* sound/brightness up/down buttons */
59#define PMU_INT_ADB 0x10 /* ADB autopoll or reply data */
60#define PMU_INT_BATTERY 0x20 /* Battery state change */
61#define PMU_INT_ENVIRONMENT 0x40 /* Environment interrupts */
62#define PMU_INT_TICK 0x80 /* 1-second tick interrupt */
63
64/* Other bits in PMU interrupt valid when PMU_INT_ADB is set */
65#define PMU_INT_ADB_AUTO 0x04 /* ADB autopoll, when PMU_INT_ADB */
66#define PMU_INT_WAITING_CHARGER 0x01 /* ??? */
67#define PMU_INT_AUTO_SRQ_POLL 0x02 /* ??? */
68
69/* Bits in the environement message (either obtained via PMU_GET_COVER,
70 * or via PMU_INT_ENVIRONMENT on core99 */
71#define PMU_ENV_LID_CLOSED 0x01 /* The lid is closed */
72
73/* I2C related definitions */
74#define PMU_I2C_MODE_SIMPLE 0
75#define PMU_I2C_MODE_STDSUB 1
76#define PMU_I2C_MODE_COMBINED 2
77
78#define PMU_I2C_BUS_STATUS 0
79#define PMU_I2C_BUS_SYSCLK 1
80#define PMU_I2C_BUS_POWER 2
81
82#define PMU_I2C_STATUS_OK 0
83#define PMU_I2C_STATUS_DATAREAD 1
84#define PMU_I2C_STATUS_BUSY 0xfe
85
86
87/* Kind of PMU (model) */
88enum {
89 PMU_UNKNOWN,
90 PMU_OHARE_BASED, /* 2400, 3400, 3500 (old G3 powerbook) */
91 PMU_HEATHROW_BASED, /* PowerBook G3 series */
92 PMU_PADDINGTON_BASED, /* 1999 PowerBook G3 */
93 PMU_KEYLARGO_BASED, /* Core99 motherboard (PMU99) */
94 PMU_68K_V1, /* 68K PMU, version 1 */
95 PMU_68K_V2, /* 68K PMU, version 2 */
96};
97
98/* PMU PMU_POWER_EVENTS commands */
99enum {
100 PMU_PWR_GET_POWERUP_EVENTS = 0x00,
101 PMU_PWR_SET_POWERUP_EVENTS = 0x01,
102 PMU_PWR_CLR_POWERUP_EVENTS = 0x02,
103 PMU_PWR_GET_WAKEUP_EVENTS = 0x03,
104 PMU_PWR_SET_WAKEUP_EVENTS = 0x04,
105 PMU_PWR_CLR_WAKEUP_EVENTS = 0x05,
106};
107
108/* Power events wakeup bits */
109enum {
110 PMU_PWR_WAKEUP_KEY = 0x01, /* Wake on key press */
111 PMU_PWR_WAKEUP_AC_INSERT = 0x02, /* Wake on AC adapter plug */
112 PMU_PWR_WAKEUP_AC_CHANGE = 0x04,
113 PMU_PWR_WAKEUP_LID_OPEN = 0x08,
114 PMU_PWR_WAKEUP_RING = 0x10,
115};
116
117/*
118 * Ioctl commands for the /dev/pmu device
119 */
120#include <linux/ioctl.h>
121
122/* no param */
123#define PMU_IOC_SLEEP _IO('B', 0)
124/* out param: u32* backlight value: 0 to 15 */
125#define PMU_IOC_GET_BACKLIGHT _IOR('B', 1, size_t)
126/* in param: u32 backlight value: 0 to 15 */
127#define PMU_IOC_SET_BACKLIGHT _IOW('B', 2, size_t)
128/* out param: u32* PMU model */
129#define PMU_IOC_GET_MODEL _IOR('B', 3, size_t)
130/* out param: u32* has_adb: 0 or 1 */
131#define PMU_IOC_HAS_ADB _IOR('B', 4, size_t)
132/* out param: u32* can_sleep: 0 or 1 */
133#define PMU_IOC_CAN_SLEEP _IOR('B', 5, size_t)
134/* no param, but historically was _IOR('B', 6, 0), meaning 4 bytes */
135#define PMU_IOC_GRAB_BACKLIGHT _IOR('B', 6, size_t)
136
137#ifdef __KERNEL__
138
139extern int find_via_pmu(void);
140
141extern int pmu_request(struct adb_request *req,
142 void (*done)(struct adb_request *), int nbytes, ...);
143
144extern void pmu_poll(void);
145extern void pmu_poll_adb(void); /* For use by xmon */
146extern void pmu_wait_complete(struct adb_request *req);
147
148/* For use before switching interrupts off for a long time;
149 * warning: not stackable
150 */
151extern void pmu_suspend(void);
152extern void pmu_resume(void);
153
154extern void pmu_enable_irled(int on);
155
156extern void pmu_restart(void);
157extern void pmu_shutdown(void);
158extern void pmu_unlock(void);
159
160extern int pmu_present(void);
161extern int pmu_get_model(void);
162
163extern int pmu_i2c_combined_read(int bus, int addr, int subaddr, u8* data, int len);
164extern int pmu_i2c_stdsub_write(int bus, int addr, int subaddr, u8* data, int len);
165extern int pmu_i2c_simple_read(int bus, int addr, u8* data, int len);
166extern int pmu_i2c_simple_write(int bus, int addr, u8* data, int len);
167
168
169#ifdef CONFIG_PMAC_PBOOK
170/*
171 * Stuff for putting the powerbook to sleep and waking it again.
172 *
173 */
174#include <linux/list.h>
175
176struct pmu_sleep_notifier
177{
178 int (*notifier_call)(struct pmu_sleep_notifier *self, int when);
179 int priority;
180 struct list_head list;
181};
182
183/* Code values for calling sleep/wakeup handlers
184 *
185 * Note: If a sleep request got cancelled, all drivers will get
186 * the PBOOK_SLEEP_REJECT, even those who didn't get the PBOOK_SLEEP_REQUEST.
187 */
188#define PBOOK_SLEEP_REQUEST 1
189#define PBOOK_SLEEP_NOW 2
190#define PBOOK_SLEEP_REJECT 3
191#define PBOOK_WAKE 4
192
193/* Result codes returned by the notifiers */
194#define PBOOK_SLEEP_OK 0
195#define PBOOK_SLEEP_REFUSE -1
196
197/* priority levels in notifiers */
198#define SLEEP_LEVEL_VIDEO 100 /* Video driver (first wake) */
199#define SLEEP_LEVEL_MEDIABAY 90 /* Media bay driver */
200#define SLEEP_LEVEL_BLOCK 80 /* IDE, SCSI */
201#define SLEEP_LEVEL_NET 70 /* bmac, gmac */
202#define SLEEP_LEVEL_MISC 60 /* Anything else */
203#define SLEEP_LEVEL_USERLAND 55 /* Reserved for apm_emu */
204#define SLEEP_LEVEL_ADB 50 /* ADB (async) */
205#define SLEEP_LEVEL_SOUND 40 /* Sound driver (blocking) */
206
207/* special register notifier functions */
208int pmu_register_sleep_notifier(struct pmu_sleep_notifier* notifier);
209int pmu_unregister_sleep_notifier(struct pmu_sleep_notifier* notifier);
210
211#define PMU_MAX_BATTERIES 2
212
213/* values for pmu_power_flags */
214#define PMU_PWR_AC_PRESENT 0x00000001
215
216/* values for pmu_battery_info.flags */
217#define PMU_BATT_PRESENT 0x00000001
218#define PMU_BATT_CHARGING 0x00000002
219#define PMU_BATT_TYPE_MASK 0x000000f0
220#define PMU_BATT_TYPE_SMART 0x00000010 /* Smart battery */
221#define PMU_BATT_TYPE_HOOPER 0x00000020 /* 3400/3500 */
222#define PMU_BATT_TYPE_COMET 0x00000030 /* 2400 */
223
224struct pmu_battery_info
225{
226 unsigned int flags;
227 unsigned int charge; /* current charge */
228 unsigned int max_charge; /* maximum charge */
229 signed int amperage; /* current, positive if charging */
230 unsigned int voltage; /* voltage */
231 unsigned int time_remaining; /* remaining time */
232};
233
234extern int pmu_battery_count;
235extern struct pmu_battery_info pmu_batteries[PMU_MAX_BATTERIES];
236extern unsigned int pmu_power_flags;
237
238#endif /* CONFIG_PMAC_PBOOK */
239
240#endif /* __KERNEL__ */
diff --git a/include/linux/pnp.h b/include/linux/pnp.h
new file mode 100644
index 000000000000..5ec2bd0c2848
--- /dev/null
+++ b/include/linux/pnp.h
@@ -0,0 +1,454 @@
1/*
2 * Linux Plug and Play Support
3 * Copyright by Adam Belay <ambx1@neo.rr.com>
4 *
5 */
6
7#ifndef _LINUX_PNP_H
8#define _LINUX_PNP_H
9
10#ifdef __KERNEL__
11
12#include <linux/device.h>
13#include <linux/list.h>
14#include <linux/errno.h>
15#include <linux/mod_devicetable.h>
16
17#define PNP_MAX_PORT 8
18#define PNP_MAX_MEM 4
19#define PNP_MAX_IRQ 2
20#define PNP_MAX_DMA 2
21#define PNP_NAME_LEN 50
22
23struct pnp_protocol;
24struct pnp_dev;
25
26
27/*
28 * Resource Management
29 */
30
31/* Use these instead of directly reading pnp_dev to get resource information */
32#define pnp_port_start(dev,bar) ((dev)->res.port_resource[(bar)].start)
33#define pnp_port_end(dev,bar) ((dev)->res.port_resource[(bar)].end)
34#define pnp_port_flags(dev,bar) ((dev)->res.port_resource[(bar)].flags)
35#define pnp_port_valid(dev,bar) \
36 ((pnp_port_flags((dev),(bar)) & (IORESOURCE_IO | IORESOURCE_UNSET)) \
37 == IORESOURCE_IO)
38#define pnp_port_len(dev,bar) \
39 ((pnp_port_start((dev),(bar)) == 0 && \
40 pnp_port_end((dev),(bar)) == \
41 pnp_port_start((dev),(bar))) ? 0 : \
42 \
43 (pnp_port_end((dev),(bar)) - \
44 pnp_port_start((dev),(bar)) + 1))
45
46#define pnp_mem_start(dev,bar) ((dev)->res.mem_resource[(bar)].start)
47#define pnp_mem_end(dev,bar) ((dev)->res.mem_resource[(bar)].end)
48#define pnp_mem_flags(dev,bar) ((dev)->res.mem_resource[(bar)].flags)
49#define pnp_mem_valid(dev,bar) \
50 ((pnp_mem_flags((dev),(bar)) & (IORESOURCE_MEM | IORESOURCE_UNSET)) \
51 == IORESOURCE_MEM)
52#define pnp_mem_len(dev,bar) \
53 ((pnp_mem_start((dev),(bar)) == 0 && \
54 pnp_mem_end((dev),(bar)) == \
55 pnp_mem_start((dev),(bar))) ? 0 : \
56 \
57 (pnp_mem_end((dev),(bar)) - \
58 pnp_mem_start((dev),(bar)) + 1))
59
60#define pnp_irq(dev,bar) ((dev)->res.irq_resource[(bar)].start)
61#define pnp_irq_flags(dev,bar) ((dev)->res.irq_resource[(bar)].flags)
62#define pnp_irq_valid(dev,bar) \
63 ((pnp_irq_flags((dev),(bar)) & (IORESOURCE_IRQ | IORESOURCE_UNSET)) \
64 == IORESOURCE_IRQ)
65
66#define pnp_dma(dev,bar) ((dev)->res.dma_resource[(bar)].start)
67#define pnp_dma_flags(dev,bar) ((dev)->res.dma_resource[(bar)].flags)
68#define pnp_dma_valid(dev,bar) \
69 ((pnp_dma_flags((dev),(bar)) & (IORESOURCE_DMA | IORESOURCE_UNSET)) \
70 == IORESOURCE_DMA)
71
72#define PNP_PORT_FLAG_16BITADDR (1<<0)
73#define PNP_PORT_FLAG_FIXED (1<<1)
74
75struct pnp_port {
76 unsigned short min; /* min base number */
77 unsigned short max; /* max base number */
78 unsigned char align; /* align boundary */
79 unsigned char size; /* size of range */
80 unsigned char flags; /* port flags */
81 unsigned char pad; /* pad */
82 struct pnp_port *next; /* next port */
83};
84
85#define PNP_IRQ_NR 256
86struct pnp_irq {
87 DECLARE_BITMAP(map, PNP_IRQ_NR); /* bitmaks for IRQ lines */
88 unsigned char flags; /* IRQ flags */
89 unsigned char pad; /* pad */
90 struct pnp_irq *next; /* next IRQ */
91};
92
93struct pnp_dma {
94 unsigned char map; /* bitmask for DMA channels */
95 unsigned char flags; /* DMA flags */
96 struct pnp_dma *next; /* next port */
97};
98
99struct pnp_mem {
100 unsigned int min; /* min base number */
101 unsigned int max; /* max base number */
102 unsigned int align; /* align boundary */
103 unsigned int size; /* size of range */
104 unsigned char flags; /* memory flags */
105 unsigned char pad; /* pad */
106 struct pnp_mem *next; /* next memory resource */
107};
108
109#define PNP_RES_PRIORITY_PREFERRED 0
110#define PNP_RES_PRIORITY_ACCEPTABLE 1
111#define PNP_RES_PRIORITY_FUNCTIONAL 2
112#define PNP_RES_PRIORITY_INVALID 65535
113
114struct pnp_option {
115 unsigned short priority; /* priority */
116 struct pnp_port *port; /* first port */
117 struct pnp_irq *irq; /* first IRQ */
118 struct pnp_dma *dma; /* first DMA */
119 struct pnp_mem *mem; /* first memory resource */
120 struct pnp_option *next; /* used to chain dependent resources */
121};
122
123struct pnp_resource_table {
124 struct resource port_resource[PNP_MAX_PORT];
125 struct resource mem_resource[PNP_MAX_MEM];
126 struct resource dma_resource[PNP_MAX_DMA];
127 struct resource irq_resource[PNP_MAX_IRQ];
128};
129
130
131/*
132 * Device Managemnt
133 */
134
135struct pnp_card {
136 struct device dev; /* Driver Model device interface */
137 unsigned char number; /* used as an index, must be unique */
138 struct list_head global_list; /* node in global list of cards */
139 struct list_head protocol_list; /* node in protocol's list of cards */
140 struct list_head devices; /* devices attached to the card */
141
142 struct pnp_protocol * protocol;
143 struct pnp_id * id; /* contains supported EISA IDs*/
144
145 char name[PNP_NAME_LEN]; /* contains a human-readable name */
146 unsigned char pnpver; /* Plug & Play version */
147 unsigned char productver; /* product version */
148 unsigned int serial; /* serial number */
149 unsigned char checksum; /* if zero - checksum passed */
150 struct proc_dir_entry *procdir; /* directory entry in /proc/bus/isapnp */
151};
152
153#define global_to_pnp_card(n) list_entry(n, struct pnp_card, global_list)
154#define protocol_to_pnp_card(n) list_entry(n, struct pnp_card, protocol_list)
155#define to_pnp_card(n) container_of(n, struct pnp_card, dev)
156#define pnp_for_each_card(card) \
157 for((card) = global_to_pnp_card(pnp_cards.next); \
158 (card) != global_to_pnp_card(&pnp_cards); \
159 (card) = global_to_pnp_card((card)->global_list.next))
160
161struct pnp_card_link {
162 struct pnp_card * card;
163 struct pnp_card_driver * driver;
164 void * driver_data;
165};
166
167static inline void *pnp_get_card_drvdata (struct pnp_card_link *pcard)
168{
169 return pcard->driver_data;
170}
171
172static inline void pnp_set_card_drvdata (struct pnp_card_link *pcard, void *data)
173{
174 pcard->driver_data = data;
175}
176
177struct pnp_dev {
178 struct device dev; /* Driver Model device interface */
179 unsigned char number; /* used as an index, must be unique */
180 int status;
181
182 struct list_head global_list; /* node in global list of devices */
183 struct list_head protocol_list; /* node in list of device's protocol */
184 struct list_head card_list; /* node in card's list of devices */
185 struct list_head rdev_list; /* node in cards list of requested devices */
186
187 struct pnp_protocol * protocol;
188 struct pnp_card * card; /* card the device is attached to, none if NULL */
189 struct pnp_driver * driver;
190 struct pnp_card_link * card_link;
191
192 struct pnp_id * id; /* supported EISA IDs*/
193
194 int active;
195 int capabilities;
196 struct pnp_option * independent;
197 struct pnp_option * dependent;
198 struct pnp_resource_table res;
199
200 char name[PNP_NAME_LEN]; /* contains a human-readable name */
201 unsigned short regs; /* ISAPnP: supported registers */
202 int flags; /* used by protocols */
203 struct proc_dir_entry *procent; /* device entry in /proc/bus/isapnp */
204 void *data;
205};
206
207#define global_to_pnp_dev(n) list_entry(n, struct pnp_dev, global_list)
208#define card_to_pnp_dev(n) list_entry(n, struct pnp_dev, card_list)
209#define protocol_to_pnp_dev(n) list_entry(n, struct pnp_dev, protocol_list)
210#define to_pnp_dev(n) container_of(n, struct pnp_dev, dev)
211#define pnp_for_each_dev(dev) \
212 for((dev) = global_to_pnp_dev(pnp_global.next); \
213 (dev) != global_to_pnp_dev(&pnp_global); \
214 (dev) = global_to_pnp_dev((dev)->global_list.next))
215#define card_for_each_dev(card,dev) \
216 for((dev) = card_to_pnp_dev((card)->devices.next); \
217 (dev) != card_to_pnp_dev(&(card)->devices); \
218 (dev) = card_to_pnp_dev((dev)->card_list.next))
219#define pnp_dev_name(dev) (dev)->name
220
221static inline void *pnp_get_drvdata (struct pnp_dev *pdev)
222{
223 return dev_get_drvdata(&pdev->dev);
224}
225
226static inline void pnp_set_drvdata (struct pnp_dev *pdev, void *data)
227{
228 dev_set_drvdata(&pdev->dev, data);
229}
230
231struct pnp_fixup {
232 char id[7];
233 void (*quirk_function)(struct pnp_dev *dev); /* fixup function */
234};
235
236/* config parameters */
237#define PNP_CONFIG_NORMAL 0x0001
238#define PNP_CONFIG_FORCE 0x0002 /* disables validity checking */
239
240/* capabilities */
241#define PNP_READ 0x0001
242#define PNP_WRITE 0x0002
243#define PNP_DISABLE 0x0004
244#define PNP_CONFIGURABLE 0x0008
245#define PNP_REMOVABLE 0x0010
246
247#define pnp_can_read(dev) (((dev)->protocol) && ((dev)->protocol->get) && \
248 ((dev)->capabilities & PNP_READ))
249#define pnp_can_write(dev) (((dev)->protocol) && ((dev)->protocol->set) && \
250 ((dev)->capabilities & PNP_WRITE))
251#define pnp_can_disable(dev) (((dev)->protocol) && ((dev)->protocol->disable) && \
252 ((dev)->capabilities & PNP_DISABLE))
253#define pnp_can_configure(dev) ((!(dev)->active) && \
254 ((dev)->capabilities & PNP_CONFIGURABLE))
255
256#ifdef CONFIG_ISAPNP
257extern struct pnp_protocol isapnp_protocol;
258#define pnp_device_is_isapnp(dev) ((dev)->protocol == (&isapnp_protocol))
259#else
260#define pnp_device_is_isapnp(dev) 0
261#endif
262
263#ifdef CONFIG_PNPBIOS
264extern struct pnp_protocol pnpbios_protocol;
265#define pnp_device_is_pnpbios(dev) ((dev)->protocol == (&pnpbios_protocol))
266#else
267#define pnp_device_is_pnpbios(dev) 0
268#endif
269
270
271/* status */
272#define PNP_READY 0x0000
273#define PNP_ATTACHED 0x0001
274#define PNP_BUSY 0x0002
275#define PNP_FAULTY 0x0004
276
277/* isapnp specific macros */
278
279#define isapnp_card_number(dev) ((dev)->card ? (dev)->card->number : -1)
280#define isapnp_csn_number(dev) ((dev)->number)
281
282/*
283 * Driver Management
284 */
285
286struct pnp_id {
287 char id[PNP_ID_LEN];
288 struct pnp_id * next;
289};
290
291struct pnp_driver {
292 char * name;
293 const struct pnp_device_id *id_table;
294 unsigned int flags;
295 int (*probe) (struct pnp_dev *dev, const struct pnp_device_id *dev_id);
296 void (*remove) (struct pnp_dev *dev);
297 struct device_driver driver;
298};
299
300#define to_pnp_driver(drv) container_of(drv, struct pnp_driver, driver)
301
302struct pnp_card_driver {
303 struct list_head global_list;
304 char * name;
305 const struct pnp_card_device_id *id_table;
306 unsigned int flags;
307 int (*probe) (struct pnp_card_link *card, const struct pnp_card_device_id *card_id);
308 void (*remove) (struct pnp_card_link *card);
309 struct pnp_driver link;
310};
311
312#define to_pnp_card_driver(drv) container_of(drv, struct pnp_card_driver, link)
313
314/* pnp driver flags */
315#define PNP_DRIVER_RES_DO_NOT_CHANGE 0x0001 /* do not change the state of the device */
316#define PNP_DRIVER_RES_DISABLE 0x0003 /* ensure the device is disabled */
317
318
319/*
320 * Protocol Management
321 */
322
323struct pnp_protocol {
324 struct list_head protocol_list;
325 char * name;
326
327 /* resource control functions */
328 int (*get)(struct pnp_dev *dev, struct pnp_resource_table *res);
329 int (*set)(struct pnp_dev *dev, struct pnp_resource_table *res);
330 int (*disable)(struct pnp_dev *dev);
331
332 /* used by pnp layer only (look but don't touch) */
333 unsigned char number; /* protocol number*/
334 struct device dev; /* link to driver model */
335 struct list_head cards;
336 struct list_head devices;
337};
338
339#define to_pnp_protocol(n) list_entry(n, struct pnp_protocol, protocol_list)
340#define protocol_for_each_card(protocol,card) \
341 for((card) = protocol_to_pnp_card((protocol)->cards.next); \
342 (card) != protocol_to_pnp_card(&(protocol)->cards); \
343 (card) = protocol_to_pnp_card((card)->protocol_list.next))
344#define protocol_for_each_dev(protocol,dev) \
345 for((dev) = protocol_to_pnp_dev((protocol)->devices.next); \
346 (dev) != protocol_to_pnp_dev(&(protocol)->devices); \
347 (dev) = protocol_to_pnp_dev((dev)->protocol_list.next))
348
349
350#if defined(CONFIG_PNP)
351
352/* device management */
353int pnp_register_protocol(struct pnp_protocol *protocol);
354void pnp_unregister_protocol(struct pnp_protocol *protocol);
355int pnp_add_device(struct pnp_dev *dev);
356void pnp_remove_device(struct pnp_dev *dev);
357int pnp_device_attach(struct pnp_dev *pnp_dev);
358void pnp_device_detach(struct pnp_dev *pnp_dev);
359extern struct list_head pnp_global;
360
361/* multidevice card support */
362int pnp_add_card(struct pnp_card *card);
363void pnp_remove_card(struct pnp_card *card);
364int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev);
365void pnp_remove_card_device(struct pnp_dev *dev);
366int pnp_add_card_id(struct pnp_id *id, struct pnp_card *card);
367struct pnp_dev * pnp_request_card_device(struct pnp_card_link *clink, const char * id, struct pnp_dev * from);
368void pnp_release_card_device(struct pnp_dev * dev);
369int pnp_register_card_driver(struct pnp_card_driver * drv);
370void pnp_unregister_card_driver(struct pnp_card_driver * drv);
371extern struct list_head pnp_cards;
372
373/* resource management */
374struct pnp_option * pnp_register_independent_option(struct pnp_dev *dev);
375struct pnp_option * pnp_register_dependent_option(struct pnp_dev *dev, int priority);
376int pnp_register_irq_resource(struct pnp_option *option, struct pnp_irq *data);
377int pnp_register_dma_resource(struct pnp_option *option, struct pnp_dma *data);
378int pnp_register_port_resource(struct pnp_option *option, struct pnp_port *data);
379int pnp_register_mem_resource(struct pnp_option *option, struct pnp_mem *data);
380void pnp_init_resource_table(struct pnp_resource_table *table);
381int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res, int mode);
382int pnp_auto_config_dev(struct pnp_dev *dev);
383int pnp_validate_config(struct pnp_dev *dev);
384int pnp_activate_dev(struct pnp_dev *dev);
385int pnp_disable_dev(struct pnp_dev *dev);
386void pnp_resource_change(struct resource *resource, unsigned long start, unsigned long size);
387
388/* protocol helpers */
389int pnp_is_active(struct pnp_dev * dev);
390int compare_pnp_id(struct pnp_id * pos, const char * id);
391int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev);
392int pnp_register_driver(struct pnp_driver *drv);
393void pnp_unregister_driver(struct pnp_driver *drv);
394
395#else
396
397/* device management */
398static inline int pnp_register_protocol(struct pnp_protocol *protocol) { return -ENODEV; }
399static inline void pnp_unregister_protocol(struct pnp_protocol *protocol) { }
400static inline int pnp_init_device(struct pnp_dev *dev) { return -ENODEV; }
401static inline int pnp_add_device(struct pnp_dev *dev) { return -ENODEV; }
402static inline void pnp_remove_device(struct pnp_dev *dev) { }
403static inline int pnp_device_attach(struct pnp_dev *pnp_dev) { return -ENODEV; }
404static inline void pnp_device_detach(struct pnp_dev *pnp_dev) { ; }
405
406/* multidevice card support */
407static inline int pnp_add_card(struct pnp_card *card) { return -ENODEV; }
408static inline void pnp_remove_card(struct pnp_card *card) { ; }
409static inline int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev) { return -ENODEV; }
410static inline void pnp_remove_card_device(struct pnp_dev *dev) { ; }
411static inline int pnp_add_card_id(struct pnp_id *id, struct pnp_card *card) { return -ENODEV; }
412static inline struct pnp_dev * pnp_request_card_device(struct pnp_card_link *clink, const char * id, struct pnp_dev * from) { return NULL; }
413static inline void pnp_release_card_device(struct pnp_dev * dev) { ; }
414static inline int pnp_register_card_driver(struct pnp_card_driver * drv) { return -ENODEV; }
415static inline void pnp_unregister_card_driver(struct pnp_card_driver * drv) { ; }
416
417/* resource management */
418static inline struct pnp_option * pnp_register_independent_option(struct pnp_dev *dev) { return NULL; }
419static inline struct pnp_option * pnp_register_dependent_option(struct pnp_dev *dev, int priority) { return NULL; }
420static inline int pnp_register_irq_resource(struct pnp_option *option, struct pnp_irq *data) { return -ENODEV; }
421static inline int pnp_register_dma_resource(struct pnp_option *option, struct pnp_dma *data) { return -ENODEV; }
422static inline int pnp_register_port_resource(struct pnp_option *option, struct pnp_port *data) { return -ENODEV; }
423static inline int pnp_register_mem_resource(struct pnp_option *option, struct pnp_mem *data) { return -ENODEV; }
424static inline void pnp_init_resource_table(struct pnp_resource_table *table) { }
425static inline int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res, int mode) { return -ENODEV; }
426static inline int pnp_auto_config_dev(struct pnp_dev *dev) { return -ENODEV; }
427static inline int pnp_validate_config(struct pnp_dev *dev) { return -ENODEV; }
428static inline int pnp_activate_dev(struct pnp_dev *dev) { return -ENODEV; }
429static inline int pnp_disable_dev(struct pnp_dev *dev) { return -ENODEV; }
430static inline void pnp_resource_change(struct resource *resource, unsigned long start, unsigned long size) { }
431
432/* protocol helpers */
433static inline int pnp_is_active(struct pnp_dev * dev) { return 0; }
434static inline int compare_pnp_id(struct pnp_id * pos, const char * id) { return -ENODEV; }
435static inline int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev) { return -ENODEV; }
436static inline int pnp_register_driver(struct pnp_driver *drv) { return -ENODEV; }
437static inline void pnp_unregister_driver(struct pnp_driver *drv) { ; }
438
439#endif /* CONFIG_PNP */
440
441
442#define pnp_err(format, arg...) printk(KERN_ERR "pnp: " format "\n" , ## arg)
443#define pnp_info(format, arg...) printk(KERN_INFO "pnp: " format "\n" , ## arg)
444#define pnp_warn(format, arg...) printk(KERN_WARNING "pnp: " format "\n" , ## arg)
445
446#ifdef DEBUG
447#define pnp_dbg(format, arg...) printk(KERN_DEBUG "pnp: " format "\n" , ## arg)
448#else
449#define pnp_dbg(format, arg...) do {} while (0)
450#endif
451
452#endif /* __KERNEL__ */
453
454#endif /* _LINUX_PNP_H */
diff --git a/include/linux/pnpbios.h b/include/linux/pnpbios.h
new file mode 100644
index 000000000000..0a282ac1f6b2
--- /dev/null
+++ b/include/linux/pnpbios.h
@@ -0,0 +1,157 @@
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, struct pnp_bios_node *data);
138extern int pnp_bios_set_dev_node (u8 nodenum, char config, struct pnp_bios_node *data);
139extern int pnp_bios_get_stat_res (char *info);
140extern int pnp_bios_isapnp_config (struct pnp_isa_config_struc *data);
141extern int pnp_bios_escd_info (struct escd_info_struc *data);
142extern int pnp_bios_read_escd (char *data, u32 nvram_base);
143extern int pnp_bios_dock_station_info(struct pnp_docking_station_info *data);
144#define needed 0
145#if needed
146extern int pnp_bios_get_event (u16 *message);
147extern int pnp_bios_send_message (u16 message);
148extern int pnp_bios_set_stat_res (char *info);
149extern int pnp_bios_apm_id_table (char *table, u16 *size);
150extern int pnp_bios_write_escd (char *data, u32 nvram_base);
151#endif
152
153#endif /* CONFIG_PNPBIOS */
154
155#endif /* __KERNEL__ */
156
157#endif /* _LINUX_PNPBIOS_H */
diff --git a/include/linux/poll.h b/include/linux/poll.h
new file mode 100644
index 000000000000..f6da702088f4
--- /dev/null
+++ b/include/linux/poll.h
@@ -0,0 +1,99 @@
1#ifndef _LINUX_POLL_H
2#define _LINUX_POLL_H
3
4#include <asm/poll.h>
5
6#ifdef __KERNEL__
7
8#include <linux/compiler.h>
9#include <linux/wait.h>
10#include <linux/string.h>
11#include <linux/mm.h>
12#include <asm/uaccess.h>
13
14struct poll_table_struct;
15
16/*
17 * structures and helpers for f_op->poll implementations
18 */
19typedef void (*poll_queue_proc)(struct file *, wait_queue_head_t *, struct poll_table_struct *);
20
21typedef struct poll_table_struct {
22 poll_queue_proc qproc;
23} poll_table;
24
25static inline void poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p)
26{
27 if (p && wait_address)
28 p->qproc(filp, wait_address, p);
29}
30
31static inline void init_poll_funcptr(poll_table *pt, poll_queue_proc qproc)
32{
33 pt->qproc = qproc;
34}
35
36/*
37 * Structures and helpers for sys_poll/sys_poll
38 */
39struct poll_wqueues {
40 poll_table pt;
41 struct poll_table_page * table;
42 int error;
43};
44
45extern void poll_initwait(struct poll_wqueues *pwq);
46extern void poll_freewait(struct poll_wqueues *pwq);
47
48/*
49 * Scaleable version of the fd_set.
50 */
51
52typedef struct {
53 unsigned long *in, *out, *ex;
54 unsigned long *res_in, *res_out, *res_ex;
55} fd_set_bits;
56
57/*
58 * How many longwords for "nr" bits?
59 */
60#define FDS_BITPERLONG (8*sizeof(long))
61#define FDS_LONGS(nr) (((nr)+FDS_BITPERLONG-1)/FDS_BITPERLONG)
62#define FDS_BYTES(nr) (FDS_LONGS(nr)*sizeof(long))
63
64/*
65 * We do a VERIFY_WRITE here even though we are only reading this time:
66 * we'll write to it eventually..
67 *
68 * Use "unsigned long" accesses to let user-mode fd_set's be long-aligned.
69 */
70static inline
71int get_fd_set(unsigned long nr, void __user *ufdset, unsigned long *fdset)
72{
73 nr = FDS_BYTES(nr);
74 if (ufdset)
75 return copy_from_user(fdset, ufdset, nr) ? -EFAULT : 0;
76
77 memset(fdset, 0, nr);
78 return 0;
79}
80
81static inline unsigned long __must_check
82set_fd_set(unsigned long nr, void __user *ufdset, unsigned long *fdset)
83{
84 if (ufdset)
85 return __copy_to_user(ufdset, fdset, FDS_BYTES(nr));
86 return 0;
87}
88
89static inline
90void zero_fd_set(unsigned long nr, unsigned long *fdset)
91{
92 memset(fdset, 0, FDS_BYTES(nr));
93}
94
95extern int do_select(int n, fd_set_bits *fds, long *timeout);
96
97#endif /* KERNEL */
98
99#endif /* _LINUX_POLL_H */
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
new file mode 100644
index 000000000000..f942e2bad8e3
--- /dev/null
+++ b/include/linux/posix-timers.h
@@ -0,0 +1,139 @@
1#ifndef _linux_POSIX_TIMERS_H
2#define _linux_POSIX_TIMERS_H
3
4#include <linux/spinlock.h>
5#include <linux/list.h>
6#include <linux/sched.h>
7
8union cpu_time_count {
9 cputime_t cpu;
10 unsigned long long sched;
11};
12
13struct cpu_timer_list {
14 struct list_head entry;
15 union cpu_time_count expires, incr;
16 struct task_struct *task;
17 int firing;
18};
19
20#define CPUCLOCK_PID(clock) ((pid_t) ~((clock) >> 3))
21#define CPUCLOCK_PERTHREAD(clock) \
22 (((clock) & (clockid_t) CPUCLOCK_PERTHREAD_MASK) != 0)
23#define CPUCLOCK_PID_MASK 7
24#define CPUCLOCK_PERTHREAD_MASK 4
25#define CPUCLOCK_WHICH(clock) ((clock) & (clockid_t) CPUCLOCK_CLOCK_MASK)
26#define CPUCLOCK_CLOCK_MASK 3
27#define CPUCLOCK_PROF 0
28#define CPUCLOCK_VIRT 1
29#define CPUCLOCK_SCHED 2
30#define CPUCLOCK_MAX 3
31
32#define MAKE_PROCESS_CPUCLOCK(pid, clock) \
33 ((~(clockid_t) (pid) << 3) | (clockid_t) (clock))
34#define MAKE_THREAD_CPUCLOCK(tid, clock) \
35 MAKE_PROCESS_CPUCLOCK((tid), (clock) | CPUCLOCK_PERTHREAD_MASK)
36
37/* POSIX.1b interval timer structure. */
38struct k_itimer {
39 struct list_head list; /* free/ allocate list */
40 spinlock_t it_lock;
41 clockid_t it_clock; /* which timer type */
42 timer_t it_id; /* timer id */
43 int it_overrun; /* overrun on pending signal */
44 int it_overrun_last; /* overrun on last delivered signal */
45 int it_requeue_pending; /* waiting to requeue this timer */
46#define REQUEUE_PENDING 1
47 int it_sigev_notify; /* notify word of sigevent struct */
48 int it_sigev_signo; /* signo word of sigevent struct */
49 sigval_t it_sigev_value; /* value word of sigevent struct */
50 struct task_struct *it_process; /* process to send signal to */
51 struct sigqueue *sigq; /* signal queue entry. */
52 union {
53 struct {
54 struct timer_list timer;
55 struct list_head abs_timer_entry; /* clock abs_timer_list */
56 struct timespec wall_to_prev; /* wall_to_monotonic used when set */
57 unsigned long incr; /* interval in jiffies */
58 } real;
59 struct cpu_timer_list cpu;
60 struct {
61 unsigned int clock;
62 unsigned int node;
63 unsigned long incr;
64 unsigned long expires;
65 } mmtimer;
66 } it;
67};
68
69struct k_clock_abs {
70 struct list_head list;
71 spinlock_t lock;
72};
73struct k_clock {
74 int res; /* in nano seconds */
75 int (*clock_getres) (clockid_t which_clock, struct timespec *tp);
76 struct k_clock_abs *abs_struct;
77 int (*clock_set) (clockid_t which_clock, struct timespec * tp);
78 int (*clock_get) (clockid_t which_clock, struct timespec * tp);
79 int (*timer_create) (struct k_itimer *timer);
80 int (*nsleep) (clockid_t which_clock, int flags, struct timespec *);
81 int (*timer_set) (struct k_itimer * timr, int flags,
82 struct itimerspec * new_setting,
83 struct itimerspec * old_setting);
84 int (*timer_del) (struct k_itimer * timr);
85#define TIMER_RETRY 1
86 void (*timer_get) (struct k_itimer * timr,
87 struct itimerspec * cur_setting);
88};
89
90void register_posix_clock(clockid_t clock_id, struct k_clock *new_clock);
91
92/* Error handlers for timer_create, nanosleep and settime */
93int do_posix_clock_notimer_create(struct k_itimer *timer);
94int do_posix_clock_nonanosleep(clockid_t, int flags, struct timespec *);
95int do_posix_clock_nosettime(clockid_t, struct timespec *tp);
96
97/* function to call to trigger timer event */
98int posix_timer_event(struct k_itimer *timr, int si_private);
99
100struct now_struct {
101 unsigned long jiffies;
102};
103
104#define posix_get_now(now) (now)->jiffies = jiffies;
105#define posix_time_before(timer, now) \
106 time_before((timer)->expires, (now)->jiffies)
107
108#define posix_bump_timer(timr, now) \
109 do { \
110 long delta, orun; \
111 delta = now.jiffies - (timr)->it.real.timer.expires; \
112 if (delta >= 0) { \
113 orun = 1 + (delta / (timr)->it.real.incr); \
114 (timr)->it.real.timer.expires += \
115 orun * (timr)->it.real.incr; \
116 (timr)->it_overrun += orun; \
117 } \
118 }while (0)
119
120int posix_cpu_clock_getres(clockid_t which_clock, struct timespec *);
121int posix_cpu_clock_get(clockid_t which_clock, struct timespec *);
122int posix_cpu_clock_set(clockid_t which_clock, const struct timespec *tp);
123int posix_cpu_timer_create(struct k_itimer *);
124int posix_cpu_nsleep(clockid_t, int, struct timespec *);
125int posix_cpu_timer_set(struct k_itimer *, int,
126 struct itimerspec *, struct itimerspec *);
127int posix_cpu_timer_del(struct k_itimer *);
128void posix_cpu_timer_get(struct k_itimer *, struct itimerspec *);
129
130void posix_cpu_timer_schedule(struct k_itimer *);
131
132void run_posix_cpu_timers(struct task_struct *);
133void posix_cpu_timers_exit(struct task_struct *);
134void posix_cpu_timers_exit_group(struct task_struct *);
135
136void set_process_cpu_timer(struct task_struct *, unsigned int,
137 cputime_t *, cputime_t *);
138
139#endif
diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h
new file mode 100644
index 000000000000..4caedddaa033
--- /dev/null
+++ b/include/linux/posix_acl.h
@@ -0,0 +1,86 @@
1/*
2 File: linux/posix_acl.h
3
4 (C) 2002 Andreas Gruenbacher, <a.gruenbacher@computer.org>
5*/
6
7
8#ifndef __LINUX_POSIX_ACL_H
9#define __LINUX_POSIX_ACL_H
10
11#include <linux/slab.h>
12
13#define ACL_UNDEFINED_ID (-1)
14
15/* a_type field in acl_user_posix_entry_t */
16#define ACL_TYPE_ACCESS (0x8000)
17#define ACL_TYPE_DEFAULT (0x4000)
18
19/* e_tag entry in struct posix_acl_entry */
20#define ACL_USER_OBJ (0x01)
21#define ACL_USER (0x02)
22#define ACL_GROUP_OBJ (0x04)
23#define ACL_GROUP (0x08)
24#define ACL_MASK (0x10)
25#define ACL_OTHER (0x20)
26
27/* permissions in the e_perm field */
28#define ACL_READ (0x04)
29#define ACL_WRITE (0x02)
30#define ACL_EXECUTE (0x01)
31//#define ACL_ADD (0x08)
32//#define ACL_DELETE (0x10)
33
34struct posix_acl_entry {
35 short e_tag;
36 unsigned short e_perm;
37 unsigned int e_id;
38};
39
40struct posix_acl {
41 atomic_t a_refcount;
42 unsigned int a_count;
43 struct posix_acl_entry a_entries[0];
44};
45
46#define FOREACH_ACL_ENTRY(pa, acl, pe) \
47 for(pa=(acl)->a_entries, pe=pa+(acl)->a_count; pa<pe; pa++)
48
49
50/*
51 * Duplicate an ACL handle.
52 */
53static inline struct posix_acl *
54posix_acl_dup(struct posix_acl *acl)
55{
56 if (acl)
57 atomic_inc(&acl->a_refcount);
58 return acl;
59}
60
61/*
62 * Free an ACL handle.
63 */
64static inline void
65posix_acl_release(struct posix_acl *acl)
66{
67 if (acl && atomic_dec_and_test(&acl->a_refcount))
68 kfree(acl);
69}
70
71
72/* posix_acl.c */
73
74extern struct posix_acl *posix_acl_alloc(int, unsigned int __nocast);
75extern struct posix_acl *posix_acl_clone(const struct posix_acl *, unsigned int __nocast);
76extern int posix_acl_valid(const struct posix_acl *);
77extern int posix_acl_permission(struct inode *, const struct posix_acl *, int);
78extern struct posix_acl *posix_acl_from_mode(mode_t, unsigned int __nocast);
79extern int posix_acl_equiv_mode(const struct posix_acl *, mode_t *);
80extern int posix_acl_create_masq(struct posix_acl *, mode_t *);
81extern int posix_acl_chmod_masq(struct posix_acl *, mode_t);
82
83extern struct posix_acl *get_posix_acl(struct inode *, int);
84extern int set_posix_acl(struct inode *, int, struct posix_acl *);
85
86#endif /* __LINUX_POSIX_ACL_H */
diff --git a/include/linux/posix_acl_xattr.h b/include/linux/posix_acl_xattr.h
new file mode 100644
index 000000000000..5efd0a6dad94
--- /dev/null
+++ b/include/linux/posix_acl_xattr.h
@@ -0,0 +1,55 @@
1/*
2 File: linux/posix_acl_xattr.h
3
4 Extended attribute system call representation of Access Control Lists.
5
6 Copyright (C) 2000 by Andreas Gruenbacher <a.gruenbacher@computer.org>
7 Copyright (C) 2002 SGI - Silicon Graphics, Inc <linux-xfs@oss.sgi.com>
8 */
9#ifndef _POSIX_ACL_XATTR_H
10#define _POSIX_ACL_XATTR_H
11
12#include <linux/posix_acl.h>
13
14/* Extended attribute names */
15#define POSIX_ACL_XATTR_ACCESS "system.posix_acl_access"
16#define POSIX_ACL_XATTR_DEFAULT "system.posix_acl_default"
17
18/* Supported ACL a_version fields */
19#define POSIX_ACL_XATTR_VERSION 0x0002
20
21
22/* An undefined entry e_id value */
23#define ACL_UNDEFINED_ID (-1)
24
25typedef struct {
26 __u16 e_tag;
27 __u16 e_perm;
28 __u32 e_id;
29} posix_acl_xattr_entry;
30
31typedef struct {
32 __u32 a_version;
33 posix_acl_xattr_entry a_entries[0];
34} posix_acl_xattr_header;
35
36
37static inline size_t
38posix_acl_xattr_size(int count)
39{
40 return (sizeof(posix_acl_xattr_header) +
41 (count * sizeof(posix_acl_xattr_entry)));
42}
43
44static inline int
45posix_acl_xattr_count(size_t size)
46{
47 if (size < sizeof(posix_acl_xattr_header))
48 return -1;
49 size -= sizeof(posix_acl_xattr_header);
50 if (size % sizeof(posix_acl_xattr_entry))
51 return -1;
52 return size / sizeof(posix_acl_xattr_entry);
53}
54
55#endif /* _POSIX_ACL_XATTR_H */
diff --git a/include/linux/posix_types.h b/include/linux/posix_types.h
new file mode 100644
index 000000000000..f04c98cf44f3
--- /dev/null
+++ b/include/linux/posix_types.h
@@ -0,0 +1,49 @@
1#ifndef _LINUX_POSIX_TYPES_H
2#define _LINUX_POSIX_TYPES_H
3
4#include <linux/stddef.h>
5
6/*
7 * This allows for 1024 file descriptors: if NR_OPEN is ever grown
8 * beyond that you'll have to change this too. But 1024 fd's seem to be
9 * enough even for such "real" unices like OSF/1, so hopefully this is
10 * one limit that doesn't have to be changed [again].
11 *
12 * Note that POSIX wants the FD_CLEAR(fd,fdsetp) defines to be in
13 * <sys/time.h> (and thus <linux/time.h>) - but this is a more logical
14 * place for them. Solved by having dummy defines in <sys/time.h>.
15 */
16
17/*
18 * Those macros may have been defined in <gnu/types.h>. But we always
19 * use the ones here.
20 */
21#undef __NFDBITS
22#define __NFDBITS (8 * sizeof(unsigned long))
23
24#undef __FD_SETSIZE
25#define __FD_SETSIZE 1024
26
27#undef __FDSET_LONGS
28#define __FDSET_LONGS (__FD_SETSIZE/__NFDBITS)
29
30#undef __FDELT
31#define __FDELT(d) ((d) / __NFDBITS)
32
33#undef __FDMASK
34#define __FDMASK(d) (1UL << ((d) % __NFDBITS))
35
36typedef struct {
37 unsigned long fds_bits [__FDSET_LONGS];
38} __kernel_fd_set;
39
40/* Type of a signal handler. */
41typedef void (*__kernel_sighandler_t)(int);
42
43/* Type of a SYSV IPC key. */
44typedef int __kernel_key_t;
45typedef int __kernel_mqd_t;
46
47#include <asm/posix_types.h>
48
49#endif /* _LINUX_POSIX_TYPES_H */
diff --git a/include/linux/ppdev.h b/include/linux/ppdev.h
new file mode 100644
index 000000000000..141c96586824
--- /dev/null
+++ b/include/linux/ppdev.h
@@ -0,0 +1,101 @@
1/*
2 * linux/drivers/char/ppdev.h
3 *
4 * User-space parallel port device driver (header file).
5 *
6 * Copyright (C) 1998-9 Tim Waugh <tim@cyberelk.demon.co.uk>
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 * Added PPGETTIME/PPSETTIME, Fred Barnes, 1999
14 * Added PPGETMODES/PPGETMODE/PPGETPHASE, Fred Barnes <frmb2@ukc.ac.uk>, 03/01/2001
15 */
16
17#define PP_MAJOR 99
18
19#define PP_IOCTL 'p'
20
21/* Set mode for read/write (e.g. IEEE1284_MODE_EPP) */
22#define PPSETMODE _IOW(PP_IOCTL, 0x80, int)
23
24/* Read status */
25#define PPRSTATUS _IOR(PP_IOCTL, 0x81, unsigned char)
26#define PPWSTATUS OBSOLETE__IOW(PP_IOCTL, 0x82, unsigned char)
27
28/* Read/write control */
29#define PPRCONTROL _IOR(PP_IOCTL, 0x83, unsigned char)
30#define PPWCONTROL _IOW(PP_IOCTL, 0x84, unsigned char)
31
32struct ppdev_frob_struct {
33 unsigned char mask;
34 unsigned char val;
35};
36#define PPFCONTROL _IOW(PP_IOCTL, 0x8e, struct ppdev_frob_struct)
37
38/* Read/write data */
39#define PPRDATA _IOR(PP_IOCTL, 0x85, unsigned char)
40#define PPWDATA _IOW(PP_IOCTL, 0x86, unsigned char)
41
42/* Read/write econtrol (not used) */
43#define PPRECONTROL OBSOLETE__IOR(PP_IOCTL, 0x87, unsigned char)
44#define PPWECONTROL OBSOLETE__IOW(PP_IOCTL, 0x88, unsigned char)
45
46/* Read/write FIFO (not used) */
47#define PPRFIFO OBSOLETE__IOR(PP_IOCTL, 0x89, unsigned char)
48#define PPWFIFO OBSOLETE__IOW(PP_IOCTL, 0x8a, unsigned char)
49
50/* Claim the port to start using it */
51#define PPCLAIM _IO(PP_IOCTL, 0x8b)
52
53/* Release the port when you aren't using it */
54#define PPRELEASE _IO(PP_IOCTL, 0x8c)
55
56/* Yield the port (release it if another driver is waiting,
57 * then reclaim) */
58#define PPYIELD _IO(PP_IOCTL, 0x8d)
59
60/* Register device exclusively (must be before PPCLAIM). */
61#define PPEXCL _IO(PP_IOCTL, 0x8f)
62
63/* Data line direction: non-zero for input mode. */
64#define PPDATADIR _IOW(PP_IOCTL, 0x90, int)
65
66/* Negotiate a particular IEEE 1284 mode. */
67#define PPNEGOT _IOW(PP_IOCTL, 0x91, int)
68
69/* Set control lines when an interrupt occurs. */
70#define PPWCTLONIRQ _IOW(PP_IOCTL, 0x92, unsigned char)
71
72/* Clear (and return) interrupt count. */
73#define PPCLRIRQ _IOR(PP_IOCTL, 0x93, int)
74
75/* Set the IEEE 1284 phase that we're in (e.g. IEEE1284_PH_FWD_IDLE) */
76#define PPSETPHASE _IOW(PP_IOCTL, 0x94, int)
77
78/* Set and get port timeout (struct timeval's) */
79#define PPGETTIME _IOR(PP_IOCTL, 0x95, struct timeval)
80#define PPSETTIME _IOW(PP_IOCTL, 0x96, struct timeval)
81
82/* Get available modes (what the hardware can do) */
83#define PPGETMODES _IOR(PP_IOCTL, 0x97, unsigned int)
84
85/* Get the current mode and phaze */
86#define PPGETMODE _IOR(PP_IOCTL, 0x98, int)
87#define PPGETPHASE _IOR(PP_IOCTL, 0x99, int)
88
89/* get/set flags */
90#define PPGETFLAGS _IOR(PP_IOCTL, 0x9a, int)
91#define PPSETFLAGS _IOW(PP_IOCTL, 0x9b, int)
92
93/* flags visible to the world */
94#define PP_FASTWRITE (1<<2)
95#define PP_FASTREAD (1<<3)
96#define PP_W91284PIC (1<<4)
97
98/* only masks user-visible flags */
99#define PP_FLAGMASK (PP_FASTWRITE | PP_FASTREAD | PP_W91284PIC)
100
101
diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
new file mode 100644
index 000000000000..7227e653b3be
--- /dev/null
+++ b/include/linux/ppp-comp.h
@@ -0,0 +1,207 @@
1/*
2 * ppp-comp.h - Definitions for doing PPP packet compression.
3 *
4 * Copyright (c) 1994 The Australian National University.
5 * All rights reserved.
6 *
7 * Permission to use, copy, modify, and distribute this software and its
8 * documentation is hereby granted, provided that the above copyright
9 * notice appears in all copies. This software is provided without any
10 * warranty, express or implied. The Australian National University
11 * makes no representations about the suitability of this software for
12 * any purpose.
13 *
14 * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
15 * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
16 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
17 * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
18 * OF SUCH DAMAGE.
19 *
20 * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
21 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
23 * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
24 * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
25 * OR MODIFICATIONS.
26 *
27 * $Id: ppp-comp.h,v 1.6 1997/11/27 06:04:44 paulus Exp $
28 */
29
30/*
31 * ==FILEVERSION 980319==
32 *
33 * NOTE TO MAINTAINERS:
34 * If you modify this file at all, please set the above date.
35 * ppp-comp.h is shipped with a PPP distribution as well as with the kernel;
36 * if everyone increases the FILEVERSION number above, then scripts
37 * can do the right thing when deciding whether to install a new ppp-comp.h
38 * file. Don't change the format of that line otherwise, so the
39 * installation script can recognize it.
40 */
41
42#ifndef _NET_PPP_COMP_H
43#define _NET_PPP_COMP_H
44
45struct module;
46
47/*
48 * The following symbols control whether we include code for
49 * various compression methods.
50 */
51
52#ifndef DO_BSD_COMPRESS
53#define DO_BSD_COMPRESS 1 /* by default, include BSD-Compress */
54#endif
55#ifndef DO_DEFLATE
56#define DO_DEFLATE 1 /* by default, include Deflate */
57#endif
58#define DO_PREDICTOR_1 0
59#define DO_PREDICTOR_2 0
60
61/*
62 * Structure giving methods for compression/decompression.
63 */
64
65struct compressor {
66 int compress_proto; /* CCP compression protocol number */
67
68 /* Allocate space for a compressor (transmit side) */
69 void *(*comp_alloc) (unsigned char *options, int opt_len);
70
71 /* Free space used by a compressor */
72 void (*comp_free) (void *state);
73
74 /* Initialize a compressor */
75 int (*comp_init) (void *state, unsigned char *options,
76 int opt_len, int unit, int opthdr, int debug);
77
78 /* Reset a compressor */
79 void (*comp_reset) (void *state);
80
81 /* Compress a packet */
82 int (*compress) (void *state, unsigned char *rptr,
83 unsigned char *obuf, int isize, int osize);
84
85 /* Return compression statistics */
86 void (*comp_stat) (void *state, struct compstat *stats);
87
88 /* Allocate space for a decompressor (receive side) */
89 void *(*decomp_alloc) (unsigned char *options, int opt_len);
90
91 /* Free space used by a decompressor */
92 void (*decomp_free) (void *state);
93
94 /* Initialize a decompressor */
95 int (*decomp_init) (void *state, unsigned char *options,
96 int opt_len, int unit, int opthdr, int mru,
97 int debug);
98
99 /* Reset a decompressor */
100 void (*decomp_reset) (void *state);
101
102 /* Decompress a packet. */
103 int (*decompress) (void *state, unsigned char *ibuf, int isize,
104 unsigned char *obuf, int osize);
105
106 /* Update state for an incompressible packet received */
107 void (*incomp) (void *state, unsigned char *ibuf, int icnt);
108
109 /* Return decompression statistics */
110 void (*decomp_stat) (void *state, struct compstat *stats);
111
112 /* Used in locking compressor modules */
113 struct module *owner;
114};
115
116/*
117 * The return value from decompress routine is the length of the
118 * decompressed packet if successful, otherwise DECOMP_ERROR
119 * or DECOMP_FATALERROR if an error occurred.
120 *
121 * We need to make this distinction so that we can disable certain
122 * useful functionality, namely sending a CCP reset-request as a result
123 * of an error detected after decompression. This is to avoid infringing
124 * a patent held by Motorola.
125 * Don't you just lurve software patents.
126 */
127
128#define DECOMP_ERROR -1 /* error detected before decomp. */
129#define DECOMP_FATALERROR -2 /* error detected after decomp. */
130
131/*
132 * CCP codes.
133 */
134
135#define CCP_CONFREQ 1
136#define CCP_CONFACK 2
137#define CCP_TERMREQ 5
138#define CCP_TERMACK 6
139#define CCP_RESETREQ 14
140#define CCP_RESETACK 15
141
142/*
143 * Max # bytes for a CCP option
144 */
145
146#define CCP_MAX_OPTION_LENGTH 32
147
148/*
149 * Parts of a CCP packet.
150 */
151
152#define CCP_CODE(dp) ((dp)[0])
153#define CCP_ID(dp) ((dp)[1])
154#define CCP_LENGTH(dp) (((dp)[2] << 8) + (dp)[3])
155#define CCP_HDRLEN 4
156
157#define CCP_OPT_CODE(dp) ((dp)[0])
158#define CCP_OPT_LENGTH(dp) ((dp)[1])
159#define CCP_OPT_MINLEN 2
160
161/*
162 * Definitions for BSD-Compress.
163 */
164
165#define CI_BSD_COMPRESS 21 /* config. option for BSD-Compress */
166#define CILEN_BSD_COMPRESS 3 /* length of config. option */
167
168/* Macros for handling the 3rd byte of the BSD-Compress config option. */
169#define BSD_NBITS(x) ((x) & 0x1F) /* number of bits requested */
170#define BSD_VERSION(x) ((x) >> 5) /* version of option format */
171#define BSD_CURRENT_VERSION 1 /* current version number */
172#define BSD_MAKE_OPT(v, n) (((v) << 5) | (n))
173
174#define BSD_MIN_BITS 9 /* smallest code size supported */
175#define BSD_MAX_BITS 15 /* largest code size supported */
176
177/*
178 * Definitions for Deflate.
179 */
180
181#define CI_DEFLATE 26 /* config option for Deflate */
182#define CI_DEFLATE_DRAFT 24 /* value used in original draft RFC */
183#define CILEN_DEFLATE 4 /* length of its config option */
184
185#define DEFLATE_MIN_SIZE 9
186#define DEFLATE_MAX_SIZE 15
187#define DEFLATE_METHOD_VAL 8
188#define DEFLATE_SIZE(x) (((x) >> 4) + 8)
189#define DEFLATE_METHOD(x) ((x) & 0x0F)
190#define DEFLATE_MAKE_OPT(w) ((((w) - 8) << 4) + DEFLATE_METHOD_VAL)
191#define DEFLATE_CHK_SEQUENCE 0
192
193/*
194 * Definitions for other, as yet unsupported, compression methods.
195 */
196
197#define CI_PREDICTOR_1 1 /* config option for Predictor-1 */
198#define CILEN_PREDICTOR_1 2 /* length of its config option */
199#define CI_PREDICTOR_2 2 /* config option for Predictor-2 */
200#define CILEN_PREDICTOR_2 2 /* length of its config option */
201
202#ifdef __KERNEL__
203extern int ppp_register_compressor(struct compressor *);
204extern void ppp_unregister_compressor(struct compressor *);
205#endif /* __KERNEL__ */
206
207#endif /* _NET_PPP_COMP_H */
diff --git a/include/linux/ppp_channel.h b/include/linux/ppp_channel.h
new file mode 100644
index 000000000000..a942892d6dfe
--- /dev/null
+++ b/include/linux/ppp_channel.h
@@ -0,0 +1,81 @@
1#ifndef _PPP_CHANNEL_H_
2#define _PPP_CHANNEL_H_
3/*
4 * Definitions for the interface between the generic PPP code
5 * and a PPP channel.
6 *
7 * A PPP channel provides a way for the generic PPP code to send
8 * and receive packets over some sort of communications medium.
9 * Packets are stored in sk_buffs and have the 2-byte PPP protocol
10 * number at the start, but not the address and control bytes.
11 *
12 * Copyright 1999 Paul Mackerras.
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version
17 * 2 of the License, or (at your option) any later version.
18 *
19 * ==FILEVERSION 20000322==
20 */
21
22#include <linux/list.h>
23#include <linux/skbuff.h>
24#include <linux/poll.h>
25
26struct ppp_channel;
27
28struct ppp_channel_ops {
29 /* Send a packet (or multilink fragment) on this channel.
30 Returns 1 if it was accepted, 0 if not. */
31 int (*start_xmit)(struct ppp_channel *, struct sk_buff *);
32 /* Handle an ioctl call that has come in via /dev/ppp. */
33 int (*ioctl)(struct ppp_channel *, unsigned int, unsigned long);
34};
35
36struct ppp_channel {
37 void *private; /* channel private data */
38 struct ppp_channel_ops *ops; /* operations for this channel */
39 int mtu; /* max transmit packet size */
40 int hdrlen; /* amount of headroom channel needs */
41 void *ppp; /* opaque to channel */
42 /* the following are not used at present */
43 int speed; /* transfer rate (bytes/second) */
44 int latency; /* overhead time in milliseconds */
45};
46
47#ifdef __KERNEL__
48/* Called by the channel when it can send some more data. */
49extern void ppp_output_wakeup(struct ppp_channel *);
50
51/* Called by the channel to process a received PPP packet.
52 The packet should have just the 2-byte PPP protocol header. */
53extern void ppp_input(struct ppp_channel *, struct sk_buff *);
54
55/* Called by the channel when an input error occurs, indicating
56 that we may have missed a packet. */
57extern void ppp_input_error(struct ppp_channel *, int code);
58
59/* Attach a channel to a given PPP unit. */
60extern int ppp_register_channel(struct ppp_channel *);
61
62/* Detach a channel from its PPP unit (e.g. on hangup). */
63extern void ppp_unregister_channel(struct ppp_channel *);
64
65/* Get the channel number for a channel */
66extern int ppp_channel_index(struct ppp_channel *);
67
68/* Get the unit number associated with a channel, or -1 if none */
69extern int ppp_unit_number(struct ppp_channel *);
70
71/*
72 * SMP locking notes:
73 * The channel code must ensure that when it calls ppp_unregister_channel,
74 * nothing is executing in any of the procedures above, for that
75 * channel. The generic layer will ensure that nothing is executing
76 * in the start_xmit and ioctl routines for the channel by the time
77 * that ppp_unregister_channel returns.
78 */
79
80#endif /* __KERNEL__ */
81#endif
diff --git a/include/linux/ppp_defs.h b/include/linux/ppp_defs.h
new file mode 100644
index 000000000000..402056cd049d
--- /dev/null
+++ b/include/linux/ppp_defs.h
@@ -0,0 +1,190 @@
1/* $Id: ppp_defs.h,v 1.2 1994/09/21 01:31:06 paulus Exp $ */
2
3/*
4 * ppp_defs.h - PPP definitions.
5 *
6 * Copyright (c) 1994 The Australian National University.
7 * All rights reserved.
8 *
9 * Permission to use, copy, modify, and distribute this software and its
10 * documentation is hereby granted, provided that the above copyright
11 * notice appears in all copies. This software is provided without any
12 * warranty, express or implied. The Australian National University
13 * makes no representations about the suitability of this software for
14 * any purpose.
15 *
16 * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
17 * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
18 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
19 * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
20 * OF SUCH DAMAGE.
21 *
22 * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
23 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
25 * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
26 * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
27 * OR MODIFICATIONS.
28 */
29
30/*
31 * ==FILEVERSION 20000114==
32 *
33 * NOTE TO MAINTAINERS:
34 * If you modify this file at all, please set the above date.
35 * ppp_defs.h is shipped with a PPP distribution as well as with the kernel;
36 * if everyone increases the FILEVERSION number above, then scripts
37 * can do the right thing when deciding whether to install a new ppp_defs.h
38 * file. Don't change the format of that line otherwise, so the
39 * installation script can recognize it.
40 */
41
42#ifndef _PPP_DEFS_H_
43#define _PPP_DEFS_H_
44
45#include <linux/crc-ccitt.h>
46
47/*
48 * The basic PPP frame.
49 */
50#define PPP_HDRLEN 4 /* octets for standard ppp header */
51#define PPP_FCSLEN 2 /* octets for FCS */
52#define PPP_MRU 1500 /* default MRU = max length of info field */
53
54#define PPP_ADDRESS(p) (((__u8 *)(p))[0])
55#define PPP_CONTROL(p) (((__u8 *)(p))[1])
56#define PPP_PROTOCOL(p) ((((__u8 *)(p))[2] << 8) + ((__u8 *)(p))[3])
57
58/*
59 * Significant octet values.
60 */
61#define PPP_ALLSTATIONS 0xff /* All-Stations broadcast address */
62#define PPP_UI 0x03 /* Unnumbered Information */
63#define PPP_FLAG 0x7e /* Flag Sequence */
64#define PPP_ESCAPE 0x7d /* Asynchronous Control Escape */
65#define PPP_TRANS 0x20 /* Asynchronous transparency modifier */
66
67/*
68 * Protocol field values.
69 */
70#define PPP_IP 0x21 /* Internet Protocol */
71#define PPP_AT 0x29 /* AppleTalk Protocol */
72#define PPP_IPX 0x2b /* IPX protocol */
73#define PPP_VJC_COMP 0x2d /* VJ compressed TCP */
74#define PPP_VJC_UNCOMP 0x2f /* VJ uncompressed TCP */
75#define PPP_MP 0x3d /* Multilink protocol */
76#define PPP_IPV6 0x57 /* Internet Protocol Version 6 */
77#define PPP_COMPFRAG 0xfb /* fragment compressed below bundle */
78#define PPP_COMP 0xfd /* compressed packet */
79#define PPP_MPLS_UC 0x0281 /* Multi Protocol Label Switching - Unicast */
80#define PPP_MPLS_MC 0x0283 /* Multi Protocol Label Switching - Multicast */
81#define PPP_IPCP 0x8021 /* IP Control Protocol */
82#define PPP_ATCP 0x8029 /* AppleTalk Control Protocol */
83#define PPP_IPXCP 0x802b /* IPX Control Protocol */
84#define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */
85#define PPP_CCPFRAG 0x80fb /* CCP at link level (below MP bundle) */
86#define PPP_CCP 0x80fd /* Compression Control Protocol */
87#define PPP_MPLSCP 0x80fd /* MPLS Control Protocol */
88#define PPP_LCP 0xc021 /* Link Control Protocol */
89#define PPP_PAP 0xc023 /* Password Authentication Protocol */
90#define PPP_LQR 0xc025 /* Link Quality Report protocol */
91#define PPP_CHAP 0xc223 /* Cryptographic Handshake Auth. Protocol */
92#define PPP_CBCP 0xc029 /* Callback Control Protocol */
93
94/*
95 * Values for FCS calculations.
96 */
97
98#define PPP_INITFCS 0xffff /* Initial FCS value */
99#define PPP_GOODFCS 0xf0b8 /* Good final FCS value */
100#define PPP_FCS(fcs, c) crc_ccitt_byte(fcs, c)
101
102/*
103 * Extended asyncmap - allows any character to be escaped.
104 */
105
106typedef __u32 ext_accm[8];
107
108/*
109 * What to do with network protocol (NP) packets.
110 */
111enum NPmode {
112 NPMODE_PASS, /* pass the packet through */
113 NPMODE_DROP, /* silently drop the packet */
114 NPMODE_ERROR, /* return an error */
115 NPMODE_QUEUE /* save it up for later. */
116};
117
118/*
119 * Statistics for LQRP and pppstats
120 */
121struct pppstat {
122 __u32 ppp_discards; /* # frames discarded */
123
124 __u32 ppp_ibytes; /* bytes received */
125 __u32 ppp_ioctects; /* bytes received not in error */
126 __u32 ppp_ipackets; /* packets received */
127 __u32 ppp_ierrors; /* receive errors */
128 __u32 ppp_ilqrs; /* # LQR frames received */
129
130 __u32 ppp_obytes; /* raw bytes sent */
131 __u32 ppp_ooctects; /* frame bytes sent */
132 __u32 ppp_opackets; /* packets sent */
133 __u32 ppp_oerrors; /* transmit errors */
134 __u32 ppp_olqrs; /* # LQR frames sent */
135};
136
137struct vjstat {
138 __u32 vjs_packets; /* outbound packets */
139 __u32 vjs_compressed; /* outbound compressed packets */
140 __u32 vjs_searches; /* searches for connection state */
141 __u32 vjs_misses; /* times couldn't find conn. state */
142 __u32 vjs_uncompressedin; /* inbound uncompressed packets */
143 __u32 vjs_compressedin; /* inbound compressed packets */
144 __u32 vjs_errorin; /* inbound unknown type packets */
145 __u32 vjs_tossed; /* inbound packets tossed because of error */
146};
147
148struct compstat {
149 __u32 unc_bytes; /* total uncompressed bytes */
150 __u32 unc_packets; /* total uncompressed packets */
151 __u32 comp_bytes; /* compressed bytes */
152 __u32 comp_packets; /* compressed packets */
153 __u32 inc_bytes; /* incompressible bytes */
154 __u32 inc_packets; /* incompressible packets */
155
156 /* the compression ratio is defined as in_count / bytes_out */
157 __u32 in_count; /* Bytes received */
158 __u32 bytes_out; /* Bytes transmitted */
159
160 double ratio; /* not computed in kernel. */
161};
162
163struct ppp_stats {
164 struct pppstat p; /* basic PPP statistics */
165 struct vjstat vj; /* VJ header compression statistics */
166};
167
168struct ppp_comp_stats {
169 struct compstat c; /* packet compression statistics */
170 struct compstat d; /* packet decompression statistics */
171};
172
173/*
174 * The following structure records the time in seconds since
175 * the last NP packet was sent or received.
176 */
177struct ppp_idle {
178 time_t xmit_idle; /* time since last NP packet sent */
179 time_t recv_idle; /* time since last NP packet received */
180};
181
182#ifndef __P
183#ifdef __STDC__
184#define __P(x) x
185#else
186#define __P(x) ()
187#endif
188#endif
189
190#endif /* _PPP_DEFS_H_ */
diff --git a/include/linux/prctl.h b/include/linux/prctl.h
new file mode 100644
index 000000000000..bf022c43a18e
--- /dev/null
+++ b/include/linux/prctl.h
@@ -0,0 +1,55 @@
1#ifndef _LINUX_PRCTL_H
2#define _LINUX_PRCTL_H
3
4/* Values to pass as first argument to prctl() */
5
6#define PR_SET_PDEATHSIG 1 /* Second arg is a signal */
7#define PR_GET_PDEATHSIG 2 /* Second arg is a ptr to return the signal */
8
9/* Get/set current->mm->dumpable */
10#define PR_GET_DUMPABLE 3
11#define PR_SET_DUMPABLE 4
12
13/* Get/set unaligned access control bits (if meaningful) */
14#define PR_GET_UNALIGN 5
15#define PR_SET_UNALIGN 6
16# define PR_UNALIGN_NOPRINT 1 /* silently fix up unaligned user accesses */
17# define PR_UNALIGN_SIGBUS 2 /* generate SIGBUS on unaligned user access */
18
19/* Get/set whether or not to drop capabilities on setuid() away from uid 0 */
20#define PR_GET_KEEPCAPS 7
21#define PR_SET_KEEPCAPS 8
22
23/* Get/set floating-point emulation control bits (if meaningful) */
24#define PR_GET_FPEMU 9
25#define PR_SET_FPEMU 10
26# define PR_FPEMU_NOPRINT 1 /* silently emulate fp operations accesses */
27# define PR_FPEMU_SIGFPE 2 /* don't emulate fp operations, send SIGFPE instead */
28
29/* Get/set floating-point exception mode (if meaningful) */
30#define PR_GET_FPEXC 11
31#define PR_SET_FPEXC 12
32# define PR_FP_EXC_SW_ENABLE 0x80 /* Use FPEXC for FP exception enables */
33# define PR_FP_EXC_DIV 0x010000 /* floating point divide by zero */
34# define PR_FP_EXC_OVF 0x020000 /* floating point overflow */
35# define PR_FP_EXC_UND 0x040000 /* floating point underflow */
36# define PR_FP_EXC_RES 0x080000 /* floating point inexact result */
37# define PR_FP_EXC_INV 0x100000 /* floating point invalid operation */
38# define PR_FP_EXC_DISABLED 0 /* FP exceptions disabled */
39# define PR_FP_EXC_NONRECOV 1 /* async non-recoverable exc. mode */
40# define PR_FP_EXC_ASYNC 2 /* async recoverable exception mode */
41# define PR_FP_EXC_PRECISE 3 /* precise exception mode */
42
43/* Get/set whether we use statistical process timing or accurate timestamp
44 * based process timing */
45#define PR_GET_TIMING 13
46#define PR_SET_TIMING 14
47# define PR_TIMING_STATISTICAL 0 /* Normal, traditional,
48 statistical process timing */
49# define PR_TIMING_TIMESTAMP 1 /* Accurate timestamp based
50 process timing */
51
52#define PR_SET_NAME 15 /* Set process name */
53#define PR_GET_NAME 16 /* Get process name */
54
55#endif /* _LINUX_PRCTL_H */
diff --git a/include/linux/preempt.h b/include/linux/preempt.h
new file mode 100644
index 000000000000..dd98c54a23b4
--- /dev/null
+++ b/include/linux/preempt.h
@@ -0,0 +1,62 @@
1#ifndef __LINUX_PREEMPT_H
2#define __LINUX_PREEMPT_H
3
4/*
5 * include/linux/preempt.h - macros for accessing and manipulating
6 * preempt_count (used for kernel preemption, interrupt count, etc.)
7 */
8
9#include <linux/config.h>
10#include <linux/linkage.h>
11
12#ifdef CONFIG_DEBUG_PREEMPT
13 extern void fastcall add_preempt_count(int val);
14 extern void fastcall sub_preempt_count(int val);
15#else
16# define add_preempt_count(val) do { preempt_count() += (val); } while (0)
17# define sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
18#endif
19
20#define inc_preempt_count() add_preempt_count(1)
21#define dec_preempt_count() sub_preempt_count(1)
22
23#define preempt_count() (current_thread_info()->preempt_count)
24
25#ifdef CONFIG_PREEMPT
26
27asmlinkage void preempt_schedule(void);
28
29#define preempt_disable() \
30do { \
31 inc_preempt_count(); \
32 barrier(); \
33} while (0)
34
35#define preempt_enable_no_resched() \
36do { \
37 barrier(); \
38 dec_preempt_count(); \
39} while (0)
40
41#define preempt_check_resched() \
42do { \
43 if (unlikely(test_thread_flag(TIF_NEED_RESCHED))) \
44 preempt_schedule(); \
45} while (0)
46
47#define preempt_enable() \
48do { \
49 preempt_enable_no_resched(); \
50 preempt_check_resched(); \
51} while (0)
52
53#else
54
55#define preempt_disable() do { } while (0)
56#define preempt_enable_no_resched() do { } while (0)
57#define preempt_enable() do { } while (0)
58#define preempt_check_resched() do { } while (0)
59
60#endif
61
62#endif /* __LINUX_PREEMPT_H */
diff --git a/include/linux/prefetch.h b/include/linux/prefetch.h
new file mode 100644
index 000000000000..fc86f274147f
--- /dev/null
+++ b/include/linux/prefetch.h
@@ -0,0 +1,69 @@
1/*
2 * Generic cache management functions. Everything is arch-specific,
3 * but this header exists to make sure the defines/functions can be
4 * used in a generic way.
5 *
6 * 2000-11-13 Arjan van de Ven <arjan@fenrus.demon.nl>
7 *
8 */
9
10#ifndef _LINUX_PREFETCH_H
11#define _LINUX_PREFETCH_H
12
13#include <linux/types.h>
14#include <asm/processor.h>
15#include <asm/cache.h>
16
17/*
18 prefetch(x) attempts to pre-emptively get the memory pointed to
19 by address "x" into the CPU L1 cache.
20 prefetch(x) should not cause any kind of exception, prefetch(0) is
21 specifically ok.
22
23 prefetch() should be defined by the architecture, if not, the
24 #define below provides a no-op define.
25
26 There are 3 prefetch() macros:
27
28 prefetch(x) - prefetches the cacheline at "x" for read
29 prefetchw(x) - prefetches the cacheline at "x" for write
30 spin_lock_prefetch(x) - prefectches the spinlock *x for taking
31
32 there is also PREFETCH_STRIDE which is the architecure-prefered
33 "lookahead" size for prefetching streamed operations.
34
35*/
36
37/*
38 * These cannot be do{}while(0) macros. See the mental gymnastics in
39 * the loop macro.
40 */
41
42#ifndef ARCH_HAS_PREFETCH
43static inline void prefetch(const void *x) {;}
44#endif
45
46#ifndef ARCH_HAS_PREFETCHW
47static inline void prefetchw(const void *x) {;}
48#endif
49
50#ifndef ARCH_HAS_SPINLOCK_PREFETCH
51#define spin_lock_prefetch(x) prefetchw(x)
52#endif
53
54#ifndef PREFETCH_STRIDE
55#define PREFETCH_STRIDE (4*L1_CACHE_BYTES)
56#endif
57
58static inline void prefetch_range(void *addr, size_t len)
59{
60#ifdef ARCH_HAS_PREFETCH
61 char *cp;
62 char *end = addr + len;
63
64 for (cp = addr; cp < end; cp += PREFETCH_STRIDE)
65 prefetch(cp);
66#endif
67}
68
69#endif
diff --git a/include/linux/prio_tree.h b/include/linux/prio_tree.h
new file mode 100644
index 000000000000..db04abb557e0
--- /dev/null
+++ b/include/linux/prio_tree.h
@@ -0,0 +1,120 @@
1#ifndef _LINUX_PRIO_TREE_H
2#define _LINUX_PRIO_TREE_H
3
4/*
5 * K&R 2nd ed. A8.3 somewhat obliquely hints that initial sequences of struct
6 * fields with identical types should end up at the same location. We'll use
7 * this until we can scrap struct raw_prio_tree_node.
8 *
9 * Note: all this could be done more elegantly by using unnamed union/struct
10 * fields. However, gcc 2.95.3 and apparently also gcc 3.0.4 don't support this
11 * language extension.
12 */
13
14struct raw_prio_tree_node {
15 struct prio_tree_node *left;
16 struct prio_tree_node *right;
17 struct prio_tree_node *parent;
18};
19
20struct prio_tree_node {
21 struct prio_tree_node *left;
22 struct prio_tree_node *right;
23 struct prio_tree_node *parent;
24 unsigned long start;
25 unsigned long last; /* last location _in_ interval */
26};
27
28struct prio_tree_root {
29 struct prio_tree_node *prio_tree_node;
30 unsigned short index_bits;
31 unsigned short raw;
32 /*
33 * 0: nodes are of type struct prio_tree_node
34 * 1: nodes are of type raw_prio_tree_node
35 */
36};
37
38struct prio_tree_iter {
39 struct prio_tree_node *cur;
40 unsigned long mask;
41 unsigned long value;
42 int size_level;
43
44 struct prio_tree_root *root;
45 pgoff_t r_index;
46 pgoff_t h_index;
47};
48
49static inline void prio_tree_iter_init(struct prio_tree_iter *iter,
50 struct prio_tree_root *root, pgoff_t r_index, pgoff_t h_index)
51{
52 iter->root = root;
53 iter->r_index = r_index;
54 iter->h_index = h_index;
55 iter->cur = NULL;
56}
57
58#define __INIT_PRIO_TREE_ROOT(ptr, _raw) \
59do { \
60 (ptr)->prio_tree_node = NULL; \
61 (ptr)->index_bits = 1; \
62 (ptr)->raw = (_raw); \
63} while (0)
64
65#define INIT_PRIO_TREE_ROOT(ptr) __INIT_PRIO_TREE_ROOT(ptr, 0)
66#define INIT_RAW_PRIO_TREE_ROOT(ptr) __INIT_PRIO_TREE_ROOT(ptr, 1)
67
68#define INIT_PRIO_TREE_NODE(ptr) \
69do { \
70 (ptr)->left = (ptr)->right = (ptr)->parent = (ptr); \
71} while (0)
72
73#define INIT_PRIO_TREE_ITER(ptr) \
74do { \
75 (ptr)->cur = NULL; \
76 (ptr)->mask = 0UL; \
77 (ptr)->value = 0UL; \
78 (ptr)->size_level = 0; \
79} while (0)
80
81#define prio_tree_entry(ptr, type, member) \
82 ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
83
84static inline int prio_tree_empty(const struct prio_tree_root *root)
85{
86 return root->prio_tree_node == NULL;
87}
88
89static inline int prio_tree_root(const struct prio_tree_node *node)
90{
91 return node->parent == node;
92}
93
94static inline int prio_tree_left_empty(const struct prio_tree_node *node)
95{
96 return node->left == node;
97}
98
99static inline int prio_tree_right_empty(const struct prio_tree_node *node)
100{
101 return node->right == node;
102}
103
104
105struct prio_tree_node *prio_tree_replace(struct prio_tree_root *root,
106 struct prio_tree_node *old, struct prio_tree_node *node);
107struct prio_tree_node *prio_tree_insert(struct prio_tree_root *root,
108 struct prio_tree_node *node);
109void prio_tree_remove(struct prio_tree_root *root, struct prio_tree_node *node);
110struct prio_tree_node *prio_tree_next(struct prio_tree_iter *iter);
111
112#define raw_prio_tree_replace(root, old, node) \
113 prio_tree_replace(root, (struct prio_tree_node *) (old), \
114 (struct prio_tree_node *) (node))
115#define raw_prio_tree_insert(root, node) \
116 prio_tree_insert(root, (struct prio_tree_node *) (node))
117#define raw_prio_tree_remove(root, node) \
118 prio_tree_remove(root, (struct prio_tree_node *) (node))
119
120#endif /* _LINUX_PRIO_TREE_H */
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
new file mode 100644
index 000000000000..59e505261fd6
--- /dev/null
+++ b/include/linux/proc_fs.h
@@ -0,0 +1,259 @@
1#ifndef _LINUX_PROC_FS_H
2#define _LINUX_PROC_FS_H
3
4#include <linux/config.h>
5#include <linux/slab.h>
6#include <linux/fs.h>
7#include <asm/atomic.h>
8
9/*
10 * The proc filesystem constants/structures
11 */
12
13/*
14 * Offset of the first process in the /proc root directory..
15 */
16#define FIRST_PROCESS_ENTRY 256
17
18
19/*
20 * We always define these enumerators
21 */
22
23enum {
24 PROC_ROOT_INO = 1,
25};
26
27#define PROC_SUPER_MAGIC 0x9fa0
28
29/*
30 * This is not completely implemented yet. The idea is to
31 * create an in-memory tree (like the actual /proc filesystem
32 * tree) of these proc_dir_entries, so that we can dynamically
33 * add new files to /proc.
34 *
35 * The "next" pointer creates a linked list of one /proc directory,
36 * while parent/subdir create the directory structure (every
37 * /proc file has a parent, but "subdir" is NULL for all
38 * non-directory entries).
39 *
40 * "get_info" is called at "read", while "owner" is used to protect module
41 * from unloading while proc_dir_entry is in use
42 */
43
44typedef int (read_proc_t)(char *page, char **start, off_t off,
45 int count, int *eof, void *data);
46typedef int (write_proc_t)(struct file *file, const char __user *buffer,
47 unsigned long count, void *data);
48typedef int (get_info_t)(char *, char **, off_t, int);
49
50struct proc_dir_entry {
51 unsigned int low_ino;
52 unsigned short namelen;
53 const char *name;
54 mode_t mode;
55 nlink_t nlink;
56 uid_t uid;
57 gid_t gid;
58 unsigned long size;
59 struct inode_operations * proc_iops;
60 struct file_operations * proc_fops;
61 get_info_t *get_info;
62 struct module *owner;
63 struct proc_dir_entry *next, *parent, *subdir;
64 void *data;
65 read_proc_t *read_proc;
66 write_proc_t *write_proc;
67 atomic_t count; /* use count */
68 int deleted; /* delete flag */
69};
70
71struct kcore_list {
72 struct kcore_list *next;
73 unsigned long addr;
74 size_t size;
75};
76
77#ifdef CONFIG_PROC_FS
78
79extern struct proc_dir_entry proc_root;
80extern struct proc_dir_entry *proc_root_fs;
81extern struct proc_dir_entry *proc_net;
82extern struct proc_dir_entry *proc_net_stat;
83extern struct proc_dir_entry *proc_bus;
84extern struct proc_dir_entry *proc_root_driver;
85extern struct proc_dir_entry *proc_root_kcore;
86
87extern void proc_root_init(void);
88extern void proc_misc_init(void);
89
90struct mm_struct;
91
92struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *);
93struct dentry *proc_pid_unhash(struct task_struct *p);
94void proc_pid_flush(struct dentry *proc_dentry);
95int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir);
96unsigned long task_vsize(struct mm_struct *);
97int task_statm(struct mm_struct *, int *, int *, int *, int *);
98char *task_mem(struct mm_struct *, char *);
99
100extern struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode,
101 struct proc_dir_entry *parent);
102extern void remove_proc_entry(const char *name, struct proc_dir_entry *parent);
103
104extern struct vfsmount *proc_mnt;
105extern int proc_fill_super(struct super_block *,void *,int);
106extern struct inode *proc_get_inode(struct super_block *, unsigned int, struct proc_dir_entry *);
107
108extern int proc_match(int, const char *,struct proc_dir_entry *);
109
110/*
111 * These are generic /proc routines that use the internal
112 * "struct proc_dir_entry" tree to traverse the filesystem.
113 *
114 * The /proc root directory has extended versions to take care
115 * of the /proc/<pid> subdirectories.
116 */
117extern int proc_readdir(struct file *, void *, filldir_t);
118extern struct dentry *proc_lookup(struct inode *, struct dentry *, struct nameidata *);
119
120extern struct file_operations proc_kcore_operations;
121extern struct file_operations proc_kmsg_operations;
122extern struct file_operations ppc_htab_operations;
123
124/*
125 * proc_tty.c
126 */
127struct tty_driver;
128extern void proc_tty_init(void);
129extern void proc_tty_register_driver(struct tty_driver *driver);
130extern void proc_tty_unregister_driver(struct tty_driver *driver);
131
132/*
133 * proc_devtree.c
134 */
135struct device_node;
136extern void proc_device_tree_init(void);
137#ifdef CONFIG_PROC_DEVICETREE
138extern void proc_device_tree_add_node(struct device_node *, struct proc_dir_entry *);
139#else /* !CONFIG_PROC_DEVICETREE */
140static inline void proc_device_tree_add_node(struct device_node *np, struct proc_dir_entry *pde)
141{
142 return;
143}
144#endif /* CONFIG_PROC_DEVICETREE */
145
146extern struct proc_dir_entry *proc_symlink(const char *,
147 struct proc_dir_entry *, const char *);
148extern struct proc_dir_entry *proc_mkdir(const char *,struct proc_dir_entry *);
149extern struct proc_dir_entry *proc_mkdir_mode(const char *name, mode_t mode,
150 struct proc_dir_entry *parent);
151
152static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
153 mode_t mode, struct proc_dir_entry *base,
154 read_proc_t *read_proc, void * data)
155{
156 struct proc_dir_entry *res=create_proc_entry(name,mode,base);
157 if (res) {
158 res->read_proc=read_proc;
159 res->data=data;
160 }
161 return res;
162}
163
164static inline struct proc_dir_entry *create_proc_info_entry(const char *name,
165 mode_t mode, struct proc_dir_entry *base, get_info_t *get_info)
166{
167 struct proc_dir_entry *res=create_proc_entry(name,mode,base);
168 if (res) res->get_info=get_info;
169 return res;
170}
171
172static inline struct proc_dir_entry *proc_net_create(const char *name,
173 mode_t mode, get_info_t *get_info)
174{
175 return create_proc_info_entry(name,mode,proc_net,get_info);
176}
177
178static inline struct proc_dir_entry *proc_net_fops_create(const char *name,
179 mode_t mode, struct file_operations *fops)
180{
181 struct proc_dir_entry *res = create_proc_entry(name, mode, proc_net);
182 if (res)
183 res->proc_fops = fops;
184 return res;
185}
186
187static inline void proc_net_remove(const char *name)
188{
189 remove_proc_entry(name,proc_net);
190}
191
192#else
193
194#define proc_root_driver NULL
195#define proc_net NULL
196#define proc_bus NULL
197
198#define proc_net_fops_create(name, mode, fops) ({ (void)(mode), NULL; })
199#define proc_net_create(name, mode, info) ({ (void)(mode), NULL; })
200static inline void proc_net_remove(const char *name) {}
201
202static inline struct dentry *proc_pid_unhash(struct task_struct *p) { return NULL; }
203static inline void proc_pid_flush(struct dentry *proc_dentry) { }
204
205static inline struct proc_dir_entry *create_proc_entry(const char *name,
206 mode_t mode, struct proc_dir_entry *parent) { return NULL; }
207
208#define remove_proc_entry(name, parent) do {} while (0)
209
210static inline struct proc_dir_entry *proc_symlink(const char *name,
211 struct proc_dir_entry *parent,const char *dest) {return NULL;}
212static inline struct proc_dir_entry *proc_mkdir(const char *name,
213 struct proc_dir_entry *parent) {return NULL;}
214
215static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
216 mode_t mode, struct proc_dir_entry *base,
217 read_proc_t *read_proc, void * data) { return NULL; }
218static inline struct proc_dir_entry *create_proc_info_entry(const char *name,
219 mode_t mode, struct proc_dir_entry *base, get_info_t *get_info)
220 { return NULL; }
221
222struct tty_driver;
223static inline void proc_tty_register_driver(struct tty_driver *driver) {};
224static inline void proc_tty_unregister_driver(struct tty_driver *driver) {};
225
226extern struct proc_dir_entry proc_root;
227
228#endif /* CONFIG_PROC_FS */
229
230#if !defined(CONFIG_PROC_KCORE)
231static inline void kclist_add(struct kcore_list *new, void *addr, size_t size)
232{
233}
234#else
235extern void kclist_add(struct kcore_list *, void *, size_t);
236#endif
237
238struct proc_inode {
239 struct task_struct *task;
240 int type;
241 union {
242 int (*proc_get_link)(struct inode *, struct dentry **, struct vfsmount **);
243 int (*proc_read)(struct task_struct *task, char *page);
244 } op;
245 struct proc_dir_entry *pde;
246 struct inode vfs_inode;
247};
248
249static inline struct proc_inode *PROC_I(const struct inode *inode)
250{
251 return container_of(inode, struct proc_inode, vfs_inode);
252}
253
254static inline struct proc_dir_entry *PDE(const struct inode *inode)
255{
256 return PROC_I(inode)->pde;
257}
258
259#endif /* _LINUX_PROC_FS_H */
diff --git a/include/linux/profile.h b/include/linux/profile.h
new file mode 100644
index 000000000000..026969a5595c
--- /dev/null
+++ b/include/linux/profile.h
@@ -0,0 +1,104 @@
1#ifndef _LINUX_PROFILE_H
2#define _LINUX_PROFILE_H
3
4#ifdef __KERNEL__
5
6#include <linux/kernel.h>
7#include <linux/config.h>
8#include <linux/init.h>
9#include <linux/cpumask.h>
10#include <asm/errno.h>
11
12#define CPU_PROFILING 1
13#define SCHED_PROFILING 2
14
15struct proc_dir_entry;
16struct pt_regs;
17
18/* init basic kernel profiler */
19void __init profile_init(void);
20void profile_tick(int, struct pt_regs *);
21void profile_hit(int, void *);
22#ifdef CONFIG_PROC_FS
23void create_prof_cpu_mask(struct proc_dir_entry *);
24#else
25#define create_prof_cpu_mask(x) do { (void)(x); } while (0)
26#endif
27
28enum profile_type {
29 PROFILE_TASK_EXIT,
30 PROFILE_MUNMAP
31};
32
33#ifdef CONFIG_PROFILING
34
35struct notifier_block;
36struct task_struct;
37struct mm_struct;
38
39/* task is in do_exit() */
40void profile_task_exit(struct task_struct * task);
41
42/* task is dead, free task struct ? Returns 1 if
43 * the task was taken, 0 if the task should be freed.
44 */
45int profile_handoff_task(struct task_struct * task);
46
47/* sys_munmap */
48void profile_munmap(unsigned long addr);
49
50int task_handoff_register(struct notifier_block * n);
51int task_handoff_unregister(struct notifier_block * n);
52
53int profile_event_register(enum profile_type, struct notifier_block * n);
54int profile_event_unregister(enum profile_type, struct notifier_block * n);
55
56int register_timer_hook(int (*hook)(struct pt_regs *));
57void unregister_timer_hook(int (*hook)(struct pt_regs *));
58
59/* Timer based profiling hook */
60extern int (*timer_hook)(struct pt_regs *);
61
62struct pt_regs;
63
64#else
65
66static inline int task_handoff_register(struct notifier_block * n)
67{
68 return -ENOSYS;
69}
70
71static inline int task_handoff_unregister(struct notifier_block * n)
72{
73 return -ENOSYS;
74}
75
76static inline int profile_event_register(enum profile_type t, struct notifier_block * n)
77{
78 return -ENOSYS;
79}
80
81static inline int profile_event_unregister(enum profile_type t, struct notifier_block * n)
82{
83 return -ENOSYS;
84}
85
86#define profile_task_exit(a) do { } while (0)
87#define profile_handoff_task(a) (0)
88#define profile_munmap(a) do { } while (0)
89
90static inline int register_timer_hook(int (*hook)(struct pt_regs *))
91{
92 return -ENOSYS;
93}
94
95static inline void unregister_timer_hook(int (*hook)(struct pt_regs *))
96{
97 return;
98}
99
100#endif /* CONFIG_PROFILING */
101
102#endif /* __KERNEL__ */
103
104#endif /* _LINUX_PROFILE_H */
diff --git a/include/linux/ps2esdi.h b/include/linux/ps2esdi.h
new file mode 100644
index 000000000000..c0e050b1dfe9
--- /dev/null
+++ b/include/linux/ps2esdi.h
@@ -0,0 +1,98 @@
1#ifndef _PS2ESDI_H_
2#define _PS2ESDI_H_
3
4#define NRML_ESDI_ID 0xddff
5#define INTG_ESDI_ID 0xdf9f
6
7#define PRIMARY_IO_BASE 0x3510
8#define ALT_IO_BASE 0x3518
9
10#define ESDI_CMD_INT (io_base+0)
11#define ESDI_STT_INT (io_base+0)
12#define ESDI_CONTROL (io_base+2)
13#define ESDI_STATUS (io_base+2)
14#define ESDI_ATTN (io_base+3)
15#define ESDI_INTRPT (io_base+3)
16
17#define STATUS_ENABLED 0x01
18#define STATUS_ALTERNATE 0x02
19#define STATUS_BUSY 0x10
20#define STATUS_STAT_AVAIL 0x08
21#define STATUS_INTR 0x01
22#define STATUS_RESET_FAIL 0xea
23#define STATUS_CMD_INF 0x04
24
25#define CTRL_SOFT_RESET 0xe4
26#define CTRL_HARD_RESET 0x80
27#define CTRL_EOI 0xe2
28#define CTRL_ENABLE_DMA 0x02
29#define CTRL_ENABLE_INTR 0x01
30#define CTRL_DISABLE_INTR 0x00
31
32#define ATT_EOI 0x02
33
34/* bits of word 0 of configuration status block. more info see p.38 of tech ref */
35#define CONFIG_IS 0x10 /* Invalid Secondary */
36#define CONFIG_ZD 0x08 /* Zero Defect */
37#define CONFIG_SF 0x04 /* Skewed Format */
38#define CONFIG_FR 0x02 /* Removable */
39#define CONFIG_RT 0x01 /* Retries */
40
41#define PORT_SYS_A 0x92
42#define PORT_DMA_FN 0x18
43#define PORT_DMA_EX 0x1a
44
45#define ON (unsigned char)0x40
46#define OFF (unsigned char)~ON
47#define LITE_ON outb(inb(PORT_SYS_A) | ON,PORT_SYS_A)
48#define LITE_OFF outb((inb(PORT_SYS_A) & OFF),PORT_SYS_A)
49
50#define FAIL 0
51#define SUCCES 1
52
53#define INT_CMD_COMPLETE 0x01
54#define INT_CMD_ECC 0x03
55#define INT_CMD_RETRY 0x05
56#define INT_CMD_FORMAT 0x06
57#define INT_CMD_ECC_RETRY 0x07
58#define INT_CMD_WARNING 0x08
59#define INT_CMD_ABORT 0x09
60#define INT_RESET 0x0A
61#define INT_TRANSFER_REQ 0x0B
62#define INT_CMD_FAILED 0x0C
63#define INT_DMA_ERR 0x0D
64#define INT_CMD_BLK_ERR 0x0E
65#define INT_ATTN_ERROR 0x0F
66
67#define DMA_MASK_CHAN 0x90
68#define DMA_UNMASK_CHAN 0xA0
69#define DMA_WRITE_ADDR 0x20
70#define DMA_WRITE_TC 0x40
71#define DMA_WRITE_MODE 0x70
72
73#define CMD_GET_DEV_CONFIG 0x09
74#define CMD_READ 0x4601
75#define CMD_WRITE 0x4602
76#define DMA_READ_16 0x4C
77#define DMA_WRITE_16 0x44
78
79
80#define MB 1024*1024
81#define SECT_SIZE 512
82
83#define ERROR 1
84#define OK 0
85
86#define HDIO_GETGEO 0x0301
87
88#define FALSE 0
89#define TRUE !FALSE
90
91struct ps2esdi_geometry {
92 unsigned char heads;
93 unsigned char sectors;
94 unsigned short cylinders;
95 unsigned long start;
96};
97
98#endif /* _PS2ESDI_H_ */
diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h
new file mode 100644
index 000000000000..a373fc254df2
--- /dev/null
+++ b/include/linux/ptrace.h
@@ -0,0 +1,122 @@
1#ifndef _LINUX_PTRACE_H
2#define _LINUX_PTRACE_H
3/* ptrace.h */
4/* structs and defines to help the user use the ptrace system call. */
5
6/* has the defines to get at the registers. */
7
8#define PTRACE_TRACEME 0
9#define PTRACE_PEEKTEXT 1
10#define PTRACE_PEEKDATA 2
11#define PTRACE_PEEKUSR 3
12#define PTRACE_POKETEXT 4
13#define PTRACE_POKEDATA 5
14#define PTRACE_POKEUSR 6
15#define PTRACE_CONT 7
16#define PTRACE_KILL 8
17#define PTRACE_SINGLESTEP 9
18
19#define PTRACE_ATTACH 0x10
20#define PTRACE_DETACH 0x11
21
22#define PTRACE_SYSCALL 24
23
24/* 0x4200-0x4300 are reserved for architecture-independent additions. */
25#define PTRACE_SETOPTIONS 0x4200
26#define PTRACE_GETEVENTMSG 0x4201
27#define PTRACE_GETSIGINFO 0x4202
28#define PTRACE_SETSIGINFO 0x4203
29
30/* options set using PTRACE_SETOPTIONS */
31#define PTRACE_O_TRACESYSGOOD 0x00000001
32#define PTRACE_O_TRACEFORK 0x00000002
33#define PTRACE_O_TRACEVFORK 0x00000004
34#define PTRACE_O_TRACECLONE 0x00000008
35#define PTRACE_O_TRACEEXEC 0x00000010
36#define PTRACE_O_TRACEVFORKDONE 0x00000020
37#define PTRACE_O_TRACEEXIT 0x00000040
38
39#define PTRACE_O_MASK 0x0000007f
40
41/* Wait extended result codes for the above trace options. */
42#define PTRACE_EVENT_FORK 1
43#define PTRACE_EVENT_VFORK 2
44#define PTRACE_EVENT_CLONE 3
45#define PTRACE_EVENT_EXEC 4
46#define PTRACE_EVENT_VFORK_DONE 5
47#define PTRACE_EVENT_EXIT 6
48
49#include <asm/ptrace.h>
50
51#ifdef __KERNEL__
52/*
53 * Ptrace flags
54 */
55
56#define PT_PTRACED 0x00000001
57#define PT_DTRACE 0x00000002 /* delayed trace (used on m68k, i386) */
58#define PT_TRACESYSGOOD 0x00000004
59#define PT_PTRACE_CAP 0x00000008 /* ptracer can follow suid-exec */
60#define PT_TRACE_FORK 0x00000010
61#define PT_TRACE_VFORK 0x00000020
62#define PT_TRACE_CLONE 0x00000040
63#define PT_TRACE_EXEC 0x00000080
64#define PT_TRACE_VFORK_DONE 0x00000100
65#define PT_TRACE_EXIT 0x00000200
66#define PT_ATTACHED 0x00000400 /* parent != real_parent */
67
68#define PT_TRACE_MASK 0x000003f4
69
70/* single stepping state bits (used on ARM and PA-RISC) */
71#define PT_SINGLESTEP_BIT 31
72#define PT_SINGLESTEP (1<<PT_SINGLESTEP_BIT)
73#define PT_BLOCKSTEP_BIT 30
74#define PT_BLOCKSTEP (1<<PT_BLOCKSTEP_BIT)
75
76#include <linux/compiler.h> /* For unlikely. */
77#include <linux/sched.h> /* For struct task_struct. */
78
79extern int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst, int len);
80extern int ptrace_writedata(struct task_struct *tsk, char __user *src, unsigned long dst, int len);
81extern int ptrace_attach(struct task_struct *tsk);
82extern int ptrace_detach(struct task_struct *, unsigned int);
83extern void ptrace_disable(struct task_struct *);
84extern int ptrace_check_attach(struct task_struct *task, int kill);
85extern int ptrace_request(struct task_struct *child, long request, long addr, long data);
86extern void ptrace_notify(int exit_code);
87extern void __ptrace_link(struct task_struct *child,
88 struct task_struct *new_parent);
89extern void __ptrace_unlink(struct task_struct *child);
90extern void ptrace_untrace(struct task_struct *child);
91
92static inline void ptrace_link(struct task_struct *child,
93 struct task_struct *new_parent)
94{
95 if (unlikely(child->ptrace))
96 __ptrace_link(child, new_parent);
97}
98static inline void ptrace_unlink(struct task_struct *child)
99{
100 if (unlikely(child->ptrace))
101 __ptrace_unlink(child);
102}
103
104
105#ifndef force_successful_syscall_return
106/*
107 * System call handlers that, upon successful completion, need to return a
108 * negative value should call force_successful_syscall_return() right before
109 * returning. On architectures where the syscall convention provides for a
110 * separate error flag (e.g., alpha, ia64, ppc{,64}, sparc{,64}, possibly
111 * others), this macro can be used to ensure that the error flag will not get
112 * set. On architectures which do not support a separate error flag, the macro
113 * is a no-op and the spurious error condition needs to be filtered out by some
114 * other means (e.g., in user-level, by passing an extra argument to the
115 * syscall handler, or something along those lines).
116 */
117#define force_successful_syscall_return() do { } while (0)
118#endif
119
120#endif
121
122#endif
diff --git a/include/linux/qic117.h b/include/linux/qic117.h
new file mode 100644
index 000000000000..07b537e5d359
--- /dev/null
+++ b/include/linux/qic117.h
@@ -0,0 +1,290 @@
1#ifndef _QIC117_H
2#define _QIC117_H
3
4/*
5 * Copyright (C) 1993-1996 Bas Laarhoven,
6 * (C) 1997 Claus-Justus Heine.
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, or (at your option)
11 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; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 *
23 * $Source: /homes/cvs/ftape-stacked/include/linux/qic117.h,v $
24 * $Revision: 1.2 $
25 * $Date: 1997/10/05 19:19:32 $
26 *
27 * This file contains QIC-117 spec. related definitions for the
28 * QIC-40/80/3010/3020 floppy-tape driver "ftape" for Linux.
29 *
30 * These data were taken from the Quarter-Inch Cartridge
31 * Drive Standards, Inc. document titled:
32 * `Common Command Set Interface Specification for Flexible
33 * Disk Controller Based Minicartridge Tape Drives'
34 * document QIC-117 Revision J, 28 Aug 96.
35 * For more information, contact:
36 * Quarter-Inch Cartridge Drive Standards, Inc.
37 * 311 East Carrillo Street
38 * Santa Barbara, California 93101
39 * Telephone (805) 963-3853
40 * Fax (805) 962-1541
41 * WWW http://www.qic.org
42 *
43 * Current QIC standard revisions (of interest) are:
44 * QIC-40-MC, Rev. M, 2 Sep 92.
45 * QIC-80-MC, Rev. N, 20 Mar 96.
46 * QIC-80-MC, Rev. K, 15 Dec 94.
47 * QIC-113, Rev. G, 15 Jun 95.
48 * QIC-117, Rev. J, 28 Aug 96.
49 * QIC-122, Rev. B, 6 Mar 91.
50 * QIC-130, Rev. C, 2 Sep 92.
51 * QIC-3010-MC, Rev. F, 14 Jun 95.
52 * QIC-3020-MC, Rev. G, 31 Aug 95.
53 * QIC-CRF3, Rev. B, 15 Jun 95.
54 * */
55
56/*
57 * QIC-117 common command set rev. J.
58 * These commands are sent to the tape unit
59 * as number of pulses over the step line.
60 */
61
62typedef enum {
63 QIC_NO_COMMAND = 0,
64 QIC_RESET = 1,
65 QIC_REPORT_NEXT_BIT = 2,
66 QIC_PAUSE = 3,
67 QIC_MICRO_STEP_PAUSE = 4,
68 QIC_ALTERNATE_TIMEOUT = 5,
69 QIC_REPORT_DRIVE_STATUS = 6,
70 QIC_REPORT_ERROR_CODE = 7,
71 QIC_REPORT_DRIVE_CONFIGURATION = 8,
72 QIC_REPORT_ROM_VERSION = 9,
73 QIC_LOGICAL_FORWARD = 10,
74 QIC_PHYSICAL_REVERSE = 11,
75 QIC_PHYSICAL_FORWARD = 12,
76 QIC_SEEK_HEAD_TO_TRACK = 13,
77 QIC_SEEK_LOAD_POINT = 14,
78 QIC_ENTER_FORMAT_MODE = 15,
79 QIC_WRITE_REFERENCE_BURST = 16,
80 QIC_ENTER_VERIFY_MODE = 17,
81 QIC_STOP_TAPE = 18,
82/* commands 19-20: reserved */
83 QIC_MICRO_STEP_HEAD_UP = 21,
84 QIC_MICRO_STEP_HEAD_DOWN = 22,
85 QIC_SOFT_SELECT = 23,
86 QIC_SOFT_DESELECT = 24,
87 QIC_SKIP_REVERSE = 25,
88 QIC_SKIP_FORWARD = 26,
89 QIC_SELECT_RATE = 27,
90/* command 27, in ccs2: Select Rate or Format */
91 QIC_ENTER_DIAGNOSTIC_1 = 28,
92 QIC_ENTER_DIAGNOSTIC_2 = 29,
93 QIC_ENTER_PRIMARY_MODE = 30,
94/* command 31: vendor unique */
95 QIC_REPORT_VENDOR_ID = 32,
96 QIC_REPORT_TAPE_STATUS = 33,
97 QIC_SKIP_EXTENDED_REVERSE = 34,
98 QIC_SKIP_EXTENDED_FORWARD = 35,
99 QIC_CALIBRATE_TAPE_LENGTH = 36,
100 QIC_REPORT_FORMAT_SEGMENTS = 37,
101 QIC_SET_FORMAT_SEGMENTS = 38,
102/* commands 39-45: reserved */
103 QIC_PHANTOM_SELECT = 46,
104 QIC_PHANTOM_DESELECT = 47
105} qic117_cmd_t;
106
107typedef enum {
108 discretional = 0, required, ccs1, ccs2
109} qic_compatibility;
110
111typedef enum {
112 unused, mode, motion, report
113} command_types;
114
115struct qic117_command_table {
116 char *name;
117 __u8 mask;
118 __u8 state;
119 __u8 cmd_type;
120 __u8 non_intr;
121 __u8 level;
122};
123
124#define QIC117_COMMANDS {\
125/* command mask state cmd_type */\
126/* | name | | | non_intr */\
127/* | | | | | | level */\
128/* 0*/ {NULL, 0x00, 0x00, mode, 0, discretional},\
129/* 1*/ {"soft reset", 0x00, 0x00, motion, 1, required},\
130/* 2*/ {"report next bit", 0x00, 0x00, report, 0, required},\
131/* 3*/ {"pause", 0x36, 0x24, motion, 1, required},\
132/* 4*/ {"micro step pause", 0x36, 0x24, motion, 1, required},\
133/* 5*/ {"alternate command timeout", 0x00, 0x00, mode, 0, required},\
134/* 6*/ {"report drive status", 0x00, 0x00, report, 0, required},\
135/* 7*/ {"report error code", 0x01, 0x01, report, 0, required},\
136/* 8*/ {"report drive configuration",0x00, 0x00, report, 0, required},\
137/* 9*/ {"report rom version", 0x00, 0x00, report, 0, required},\
138/*10*/ {"logical forward", 0x37, 0x25, motion, 0, required},\
139/*11*/ {"physical reverse", 0x17, 0x05, motion, 0, required},\
140/*12*/ {"physical forward", 0x17, 0x05, motion, 0, required},\
141/*13*/ {"seek head to track", 0x37, 0x25, motion, 0, required},\
142/*14*/ {"seek load point", 0x17, 0x05, motion, 1, required},\
143/*15*/ {"enter format mode", 0x1f, 0x05, mode, 0, required},\
144/*16*/ {"write reference burst", 0x1f, 0x05, motion, 1, required},\
145/*17*/ {"enter verify mode", 0x37, 0x25, mode, 0, required},\
146/*18*/ {"stop tape", 0x00, 0x00, motion, 1, required},\
147/*19*/ {"reserved (19)", 0x00, 0x00, unused, 0, discretional},\
148/*20*/ {"reserved (20)", 0x00, 0x00, unused, 0, discretional},\
149/*21*/ {"micro step head up", 0x02, 0x00, motion, 0, required},\
150/*22*/ {"micro step head down", 0x02, 0x00, motion, 0, required},\
151/*23*/ {"soft select", 0x00, 0x00, mode, 0, discretional},\
152/*24*/ {"soft deselect", 0x00, 0x00, mode, 0, discretional},\
153/*25*/ {"skip segments reverse", 0x36, 0x24, motion, 1, required},\
154/*26*/ {"skip segments forward", 0x36, 0x24, motion, 1, required},\
155/*27*/ {"select rate or format", 0x03, 0x01, mode, 0, required /* [ccs2] */},\
156/*28*/ {"enter diag mode 1", 0x00, 0x00, mode, 0, discretional},\
157/*29*/ {"enter diag mode 2", 0x00, 0x00, mode, 0, discretional},\
158/*30*/ {"enter primary mode", 0x00, 0x00, mode, 0, required},\
159/*31*/ {"vendor unique (31)", 0x00, 0x00, unused, 0, discretional},\
160/*32*/ {"report vendor id", 0x00, 0x00, report, 0, required},\
161/*33*/ {"report tape status", 0x04, 0x04, report, 0, ccs1},\
162/*34*/ {"skip extended reverse", 0x36, 0x24, motion, 1, ccs1},\
163/*35*/ {"skip extended forward", 0x36, 0x24, motion, 1, ccs1},\
164/*36*/ {"calibrate tape length", 0x17, 0x05, motion, 1, ccs2},\
165/*37*/ {"report format segments", 0x17, 0x05, report, 0, ccs2},\
166/*38*/ {"set format segments", 0x17, 0x05, mode, 0, ccs2},\
167/*39*/ {"reserved (39)", 0x00, 0x00, unused, 0, discretional},\
168/*40*/ {"vendor unique (40)", 0x00, 0x00, unused, 0, discretional},\
169/*41*/ {"vendor unique (41)", 0x00, 0x00, unused, 0, discretional},\
170/*42*/ {"vendor unique (42)", 0x00, 0x00, unused, 0, discretional},\
171/*43*/ {"vendor unique (43)", 0x00, 0x00, unused, 0, discretional},\
172/*44*/ {"vendor unique (44)", 0x00, 0x00, unused, 0, discretional},\
173/*45*/ {"vendor unique (45)", 0x00, 0x00, unused, 0, discretional},\
174/*46*/ {"phantom select", 0x00, 0x00, mode, 0, discretional},\
175/*47*/ {"phantom deselect", 0x00, 0x00, mode, 0, discretional},\
176}
177
178/*
179 * Status bits returned by QIC_REPORT_DRIVE_STATUS
180 */
181
182#define QIC_STATUS_READY 0x01 /* Drive is ready or idle. */
183#define QIC_STATUS_ERROR 0x02 /* Error detected, must read
184 error code to clear this */
185#define QIC_STATUS_CARTRIDGE_PRESENT 0x04 /* Tape is present */
186#define QIC_STATUS_WRITE_PROTECT 0x08 /* Tape is write protected */
187#define QIC_STATUS_NEW_CARTRIDGE 0x10 /* New cartridge inserted, must
188 read error status to clear. */
189#define QIC_STATUS_REFERENCED 0x20 /* Cartridge appears to have been
190 formatted. */
191#define QIC_STATUS_AT_BOT 0x40 /* Cartridge is at physical
192 beginning of tape. */
193#define QIC_STATUS_AT_EOT 0x80 /* Cartridge is at physical end
194 of tape. */
195/*
196 * Status bits returned by QIC_REPORT_DRIVE_CONFIGURATION
197 */
198
199#define QIC_CONFIG_RATE_MASK 0x18
200#define QIC_CONFIG_RATE_SHIFT 3
201#define QIC_CONFIG_RATE_250 0
202#define QIC_CONFIG_RATE_500 2
203#define QIC_CONFIG_RATE_1000 3
204#define QIC_CONFIG_RATE_2000 1
205#define QIC_CONFIG_RATE_4000 0 /* since QIC-117 Rev. J */
206
207#define QIC_CONFIG_LONG 0x40 /* Extra Length Tape Detected */
208#define QIC_CONFIG_80 0x80 /* QIC-80 detected. */
209
210/*
211 * Status bits returned by QIC_REPORT_TAPE_STATUS
212 */
213
214#define QIC_TAPE_STD_MASK 0x0f
215#define QIC_TAPE_QIC40 0x01
216#define QIC_TAPE_QIC80 0x02
217#define QIC_TAPE_QIC3020 0x03
218#define QIC_TAPE_QIC3010 0x04
219
220#define QIC_TAPE_LEN_MASK 0x70
221#define QIC_TAPE_205FT 0x10
222#define QIC_TAPE_307FT 0x20
223#define QIC_TAPE_VARIABLE 0x30
224#define QIC_TAPE_1100FT 0x40
225#define QIC_TAPE_FLEX 0x60
226
227#define QIC_TAPE_WIDE 0x80
228
229/* Define a value (in feet) slightly higher than
230 * the possible maximum tape length.
231 */
232#define QIC_TOP_TAPE_LEN 1500
233
234/*
235 * Errors: List of error codes, and their severity.
236 */
237
238typedef struct {
239 char *message; /* Text describing the error. */
240 unsigned int fatal:1; /* Non-zero if the error is fatal. */
241} ftape_error;
242
243#define QIC117_ERRORS {\
244 /* 0*/ { "No error", 0, },\
245 /* 1*/ { "Command Received while Drive Not Ready", 0, },\
246 /* 2*/ { "Cartridge Not Present or Removed", 1, },\
247 /* 3*/ { "Motor Speed Error (not within 1%)", 1, },\
248 /* 4*/ { "Motor Speed Fault (jammed, or gross speed error", 1, },\
249 /* 5*/ { "Cartridge Write Protected", 1, },\
250 /* 6*/ { "Undefined or Reserved Command Code", 1, },\
251 /* 7*/ { "Illegal Track Address Specified for Seek", 1, },\
252 /* 8*/ { "Illegal Command in Report Subcontext", 0, },\
253 /* 9*/ { "Illegal Entry into a Diagnostic Mode", 1, },\
254 /*10*/ { "Broken Tape Detected (based on hole sensor)", 1, },\
255 /*11*/ { "Warning--Read Gain Setting Error", 1, },\
256 /*12*/ { "Command Received While Error Status Pending (obs)", 1, },\
257 /*13*/ { "Command Received While New Cartridge Pending", 1, },\
258 /*14*/ { "Command Illegal or Undefined in Primary Mode", 1, },\
259 /*15*/ { "Command Illegal or Undefined in Format Mode", 1, },\
260 /*16*/ { "Command Illegal or Undefined in Verify Mode", 1, },\
261 /*17*/ { "Logical Forward Not at Logical BOT or no Format Segments in Format Mode", 1, },\
262 /*18*/ { "Logical EOT Before All Segments generated", 1, },\
263 /*19*/ { "Command Illegal When Cartridge Not Referenced", 1, },\
264 /*20*/ { "Self-Diagnostic Failed (cannot be cleared)", 1, },\
265 /*21*/ { "Warning EEPROM Not Initialized, Defaults Set", 1, },\
266 /*22*/ { "EEPROM Corrupted or Hardware Failure", 1, },\
267 /*23*/ { "Motion Time-out Error", 1, },\
268 /*24*/ { "Data Segment Too Long -- Logical Forward or Pause", 1, },\
269 /*25*/ { "Transmit Overrun (obs)", 1, },\
270 /*26*/ { "Power On Reset Occurred", 0, },\
271 /*27*/ { "Software Reset Occurred", 0, },\
272 /*28*/ { "Diagnostic Mode 1 Error", 1, },\
273 /*29*/ { "Diagnostic Mode 2 Error", 1, },\
274 /*30*/ { "Command Received During Non-Interruptible Process", 1, },\
275 /*31*/ { "Rate or Format Selection Error", 1, },\
276 /*32*/ { "Illegal Command While in High Speed Mode", 1, },\
277 /*33*/ { "Illegal Seek Segment Value", 1, },\
278 /*34*/ { "Invalid Media", 1, },\
279 /*35*/ { "Head Positioning Failure", 1, },\
280 /*36*/ { "Write Reference Burst Failure", 1, },\
281 /*37*/ { "Prom Code Missing", 1, },\
282 /*38*/ { "Invalid Format", 1, },\
283 /*39*/ { "EOT/BOT System Failure", 1, },\
284 /*40*/ { "Prom A Checksum Error", 1, },\
285 /*41*/ { "Drive Wakeup Reset Occurred", 1, },\
286 /*42*/ { "Prom B Checksum Error", 1, },\
287 /*43*/ { "Illegal Entry into Format Mode", 1, },\
288}
289
290#endif /* _QIC117_H */
diff --git a/include/linux/qnx4_fs.h b/include/linux/qnx4_fs.h
new file mode 100644
index 000000000000..22ba580b0ae8
--- /dev/null
+++ b/include/linux/qnx4_fs.h
@@ -0,0 +1,150 @@
1/*
2 * Name : qnx4_fs.h
3 * Author : Richard Frowijn
4 * Function : qnx4 global filesystem definitions
5 * Version : 1.0.2
6 * Last modified : 2000-01-31
7 *
8 * History : 23-03-1998 created
9 */
10#ifndef _LINUX_QNX4_FS_H
11#define _LINUX_QNX4_FS_H
12
13#include <linux/qnxtypes.h>
14
15#define QNX4_ROOT_INO 1
16
17#define QNX4_MAX_XTNTS_PER_XBLK 60
18/* for di_status */
19#define QNX4_FILE_USED 0x01
20#define QNX4_FILE_MODIFIED 0x02
21#define QNX4_FILE_BUSY 0x04
22#define QNX4_FILE_LINK 0x08
23#define QNX4_FILE_INODE 0x10
24#define QNX4_FILE_FSYSCLEAN 0x20
25
26#define QNX4_I_MAP_SLOTS 8
27#define QNX4_Z_MAP_SLOTS 64
28#define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
29#define QNX4_VALID_FS 0x0001 /* Clean fs. */
30#define QNX4_ERROR_FS 0x0002 /* fs has errors. */
31#define QNX4_BLOCK_SIZE 0x200 /* blocksize of 512 bytes */
32#define QNX4_BLOCK_SIZE_BITS 9 /* blocksize shift */
33#define QNX4_DIR_ENTRY_SIZE 0x040 /* dir entry size of 64 bytes */
34#define QNX4_DIR_ENTRY_SIZE_BITS 6 /* dir entry size shift */
35#define QNX4_XBLK_ENTRY_SIZE 0x200 /* xblk entry size */
36#define QNX4_INODES_PER_BLOCK 0x08 /* 512 / 64 */
37
38/* for filenames */
39#define QNX4_SHORT_NAME_MAX 16
40#define QNX4_NAME_MAX 48
41
42/*
43 * This is the original qnx4 inode layout on disk.
44 */
45struct qnx4_inode_entry {
46 char di_fname[QNX4_SHORT_NAME_MAX];
47 qnx4_off_t di_size;
48 qnx4_xtnt_t di_first_xtnt;
49 __u32 di_xblk;
50 __s32 di_ftime;
51 __s32 di_mtime;
52 __s32 di_atime;
53 __s32 di_ctime;
54 qnx4_nxtnt_t di_num_xtnts;
55 qnx4_mode_t di_mode;
56 qnx4_muid_t di_uid;
57 qnx4_mgid_t di_gid;
58 qnx4_nlink_t di_nlink;
59 __u8 di_zero[4];
60 qnx4_ftype_t di_type;
61 __u8 di_status;
62};
63
64struct qnx4_link_info {
65 char dl_fname[QNX4_NAME_MAX];
66 __u32 dl_inode_blk;
67 __u8 dl_inode_ndx;
68 __u8 dl_spare[10];
69 __u8 dl_status;
70};
71
72struct qnx4_xblk {
73 __u32 xblk_next_xblk;
74 __u32 xblk_prev_xblk;
75 __u8 xblk_num_xtnts;
76 __u8 xblk_spare[3];
77 __s32 xblk_num_blocks;
78 qnx4_xtnt_t xblk_xtnts[QNX4_MAX_XTNTS_PER_XBLK];
79 char xblk_signature[8];
80 qnx4_xtnt_t xblk_first_xtnt;
81};
82
83struct qnx4_super_block {
84 struct qnx4_inode_entry RootDir;
85 struct qnx4_inode_entry Inode;
86 struct qnx4_inode_entry Boot;
87 struct qnx4_inode_entry AltBoot;
88};
89
90#ifdef __KERNEL__
91
92#define QNX4_DEBUG 0
93
94#if QNX4_DEBUG
95#define QNX4DEBUG(X) printk X
96#else
97#define QNX4DEBUG(X) (void) 0
98#endif
99
100struct qnx4_sb_info {
101 struct buffer_head *sb_buf; /* superblock buffer */
102 struct qnx4_super_block *sb; /* our superblock */
103 unsigned int Version; /* may be useful */
104 struct qnx4_inode_entry *BitMap; /* useful */
105};
106
107struct qnx4_inode_info {
108 struct qnx4_inode_entry raw;
109 loff_t mmu_private;
110 struct inode vfs_inode;
111};
112
113extern struct dentry *qnx4_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd);
114extern unsigned long qnx4_count_free_blocks(struct super_block *sb);
115extern unsigned long qnx4_block_map(struct inode *inode, long iblock);
116
117extern struct buffer_head *qnx4_bread(struct inode *, int, int);
118
119extern struct inode_operations qnx4_file_inode_operations;
120extern struct inode_operations qnx4_dir_inode_operations;
121extern struct file_operations qnx4_file_operations;
122extern struct file_operations qnx4_dir_operations;
123extern int qnx4_is_free(struct super_block *sb, long block);
124extern int qnx4_set_bitmap(struct super_block *sb, long block, int busy);
125extern int qnx4_create(struct inode *inode, struct dentry *dentry, int mode, struct nameidata *nd);
126extern void qnx4_truncate(struct inode *inode);
127extern void qnx4_free_inode(struct inode *inode);
128extern int qnx4_unlink(struct inode *dir, struct dentry *dentry);
129extern int qnx4_rmdir(struct inode *dir, struct dentry *dentry);
130extern int qnx4_sync_file(struct file *file, struct dentry *dentry, int);
131extern int qnx4_sync_inode(struct inode *inode);
132
133static inline struct qnx4_sb_info *qnx4_sb(struct super_block *sb)
134{
135 return sb->s_fs_info;
136}
137
138static inline struct qnx4_inode_info *qnx4_i(struct inode *inode)
139{
140 return container_of(inode, struct qnx4_inode_info, vfs_inode);
141}
142
143static inline struct qnx4_inode_entry *qnx4_raw_inode(struct inode *inode)
144{
145 return &qnx4_i(inode)->raw;
146}
147
148#endif /* __KERNEL__ */
149
150#endif
diff --git a/include/linux/qnxtypes.h b/include/linux/qnxtypes.h
new file mode 100644
index 000000000000..fb518e318c7c
--- /dev/null
+++ b/include/linux/qnxtypes.h
@@ -0,0 +1,29 @@
1/*
2 * Name : qnxtypes.h
3 * Author : Richard Frowijn
4 * Function : standard qnx types
5 * Version : 1.0.2
6 * Last modified : 2000-01-06
7 *
8 * History : 22-03-1998 created
9 *
10 */
11
12#ifndef _QNX4TYPES_H
13#define _QNX4TYPES_H
14
15typedef __u16 qnx4_nxtnt_t;
16typedef __u8 qnx4_ftype_t;
17
18typedef struct {
19 __u32 xtnt_blk;
20 __u32 xtnt_size;
21} qnx4_xtnt_t;
22
23typedef __u16 qnx4_mode_t;
24typedef __u16 qnx4_muid_t;
25typedef __u16 qnx4_mgid_t;
26typedef __u32 qnx4_off_t;
27typedef __u16 qnx4_nlink_t;
28
29#endif
diff --git a/include/linux/quota.h b/include/linux/quota.h
new file mode 100644
index 000000000000..ac5b90f4f256
--- /dev/null
+++ b/include/linux/quota.h
@@ -0,0 +1,327 @@
1/*
2 * Copyright (c) 1982, 1986 Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Robert Elz at The University of Melbourne.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the University nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * Version: $Id: quota.h,v 2.0 1996/11/17 16:48:14 mvw Exp mvw $
33 */
34
35#ifndef _LINUX_QUOTA_
36#define _LINUX_QUOTA_
37
38#include <linux/errno.h>
39#include <linux/types.h>
40#include <linux/spinlock.h>
41
42#define __DQUOT_VERSION__ "dquot_6.5.1"
43#define __DQUOT_NUM_VERSION__ 6*10000+5*100+1
44
45typedef __kernel_uid32_t qid_t; /* Type in which we store ids in memory */
46typedef __u64 qsize_t; /* Type in which we store sizes */
47
48extern spinlock_t dq_data_lock;
49
50/* Size of blocks in which are counted size limits */
51#define QUOTABLOCK_BITS 10
52#define QUOTABLOCK_SIZE (1 << QUOTABLOCK_BITS)
53
54/* Conversion routines from and to quota blocks */
55#define qb2kb(x) ((x) << (QUOTABLOCK_BITS-10))
56#define kb2qb(x) ((x) >> (QUOTABLOCK_BITS-10))
57#define toqb(x) (((x) + QUOTABLOCK_SIZE - 1) >> QUOTABLOCK_BITS)
58
59#define MAXQUOTAS 2
60#define USRQUOTA 0 /* element used for user quotas */
61#define GRPQUOTA 1 /* element used for group quotas */
62
63/*
64 * Definitions for the default names of the quotas files.
65 */
66#define INITQFNAMES { \
67 "user", /* USRQUOTA */ \
68 "group", /* GRPQUOTA */ \
69 "undefined", \
70};
71
72/*
73 * Command definitions for the 'quotactl' system call.
74 * The commands are broken into a main command defined below
75 * and a subcommand that is used to convey the type of
76 * quota that is being manipulated (see above).
77 */
78#define SUBCMDMASK 0x00ff
79#define SUBCMDSHIFT 8
80#define QCMD(cmd, type) (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK))
81
82#define Q_SYNC 0x800001 /* sync disk copy of a filesystems quotas */
83#define Q_QUOTAON 0x800002 /* turn quotas on */
84#define Q_QUOTAOFF 0x800003 /* turn quotas off */
85#define Q_GETFMT 0x800004 /* get quota format used on given filesystem */
86#define Q_GETINFO 0x800005 /* get information about quota files */
87#define Q_SETINFO 0x800006 /* set information about quota files */
88#define Q_GETQUOTA 0x800007 /* get user quota structure */
89#define Q_SETQUOTA 0x800008 /* set user quota structure */
90
91/*
92 * Quota structure used for communication with userspace via quotactl
93 * Following flags are used to specify which fields are valid
94 */
95#define QIF_BLIMITS 1
96#define QIF_SPACE 2
97#define QIF_ILIMITS 4
98#define QIF_INODES 8
99#define QIF_BTIME 16
100#define QIF_ITIME 32
101#define QIF_LIMITS (QIF_BLIMITS | QIF_ILIMITS)
102#define QIF_USAGE (QIF_SPACE | QIF_INODES)
103#define QIF_TIMES (QIF_BTIME | QIF_ITIME)
104#define QIF_ALL (QIF_LIMITS | QIF_USAGE | QIF_TIMES)
105
106struct if_dqblk {
107 __u64 dqb_bhardlimit;
108 __u64 dqb_bsoftlimit;
109 __u64 dqb_curspace;
110 __u64 dqb_ihardlimit;
111 __u64 dqb_isoftlimit;
112 __u64 dqb_curinodes;
113 __u64 dqb_btime;
114 __u64 dqb_itime;
115 __u32 dqb_valid;
116};
117
118/*
119 * Structure used for setting quota information about file via quotactl
120 * Following flags are used to specify which fields are valid
121 */
122#define IIF_BGRACE 1
123#define IIF_IGRACE 2
124#define IIF_FLAGS 4
125#define IIF_ALL (IIF_BGRACE | IIF_IGRACE | IIF_FLAGS)
126
127struct if_dqinfo {
128 __u64 dqi_bgrace;
129 __u64 dqi_igrace;
130 __u32 dqi_flags;
131 __u32 dqi_valid;
132};
133
134#ifdef __KERNEL__
135
136#include <linux/dqblk_xfs.h>
137#include <linux/dqblk_v1.h>
138#include <linux/dqblk_v2.h>
139
140/* Maximal numbers of writes for quota operation (insert/delete/update)
141 * (over all formats) - info block, 4 pointer blocks, data block */
142#define DQUOT_MAX_WRITES 6
143
144/*
145 * Data for one user/group kept in memory
146 */
147struct mem_dqblk {
148 __u32 dqb_bhardlimit; /* absolute limit on disk blks alloc */
149 __u32 dqb_bsoftlimit; /* preferred limit on disk blks */
150 qsize_t dqb_curspace; /* current used space */
151 __u32 dqb_ihardlimit; /* absolute limit on allocated inodes */
152 __u32 dqb_isoftlimit; /* preferred inode limit */
153 __u32 dqb_curinodes; /* current # allocated inodes */
154 time_t dqb_btime; /* time limit for excessive disk use */
155 time_t dqb_itime; /* time limit for excessive inode use */
156};
157
158/*
159 * Data for one quotafile kept in memory
160 */
161struct quota_format_type;
162
163struct mem_dqinfo {
164 struct quota_format_type *dqi_format;
165 struct list_head dqi_dirty_list; /* List of dirty dquots */
166 unsigned long dqi_flags;
167 unsigned int dqi_bgrace;
168 unsigned int dqi_igrace;
169 union {
170 struct v1_mem_dqinfo v1_i;
171 struct v2_mem_dqinfo v2_i;
172 } u;
173};
174
175struct super_block;
176
177#define DQF_MASK 0xffff /* Mask for format specific flags */
178#define DQF_INFO_DIRTY_B 16
179#define DQF_INFO_DIRTY (1 << DQF_INFO_DIRTY_B) /* Is info dirty? */
180
181extern void mark_info_dirty(struct super_block *sb, int type);
182#define info_dirty(info) test_bit(DQF_INFO_DIRTY_B, &(info)->dqi_flags)
183#define info_any_dquot_dirty(info) (!list_empty(&(info)->dqi_dirty_list))
184#define info_any_dirty(info) (info_dirty(info) || info_any_dquot_dirty(info))
185
186#define sb_dqopt(sb) (&(sb)->s_dquot)
187#define sb_dqinfo(sb, type) (sb_dqopt(sb)->info+(type))
188
189struct dqstats {
190 int lookups;
191 int drops;
192 int reads;
193 int writes;
194 int cache_hits;
195 int allocated_dquots;
196 int free_dquots;
197 int syncs;
198};
199
200extern struct dqstats dqstats;
201
202#define DQ_MOD_B 0 /* dquot modified since read */
203#define DQ_BLKS_B 1 /* uid/gid has been warned about blk limit */
204#define DQ_INODES_B 2 /* uid/gid has been warned about inode limit */
205#define DQ_FAKE_B 3 /* no limits only usage */
206#define DQ_READ_B 4 /* dquot was read into memory */
207#define DQ_ACTIVE_B 5 /* dquot is active (dquot_release not called) */
208#define DQ_WAITFREE_B 6 /* dquot being waited (by invalidate_dquots) */
209
210struct dquot {
211 struct hlist_node dq_hash; /* Hash list in memory */
212 struct list_head dq_inuse; /* List of all quotas */
213 struct list_head dq_free; /* Free list element */
214 struct list_head dq_dirty; /* List of dirty dquots */
215 struct semaphore dq_lock; /* dquot IO lock */
216 atomic_t dq_count; /* Use count */
217 wait_queue_head_t dq_wait_unused; /* Wait queue for dquot to become unused */
218 struct super_block *dq_sb; /* superblock this applies to */
219 unsigned int dq_id; /* ID this applies to (uid, gid) */
220 loff_t dq_off; /* Offset of dquot on disk */
221 unsigned long dq_flags; /* See DQ_* */
222 short dq_type; /* Type of quota */
223 struct mem_dqblk dq_dqb; /* Diskquota usage */
224};
225
226#define NODQUOT (struct dquot *)NULL
227
228#define QUOTA_OK 0
229#define NO_QUOTA 1
230
231/* Operations which must be implemented by each quota format */
232struct quota_format_ops {
233 int (*check_quota_file)(struct super_block *sb, int type); /* Detect whether file is in our format */
234 int (*read_file_info)(struct super_block *sb, int type); /* Read main info about file - called on quotaon() */
235 int (*write_file_info)(struct super_block *sb, int type); /* Write main info about file */
236 int (*free_file_info)(struct super_block *sb, int type); /* Called on quotaoff() */
237 int (*read_dqblk)(struct dquot *dquot); /* Read structure for one user */
238 int (*commit_dqblk)(struct dquot *dquot); /* Write structure for one user */
239 int (*release_dqblk)(struct dquot *dquot); /* Called when last reference to dquot is being dropped */
240};
241
242/* Operations working with dquots */
243struct dquot_operations {
244 int (*initialize) (struct inode *, int);
245 int (*drop) (struct inode *);
246 int (*alloc_space) (struct inode *, qsize_t, int);
247 int (*alloc_inode) (const struct inode *, unsigned long);
248 int (*free_space) (struct inode *, qsize_t);
249 int (*free_inode) (const struct inode *, unsigned long);
250 int (*transfer) (struct inode *, struct iattr *);
251 int (*write_dquot) (struct dquot *); /* Ordinary dquot write */
252 int (*acquire_dquot) (struct dquot *); /* Quota is going to be created on disk */
253 int (*release_dquot) (struct dquot *); /* Quota is going to be deleted from disk */
254 int (*mark_dirty) (struct dquot *); /* Dquot is marked dirty */
255 int (*write_info) (struct super_block *, int); /* Write of quota "superblock" */
256};
257
258/* Operations handling requests from userspace */
259struct quotactl_ops {
260 int (*quota_on)(struct super_block *, int, int, char *);
261 int (*quota_off)(struct super_block *, int);
262 int (*quota_sync)(struct super_block *, int);
263 int (*get_info)(struct super_block *, int, struct if_dqinfo *);
264 int (*set_info)(struct super_block *, int, struct if_dqinfo *);
265 int (*get_dqblk)(struct super_block *, int, qid_t, struct if_dqblk *);
266 int (*set_dqblk)(struct super_block *, int, qid_t, struct if_dqblk *);
267 int (*get_xstate)(struct super_block *, struct fs_quota_stat *);
268 int (*set_xstate)(struct super_block *, unsigned int, int);
269 int (*get_xquota)(struct super_block *, int, qid_t, struct fs_disk_quota *);
270 int (*set_xquota)(struct super_block *, int, qid_t, struct fs_disk_quota *);
271};
272
273struct quota_format_type {
274 int qf_fmt_id; /* Quota format id */
275 struct quota_format_ops *qf_ops; /* Operations of format */
276 struct module *qf_owner; /* Module implementing quota format */
277 struct quota_format_type *qf_next;
278};
279
280#define DQUOT_USR_ENABLED 0x01 /* User diskquotas enabled */
281#define DQUOT_GRP_ENABLED 0x02 /* Group diskquotas enabled */
282
283struct quota_info {
284 unsigned int flags; /* Flags for diskquotas on this device */
285 struct semaphore dqio_sem; /* lock device while I/O in progress */
286 struct semaphore dqonoff_sem; /* Serialize quotaon & quotaoff */
287 struct rw_semaphore dqptr_sem; /* serialize ops using quota_info struct, pointers from inode to dquots */
288 struct inode *files[MAXQUOTAS]; /* inodes of quotafiles */
289 struct vfsmount *mnt[MAXQUOTAS]; /* mountpoint entries of filesystems with quota files */
290 struct mem_dqinfo info[MAXQUOTAS]; /* Information for each quota type */
291 struct quota_format_ops *ops[MAXQUOTAS]; /* Operations for each type */
292};
293
294/* Inline would be better but we need to dereference super_block which is not defined yet */
295int mark_dquot_dirty(struct dquot *dquot);
296
297#define dquot_dirty(dquot) test_bit(DQ_MOD_B, &(dquot)->dq_flags)
298
299#define sb_has_quota_enabled(sb, type) ((type)==USRQUOTA ? \
300 (sb_dqopt(sb)->flags & DQUOT_USR_ENABLED) : (sb_dqopt(sb)->flags & DQUOT_GRP_ENABLED))
301
302#define sb_any_quota_enabled(sb) (sb_has_quota_enabled(sb, USRQUOTA) | \
303 sb_has_quota_enabled(sb, GRPQUOTA))
304
305int register_quota_format(struct quota_format_type *fmt);
306void unregister_quota_format(struct quota_format_type *fmt);
307
308struct quota_module_name {
309 int qm_fmt_id;
310 char *qm_mod_name;
311};
312
313#define INIT_QUOTA_MODULE_NAMES {\
314 {QFMT_VFS_OLD, "quota_v1"},\
315 {QFMT_VFS_V0, "quota_v2"},\
316 {0, NULL}}
317
318#else
319
320# /* nodep */ include <sys/cdefs.h>
321
322__BEGIN_DECLS
323long quotactl __P ((unsigned int, const char *, int, caddr_t));
324__END_DECLS
325
326#endif /* __KERNEL__ */
327#endif /* _QUOTA_ */
diff --git a/include/linux/quotaio_v1.h b/include/linux/quotaio_v1.h
new file mode 100644
index 000000000000..746654b5de70
--- /dev/null
+++ b/include/linux/quotaio_v1.h
@@ -0,0 +1,33 @@
1#ifndef _LINUX_QUOTAIO_V1_H
2#define _LINUX_QUOTAIO_V1_H
3
4#include <linux/types.h>
5
6/*
7 * The following constants define the amount of time given a user
8 * before the soft limits are treated as hard limits (usually resulting
9 * in an allocation failure). The timer is started when the user crosses
10 * their soft limit, it is reset when they go below their soft limit.
11 */
12#define MAX_IQ_TIME 604800 /* (7*24*60*60) 1 week */
13#define MAX_DQ_TIME 604800 /* (7*24*60*60) 1 week */
14
15/*
16 * The following structure defines the format of the disk quota file
17 * (as it appears on disk) - the file is an array of these structures
18 * indexed by user or group number.
19 */
20struct v1_disk_dqblk {
21 __u32 dqb_bhardlimit; /* absolute limit on disk blks alloc */
22 __u32 dqb_bsoftlimit; /* preferred limit on disk blks */
23 __u32 dqb_curblocks; /* current block count */
24 __u32 dqb_ihardlimit; /* absolute limit on allocated inodes */
25 __u32 dqb_isoftlimit; /* preferred inode limit */
26 __u32 dqb_curinodes; /* current # allocated inodes */
27 time_t dqb_btime; /* time limit for excessive disk use */
28 time_t dqb_itime; /* time limit for excessive inode use */
29};
30
31#define v1_dqoff(UID) ((loff_t)((UID) * sizeof (struct v1_disk_dqblk)))
32
33#endif /* _LINUX_QUOTAIO_V1_H */
diff --git a/include/linux/quotaio_v2.h b/include/linux/quotaio_v2.h
new file mode 100644
index 000000000000..303d7cbe30d4
--- /dev/null
+++ b/include/linux/quotaio_v2.h
@@ -0,0 +1,79 @@
1/*
2 * Definitions of structures for vfsv0 quota format
3 */
4
5#ifndef _LINUX_QUOTAIO_V2_H
6#define _LINUX_QUOTAIO_V2_H
7
8#include <linux/types.h>
9#include <linux/quota.h>
10
11/*
12 * Definitions of magics and versions of current quota files
13 */
14#define V2_INITQMAGICS {\
15 0xd9c01f11, /* USRQUOTA */\
16 0xd9c01927 /* GRPQUOTA */\
17}
18
19#define V2_INITQVERSIONS {\
20 0, /* USRQUOTA */\
21 0 /* GRPQUOTA */\
22}
23
24/*
25 * The following structure defines the format of the disk quota file
26 * (as it appears on disk) - the file is a radix tree whose leaves point
27 * to blocks of these structures.
28 */
29struct v2_disk_dqblk {
30 __le32 dqb_id; /* id this quota applies to */
31 __le32 dqb_ihardlimit; /* absolute limit on allocated inodes */
32 __le32 dqb_isoftlimit; /* preferred inode limit */
33 __le32 dqb_curinodes; /* current # allocated inodes */
34 __le32 dqb_bhardlimit; /* absolute limit on disk space (in QUOTABLOCK_SIZE) */
35 __le32 dqb_bsoftlimit; /* preferred limit on disk space (in QUOTABLOCK_SIZE) */
36 __le64 dqb_curspace; /* current space occupied (in bytes) */
37 __le64 dqb_btime; /* time limit for excessive disk use */
38 __le64 dqb_itime; /* time limit for excessive inode use */
39};
40
41/*
42 * Here are header structures as written on disk and their in-memory copies
43 */
44/* First generic header */
45struct v2_disk_dqheader {
46 __le32 dqh_magic; /* Magic number identifying file */
47 __le32 dqh_version; /* File version */
48};
49
50/* Header with type and version specific information */
51struct v2_disk_dqinfo {
52 __le32 dqi_bgrace; /* Time before block soft limit becomes hard limit */
53 __le32 dqi_igrace; /* Time before inode soft limit becomes hard limit */
54 __le32 dqi_flags; /* Flags for quotafile (DQF_*) */
55 __le32 dqi_blocks; /* Number of blocks in file */
56 __le32 dqi_free_blk; /* Number of first free block in the list */
57 __le32 dqi_free_entry; /* Number of block with at least one free entry */
58};
59
60/*
61 * Structure of header of block with quota structures. It is padded to 16 bytes so
62 * there will be space for exactly 21 quota-entries in a block
63 */
64struct v2_disk_dqdbheader {
65 __le32 dqdh_next_free; /* Number of next block with free entry */
66 __le32 dqdh_prev_free; /* Number of previous block with free entry */
67 __le16 dqdh_entries; /* Number of valid entries in block */
68 __le16 dqdh_pad1;
69 __le32 dqdh_pad2;
70};
71
72#define V2_DQINFOOFF sizeof(struct v2_disk_dqheader) /* Offset of info header in file */
73#define V2_DQBLKSIZE_BITS 10
74#define V2_DQBLKSIZE (1 << V2_DQBLKSIZE_BITS) /* Size of block with quota structures */
75#define V2_DQTREEOFF 1 /* Offset of tree in file in blocks */
76#define V2_DQTREEDEPTH 4 /* Depth of quota tree */
77#define V2_DQSTRINBLK ((V2_DQBLKSIZE - sizeof(struct v2_disk_dqdbheader)) / sizeof(struct v2_disk_dqblk)) /* Number of entries in one blocks */
78
79#endif /* _LINUX_QUOTAIO_V2_H */
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
new file mode 100644
index 000000000000..e57baa85e744
--- /dev/null
+++ b/include/linux/quotaops.h
@@ -0,0 +1,246 @@
1/*
2 * Definitions for diskquota-operations. When diskquota is configured these
3 * macros expand to the right source-code.
4 *
5 * Author: Marco van Wieringen <mvw@planets.elm.net>
6 *
7 * Version: $Id: quotaops.h,v 1.2 1998/01/15 16:22:26 ecd Exp $
8 *
9 */
10#ifndef _LINUX_QUOTAOPS_
11#define _LINUX_QUOTAOPS_
12
13#include <linux/config.h>
14#include <linux/smp_lock.h>
15
16#include <linux/fs.h>
17
18#if defined(CONFIG_QUOTA)
19
20/*
21 * declaration of quota_function calls in kernel.
22 */
23extern void sync_dquots(struct super_block *sb, int type);
24
25extern int dquot_initialize(struct inode *inode, int type);
26extern int dquot_drop(struct inode *inode);
27
28extern int dquot_alloc_space(struct inode *inode, qsize_t number, int prealloc);
29extern int dquot_alloc_inode(const struct inode *inode, unsigned long number);
30
31extern int dquot_free_space(struct inode *inode, qsize_t number);
32extern int dquot_free_inode(const struct inode *inode, unsigned long number);
33
34extern int dquot_transfer(struct inode *inode, struct iattr *iattr);
35extern int dquot_commit(struct dquot *dquot);
36extern int dquot_acquire(struct dquot *dquot);
37extern int dquot_release(struct dquot *dquot);
38extern int dquot_commit_info(struct super_block *sb, int type);
39extern int dquot_mark_dquot_dirty(struct dquot *dquot);
40
41extern int vfs_quota_on(struct super_block *sb, int type, int format_id, char *path);
42extern int vfs_quota_on_mount(int type, int format_id, struct dentry *dentry);
43extern int vfs_quota_off(struct super_block *sb, int type);
44#define vfs_quota_off_mount(sb, type) vfs_quota_off(sb, 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);
47extern int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii);
48extern int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di);
49extern int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di);
50
51/*
52 * Operations supported for diskquotas.
53 */
54extern struct dquot_operations dquot_operations;
55extern struct quotactl_ops vfs_quotactl_ops;
56
57#define sb_dquot_ops (&dquot_operations)
58#define sb_quotactl_ops (&vfs_quotactl_ops)
59
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. */
62static __inline__ void DQUOT_INIT(struct inode *inode)
63{
64 BUG_ON(!inode->i_sb);
65 if (sb_any_quota_enabled(inode->i_sb) && !IS_NOQUOTA(inode))
66 inode->i_sb->dq_op->initialize(inode, -1);
67}
68
69/* The same as with DQUOT_INIT */
70static __inline__ void DQUOT_DROP(struct inode *inode)
71{
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
74 * are allowed to change only at mount time */
75 if (!IS_NOQUOTA(inode) && inode->i_sb && inode->i_sb->dq_op
76 && inode->i_sb->dq_op->drop) {
77 int cnt;
78 /* Test before calling to rule out calls from proc and such
79 * where we are not allowed to block. Note that this is
80 * actually reliable test even without the lock - the caller
81 * must assure that nobody can come after the DQUOT_DROP and
82 * add quota pointers back anyway */
83 for (cnt = 0; cnt < MAXQUOTAS; cnt++)
84 if (inode->i_dquot[cnt] != NODQUOT)
85 break;
86 if (cnt < MAXQUOTAS)
87 inode->i_sb->dq_op->drop(inode);
88 }
89}
90
91/* The following allocation/freeing/transfer functions *must* be called inside
92 * a transaction (deadlocks possible otherwise) */
93static __inline__ int DQUOT_PREALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr)
94{
95 if (sb_any_quota_enabled(inode->i_sb)) {
96 /* Used space is updated in alloc_space() */
97 if (inode->i_sb->dq_op->alloc_space(inode, nr, 1) == NO_QUOTA)
98 return 1;
99 }
100 else
101 inode_add_bytes(inode, nr);
102 return 0;
103}
104
105static __inline__ int DQUOT_PREALLOC_SPACE(struct inode *inode, qsize_t nr)
106{
107 int ret;
108 if (!(ret = DQUOT_PREALLOC_SPACE_NODIRTY(inode, nr)))
109 mark_inode_dirty(inode);
110 return ret;
111}
112
113static __inline__ int DQUOT_ALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr)
114{
115 if (sb_any_quota_enabled(inode->i_sb)) {
116 /* Used space is updated in alloc_space() */
117 if (inode->i_sb->dq_op->alloc_space(inode, nr, 0) == NO_QUOTA)
118 return 1;
119 }
120 else
121 inode_add_bytes(inode, nr);
122 return 0;
123}
124
125static __inline__ int DQUOT_ALLOC_SPACE(struct inode *inode, qsize_t nr)
126{
127 int ret;
128 if (!(ret = DQUOT_ALLOC_SPACE_NODIRTY(inode, nr)))
129 mark_inode_dirty(inode);
130 return ret;
131}
132
133static __inline__ int DQUOT_ALLOC_INODE(struct inode *inode)
134{
135 if (sb_any_quota_enabled(inode->i_sb)) {
136 DQUOT_INIT(inode);
137 if (inode->i_sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA)
138 return 1;
139 }
140 return 0;
141}
142
143static __inline__ void DQUOT_FREE_SPACE_NODIRTY(struct inode *inode, qsize_t nr)
144{
145 if (sb_any_quota_enabled(inode->i_sb))
146 inode->i_sb->dq_op->free_space(inode, nr);
147 else
148 inode_sub_bytes(inode, nr);
149}
150
151static __inline__ void DQUOT_FREE_SPACE(struct inode *inode, qsize_t nr)
152{
153 DQUOT_FREE_SPACE_NODIRTY(inode, nr);
154 mark_inode_dirty(inode);
155}
156
157static __inline__ void DQUOT_FREE_INODE(struct inode *inode)
158{
159 if (sb_any_quota_enabled(inode->i_sb))
160 inode->i_sb->dq_op->free_inode(inode, 1);
161}
162
163static __inline__ int DQUOT_TRANSFER(struct inode *inode, struct iattr *iattr)
164{
165 if (sb_any_quota_enabled(inode->i_sb) && !IS_NOQUOTA(inode)) {
166 DQUOT_INIT(inode);
167 if (inode->i_sb->dq_op->transfer(inode, iattr) == NO_QUOTA)
168 return 1;
169 }
170 return 0;
171}
172
173/* The following two functions cannot be called inside a transaction */
174#define DQUOT_SYNC(sb) sync_dquots(sb, -1)
175
176static __inline__ int DQUOT_OFF(struct super_block *sb)
177{
178 int ret = -ENOSYS;
179
180 if (sb_any_quota_enabled(sb) && sb->s_qcop && sb->s_qcop->quota_off)
181 ret = sb->s_qcop->quota_off(sb, -1);
182 return ret;
183}
184
185#else
186
187/*
188 * NO-OP when quota not configured.
189 */
190#define sb_dquot_ops (NULL)
191#define sb_quotactl_ops (NULL)
192#define sync_dquots_dev(dev,type) (NULL)
193#define DQUOT_INIT(inode) do { } while(0)
194#define DQUOT_DROP(inode) do { } while(0)
195#define DQUOT_ALLOC_INODE(inode) (0)
196#define DQUOT_FREE_INODE(inode) do { } while(0)
197#define DQUOT_SYNC(sb) do { } while(0)
198#define DQUOT_OFF(sb) do { } while(0)
199#define DQUOT_TRANSFER(inode, iattr) (0)
200extern __inline__ int DQUOT_PREALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr)
201{
202 inode_add_bytes(inode, nr);
203 return 0;
204}
205
206extern __inline__ int DQUOT_PREALLOC_SPACE(struct inode *inode, qsize_t nr)
207{
208 DQUOT_PREALLOC_SPACE_NODIRTY(inode, nr);
209 mark_inode_dirty(inode);
210 return 0;
211}
212
213extern __inline__ int DQUOT_ALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr)
214{
215 inode_add_bytes(inode, nr);
216 return 0;
217}
218
219extern __inline__ int DQUOT_ALLOC_SPACE(struct inode *inode, qsize_t nr)
220{
221 DQUOT_ALLOC_SPACE_NODIRTY(inode, nr);
222 mark_inode_dirty(inode);
223 return 0;
224}
225
226extern __inline__ void DQUOT_FREE_SPACE_NODIRTY(struct inode *inode, qsize_t nr)
227{
228 inode_sub_bytes(inode, nr);
229}
230
231extern __inline__ void DQUOT_FREE_SPACE(struct inode *inode, qsize_t nr)
232{
233 DQUOT_FREE_SPACE_NODIRTY(inode, nr);
234 mark_inode_dirty(inode);
235}
236
237#endif /* CONFIG_QUOTA */
238
239#define DQUOT_PREALLOC_BLOCK_NODIRTY(inode, nr) DQUOT_PREALLOC_SPACE_NODIRTY(inode, ((qsize_t)(nr)) << (inode)->i_sb->s_blocksize_bits)
240#define DQUOT_PREALLOC_BLOCK(inode, nr) DQUOT_PREALLOC_SPACE(inode, ((qsize_t)(nr)) << (inode)->i_sb->s_blocksize_bits)
241#define DQUOT_ALLOC_BLOCK_NODIRTY(inode, nr) DQUOT_ALLOC_SPACE_NODIRTY(inode, ((qsize_t)(nr)) << (inode)->i_sb->s_blocksize_bits)
242#define DQUOT_ALLOC_BLOCK(inode, nr) DQUOT_ALLOC_SPACE(inode, ((qsize_t)(nr)) << (inode)->i_sb->s_blocksize_bits)
243#define DQUOT_FREE_BLOCK_NODIRTY(inode, nr) DQUOT_FREE_SPACE_NODIRTY(inode, ((qsize_t)(nr)) << (inode)->i_sb->s_blocksize_bits)
244#define DQUOT_FREE_BLOCK(inode, nr) DQUOT_FREE_SPACE(inode, ((qsize_t)(nr)) << (inode)->i_sb->s_blocksize_bits)
245
246#endif /* _LINUX_QUOTAOPS_ */
diff --git a/include/linux/radeonfb.h b/include/linux/radeonfb.h
new file mode 100644
index 000000000000..5bd8975ed78e
--- /dev/null
+++ b/include/linux/radeonfb.h
@@ -0,0 +1,15 @@
1#ifndef __LINUX_RADEONFB_H__
2#define __LINUX_RADEONFB_H__
3
4#include <asm/ioctl.h>
5#include <asm/types.h>
6
7#define ATY_RADEON_LCD_ON 0x00000001
8#define ATY_RADEON_CRT_ON 0x00000002
9
10
11#define FBIO_RADEON_GET_MIRROR _IOR('@', 3, size_t)
12#define FBIO_RADEON_SET_MIRROR _IOW('@', 4, size_t)
13
14#endif
15
diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h
new file mode 100644
index 000000000000..8081a281fa5e
--- /dev/null
+++ b/include/linux/radix-tree.h
@@ -0,0 +1,71 @@
1/*
2 * Copyright (C) 2001 Momchil Velikov
3 * Portions Copyright (C) 2001 Christoph Hellwig
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2, or (at
8 * your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19#ifndef _LINUX_RADIX_TREE_H
20#define _LINUX_RADIX_TREE_H
21
22#include <linux/preempt.h>
23#include <linux/types.h>
24
25struct radix_tree_root {
26 unsigned int height;
27 int gfp_mask;
28 struct radix_tree_node *rnode;
29};
30
31#define RADIX_TREE_INIT(mask) { \
32 .height = 0, \
33 .gfp_mask = (mask), \
34 .rnode = NULL, \
35}
36
37#define RADIX_TREE(name, mask) \
38 struct radix_tree_root name = RADIX_TREE_INIT(mask)
39
40#define INIT_RADIX_TREE(root, mask) \
41do { \
42 (root)->height = 0; \
43 (root)->gfp_mask = (mask); \
44 (root)->rnode = NULL; \
45} while (0)
46
47int radix_tree_insert(struct radix_tree_root *, unsigned long, void *);
48void *radix_tree_lookup(struct radix_tree_root *, unsigned long);
49void *radix_tree_delete(struct radix_tree_root *, unsigned long);
50unsigned int
51radix_tree_gang_lookup(struct radix_tree_root *root, void **results,
52 unsigned long first_index, unsigned int max_items);
53int radix_tree_preload(int gfp_mask);
54void radix_tree_init(void);
55void *radix_tree_tag_set(struct radix_tree_root *root,
56 unsigned long index, int tag);
57void *radix_tree_tag_clear(struct radix_tree_root *root,
58 unsigned long index, int tag);
59int radix_tree_tag_get(struct radix_tree_root *root,
60 unsigned long index, int tag);
61unsigned int
62radix_tree_gang_lookup_tag(struct radix_tree_root *root, void **results,
63 unsigned long first_index, unsigned int max_items, int tag);
64int radix_tree_tagged(struct radix_tree_root *root, int tag);
65
66static inline void radix_tree_preload_end(void)
67{
68 preempt_enable();
69}
70
71#endif /* _LINUX_RADIX_TREE_H */
diff --git a/include/linux/raid/linear.h b/include/linux/raid/linear.h
new file mode 100644
index 000000000000..e04c4fe45b53
--- /dev/null
+++ b/include/linux/raid/linear.h
@@ -0,0 +1,27 @@
1#ifndef _LINEAR_H
2#define _LINEAR_H
3
4#include <linux/raid/md.h>
5
6struct dev_info {
7 mdk_rdev_t *rdev;
8 sector_t size;
9 sector_t offset;
10};
11
12typedef struct dev_info dev_info_t;
13
14struct linear_private_data
15{
16 dev_info_t **hash_table;
17 dev_info_t *smallest;
18 int nr_zones;
19 dev_info_t disks[0];
20};
21
22
23typedef struct linear_private_data linear_conf_t;
24
25#define mddev_to_conf(mddev) ((linear_conf_t *) mddev->private)
26
27#endif
diff --git a/include/linux/raid/md.h b/include/linux/raid/md.h
new file mode 100644
index 000000000000..a6a67d102bfa
--- /dev/null
+++ b/include/linux/raid/md.h
@@ -0,0 +1,84 @@
1/*
2 md.h : Multiple Devices driver for Linux
3 Copyright (C) 1996-98 Ingo Molnar, Gadi Oxman
4 Copyright (C) 1994-96 Marc ZYNGIER
5 <zyngier@ufr-info-p7.ibp.fr> or
6 <maz@gloups.fdn.fr>
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, or (at your option)
11 any later version.
12
13 You should have received a copy of the GNU General Public License
14 (for example /usr/src/linux/COPYING); if not, write to the Free
15 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16*/
17
18#ifndef _MD_H
19#define _MD_H
20
21#include <linux/blkdev.h>
22#include <asm/semaphore.h>
23#include <linux/major.h>
24#include <linux/ioctl.h>
25#include <linux/types.h>
26#include <linux/bitops.h>
27#include <linux/module.h>
28#include <linux/hdreg.h>
29#include <linux/proc_fs.h>
30#include <linux/seq_file.h>
31#include <linux/smp_lock.h>
32#include <linux/delay.h>
33#include <net/checksum.h>
34#include <linux/random.h>
35#include <linux/kernel_stat.h>
36#include <asm/io.h>
37#include <linux/completion.h>
38#include <linux/mempool.h>
39#include <linux/list.h>
40#include <linux/reboot.h>
41#include <linux/vmalloc.h>
42#include <linux/blkpg.h>
43#include <linux/bio.h>
44
45/*
46 * 'md_p.h' holds the 'physical' layout of RAID devices
47 * 'md_u.h' holds the user <=> kernel API
48 *
49 * 'md_k.h' holds kernel internal definitions
50 */
51
52#include <linux/raid/md_p.h>
53#include <linux/raid/md_u.h>
54#include <linux/raid/md_k.h>
55
56/*
57 * Different major versions are not compatible.
58 * Different minor versions are only downward compatible.
59 * Different patchlevel versions are downward and upward compatible.
60 */
61#define MD_MAJOR_VERSION 0
62#define MD_MINOR_VERSION 90
63#define MD_PATCHLEVEL_VERSION 1
64
65extern int register_md_personality (int p_num, mdk_personality_t *p);
66extern int unregister_md_personality (int p_num);
67extern mdk_thread_t * md_register_thread (void (*run) (mddev_t *mddev),
68 mddev_t *mddev, const char *name);
69extern void md_unregister_thread (mdk_thread_t *thread);
70extern void md_wakeup_thread(mdk_thread_t *thread);
71extern void md_check_recovery(mddev_t *mddev);
72extern void md_write_start(mddev_t *mddev);
73extern void md_write_end(mddev_t *mddev);
74extern void md_handle_safemode(mddev_t *mddev);
75extern void md_done_sync(mddev_t *mddev, int blocks, int ok);
76extern void md_error (mddev_t *mddev, mdk_rdev_t *rdev);
77extern void md_unplug_mddev(mddev_t *mddev);
78
79extern void md_print_devices (void);
80
81#define MD_BUG(x...) { printk("md: bug in file %s, line %d\n", __FILE__, __LINE__); md_print_devices(); }
82
83#endif
84
diff --git a/include/linux/raid/md_k.h b/include/linux/raid/md_k.h
new file mode 100644
index 000000000000..c9a0d4013be7
--- /dev/null
+++ b/include/linux/raid/md_k.h
@@ -0,0 +1,369 @@
1/*
2 md_k.h : kernel internal structure of the Linux MD driver
3 Copyright (C) 1996-98 Ingo Molnar, Gadi Oxman
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9
10 You should have received a copy of the GNU General Public License
11 (for example /usr/src/linux/COPYING); if not, write to the Free
12 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
13*/
14
15#ifndef _MD_K_H
16#define _MD_K_H
17
18#define MD_RESERVED 0UL
19#define LINEAR 1UL
20#define RAID0 2UL
21#define RAID1 3UL
22#define RAID5 4UL
23#define TRANSLUCENT 5UL
24#define HSM 6UL
25#define MULTIPATH 7UL
26#define RAID6 8UL
27#define RAID10 9UL
28#define FAULTY 10UL
29#define MAX_PERSONALITY 11UL
30
31#define LEVEL_MULTIPATH (-4)
32#define LEVEL_LINEAR (-1)
33#define LEVEL_FAULTY (-5)
34
35#define MaxSector (~(sector_t)0)
36#define MD_THREAD_NAME_MAX 14
37
38static inline int pers_to_level (int pers)
39{
40 switch (pers) {
41 case FAULTY: return LEVEL_FAULTY;
42 case MULTIPATH: return LEVEL_MULTIPATH;
43 case HSM: return -3;
44 case TRANSLUCENT: return -2;
45 case LINEAR: return LEVEL_LINEAR;
46 case RAID0: return 0;
47 case RAID1: return 1;
48 case RAID5: return 5;
49 case RAID6: return 6;
50 case RAID10: return 10;
51 }
52 BUG();
53 return MD_RESERVED;
54}
55
56static inline int level_to_pers (int level)
57{
58 switch (level) {
59 case LEVEL_FAULTY: return FAULTY;
60 case LEVEL_MULTIPATH: return MULTIPATH;
61 case -3: return HSM;
62 case -2: return TRANSLUCENT;
63 case LEVEL_LINEAR: return LINEAR;
64 case 0: return RAID0;
65 case 1: return RAID1;
66 case 4:
67 case 5: return RAID5;
68 case 6: return RAID6;
69 case 10: return RAID10;
70 }
71 return MD_RESERVED;
72}
73
74typedef struct mddev_s mddev_t;
75typedef struct mdk_rdev_s mdk_rdev_t;
76
77#define MAX_MD_DEVS 256 /* Max number of md dev */
78
79/*
80 * options passed in raidrun:
81 */
82
83#define MAX_CHUNK_SIZE (4096*1024)
84
85/*
86 * default readahead
87 */
88
89static inline int disk_faulty(mdp_disk_t * d)
90{
91 return d->state & (1 << MD_DISK_FAULTY);
92}
93
94static inline int disk_active(mdp_disk_t * d)
95{
96 return d->state & (1 << MD_DISK_ACTIVE);
97}
98
99static inline int disk_sync(mdp_disk_t * d)
100{
101 return d->state & (1 << MD_DISK_SYNC);
102}
103
104static inline int disk_spare(mdp_disk_t * d)
105{
106 return !disk_sync(d) && !disk_active(d) && !disk_faulty(d);
107}
108
109static inline int disk_removed(mdp_disk_t * d)
110{
111 return d->state & (1 << MD_DISK_REMOVED);
112}
113
114static inline void mark_disk_faulty(mdp_disk_t * d)
115{
116 d->state |= (1 << MD_DISK_FAULTY);
117}
118
119static inline void mark_disk_active(mdp_disk_t * d)
120{
121 d->state |= (1 << MD_DISK_ACTIVE);
122}
123
124static inline void mark_disk_sync(mdp_disk_t * d)
125{
126 d->state |= (1 << MD_DISK_SYNC);
127}
128
129static inline void mark_disk_spare(mdp_disk_t * d)
130{
131 d->state = 0;
132}
133
134static inline void mark_disk_removed(mdp_disk_t * d)
135{
136 d->state = (1 << MD_DISK_FAULTY) | (1 << MD_DISK_REMOVED);
137}
138
139static inline void mark_disk_inactive(mdp_disk_t * d)
140{
141 d->state &= ~(1 << MD_DISK_ACTIVE);
142}
143
144static inline void mark_disk_nonsync(mdp_disk_t * d)
145{
146 d->state &= ~(1 << MD_DISK_SYNC);
147}
148
149/*
150 * MD's 'extended' device
151 */
152struct mdk_rdev_s
153{
154 struct list_head same_set; /* RAID devices within the same set */
155
156 sector_t size; /* Device size (in blocks) */
157 mddev_t *mddev; /* RAID array if running */
158 unsigned long last_events; /* IO event timestamp */
159
160 struct block_device *bdev; /* block device handle */
161
162 struct page *sb_page;
163 int sb_loaded;
164 sector_t data_offset; /* start of data in array */
165 sector_t sb_offset;
166 int preferred_minor; /* autorun support */
167
168 /* A device can be in one of three states based on two flags:
169 * Not working: faulty==1 in_sync==0
170 * Fully working: faulty==0 in_sync==1
171 * Working, but not
172 * in sync with array
173 * faulty==0 in_sync==0
174 *
175 * It can never have faulty==1, in_sync==1
176 * This reduces the burden of testing multiple flags in many cases
177 */
178 int faulty; /* if faulty do not issue IO requests */
179 int in_sync; /* device is a full member of the array */
180
181 int desc_nr; /* descriptor index in the superblock */
182 int raid_disk; /* role of device in array */
183
184 atomic_t nr_pending; /* number of pending requests.
185 * only maintained for arrays that
186 * support hot removal
187 */
188};
189
190typedef struct mdk_personality_s mdk_personality_t;
191
192struct mddev_s
193{
194 void *private;
195 mdk_personality_t *pers;
196 dev_t unit;
197 int md_minor;
198 struct list_head disks;
199 int sb_dirty;
200 int ro;
201
202 struct gendisk *gendisk;
203
204 /* Superblock information */
205 int major_version,
206 minor_version,
207 patch_version;
208 int persistent;
209 int chunk_size;
210 time_t ctime, utime;
211 int level, layout;
212 int raid_disks;
213 int max_disks;
214 sector_t size; /* used size of component devices */
215 sector_t array_size; /* exported array size */
216 __u64 events;
217
218 char uuid[16];
219
220 struct mdk_thread_s *thread; /* management thread */
221 struct mdk_thread_s *sync_thread; /* doing resync or reconstruct */
222 sector_t curr_resync; /* blocks scheduled */
223 unsigned long resync_mark; /* a recent timestamp */
224 sector_t resync_mark_cnt;/* blocks written at resync_mark */
225
226 sector_t resync_max_sectors; /* may be set by personality */
227 /* recovery/resync flags
228 * NEEDED: we might need to start a resync/recover
229 * RUNNING: a thread is running, or about to be started
230 * SYNC: actually doing a resync, not a recovery
231 * ERR: and IO error was detected - abort the resync/recovery
232 * INTR: someone requested a (clean) early abort.
233 * DONE: thread is done and is waiting to be reaped
234 */
235#define MD_RECOVERY_RUNNING 0
236#define MD_RECOVERY_SYNC 1
237#define MD_RECOVERY_ERR 2
238#define MD_RECOVERY_INTR 3
239#define MD_RECOVERY_DONE 4
240#define MD_RECOVERY_NEEDED 5
241 unsigned long recovery;
242
243 int in_sync; /* know to not need resync */
244 struct semaphore reconfig_sem;
245 atomic_t active;
246
247 int changed; /* true if we might need to reread partition info */
248 int degraded; /* whether md should consider
249 * adding a spare
250 */
251
252 atomic_t recovery_active; /* blocks scheduled, but not written */
253 wait_queue_head_t recovery_wait;
254 sector_t recovery_cp;
255 unsigned int safemode; /* if set, update "clean" superblock
256 * when no writes pending.
257 */
258 unsigned int safemode_delay;
259 struct timer_list safemode_timer;
260 atomic_t writes_pending;
261 request_queue_t *queue; /* for plugging ... */
262
263 struct list_head all_mddevs;
264};
265
266
267static inline void rdev_dec_pending(mdk_rdev_t *rdev, mddev_t *mddev)
268{
269 int faulty = rdev->faulty;
270 if (atomic_dec_and_test(&rdev->nr_pending) && faulty)
271 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
272}
273
274static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
275{
276 atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
277}
278
279struct mdk_personality_s
280{
281 char *name;
282 struct module *owner;
283 int (*make_request)(request_queue_t *q, struct bio *bio);
284 int (*run)(mddev_t *mddev);
285 int (*stop)(mddev_t *mddev);
286 void (*status)(struct seq_file *seq, mddev_t *mddev);
287 /* error_handler must set ->faulty and clear ->in_sync
288 * if appropriate, and should abort recovery if needed
289 */
290 void (*error_handler)(mddev_t *mddev, mdk_rdev_t *rdev);
291 int (*hot_add_disk) (mddev_t *mddev, mdk_rdev_t *rdev);
292 int (*hot_remove_disk) (mddev_t *mddev, int number);
293 int (*spare_active) (mddev_t *mddev);
294 int (*sync_request)(mddev_t *mddev, sector_t sector_nr, int go_faster);
295 int (*resize) (mddev_t *mddev, sector_t sectors);
296 int (*reshape) (mddev_t *mddev, int raid_disks);
297 int (*reconfig) (mddev_t *mddev, int layout, int chunk_size);
298};
299
300
301static inline char * mdname (mddev_t * mddev)
302{
303 return mddev->gendisk ? mddev->gendisk->disk_name : "mdX";
304}
305
306extern mdk_rdev_t * find_rdev_nr(mddev_t *mddev, int nr);
307
308/*
309 * iterates through some rdev ringlist. It's safe to remove the
310 * current 'rdev'. Dont touch 'tmp' though.
311 */
312#define ITERATE_RDEV_GENERIC(head,rdev,tmp) \
313 \
314 for ((tmp) = (head).next; \
315 (rdev) = (list_entry((tmp), mdk_rdev_t, same_set)), \
316 (tmp) = (tmp)->next, (tmp)->prev != &(head) \
317 ; )
318/*
319 * iterates through the 'same array disks' ringlist
320 */
321#define ITERATE_RDEV(mddev,rdev,tmp) \
322 ITERATE_RDEV_GENERIC((mddev)->disks,rdev,tmp)
323
324/*
325 * Iterates through 'pending RAID disks'
326 */
327#define ITERATE_RDEV_PENDING(rdev,tmp) \
328 ITERATE_RDEV_GENERIC(pending_raid_disks,rdev,tmp)
329
330typedef struct mdk_thread_s {
331 void (*run) (mddev_t *mddev);
332 mddev_t *mddev;
333 wait_queue_head_t wqueue;
334 unsigned long flags;
335 struct completion *event;
336 struct task_struct *tsk;
337 const char *name;
338} mdk_thread_t;
339
340#define THREAD_WAKEUP 0
341
342#define __wait_event_lock_irq(wq, condition, lock, cmd) \
343do { \
344 wait_queue_t __wait; \
345 init_waitqueue_entry(&__wait, current); \
346 \
347 add_wait_queue(&wq, &__wait); \
348 for (;;) { \
349 set_current_state(TASK_UNINTERRUPTIBLE); \
350 if (condition) \
351 break; \
352 spin_unlock_irq(&lock); \
353 cmd; \
354 schedule(); \
355 spin_lock_irq(&lock); \
356 } \
357 current->state = TASK_RUNNING; \
358 remove_wait_queue(&wq, &__wait); \
359} while (0)
360
361#define wait_event_lock_irq(wq, condition, lock, cmd) \
362do { \
363 if (condition) \
364 break; \
365 __wait_event_lock_irq(wq, condition, lock, cmd); \
366} while (0)
367
368#endif
369
diff --git a/include/linux/raid/md_p.h b/include/linux/raid/md_p.h
new file mode 100644
index 000000000000..8ba95d67329f
--- /dev/null
+++ b/include/linux/raid/md_p.h
@@ -0,0 +1,230 @@
1/*
2 md_p.h : physical layout of Linux RAID devices
3 Copyright (C) 1996-98 Ingo Molnar, Gadi Oxman
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9
10 You should have received a copy of the GNU General Public License
11 (for example /usr/src/linux/COPYING); if not, write to the Free
12 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
13*/
14
15#ifndef _MD_P_H
16#define _MD_P_H
17
18/*
19 * RAID superblock.
20 *
21 * The RAID superblock maintains some statistics on each RAID configuration.
22 * Each real device in the RAID set contains it near the end of the device.
23 * Some of the ideas are copied from the ext2fs implementation.
24 *
25 * We currently use 4096 bytes as follows:
26 *
27 * word offset function
28 *
29 * 0 - 31 Constant generic RAID device information.
30 * 32 - 63 Generic state information.
31 * 64 - 127 Personality specific information.
32 * 128 - 511 12 32-words descriptors of the disks in the raid set.
33 * 512 - 911 Reserved.
34 * 912 - 1023 Disk specific descriptor.
35 */
36
37/*
38 * If x is the real device size in bytes, we return an apparent size of:
39 *
40 * y = (x & ~(MD_RESERVED_BYTES - 1)) - MD_RESERVED_BYTES
41 *
42 * and place the 4kB superblock at offset y.
43 */
44#define MD_RESERVED_BYTES (64 * 1024)
45#define MD_RESERVED_SECTORS (MD_RESERVED_BYTES / 512)
46#define MD_RESERVED_BLOCKS (MD_RESERVED_BYTES / BLOCK_SIZE)
47
48#define MD_NEW_SIZE_SECTORS(x) ((x & ~(MD_RESERVED_SECTORS - 1)) - MD_RESERVED_SECTORS)
49#define MD_NEW_SIZE_BLOCKS(x) ((x & ~(MD_RESERVED_BLOCKS - 1)) - MD_RESERVED_BLOCKS)
50
51#define MD_SB_BYTES 4096
52#define MD_SB_WORDS (MD_SB_BYTES / 4)
53#define MD_SB_BLOCKS (MD_SB_BYTES / BLOCK_SIZE)
54#define MD_SB_SECTORS (MD_SB_BYTES / 512)
55
56/*
57 * The following are counted in 32-bit words
58 */
59#define MD_SB_GENERIC_OFFSET 0
60#define MD_SB_PERSONALITY_OFFSET 64
61#define MD_SB_DISKS_OFFSET 128
62#define MD_SB_DESCRIPTOR_OFFSET 992
63
64#define MD_SB_GENERIC_CONSTANT_WORDS 32
65#define MD_SB_GENERIC_STATE_WORDS 32
66#define MD_SB_GENERIC_WORDS (MD_SB_GENERIC_CONSTANT_WORDS + MD_SB_GENERIC_STATE_WORDS)
67#define MD_SB_PERSONALITY_WORDS 64
68#define MD_SB_DESCRIPTOR_WORDS 32
69#define MD_SB_DISKS 27
70#define MD_SB_DISKS_WORDS (MD_SB_DISKS*MD_SB_DESCRIPTOR_WORDS)
71#define MD_SB_RESERVED_WORDS (1024 - MD_SB_GENERIC_WORDS - MD_SB_PERSONALITY_WORDS - MD_SB_DISKS_WORDS - MD_SB_DESCRIPTOR_WORDS)
72#define MD_SB_EQUAL_WORDS (MD_SB_GENERIC_WORDS + MD_SB_PERSONALITY_WORDS + MD_SB_DISKS_WORDS)
73
74/*
75 * Device "operational" state bits
76 */
77#define MD_DISK_FAULTY 0 /* disk is faulty / operational */
78#define MD_DISK_ACTIVE 1 /* disk is running or spare disk */
79#define MD_DISK_SYNC 2 /* disk is in sync with the raid set */
80#define MD_DISK_REMOVED 3 /* disk is in sync with the raid set */
81
82typedef struct mdp_device_descriptor_s {
83 __u32 number; /* 0 Device number in the entire set */
84 __u32 major; /* 1 Device major number */
85 __u32 minor; /* 2 Device minor number */
86 __u32 raid_disk; /* 3 The role of the device in the raid set */
87 __u32 state; /* 4 Operational state */
88 __u32 reserved[MD_SB_DESCRIPTOR_WORDS - 5];
89} mdp_disk_t;
90
91#define MD_SB_MAGIC 0xa92b4efc
92
93/*
94 * Superblock state bits
95 */
96#define MD_SB_CLEAN 0
97#define MD_SB_ERRORS 1
98
99typedef struct mdp_superblock_s {
100 /*
101 * Constant generic information
102 */
103 __u32 md_magic; /* 0 MD identifier */
104 __u32 major_version; /* 1 major version to which the set conforms */
105 __u32 minor_version; /* 2 minor version ... */
106 __u32 patch_version; /* 3 patchlevel version ... */
107 __u32 gvalid_words; /* 4 Number of used words in this section */
108 __u32 set_uuid0; /* 5 Raid set identifier */
109 __u32 ctime; /* 6 Creation time */
110 __u32 level; /* 7 Raid personality */
111 __u32 size; /* 8 Apparent size of each individual disk */
112 __u32 nr_disks; /* 9 total disks in the raid set */
113 __u32 raid_disks; /* 10 disks in a fully functional raid set */
114 __u32 md_minor; /* 11 preferred MD minor device number */
115 __u32 not_persistent; /* 12 does it have a persistent superblock */
116 __u32 set_uuid1; /* 13 Raid set identifier #2 */
117 __u32 set_uuid2; /* 14 Raid set identifier #3 */
118 __u32 set_uuid3; /* 15 Raid set identifier #4 */
119 __u32 gstate_creserved[MD_SB_GENERIC_CONSTANT_WORDS - 16];
120
121 /*
122 * Generic state information
123 */
124 __u32 utime; /* 0 Superblock update time */
125 __u32 state; /* 1 State bits (clean, ...) */
126 __u32 active_disks; /* 2 Number of currently active disks */
127 __u32 working_disks; /* 3 Number of working disks */
128 __u32 failed_disks; /* 4 Number of failed disks */
129 __u32 spare_disks; /* 5 Number of spare disks */
130 __u32 sb_csum; /* 6 checksum of the whole superblock */
131#ifdef __BIG_ENDIAN
132 __u32 events_hi; /* 7 high-order of superblock update count */
133 __u32 events_lo; /* 8 low-order of superblock update count */
134 __u32 cp_events_hi; /* 9 high-order of checkpoint update count */
135 __u32 cp_events_lo; /* 10 low-order of checkpoint update count */
136#else
137 __u32 events_lo; /* 7 low-order of superblock update count */
138 __u32 events_hi; /* 8 high-order of superblock update count */
139 __u32 cp_events_lo; /* 9 low-order of checkpoint update count */
140 __u32 cp_events_hi; /* 10 high-order of checkpoint update count */
141#endif
142 __u32 recovery_cp; /* 11 recovery checkpoint sector count */
143 __u32 gstate_sreserved[MD_SB_GENERIC_STATE_WORDS - 12];
144
145 /*
146 * Personality information
147 */
148 __u32 layout; /* 0 the array's physical layout */
149 __u32 chunk_size; /* 1 chunk size in bytes */
150 __u32 root_pv; /* 2 LV root PV */
151 __u32 root_block; /* 3 LV root block */
152 __u32 pstate_reserved[MD_SB_PERSONALITY_WORDS - 4];
153
154 /*
155 * Disks information
156 */
157 mdp_disk_t disks[MD_SB_DISKS];
158
159 /*
160 * Reserved
161 */
162 __u32 reserved[MD_SB_RESERVED_WORDS];
163
164 /*
165 * Active descriptor
166 */
167 mdp_disk_t this_disk;
168
169} mdp_super_t;
170
171static inline __u64 md_event(mdp_super_t *sb) {
172 __u64 ev = sb->events_hi;
173 return (ev<<32)| sb->events_lo;
174}
175
176/*
177 * The version-1 superblock :
178 * All numeric fields are little-endian.
179 *
180 * total size: 256 bytes plus 2 per device.
181 * 1K allows 384 devices.
182 */
183struct mdp_superblock_1 {
184 /* constant array information - 128 bytes */
185 __u32 magic; /* MD_SB_MAGIC: 0xa92b4efc - little endian */
186 __u32 major_version; /* 1 */
187 __u32 feature_map; /* 0 for now */
188 __u32 pad0; /* always set to 0 when writing */
189
190 __u8 set_uuid[16]; /* user-space generated. */
191 char set_name[32]; /* set and interpreted by user-space */
192
193 __u64 ctime; /* lo 40 bits are seconds, top 24 are microseconds or 0*/
194 __u32 level; /* -4 (multipath), -1 (linear), 0,1,4,5 */
195 __u32 layout; /* only for raid5 currently */
196 __u64 size; /* used size of component devices, in 512byte sectors */
197
198 __u32 chunksize; /* in 512byte sectors */
199 __u32 raid_disks;
200 __u8 pad1[128-96]; /* set to 0 when written */
201
202 /* constant this-device information - 64 bytes */
203 __u64 data_offset; /* sector start of data, often 0 */
204 __u64 data_size; /* sectors in this device that can be used for data */
205 __u64 super_offset; /* sector start of this superblock */
206 __u64 recovery_offset;/* sectors before this offset (from data_offset) have been recovered */
207 __u32 dev_number; /* permanent identifier of this device - not role in raid */
208 __u32 cnt_corrected_read; /* number of read errors that were corrected by re-writing */
209 __u8 device_uuid[16]; /* user-space setable, ignored by kernel */
210 __u8 pad2[64-56]; /* set to 0 when writing */
211
212 /* array state information - 64 bytes */
213 __u64 utime; /* 40 bits second, 24 btes microseconds */
214 __u64 events; /* incremented when superblock updated */
215 __u64 resync_offset; /* data before this offset (from data_offset) known to be in sync */
216 __u32 sb_csum; /* checksum upto devs[max_dev] */
217 __u32 max_dev; /* size of devs[] array to consider */
218 __u8 pad3[64-32]; /* set to 0 when writing */
219
220 /* device state information. Indexed by dev_number.
221 * 2 bytes per device
222 * Note there are no per-device state flags. State information is rolled
223 * into the 'roles' value. If a device is spare or faulty, then it doesn't
224 * have a meaningful role.
225 */
226 __u16 dev_roles[0]; /* role in array, or 0xffff for a spare, or 0xfffe for faulty */
227};
228
229#endif
230
diff --git a/include/linux/raid/md_u.h b/include/linux/raid/md_u.h
new file mode 100644
index 000000000000..a2df5c2a42af
--- /dev/null
+++ b/include/linux/raid/md_u.h
@@ -0,0 +1,117 @@
1/*
2 md_u.h : user <=> kernel API between Linux raidtools and RAID drivers
3 Copyright (C) 1998 Ingo Molnar
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9
10 You should have received a copy of the GNU General Public License
11 (for example /usr/src/linux/COPYING); if not, write to the Free
12 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
13*/
14
15#ifndef _MD_U_H
16#define _MD_U_H
17
18/* ioctls */
19
20/* status */
21#define RAID_VERSION _IOR (MD_MAJOR, 0x10, mdu_version_t)
22#define GET_ARRAY_INFO _IOR (MD_MAJOR, 0x11, mdu_array_info_t)
23#define GET_DISK_INFO _IOR (MD_MAJOR, 0x12, mdu_disk_info_t)
24#define PRINT_RAID_DEBUG _IO (MD_MAJOR, 0x13)
25#define RAID_AUTORUN _IO (MD_MAJOR, 0x14)
26
27/* configuration */
28#define CLEAR_ARRAY _IO (MD_MAJOR, 0x20)
29#define ADD_NEW_DISK _IOW (MD_MAJOR, 0x21, mdu_disk_info_t)
30#define HOT_REMOVE_DISK _IO (MD_MAJOR, 0x22)
31#define SET_ARRAY_INFO _IOW (MD_MAJOR, 0x23, mdu_array_info_t)
32#define SET_DISK_INFO _IO (MD_MAJOR, 0x24)
33#define WRITE_RAID_INFO _IO (MD_MAJOR, 0x25)
34#define UNPROTECT_ARRAY _IO (MD_MAJOR, 0x26)
35#define PROTECT_ARRAY _IO (MD_MAJOR, 0x27)
36#define HOT_ADD_DISK _IO (MD_MAJOR, 0x28)
37#define SET_DISK_FAULTY _IO (MD_MAJOR, 0x29)
38#define HOT_GENERATE_ERROR _IO (MD_MAJOR, 0x2a)
39
40/* usage */
41#define RUN_ARRAY _IOW (MD_MAJOR, 0x30, mdu_param_t)
42#define START_ARRAY _IO (MD_MAJOR, 0x31)
43#define STOP_ARRAY _IO (MD_MAJOR, 0x32)
44#define STOP_ARRAY_RO _IO (MD_MAJOR, 0x33)
45#define RESTART_ARRAY_RW _IO (MD_MAJOR, 0x34)
46
47typedef struct mdu_version_s {
48 int major;
49 int minor;
50 int patchlevel;
51} mdu_version_t;
52
53typedef struct mdu_array_info_s {
54 /*
55 * Generic constant information
56 */
57 int major_version;
58 int minor_version;
59 int patch_version;
60 int ctime;
61 int level;
62 int size;
63 int nr_disks;
64 int raid_disks;
65 int md_minor;
66 int not_persistent;
67
68 /*
69 * Generic state information
70 */
71 int utime; /* 0 Superblock update time */
72 int state; /* 1 State bits (clean, ...) */
73 int active_disks; /* 2 Number of currently active disks */
74 int working_disks; /* 3 Number of working disks */
75 int failed_disks; /* 4 Number of failed disks */
76 int spare_disks; /* 5 Number of spare disks */
77
78 /*
79 * Personality information
80 */
81 int layout; /* 0 the array's physical layout */
82 int chunk_size; /* 1 chunk size in bytes */
83
84} mdu_array_info_t;
85
86typedef struct mdu_disk_info_s {
87 /*
88 * configuration/status of one particular disk
89 */
90 int number;
91 int major;
92 int minor;
93 int raid_disk;
94 int state;
95
96} mdu_disk_info_t;
97
98typedef struct mdu_start_info_s {
99 /*
100 * configuration/status of one particular disk
101 */
102 int major;
103 int minor;
104 int raid_disk;
105 int state;
106
107} mdu_start_info_t;
108
109typedef struct mdu_param_s
110{
111 int personality; /* 1,2,3,4 */
112 int chunk_size; /* in bytes */
113 int max_fault; /* unused for now */
114} mdu_param_t;
115
116#endif
117
diff --git a/include/linux/raid/multipath.h b/include/linux/raid/multipath.h
new file mode 100644
index 000000000000..6f53fc177a47
--- /dev/null
+++ b/include/linux/raid/multipath.h
@@ -0,0 +1,42 @@
1#ifndef _MULTIPATH_H
2#define _MULTIPATH_H
3
4#include <linux/raid/md.h>
5
6struct multipath_info {
7 mdk_rdev_t *rdev;
8};
9
10struct multipath_private_data {
11 mddev_t *mddev;
12 struct multipath_info *multipaths;
13 int raid_disks;
14 int working_disks;
15 spinlock_t device_lock;
16 struct list_head retry_list;
17
18 mempool_t *pool;
19};
20
21typedef struct multipath_private_data multipath_conf_t;
22
23/*
24 * this is the only point in the RAID code where we violate
25 * C type safety. mddev->private is an 'opaque' pointer.
26 */
27#define mddev_to_conf(mddev) ((multipath_conf_t *) mddev->private)
28
29/*
30 * this is our 'private' 'collective' MULTIPATH buffer head.
31 * it contains information about what kind of IO operations were started
32 * for this MULTIPATH operation, and about their status:
33 */
34
35struct multipath_bh {
36 mddev_t *mddev;
37 struct bio *master_bio;
38 struct bio bio;
39 int path;
40 struct list_head retry_list;
41};
42#endif
diff --git a/include/linux/raid/raid0.h b/include/linux/raid/raid0.h
new file mode 100644
index 000000000000..1b2dda035f8e
--- /dev/null
+++ b/include/linux/raid/raid0.h
@@ -0,0 +1,30 @@
1#ifndef _RAID0_H
2#define _RAID0_H
3
4#include <linux/raid/md.h>
5
6struct strip_zone
7{
8 sector_t zone_offset; /* Zone offset in md_dev */
9 sector_t dev_offset; /* Zone offset in real dev */
10 sector_t size; /* Zone size */
11 int nb_dev; /* # of devices attached to the zone */
12 mdk_rdev_t **dev; /* Devices attached to the zone */
13};
14
15struct raid0_private_data
16{
17 struct strip_zone **hash_table; /* Table of indexes into strip_zone */
18 struct strip_zone *strip_zone;
19 mdk_rdev_t **devlist; /* lists of rdevs, pointed to by strip_zone->dev */
20 int nr_strip_zones;
21
22 sector_t hash_spacing;
23 int preshift; /* shift this before divide by hash_spacing */
24};
25
26typedef struct raid0_private_data raid0_conf_t;
27
28#define mddev_to_conf(mddev) ((raid0_conf_t *) mddev->private)
29
30#endif
diff --git a/include/linux/raid/raid1.h b/include/linux/raid/raid1.h
new file mode 100644
index 000000000000..abbfdd9afe1e
--- /dev/null
+++ b/include/linux/raid/raid1.h
@@ -0,0 +1,98 @@
1#ifndef _RAID1_H
2#define _RAID1_H
3
4#include <linux/raid/md.h>
5
6typedef struct mirror_info mirror_info_t;
7
8struct mirror_info {
9 mdk_rdev_t *rdev;
10 sector_t head_position;
11};
12
13/*
14 * memory pools need a pointer to the mddev, so they can force an unplug
15 * when memory is tight, and a count of the number of drives that the
16 * pool was allocated for, so they know how much to allocate and free.
17 * mddev->raid_disks cannot be used, as it can change while a pool is active
18 * These two datums are stored in a kmalloced struct.
19 */
20
21struct pool_info {
22 mddev_t *mddev;
23 int raid_disks;
24};
25
26
27typedef struct r1bio_s r1bio_t;
28
29struct r1_private_data_s {
30 mddev_t *mddev;
31 mirror_info_t *mirrors;
32 int raid_disks;
33 int working_disks;
34 int last_used;
35 sector_t next_seq_sect;
36 spinlock_t device_lock;
37
38 struct list_head retry_list;
39 /* for use when syncing mirrors: */
40
41 spinlock_t resync_lock;
42 int nr_pending;
43 int barrier;
44 sector_t next_resync;
45
46 wait_queue_head_t wait_idle;
47 wait_queue_head_t wait_resume;
48
49 struct pool_info *poolinfo;
50
51 mempool_t *r1bio_pool;
52 mempool_t *r1buf_pool;
53};
54
55typedef struct r1_private_data_s conf_t;
56
57/*
58 * this is the only point in the RAID code where we violate
59 * C type safety. mddev->private is an 'opaque' pointer.
60 */
61#define mddev_to_conf(mddev) ((conf_t *) mddev->private)
62
63/*
64 * this is our 'private' RAID1 bio.
65 *
66 * it contains information about what kind of IO operations were started
67 * for this RAID1 operation, and about their status:
68 */
69
70struct r1bio_s {
71 atomic_t remaining; /* 'have we finished' count,
72 * used from IRQ handlers
73 */
74 sector_t sector;
75 int sectors;
76 unsigned long state;
77 mddev_t *mddev;
78 /*
79 * original bio going to /dev/mdx
80 */
81 struct bio *master_bio;
82 /*
83 * if the IO is in READ direction, then this is where we read
84 */
85 int read_disk;
86
87 struct list_head retry_list;
88 /*
89 * if the IO is in WRITE direction, then multiple bios are used.
90 * We choose the number when they are allocated.
91 */
92 struct bio *bios[0];
93};
94
95/* bits for r1bio.state */
96#define R1BIO_Uptodate 0
97#define R1BIO_IsSync 1
98#endif
diff --git a/include/linux/raid/raid10.h b/include/linux/raid/raid10.h
new file mode 100644
index 000000000000..60708789c8f9
--- /dev/null
+++ b/include/linux/raid/raid10.h
@@ -0,0 +1,103 @@
1#ifndef _RAID10_H
2#define _RAID10_H
3
4#include <linux/raid/md.h>
5
6typedef struct mirror_info mirror_info_t;
7
8struct mirror_info {
9 mdk_rdev_t *rdev;
10 sector_t head_position;
11};
12
13typedef struct r10bio_s r10bio_t;
14
15struct r10_private_data_s {
16 mddev_t *mddev;
17 mirror_info_t *mirrors;
18 int raid_disks;
19 int working_disks;
20 spinlock_t device_lock;
21
22 /* geometry */
23 int near_copies; /* number of copies layed out raid0 style */
24 int far_copies; /* number of copies layed out
25 * at large strides across drives
26 */
27 int copies; /* near_copies * far_copies.
28 * must be <= raid_disks
29 */
30 sector_t stride; /* distance between far copies.
31 * This is size / far_copies
32 */
33
34 int chunk_shift; /* shift from chunks to sectors */
35 sector_t chunk_mask;
36
37 struct list_head retry_list;
38 /* for use when syncing mirrors: */
39
40 spinlock_t resync_lock;
41 int nr_pending;
42 int barrier;
43 sector_t next_resync;
44
45 wait_queue_head_t wait_idle;
46 wait_queue_head_t wait_resume;
47
48 mempool_t *r10bio_pool;
49 mempool_t *r10buf_pool;
50};
51
52typedef struct r10_private_data_s conf_t;
53
54/*
55 * this is the only point in the RAID code where we violate
56 * C type safety. mddev->private is an 'opaque' pointer.
57 */
58#define mddev_to_conf(mddev) ((conf_t *) mddev->private)
59
60/*
61 * this is our 'private' RAID10 bio.
62 *
63 * it contains information about what kind of IO operations were started
64 * for this RAID10 operation, and about their status:
65 */
66
67struct r10bio_s {
68 atomic_t remaining; /* 'have we finished' count,
69 * used from IRQ handlers
70 */
71 sector_t sector; /* virtual sector number */
72 int sectors;
73 unsigned long state;
74 mddev_t *mddev;
75 /*
76 * original bio going to /dev/mdx
77 */
78 struct bio *master_bio;
79 /*
80 * if the IO is in READ direction, then this is where we read
81 */
82 int read_slot;
83
84 struct list_head retry_list;
85 /*
86 * if the IO is in WRITE direction, then multiple bios are used,
87 * one for each copy.
88 * When resyncing we also use one for each copy.
89 * When reconstructing, we use 2 bios, one for read, one for write.
90 * We choose the number when they are allocated.
91 */
92 struct {
93 struct bio *bio;
94 sector_t addr;
95 int devnum;
96 } devs[0];
97};
98
99/* bits for r10bio.state */
100#define R10BIO_Uptodate 0
101#define R10BIO_IsSync 1
102#define R10BIO_IsRecover 2
103#endif
diff --git a/include/linux/raid/raid5.h b/include/linux/raid/raid5.h
new file mode 100644
index 000000000000..d63ddcb4afad
--- /dev/null
+++ b/include/linux/raid/raid5.h
@@ -0,0 +1,243 @@
1#ifndef _RAID5_H
2#define _RAID5_H
3
4#include <linux/raid/md.h>
5#include <linux/raid/xor.h>
6
7/*
8 *
9 * Each stripe contains one buffer per disc. Each buffer can be in
10 * one of a number of states stored in "flags". Changes between
11 * these states happen *almost* exclusively under a per-stripe
12 * spinlock. Some very specific changes can happen in bi_end_io, and
13 * these are not protected by the spin lock.
14 *
15 * The flag bits that are used to represent these states are:
16 * R5_UPTODATE and R5_LOCKED
17 *
18 * State Empty == !UPTODATE, !LOCK
19 * We have no data, and there is no active request
20 * State Want == !UPTODATE, LOCK
21 * A read request is being submitted for this block
22 * State Dirty == UPTODATE, LOCK
23 * Some new data is in this buffer, and it is being written out
24 * State Clean == UPTODATE, !LOCK
25 * We have valid data which is the same as on disc
26 *
27 * The possible state transitions are:
28 *
29 * Empty -> Want - on read or write to get old data for parity calc
30 * Empty -> Dirty - on compute_parity to satisfy write/sync request.(RECONSTRUCT_WRITE)
31 * Empty -> Clean - on compute_block when computing a block for failed drive
32 * Want -> Empty - on failed read
33 * Want -> Clean - on successful completion of read request
34 * Dirty -> Clean - on successful completion of write request
35 * Dirty -> Clean - on failed write
36 * Clean -> Dirty - on compute_parity to satisfy write/sync (RECONSTRUCT or RMW)
37 *
38 * The Want->Empty, Want->Clean, Dirty->Clean, transitions
39 * all happen in b_end_io at interrupt time.
40 * Each sets the Uptodate bit before releasing the Lock bit.
41 * This leaves one multi-stage transition:
42 * Want->Dirty->Clean
43 * This is safe because thinking that a Clean buffer is actually dirty
44 * will at worst delay some action, and the stripe will be scheduled
45 * for attention after the transition is complete.
46 *
47 * There is one possibility that is not covered by these states. That
48 * is if one drive has failed and there is a spare being rebuilt. We
49 * can't distinguish between a clean block that has been generated
50 * from parity calculations, and a clean block that has been
51 * successfully written to the spare ( or to parity when resyncing).
52 * To distingush these states we have a stripe bit STRIPE_INSYNC that
53 * is set whenever a write is scheduled to the spare, or to the parity
54 * disc if there is no spare. A sync request clears this bit, and
55 * when we find it set with no buffers locked, we know the sync is
56 * complete.
57 *
58 * Buffers for the md device that arrive via make_request are attached
59 * to the appropriate stripe in one of two lists linked on b_reqnext.
60 * One list (bh_read) for read requests, one (bh_write) for write.
61 * There should never be more than one buffer on the two lists
62 * together, but we are not guaranteed of that so we allow for more.
63 *
64 * If a buffer is on the read list when the associated cache buffer is
65 * Uptodate, the data is copied into the read buffer and it's b_end_io
66 * routine is called. This may happen in the end_request routine only
67 * if the buffer has just successfully been read. end_request should
68 * remove the buffers from the list and then set the Uptodate bit on
69 * the buffer. Other threads may do this only if they first check
70 * that the Uptodate bit is set. Once they have checked that they may
71 * take buffers off the read queue.
72 *
73 * When a buffer on the write list is committed for write it is copied
74 * into the cache buffer, which is then marked dirty, and moved onto a
75 * third list, the written list (bh_written). Once both the parity
76 * block and the cached buffer are successfully written, any buffer on
77 * a written list can be returned with b_end_io.
78 *
79 * The write list and read list both act as fifos. The read list is
80 * protected by the device_lock. The write and written lists are
81 * protected by the stripe lock. The device_lock, which can be
82 * claimed while the stipe lock is held, is only for list
83 * manipulations and will only be held for a very short time. It can
84 * be claimed from interrupts.
85 *
86 *
87 * Stripes in the stripe cache can be on one of two lists (or on
88 * neither). The "inactive_list" contains stripes which are not
89 * currently being used for any request. They can freely be reused
90 * for another stripe. The "handle_list" contains stripes that need
91 * to be handled in some way. Both of these are fifo queues. Each
92 * stripe is also (potentially) linked to a hash bucket in the hash
93 * table so that it can be found by sector number. Stripes that are
94 * not hashed must be on the inactive_list, and will normally be at
95 * the front. All stripes start life this way.
96 *
97 * The inactive_list, handle_list and hash bucket lists are all protected by the
98 * device_lock.
99 * - stripes on the inactive_list never have their stripe_lock held.
100 * - stripes have a reference counter. If count==0, they are on a list.
101 * - If a stripe might need handling, STRIPE_HANDLE is set.
102 * - When refcount reaches zero, then if STRIPE_HANDLE it is put on
103 * handle_list else inactive_list
104 *
105 * This, combined with the fact that STRIPE_HANDLE is only ever
106 * cleared while a stripe has a non-zero count means that if the
107 * refcount is 0 and STRIPE_HANDLE is set, then it is on the
108 * handle_list and if recount is 0 and STRIPE_HANDLE is not set, then
109 * the stripe is on inactive_list.
110 *
111 * The possible transitions are:
112 * activate an unhashed/inactive stripe (get_active_stripe())
113 * lockdev check-hash unlink-stripe cnt++ clean-stripe hash-stripe unlockdev
114 * activate a hashed, possibly active stripe (get_active_stripe())
115 * lockdev check-hash if(!cnt++)unlink-stripe unlockdev
116 * attach a request to an active stripe (add_stripe_bh())
117 * lockdev attach-buffer unlockdev
118 * handle a stripe (handle_stripe())
119 * lockstripe clrSTRIPE_HANDLE ... (lockdev check-buffers unlockdev) .. change-state .. record io needed unlockstripe schedule io
120 * release an active stripe (release_stripe())
121 * lockdev if (!--cnt) { if STRIPE_HANDLE, add to handle_list else add to inactive-list } unlockdev
122 *
123 * The refcount counts each thread that have activated the stripe,
124 * plus raid5d if it is handling it, plus one for each active request
125 * on a cached buffer.
126 */
127
128struct stripe_head {
129 struct stripe_head *hash_next, **hash_pprev; /* hash pointers */
130 struct list_head lru; /* inactive_list or handle_list */
131 struct raid5_private_data *raid_conf;
132 sector_t sector; /* sector of this row */
133 int pd_idx; /* parity disk index */
134 unsigned long state; /* state flags */
135 atomic_t count; /* nr of active thread/requests */
136 spinlock_t lock;
137 struct r5dev {
138 struct bio req;
139 struct bio_vec vec;
140 struct page *page;
141 struct bio *toread, *towrite, *written;
142 sector_t sector; /* sector of this page */
143 unsigned long flags;
144 } dev[1]; /* allocated with extra space depending of RAID geometry */
145};
146/* Flags */
147#define R5_UPTODATE 0 /* page contains current data */
148#define R5_LOCKED 1 /* IO has been submitted on "req" */
149#define R5_OVERWRITE 2 /* towrite covers whole page */
150/* and some that are internal to handle_stripe */
151#define R5_Insync 3 /* rdev && rdev->in_sync at start */
152#define R5_Wantread 4 /* want to schedule a read */
153#define R5_Wantwrite 5
154#define R5_Syncio 6 /* this io need to be accounted as resync io */
155#define R5_Overlap 7 /* There is a pending overlapping request on this block */
156
157/*
158 * Write method
159 */
160#define RECONSTRUCT_WRITE 1
161#define READ_MODIFY_WRITE 2
162/* not a write method, but a compute_parity mode */
163#define CHECK_PARITY 3
164
165/*
166 * Stripe state
167 */
168#define STRIPE_ERROR 1
169#define STRIPE_HANDLE 2
170#define STRIPE_SYNCING 3
171#define STRIPE_INSYNC 4
172#define STRIPE_PREREAD_ACTIVE 5
173#define STRIPE_DELAYED 6
174
175/*
176 * Plugging:
177 *
178 * To improve write throughput, we need to delay the handling of some
179 * stripes until there has been a chance that several write requests
180 * for the one stripe have all been collected.
181 * In particular, any write request that would require pre-reading
182 * is put on a "delayed" queue until there are no stripes currently
183 * in a pre-read phase. Further, if the "delayed" queue is empty when
184 * a stripe is put on it then we "plug" the queue and do not process it
185 * until an unplug call is made. (the unplug_io_fn() is called).
186 *
187 * When preread is initiated on a stripe, we set PREREAD_ACTIVE and add
188 * it to the count of prereading stripes.
189 * When write is initiated, or the stripe refcnt == 0 (just in case) we
190 * clear the PREREAD_ACTIVE flag and decrement the count
191 * Whenever the delayed queue is empty and the device is not plugged, we
192 * move any strips from delayed to handle and clear the DELAYED flag and set PREREAD_ACTIVE.
193 * In stripe_handle, if we find pre-reading is necessary, we do it if
194 * PREREAD_ACTIVE is set, else we set DELAYED which will send it to the delayed queue.
195 * HANDLE gets cleared if stripe_handle leave nothing locked.
196 */
197
198
199struct disk_info {
200 mdk_rdev_t *rdev;
201};
202
203struct raid5_private_data {
204 struct stripe_head **stripe_hashtbl;
205 mddev_t *mddev;
206 struct disk_info *spare;
207 int chunk_size, level, algorithm;
208 int raid_disks, working_disks, failed_disks;
209 int max_nr_stripes;
210
211 struct list_head handle_list; /* stripes needing handling */
212 struct list_head delayed_list; /* stripes that have plugged requests */
213 atomic_t preread_active_stripes; /* stripes with scheduled io */
214
215 char cache_name[20];
216 kmem_cache_t *slab_cache; /* for allocating stripes */
217 /*
218 * Free stripes pool
219 */
220 atomic_t active_stripes;
221 struct list_head inactive_list;
222 wait_queue_head_t wait_for_stripe;
223 wait_queue_head_t wait_for_overlap;
224 int inactive_blocked; /* release of inactive stripes blocked,
225 * waiting for 25% to be free
226 */
227 spinlock_t device_lock;
228 struct disk_info disks[0];
229};
230
231typedef struct raid5_private_data raid5_conf_t;
232
233#define mddev_to_conf(mddev) ((raid5_conf_t *) mddev->private)
234
235/*
236 * Our supported algorithms
237 */
238#define ALGORITHM_LEFT_ASYMMETRIC 0
239#define ALGORITHM_RIGHT_ASYMMETRIC 1
240#define ALGORITHM_LEFT_SYMMETRIC 2
241#define ALGORITHM_RIGHT_SYMMETRIC 3
242
243#endif
diff --git a/include/linux/raid/xor.h b/include/linux/raid/xor.h
new file mode 100644
index 000000000000..f0d67cbdea40
--- /dev/null
+++ b/include/linux/raid/xor.h
@@ -0,0 +1,23 @@
1#ifndef _XOR_H
2#define _XOR_H
3
4#include <linux/raid/md.h>
5
6#define MAX_XOR_BLOCKS 5
7
8extern void xor_block(unsigned int count, unsigned int bytes, void **ptr);
9
10struct xor_block_template {
11 struct xor_block_template *next;
12 const char *name;
13 int speed;
14 void (*do_2)(unsigned long, unsigned long *, unsigned long *);
15 void (*do_3)(unsigned long, unsigned long *, unsigned long *,
16 unsigned long *);
17 void (*do_4)(unsigned long, unsigned long *, unsigned long *,
18 unsigned long *, unsigned long *);
19 void (*do_5)(unsigned long, unsigned long *, unsigned long *,
20 unsigned long *, unsigned long *, unsigned long *);
21};
22
23#endif
diff --git a/include/linux/ramfs.h b/include/linux/ramfs.h
new file mode 100644
index 000000000000..e0a4faa9610c
--- /dev/null
+++ b/include/linux/ramfs.h
@@ -0,0 +1,11 @@
1#ifndef _LINUX_RAMFS_H
2#define _LINUX_RAMFS_H
3
4struct inode *ramfs_get_inode(struct super_block *sb, int mode, dev_t dev);
5struct super_block *ramfs_get_sb(struct file_system_type *fs_type,
6 int flags, const char *dev_name, void *data);
7
8extern struct file_operations ramfs_file_operations;
9extern struct vm_operations_struct generic_file_vm_ops;
10
11#endif
diff --git a/include/linux/random.h b/include/linux/random.h
new file mode 100644
index 000000000000..cc6703449916
--- /dev/null
+++ b/include/linux/random.h
@@ -0,0 +1,72 @@
1/*
2 * include/linux/random.h
3 *
4 * Include file for the random number generator.
5 */
6
7#ifndef _LINUX_RANDOM_H
8#define _LINUX_RANDOM_H
9
10#include <linux/ioctl.h>
11
12/* ioctl()'s for the random number generator */
13
14/* Get the entropy count. */
15#define RNDGETENTCNT _IOR( 'R', 0x00, int )
16
17/* Add to (or subtract from) the entropy count. (Superuser only.) */
18#define RNDADDTOENTCNT _IOW( 'R', 0x01, int )
19
20/* Get the contents of the entropy pool. (Superuser only.) */
21#define RNDGETPOOL _IOR( 'R', 0x02, int [2] )
22
23/*
24 * Write bytes into the entropy pool and add to the entropy count.
25 * (Superuser only.)
26 */
27#define RNDADDENTROPY _IOW( 'R', 0x03, int [2] )
28
29/* Clear entropy count to 0. (Superuser only.) */
30#define RNDZAPENTCNT _IO( 'R', 0x04 )
31
32/* Clear the entropy pool and associated counters. (Superuser only.) */
33#define RNDCLEARPOOL _IO( 'R', 0x06 )
34
35struct rand_pool_info {
36 int entropy_count;
37 int buf_size;
38 __u32 buf[0];
39};
40
41/* Exported functions */
42
43#ifdef __KERNEL__
44
45extern void rand_initialize_irq(int irq);
46
47extern void add_input_randomness(unsigned int type, unsigned int code,
48 unsigned int value);
49extern void add_interrupt_randomness(int irq);
50
51extern void get_random_bytes(void *buf, int nbytes);
52void generate_random_uuid(unsigned char uuid_out[16]);
53
54extern __u32 secure_ip_id(__u32 daddr);
55extern u32 secure_tcp_port_ephemeral(__u32 saddr, __u32 daddr, __u16 dport);
56extern u32 secure_tcpv6_port_ephemeral(const __u32 *saddr, const __u32 *daddr,
57 __u16 dport);
58extern __u32 secure_tcp_sequence_number(__u32 saddr, __u32 daddr,
59 __u16 sport, __u16 dport);
60extern __u32 secure_tcpv6_sequence_number(__u32 *saddr, __u32 *daddr,
61 __u16 sport, __u16 dport);
62
63#ifndef MODULE
64extern struct file_operations random_fops, urandom_fops;
65#endif
66
67unsigned int get_random_int(void);
68unsigned long randomize_range(unsigned long start, unsigned long end, unsigned long len);
69
70#endif /* __KERNEL___ */
71
72#endif /* _LINUX_RANDOM_H */
diff --git a/include/linux/raw.h b/include/linux/raw.h
new file mode 100644
index 000000000000..62d543e70603
--- /dev/null
+++ b/include/linux/raw.h
@@ -0,0 +1,18 @@
1#ifndef __LINUX_RAW_H
2#define __LINUX_RAW_H
3
4#include <linux/types.h>
5
6#define RAW_SETBIND _IO( 0xac, 0 )
7#define RAW_GETBIND _IO( 0xac, 1 )
8
9struct raw_config_request
10{
11 int raw_minor;
12 __u64 block_major;
13 __u64 block_minor;
14};
15
16#define MAX_RAW_MINORS CONFIG_MAX_RAW_DEVS
17
18#endif /* __LINUX_RAW_H */
diff --git a/include/linux/rbtree.h b/include/linux/rbtree.h
new file mode 100644
index 000000000000..4b7cc4fe366d
--- /dev/null
+++ b/include/linux/rbtree.h
@@ -0,0 +1,141 @@
1/*
2 Red Black Trees
3 (C) 1999 Andrea Arcangeli <andrea@suse.de>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 linux/include/linux/rbtree.h
20
21 To use rbtrees you'll have to implement your own insert and search cores.
22 This will avoid us to use callbacks and to drop drammatically performances.
23 I know it's not the cleaner way, but in C (not in C++) to get
24 performances and genericity...
25
26 Some example of insert and search follows here. The search is a plain
27 normal search over an ordered tree. The insert instead must be implemented
28 int two steps: as first thing the code must insert the element in
29 order as a red leaf in the tree, then the support library function
30 rb_insert_color() must be called. Such function will do the
31 not trivial work to rebalance the rbtree if necessary.
32
33-----------------------------------------------------------------------
34static inline struct page * rb_search_page_cache(struct inode * inode,
35 unsigned long offset)
36{
37 struct rb_node * n = inode->i_rb_page_cache.rb_node;
38 struct page * page;
39
40 while (n)
41 {
42 page = rb_entry(n, struct page, rb_page_cache);
43
44 if (offset < page->offset)
45 n = n->rb_left;
46 else if (offset > page->offset)
47 n = n->rb_right;
48 else
49 return page;
50 }
51 return NULL;
52}
53
54static inline struct page * __rb_insert_page_cache(struct inode * inode,
55 unsigned long offset,
56 struct rb_node * node)
57{
58 struct rb_node ** p = &inode->i_rb_page_cache.rb_node;
59 struct rb_node * parent = NULL;
60 struct page * page;
61
62 while (*p)
63 {
64 parent = *p;
65 page = rb_entry(parent, struct page, rb_page_cache);
66
67 if (offset < page->offset)
68 p = &(*p)->rb_left;
69 else if (offset > page->offset)
70 p = &(*p)->rb_right;
71 else
72 return page;
73 }
74
75 rb_link_node(node, parent, p);
76
77 return NULL;
78}
79
80static inline struct page * rb_insert_page_cache(struct inode * inode,
81 unsigned long offset,
82 struct rb_node * node)
83{
84 struct page * ret;
85 if ((ret = __rb_insert_page_cache(inode, offset, node)))
86 goto out;
87 rb_insert_color(node, &inode->i_rb_page_cache);
88 out:
89 return ret;
90}
91-----------------------------------------------------------------------
92*/
93
94#ifndef _LINUX_RBTREE_H
95#define _LINUX_RBTREE_H
96
97#include <linux/kernel.h>
98#include <linux/stddef.h>
99
100struct rb_node
101{
102 struct rb_node *rb_parent;
103 int rb_color;
104#define RB_RED 0
105#define RB_BLACK 1
106 struct rb_node *rb_right;
107 struct rb_node *rb_left;
108};
109
110struct rb_root
111{
112 struct rb_node *rb_node;
113};
114
115#define RB_ROOT (struct rb_root) { NULL, }
116#define rb_entry(ptr, type, member) container_of(ptr, type, member)
117
118extern void rb_insert_color(struct rb_node *, struct rb_root *);
119extern void rb_erase(struct rb_node *, struct rb_root *);
120
121/* Find logical next and previous nodes in a tree */
122extern struct rb_node *rb_next(struct rb_node *);
123extern struct rb_node *rb_prev(struct rb_node *);
124extern struct rb_node *rb_first(struct rb_root *);
125extern struct rb_node *rb_last(struct rb_root *);
126
127/* Fast replacement of a single node without remove/rebalance/add/rebalance */
128extern void rb_replace_node(struct rb_node *victim, struct rb_node *new,
129 struct rb_root *root);
130
131static inline void rb_link_node(struct rb_node * node, struct rb_node * parent,
132 struct rb_node ** rb_link)
133{
134 node->rb_parent = parent;
135 node->rb_color = RB_RED;
136 node->rb_left = node->rb_right = NULL;
137
138 *rb_link = node;
139}
140
141#endif /* _LINUX_RBTREE_H */
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
new file mode 100644
index 000000000000..4d747433916b
--- /dev/null
+++ b/include/linux/rcupdate.h
@@ -0,0 +1,271 @@
1/*
2 * Read-Copy Update mechanism for mutual exclusion
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 * Copyright (C) IBM Corporation, 2001
19 *
20 * Author: Dipankar Sarma <dipankar@in.ibm.com>
21 *
22 * Based on the original work by Paul McKenney <paul.mckenney@us.ibm.com>
23 * and inputs from Rusty Russell, Andrea Arcangeli and Andi Kleen.
24 * Papers:
25 * http://www.rdrop.com/users/paulmck/paper/rclockpdcsproof.pdf
26 * http://lse.sourceforge.net/locking/rclock_OLS.2001.05.01c.sc.pdf (OLS2001)
27 *
28 * For detailed explanation of Read-Copy Update mechanism see -
29 * http://lse.sourceforge.net/locking/rcupdate.html
30 *
31 */
32
33#ifndef __LINUX_RCUPDATE_H
34#define __LINUX_RCUPDATE_H
35
36#ifdef __KERNEL__
37
38#include <linux/cache.h>
39#include <linux/spinlock.h>
40#include <linux/threads.h>
41#include <linux/percpu.h>
42#include <linux/cpumask.h>
43#include <linux/seqlock.h>
44
45/**
46 * struct rcu_head - callback structure for use with RCU
47 * @next: next update requests in a list
48 * @func: actual update function to call after the grace period.
49 */
50struct rcu_head {
51 struct rcu_head *next;
52 void (*func)(struct rcu_head *head);
53};
54
55#define RCU_HEAD_INIT(head) { .next = NULL, .func = NULL }
56#define RCU_HEAD(head) struct rcu_head head = RCU_HEAD_INIT(head)
57#define INIT_RCU_HEAD(ptr) do { \
58 (ptr)->next = NULL; (ptr)->func = NULL; \
59} while (0)
60
61
62
63/* Global control variables for rcupdate callback mechanism. */
64struct rcu_ctrlblk {
65 long cur; /* Current batch number. */
66 long completed; /* Number of the last completed batch */
67 int next_pending; /* Is the next batch already waiting? */
68} ____cacheline_maxaligned_in_smp;
69
70/* Is batch a before batch b ? */
71static inline int rcu_batch_before(long a, long b)
72{
73 return (a - b) < 0;
74}
75
76/* Is batch a after batch b ? */
77static inline int rcu_batch_after(long a, long b)
78{
79 return (a - b) > 0;
80}
81
82/*
83 * Per-CPU data for Read-Copy UPdate.
84 * nxtlist - new callbacks are added here
85 * curlist - current batch for which quiescent cycle started if any
86 */
87struct rcu_data {
88 /* 1) quiescent state handling : */
89 long quiescbatch; /* Batch # for grace period */
90 int passed_quiesc; /* User-mode/idle loop etc. */
91 int qs_pending; /* core waits for quiesc state */
92
93 /* 2) batch handling */
94 long batch; /* Batch # for current RCU batch */
95 struct rcu_head *nxtlist;
96 struct rcu_head **nxttail;
97 struct rcu_head *curlist;
98 struct rcu_head **curtail;
99 struct rcu_head *donelist;
100 struct rcu_head **donetail;
101 int cpu;
102};
103
104DECLARE_PER_CPU(struct rcu_data, rcu_data);
105DECLARE_PER_CPU(struct rcu_data, rcu_bh_data);
106extern struct rcu_ctrlblk rcu_ctrlblk;
107extern struct rcu_ctrlblk rcu_bh_ctrlblk;
108
109/*
110 * Increment the quiescent state counter.
111 * The counter is a bit degenerated: We do not need to know
112 * how many quiescent states passed, just if there was at least
113 * one since the start of the grace period. Thus just a flag.
114 */
115static inline void rcu_qsctr_inc(int cpu)
116{
117 struct rcu_data *rdp = &per_cpu(rcu_data, cpu);
118 rdp->passed_quiesc = 1;
119}
120static inline void rcu_bh_qsctr_inc(int cpu)
121{
122 struct rcu_data *rdp = &per_cpu(rcu_bh_data, cpu);
123 rdp->passed_quiesc = 1;
124}
125
126static inline int __rcu_pending(struct rcu_ctrlblk *rcp,
127 struct rcu_data *rdp)
128{
129 /* This cpu has pending rcu entries and the grace period
130 * for them has completed.
131 */
132 if (rdp->curlist && !rcu_batch_before(rcp->completed, rdp->batch))
133 return 1;
134
135 /* This cpu has no pending entries, but there are new entries */
136 if (!rdp->curlist && rdp->nxtlist)
137 return 1;
138
139 /* This cpu has finished callbacks to invoke */
140 if (rdp->donelist)
141 return 1;
142
143 /* The rcu core waits for a quiescent state from the cpu */
144 if (rdp->quiescbatch != rcp->cur || rdp->qs_pending)
145 return 1;
146
147 /* nothing to do */
148 return 0;
149}
150
151static inline int rcu_pending(int cpu)
152{
153 return __rcu_pending(&rcu_ctrlblk, &per_cpu(rcu_data, cpu)) ||
154 __rcu_pending(&rcu_bh_ctrlblk, &per_cpu(rcu_bh_data, cpu));
155}
156
157/**
158 * rcu_read_lock - mark the beginning of an RCU read-side critical section.
159 *
160 * When synchronize_kernel() is invoked on one CPU while other CPUs
161 * are within RCU read-side critical sections, then the
162 * synchronize_kernel() is guaranteed to block until after all the other
163 * CPUs exit their critical sections. Similarly, if call_rcu() is invoked
164 * on one CPU while other CPUs are within RCU read-side critical
165 * sections, invocation of the corresponding RCU callback is deferred
166 * until after the all the other CPUs exit their critical sections.
167 *
168 * Note, however, that RCU callbacks are permitted to run concurrently
169 * with RCU read-side critical sections. One way that this can happen
170 * is via the following sequence of events: (1) CPU 0 enters an RCU
171 * read-side critical section, (2) CPU 1 invokes call_rcu() to register
172 * an RCU callback, (3) CPU 0 exits the RCU read-side critical section,
173 * (4) CPU 2 enters a RCU read-side critical section, (5) the RCU
174 * callback is invoked. This is legal, because the RCU read-side critical
175 * section that was running concurrently with the call_rcu() (and which
176 * therefore might be referencing something that the corresponding RCU
177 * callback would free up) has completed before the corresponding
178 * RCU callback is invoked.
179 *
180 * RCU read-side critical sections may be nested. Any deferred actions
181 * will be deferred until the outermost RCU read-side critical section
182 * completes.
183 *
184 * It is illegal to block while in an RCU read-side critical section.
185 */
186#define rcu_read_lock() preempt_disable()
187
188/**
189 * rcu_read_unlock - marks the end of an RCU read-side critical section.
190 *
191 * See rcu_read_lock() for more information.
192 */
193#define rcu_read_unlock() preempt_enable()
194
195/*
196 * So where is rcu_write_lock()? It does not exist, as there is no
197 * way for writers to lock out RCU readers. This is a feature, not
198 * a bug -- this property is what provides RCU's performance benefits.
199 * Of course, writers must coordinate with each other. The normal
200 * spinlock primitives work well for this, but any other technique may be
201 * used as well. RCU does not care how the writers keep out of each
202 * others' way, as long as they do so.
203 */
204
205/**
206 * rcu_read_lock_bh - mark the beginning of a softirq-only RCU critical section
207 *
208 * This is equivalent of rcu_read_lock(), but to be used when updates
209 * are being done using call_rcu_bh(). Since call_rcu_bh() callbacks
210 * consider completion of a softirq handler to be a quiescent state,
211 * a process in RCU read-side critical section must be protected by
212 * disabling softirqs. Read-side critical sections in interrupt context
213 * can use just rcu_read_lock().
214 *
215 */
216#define rcu_read_lock_bh() local_bh_disable()
217
218/*
219 * rcu_read_unlock_bh - marks the end of a softirq-only RCU critical section
220 *
221 * See rcu_read_lock_bh() for more information.
222 */
223#define rcu_read_unlock_bh() local_bh_enable()
224
225/**
226 * rcu_dereference - fetch an RCU-protected pointer in an
227 * RCU read-side critical section. This pointer may later
228 * be safely dereferenced.
229 *
230 * Inserts memory barriers on architectures that require them
231 * (currently only the Alpha), and, more importantly, documents
232 * exactly which pointers are protected by RCU.
233 */
234
235#define rcu_dereference(p) ({ \
236 typeof(p) _________p1 = p; \
237 smp_read_barrier_depends(); \
238 (_________p1); \
239 })
240
241/**
242 * rcu_assign_pointer - assign (publicize) a pointer to a newly
243 * initialized structure that will be dereferenced by RCU read-side
244 * critical sections. Returns the value assigned.
245 *
246 * Inserts memory barriers on architectures that require them
247 * (pretty much all of them other than x86), and also prevents
248 * the compiler from reordering the code that initializes the
249 * structure after the pointer assignment. More importantly, this
250 * call documents which pointers will be dereferenced by RCU read-side
251 * code.
252 */
253
254#define rcu_assign_pointer(p, v) ({ \
255 smp_wmb(); \
256 (p) = (v); \
257 })
258
259extern void rcu_init(void);
260extern void rcu_check_callbacks(int cpu, int user);
261extern void rcu_restart_cpu(int cpu);
262
263/* Exported interfaces */
264extern void FASTCALL(call_rcu(struct rcu_head *head,
265 void (*func)(struct rcu_head *head)));
266extern void FASTCALL(call_rcu_bh(struct rcu_head *head,
267 void (*func)(struct rcu_head *head)));
268extern void synchronize_kernel(void);
269
270#endif /* __KERNEL__ */
271#endif /* __LINUX_RCUPDATE_H */
diff --git a/include/linux/reboot.h b/include/linux/reboot.h
new file mode 100644
index 000000000000..d60fafc8bdc5
--- /dev/null
+++ b/include/linux/reboot.h
@@ -0,0 +1,56 @@
1#ifndef _LINUX_REBOOT_H
2#define _LINUX_REBOOT_H
3
4/*
5 * Magic values required to use _reboot() system call.
6 */
7
8#define LINUX_REBOOT_MAGIC1 0xfee1dead
9#define LINUX_REBOOT_MAGIC2 672274793
10#define LINUX_REBOOT_MAGIC2A 85072278
11#define LINUX_REBOOT_MAGIC2B 369367448
12#define LINUX_REBOOT_MAGIC2C 537993216
13
14
15/*
16 * Commands accepted by the _reboot() system call.
17 *
18 * RESTART Restart system using default command and mode.
19 * HALT Stop OS and give system control to ROM monitor, if any.
20 * CAD_ON Ctrl-Alt-Del sequence causes RESTART command.
21 * CAD_OFF Ctrl-Alt-Del sequence sends SIGINT to init task.
22 * POWER_OFF Stop OS and remove all power from system, if possible.
23 * RESTART2 Restart system using given command string.
24 * SW_SUSPEND Suspend system using software suspend if compiled in.
25 * KEXEC Restart system using a previously loaded Linux kernel
26 */
27
28#define LINUX_REBOOT_CMD_RESTART 0x01234567
29#define LINUX_REBOOT_CMD_HALT 0xCDEF0123
30#define LINUX_REBOOT_CMD_CAD_ON 0x89ABCDEF
31#define LINUX_REBOOT_CMD_CAD_OFF 0x00000000
32#define LINUX_REBOOT_CMD_POWER_OFF 0x4321FEDC
33#define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
34#define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
35#define LINUX_REBOOT_CMD_KEXEC 0x45584543
36
37
38#ifdef __KERNEL__
39
40#include <linux/notifier.h>
41
42extern int register_reboot_notifier(struct notifier_block *);
43extern int unregister_reboot_notifier(struct notifier_block *);
44
45
46/*
47 * Architecture-specific implementations of sys_reboot commands.
48 */
49
50extern void machine_restart(char *cmd);
51extern void machine_halt(void);
52extern void machine_power_off(void);
53
54#endif
55
56#endif /* _LINUX_REBOOT_H */
diff --git a/include/linux/reiserfs_acl.h b/include/linux/reiserfs_acl.h
new file mode 100644
index 000000000000..a57e973af0bd
--- /dev/null
+++ b/include/linux/reiserfs_acl.h
@@ -0,0 +1,89 @@
1#include <linux/init.h>
2#include <linux/posix_acl.h>
3#include <linux/xattr_acl.h>
4
5#define REISERFS_ACL_VERSION 0x0001
6
7typedef struct {
8 __u16 e_tag;
9 __u16 e_perm;
10 __u32 e_id;
11} reiserfs_acl_entry;
12
13typedef struct {
14 __u16 e_tag;
15 __u16 e_perm;
16} reiserfs_acl_entry_short;
17
18typedef struct {
19 __u32 a_version;
20} reiserfs_acl_header;
21
22static inline size_t reiserfs_acl_size(int count)
23{
24 if (count <= 4) {
25 return sizeof(reiserfs_acl_header) +
26 count * sizeof(reiserfs_acl_entry_short);
27 } else {
28 return sizeof(reiserfs_acl_header) +
29 4 * sizeof(reiserfs_acl_entry_short) +
30 (count - 4) * sizeof(reiserfs_acl_entry);
31 }
32}
33
34static inline int reiserfs_acl_count(size_t size)
35{
36 ssize_t s;
37 size -= sizeof(reiserfs_acl_header);
38 s = size - 4 * sizeof(reiserfs_acl_entry_short);
39 if (s < 0) {
40 if (size % sizeof(reiserfs_acl_entry_short))
41 return -1;
42 return size / sizeof(reiserfs_acl_entry_short);
43 } else {
44 if (s % sizeof(reiserfs_acl_entry))
45 return -1;
46 return s / sizeof(reiserfs_acl_entry) + 4;
47 }
48}
49
50
51#ifdef CONFIG_REISERFS_FS_POSIX_ACL
52struct posix_acl * reiserfs_get_acl(struct inode *inode, int type);
53int reiserfs_acl_chmod (struct inode *inode);
54int reiserfs_inherit_default_acl (struct inode *dir, struct dentry *dentry, struct inode *inode);
55int reiserfs_cache_default_acl (struct inode *dir);
56extern int reiserfs_xattr_posix_acl_init (void) __init;
57extern int reiserfs_xattr_posix_acl_exit (void);
58extern struct reiserfs_xattr_handler posix_acl_default_handler;
59extern struct reiserfs_xattr_handler posix_acl_access_handler;
60#else
61
62#define reiserfs_get_acl NULL
63#define reiserfs_cache_default_acl(inode) 0
64
65static inline int
66reiserfs_xattr_posix_acl_init (void)
67{
68 return 0;
69}
70
71static inline int
72reiserfs_xattr_posix_acl_exit (void)
73{
74 return 0;
75}
76
77static inline int
78reiserfs_acl_chmod (struct inode *inode)
79{
80 return 0;
81}
82
83static inline int
84reiserfs_inherit_default_acl (const struct inode *dir, struct dentry *dentry, struct inode *inode)
85{
86 return 0;
87}
88
89#endif
diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h
new file mode 100644
index 000000000000..bccff8b17dc4
--- /dev/null
+++ b/include/linux/reiserfs_fs.h
@@ -0,0 +1,2255 @@
1/*
2 * Copyright 1996, 1997, 1998 Hans Reiser, see reiserfs/README for licensing and copyright details
3 */
4
5 /* this file has an amazingly stupid
6 name, yura please fix it to be
7 reiserfs.h, and merge all the rest
8 of our .h files that are in this
9 directory into it. */
10
11
12#ifndef _LINUX_REISER_FS_H
13#define _LINUX_REISER_FS_H
14
15#include <linux/types.h>
16#ifdef __KERNEL__
17#include <linux/slab.h>
18#include <linux/interrupt.h>
19#include <linux/sched.h>
20#include <linux/workqueue.h>
21#include <asm/unaligned.h>
22#include <linux/bitops.h>
23#include <linux/proc_fs.h>
24#include <linux/smp_lock.h>
25#include <linux/buffer_head.h>
26#include <linux/reiserfs_fs_i.h>
27#include <linux/reiserfs_fs_sb.h>
28#endif
29
30/*
31 * include/linux/reiser_fs.h
32 *
33 * Reiser File System constants and structures
34 *
35 */
36
37/* in reading the #defines, it may help to understand that they employ
38 the following abbreviations:
39
40 B = Buffer
41 I = Item header
42 H = Height within the tree (should be changed to LEV)
43 N = Number of the item in the node
44 STAT = stat data
45 DEH = Directory Entry Header
46 EC = Entry Count
47 E = Entry number
48 UL = Unsigned Long
49 BLKH = BLocK Header
50 UNFM = UNForMatted node
51 DC = Disk Child
52 P = Path
53
54 These #defines are named by concatenating these abbreviations,
55 where first comes the arguments, and last comes the return value,
56 of the macro.
57
58*/
59
60#define USE_INODE_GENERATION_COUNTER
61
62#define REISERFS_PREALLOCATE
63#define DISPLACE_NEW_PACKING_LOCALITIES
64#define PREALLOCATION_SIZE 9
65
66/* n must be power of 2 */
67#define _ROUND_UP(x,n) (((x)+(n)-1u) & ~((n)-1u))
68
69// to be ok for alpha and others we have to align structures to 8 byte
70// boundary.
71// FIXME: do not change 4 by anything else: there is code which relies on that
72#define ROUND_UP(x) _ROUND_UP(x,8LL)
73
74/* debug levels. Right now, CONFIG_REISERFS_CHECK means print all debug
75** messages.
76*/
77#define REISERFS_DEBUG_CODE 5 /* extra messages to help find/debug errors */
78
79void reiserfs_warning (struct super_block *s, const char * fmt, ...);
80/* assertions handling */
81
82/** always check a condition and panic if it's false. */
83#define RASSERT( cond, format, args... ) \
84if( !( cond ) ) \
85 reiserfs_panic( NULL, "reiserfs[%i]: assertion " #cond " failed at " \
86 __FILE__ ":%i:%s: " format "\n", \
87 in_interrupt() ? -1 : current -> pid, __LINE__ , __FUNCTION__ , ##args )
88
89#if defined( CONFIG_REISERFS_CHECK )
90#define RFALSE( cond, format, args... ) RASSERT( !( cond ), format, ##args )
91#else
92#define RFALSE( cond, format, args... ) do {;} while( 0 )
93#endif
94
95#define CONSTF __attribute_const__
96/*
97 * Disk Data Structures
98 */
99
100/***************************************************************************/
101/* SUPER BLOCK */
102/***************************************************************************/
103
104/*
105 * Structure of super block on disk, a version of which in RAM is often accessed as REISERFS_SB(s)->s_rs
106 * the version in RAM is part of a larger structure containing fields never written to disk.
107 */
108#define UNSET_HASH 0 // read_super will guess about, what hash names
109 // in directories were sorted with
110#define TEA_HASH 1
111#define YURA_HASH 2
112#define R5_HASH 3
113#define DEFAULT_HASH R5_HASH
114
115
116struct journal_params {
117 __u32 jp_journal_1st_block; /* where does journal start from on its
118 * device */
119 __u32 jp_journal_dev; /* journal device st_rdev */
120 __u32 jp_journal_size; /* size of the journal */
121 __u32 jp_journal_trans_max; /* max number of blocks in a transaction. */
122 __u32 jp_journal_magic; /* random value made on fs creation (this
123 * was sb_journal_block_count) */
124 __u32 jp_journal_max_batch; /* max number of blocks to batch into a
125 * trans */
126 __u32 jp_journal_max_commit_age; /* in seconds, how old can an async
127 * commit be */
128 __u32 jp_journal_max_trans_age; /* in seconds, how old can a transaction
129 * be */
130};
131
132/* this is the super from 3.5.X, where X >= 10 */
133struct reiserfs_super_block_v1
134{
135 __u32 s_block_count; /* blocks count */
136 __u32 s_free_blocks; /* free blocks count */
137 __u32 s_root_block; /* root block number */
138 struct journal_params s_journal;
139 __u16 s_blocksize; /* block size */
140 __u16 s_oid_maxsize; /* max size of object id array, see
141 * get_objectid() commentary */
142 __u16 s_oid_cursize; /* current size of object id array */
143 __u16 s_umount_state; /* this is set to 1 when filesystem was
144 * umounted, to 2 - when not */
145 char s_magic[10]; /* reiserfs magic string indicates that
146 * file system is reiserfs:
147 * "ReIsErFs" or "ReIsEr2Fs" or "ReIsEr3Fs" */
148 __u16 s_fs_state; /* it is set to used by fsck to mark which
149 * phase of rebuilding is done */
150 __u32 s_hash_function_code; /* indicate, what hash function is being use
151 * to sort names in a directory*/
152 __u16 s_tree_height; /* height of disk tree */
153 __u16 s_bmap_nr; /* amount of bitmap blocks needed to address
154 * each block of file system */
155 __u16 s_version; /* this field is only reliable on filesystem
156 * with non-standard journal */
157 __u16 s_reserved_for_journal; /* size in blocks of journal area on main
158 * device, we need to keep after
159 * making fs with non-standard journal */
160} __attribute__ ((__packed__));
161
162#define SB_SIZE_V1 (sizeof(struct reiserfs_super_block_v1))
163
164/* this is the on disk super block */
165struct reiserfs_super_block
166{
167 struct reiserfs_super_block_v1 s_v1;
168 __u32 s_inode_generation;
169 __u32 s_flags; /* Right now used only by inode-attributes, if enabled */
170 unsigned char s_uuid[16]; /* filesystem unique identifier */
171 unsigned char s_label[16]; /* filesystem volume label */
172 char s_unused[88] ; /* zero filled by mkreiserfs and
173 * reiserfs_convert_objectid_map_v1()
174 * so any additions must be updated
175 * there as well. */
176} __attribute__ ((__packed__));
177
178#define SB_SIZE (sizeof(struct reiserfs_super_block))
179
180#define REISERFS_VERSION_1 0
181#define REISERFS_VERSION_2 2
182
183
184// on-disk super block fields converted to cpu form
185#define SB_DISK_SUPER_BLOCK(s) (REISERFS_SB(s)->s_rs)
186#define SB_V1_DISK_SUPER_BLOCK(s) (&(SB_DISK_SUPER_BLOCK(s)->s_v1))
187#define SB_BLOCKSIZE(s) \
188 le32_to_cpu ((SB_V1_DISK_SUPER_BLOCK(s)->s_blocksize))
189#define SB_BLOCK_COUNT(s) \
190 le32_to_cpu ((SB_V1_DISK_SUPER_BLOCK(s)->s_block_count))
191#define SB_FREE_BLOCKS(s) \
192 le32_to_cpu ((SB_V1_DISK_SUPER_BLOCK(s)->s_free_blocks))
193#define SB_REISERFS_MAGIC(s) \
194 (SB_V1_DISK_SUPER_BLOCK(s)->s_magic)
195#define SB_ROOT_BLOCK(s) \
196 le32_to_cpu ((SB_V1_DISK_SUPER_BLOCK(s)->s_root_block))
197#define SB_TREE_HEIGHT(s) \
198 le16_to_cpu ((SB_V1_DISK_SUPER_BLOCK(s)->s_tree_height))
199#define SB_REISERFS_STATE(s) \
200 le16_to_cpu ((SB_V1_DISK_SUPER_BLOCK(s)->s_umount_state))
201#define SB_VERSION(s) le16_to_cpu ((SB_V1_DISK_SUPER_BLOCK(s)->s_version))
202#define SB_BMAP_NR(s) le16_to_cpu ((SB_V1_DISK_SUPER_BLOCK(s)->s_bmap_nr))
203
204#define PUT_SB_BLOCK_COUNT(s, val) \
205 do { SB_V1_DISK_SUPER_BLOCK(s)->s_block_count = cpu_to_le32(val); } while (0)
206#define PUT_SB_FREE_BLOCKS(s, val) \
207 do { SB_V1_DISK_SUPER_BLOCK(s)->s_free_blocks = cpu_to_le32(val); } while (0)
208#define PUT_SB_ROOT_BLOCK(s, val) \
209 do { SB_V1_DISK_SUPER_BLOCK(s)->s_root_block = cpu_to_le32(val); } while (0)
210#define PUT_SB_TREE_HEIGHT(s, val) \
211 do { SB_V1_DISK_SUPER_BLOCK(s)->s_tree_height = cpu_to_le16(val); } while (0)
212#define PUT_SB_REISERFS_STATE(s, val) \
213 do { SB_V1_DISK_SUPER_BLOCK(s)->s_umount_state = cpu_to_le16(val); } while (0)
214#define PUT_SB_VERSION(s, val) \
215 do { SB_V1_DISK_SUPER_BLOCK(s)->s_version = cpu_to_le16(val); } while (0)
216#define PUT_SB_BMAP_NR(s, val) \
217 do { SB_V1_DISK_SUPER_BLOCK(s)->s_bmap_nr = cpu_to_le16 (val); } while (0)
218
219
220#define SB_ONDISK_JP(s) (&SB_V1_DISK_SUPER_BLOCK(s)->s_journal)
221#define SB_ONDISK_JOURNAL_SIZE(s) \
222 le32_to_cpu ((SB_ONDISK_JP(s)->jp_journal_size))
223#define SB_ONDISK_JOURNAL_1st_BLOCK(s) \
224 le32_to_cpu ((SB_ONDISK_JP(s)->jp_journal_1st_block))
225#define SB_ONDISK_JOURNAL_DEVICE(s) \
226 le32_to_cpu ((SB_ONDISK_JP(s)->jp_journal_dev))
227#define SB_ONDISK_RESERVED_FOR_JOURNAL(s) \
228 le32_to_cpu ((SB_V1_DISK_SUPER_BLOCK(s)->s_reserved_for_journal))
229
230#define is_block_in_log_or_reserved_area(s, block) \
231 block >= SB_JOURNAL_1st_RESERVED_BLOCK(s) \
232 && block < SB_JOURNAL_1st_RESERVED_BLOCK(s) + \
233 ((!is_reiserfs_jr(SB_DISK_SUPER_BLOCK(s)) ? \
234 SB_ONDISK_JOURNAL_SIZE(s) + 1 : SB_ONDISK_RESERVED_FOR_JOURNAL(s)))
235
236
237
238 /* used by gcc */
239#define REISERFS_SUPER_MAGIC 0x52654973
240 /* used by file system utilities that
241 look at the superblock, etc. */
242#define REISERFS_SUPER_MAGIC_STRING "ReIsErFs"
243#define REISER2FS_SUPER_MAGIC_STRING "ReIsEr2Fs"
244#define REISER2FS_JR_SUPER_MAGIC_STRING "ReIsEr3Fs"
245
246int is_reiserfs_3_5 (struct reiserfs_super_block * rs);
247int is_reiserfs_3_6 (struct reiserfs_super_block * rs);
248int is_reiserfs_jr (struct reiserfs_super_block * rs);
249
250/* ReiserFS leaves the first 64k unused, so that partition labels have
251 enough space. If someone wants to write a fancy bootloader that
252 needs more than 64k, let us know, and this will be increased in size.
253 This number must be larger than than the largest block size on any
254 platform, or code will break. -Hans */
255#define REISERFS_DISK_OFFSET_IN_BYTES (64 * 1024)
256#define REISERFS_FIRST_BLOCK unused_define
257#define REISERFS_JOURNAL_OFFSET_IN_BYTES REISERFS_DISK_OFFSET_IN_BYTES
258
259/* the spot for the super in versions 3.5 - 3.5.10 (inclusive) */
260#define REISERFS_OLD_DISK_OFFSET_IN_BYTES (8 * 1024)
261
262// reiserfs internal error code (used by search_by_key adn fix_nodes))
263#define CARRY_ON 0
264#define REPEAT_SEARCH -1
265#define IO_ERROR -2
266#define NO_DISK_SPACE -3
267#define NO_BALANCING_NEEDED (-4)
268#define NO_MORE_UNUSED_CONTIGUOUS_BLOCKS (-5)
269#define QUOTA_EXCEEDED -6
270
271typedef __u32 b_blocknr_t;
272typedef __u32 unp_t;
273
274struct unfm_nodeinfo {
275 unp_t unfm_nodenum;
276 unsigned short unfm_freespace;
277};
278
279/* there are two formats of keys: 3.5 and 3.6
280 */
281#define KEY_FORMAT_3_5 0
282#define KEY_FORMAT_3_6 1
283
284/* there are two stat datas */
285#define STAT_DATA_V1 0
286#define STAT_DATA_V2 1
287
288
289static inline struct reiserfs_inode_info *REISERFS_I(const struct inode *inode)
290{
291 return container_of(inode, struct reiserfs_inode_info, vfs_inode);
292}
293
294static inline struct reiserfs_sb_info *REISERFS_SB(const struct super_block *sb)
295{
296 return sb->s_fs_info;
297}
298
299/** this says about version of key of all items (but stat data) the
300 object consists of */
301#define get_inode_item_key_version( inode ) \
302 ((REISERFS_I(inode)->i_flags & i_item_key_version_mask) ? KEY_FORMAT_3_6 : KEY_FORMAT_3_5)
303
304#define set_inode_item_key_version( inode, version ) \
305 ({ if((version)==KEY_FORMAT_3_6) \
306 REISERFS_I(inode)->i_flags |= i_item_key_version_mask; \
307 else \
308 REISERFS_I(inode)->i_flags &= ~i_item_key_version_mask; })
309
310#define get_inode_sd_version(inode) \
311 ((REISERFS_I(inode)->i_flags & i_stat_data_version_mask) ? STAT_DATA_V2 : STAT_DATA_V1)
312
313#define set_inode_sd_version(inode, version) \
314 ({ if((version)==STAT_DATA_V2) \
315 REISERFS_I(inode)->i_flags |= i_stat_data_version_mask; \
316 else \
317 REISERFS_I(inode)->i_flags &= ~i_stat_data_version_mask; })
318
319/* This is an aggressive tail suppression policy, I am hoping it
320 improves our benchmarks. The principle behind it is that percentage
321 space saving is what matters, not absolute space saving. This is
322 non-intuitive, but it helps to understand it if you consider that the
323 cost to access 4 blocks is not much more than the cost to access 1
324 block, if you have to do a seek and rotate. A tail risks a
325 non-linear disk access that is significant as a percentage of total
326 time cost for a 4 block file and saves an amount of space that is
327 less significant as a percentage of space, or so goes the hypothesis.
328 -Hans */
329#define STORE_TAIL_IN_UNFM_S1(n_file_size,n_tail_size,n_block_size) \
330(\
331 (!(n_tail_size)) || \
332 (((n_tail_size) > MAX_DIRECT_ITEM_LEN(n_block_size)) || \
333 ( (n_file_size) >= (n_block_size) * 4 ) || \
334 ( ( (n_file_size) >= (n_block_size) * 3 ) && \
335 ( (n_tail_size) >= (MAX_DIRECT_ITEM_LEN(n_block_size))/4) ) || \
336 ( ( (n_file_size) >= (n_block_size) * 2 ) && \
337 ( (n_tail_size) >= (MAX_DIRECT_ITEM_LEN(n_block_size))/2) ) || \
338 ( ( (n_file_size) >= (n_block_size) ) && \
339 ( (n_tail_size) >= (MAX_DIRECT_ITEM_LEN(n_block_size) * 3)/4) ) ) \
340)
341
342/* Another strategy for tails, this one means only create a tail if all the
343 file would fit into one DIRECT item.
344 Primary intention for this one is to increase performance by decreasing
345 seeking.
346*/
347#define STORE_TAIL_IN_UNFM_S2(n_file_size,n_tail_size,n_block_size) \
348(\
349 (!(n_tail_size)) || \
350 (((n_file_size) > MAX_DIRECT_ITEM_LEN(n_block_size)) ) \
351)
352
353
354
355/*
356 * values for s_umount_state field
357 */
358#define REISERFS_VALID_FS 1
359#define REISERFS_ERROR_FS 2
360
361//
362// there are 5 item types currently
363//
364#define TYPE_STAT_DATA 0
365#define TYPE_INDIRECT 1
366#define TYPE_DIRECT 2
367#define TYPE_DIRENTRY 3
368#define TYPE_MAXTYPE 3
369#define TYPE_ANY 15 // FIXME: comment is required
370
371/***************************************************************************/
372/* KEY & ITEM HEAD */
373/***************************************************************************/
374
375//
376// directories use this key as well as old files
377//
378struct offset_v1 {
379 __u32 k_offset;
380 __u32 k_uniqueness;
381} __attribute__ ((__packed__));
382
383struct offset_v2 {
384#ifdef __LITTLE_ENDIAN
385 /* little endian version */
386 __u64 k_offset:60;
387 __u64 k_type: 4;
388#else
389 /* big endian version */
390 __u64 k_type: 4;
391 __u64 k_offset:60;
392#endif
393} __attribute__ ((__packed__));
394
395#ifndef __LITTLE_ENDIAN
396typedef union {
397 struct offset_v2 offset_v2;
398 __u64 linear;
399} __attribute__ ((__packed__)) offset_v2_esafe_overlay;
400
401static inline __u16 offset_v2_k_type( const struct offset_v2 *v2 )
402{
403 offset_v2_esafe_overlay tmp = *(const offset_v2_esafe_overlay *)v2;
404 tmp.linear = le64_to_cpu( tmp.linear );
405 return (tmp.offset_v2.k_type <= TYPE_MAXTYPE)?tmp.offset_v2.k_type:TYPE_ANY;
406}
407
408static inline void set_offset_v2_k_type( struct offset_v2 *v2, int type )
409{
410 offset_v2_esafe_overlay *tmp = (offset_v2_esafe_overlay *)v2;
411 tmp->linear = le64_to_cpu(tmp->linear);
412 tmp->offset_v2.k_type = type;
413 tmp->linear = cpu_to_le64(tmp->linear);
414}
415
416static inline loff_t offset_v2_k_offset( const struct offset_v2 *v2 )
417{
418 offset_v2_esafe_overlay tmp = *(const offset_v2_esafe_overlay *)v2;
419 tmp.linear = le64_to_cpu( tmp.linear );
420 return tmp.offset_v2.k_offset;
421}
422
423static inline void set_offset_v2_k_offset( struct offset_v2 *v2, loff_t offset ){
424 offset_v2_esafe_overlay *tmp = (offset_v2_esafe_overlay *)v2;
425 tmp->linear = le64_to_cpu(tmp->linear);
426 tmp->offset_v2.k_offset = offset;
427 tmp->linear = cpu_to_le64(tmp->linear);
428}
429#else
430# define offset_v2_k_type(v2) ((v2)->k_type)
431# define set_offset_v2_k_type(v2,val) (offset_v2_k_type(v2) = (val))
432# define offset_v2_k_offset(v2) ((v2)->k_offset)
433# define set_offset_v2_k_offset(v2,val) (offset_v2_k_offset(v2) = (val))
434#endif
435
436/* Key of an item determines its location in the S+tree, and
437 is composed of 4 components */
438struct reiserfs_key {
439 __u32 k_dir_id; /* packing locality: by default parent
440 directory object id */
441 __u32 k_objectid; /* object identifier */
442 union {
443 struct offset_v1 k_offset_v1;
444 struct offset_v2 k_offset_v2;
445 } __attribute__ ((__packed__)) u;
446} __attribute__ ((__packed__));
447
448
449struct cpu_key {
450 struct reiserfs_key on_disk_key;
451 int version;
452 int key_length; /* 3 in all cases but direct2indirect and
453 indirect2direct conversion */
454};
455
456/* Our function for comparing keys can compare keys of different
457 lengths. It takes as a parameter the length of the keys it is to
458 compare. These defines are used in determining what is to be passed
459 to it as that parameter. */
460#define REISERFS_FULL_KEY_LEN 4
461#define REISERFS_SHORT_KEY_LEN 2
462
463/* The result of the key compare */
464#define FIRST_GREATER 1
465#define SECOND_GREATER -1
466#define KEYS_IDENTICAL 0
467#define KEY_FOUND 1
468#define KEY_NOT_FOUND 0
469
470#define KEY_SIZE (sizeof(struct reiserfs_key))
471#define SHORT_KEY_SIZE (sizeof (__u32) + sizeof (__u32))
472
473/* return values for search_by_key and clones */
474#define ITEM_FOUND 1
475#define ITEM_NOT_FOUND 0
476#define ENTRY_FOUND 1
477#define ENTRY_NOT_FOUND 0
478#define DIRECTORY_NOT_FOUND -1
479#define REGULAR_FILE_FOUND -2
480#define DIRECTORY_FOUND -3
481#define BYTE_FOUND 1
482#define BYTE_NOT_FOUND 0
483#define FILE_NOT_FOUND -1
484
485#define POSITION_FOUND 1
486#define POSITION_NOT_FOUND 0
487
488// return values for reiserfs_find_entry and search_by_entry_key
489#define NAME_FOUND 1
490#define NAME_NOT_FOUND 0
491#define GOTO_PREVIOUS_ITEM 2
492#define NAME_FOUND_INVISIBLE 3
493
494/* Everything in the filesystem is stored as a set of items. The
495 item head contains the key of the item, its free space (for
496 indirect items) and specifies the location of the item itself
497 within the block. */
498
499struct item_head
500{
501 /* Everything in the tree is found by searching for it based on
502 * its key.*/
503 struct reiserfs_key ih_key;
504 union {
505 /* The free space in the last unformatted node of an
506 indirect item if this is an indirect item. This
507 equals 0xFFFF iff this is a direct item or stat data
508 item. Note that the key, not this field, is used to
509 determine the item type, and thus which field this
510 union contains. */
511 __u16 ih_free_space_reserved;
512 /* Iff this is a directory item, this field equals the
513 number of directory entries in the directory item. */
514 __u16 ih_entry_count;
515 } __attribute__ ((__packed__)) u;
516 __u16 ih_item_len; /* total size of the item body */
517 __u16 ih_item_location; /* an offset to the item body
518 * within the block */
519 __u16 ih_version; /* 0 for all old items, 2 for new
520 ones. Highest bit is set by fsck
521 temporary, cleaned after all
522 done */
523} __attribute__ ((__packed__));
524/* size of item header */
525#define IH_SIZE (sizeof(struct item_head))
526
527#define ih_free_space(ih) le16_to_cpu((ih)->u.ih_free_space_reserved)
528#define ih_version(ih) le16_to_cpu((ih)->ih_version)
529#define ih_entry_count(ih) le16_to_cpu((ih)->u.ih_entry_count)
530#define ih_location(ih) le16_to_cpu((ih)->ih_item_location)
531#define ih_item_len(ih) le16_to_cpu((ih)->ih_item_len)
532
533#define put_ih_free_space(ih, val) do { (ih)->u.ih_free_space_reserved = cpu_to_le16(val); } while(0)
534#define put_ih_version(ih, val) do { (ih)->ih_version = cpu_to_le16(val); } while (0)
535#define put_ih_entry_count(ih, val) do { (ih)->u.ih_entry_count = cpu_to_le16(val); } while (0)
536#define put_ih_location(ih, val) do { (ih)->ih_item_location = cpu_to_le16(val); } while (0)
537#define put_ih_item_len(ih, val) do { (ih)->ih_item_len = cpu_to_le16(val); } while (0)
538
539
540#define unreachable_item(ih) (ih_version(ih) & (1 << 15))
541
542#define get_ih_free_space(ih) (ih_version (ih) == KEY_FORMAT_3_6 ? 0 : ih_free_space (ih))
543#define set_ih_free_space(ih,val) put_ih_free_space((ih), ((ih_version(ih) == KEY_FORMAT_3_6) ? 0 : (val)))
544
545/* these operate on indirect items, where you've got an array of ints
546** at a possibly unaligned location. These are a noop on ia32
547**
548** p is the array of __u32, i is the index into the array, v is the value
549** to store there.
550*/
551#define get_block_num(p, i) le32_to_cpu(get_unaligned((p) + (i)))
552#define put_block_num(p, i, v) put_unaligned(cpu_to_le32(v), (p) + (i))
553
554//
555// in old version uniqueness field shows key type
556//
557#define V1_SD_UNIQUENESS 0
558#define V1_INDIRECT_UNIQUENESS 0xfffffffe
559#define V1_DIRECT_UNIQUENESS 0xffffffff
560#define V1_DIRENTRY_UNIQUENESS 500
561#define V1_ANY_UNIQUENESS 555 // FIXME: comment is required
562
563//
564// here are conversion routines
565//
566static inline int uniqueness2type (__u32 uniqueness) CONSTF;
567static inline int uniqueness2type (__u32 uniqueness)
568{
569 switch ((int)uniqueness) {
570 case V1_SD_UNIQUENESS: return TYPE_STAT_DATA;
571 case V1_INDIRECT_UNIQUENESS: return TYPE_INDIRECT;
572 case V1_DIRECT_UNIQUENESS: return TYPE_DIRECT;
573 case V1_DIRENTRY_UNIQUENESS: return TYPE_DIRENTRY;
574 default:
575 reiserfs_warning (NULL, "vs-500: unknown uniqueness %d",
576 uniqueness);
577 case V1_ANY_UNIQUENESS:
578 return TYPE_ANY;
579 }
580}
581
582static inline __u32 type2uniqueness (int type) CONSTF;
583static inline __u32 type2uniqueness (int type)
584{
585 switch (type) {
586 case TYPE_STAT_DATA: return V1_SD_UNIQUENESS;
587 case TYPE_INDIRECT: return V1_INDIRECT_UNIQUENESS;
588 case TYPE_DIRECT: return V1_DIRECT_UNIQUENESS;
589 case TYPE_DIRENTRY: return V1_DIRENTRY_UNIQUENESS;
590 default:
591 reiserfs_warning (NULL, "vs-501: unknown type %d", type);
592 case TYPE_ANY:
593 return V1_ANY_UNIQUENESS;
594 }
595}
596
597//
598// key is pointer to on disk key which is stored in le, result is cpu,
599// there is no way to get version of object from key, so, provide
600// version to these defines
601//
602static inline loff_t le_key_k_offset (int version, const struct reiserfs_key * key)
603{
604 return (version == KEY_FORMAT_3_5) ?
605 le32_to_cpu( key->u.k_offset_v1.k_offset ) :
606 offset_v2_k_offset( &(key->u.k_offset_v2) );
607}
608
609static inline loff_t le_ih_k_offset (const struct item_head * ih)
610{
611 return le_key_k_offset (ih_version (ih), &(ih->ih_key));
612}
613
614static inline loff_t le_key_k_type (int version, const struct reiserfs_key * key)
615{
616 return (version == KEY_FORMAT_3_5) ?
617 uniqueness2type( le32_to_cpu( key->u.k_offset_v1.k_uniqueness)) :
618 offset_v2_k_type( &(key->u.k_offset_v2) );
619}
620
621static inline loff_t le_ih_k_type (const struct item_head * ih)
622{
623 return le_key_k_type (ih_version (ih), &(ih->ih_key));
624}
625
626
627static inline void set_le_key_k_offset (int version, struct reiserfs_key * key, loff_t offset)
628{
629 (version == KEY_FORMAT_3_5) ?
630 (void)(key->u.k_offset_v1.k_offset = cpu_to_le32 (offset)) : /* jdm check */
631 (void)(set_offset_v2_k_offset( &(key->u.k_offset_v2), offset ));
632}
633
634
635static inline void set_le_ih_k_offset (struct item_head * ih, loff_t offset)
636{
637 set_le_key_k_offset (ih_version (ih), &(ih->ih_key), offset);
638}
639
640
641static inline void set_le_key_k_type (int version, struct reiserfs_key * key, int type)
642{
643 (version == KEY_FORMAT_3_5) ?
644 (void)(key->u.k_offset_v1.k_uniqueness = cpu_to_le32(type2uniqueness(type))):
645 (void)(set_offset_v2_k_type( &(key->u.k_offset_v2), type ));
646}
647static inline void set_le_ih_k_type (struct item_head * ih, int type)
648{
649 set_le_key_k_type (ih_version (ih), &(ih->ih_key), type);
650}
651
652
653#define is_direntry_le_key(version,key) (le_key_k_type (version, key) == TYPE_DIRENTRY)
654#define is_direct_le_key(version,key) (le_key_k_type (version, key) == TYPE_DIRECT)
655#define is_indirect_le_key(version,key) (le_key_k_type (version, key) == TYPE_INDIRECT)
656#define is_statdata_le_key(version,key) (le_key_k_type (version, key) == TYPE_STAT_DATA)
657
658//
659// item header has version.
660//
661#define is_direntry_le_ih(ih) is_direntry_le_key (ih_version (ih), &((ih)->ih_key))
662#define is_direct_le_ih(ih) is_direct_le_key (ih_version (ih), &((ih)->ih_key))
663#define is_indirect_le_ih(ih) is_indirect_le_key (ih_version(ih), &((ih)->ih_key))
664#define is_statdata_le_ih(ih) is_statdata_le_key (ih_version (ih), &((ih)->ih_key))
665
666
667
668//
669// key is pointer to cpu key, result is cpu
670//
671static inline loff_t cpu_key_k_offset (const struct cpu_key * key)
672{
673 return (key->version == KEY_FORMAT_3_5) ?
674 key->on_disk_key.u.k_offset_v1.k_offset :
675 key->on_disk_key.u.k_offset_v2.k_offset;
676}
677
678static inline loff_t cpu_key_k_type (const struct cpu_key * key)
679{
680 return (key->version == KEY_FORMAT_3_5) ?
681 uniqueness2type (key->on_disk_key.u.k_offset_v1.k_uniqueness) :
682 key->on_disk_key.u.k_offset_v2.k_type;
683}
684
685static inline void set_cpu_key_k_offset (struct cpu_key * key, loff_t offset)
686{
687 (key->version == KEY_FORMAT_3_5) ?
688 (key->on_disk_key.u.k_offset_v1.k_offset = offset) :
689 (key->on_disk_key.u.k_offset_v2.k_offset = offset);
690}
691
692
693static inline void set_cpu_key_k_type (struct cpu_key * key, int type)
694{
695 (key->version == KEY_FORMAT_3_5) ?
696 (key->on_disk_key.u.k_offset_v1.k_uniqueness = type2uniqueness (type)):
697 (key->on_disk_key.u.k_offset_v2.k_type = type);
698}
699
700
701static inline void cpu_key_k_offset_dec (struct cpu_key * key)
702{
703 if (key->version == KEY_FORMAT_3_5)
704 key->on_disk_key.u.k_offset_v1.k_offset --;
705 else
706 key->on_disk_key.u.k_offset_v2.k_offset --;
707}
708
709
710#define is_direntry_cpu_key(key) (cpu_key_k_type (key) == TYPE_DIRENTRY)
711#define is_direct_cpu_key(key) (cpu_key_k_type (key) == TYPE_DIRECT)
712#define is_indirect_cpu_key(key) (cpu_key_k_type (key) == TYPE_INDIRECT)
713#define is_statdata_cpu_key(key) (cpu_key_k_type (key) == TYPE_STAT_DATA)
714
715
716/* are these used ? */
717#define is_direntry_cpu_ih(ih) (is_direntry_cpu_key (&((ih)->ih_key)))
718#define is_direct_cpu_ih(ih) (is_direct_cpu_key (&((ih)->ih_key)))
719#define is_indirect_cpu_ih(ih) (is_indirect_cpu_key (&((ih)->ih_key)))
720#define is_statdata_cpu_ih(ih) (is_statdata_cpu_key (&((ih)->ih_key)))
721
722
723
724
725
726#define I_K_KEY_IN_ITEM(p_s_ih, p_s_key, n_blocksize) \
727 ( ! COMP_SHORT_KEYS(p_s_ih, p_s_key) && \
728 I_OFF_BYTE_IN_ITEM(p_s_ih, k_offset (p_s_key), n_blocksize) )
729
730/* maximal length of item */
731#define MAX_ITEM_LEN(block_size) (block_size - BLKH_SIZE - IH_SIZE)
732#define MIN_ITEM_LEN 1
733
734
735/* object identifier for root dir */
736#define REISERFS_ROOT_OBJECTID 2
737#define REISERFS_ROOT_PARENT_OBJECTID 1
738extern struct reiserfs_key root_key;
739
740
741
742
743/*
744 * Picture represents a leaf of the S+tree
745 * ______________________________________________________
746 * | | Array of | | |
747 * |Block | Object-Item | F r e e | Objects- |
748 * | head | Headers | S p a c e | Items |
749 * |______|_______________|___________________|___________|
750 */
751
752/* Header of a disk block. More precisely, header of a formatted leaf
753 or internal node, and not the header of an unformatted node. */
754struct block_head {
755 __u16 blk_level; /* Level of a block in the tree. */
756 __u16 blk_nr_item; /* Number of keys/items in a block. */
757 __u16 blk_free_space; /* Block free space in bytes. */
758 __u16 blk_reserved;
759 /* dump this in v4/planA */
760 struct reiserfs_key blk_right_delim_key; /* kept only for compatibility */
761};
762
763#define BLKH_SIZE (sizeof(struct block_head))
764#define blkh_level(p_blkh) (le16_to_cpu((p_blkh)->blk_level))
765#define blkh_nr_item(p_blkh) (le16_to_cpu((p_blkh)->blk_nr_item))
766#define blkh_free_space(p_blkh) (le16_to_cpu((p_blkh)->blk_free_space))
767#define blkh_reserved(p_blkh) (le16_to_cpu((p_blkh)->blk_reserved))
768#define set_blkh_level(p_blkh,val) ((p_blkh)->blk_level = cpu_to_le16(val))
769#define set_blkh_nr_item(p_blkh,val) ((p_blkh)->blk_nr_item = cpu_to_le16(val))
770#define set_blkh_free_space(p_blkh,val) ((p_blkh)->blk_free_space = cpu_to_le16(val))
771#define set_blkh_reserved(p_blkh,val) ((p_blkh)->blk_reserved = cpu_to_le16(val))
772#define blkh_right_delim_key(p_blkh) ((p_blkh)->blk_right_delim_key)
773#define set_blkh_right_delim_key(p_blkh,val) ((p_blkh)->blk_right_delim_key = val)
774
775/*
776 * values for blk_level field of the struct block_head
777 */
778
779#define FREE_LEVEL 0 /* when node gets removed from the tree its
780 blk_level is set to FREE_LEVEL. It is then
781 used to see whether the node is still in the
782 tree */
783
784#define DISK_LEAF_NODE_LEVEL 1 /* Leaf node level.*/
785
786/* Given the buffer head of a formatted node, resolve to the block head of that node. */
787#define B_BLK_HEAD(p_s_bh) ((struct block_head *)((p_s_bh)->b_data))
788/* Number of items that are in buffer. */
789#define B_NR_ITEMS(p_s_bh) (blkh_nr_item(B_BLK_HEAD(p_s_bh)))
790#define B_LEVEL(p_s_bh) (blkh_level(B_BLK_HEAD(p_s_bh)))
791#define B_FREE_SPACE(p_s_bh) (blkh_free_space(B_BLK_HEAD(p_s_bh)))
792
793#define PUT_B_NR_ITEMS(p_s_bh,val) do { set_blkh_nr_item(B_BLK_HEAD(p_s_bh),val); } while (0)
794#define PUT_B_LEVEL(p_s_bh,val) do { set_blkh_level(B_BLK_HEAD(p_s_bh),val); } while (0)
795#define PUT_B_FREE_SPACE(p_s_bh,val) do { set_blkh_free_space(B_BLK_HEAD(p_s_bh),val); } while (0)
796
797
798/* Get right delimiting key. -- little endian */
799#define B_PRIGHT_DELIM_KEY(p_s_bh) (&(blk_right_delim_key(B_BLK_HEAD(p_s_bh))
800
801/* Does the buffer contain a disk leaf. */
802#define B_IS_ITEMS_LEVEL(p_s_bh) (B_LEVEL(p_s_bh) == DISK_LEAF_NODE_LEVEL)
803
804/* Does the buffer contain a disk internal node */
805#define B_IS_KEYS_LEVEL(p_s_bh) (B_LEVEL(p_s_bh) > DISK_LEAF_NODE_LEVEL \
806 && B_LEVEL(p_s_bh) <= MAX_HEIGHT)
807
808
809
810
811/***************************************************************************/
812/* STAT DATA */
813/***************************************************************************/
814
815
816//
817// old stat data is 32 bytes long. We are going to distinguish new one by
818// different size
819//
820struct stat_data_v1
821{
822 __u16 sd_mode; /* file type, permissions */
823 __u16 sd_nlink; /* number of hard links */
824 __u16 sd_uid; /* owner */
825 __u16 sd_gid; /* group */
826 __u32 sd_size; /* file size */
827 __u32 sd_atime; /* time of last access */
828 __u32 sd_mtime; /* time file was last modified */
829 __u32 sd_ctime; /* time inode (stat data) was last changed (except changes to sd_atime and sd_mtime) */
830 union {
831 __u32 sd_rdev;
832 __u32 sd_blocks; /* number of blocks file uses */
833 } __attribute__ ((__packed__)) u;
834 __u32 sd_first_direct_byte; /* first byte of file which is stored
835 in a direct item: except that if it
836 equals 1 it is a symlink and if it
837 equals ~(__u32)0 there is no
838 direct item. The existence of this
839 field really grates on me. Let's
840 replace it with a macro based on
841 sd_size and our tail suppression
842 policy. Someday. -Hans */
843} __attribute__ ((__packed__));
844
845#define SD_V1_SIZE (sizeof(struct stat_data_v1))
846#define stat_data_v1(ih) (ih_version (ih) == KEY_FORMAT_3_5)
847#define sd_v1_mode(sdp) (le16_to_cpu((sdp)->sd_mode))
848#define set_sd_v1_mode(sdp,v) ((sdp)->sd_mode = cpu_to_le16(v))
849#define sd_v1_nlink(sdp) (le16_to_cpu((sdp)->sd_nlink))
850#define set_sd_v1_nlink(sdp,v) ((sdp)->sd_nlink = cpu_to_le16(v))
851#define sd_v1_uid(sdp) (le16_to_cpu((sdp)->sd_uid))
852#define set_sd_v1_uid(sdp,v) ((sdp)->sd_uid = cpu_to_le16(v))
853#define sd_v1_gid(sdp) (le16_to_cpu((sdp)->sd_gid))
854#define set_sd_v1_gid(sdp,v) ((sdp)->sd_gid = cpu_to_le16(v))
855#define sd_v1_size(sdp) (le32_to_cpu((sdp)->sd_size))
856#define set_sd_v1_size(sdp,v) ((sdp)->sd_size = cpu_to_le32(v))
857#define sd_v1_atime(sdp) (le32_to_cpu((sdp)->sd_atime))
858#define set_sd_v1_atime(sdp,v) ((sdp)->sd_atime = cpu_to_le32(v))
859#define sd_v1_mtime(sdp) (le32_to_cpu((sdp)->sd_mtime))
860#define set_sd_v1_mtime(sdp,v) ((sdp)->sd_mtime = cpu_to_le32(v))
861#define sd_v1_ctime(sdp) (le32_to_cpu((sdp)->sd_ctime))
862#define set_sd_v1_ctime(sdp,v) ((sdp)->sd_ctime = cpu_to_le32(v))
863#define sd_v1_rdev(sdp) (le32_to_cpu((sdp)->u.sd_rdev))
864#define set_sd_v1_rdev(sdp,v) ((sdp)->u.sd_rdev = cpu_to_le32(v))
865#define sd_v1_blocks(sdp) (le32_to_cpu((sdp)->u.sd_blocks))
866#define set_sd_v1_blocks(sdp,v) ((sdp)->u.sd_blocks = cpu_to_le32(v))
867#define sd_v1_first_direct_byte(sdp) \
868 (le32_to_cpu((sdp)->sd_first_direct_byte))
869#define set_sd_v1_first_direct_byte(sdp,v) \
870 ((sdp)->sd_first_direct_byte = cpu_to_le32(v))
871
872#include <linux/ext2_fs.h>
873
874/* inode flags stored in sd_attrs (nee sd_reserved) */
875
876/* we want common flags to have the same values as in ext2,
877 so chattr(1) will work without problems */
878#define REISERFS_IMMUTABLE_FL EXT2_IMMUTABLE_FL
879#define REISERFS_APPEND_FL EXT2_APPEND_FL
880#define REISERFS_SYNC_FL EXT2_SYNC_FL
881#define REISERFS_NOATIME_FL EXT2_NOATIME_FL
882#define REISERFS_NODUMP_FL EXT2_NODUMP_FL
883#define REISERFS_SECRM_FL EXT2_SECRM_FL
884#define REISERFS_UNRM_FL EXT2_UNRM_FL
885#define REISERFS_COMPR_FL EXT2_COMPR_FL
886#define REISERFS_NOTAIL_FL EXT2_NOTAIL_FL
887
888/* persistent flags that file inherits from the parent directory */
889#define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
890 REISERFS_SYNC_FL | \
891 REISERFS_NOATIME_FL | \
892 REISERFS_NODUMP_FL | \
893 REISERFS_SECRM_FL | \
894 REISERFS_COMPR_FL | \
895 REISERFS_NOTAIL_FL )
896
897/* Stat Data on disk (reiserfs version of UFS disk inode minus the
898 address blocks) */
899struct stat_data {
900 __u16 sd_mode; /* file type, permissions */
901 __u16 sd_attrs; /* persistent inode flags */
902 __u32 sd_nlink; /* number of hard links */
903 __u64 sd_size; /* file size */
904 __u32 sd_uid; /* owner */
905 __u32 sd_gid; /* group */
906 __u32 sd_atime; /* time of last access */
907 __u32 sd_mtime; /* time file was last modified */
908 __u32 sd_ctime; /* time inode (stat data) was last changed (except changes to sd_atime and sd_mtime) */
909 __u32 sd_blocks;
910 union {
911 __u32 sd_rdev;
912 __u32 sd_generation;
913 //__u32 sd_first_direct_byte;
914 /* first byte of file which is stored in a
915 direct item: except that if it equals 1
916 it is a symlink and if it equals
917 ~(__u32)0 there is no direct item. The
918 existence of this field really grates
919 on me. Let's replace it with a macro
920 based on sd_size and our tail
921 suppression policy? */
922 } __attribute__ ((__packed__)) u;
923} __attribute__ ((__packed__));
924//
925// this is 44 bytes long
926//
927#define SD_SIZE (sizeof(struct stat_data))
928#define SD_V2_SIZE SD_SIZE
929#define stat_data_v2(ih) (ih_version (ih) == KEY_FORMAT_3_6)
930#define sd_v2_mode(sdp) (le16_to_cpu((sdp)->sd_mode))
931#define set_sd_v2_mode(sdp,v) ((sdp)->sd_mode = cpu_to_le16(v))
932/* sd_reserved */
933/* set_sd_reserved */
934#define sd_v2_nlink(sdp) (le32_to_cpu((sdp)->sd_nlink))
935#define set_sd_v2_nlink(sdp,v) ((sdp)->sd_nlink = cpu_to_le32(v))
936#define sd_v2_size(sdp) (le64_to_cpu((sdp)->sd_size))
937#define set_sd_v2_size(sdp,v) ((sdp)->sd_size = cpu_to_le64(v))
938#define sd_v2_uid(sdp) (le32_to_cpu((sdp)->sd_uid))
939#define set_sd_v2_uid(sdp,v) ((sdp)->sd_uid = cpu_to_le32(v))
940#define sd_v2_gid(sdp) (le32_to_cpu((sdp)->sd_gid))
941#define set_sd_v2_gid(sdp,v) ((sdp)->sd_gid = cpu_to_le32(v))
942#define sd_v2_atime(sdp) (le32_to_cpu((sdp)->sd_atime))
943#define set_sd_v2_atime(sdp,v) ((sdp)->sd_atime = cpu_to_le32(v))
944#define sd_v2_mtime(sdp) (le32_to_cpu((sdp)->sd_mtime))
945#define set_sd_v2_mtime(sdp,v) ((sdp)->sd_mtime = cpu_to_le32(v))
946#define sd_v2_ctime(sdp) (le32_to_cpu((sdp)->sd_ctime))
947#define set_sd_v2_ctime(sdp,v) ((sdp)->sd_ctime = cpu_to_le32(v))
948#define sd_v2_blocks(sdp) (le32_to_cpu((sdp)->sd_blocks))
949#define set_sd_v2_blocks(sdp,v) ((sdp)->sd_blocks = cpu_to_le32(v))
950#define sd_v2_rdev(sdp) (le32_to_cpu((sdp)->u.sd_rdev))
951#define set_sd_v2_rdev(sdp,v) ((sdp)->u.sd_rdev = cpu_to_le32(v))
952#define sd_v2_generation(sdp) (le32_to_cpu((sdp)->u.sd_generation))
953#define set_sd_v2_generation(sdp,v) ((sdp)->u.sd_generation = cpu_to_le32(v))
954#define sd_v2_attrs(sdp) (le16_to_cpu((sdp)->sd_attrs))
955#define set_sd_v2_attrs(sdp,v) ((sdp)->sd_attrs = cpu_to_le16(v))
956
957
958/***************************************************************************/
959/* DIRECTORY STRUCTURE */
960/***************************************************************************/
961/*
962 Picture represents the structure of directory items
963 ________________________________________________
964 | Array of | | | | | |
965 | directory |N-1| N-2 | .... | 1st |0th|
966 | entry headers | | | | | |
967 |_______________|___|_____|________|_______|___|
968 <---- directory entries ------>
969
970 First directory item has k_offset component 1. We store "." and ".."
971 in one item, always, we never split "." and ".." into differing
972 items. This makes, among other things, the code for removing
973 directories simpler. */
974#define SD_OFFSET 0
975#define SD_UNIQUENESS 0
976#define DOT_OFFSET 1
977#define DOT_DOT_OFFSET 2
978#define DIRENTRY_UNIQUENESS 500
979
980/* */
981#define FIRST_ITEM_OFFSET 1
982
983/*
984 Q: How to get key of object pointed to by entry from entry?
985
986 A: Each directory entry has its header. This header has deh_dir_id and deh_objectid fields, those are key
987 of object, entry points to */
988
989/* NOT IMPLEMENTED:
990 Directory will someday contain stat data of object */
991
992
993
994struct reiserfs_de_head
995{
996 __u32 deh_offset; /* third component of the directory entry key */
997 __u32 deh_dir_id; /* objectid of the parent directory of the object, that is referenced
998 by directory entry */
999 __u32 deh_objectid; /* objectid of the object, that is referenced by directory entry */
1000 __u16 deh_location; /* offset of name in the whole item */
1001 __u16 deh_state; /* whether 1) entry contains stat data (for future), and 2) whether
1002 entry is hidden (unlinked) */
1003} __attribute__ ((__packed__));
1004#define DEH_SIZE sizeof(struct reiserfs_de_head)
1005#define deh_offset(p_deh) (le32_to_cpu((p_deh)->deh_offset))
1006#define deh_dir_id(p_deh) (le32_to_cpu((p_deh)->deh_dir_id))
1007#define deh_objectid(p_deh) (le32_to_cpu((p_deh)->deh_objectid))
1008#define deh_location(p_deh) (le16_to_cpu((p_deh)->deh_location))
1009#define deh_state(p_deh) (le16_to_cpu((p_deh)->deh_state))
1010
1011#define put_deh_offset(p_deh,v) ((p_deh)->deh_offset = cpu_to_le32((v)))
1012#define put_deh_dir_id(p_deh,v) ((p_deh)->deh_dir_id = cpu_to_le32((v)))
1013#define put_deh_objectid(p_deh,v) ((p_deh)->deh_objectid = cpu_to_le32((v)))
1014#define put_deh_location(p_deh,v) ((p_deh)->deh_location = cpu_to_le16((v)))
1015#define put_deh_state(p_deh,v) ((p_deh)->deh_state = cpu_to_le16((v)))
1016
1017/* empty directory contains two entries "." and ".." and their headers */
1018#define EMPTY_DIR_SIZE \
1019(DEH_SIZE * 2 + ROUND_UP (strlen (".")) + ROUND_UP (strlen ("..")))
1020
1021/* old format directories have this size when empty */
1022#define EMPTY_DIR_SIZE_V1 (DEH_SIZE * 2 + 3)
1023
1024#define DEH_Statdata 0 /* not used now */
1025#define DEH_Visible 2
1026
1027/* 64 bit systems (and the S/390) need to be aligned explicitly -jdm */
1028#if BITS_PER_LONG == 64 || defined(__s390__) || defined(__hppa__)
1029# define ADDR_UNALIGNED_BITS (3)
1030#endif
1031
1032/* These are only used to manipulate deh_state.
1033 * Because of this, we'll use the ext2_ bit routines,
1034 * since they are little endian */
1035#ifdef ADDR_UNALIGNED_BITS
1036
1037# define aligned_address(addr) ((void *)((long)(addr) & ~((1UL << ADDR_UNALIGNED_BITS) - 1)))
1038# define unaligned_offset(addr) (((int)((long)(addr) & ((1 << ADDR_UNALIGNED_BITS) - 1))) << 3)
1039
1040# define set_bit_unaligned(nr, addr) ext2_set_bit((nr) + unaligned_offset(addr), aligned_address(addr))
1041# define clear_bit_unaligned(nr, addr) ext2_clear_bit((nr) + unaligned_offset(addr), aligned_address(addr))
1042# define test_bit_unaligned(nr, addr) ext2_test_bit((nr) + unaligned_offset(addr), aligned_address(addr))
1043
1044#else
1045
1046# define set_bit_unaligned(nr, addr) ext2_set_bit(nr, addr)
1047# define clear_bit_unaligned(nr, addr) ext2_clear_bit(nr, addr)
1048# define test_bit_unaligned(nr, addr) ext2_test_bit(nr, addr)
1049
1050#endif
1051
1052#define mark_de_with_sd(deh) set_bit_unaligned (DEH_Statdata, &((deh)->deh_state))
1053#define mark_de_without_sd(deh) clear_bit_unaligned (DEH_Statdata, &((deh)->deh_state))
1054#define mark_de_visible(deh) set_bit_unaligned (DEH_Visible, &((deh)->deh_state))
1055#define mark_de_hidden(deh) clear_bit_unaligned (DEH_Visible, &((deh)->deh_state))
1056
1057#define de_with_sd(deh) test_bit_unaligned (DEH_Statdata, &((deh)->deh_state))
1058#define de_visible(deh) test_bit_unaligned (DEH_Visible, &((deh)->deh_state))
1059#define de_hidden(deh) !test_bit_unaligned (DEH_Visible, &((deh)->deh_state))
1060
1061extern void make_empty_dir_item_v1 (char * body, __u32 dirid, __u32 objid,
1062 __u32 par_dirid, __u32 par_objid);
1063extern void make_empty_dir_item (char * body, __u32 dirid, __u32 objid,
1064 __u32 par_dirid, __u32 par_objid);
1065
1066/* array of the entry headers */
1067 /* get item body */
1068#define B_I_PITEM(bh,ih) ( (bh)->b_data + ih_location(ih) )
1069#define B_I_DEH(bh,ih) ((struct reiserfs_de_head *)(B_I_PITEM(bh,ih)))
1070
1071/* length of the directory entry in directory item. This define
1072 calculates length of i-th directory entry using directory entry
1073 locations from dir entry head. When it calculates length of 0-th
1074 directory entry, it uses length of whole item in place of entry
1075 location of the non-existent following entry in the calculation.
1076 See picture above.*/
1077/*
1078#define I_DEH_N_ENTRY_LENGTH(ih,deh,i) \
1079((i) ? (deh_location((deh)-1) - deh_location((deh))) : (ih_item_len((ih)) - deh_location((deh))))
1080*/
1081static inline int entry_length (const struct buffer_head * bh,
1082 const struct item_head * ih, int pos_in_item)
1083{
1084 struct reiserfs_de_head * deh;
1085
1086 deh = B_I_DEH (bh, ih) + pos_in_item;
1087 if (pos_in_item)
1088 return deh_location(deh-1) - deh_location(deh);
1089
1090 return ih_item_len(ih) - deh_location(deh);
1091}
1092
1093
1094
1095/* number of entries in the directory item, depends on ENTRY_COUNT being at the start of directory dynamic data. */
1096#define I_ENTRY_COUNT(ih) (ih_entry_count((ih)))
1097
1098
1099/* name by bh, ih and entry_num */
1100#define B_I_E_NAME(bh,ih,entry_num) ((char *)(bh->b_data + ih_location(ih) + deh_location(B_I_DEH(bh,ih)+(entry_num))))
1101
1102// two entries per block (at least)
1103#define REISERFS_MAX_NAME(block_size) 255
1104
1105
1106/* this structure is used for operations on directory entries. It is
1107 not a disk structure. */
1108/* When reiserfs_find_entry or search_by_entry_key find directory
1109 entry, they return filled reiserfs_dir_entry structure */
1110struct reiserfs_dir_entry
1111{
1112 struct buffer_head * de_bh;
1113 int de_item_num;
1114 struct item_head * de_ih;
1115 int de_entry_num;
1116 struct reiserfs_de_head * de_deh;
1117 int de_entrylen;
1118 int de_namelen;
1119 char * de_name;
1120 char * de_gen_number_bit_string;
1121
1122 __u32 de_dir_id;
1123 __u32 de_objectid;
1124
1125 struct cpu_key de_entry_key;
1126};
1127
1128/* these defines are useful when a particular member of a reiserfs_dir_entry is needed */
1129
1130/* pointer to file name, stored in entry */
1131#define B_I_DEH_ENTRY_FILE_NAME(bh,ih,deh) (B_I_PITEM (bh, ih) + deh_location(deh))
1132
1133/* length of name */
1134#define I_DEH_N_ENTRY_FILE_NAME_LENGTH(ih,deh,entry_num) \
1135(I_DEH_N_ENTRY_LENGTH (ih, deh, entry_num) - (de_with_sd (deh) ? SD_SIZE : 0))
1136
1137
1138
1139/* hash value occupies bits from 7 up to 30 */
1140#define GET_HASH_VALUE(offset) ((offset) & 0x7fffff80LL)
1141/* generation number occupies 7 bits starting from 0 up to 6 */
1142#define GET_GENERATION_NUMBER(offset) ((offset) & 0x7fLL)
1143#define MAX_GENERATION_NUMBER 127
1144
1145#define SET_GENERATION_NUMBER(offset,gen_number) (GET_HASH_VALUE(offset)|(gen_number))
1146
1147
1148/*
1149 * Picture represents an internal node of the reiserfs tree
1150 * ______________________________________________________
1151 * | | Array of | Array of | Free |
1152 * |block | keys | pointers | space |
1153 * | head | N | N+1 | |
1154 * |______|_______________|___________________|___________|
1155 */
1156
1157/***************************************************************************/
1158/* DISK CHILD */
1159/***************************************************************************/
1160/* Disk child pointer: The pointer from an internal node of the tree
1161 to a node that is on disk. */
1162struct disk_child {
1163 __u32 dc_block_number; /* Disk child's block number. */
1164 __u16 dc_size; /* Disk child's used space. */
1165 __u16 dc_reserved;
1166};
1167
1168#define DC_SIZE (sizeof(struct disk_child))
1169#define dc_block_number(dc_p) (le32_to_cpu((dc_p)->dc_block_number))
1170#define dc_size(dc_p) (le16_to_cpu((dc_p)->dc_size))
1171#define put_dc_block_number(dc_p, val) do { (dc_p)->dc_block_number = cpu_to_le32(val); } while(0)
1172#define put_dc_size(dc_p, val) do { (dc_p)->dc_size = cpu_to_le16(val); } while(0)
1173
1174/* Get disk child by buffer header and position in the tree node. */
1175#define B_N_CHILD(p_s_bh,n_pos) ((struct disk_child *)\
1176((p_s_bh)->b_data+BLKH_SIZE+B_NR_ITEMS(p_s_bh)*KEY_SIZE+DC_SIZE*(n_pos)))
1177
1178/* Get disk child number by buffer header and position in the tree node. */
1179#define B_N_CHILD_NUM(p_s_bh,n_pos) (dc_block_number(B_N_CHILD(p_s_bh,n_pos)))
1180#define PUT_B_N_CHILD_NUM(p_s_bh,n_pos, val) (put_dc_block_number(B_N_CHILD(p_s_bh,n_pos), val ))
1181
1182 /* maximal value of field child_size in structure disk_child */
1183 /* child size is the combined size of all items and their headers */
1184#define MAX_CHILD_SIZE(bh) ((int)( (bh)->b_size - BLKH_SIZE ))
1185
1186/* amount of used space in buffer (not including block head) */
1187#define B_CHILD_SIZE(cur) (MAX_CHILD_SIZE(cur)-(B_FREE_SPACE(cur)))
1188
1189/* max and min number of keys in internal node */
1190#define MAX_NR_KEY(bh) ( (MAX_CHILD_SIZE(bh)-DC_SIZE)/(KEY_SIZE+DC_SIZE) )
1191#define MIN_NR_KEY(bh) (MAX_NR_KEY(bh)/2)
1192
1193/***************************************************************************/
1194/* PATH STRUCTURES AND DEFINES */
1195/***************************************************************************/
1196
1197
1198/* Search_by_key fills up the path from the root to the leaf as it descends the tree looking for the
1199 key. It uses reiserfs_bread to try to find buffers in the cache given their block number. If it
1200 does not find them in the cache it reads them from disk. For each node search_by_key finds using
1201 reiserfs_bread it then uses bin_search to look through that node. bin_search will find the
1202 position of the block_number of the next node if it is looking through an internal node. If it
1203 is looking through a leaf node bin_search will find the position of the item which has key either
1204 equal to given key, or which is the maximal key less than the given key. */
1205
1206struct path_element {
1207 struct buffer_head * pe_buffer; /* Pointer to the buffer at the path in the tree. */
1208 int pe_position; /* Position in the tree node which is placed in the */
1209 /* buffer above. */
1210};
1211
1212#define MAX_HEIGHT 5 /* maximal height of a tree. don't change this without changing JOURNAL_PER_BALANCE_CNT */
1213#define EXTENDED_MAX_HEIGHT 7 /* Must be equals MAX_HEIGHT + FIRST_PATH_ELEMENT_OFFSET */
1214#define FIRST_PATH_ELEMENT_OFFSET 2 /* Must be equal to at least 2. */
1215
1216#define ILLEGAL_PATH_ELEMENT_OFFSET 1 /* Must be equal to FIRST_PATH_ELEMENT_OFFSET - 1 */
1217#define MAX_FEB_SIZE 6 /* this MUST be MAX_HEIGHT + 1. See about FEB below */
1218
1219
1220
1221/* We need to keep track of who the ancestors of nodes are. When we
1222 perform a search we record which nodes were visited while
1223 descending the tree looking for the node we searched for. This list
1224 of nodes is called the path. This information is used while
1225 performing balancing. Note that this path information may become
1226 invalid, and this means we must check it when using it to see if it
1227 is still valid. You'll need to read search_by_key and the comments
1228 in it, especially about decrement_counters_in_path(), to understand
1229 this structure.
1230
1231Paths make the code so much harder to work with and debug.... An
1232enormous number of bugs are due to them, and trying to write or modify
1233code that uses them just makes my head hurt. They are based on an
1234excessive effort to avoid disturbing the precious VFS code.:-( The
1235gods only know how we are going to SMP the code that uses them.
1236znodes are the way! */
1237
1238#define PATH_READA 0x1 /* do read ahead */
1239#define PATH_READA_BACK 0x2 /* read backwards */
1240
1241struct path {
1242 int path_length; /* Length of the array above. */
1243 int reada;
1244 struct path_element path_elements[EXTENDED_MAX_HEIGHT]; /* Array of the path elements. */
1245 int pos_in_item;
1246};
1247
1248#define pos_in_item(path) ((path)->pos_in_item)
1249
1250#define INITIALIZE_PATH(var) \
1251struct path var = {.path_length = ILLEGAL_PATH_ELEMENT_OFFSET, .reada = 0,}
1252
1253/* Get path element by path and path position. */
1254#define PATH_OFFSET_PELEMENT(p_s_path,n_offset) ((p_s_path)->path_elements +(n_offset))
1255
1256/* Get buffer header at the path by path and path position. */
1257#define PATH_OFFSET_PBUFFER(p_s_path,n_offset) (PATH_OFFSET_PELEMENT(p_s_path,n_offset)->pe_buffer)
1258
1259/* Get position in the element at the path by path and path position. */
1260#define PATH_OFFSET_POSITION(p_s_path,n_offset) (PATH_OFFSET_PELEMENT(p_s_path,n_offset)->pe_position)
1261
1262
1263#define PATH_PLAST_BUFFER(p_s_path) (PATH_OFFSET_PBUFFER((p_s_path), (p_s_path)->path_length))
1264 /* you know, to the person who didn't
1265 write this the macro name does not
1266 at first suggest what it does.
1267 Maybe POSITION_FROM_PATH_END? Or
1268 maybe we should just focus on
1269 dumping paths... -Hans */
1270#define PATH_LAST_POSITION(p_s_path) (PATH_OFFSET_POSITION((p_s_path), (p_s_path)->path_length))
1271
1272
1273#define PATH_PITEM_HEAD(p_s_path) B_N_PITEM_HEAD(PATH_PLAST_BUFFER(p_s_path),PATH_LAST_POSITION(p_s_path))
1274
1275/* in do_balance leaf has h == 0 in contrast with path structure,
1276 where root has level == 0. That is why we need these defines */
1277#define PATH_H_PBUFFER(p_s_path, h) PATH_OFFSET_PBUFFER (p_s_path, p_s_path->path_length - (h)) /* tb->S[h] */
1278#define PATH_H_PPARENT(path, h) PATH_H_PBUFFER (path, (h) + 1) /* tb->F[h] or tb->S[0]->b_parent */
1279#define PATH_H_POSITION(path, h) PATH_OFFSET_POSITION (path, path->path_length - (h))
1280#define PATH_H_B_ITEM_ORDER(path, h) PATH_H_POSITION(path, h + 1) /* tb->S[h]->b_item_order */
1281
1282#define PATH_H_PATH_OFFSET(p_s_path, n_h) ((p_s_path)->path_length - (n_h))
1283
1284#define get_last_bh(path) PATH_PLAST_BUFFER(path)
1285#define get_ih(path) PATH_PITEM_HEAD(path)
1286#define get_item_pos(path) PATH_LAST_POSITION(path)
1287#define get_item(path) ((void *)B_N_PITEM(PATH_PLAST_BUFFER(path), PATH_LAST_POSITION (path)))
1288#define item_moved(ih,path) comp_items(ih, path)
1289#define path_changed(ih,path) comp_items (ih, path)
1290
1291
1292/***************************************************************************/
1293/* MISC */
1294/***************************************************************************/
1295
1296/* Size of pointer to the unformatted node. */
1297#define UNFM_P_SIZE (sizeof(unp_t))
1298#define UNFM_P_SHIFT 2
1299
1300// in in-core inode key is stored on le form
1301#define INODE_PKEY(inode) ((struct reiserfs_key *)(REISERFS_I(inode)->i_key))
1302
1303#define MAX_UL_INT 0xffffffff
1304#define MAX_INT 0x7ffffff
1305#define MAX_US_INT 0xffff
1306
1307// reiserfs version 2 has max offset 60 bits. Version 1 - 32 bit offset
1308#define U32_MAX (~(__u32)0)
1309
1310static inline loff_t max_reiserfs_offset (struct inode * inode)
1311{
1312 if (get_inode_item_key_version(inode) == KEY_FORMAT_3_5)
1313 return (loff_t)U32_MAX;
1314
1315 return (loff_t)((~(__u64)0) >> 4);
1316}
1317
1318
1319/*#define MAX_KEY_UNIQUENESS MAX_UL_INT*/
1320#define MAX_KEY_OBJECTID MAX_UL_INT
1321
1322
1323#define MAX_B_NUM MAX_UL_INT
1324#define MAX_FC_NUM MAX_US_INT
1325
1326
1327/* the purpose is to detect overflow of an unsigned short */
1328#define REISERFS_LINK_MAX (MAX_US_INT - 1000)
1329
1330
1331/* The following defines are used in reiserfs_insert_item and reiserfs_append_item */
1332#define REISERFS_KERNEL_MEM 0 /* reiserfs kernel memory mode */
1333#define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
1334
1335#define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
1336#define get_generation(s) atomic_read (&fs_generation(s))
1337#define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
1338#define __fs_changed(gen,s) (gen != get_generation (s))
1339#define fs_changed(gen,s) ({cond_resched(); __fs_changed(gen, s);})
1340
1341
1342/***************************************************************************/
1343/* FIXATE NODES */
1344/***************************************************************************/
1345
1346#define VI_TYPE_LEFT_MERGEABLE 1
1347#define VI_TYPE_RIGHT_MERGEABLE 2
1348
1349/* To make any changes in the tree we always first find node, that
1350 contains item to be changed/deleted or place to insert a new
1351 item. We call this node S. To do balancing we need to decide what
1352 we will shift to left/right neighbor, or to a new node, where new
1353 item will be etc. To make this analysis simpler we build virtual
1354 node. Virtual node is an array of items, that will replace items of
1355 node S. (For instance if we are going to delete an item, virtual
1356 node does not contain it). Virtual node keeps information about
1357 item sizes and types, mergeability of first and last items, sizes
1358 of all entries in directory item. We use this array of items when
1359 calculating what we can shift to neighbors and how many nodes we
1360 have to have if we do not any shiftings, if we shift to left/right
1361 neighbor or to both. */
1362struct virtual_item
1363{
1364 int vi_index; // index in the array of item operations
1365 unsigned short vi_type; // left/right mergeability
1366 unsigned short vi_item_len; /* length of item that it will have after balancing */
1367 struct item_head * vi_ih;
1368 const char * vi_item; // body of item (old or new)
1369 const void * vi_new_data; // 0 always but paste mode
1370 void * vi_uarea; // item specific area
1371};
1372
1373
1374struct virtual_node
1375{
1376 char * vn_free_ptr; /* this is a pointer to the free space in the buffer */
1377 unsigned short vn_nr_item; /* number of items in virtual node */
1378 short vn_size; /* size of node , that node would have if it has unlimited size and no balancing is performed */
1379 short vn_mode; /* mode of balancing (paste, insert, delete, cut) */
1380 short vn_affected_item_num;
1381 short vn_pos_in_item;
1382 struct item_head * vn_ins_ih; /* item header of inserted item, 0 for other modes */
1383 const void * vn_data;
1384 struct virtual_item * vn_vi; /* array of items (including a new one, excluding item to be deleted) */
1385};
1386
1387/* used by directory items when creating virtual nodes */
1388struct direntry_uarea {
1389 int flags;
1390 __u16 entry_count;
1391 __u16 entry_sizes[1];
1392} __attribute__ ((__packed__)) ;
1393
1394
1395/***************************************************************************/
1396/* TREE BALANCE */
1397/***************************************************************************/
1398
1399/* This temporary structure is used in tree balance algorithms, and
1400 constructed as we go to the extent that its various parts are
1401 needed. It contains arrays of nodes that can potentially be
1402 involved in the balancing of node S, and parameters that define how
1403 each of the nodes must be balanced. Note that in these algorithms
1404 for balancing the worst case is to need to balance the current node
1405 S and the left and right neighbors and all of their parents plus
1406 create a new node. We implement S1 balancing for the leaf nodes
1407 and S0 balancing for the internal nodes (S1 and S0 are defined in
1408 our papers.)*/
1409
1410#define MAX_FREE_BLOCK 7 /* size of the array of buffers to free at end of do_balance */
1411
1412/* maximum number of FEB blocknrs on a single level */
1413#define MAX_AMOUNT_NEEDED 2
1414
1415/* someday somebody will prefix every field in this struct with tb_ */
1416struct tree_balance
1417{
1418 int tb_mode;
1419 int need_balance_dirty;
1420 struct super_block * tb_sb;
1421 struct reiserfs_transaction_handle *transaction_handle ;
1422 struct path * tb_path;
1423 struct buffer_head * L[MAX_HEIGHT]; /* array of left neighbors of nodes in the path */
1424 struct buffer_head * R[MAX_HEIGHT]; /* array of right neighbors of nodes in the path*/
1425 struct buffer_head * FL[MAX_HEIGHT]; /* array of fathers of the left neighbors */
1426 struct buffer_head * FR[MAX_HEIGHT]; /* array of fathers of the right neighbors */
1427 struct buffer_head * CFL[MAX_HEIGHT]; /* array of common parents of center node and its left neighbor */
1428 struct buffer_head * CFR[MAX_HEIGHT]; /* array of common parents of center node and its right neighbor */
1429
1430 struct buffer_head * FEB[MAX_FEB_SIZE]; /* array of empty buffers. Number of buffers in array equals
1431 cur_blknum. */
1432 struct buffer_head * used[MAX_FEB_SIZE];
1433 struct buffer_head * thrown[MAX_FEB_SIZE];
1434 int lnum[MAX_HEIGHT]; /* array of number of items which must be
1435 shifted to the left in order to balance the
1436 current node; for leaves includes item that
1437 will be partially shifted; for internal
1438 nodes, it is the number of child pointers
1439 rather than items. It includes the new item
1440 being created. The code sometimes subtracts
1441 one to get the number of wholly shifted
1442 items for other purposes. */
1443 int rnum[MAX_HEIGHT]; /* substitute right for left in comment above */
1444 int lkey[MAX_HEIGHT]; /* array indexed by height h mapping the key delimiting L[h] and
1445 S[h] to its item number within the node CFL[h] */
1446 int rkey[MAX_HEIGHT]; /* substitute r for l in comment above */
1447 int insert_size[MAX_HEIGHT]; /* the number of bytes by we are trying to add or remove from
1448 S[h]. A negative value means removing. */
1449 int blknum[MAX_HEIGHT]; /* number of nodes that will replace node S[h] after
1450 balancing on the level h of the tree. If 0 then S is
1451 being deleted, if 1 then S is remaining and no new nodes
1452 are being created, if 2 or 3 then 1 or 2 new nodes is
1453 being created */
1454
1455 /* fields that are used only for balancing leaves of the tree */
1456 int cur_blknum; /* number of empty blocks having been already allocated */
1457 int s0num; /* number of items that fall into left most node when S[0] splits */
1458 int s1num; /* number of items that fall into first new node when S[0] splits */
1459 int s2num; /* number of items that fall into second new node when S[0] splits */
1460 int lbytes; /* number of bytes which can flow to the left neighbor from the left */
1461 /* most liquid item that cannot be shifted from S[0] entirely */
1462 /* if -1 then nothing will be partially shifted */
1463 int rbytes; /* number of bytes which will flow to the right neighbor from the right */
1464 /* most liquid item that cannot be shifted from S[0] entirely */
1465 /* if -1 then nothing will be partially shifted */
1466 int s1bytes; /* number of bytes which flow to the first new node when S[0] splits */
1467 /* note: if S[0] splits into 3 nodes, then items do not need to be cut */
1468 int s2bytes;
1469 struct buffer_head * buf_to_free[MAX_FREE_BLOCK]; /* buffers which are to be freed after do_balance finishes by unfix_nodes */
1470 char * vn_buf; /* kmalloced memory. Used to create
1471 virtual node and keep map of
1472 dirtied bitmap blocks */
1473 int vn_buf_size; /* size of the vn_buf */
1474 struct virtual_node * tb_vn; /* VN starts after bitmap of bitmap blocks */
1475
1476 int fs_gen; /* saved value of `reiserfs_generation' counter
1477 see FILESYSTEM_CHANGED() macro in reiserfs_fs.h */
1478#ifdef DISPLACE_NEW_PACKING_LOCALITIES
1479 struct reiserfs_key key; /* key pointer, to pass to block allocator or
1480 another low-level subsystem */
1481#endif
1482} ;
1483
1484/* These are modes of balancing */
1485
1486/* When inserting an item. */
1487#define M_INSERT 'i'
1488/* When inserting into (directories only) or appending onto an already
1489 existant item. */
1490#define M_PASTE 'p'
1491/* When deleting an item. */
1492#define M_DELETE 'd'
1493/* When truncating an item or removing an entry from a (directory) item. */
1494#define M_CUT 'c'
1495
1496/* used when balancing on leaf level skipped (in reiserfsck) */
1497#define M_INTERNAL 'n'
1498
1499/* When further balancing is not needed, then do_balance does not need
1500 to be called. */
1501#define M_SKIP_BALANCING 's'
1502#define M_CONVERT 'v'
1503
1504/* modes of leaf_move_items */
1505#define LEAF_FROM_S_TO_L 0
1506#define LEAF_FROM_S_TO_R 1
1507#define LEAF_FROM_R_TO_L 2
1508#define LEAF_FROM_L_TO_R 3
1509#define LEAF_FROM_S_TO_SNEW 4
1510
1511#define FIRST_TO_LAST 0
1512#define LAST_TO_FIRST 1
1513
1514/* used in do_balance for passing parent of node information that has
1515 been gotten from tb struct */
1516struct buffer_info {
1517 struct tree_balance * tb;
1518 struct buffer_head * bi_bh;
1519 struct buffer_head * bi_parent;
1520 int bi_position;
1521};
1522
1523
1524/* there are 4 types of items: stat data, directory item, indirect, direct.
1525+-------------------+------------+--------------+------------+
1526| | k_offset | k_uniqueness | mergeable? |
1527+-------------------+------------+--------------+------------+
1528| stat data | 0 | 0 | no |
1529+-------------------+------------+--------------+------------+
1530| 1st directory item| DOT_OFFSET |DIRENTRY_UNIQUENESS| no |
1531| non 1st directory | hash value | | yes |
1532| item | | | |
1533+-------------------+------------+--------------+------------+
1534| indirect item | offset + 1 |TYPE_INDIRECT | if this is not the first indirect item of the object
1535+-------------------+------------+--------------+------------+
1536| direct item | offset + 1 |TYPE_DIRECT | if not this is not the first direct item of the object
1537+-------------------+------------+--------------+------------+
1538*/
1539
1540struct item_operations {
1541 int (*bytes_number) (struct item_head * ih, int block_size);
1542 void (*decrement_key) (struct cpu_key *);
1543 int (*is_left_mergeable) (struct reiserfs_key * ih, unsigned long bsize);
1544 void (*print_item) (struct item_head *, char * item);
1545 void (*check_item) (struct item_head *, char * item);
1546
1547 int (*create_vi) (struct virtual_node * vn, struct virtual_item * vi,
1548 int is_affected, int insert_size);
1549 int (*check_left) (struct virtual_item * vi, int free,
1550 int start_skip, int end_skip);
1551 int (*check_right) (struct virtual_item * vi, int free);
1552 int (*part_size) (struct virtual_item * vi, int from, int to);
1553 int (*unit_num) (struct virtual_item * vi);
1554 void (*print_vi) (struct virtual_item * vi);
1555};
1556
1557
1558extern struct item_operations * item_ops [TYPE_ANY + 1];
1559
1560#define op_bytes_number(ih,bsize) item_ops[le_ih_k_type (ih)]->bytes_number (ih, bsize)
1561#define op_is_left_mergeable(key,bsize) item_ops[le_key_k_type (le_key_version (key), key)]->is_left_mergeable (key, bsize)
1562#define op_print_item(ih,item) item_ops[le_ih_k_type (ih)]->print_item (ih, item)
1563#define op_check_item(ih,item) item_ops[le_ih_k_type (ih)]->check_item (ih, item)
1564#define op_create_vi(vn,vi,is_affected,insert_size) item_ops[le_ih_k_type ((vi)->vi_ih)]->create_vi (vn,vi,is_affected,insert_size)
1565#define op_check_left(vi,free,start_skip,end_skip) item_ops[(vi)->vi_index]->check_left (vi, free, start_skip, end_skip)
1566#define op_check_right(vi,free) item_ops[(vi)->vi_index]->check_right (vi, free)
1567#define op_part_size(vi,from,to) item_ops[(vi)->vi_index]->part_size (vi, from, to)
1568#define op_unit_num(vi) item_ops[(vi)->vi_index]->unit_num (vi)
1569#define op_print_vi(vi) item_ops[(vi)->vi_index]->print_vi (vi)
1570
1571
1572
1573#define COMP_SHORT_KEYS comp_short_keys
1574
1575/* number of blocks pointed to by the indirect item */
1576#define I_UNFM_NUM(p_s_ih) ( ih_item_len(p_s_ih) / UNFM_P_SIZE )
1577
1578/* the used space within the unformatted node corresponding to pos within the item pointed to by ih */
1579#define I_POS_UNFM_SIZE(ih,pos,size) (((pos) == I_UNFM_NUM(ih) - 1 ) ? (size) - ih_free_space(ih) : (size))
1580
1581/* number of bytes contained by the direct item or the unformatted nodes the indirect item points to */
1582
1583
1584/* get the item header */
1585#define B_N_PITEM_HEAD(bh,item_num) ( (struct item_head * )((bh)->b_data + BLKH_SIZE) + (item_num) )
1586
1587/* get key */
1588#define B_N_PDELIM_KEY(bh,item_num) ( (struct reiserfs_key * )((bh)->b_data + BLKH_SIZE) + (item_num) )
1589
1590/* get the key */
1591#define B_N_PKEY(bh,item_num) ( &(B_N_PITEM_HEAD(bh,item_num)->ih_key) )
1592
1593/* get item body */
1594#define B_N_PITEM(bh,item_num) ( (bh)->b_data + ih_location(B_N_PITEM_HEAD((bh),(item_num))))
1595
1596/* get the stat data by the buffer header and the item order */
1597#define B_N_STAT_DATA(bh,nr) \
1598( (struct stat_data *)((bh)->b_data + ih_location(B_N_PITEM_HEAD((bh),(nr))) ) )
1599
1600 /* following defines use reiserfs buffer header and item header */
1601
1602/* get stat-data */
1603#define B_I_STAT_DATA(bh, ih) ( (struct stat_data * )((bh)->b_data + ih_location(ih)) )
1604
1605// this is 3976 for size==4096
1606#define MAX_DIRECT_ITEM_LEN(size) ((size) - BLKH_SIZE - 2*IH_SIZE - SD_SIZE - UNFM_P_SIZE)
1607
1608/* indirect items consist of entries which contain blocknrs, pos
1609 indicates which entry, and B_I_POS_UNFM_POINTER resolves to the
1610 blocknr contained by the entry pos points to */
1611#define B_I_POS_UNFM_POINTER(bh,ih,pos) le32_to_cpu(*(((unp_t *)B_I_PITEM(bh,ih)) + (pos)))
1612#define PUT_B_I_POS_UNFM_POINTER(bh,ih,pos, val) do {*(((unp_t *)B_I_PITEM(bh,ih)) + (pos)) = cpu_to_le32(val); } while (0)
1613
1614struct reiserfs_iget_args {
1615 __u32 objectid ;
1616 __u32 dirid ;
1617} ;
1618
1619/***************************************************************************/
1620/* FUNCTION DECLARATIONS */
1621/***************************************************************************/
1622
1623/*#ifdef __KERNEL__*/
1624#define get_journal_desc_magic(bh) (bh->b_data + bh->b_size - 12)
1625
1626#define journal_trans_half(blocksize) \
1627 ((blocksize - sizeof (struct reiserfs_journal_desc) + sizeof (__u32) - 12) / sizeof (__u32))
1628
1629/* journal.c see journal.c for all the comments here */
1630
1631/* first block written in a commit. */
1632struct reiserfs_journal_desc {
1633 __u32 j_trans_id ; /* id of commit */
1634 __u32 j_len ; /* length of commit. len +1 is the commit block */
1635 __u32 j_mount_id ; /* mount id of this trans*/
1636 __u32 j_realblock[1] ; /* real locations for each block */
1637} ;
1638
1639#define get_desc_trans_id(d) le32_to_cpu((d)->j_trans_id)
1640#define get_desc_trans_len(d) le32_to_cpu((d)->j_len)
1641#define get_desc_mount_id(d) le32_to_cpu((d)->j_mount_id)
1642
1643#define set_desc_trans_id(d,val) do { (d)->j_trans_id = cpu_to_le32 (val); } while (0)
1644#define set_desc_trans_len(d,val) do { (d)->j_len = cpu_to_le32 (val); } while (0)
1645#define set_desc_mount_id(d,val) do { (d)->j_mount_id = cpu_to_le32 (val); } while (0)
1646
1647/* last block written in a commit */
1648struct reiserfs_journal_commit {
1649 __u32 j_trans_id ; /* must match j_trans_id from the desc block */
1650 __u32 j_len ; /* ditto */
1651 __u32 j_realblock[1] ; /* real locations for each block */
1652} ;
1653
1654#define get_commit_trans_id(c) le32_to_cpu((c)->j_trans_id)
1655#define get_commit_trans_len(c) le32_to_cpu((c)->j_len)
1656#define get_commit_mount_id(c) le32_to_cpu((c)->j_mount_id)
1657
1658#define set_commit_trans_id(c,val) do { (c)->j_trans_id = cpu_to_le32 (val); } while (0)
1659#define set_commit_trans_len(c,val) do { (c)->j_len = cpu_to_le32 (val); } while (0)
1660
1661/* this header block gets written whenever a transaction is considered fully flushed, and is more recent than the
1662** last fully flushed transaction. fully flushed means all the log blocks and all the real blocks are on disk,
1663** and this transaction does not need to be replayed.
1664*/
1665struct reiserfs_journal_header {
1666 __u32 j_last_flush_trans_id ; /* id of last fully flushed transaction */
1667 __u32 j_first_unflushed_offset ; /* offset in the log of where to start replay after a crash */
1668 __u32 j_mount_id ;
1669 /* 12 */ struct journal_params jh_journal;
1670} ;
1671
1672/* biggest tunable defines are right here */
1673#define JOURNAL_BLOCK_COUNT 8192 /* number of blocks in the journal */
1674#define JOURNAL_TRANS_MAX_DEFAULT 1024 /* biggest possible single transaction, don't change for now (8/3/99) */
1675#define JOURNAL_TRANS_MIN_DEFAULT 256
1676#define JOURNAL_MAX_BATCH_DEFAULT 900 /* max blocks to batch into one transaction, don't make this any bigger than 900 */
1677#define JOURNAL_MIN_RATIO 2
1678#define JOURNAL_MAX_COMMIT_AGE 30
1679#define JOURNAL_MAX_TRANS_AGE 30
1680#define JOURNAL_PER_BALANCE_CNT (3 * (MAX_HEIGHT-2) + 9)
1681#ifdef CONFIG_QUOTA
1682#define REISERFS_QUOTA_TRANS_BLOCKS 2 /* We need to update data and inode (atime) */
1683#define REISERFS_QUOTA_INIT_BLOCKS (DQUOT_MAX_WRITES*(JOURNAL_PER_BALANCE_CNT+2)+1) /* 1 balancing, 1 bitmap, 1 data per write + stat data update */
1684#else
1685#define REISERFS_QUOTA_TRANS_BLOCKS 0
1686#define REISERFS_QUOTA_INIT_BLOCKS 0
1687#endif
1688
1689/* both of these can be as low as 1, or as high as you want. The min is the
1690** number of 4k bitmap nodes preallocated on mount. New nodes are allocated
1691** as needed, and released when transactions are committed. On release, if
1692** the current number of nodes is > max, the node is freed, otherwise,
1693** it is put on a free list for faster use later.
1694*/
1695#define REISERFS_MIN_BITMAP_NODES 10
1696#define REISERFS_MAX_BITMAP_NODES 100
1697
1698#define JBH_HASH_SHIFT 13 /* these are based on journal hash size of 8192 */
1699#define JBH_HASH_MASK 8191
1700
1701#define _jhashfn(sb,block) \
1702 (((unsigned long)sb>>L1_CACHE_SHIFT) ^ \
1703 (((block)<<(JBH_HASH_SHIFT - 6)) ^ ((block) >> 13) ^ ((block) << (JBH_HASH_SHIFT - 12))))
1704#define journal_hash(t,sb,block) ((t)[_jhashfn((sb),(block)) & JBH_HASH_MASK])
1705
1706// We need these to make journal.c code more readable
1707#define journal_find_get_block(s, block) __find_get_block(SB_JOURNAL(s)->j_dev_bd, block, s->s_blocksize)
1708#define journal_getblk(s, block) __getblk(SB_JOURNAL(s)->j_dev_bd, block, s->s_blocksize)
1709#define journal_bread(s, block) __bread(SB_JOURNAL(s)->j_dev_bd, block, s->s_blocksize)
1710
1711enum reiserfs_bh_state_bits {
1712 BH_JDirty = BH_PrivateStart, /* buffer is in current transaction */
1713 BH_JDirty_wait,
1714 BH_JNew, /* disk block was taken off free list before
1715 * being in a finished transaction, or
1716 * written to disk. Can be reused immed. */
1717 BH_JPrepared,
1718 BH_JRestore_dirty,
1719 BH_JTest, // debugging only will go away
1720};
1721
1722BUFFER_FNS(JDirty, journaled);
1723TAS_BUFFER_FNS(JDirty, journaled);
1724BUFFER_FNS(JDirty_wait, journal_dirty);
1725TAS_BUFFER_FNS(JDirty_wait, journal_dirty);
1726BUFFER_FNS(JNew, journal_new);
1727TAS_BUFFER_FNS(JNew, journal_new);
1728BUFFER_FNS(JPrepared, journal_prepared);
1729TAS_BUFFER_FNS(JPrepared, journal_prepared);
1730BUFFER_FNS(JRestore_dirty, journal_restore_dirty);
1731TAS_BUFFER_FNS(JRestore_dirty, journal_restore_dirty);
1732BUFFER_FNS(JTest, journal_test);
1733TAS_BUFFER_FNS(JTest, journal_test);
1734
1735/*
1736** transaction handle which is passed around for all journal calls
1737*/
1738struct reiserfs_transaction_handle {
1739 struct super_block *t_super ; /* super for this FS when journal_begin was
1740 called. saves calls to reiserfs_get_super
1741 also used by nested transactions to make
1742 sure they are nesting on the right FS
1743 _must_ be first in the handle
1744 */
1745 int t_refcount;
1746 int t_blocks_logged ; /* number of blocks this writer has logged */
1747 int t_blocks_allocated ; /* number of blocks this writer allocated */
1748 unsigned long t_trans_id ; /* sanity check, equals the current trans id */
1749 void *t_handle_save ; /* save existing current->journal_info */
1750 unsigned displace_new_blocks:1; /* if new block allocation occurres, that block
1751 should be displaced from others */
1752 struct list_head t_list;
1753} ;
1754
1755/* used to keep track of ordered and tail writes, attached to the buffer
1756 * head through b_journal_head.
1757 */
1758struct reiserfs_jh {
1759 struct reiserfs_journal_list *jl;
1760 struct buffer_head *bh;
1761 struct list_head list;
1762};
1763
1764void reiserfs_free_jh(struct buffer_head *bh);
1765int reiserfs_add_tail_list(struct inode *inode, struct buffer_head *bh);
1766int reiserfs_add_ordered_list(struct inode *inode, struct buffer_head *bh);
1767int journal_mark_dirty(struct reiserfs_transaction_handle *, struct super_block *, struct buffer_head *bh) ;
1768
1769static inline int
1770reiserfs_file_data_log(struct inode *inode) {
1771 if (reiserfs_data_log(inode->i_sb) ||
1772 (REISERFS_I(inode)->i_flags & i_data_log))
1773 return 1 ;
1774 return 0 ;
1775}
1776
1777static inline int reiserfs_transaction_running(struct super_block *s) {
1778 struct reiserfs_transaction_handle *th = current->journal_info ;
1779 if (th && th->t_super == s)
1780 return 1 ;
1781 if (th && th->t_super == NULL)
1782 BUG();
1783 return 0 ;
1784}
1785
1786int reiserfs_async_progress_wait(struct super_block *s);
1787
1788struct reiserfs_transaction_handle *
1789reiserfs_persistent_transaction(struct super_block *, int count);
1790int reiserfs_end_persistent_transaction(struct reiserfs_transaction_handle *);
1791int reiserfs_commit_page(struct inode *inode, struct page *page,
1792 unsigned from, unsigned to);
1793int reiserfs_flush_old_commits(struct super_block *);
1794int reiserfs_commit_for_inode(struct inode *) ;
1795int reiserfs_inode_needs_commit(struct inode *) ;
1796void reiserfs_update_inode_transaction(struct inode *) ;
1797void reiserfs_wait_on_write_block(struct super_block *s) ;
1798void reiserfs_block_writes(struct reiserfs_transaction_handle *th) ;
1799void reiserfs_allow_writes(struct super_block *s) ;
1800void reiserfs_check_lock_depth(struct super_block *s, char *caller) ;
1801int reiserfs_prepare_for_journal(struct super_block *, struct buffer_head *bh, int wait) ;
1802void reiserfs_restore_prepared_buffer(struct super_block *, struct buffer_head *bh) ;
1803int journal_init(struct super_block *, const char * j_dev_name, int old_format, unsigned int) ;
1804int journal_release(struct reiserfs_transaction_handle*, struct super_block *) ;
1805int journal_release_error(struct reiserfs_transaction_handle*, struct super_block *) ;
1806int journal_end(struct reiserfs_transaction_handle *, struct super_block *, unsigned long) ;
1807int journal_end_sync(struct reiserfs_transaction_handle *, struct super_block *, unsigned long) ;
1808int journal_mark_freed(struct reiserfs_transaction_handle *, struct super_block *, b_blocknr_t blocknr) ;
1809int journal_transaction_should_end(struct reiserfs_transaction_handle *, int) ;
1810int reiserfs_in_journal(struct super_block *p_s_sb, int bmap_nr, int bit_nr, int searchall, b_blocknr_t *next) ;
1811int journal_begin(struct reiserfs_transaction_handle *, struct super_block *p_s_sb, unsigned long) ;
1812int journal_join_abort(struct reiserfs_transaction_handle *, struct super_block *p_s_sb, unsigned long) ;
1813void reiserfs_journal_abort (struct super_block *sb, int errno);
1814void reiserfs_abort (struct super_block *sb, int errno, const char *fmt, ...);
1815int reiserfs_allocate_list_bitmaps(struct super_block *s, struct reiserfs_list_bitmap *, int) ;
1816
1817void add_save_link (struct reiserfs_transaction_handle * th,
1818 struct inode * inode, int truncate);
1819int remove_save_link (struct inode * inode, int truncate);
1820
1821/* objectid.c */
1822__u32 reiserfs_get_unused_objectid (struct reiserfs_transaction_handle *th);
1823void reiserfs_release_objectid (struct reiserfs_transaction_handle *th, __u32 objectid_to_release);
1824int reiserfs_convert_objectid_map_v1(struct super_block *) ;
1825
1826/* stree.c */
1827int B_IS_IN_TREE(const struct buffer_head *);
1828extern void copy_item_head(struct item_head * p_v_to,
1829 const struct item_head * p_v_from);
1830
1831// first key is in cpu form, second - le
1832extern int comp_short_keys (const struct reiserfs_key * le_key,
1833 const struct cpu_key * cpu_key);
1834extern void le_key2cpu_key (struct cpu_key * to, const struct reiserfs_key * from);
1835
1836// both are in le form
1837extern int comp_le_keys (const struct reiserfs_key *, const struct reiserfs_key *);
1838extern int comp_short_le_keys (const struct reiserfs_key *, const struct reiserfs_key *);
1839
1840//
1841// get key version from on disk key - kludge
1842//
1843static inline int le_key_version (const struct reiserfs_key * key)
1844{
1845 int type;
1846
1847 type = offset_v2_k_type( &(key->u.k_offset_v2));
1848 if (type != TYPE_DIRECT && type != TYPE_INDIRECT && type != TYPE_DIRENTRY)
1849 return KEY_FORMAT_3_5;
1850
1851 return KEY_FORMAT_3_6;
1852
1853}
1854
1855
1856static inline void copy_key (struct reiserfs_key *to, const struct reiserfs_key *from)
1857{
1858 memcpy (to, from, KEY_SIZE);
1859}
1860
1861
1862int comp_items (const struct item_head * stored_ih, const struct path * p_s_path);
1863const struct reiserfs_key * get_rkey (const struct path * p_s_chk_path,
1864 const struct super_block * p_s_sb);
1865int search_by_key (struct super_block *, const struct cpu_key *,
1866 struct path *, int);
1867#define search_item(s,key,path) search_by_key (s, key, path, DISK_LEAF_NODE_LEVEL)
1868int search_for_position_by_key (struct super_block * p_s_sb,
1869 const struct cpu_key * p_s_cpu_key,
1870 struct path * p_s_search_path);
1871extern void decrement_bcount (struct buffer_head * p_s_bh);
1872void decrement_counters_in_path (struct path * p_s_search_path);
1873void pathrelse (struct path * p_s_search_path);
1874int reiserfs_check_path(struct path *p) ;
1875void pathrelse_and_restore (struct super_block *s, struct path * p_s_search_path);
1876
1877int reiserfs_insert_item (struct reiserfs_transaction_handle *th,
1878 struct path * path,
1879 const struct cpu_key * key,
1880 struct item_head * ih,
1881 struct inode *inode, const char * body);
1882
1883int reiserfs_paste_into_item (struct reiserfs_transaction_handle *th,
1884 struct path * path,
1885 const struct cpu_key * key,
1886 struct inode *inode,
1887 const char * body, int paste_size);
1888
1889int reiserfs_cut_from_item (struct reiserfs_transaction_handle *th,
1890 struct path * path,
1891 struct cpu_key * key,
1892 struct inode * inode,
1893 struct page *page,
1894 loff_t new_file_size);
1895
1896int reiserfs_delete_item (struct reiserfs_transaction_handle *th,
1897 struct path * path,
1898 const struct cpu_key * key,
1899 struct inode * inode,
1900 struct buffer_head * p_s_un_bh);
1901
1902void reiserfs_delete_solid_item (struct reiserfs_transaction_handle *th,
1903 struct inode *inode, struct reiserfs_key * key);
1904int reiserfs_delete_object (struct reiserfs_transaction_handle *th, struct inode * p_s_inode);
1905int reiserfs_do_truncate (struct reiserfs_transaction_handle *th,
1906 struct inode * p_s_inode, struct page *,
1907 int update_timestamps);
1908
1909#define i_block_size(inode) ((inode)->i_sb->s_blocksize)
1910#define file_size(inode) ((inode)->i_size)
1911#define tail_size(inode) (file_size (inode) & (i_block_size (inode) - 1))
1912
1913#define tail_has_to_be_packed(inode) (have_large_tails ((inode)->i_sb)?\
1914!STORE_TAIL_IN_UNFM_S1(file_size (inode), tail_size(inode), inode->i_sb->s_blocksize):have_small_tails ((inode)->i_sb)?!STORE_TAIL_IN_UNFM_S2(file_size (inode), tail_size(inode), inode->i_sb->s_blocksize):0 )
1915
1916void padd_item (char * item, int total_length, int length);
1917
1918/* inode.c */
1919/* args for the create parameter of reiserfs_get_block */
1920#define GET_BLOCK_NO_CREATE 0 /* don't create new blocks or convert tails */
1921#define GET_BLOCK_CREATE 1 /* add anything you need to find block */
1922#define GET_BLOCK_NO_HOLE 2 /* return -ENOENT for file holes */
1923#define GET_BLOCK_READ_DIRECT 4 /* read the tail if indirect item not found */
1924#define GET_BLOCK_NO_ISEM 8 /* i_sem is not held, don't preallocate */
1925#define GET_BLOCK_NO_DANGLE 16 /* don't leave any transactions running */
1926
1927int restart_transaction(struct reiserfs_transaction_handle *th, struct inode *inode, struct path *path);
1928void reiserfs_read_locked_inode(struct inode * inode, struct reiserfs_iget_args *args) ;
1929int reiserfs_find_actor(struct inode * inode, void *p) ;
1930int reiserfs_init_locked_inode(struct inode * inode, void *p) ;
1931void reiserfs_delete_inode (struct inode * inode);
1932int reiserfs_write_inode (struct inode * inode, int) ;
1933int reiserfs_get_block (struct inode * inode, sector_t block, struct buffer_head * bh_result, int create);
1934struct dentry *reiserfs_get_dentry(struct super_block *, void *) ;
1935struct dentry *reiserfs_decode_fh(struct super_block *sb, __u32 *data,
1936 int len, int fhtype,
1937 int (*acceptable)(void *contect, struct dentry *de),
1938 void *context) ;
1939int reiserfs_encode_fh( struct dentry *dentry, __u32 *data, int *lenp,
1940 int connectable );
1941
1942int reiserfs_truncate_file(struct inode *, int update_timestamps) ;
1943void make_cpu_key (struct cpu_key * cpu_key, struct inode * inode, loff_t offset,
1944 int type, int key_length);
1945void make_le_item_head (struct item_head * ih, const struct cpu_key * key,
1946 int version,
1947 loff_t offset, int type, int length, int entry_count);
1948struct inode * reiserfs_iget (struct super_block * s,
1949 const struct cpu_key * key);
1950
1951
1952int reiserfs_new_inode (struct reiserfs_transaction_handle *th,
1953 struct inode * dir, int mode,
1954 const char * symname, loff_t i_size,
1955 struct dentry *dentry, struct inode *inode);
1956
1957void reiserfs_update_sd_size (struct reiserfs_transaction_handle *th,
1958 struct inode * inode, loff_t size);
1959
1960static inline void reiserfs_update_sd(struct reiserfs_transaction_handle *th,
1961 struct inode *inode)
1962{
1963 reiserfs_update_sd_size(th, inode, inode->i_size) ;
1964}
1965
1966void sd_attrs_to_i_attrs( __u16 sd_attrs, struct inode *inode );
1967void i_attrs_to_sd_attrs( struct inode *inode, __u16 *sd_attrs );
1968int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
1969
1970/* namei.c */
1971void set_de_name_and_namelen (struct reiserfs_dir_entry * de);
1972int search_by_entry_key (struct super_block * sb, const struct cpu_key * key,
1973 struct path * path,
1974 struct reiserfs_dir_entry * de);
1975struct dentry *reiserfs_get_parent(struct dentry *) ;
1976/* procfs.c */
1977
1978#if defined( CONFIG_PROC_FS ) && defined( CONFIG_REISERFS_PROC_INFO )
1979#define REISERFS_PROC_INFO
1980#else
1981#undef REISERFS_PROC_INFO
1982#endif
1983
1984int reiserfs_proc_info_init( struct super_block *sb );
1985int reiserfs_proc_info_done( struct super_block *sb );
1986struct proc_dir_entry *reiserfs_proc_register_global( char *name,
1987 read_proc_t *func );
1988void reiserfs_proc_unregister_global( const char *name );
1989int reiserfs_proc_info_global_init( void );
1990int reiserfs_proc_info_global_done( void );
1991int reiserfs_global_version_in_proc( char *buffer, char **start, off_t offset,
1992 int count, int *eof, void *data );
1993
1994#if defined( REISERFS_PROC_INFO )
1995
1996#define PROC_EXP( e ) e
1997
1998#define __PINFO( sb ) REISERFS_SB(sb) -> s_proc_info_data
1999#define PROC_INFO_MAX( sb, field, value ) \
2000 __PINFO( sb ).field = \
2001 max( REISERFS_SB( sb ) -> s_proc_info_data.field, value )
2002#define PROC_INFO_INC( sb, field ) ( ++ ( __PINFO( sb ).field ) )
2003#define PROC_INFO_ADD( sb, field, val ) ( __PINFO( sb ).field += ( val ) )
2004#define PROC_INFO_BH_STAT( sb, bh, level ) \
2005 PROC_INFO_INC( sb, sbk_read_at[ ( level ) ] ); \
2006 PROC_INFO_ADD( sb, free_at[ ( level ) ], B_FREE_SPACE( bh ) ); \
2007 PROC_INFO_ADD( sb, items_at[ ( level ) ], B_NR_ITEMS( bh ) )
2008#else
2009#define PROC_EXP( e )
2010#define VOID_V ( ( void ) 0 )
2011#define PROC_INFO_MAX( sb, field, value ) VOID_V
2012#define PROC_INFO_INC( sb, field ) VOID_V
2013#define PROC_INFO_ADD( sb, field, val ) VOID_V
2014#define PROC_INFO_BH_STAT( p_s_sb, p_s_bh, n_node_level ) VOID_V
2015#endif
2016
2017/* dir.c */
2018extern struct inode_operations reiserfs_dir_inode_operations;
2019extern struct inode_operations reiserfs_symlink_inode_operations;
2020extern struct inode_operations reiserfs_special_inode_operations;
2021extern struct file_operations reiserfs_dir_operations;
2022
2023/* tail_conversion.c */
2024int direct2indirect (struct reiserfs_transaction_handle *, struct inode *, struct path *, struct buffer_head *, loff_t);
2025int indirect2direct (struct reiserfs_transaction_handle *, struct inode *, struct page *, struct path *, const struct cpu_key *, loff_t, char *);
2026void reiserfs_unmap_buffer(struct buffer_head *) ;
2027
2028
2029/* file.c */
2030extern struct inode_operations reiserfs_file_inode_operations;
2031extern struct file_operations reiserfs_file_operations;
2032extern struct address_space_operations reiserfs_address_space_operations ;
2033
2034/* fix_nodes.c */
2035#ifdef CONFIG_REISERFS_CHECK
2036void * reiserfs_kmalloc (size_t size, int flags, struct super_block * s);
2037void reiserfs_kfree (const void * vp, size_t size, struct super_block * s);
2038#else
2039static inline void *reiserfs_kmalloc(size_t size, int flags,
2040 struct super_block *s)
2041{
2042 return kmalloc(size, flags);
2043}
2044
2045static inline void reiserfs_kfree(const void *vp, size_t size,
2046 struct super_block *s)
2047{
2048 kfree(vp);
2049}
2050#endif
2051
2052int fix_nodes (int n_op_mode, struct tree_balance * p_s_tb,
2053 struct item_head * p_s_ins_ih, const void *);
2054void unfix_nodes (struct tree_balance *);
2055
2056
2057/* prints.c */
2058void reiserfs_panic (struct super_block * s, const char * fmt, ...) __attribute__ ( ( noreturn ) );
2059void reiserfs_info (struct super_block *s, const char * fmt, ...);
2060void reiserfs_debug (struct super_block *s, int level, const char * fmt, ...);
2061void print_indirect_item (struct buffer_head * bh, int item_num);
2062void store_print_tb (struct tree_balance * tb);
2063void print_cur_tb (char * mes);
2064void print_de (struct reiserfs_dir_entry * de);
2065void print_bi (struct buffer_info * bi, char * mes);
2066#define PRINT_LEAF_ITEMS 1 /* print all items */
2067#define PRINT_DIRECTORY_ITEMS 2 /* print directory items */
2068#define PRINT_DIRECT_ITEMS 4 /* print contents of direct items */
2069void print_block (struct buffer_head * bh, ...);
2070void print_bmap (struct super_block * s, int silent);
2071void print_bmap_block (int i, char * data, int size, int silent);
2072/*void print_super_block (struct super_block * s, char * mes);*/
2073void print_objectid_map (struct super_block * s);
2074void print_block_head (struct buffer_head * bh, char * mes);
2075void check_leaf (struct buffer_head * bh);
2076void check_internal (struct buffer_head * bh);
2077void print_statistics (struct super_block * s);
2078char * reiserfs_hashname(int code);
2079
2080/* lbalance.c */
2081int leaf_move_items (int shift_mode, struct tree_balance * tb, int mov_num, int mov_bytes, struct buffer_head * Snew);
2082int leaf_shift_left (struct tree_balance * tb, int shift_num, int shift_bytes);
2083int leaf_shift_right (struct tree_balance * tb, int shift_num, int shift_bytes);
2084void leaf_delete_items (struct buffer_info * cur_bi, int last_first, int first, int del_num, int del_bytes);
2085void leaf_insert_into_buf (struct buffer_info * bi, int before,
2086 struct item_head * inserted_item_ih, const char * inserted_item_body, int zeros_number);
2087void leaf_paste_in_buffer (struct buffer_info * bi, int pasted_item_num,
2088 int pos_in_item, int paste_size, const char * body, int zeros_number);
2089void leaf_cut_from_buffer (struct buffer_info * bi, int cut_item_num, int pos_in_item,
2090 int cut_size);
2091void leaf_paste_entries (struct buffer_head * bh, int item_num, int before,
2092 int new_entry_count, struct reiserfs_de_head * new_dehs, const char * records, int paste_size);
2093/* ibalance.c */
2094int balance_internal (struct tree_balance * , int, int, struct item_head * ,
2095 struct buffer_head **);
2096
2097/* do_balance.c */
2098void do_balance_mark_leaf_dirty (struct tree_balance * tb,
2099 struct buffer_head * bh, int flag);
2100#define do_balance_mark_internal_dirty do_balance_mark_leaf_dirty
2101#define do_balance_mark_sb_dirty do_balance_mark_leaf_dirty
2102
2103void do_balance (struct tree_balance * tb, struct item_head * ih,
2104 const char * body, int flag);
2105void reiserfs_invalidate_buffer (struct tree_balance * tb, struct buffer_head * bh);
2106
2107int get_left_neighbor_position (struct tree_balance * tb, int h);
2108int get_right_neighbor_position (struct tree_balance * tb, int h);
2109void replace_key (struct tree_balance * tb, struct buffer_head *, int, struct buffer_head *, int);
2110void make_empty_node (struct buffer_info *);
2111struct buffer_head * get_FEB (struct tree_balance *);
2112
2113/* bitmap.c */
2114
2115/* structure contains hints for block allocator, and it is a container for
2116 * arguments, such as node, search path, transaction_handle, etc. */
2117 struct __reiserfs_blocknr_hint {
2118 struct inode * inode; /* inode passed to allocator, if we allocate unf. nodes */
2119 long block; /* file offset, in blocks */
2120 struct reiserfs_key key;
2121 struct path * path; /* search path, used by allocator to deternine search_start by
2122 * various ways */
2123 struct reiserfs_transaction_handle * th; /* transaction handle is needed to log super blocks and
2124 * bitmap blocks changes */
2125 b_blocknr_t beg, end;
2126 b_blocknr_t search_start; /* a field used to transfer search start value (block number)
2127 * between different block allocator procedures
2128 * (determine_search_start() and others) */
2129 int prealloc_size; /* is set in determine_prealloc_size() function, used by underlayed
2130 * function that do actual allocation */
2131
2132 unsigned formatted_node:1; /* the allocator uses different polices for getting disk space for
2133 * formatted/unformatted blocks with/without preallocation */
2134 unsigned preallocate:1;
2135};
2136
2137typedef struct __reiserfs_blocknr_hint reiserfs_blocknr_hint_t;
2138
2139int reiserfs_parse_alloc_options (struct super_block *, char *);
2140void reiserfs_init_alloc_options (struct super_block *s);
2141
2142/*
2143 * given a directory, this will tell you what packing locality
2144 * to use for a new object underneat it. The locality is returned
2145 * in disk byte order (le).
2146 */
2147u32 reiserfs_choose_packing(struct inode *dir);
2148
2149int is_reusable (struct super_block * s, b_blocknr_t block, int bit_value);
2150void reiserfs_free_block (struct reiserfs_transaction_handle *th, struct inode *, b_blocknr_t, int for_unformatted);
2151int reiserfs_allocate_blocknrs(reiserfs_blocknr_hint_t *, b_blocknr_t * , int, int);
2152extern inline int reiserfs_new_form_blocknrs (struct tree_balance * tb,
2153 b_blocknr_t *new_blocknrs, int amount_needed)
2154{
2155 reiserfs_blocknr_hint_t hint = {
2156 .th = tb->transaction_handle,
2157 .path = tb->tb_path,
2158 .inode = NULL,
2159 .key = tb->key,
2160 .block = 0,
2161 .formatted_node = 1
2162 };
2163 return reiserfs_allocate_blocknrs(&hint, new_blocknrs, amount_needed, 0);
2164}
2165
2166extern inline int reiserfs_new_unf_blocknrs (struct reiserfs_transaction_handle *th,
2167 struct inode *inode,
2168 b_blocknr_t *new_blocknrs,
2169 struct path * path, long block)
2170{
2171 reiserfs_blocknr_hint_t hint = {
2172 .th = th,
2173 .path = path,
2174 .inode = inode,
2175 .block = block,
2176 .formatted_node = 0,
2177 .preallocate = 0
2178 };
2179 return reiserfs_allocate_blocknrs(&hint, new_blocknrs, 1, 0);
2180}
2181
2182#ifdef REISERFS_PREALLOCATE
2183extern inline int reiserfs_new_unf_blocknrs2(struct reiserfs_transaction_handle *th,
2184 struct inode * inode,
2185 b_blocknr_t *new_blocknrs,
2186 struct path * path, long block)
2187{
2188 reiserfs_blocknr_hint_t hint = {
2189 .th = th,
2190 .path = path,
2191 .inode = inode,
2192 .block = block,
2193 .formatted_node = 0,
2194 .preallocate = 1
2195 };
2196 return reiserfs_allocate_blocknrs(&hint, new_blocknrs, 1, 0);
2197}
2198
2199void reiserfs_discard_prealloc (struct reiserfs_transaction_handle *th,
2200 struct inode * inode);
2201void reiserfs_discard_all_prealloc (struct reiserfs_transaction_handle *th);
2202#endif
2203void reiserfs_claim_blocks_to_be_allocated( struct super_block *sb, int blocks);
2204void reiserfs_release_claimed_blocks( struct super_block *sb, int blocks);
2205int reiserfs_can_fit_pages(struct super_block *sb);
2206
2207/* hashes.c */
2208__u32 keyed_hash (const signed char *msg, int len);
2209__u32 yura_hash (const signed char *msg, int len);
2210__u32 r5_hash (const signed char *msg, int len);
2211
2212/* the ext2 bit routines adjust for big or little endian as
2213** appropriate for the arch, so in our laziness we use them rather
2214** than using the bit routines they call more directly. These
2215** routines must be used when changing on disk bitmaps. */
2216#define reiserfs_test_and_set_le_bit ext2_set_bit
2217#define reiserfs_test_and_clear_le_bit ext2_clear_bit
2218#define reiserfs_test_le_bit ext2_test_bit
2219#define reiserfs_find_next_zero_le_bit ext2_find_next_zero_bit
2220
2221/* sometimes reiserfs_truncate may require to allocate few new blocks
2222 to perform indirect2direct conversion. People probably used to
2223 think, that truncate should work without problems on a filesystem
2224 without free disk space. They may complain that they can not
2225 truncate due to lack of free disk space. This spare space allows us
2226 to not worry about it. 500 is probably too much, but it should be
2227 absolutely safe */
2228#define SPARE_SPACE 500
2229
2230
2231/* prototypes from ioctl.c */
2232int reiserfs_ioctl (struct inode * inode, struct file * filp,
2233 unsigned int cmd, unsigned long arg);
2234
2235/* ioctl's command */
2236#define REISERFS_IOC_UNPACK _IOW(0xCD,1,long)
2237/* define following flags to be the same as in ext2, so that chattr(1),
2238 lsattr(1) will work with us. */
2239#define REISERFS_IOC_GETFLAGS EXT2_IOC_GETFLAGS
2240#define REISERFS_IOC_SETFLAGS EXT2_IOC_SETFLAGS
2241#define REISERFS_IOC_GETVERSION EXT2_IOC_GETVERSION
2242#define REISERFS_IOC_SETVERSION EXT2_IOC_SETVERSION
2243
2244/* Locking primitives */
2245/* Right now we are still falling back to (un)lock_kernel, but eventually that
2246 would evolve into real per-fs locks */
2247#define reiserfs_write_lock( sb ) lock_kernel()
2248#define reiserfs_write_unlock( sb ) unlock_kernel()
2249
2250/* xattr stuff */
2251#define REISERFS_XATTR_DIR_SEM(s) (REISERFS_SB(s)->xattr_dir_sem)
2252
2253#endif /* _LINUX_REISER_FS_H */
2254
2255
diff --git a/include/linux/reiserfs_fs_i.h b/include/linux/reiserfs_fs_i.h
new file mode 100644
index 000000000000..e321eb050d65
--- /dev/null
+++ b/include/linux/reiserfs_fs_i.h
@@ -0,0 +1,63 @@
1#ifndef _REISER_FS_I
2#define _REISER_FS_I
3
4#include <linux/list.h>
5
6struct reiserfs_journal_list;
7
8/** bitmasks for i_flags field in reiserfs-specific part of inode */
9typedef enum {
10 /** this says what format of key do all items (but stat data) of
11 an object have. If this is set, that format is 3.6 otherwise
12 - 3.5 */
13 i_item_key_version_mask = 0x0001,
14 /** If this is unset, object has 3.5 stat data, otherwise, it has
15 3.6 stat data with 64bit size, 32bit nlink etc. */
16 i_stat_data_version_mask = 0x0002,
17 /** file might need tail packing on close */
18 i_pack_on_close_mask = 0x0004,
19 /** don't pack tail of file */
20 i_nopack_mask = 0x0008,
21 /** If those is set, "safe link" was created for this file during
22 truncate or unlink. Safe link is used to avoid leakage of disk
23 space on crash with some files open, but unlinked. */
24 i_link_saved_unlink_mask = 0x0010,
25 i_link_saved_truncate_mask = 0x0020,
26 i_has_xattr_dir = 0x0040,
27 i_data_log = 0x0080,
28} reiserfs_inode_flags;
29
30
31struct reiserfs_inode_info {
32 __u32 i_key [4];/* key is still 4 32 bit integers */
33 /** transient inode flags that are never stored on disk. Bitmasks
34 for this field are defined above. */
35 __u32 i_flags;
36
37 __u32 i_first_direct_byte; // offset of first byte stored in direct item.
38
39 /* copy of persistent inode flags read from sd_attrs. */
40 __u32 i_attrs;
41
42 int i_prealloc_block; /* first unused block of a sequence of unused blocks */
43 int i_prealloc_count; /* length of that sequence */
44 struct list_head i_prealloc_list; /* per-transaction list of inodes which
45 * have preallocated blocks */
46
47 unsigned new_packing_locality:1; /* new_packig_locality is created; new blocks
48 * for the contents of this directory should be
49 * displaced */
50
51 /* we use these for fsync or O_SYNC to decide which transaction
52 ** needs to be committed in order for this inode to be properly
53 ** flushed */
54 unsigned long i_trans_id ;
55 struct reiserfs_journal_list *i_jl;
56
57 struct posix_acl *i_acl_access;
58 struct posix_acl *i_acl_default;
59 struct rw_semaphore xattr_sem;
60 struct inode vfs_inode;
61};
62
63#endif
diff --git a/include/linux/reiserfs_fs_sb.h b/include/linux/reiserfs_fs_sb.h
new file mode 100644
index 000000000000..37a3a7afbec7
--- /dev/null
+++ b/include/linux/reiserfs_fs_sb.h
@@ -0,0 +1,535 @@
1/* Copyright 1996-2000 Hans Reiser, see reiserfs/README for licensing
2 * and copyright details */
3
4#ifndef _LINUX_REISER_FS_SB
5#define _LINUX_REISER_FS_SB
6
7#ifdef __KERNEL__
8#include <linux/workqueue.h>
9#include <linux/rwsem.h>
10#endif
11
12typedef enum {
13 reiserfs_attrs_cleared = 0x00000001,
14} reiserfs_super_block_flags;
15
16/* struct reiserfs_super_block accessors/mutators
17 * since this is a disk structure, it will always be in
18 * little endian format. */
19#define sb_block_count(sbp) (le32_to_cpu((sbp)->s_v1.s_block_count))
20#define set_sb_block_count(sbp,v) ((sbp)->s_v1.s_block_count = cpu_to_le32(v))
21#define sb_free_blocks(sbp) (le32_to_cpu((sbp)->s_v1.s_free_blocks))
22#define set_sb_free_blocks(sbp,v) ((sbp)->s_v1.s_free_blocks = cpu_to_le32(v))
23#define sb_root_block(sbp) (le32_to_cpu((sbp)->s_v1.s_root_block))
24#define set_sb_root_block(sbp,v) ((sbp)->s_v1.s_root_block = cpu_to_le32(v))
25
26#define sb_jp_journal_1st_block(sbp) \
27 (le32_to_cpu((sbp)->s_v1.s_journal.jp_journal_1st_block))
28#define set_sb_jp_journal_1st_block(sbp,v) \
29 ((sbp)->s_v1.s_journal.jp_journal_1st_block = cpu_to_le32(v))
30#define sb_jp_journal_dev(sbp) \
31 (le32_to_cpu((sbp)->s_v1.s_journal.jp_journal_dev))
32#define set_sb_jp_journal_dev(sbp,v) \
33 ((sbp)->s_v1.s_journal.jp_journal_dev = cpu_to_le32(v))
34#define sb_jp_journal_size(sbp) \
35 (le32_to_cpu((sbp)->s_v1.s_journal.jp_journal_size))
36#define set_sb_jp_journal_size(sbp,v) \
37 ((sbp)->s_v1.s_journal.jp_journal_size = cpu_to_le32(v))
38#define sb_jp_journal_trans_max(sbp) \
39 (le32_to_cpu((sbp)->s_v1.s_journal.jp_journal_trans_max))
40#define set_sb_jp_journal_trans_max(sbp,v) \
41 ((sbp)->s_v1.s_journal.jp_journal_trans_max = cpu_to_le32(v))
42#define sb_jp_journal_magic(sbp) \
43 (le32_to_cpu((sbp)->s_v1.s_journal.jp_journal_magic))
44#define set_sb_jp_journal_magic(sbp,v) \
45 ((sbp)->s_v1.s_journal.jp_journal_magic = cpu_to_le32(v))
46#define sb_jp_journal_max_batch(sbp) \
47 (le32_to_cpu((sbp)->s_v1.s_journal.jp_journal_max_batch))
48#define set_sb_jp_journal_max_batch(sbp,v) \
49 ((sbp)->s_v1.s_journal.jp_journal_max_batch = cpu_to_le32(v))
50#define sb_jp_jourmal_max_commit_age(sbp) \
51 (le32_to_cpu((sbp)->s_v1.s_journal.jp_journal_max_commit_age))
52#define set_sb_jp_journal_max_commit_age(sbp,v) \
53 ((sbp)->s_v1.s_journal.jp_journal_max_commit_age = cpu_to_le32(v))
54
55#define sb_blocksize(sbp) (le16_to_cpu((sbp)->s_v1.s_blocksize))
56#define set_sb_blocksize(sbp,v) ((sbp)->s_v1.s_blocksize = cpu_to_le16(v))
57#define sb_oid_maxsize(sbp) (le16_to_cpu((sbp)->s_v1.s_oid_maxsize))
58#define set_sb_oid_maxsize(sbp,v) ((sbp)->s_v1.s_oid_maxsize = cpu_to_le16(v))
59#define sb_oid_cursize(sbp) (le16_to_cpu((sbp)->s_v1.s_oid_cursize))
60#define set_sb_oid_cursize(sbp,v) ((sbp)->s_v1.s_oid_cursize = cpu_to_le16(v))
61#define sb_umount_state(sbp) (le16_to_cpu((sbp)->s_v1.s_umount_state))
62#define set_sb_umount_state(sbp,v) ((sbp)->s_v1.s_umount_state = cpu_to_le16(v))
63#define sb_fs_state(sbp) (le16_to_cpu((sbp)->s_v1.s_fs_state))
64#define set_sb_fs_state(sbp,v) ((sbp)->s_v1.s_fs_state = cpu_to_le16(v))
65#define sb_hash_function_code(sbp) \
66 (le32_to_cpu((sbp)->s_v1.s_hash_function_code))
67#define set_sb_hash_function_code(sbp,v) \
68 ((sbp)->s_v1.s_hash_function_code = cpu_to_le32(v))
69#define sb_tree_height(sbp) (le16_to_cpu((sbp)->s_v1.s_tree_height))
70#define set_sb_tree_height(sbp,v) ((sbp)->s_v1.s_tree_height = cpu_to_le16(v))
71#define sb_bmap_nr(sbp) (le16_to_cpu((sbp)->s_v1.s_bmap_nr))
72#define set_sb_bmap_nr(sbp,v) ((sbp)->s_v1.s_bmap_nr = cpu_to_le16(v))
73#define sb_version(sbp) (le16_to_cpu((sbp)->s_v1.s_version))
74#define set_sb_version(sbp,v) ((sbp)->s_v1.s_version = cpu_to_le16(v))
75
76#define sb_reserved_for_journal(sbp) \
77 (le16_to_cpu((sbp)->s_v1.s_reserved_for_journal))
78#define set_sb_reserved_for_journal(sbp,v) \
79 ((sbp)->s_v1.s_reserved_for_journal = cpu_to_le16(v))
80
81/* LOGGING -- */
82
83/* These all interelate for performance.
84**
85** If the journal block count is smaller than n transactions, you lose speed.
86** I don't know what n is yet, I'm guessing 8-16.
87**
88** typical transaction size depends on the application, how often fsync is
89** called, and how many metadata blocks you dirty in a 30 second period.
90** The more small files (<16k) you use, the larger your transactions will
91** be.
92**
93** If your journal fills faster than dirty buffers get flushed to disk, it must flush them before allowing the journal
94** to wrap, which slows things down. If you need high speed meta data updates, the journal should be big enough
95** to prevent wrapping before dirty meta blocks get to disk.
96**
97** If the batch max is smaller than the transaction max, you'll waste space at the end of the journal
98** because journal_end sets the next transaction to start at 0 if the next transaction has any chance of wrapping.
99**
100** The large the batch max age, the better the speed, and the more meta data changes you'll lose after a crash.
101**
102*/
103
104/* don't mess with these for a while */
105 /* we have a node size define somewhere in reiserfs_fs.h. -Hans */
106#define JOURNAL_BLOCK_SIZE 4096 /* BUG gotta get rid of this */
107#define JOURNAL_MAX_CNODE 1500 /* max cnodes to allocate. */
108#define JOURNAL_HASH_SIZE 8192
109#define JOURNAL_NUM_BITMAPS 5 /* number of copies of the bitmaps to have floating. Must be >= 2 */
110
111/* One of these for every block in every transaction
112** Each one is in two hash tables. First, a hash of the current transaction, and after journal_end, a
113** hash of all the in memory transactions.
114** next and prev are used by the current transaction (journal_hash).
115** hnext and hprev are used by journal_list_hash. If a block is in more than one transaction, the journal_list_hash
116** links it in multiple times. This allows flush_journal_list to remove just the cnode belonging
117** to a given transaction.
118*/
119struct reiserfs_journal_cnode {
120 struct buffer_head *bh ; /* real buffer head */
121 struct super_block *sb ; /* dev of real buffer head */
122 __u32 blocknr ; /* block number of real buffer head, == 0 when buffer on disk */
123 long state ;
124 struct reiserfs_journal_list *jlist ; /* journal list this cnode lives in */
125 struct reiserfs_journal_cnode *next ; /* next in transaction list */
126 struct reiserfs_journal_cnode *prev ; /* prev in transaction list */
127 struct reiserfs_journal_cnode *hprev ; /* prev in hash list */
128 struct reiserfs_journal_cnode *hnext ; /* next in hash list */
129};
130
131struct reiserfs_bitmap_node {
132 int id ;
133 char *data ;
134 struct list_head list ;
135} ;
136
137struct reiserfs_list_bitmap {
138 struct reiserfs_journal_list *journal_list ;
139 struct reiserfs_bitmap_node **bitmaps ;
140} ;
141
142/*
143** one of these for each transaction. The most important part here is the j_realblock.
144** this list of cnodes is used to hash all the blocks in all the commits, to mark all the
145** real buffer heads dirty once all the commits hit the disk,
146** and to make sure every real block in a transaction is on disk before allowing the log area
147** to be overwritten */
148struct reiserfs_journal_list {
149 unsigned long j_start ;
150 unsigned long j_state;
151 unsigned long j_len ;
152 atomic_t j_nonzerolen ;
153 atomic_t j_commit_left ;
154 atomic_t j_older_commits_done ; /* all commits older than this on disk*/
155 struct semaphore j_commit_lock;
156 unsigned long j_trans_id ;
157 time_t j_timestamp ;
158 struct reiserfs_list_bitmap *j_list_bitmap ;
159 struct buffer_head *j_commit_bh ; /* commit buffer head */
160 struct reiserfs_journal_cnode *j_realblock ;
161 struct reiserfs_journal_cnode *j_freedlist ; /* list of buffers that were freed during this trans. free each of these on flush */
162 /* time ordered list of all active transactions */
163 struct list_head j_list;
164
165 /* time ordered list of all transactions we haven't tried to flush yet */
166 struct list_head j_working_list;
167
168 /* list of tail conversion targets in need of flush before commit */
169 struct list_head j_tail_bh_list;
170 /* list of data=ordered buffers in need of flush before commit */
171 struct list_head j_bh_list;
172 int j_refcount;
173} ;
174
175struct reiserfs_journal {
176 struct buffer_head ** j_ap_blocks ; /* journal blocks on disk */
177 struct reiserfs_journal_cnode *j_last ; /* newest journal block */
178 struct reiserfs_journal_cnode *j_first ; /* oldest journal block. start here for traverse */
179
180 struct file *j_dev_file;
181 struct block_device *j_dev_bd;
182 int j_1st_reserved_block; /* first block on s_dev of reserved area journal */
183
184 long j_state ;
185 unsigned long j_trans_id ;
186 unsigned long j_mount_id ;
187 unsigned long j_start ; /* start of current waiting commit (index into j_ap_blocks) */
188 unsigned long j_len ; /* lenght of current waiting commit */
189 unsigned long j_len_alloc ; /* number of buffers requested by journal_begin() */
190 atomic_t j_wcount ; /* count of writers for current commit */
191 unsigned long j_bcount ; /* batch count. allows turning X transactions into 1 */
192 unsigned long j_first_unflushed_offset ; /* first unflushed transactions offset */
193 unsigned long j_last_flush_trans_id ; /* last fully flushed journal timestamp */
194 struct buffer_head *j_header_bh ;
195
196 time_t j_trans_start_time ; /* time this transaction started */
197 struct semaphore j_lock;
198 struct semaphore j_flush_sem;
199 wait_queue_head_t j_join_wait ; /* wait for current transaction to finish before starting new one */
200 atomic_t j_jlock ; /* lock for j_join_wait */
201 int j_list_bitmap_index ; /* number of next list bitmap to use */
202 int j_must_wait ; /* no more journal begins allowed. MUST sleep on j_join_wait */
203 int j_next_full_flush ; /* next journal_end will flush all journal list */
204 int j_next_async_flush ; /* next journal_end will flush all async commits */
205
206 int j_cnode_used ; /* number of cnodes on the used list */
207 int j_cnode_free ; /* number of cnodes on the free list */
208
209 unsigned int j_trans_max ; /* max number of blocks in a transaction. */
210 unsigned int j_max_batch ; /* max number of blocks to batch into a trans */
211 unsigned int j_max_commit_age ; /* in seconds, how old can an async commit be */
212 unsigned int j_max_trans_age ; /* in seconds, how old can a transaction be */
213 unsigned int j_default_max_commit_age ; /* the default for the max commit age */
214
215 struct reiserfs_journal_cnode *j_cnode_free_list ;
216 struct reiserfs_journal_cnode *j_cnode_free_orig ; /* orig pointer returned from vmalloc */
217
218 struct reiserfs_journal_list *j_current_jl;
219 int j_free_bitmap_nodes ;
220 int j_used_bitmap_nodes ;
221
222 int j_num_lists; /* total number of active transactions */
223 int j_num_work_lists; /* number that need attention from kreiserfsd */
224
225 /* debugging to make sure things are flushed in order */
226 int j_last_flush_id;
227
228 /* debugging to make sure things are committed in order */
229 int j_last_commit_id;
230
231 struct list_head j_bitmap_nodes ;
232 struct list_head j_dirty_buffers ;
233 spinlock_t j_dirty_buffers_lock ; /* protects j_dirty_buffers */
234
235 /* list of all active transactions */
236 struct list_head j_journal_list;
237 /* lists that haven't been touched by writeback attempts */
238 struct list_head j_working_list;
239
240 struct reiserfs_list_bitmap j_list_bitmap[JOURNAL_NUM_BITMAPS] ; /* array of bitmaps to record the deleted blocks */
241 struct reiserfs_journal_cnode *j_hash_table[JOURNAL_HASH_SIZE] ; /* hash table for real buffer heads in current trans */
242 struct reiserfs_journal_cnode *j_list_hash_table[JOURNAL_HASH_SIZE] ; /* hash table for all the real buffer heads in all
243 the transactions */
244 struct list_head j_prealloc_list; /* list of inodes which have preallocated blocks */
245 int j_persistent_trans;
246 unsigned long j_max_trans_size ;
247 unsigned long j_max_batch_size ;
248
249 int j_errno;
250
251 /* when flushing ordered buffers, throttle new ordered writers */
252 struct work_struct j_work;
253 atomic_t j_async_throttle;
254};
255
256enum journal_state_bits {
257 J_WRITERS_BLOCKED = 1, /* set when new writers not allowed */
258 J_WRITERS_QUEUED, /* set when log is full due to too many writers */
259 J_ABORTED, /* set when log is aborted */
260};
261
262
263#define JOURNAL_DESC_MAGIC "ReIsErLB" /* ick. magic string to find desc blocks in the journal */
264
265typedef __u32 (*hashf_t) (const signed char *, int);
266
267struct reiserfs_bitmap_info
268{
269 // FIXME: Won't work with block sizes > 8K
270 __u16 first_zero_hint;
271 __u16 free_count;
272 struct buffer_head *bh; /* the actual bitmap */
273};
274
275struct proc_dir_entry;
276
277#if defined( CONFIG_PROC_FS ) && defined( CONFIG_REISERFS_PROC_INFO )
278typedef unsigned long int stat_cnt_t;
279typedef struct reiserfs_proc_info_data
280{
281 spinlock_t lock;
282 int exiting;
283 int max_hash_collisions;
284
285 stat_cnt_t breads;
286 stat_cnt_t bread_miss;
287 stat_cnt_t search_by_key;
288 stat_cnt_t search_by_key_fs_changed;
289 stat_cnt_t search_by_key_restarted;
290
291 stat_cnt_t insert_item_restarted;
292 stat_cnt_t paste_into_item_restarted;
293 stat_cnt_t cut_from_item_restarted;
294 stat_cnt_t delete_solid_item_restarted;
295 stat_cnt_t delete_item_restarted;
296
297 stat_cnt_t leaked_oid;
298 stat_cnt_t leaves_removable;
299
300 /* balances per level. Use explicit 5 as MAX_HEIGHT is not visible yet. */
301 stat_cnt_t balance_at[ 5 ]; /* XXX */
302 /* sbk == search_by_key */
303 stat_cnt_t sbk_read_at[ 5 ]; /* XXX */
304 stat_cnt_t sbk_fs_changed[ 5 ];
305 stat_cnt_t sbk_restarted[ 5 ];
306 stat_cnt_t items_at[ 5 ]; /* XXX */
307 stat_cnt_t free_at[ 5 ]; /* XXX */
308 stat_cnt_t can_node_be_removed[ 5 ]; /* XXX */
309 long int lnum[ 5 ]; /* XXX */
310 long int rnum[ 5 ]; /* XXX */
311 long int lbytes[ 5 ]; /* XXX */
312 long int rbytes[ 5 ]; /* XXX */
313 stat_cnt_t get_neighbors[ 5 ];
314 stat_cnt_t get_neighbors_restart[ 5 ];
315 stat_cnt_t need_l_neighbor[ 5 ];
316 stat_cnt_t need_r_neighbor[ 5 ];
317
318 stat_cnt_t free_block;
319 struct __scan_bitmap_stats {
320 stat_cnt_t call;
321 stat_cnt_t wait;
322 stat_cnt_t bmap;
323 stat_cnt_t retry;
324 stat_cnt_t in_journal_hint;
325 stat_cnt_t in_journal_nohint;
326 stat_cnt_t stolen;
327 } scan_bitmap;
328 struct __journal_stats {
329 stat_cnt_t in_journal;
330 stat_cnt_t in_journal_bitmap;
331 stat_cnt_t in_journal_reusable;
332 stat_cnt_t lock_journal;
333 stat_cnt_t lock_journal_wait;
334 stat_cnt_t journal_being;
335 stat_cnt_t journal_relock_writers;
336 stat_cnt_t journal_relock_wcount;
337 stat_cnt_t mark_dirty;
338 stat_cnt_t mark_dirty_already;
339 stat_cnt_t mark_dirty_notjournal;
340 stat_cnt_t restore_prepared;
341 stat_cnt_t prepare;
342 stat_cnt_t prepare_retry;
343 } journal;
344} reiserfs_proc_info_data_t;
345#else
346typedef struct reiserfs_proc_info_data
347{} reiserfs_proc_info_data_t;
348#endif
349
350/* reiserfs union of in-core super block data */
351struct reiserfs_sb_info
352{
353 struct buffer_head * s_sbh; /* Buffer containing the super block */
354 /* both the comment and the choice of
355 name are unclear for s_rs -Hans */
356 struct reiserfs_super_block * s_rs; /* Pointer to the super block in the buffer */
357 struct reiserfs_bitmap_info * s_ap_bitmap;
358 struct reiserfs_journal *s_journal ; /* pointer to journal information */
359 unsigned short s_mount_state; /* reiserfs state (valid, invalid) */
360
361 /* Comment? -Hans */
362 void (*end_io_handler)(struct buffer_head *, int);
363 hashf_t s_hash_function; /* pointer to function which is used
364 to sort names in directory. Set on
365 mount */
366 unsigned long s_mount_opt; /* reiserfs's mount options are set
367 here (currently - NOTAIL, NOLOG,
368 REPLAYONLY) */
369
370 struct { /* This is a structure that describes block allocator options */
371 unsigned long bits; /* Bitfield for enable/disable kind of options */
372 unsigned long large_file_size; /* size started from which we consider file to be a large one(in blocks) */
373 int border; /* percentage of disk, border takes */
374 int preallocmin; /* Minimal file size (in blocks) starting from which we do preallocations */
375 int preallocsize; /* Number of blocks we try to prealloc when file
376 reaches preallocmin size (in blocks) or
377 prealloc_list is empty. */
378 } s_alloc_options;
379
380 /* Comment? -Hans */
381 wait_queue_head_t s_wait;
382 /* To be obsoleted soon by per buffer seals.. -Hans */
383 atomic_t s_generation_counter; // increased by one every time the
384 // tree gets re-balanced
385 unsigned long s_properties; /* File system properties. Currently holds
386 on-disk FS format */
387
388 /* session statistics */
389 int s_kmallocs;
390 int s_disk_reads;
391 int s_disk_writes;
392 int s_fix_nodes;
393 int s_do_balance;
394 int s_unneeded_left_neighbor;
395 int s_good_search_by_key_reada;
396 int s_bmaps;
397 int s_bmaps_without_search;
398 int s_direct2indirect;
399 int s_indirect2direct;
400 /* set up when it's ok for reiserfs_read_inode2() to read from
401 disk inode with nlink==0. Currently this is only used during
402 finish_unfinished() processing at mount time */
403 int s_is_unlinked_ok;
404 reiserfs_proc_info_data_t s_proc_info_data;
405 struct proc_dir_entry *procdir;
406 int reserved_blocks; /* amount of blocks reserved for further allocations */
407 spinlock_t bitmap_lock; /* this lock on now only used to protect reserved_blocks variable */
408 struct dentry *priv_root; /* root of /.reiserfs_priv */
409 struct dentry *xattr_root; /* root of /.reiserfs_priv/.xa */
410 struct rw_semaphore xattr_dir_sem;
411
412 int j_errno;
413#ifdef CONFIG_QUOTA
414 char *s_qf_names[MAXQUOTAS];
415 int s_jquota_fmt;
416#endif
417};
418
419/* Definitions of reiserfs on-disk properties: */
420#define REISERFS_3_5 0
421#define REISERFS_3_6 1
422
423enum reiserfs_mount_options {
424/* Mount options */
425 REISERFS_LARGETAIL, /* large tails will be created in a session */
426 REISERFS_SMALLTAIL, /* small (for files less than block size) tails will be created in a session */
427 REPLAYONLY, /* replay journal and return 0. Use by fsck */
428 REISERFS_CONVERT, /* -o conv: causes conversion of old
429 format super block to the new
430 format. If not specified - old
431 partition will be dealt with in a
432 manner of 3.5.x */
433
434/* -o hash={tea, rupasov, r5, detect} is meant for properly mounting
435** reiserfs disks from 3.5.19 or earlier. 99% of the time, this option
436** is not required. If the normal autodection code can't determine which
437** hash to use (because both hases had the same value for a file)
438** use this option to force a specific hash. It won't allow you to override
439** the existing hash on the FS, so if you have a tea hash disk, and mount
440** with -o hash=rupasov, the mount will fail.
441*/
442 FORCE_TEA_HASH, /* try to force tea hash on mount */
443 FORCE_RUPASOV_HASH, /* try to force rupasov hash on mount */
444 FORCE_R5_HASH, /* try to force rupasov hash on mount */
445 FORCE_HASH_DETECT, /* try to detect hash function on mount */
446
447 REISERFS_DATA_LOG,
448 REISERFS_DATA_ORDERED,
449 REISERFS_DATA_WRITEBACK,
450
451/* used for testing experimental features, makes benchmarking new
452 features with and without more convenient, should never be used by
453 users in any code shipped to users (ideally) */
454
455 REISERFS_NO_BORDER,
456 REISERFS_NO_UNHASHED_RELOCATION,
457 REISERFS_HASHED_RELOCATION,
458 REISERFS_ATTRS,
459 REISERFS_XATTRS,
460 REISERFS_XATTRS_USER,
461 REISERFS_POSIXACL,
462 REISERFS_BARRIER_NONE,
463 REISERFS_BARRIER_FLUSH,
464
465 /* Actions on error */
466 REISERFS_ERROR_PANIC,
467 REISERFS_ERROR_RO,
468 REISERFS_ERROR_CONTINUE,
469
470 REISERFS_TEST1,
471 REISERFS_TEST2,
472 REISERFS_TEST3,
473 REISERFS_TEST4,
474 REISERFS_UNSUPPORTED_OPT,
475};
476
477#define reiserfs_r5_hash(s) (REISERFS_SB(s)->s_mount_opt & (1 << FORCE_R5_HASH))
478#define reiserfs_rupasov_hash(s) (REISERFS_SB(s)->s_mount_opt & (1 << FORCE_RUPASOV_HASH))
479#define reiserfs_tea_hash(s) (REISERFS_SB(s)->s_mount_opt & (1 << FORCE_TEA_HASH))
480#define reiserfs_hash_detect(s) (REISERFS_SB(s)->s_mount_opt & (1 << FORCE_HASH_DETECT))
481#define reiserfs_no_border(s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_NO_BORDER))
482#define reiserfs_no_unhashed_relocation(s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_NO_UNHASHED_RELOCATION))
483#define reiserfs_hashed_relocation(s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_HASHED_RELOCATION))
484#define reiserfs_test4(s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TEST4))
485
486#define have_large_tails(s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_LARGETAIL))
487#define have_small_tails(s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_SMALLTAIL))
488#define replay_only(s) (REISERFS_SB(s)->s_mount_opt & (1 << REPLAYONLY))
489#define reiserfs_attrs(s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_ATTRS))
490#define old_format_only(s) (REISERFS_SB(s)->s_properties & (1 << REISERFS_3_5))
491#define convert_reiserfs(s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_CONVERT))
492#define reiserfs_data_log(s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_DATA_LOG))
493#define reiserfs_data_ordered(s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_DATA_ORDERED))
494#define reiserfs_data_writeback(s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_DATA_WRITEBACK))
495#define reiserfs_xattrs(s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_XATTRS))
496#define reiserfs_xattrs_user(s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_XATTRS_USER))
497#define reiserfs_posixacl(s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_POSIXACL))
498#define reiserfs_xattrs_optional(s) (reiserfs_xattrs_user(s) || reiserfs_posixacl(s))
499#define reiserfs_barrier_none(s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_BARRIER_NONE))
500#define reiserfs_barrier_flush(s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_BARRIER_FLUSH))
501
502#define reiserfs_error_panic(s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_ERROR_PANIC))
503#define reiserfs_error_ro(s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_ERROR_RO))
504
505void reiserfs_file_buffer (struct buffer_head * bh, int list);
506extern struct file_system_type reiserfs_fs_type;
507int reiserfs_resize(struct super_block *, unsigned long) ;
508
509#define CARRY_ON 0
510#define SCHEDULE_OCCURRED 1
511
512
513#define SB_BUFFER_WITH_SB(s) (REISERFS_SB(s)->s_sbh)
514#define SB_JOURNAL(s) (REISERFS_SB(s)->s_journal)
515#define SB_JOURNAL_1st_RESERVED_BLOCK(s) (SB_JOURNAL(s)->j_1st_reserved_block)
516#define SB_JOURNAL_LEN_FREE(s) (SB_JOURNAL(s)->j_journal_len_free)
517#define SB_AP_BITMAP(s) (REISERFS_SB(s)->s_ap_bitmap)
518
519#define SB_DISK_JOURNAL_HEAD(s) (SB_JOURNAL(s)->j_header_bh->)
520
521/* A safe version of the "bdevname", which returns the "s_id" field of
522 * a superblock or else "Null superblock" if the super block is NULL.
523 */
524static inline char *reiserfs_bdevname(struct super_block *s)
525{
526 return (s == NULL) ? "Null superblock" : s -> s_id;
527}
528
529#define reiserfs_is_journal_aborted(journal) (unlikely (__reiserfs_is_journal_aborted (journal)))
530static inline int __reiserfs_is_journal_aborted (struct reiserfs_journal *journal)
531{
532 return test_bit (J_ABORTED, &journal->j_state);
533}
534
535#endif /* _LINUX_REISER_FS_SB */
diff --git a/include/linux/reiserfs_xattr.h b/include/linux/reiserfs_xattr.h
new file mode 100644
index 000000000000..1eaa48eca811
--- /dev/null
+++ b/include/linux/reiserfs_xattr.h
@@ -0,0 +1,139 @@
1/*
2 File: linux/reiserfs_xattr.h
3*/
4
5#include <linux/config.h>
6#include <linux/init.h>
7#include <linux/xattr.h>
8
9/* Magic value in header */
10#define REISERFS_XATTR_MAGIC 0x52465841 /* "RFXA" */
11
12struct reiserfs_xattr_header {
13 __u32 h_magic; /* magic number for identification */
14 __u32 h_hash; /* hash of the value */
15};
16
17#ifdef __KERNEL__
18
19struct reiserfs_xattr_handler {
20 char *prefix;
21 int (*init)(void);
22 void (*exit)(void);
23 int (*get)(struct inode *inode, const char *name, void *buffer,
24 size_t size);
25 int (*set)(struct inode *inode, const char *name, const void *buffer,
26 size_t size, int flags);
27 int (*del)(struct inode *inode, const char *name);
28 int (*list)(struct inode *inode, const char *name, int namelen, char *out);
29 struct list_head handlers;
30};
31
32
33#ifdef CONFIG_REISERFS_FS_XATTR
34#define is_reiserfs_priv_object(inode) IS_PRIVATE(inode)
35#define has_xattr_dir(inode) (REISERFS_I(inode)->i_flags & i_has_xattr_dir)
36ssize_t reiserfs_getxattr (struct dentry *dentry, const char *name,
37 void *buffer, size_t size);
38int reiserfs_setxattr (struct dentry *dentry, const char *name,
39 const void *value, size_t size, int flags);
40ssize_t reiserfs_listxattr (struct dentry *dentry, char *buffer, size_t size);
41int reiserfs_removexattr (struct dentry *dentry, const char *name);
42int reiserfs_delete_xattrs (struct inode *inode);
43int reiserfs_chown_xattrs (struct inode *inode, struct iattr *attrs);
44int reiserfs_xattr_init (struct super_block *sb, int mount_flags);
45int reiserfs_permission (struct inode *inode, int mask, struct nameidata *nd);
46int reiserfs_permission_locked (struct inode *inode, int mask, struct nameidata *nd);
47
48int reiserfs_xattr_del (struct inode *, const char *);
49int reiserfs_xattr_get (const struct inode *, const char *, void *, size_t);
50int reiserfs_xattr_set (struct inode *, const char *, const void *,
51 size_t, int);
52
53extern struct reiserfs_xattr_handler user_handler;
54extern struct reiserfs_xattr_handler trusted_handler;
55#ifdef CONFIG_REISERFS_FS_SECURITY
56extern struct reiserfs_xattr_handler security_handler;
57#endif
58
59int reiserfs_xattr_register_handlers (void) __init;
60void reiserfs_xattr_unregister_handlers (void);
61
62static inline void
63reiserfs_write_lock_xattrs(struct super_block *sb)
64{
65 down_write (&REISERFS_XATTR_DIR_SEM(sb));
66}
67static inline void
68reiserfs_write_unlock_xattrs(struct super_block *sb)
69{
70 up_write (&REISERFS_XATTR_DIR_SEM(sb));
71}
72static inline void
73reiserfs_read_lock_xattrs(struct super_block *sb)
74{
75 down_read (&REISERFS_XATTR_DIR_SEM(sb));
76}
77
78static inline void
79reiserfs_read_unlock_xattrs(struct super_block *sb)
80{
81 up_read (&REISERFS_XATTR_DIR_SEM(sb));
82}
83
84static inline void
85reiserfs_write_lock_xattr_i(struct inode *inode)
86{
87 down_write (&REISERFS_I(inode)->xattr_sem);
88}
89static inline void
90reiserfs_write_unlock_xattr_i(struct inode *inode)
91{
92 up_write (&REISERFS_I(inode)->xattr_sem);
93}
94static inline void
95reiserfs_read_lock_xattr_i(struct inode *inode)
96{
97 down_read (&REISERFS_I(inode)->xattr_sem);
98}
99
100static inline void
101reiserfs_read_unlock_xattr_i(struct inode *inode)
102{
103 up_read (&REISERFS_I(inode)->xattr_sem);
104}
105
106static inline void
107reiserfs_mark_inode_private(struct inode *inode)
108{
109 inode->i_flags |= S_PRIVATE;
110}
111
112#else
113
114#define is_reiserfs_priv_object(inode) 0
115#define reiserfs_mark_inode_private(inode)
116#define reiserfs_getxattr NULL
117#define reiserfs_setxattr NULL
118#define reiserfs_listxattr NULL
119#define reiserfs_removexattr NULL
120#define reiserfs_write_lock_xattrs(sb)
121#define reiserfs_write_unlock_xattrs(sb)
122#define reiserfs_read_lock_xattrs(sb)
123#define reiserfs_read_unlock_xattrs(sb)
124
125#define reiserfs_permission NULL
126
127#define reiserfs_xattr_register_handlers() 0
128#define reiserfs_xattr_unregister_handlers()
129
130static inline int reiserfs_delete_xattrs (struct inode *inode) { return 0; };
131static inline int reiserfs_chown_xattrs (struct inode *inode, struct iattr *attrs) { return 0; };
132static inline int reiserfs_xattr_init (struct super_block *sb, int mount_flags)
133{
134 sb->s_flags = (sb->s_flags & ~MS_POSIXACL); /* to be sure */
135 return 0;
136};
137#endif
138
139#endif /* __KERNEL__ */
diff --git a/include/linux/resource.h b/include/linux/resource.h
new file mode 100644
index 000000000000..21a86cb6acdb
--- /dev/null
+++ b/include/linux/resource.h
@@ -0,0 +1,70 @@
1#ifndef _LINUX_RESOURCE_H
2#define _LINUX_RESOURCE_H
3
4#include <linux/time.h>
5
6/*
7 * Resource control/accounting header file for linux
8 */
9
10/*
11 * Definition of struct rusage taken from BSD 4.3 Reno
12 *
13 * We don't support all of these yet, but we might as well have them....
14 * Otherwise, each time we add new items, programs which depend on this
15 * structure will lose. This reduces the chances of that happening.
16 */
17#define RUSAGE_SELF 0
18#define RUSAGE_CHILDREN (-1)
19#define RUSAGE_BOTH (-2) /* sys_wait4() uses this */
20
21struct rusage {
22 struct timeval ru_utime; /* user time used */
23 struct timeval ru_stime; /* system time used */
24 long ru_maxrss; /* maximum resident set size */
25 long ru_ixrss; /* integral shared memory size */
26 long ru_idrss; /* integral unshared data size */
27 long ru_isrss; /* integral unshared stack size */
28 long ru_minflt; /* page reclaims */
29 long ru_majflt; /* page faults */
30 long ru_nswap; /* swaps */
31 long ru_inblock; /* block input operations */
32 long ru_oublock; /* block output operations */
33 long ru_msgsnd; /* messages sent */
34 long ru_msgrcv; /* messages received */
35 long ru_nsignals; /* signals received */
36 long ru_nvcsw; /* voluntary context switches */
37 long ru_nivcsw; /* involuntary " */
38};
39
40struct rlimit {
41 unsigned long rlim_cur;
42 unsigned long rlim_max;
43};
44
45#define PRIO_MIN (-20)
46#define PRIO_MAX 20
47
48#define PRIO_PROCESS 0
49#define PRIO_PGRP 1
50#define PRIO_USER 2
51
52/*
53 * Limit the stack by to some sane default: root can always
54 * increase this limit if needed.. 8MB seems reasonable.
55 */
56#define _STK_LIM (8*1024*1024)
57
58/*
59 * GPG wants 32kB of mlocked memory, to make sure pass phrases
60 * and other sensitive information are never written to disk.
61 */
62#define MLOCK_LIMIT (8 * PAGE_SIZE)
63
64/*
65 * Due to binary compatibility, the actual resource numbers
66 * may be different for different linux versions..
67 */
68#include <asm/resource.h>
69
70#endif
diff --git a/include/linux/rmap.h b/include/linux/rmap.h
new file mode 100644
index 000000000000..11b484e37ac9
--- /dev/null
+++ b/include/linux/rmap.h
@@ -0,0 +1,118 @@
1#ifndef _LINUX_RMAP_H
2#define _LINUX_RMAP_H
3/*
4 * Declarations for Reverse Mapping functions in mm/rmap.c
5 */
6
7#include <linux/config.h>
8#include <linux/list.h>
9#include <linux/slab.h>
10#include <linux/mm.h>
11#include <linux/spinlock.h>
12
13/*
14 * The anon_vma heads a list of private "related" vmas, to scan if
15 * an anonymous page pointing to this anon_vma needs to be unmapped:
16 * the vmas on the list will be related by forking, or by splitting.
17 *
18 * Since vmas come and go as they are split and merged (particularly
19 * in mprotect), the mapping field of an anonymous page cannot point
20 * directly to a vma: instead it points to an anon_vma, on whose list
21 * the related vmas can be easily linked or unlinked.
22 *
23 * After unlinking the last vma on the list, we must garbage collect
24 * the anon_vma object itself: we're guaranteed no page can be
25 * pointing to this anon_vma once its vma list is empty.
26 */
27struct anon_vma {
28 spinlock_t lock; /* Serialize access to vma list */
29 struct list_head head; /* List of private "related" vmas */
30};
31
32#ifdef CONFIG_MMU
33
34extern kmem_cache_t *anon_vma_cachep;
35
36static inline struct anon_vma *anon_vma_alloc(void)
37{
38 return kmem_cache_alloc(anon_vma_cachep, SLAB_KERNEL);
39}
40
41static inline void anon_vma_free(struct anon_vma *anon_vma)
42{
43 kmem_cache_free(anon_vma_cachep, anon_vma);
44}
45
46static inline void anon_vma_lock(struct vm_area_struct *vma)
47{
48 struct anon_vma *anon_vma = vma->anon_vma;
49 if (anon_vma)
50 spin_lock(&anon_vma->lock);
51}
52
53static inline void anon_vma_unlock(struct vm_area_struct *vma)
54{
55 struct anon_vma *anon_vma = vma->anon_vma;
56 if (anon_vma)
57 spin_unlock(&anon_vma->lock);
58}
59
60/*
61 * anon_vma helper functions.
62 */
63void anon_vma_init(void); /* create anon_vma_cachep */
64int anon_vma_prepare(struct vm_area_struct *);
65void __anon_vma_merge(struct vm_area_struct *, struct vm_area_struct *);
66void anon_vma_unlink(struct vm_area_struct *);
67void anon_vma_link(struct vm_area_struct *);
68void __anon_vma_link(struct vm_area_struct *);
69
70/*
71 * rmap interfaces called when adding or removing pte of page
72 */
73void page_add_anon_rmap(struct page *, struct vm_area_struct *, unsigned long);
74void page_add_file_rmap(struct page *);
75void page_remove_rmap(struct page *);
76
77/**
78 * page_dup_rmap - duplicate pte mapping to a page
79 * @page: the page to add the mapping to
80 *
81 * For copy_page_range only: minimal extract from page_add_rmap,
82 * avoiding unnecessary tests (already checked) so it's quicker.
83 */
84static inline void page_dup_rmap(struct page *page)
85{
86 atomic_inc(&page->_mapcount);
87}
88
89/*
90 * Called from mm/vmscan.c to handle paging out
91 */
92int page_referenced(struct page *, int is_locked, int ignore_token);
93int try_to_unmap(struct page *);
94
95/*
96 * Used by swapoff to help locate where page is expected in vma.
97 */
98unsigned long page_address_in_vma(struct page *, struct vm_area_struct *);
99
100#else /* !CONFIG_MMU */
101
102#define anon_vma_init() do {} while (0)
103#define anon_vma_prepare(vma) (0)
104#define anon_vma_link(vma) do {} while (0)
105
106#define page_referenced(page,l,i) TestClearPageReferenced(page)
107#define try_to_unmap(page) SWAP_FAIL
108
109#endif /* CONFIG_MMU */
110
111/*
112 * Return values of try_to_unmap
113 */
114#define SWAP_SUCCESS 0
115#define SWAP_AGAIN 1
116#define SWAP_FAIL 2
117
118#endif /* _LINUX_RMAP_H */
diff --git a/include/linux/romfs_fs.h b/include/linux/romfs_fs.h
new file mode 100644
index 000000000000..e20bbf9eb365
--- /dev/null
+++ b/include/linux/romfs_fs.h
@@ -0,0 +1,61 @@
1#ifndef __LINUX_ROMFS_FS_H
2#define __LINUX_ROMFS_FS_H
3
4/* The basic structures of the romfs filesystem */
5
6#define ROMBSIZE BLOCK_SIZE
7#define ROMBSBITS BLOCK_SIZE_BITS
8#define ROMBMASK (ROMBSIZE-1)
9#define ROMFS_MAGIC 0x7275
10
11#define ROMFS_MAXFN 128
12
13#define __mkw(h,l) (((h)&0x00ff)<< 8|((l)&0x00ff))
14#define __mkl(h,l) (((h)&0xffff)<<16|((l)&0xffff))
15#define __mk4(a,b,c,d) cpu_to_be32(__mkl(__mkw(a,b),__mkw(c,d)))
16#define ROMSB_WORD0 __mk4('-','r','o','m')
17#define ROMSB_WORD1 __mk4('1','f','s','-')
18
19/* On-disk "super block" */
20
21struct romfs_super_block {
22 __be32 word0;
23 __be32 word1;
24 __be32 size;
25 __be32 checksum;
26 char name[0]; /* volume name */
27};
28
29/* On disk inode */
30
31struct romfs_inode {
32 __be32 next; /* low 4 bits see ROMFH_ */
33 __be32 spec;
34 __be32 size;
35 __be32 checksum;
36 char name[0];
37};
38
39#define ROMFH_TYPE 7
40#define ROMFH_HRD 0
41#define ROMFH_DIR 1
42#define ROMFH_REG 2
43#define ROMFH_SYM 3
44#define ROMFH_BLK 4
45#define ROMFH_CHR 5
46#define ROMFH_SCK 6
47#define ROMFH_FIF 7
48#define ROMFH_EXEC 8
49
50/* Alignment */
51
52#define ROMFH_SIZE 16
53#define ROMFH_PAD (ROMFH_SIZE-1)
54#define ROMFH_MASK (~ROMFH_PAD)
55
56#ifdef __KERNEL__
57
58/* Not much now */
59
60#endif /* __KERNEL__ */
61#endif
diff --git a/include/linux/root_dev.h b/include/linux/root_dev.h
new file mode 100644
index 000000000000..ea4bc9d13735
--- /dev/null
+++ b/include/linux/root_dev.h
@@ -0,0 +1,21 @@
1#ifndef _ROOT_DEV_H_
2#define _ROOT_DEV_H_
3
4#include <linux/major.h>
5
6enum {
7 Root_NFS = MKDEV(UNNAMED_MAJOR, 255),
8 Root_RAM0 = MKDEV(RAMDISK_MAJOR, 0),
9 Root_RAM1 = MKDEV(RAMDISK_MAJOR, 1),
10 Root_FD0 = MKDEV(FLOPPY_MAJOR, 0),
11 Root_HDA1 = MKDEV(IDE0_MAJOR, 1),
12 Root_HDA2 = MKDEV(IDE0_MAJOR, 2),
13 Root_SDA1 = MKDEV(SCSI_DISK0_MAJOR, 1),
14 Root_SDA2 = MKDEV(SCSI_DISK0_MAJOR, 2),
15 Root_HDC1 = MKDEV(IDE1_MAJOR, 1),
16 Root_SR0 = MKDEV(SCSI_CDROM_MAJOR, 0),
17};
18
19extern dev_t ROOT_DEV;
20
21#endif
diff --git a/include/linux/rose.h b/include/linux/rose.h
new file mode 100644
index 000000000000..c7b4b184c82e
--- /dev/null
+++ b/include/linux/rose.h
@@ -0,0 +1,87 @@
1/*
2 * These are the public elements of the Linux kernel Rose implementation.
3 * For kernel AX.25 see the file ax25.h. This file requires ax25.h for the
4 * definition of the ax25_address structure.
5 */
6
7#ifndef ROSE_KERNEL_H
8#define ROSE_KERNEL_H
9
10#define ROSE_MTU 251
11
12#define ROSE_MAX_DIGIS 6
13
14#define ROSE_DEFER 1
15#define ROSE_T1 2
16#define ROSE_T2 3
17#define ROSE_T3 4
18#define ROSE_IDLE 5
19#define ROSE_QBITINCL 6
20#define ROSE_HOLDBACK 7
21
22#define SIOCRSGCAUSE (SIOCPROTOPRIVATE+0)
23#define SIOCRSSCAUSE (SIOCPROTOPRIVATE+1)
24#define SIOCRSL2CALL (SIOCPROTOPRIVATE+2)
25#define SIOCRSSL2CALL (SIOCPROTOPRIVATE+2)
26#define SIOCRSACCEPT (SIOCPROTOPRIVATE+3)
27#define SIOCRSCLRRT (SIOCPROTOPRIVATE+4)
28#define SIOCRSGL2CALL (SIOCPROTOPRIVATE+5)
29#define SIOCRSGFACILITIES (SIOCPROTOPRIVATE+6)
30
31#define ROSE_DTE_ORIGINATED 0x00
32#define ROSE_NUMBER_BUSY 0x01
33#define ROSE_INVALID_FACILITY 0x03
34#define ROSE_NETWORK_CONGESTION 0x05
35#define ROSE_OUT_OF_ORDER 0x09
36#define ROSE_ACCESS_BARRED 0x0B
37#define ROSE_NOT_OBTAINABLE 0x0D
38#define ROSE_REMOTE_PROCEDURE 0x11
39#define ROSE_LOCAL_PROCEDURE 0x13
40#define ROSE_SHIP_ABSENT 0x39
41
42typedef struct {
43 char rose_addr[5];
44} rose_address;
45
46struct sockaddr_rose {
47 sa_family_t srose_family;
48 rose_address srose_addr;
49 ax25_address srose_call;
50 int srose_ndigis;
51 ax25_address srose_digi;
52};
53
54struct full_sockaddr_rose {
55 sa_family_t srose_family;
56 rose_address srose_addr;
57 ax25_address srose_call;
58 unsigned int srose_ndigis;
59 ax25_address srose_digis[ROSE_MAX_DIGIS];
60};
61
62struct rose_route_struct {
63 rose_address address;
64 unsigned short mask;
65 ax25_address neighbour;
66 char device[16];
67 unsigned char ndigis;
68 ax25_address digipeaters[AX25_MAX_DIGIS];
69};
70
71struct rose_cause_struct {
72 unsigned char cause;
73 unsigned char diagnostic;
74};
75
76struct rose_facilities_struct {
77 rose_address source_addr, dest_addr;
78 ax25_address source_call, dest_call;
79 unsigned char source_ndigis, dest_ndigis;
80 ax25_address source_digis[ROSE_MAX_DIGIS];
81 ax25_address dest_digis[ROSE_MAX_DIGIS];
82 unsigned int rand;
83 rose_address fail_addr;
84 ax25_address fail_call;
85};
86
87#endif
diff --git a/include/linux/route.h b/include/linux/route.h
new file mode 100644
index 000000000000..f7ed35d5e653
--- /dev/null
+++ b/include/linux/route.h
@@ -0,0 +1,70 @@
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Global definitions for the IP router interface.
7 *
8 * Version: @(#)route.h 1.0.3 05/27/93
9 *
10 * Authors: Original taken from Berkeley UNIX 4.3, (c) UCB 1986-1988
11 * for the purposes of compatibility only.
12 *
13 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
14 *
15 * Changes:
16 * Mike McLagan : Routing by source
17 *
18 * This program is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU General Public License
20 * as published by the Free Software Foundation; either version
21 * 2 of the License, or (at your option) any later version.
22 */
23#ifndef _LINUX_ROUTE_H
24#define _LINUX_ROUTE_H
25
26#include <linux/if.h>
27#include <linux/compiler.h>
28
29/* This structure gets passed by the SIOCADDRT and SIOCDELRT calls. */
30struct rtentry
31{
32 unsigned long rt_pad1;
33 struct sockaddr rt_dst; /* target address */
34 struct sockaddr rt_gateway; /* gateway addr (RTF_GATEWAY) */
35 struct sockaddr rt_genmask; /* target network mask (IP) */
36 unsigned short rt_flags;
37 short rt_pad2;
38 unsigned long rt_pad3;
39 void *rt_pad4;
40 short rt_metric; /* +1 for binary compatibility! */
41 char __user *rt_dev; /* forcing the device at add */
42 unsigned long rt_mtu; /* per route MTU/Window */
43#ifndef __KERNEL__
44#define rt_mss rt_mtu /* Compatibility :-( */
45#endif
46 unsigned long rt_window; /* Window clamping */
47 unsigned short rt_irtt; /* Initial RTT */
48};
49
50
51#define RTF_UP 0x0001 /* route usable */
52#define RTF_GATEWAY 0x0002 /* destination is a gateway */
53#define RTF_HOST 0x0004 /* host entry (net otherwise) */
54#define RTF_REINSTATE 0x0008 /* reinstate route after tmout */
55#define RTF_DYNAMIC 0x0010 /* created dyn. (by redirect) */
56#define RTF_MODIFIED 0x0020 /* modified dyn. (by redirect) */
57#define RTF_MTU 0x0040 /* specific MTU for this route */
58#define RTF_MSS RTF_MTU /* Compatibility :-( */
59#define RTF_WINDOW 0x0080 /* per route window clamping */
60#define RTF_IRTT 0x0100 /* Initial round trip time */
61#define RTF_REJECT 0x0200 /* Reject route */
62
63/*
64 * <linux/ipv6_route.h> uses RTF values >= 64k
65 */
66
67
68
69#endif /* _LINUX_ROUTE_H */
70
diff --git a/include/linux/rslib.h b/include/linux/rslib.h
new file mode 100644
index 000000000000..980c8f74d8dc
--- /dev/null
+++ b/include/linux/rslib.h
@@ -0,0 +1,105 @@
1/*
2 * include/linux/rslib.h
3 *
4 * Overview:
5 * Generic Reed Solomon encoder / decoder library
6 *
7 * Copyright (C) 2004 Thomas Gleixner (tglx@linutronix.de)
8 *
9 * RS code lifted from reed solomon library written by Phil Karn
10 * Copyright 2002 Phil Karn, KA9Q
11 *
12 * $Id: rslib.h,v 1.3 2004/10/05 22:08:22 gleixner Exp $
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 version 2 as
16 * published by the Free Software Foundation.
17 */
18
19#ifndef _RSLIB_H_
20#define _RSLIB_H_
21
22#include <linux/list.h>
23
24/**
25 * struct rs_control - rs control structure
26 *
27 * @mm: Bits per symbol
28 * @nn: Symbols per block (= (1<<mm)-1)
29 * @alpha_to: log lookup table
30 * @index_of: Antilog lookup table
31 * @genpoly: Generator polynomial
32 * @nroots: Number of generator roots = number of parity symbols
33 * @fcr: First consecutive root, index form
34 * @prim: Primitive element, index form
35 * @iprim: prim-th root of 1, index form
36 * @gfpoly: The primitive generator polynominal
37 * @users: Users of this structure
38 * @list: List entry for the rs control list
39*/
40struct rs_control {
41 int mm;
42 int nn;
43 uint16_t *alpha_to;
44 uint16_t *index_of;
45 uint16_t *genpoly;
46 int nroots;
47 int fcr;
48 int prim;
49 int iprim;
50 int gfpoly;
51 int users;
52 struct list_head list;
53};
54
55/* General purpose RS codec, 8-bit data width, symbol width 1-15 bit */
56#ifdef CONFIG_REED_SOLOMON_ENC8
57int encode_rs8(struct rs_control *rs, uint8_t *data, int len, uint16_t *par,
58 uint16_t invmsk);
59#endif
60#ifdef CONFIG_REED_SOLOMON_DEC8
61int decode_rs8(struct rs_control *rs, uint8_t *data, uint16_t *par, int len,
62 uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk,
63 uint16_t *corr);
64#endif
65
66/* General purpose RS codec, 16-bit data width, symbol width 1-15 bit */
67#ifdef CONFIG_REED_SOLOMON_ENC16
68int encode_rs16(struct rs_control *rs, uint16_t *data, int len, uint16_t *par,
69 uint16_t invmsk);
70#endif
71#ifdef CONFIG_REED_SOLOMON_DEC16
72int decode_rs16(struct rs_control *rs, uint16_t *data, uint16_t *par, int len,
73 uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk,
74 uint16_t *corr);
75#endif
76
77/* Create or get a matching rs control structure */
78struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim,
79 int nroots);
80
81/* Release a rs control structure */
82void free_rs(struct rs_control *rs);
83
84/** modulo replacement for galois field arithmetics
85 *
86 * @rs: the rs control structure
87 * @x: the value to reduce
88 *
89 * where
90 * rs->mm = number of bits per symbol
91 * rs->nn = (2^rs->mm) - 1
92 *
93 * Simple arithmetic modulo would return a wrong result for values
94 * >= 3 * rs->nn
95*/
96static inline int rs_modnn(struct rs_control *rs, int x)
97{
98 while (x >= rs->nn) {
99 x -= rs->nn;
100 x = (x >> rs->mm) + (x & rs->nn);
101 }
102 return x;
103}
104
105#endif
diff --git a/include/linux/rtc.h b/include/linux/rtc.h
new file mode 100644
index 000000000000..e1aaf1fac8e0
--- /dev/null
+++ b/include/linux/rtc.h
@@ -0,0 +1,108 @@
1/*
2 * Generic RTC interface.
3 * This version contains the part of the user interface to the Real Time Clock
4 * service. It is used with both the legacy mc146818 and also EFI
5 * Struct rtc_time and first 12 ioctl by Paul Gortmaker, 1996 - separated out
6 * from <linux/mc146818rtc.h> to this file for 2.4 kernels.
7 *
8 * Copyright (C) 1999 Hewlett-Packard Co.
9 * Copyright (C) 1999 Stephane Eranian <eranian@hpl.hp.com>
10 */
11#ifndef _LINUX_RTC_H_
12#define _LINUX_RTC_H_
13
14/*
15 * The struct used to pass data via the following ioctl. Similar to the
16 * struct tm in <time.h>, but it needs to be here so that the kernel
17 * source is self contained, allowing cross-compiles, etc. etc.
18 */
19
20struct rtc_time {
21 int tm_sec;
22 int tm_min;
23 int tm_hour;
24 int tm_mday;
25 int tm_mon;
26 int tm_year;
27 int tm_wday;
28 int tm_yday;
29 int tm_isdst;
30};
31
32/*
33 * This data structure is inspired by the EFI (v0.92) wakeup
34 * alarm API.
35 */
36struct rtc_wkalrm {
37 unsigned char enabled; /* 0 = alarm disable, 1 = alarm disabled */
38 unsigned char pending; /* 0 = alarm pending, 1 = alarm not pending */
39 struct rtc_time time; /* time the alarm is set to */
40};
41
42/*
43 * Data structure to control PLL correction some better RTC feature
44 * pll_value is used to get or set current value of correction,
45 * the rest of the struct is used to query HW capabilities.
46 * This is modeled after the RTC used in Q40/Q60 computers but
47 * should be sufficiently flexible for other devices
48 *
49 * +ve pll_value means clock will run faster by
50 * pll_value*pll_posmult/pll_clock
51 * -ve pll_value means clock will run slower by
52 * pll_value*pll_negmult/pll_clock
53 */
54
55struct rtc_pll_info {
56 int pll_ctrl; /* placeholder for fancier control */
57 int pll_value; /* get/set correction value */
58 int pll_max; /* max +ve (faster) adjustment value */
59 int pll_min; /* max -ve (slower) adjustment value */
60 int pll_posmult; /* factor for +ve correction */
61 int pll_negmult; /* factor for -ve correction */
62 long pll_clock; /* base PLL frequency */
63};
64
65/*
66 * ioctl calls that are permitted to the /dev/rtc interface, if
67 * any of the RTC drivers are enabled.
68 */
69
70#define RTC_AIE_ON _IO('p', 0x01) /* Alarm int. enable on */
71#define RTC_AIE_OFF _IO('p', 0x02) /* ... off */
72#define RTC_UIE_ON _IO('p', 0x03) /* Update int. enable on */
73#define RTC_UIE_OFF _IO('p', 0x04) /* ... off */
74#define RTC_PIE_ON _IO('p', 0x05) /* Periodic int. enable on */
75#define RTC_PIE_OFF _IO('p', 0x06) /* ... off */
76#define RTC_WIE_ON _IO('p', 0x0f) /* Watchdog int. enable on */
77#define RTC_WIE_OFF _IO('p', 0x10) /* ... off */
78
79#define RTC_ALM_SET _IOW('p', 0x07, struct rtc_time) /* Set alarm time */
80#define RTC_ALM_READ _IOR('p', 0x08, struct rtc_time) /* Read alarm time */
81#define RTC_RD_TIME _IOR('p', 0x09, struct rtc_time) /* Read RTC time */
82#define RTC_SET_TIME _IOW('p', 0x0a, struct rtc_time) /* Set RTC time */
83#define RTC_IRQP_READ _IOR('p', 0x0b, unsigned long) /* Read IRQ rate */
84#define RTC_IRQP_SET _IOW('p', 0x0c, unsigned long) /* Set IRQ rate */
85#define RTC_EPOCH_READ _IOR('p', 0x0d, unsigned long) /* Read epoch */
86#define RTC_EPOCH_SET _IOW('p', 0x0e, unsigned long) /* Set epoch */
87
88#define RTC_WKALM_SET _IOW('p', 0x0f, struct rtc_wkalrm)/* Set wakeup alarm*/
89#define RTC_WKALM_RD _IOR('p', 0x10, struct rtc_wkalrm)/* Get wakeup alarm*/
90
91#define RTC_PLL_GET _IOR('p', 0x11, struct rtc_pll_info) /* Get PLL correction */
92#define RTC_PLL_SET _IOW('p', 0x12, struct rtc_pll_info) /* Set PLL correction */
93
94#ifdef __KERNEL__
95
96typedef struct rtc_task {
97 void (*func)(void *private_data);
98 void *private_data;
99} rtc_task_t;
100
101int rtc_register(rtc_task_t *task);
102int rtc_unregister(rtc_task_t *task);
103int rtc_control(rtc_task_t *t, unsigned int cmd, unsigned long arg);
104void rtc_get_rtc_time(struct rtc_time *rtc_tm);
105
106#endif /* __KERNEL__ */
107
108#endif /* _LINUX_RTC_H_ */
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
new file mode 100644
index 000000000000..32e52769a00b
--- /dev/null
+++ b/include/linux/rtnetlink.h
@@ -0,0 +1,842 @@
1#ifndef __LINUX_RTNETLINK_H
2#define __LINUX_RTNETLINK_H
3
4#include <linux/netlink.h>
5
6/****
7 * Routing/neighbour discovery messages.
8 ****/
9
10/* Types of messages */
11
12enum {
13 RTM_BASE = 16,
14#define RTM_BASE RTM_BASE
15
16 RTM_NEWLINK = 16,
17#define RTM_NEWLINK RTM_NEWLINK
18 RTM_DELLINK,
19#define RTM_DELLINK RTM_DELLINK
20 RTM_GETLINK,
21#define RTM_GETLINK RTM_GETLINK
22 RTM_SETLINK,
23#define RTM_SETLINK RTM_SETLINK
24
25 RTM_NEWADDR = 20,
26#define RTM_NEWADDR RTM_NEWADDR
27 RTM_DELADDR,
28#define RTM_DELADDR RTM_DELADDR
29 RTM_GETADDR,
30#define RTM_GETADDR RTM_GETADDR
31
32 RTM_NEWROUTE = 24,
33#define RTM_NEWROUTE RTM_NEWROUTE
34 RTM_DELROUTE,
35#define RTM_DELROUTE RTM_DELROUTE
36 RTM_GETROUTE,
37#define RTM_GETROUTE RTM_GETROUTE
38
39 RTM_NEWNEIGH = 28,
40#define RTM_NEWNEIGH RTM_NEWNEIGH
41 RTM_DELNEIGH,
42#define RTM_DELNEIGH RTM_DELNEIGH
43 RTM_GETNEIGH,
44#define RTM_GETNEIGH RTM_GETNEIGH
45
46 RTM_NEWRULE = 32,
47#define RTM_NEWRULE RTM_NEWRULE
48 RTM_DELRULE,
49#define RTM_DELRULE RTM_DELRULE
50 RTM_GETRULE,
51#define RTM_GETRULE RTM_GETRULE
52
53 RTM_NEWQDISC = 36,
54#define RTM_NEWQDISC RTM_NEWQDISC
55 RTM_DELQDISC,
56#define RTM_DELQDISC RTM_DELQDISC
57 RTM_GETQDISC,
58#define RTM_GETQDISC RTM_GETQDISC
59
60 RTM_NEWTCLASS = 40,
61#define RTM_NEWTCLASS RTM_NEWTCLASS
62 RTM_DELTCLASS,
63#define RTM_DELTCLASS RTM_DELTCLASS
64 RTM_GETTCLASS,
65#define RTM_GETTCLASS RTM_GETTCLASS
66
67 RTM_NEWTFILTER = 44,
68#define RTM_NEWTFILTER RTM_NEWTFILTER
69 RTM_DELTFILTER,
70#define RTM_DELTFILTER RTM_DELTFILTER
71 RTM_GETTFILTER,
72#define RTM_GETTFILTER RTM_GETTFILTER
73
74 RTM_NEWACTION = 48,
75#define RTM_NEWACTION RTM_NEWACTION
76 RTM_DELACTION,
77#define RTM_DELACTION RTM_DELACTION
78 RTM_GETACTION,
79#define RTM_GETACTION RTM_GETACTION
80
81 RTM_NEWPREFIX = 52,
82#define RTM_NEWPREFIX RTM_NEWPREFIX
83 RTM_GETPREFIX = 54,
84#define RTM_GETPREFIX RTM_GETPREFIX
85
86 RTM_GETMULTICAST = 58,
87#define RTM_GETMULTICAST RTM_GETMULTICAST
88
89 RTM_GETANYCAST = 62,
90#define RTM_GETANYCAST RTM_GETANYCAST
91
92 RTM_MAX,
93#define RTM_MAX RTM_MAX
94};
95
96/*
97 Generic structure for encapsulation of optional route information.
98 It is reminiscent of sockaddr, but with sa_family replaced
99 with attribute type.
100 */
101
102struct rtattr
103{
104 unsigned short rta_len;
105 unsigned short rta_type;
106};
107
108/* Macros to handle rtattributes */
109
110#define RTA_ALIGNTO 4
111#define RTA_ALIGN(len) ( ((len)+RTA_ALIGNTO-1) & ~(RTA_ALIGNTO-1) )
112#define RTA_OK(rta,len) ((len) >= (int)sizeof(struct rtattr) && \
113 (rta)->rta_len >= sizeof(struct rtattr) && \
114 (rta)->rta_len <= (len))
115#define RTA_NEXT(rta,attrlen) ((attrlen) -= RTA_ALIGN((rta)->rta_len), \
116 (struct rtattr*)(((char*)(rta)) + RTA_ALIGN((rta)->rta_len)))
117#define RTA_LENGTH(len) (RTA_ALIGN(sizeof(struct rtattr)) + (len))
118#define RTA_SPACE(len) RTA_ALIGN(RTA_LENGTH(len))
119#define RTA_DATA(rta) ((void*)(((char*)(rta)) + RTA_LENGTH(0)))
120#define RTA_PAYLOAD(rta) ((int)((rta)->rta_len) - RTA_LENGTH(0))
121
122
123
124
125/******************************************************************************
126 * Definitions used in routing table administration.
127 ****/
128
129struct rtmsg
130{
131 unsigned char rtm_family;
132 unsigned char rtm_dst_len;
133 unsigned char rtm_src_len;
134 unsigned char rtm_tos;
135
136 unsigned char rtm_table; /* Routing table id */
137 unsigned char rtm_protocol; /* Routing protocol; see below */
138 unsigned char rtm_scope; /* See below */
139 unsigned char rtm_type; /* See below */
140
141 unsigned rtm_flags;
142};
143
144/* rtm_type */
145
146enum
147{
148 RTN_UNSPEC,
149 RTN_UNICAST, /* Gateway or direct route */
150 RTN_LOCAL, /* Accept locally */
151 RTN_BROADCAST, /* Accept locally as broadcast,
152 send as broadcast */
153 RTN_ANYCAST, /* Accept locally as broadcast,
154 but send as unicast */
155 RTN_MULTICAST, /* Multicast route */
156 RTN_BLACKHOLE, /* Drop */
157 RTN_UNREACHABLE, /* Destination is unreachable */
158 RTN_PROHIBIT, /* Administratively prohibited */
159 RTN_THROW, /* Not in this table */
160 RTN_NAT, /* Translate this address */
161 RTN_XRESOLVE, /* Use external resolver */
162 __RTN_MAX
163};
164
165#define RTN_MAX (__RTN_MAX - 1)
166
167
168/* rtm_protocol */
169
170#define RTPROT_UNSPEC 0
171#define RTPROT_REDIRECT 1 /* Route installed by ICMP redirects;
172 not used by current IPv4 */
173#define RTPROT_KERNEL 2 /* Route installed by kernel */
174#define RTPROT_BOOT 3 /* Route installed during boot */
175#define RTPROT_STATIC 4 /* Route installed by administrator */
176
177/* Values of protocol >= RTPROT_STATIC are not interpreted by kernel;
178 they are just passed from user and back as is.
179 It will be used by hypothetical multiple routing daemons.
180 Note that protocol values should be standardized in order to
181 avoid conflicts.
182 */
183
184#define RTPROT_GATED 8 /* Apparently, GateD */
185#define RTPROT_RA 9 /* RDISC/ND router advertisements */
186#define RTPROT_MRT 10 /* Merit MRT */
187#define RTPROT_ZEBRA 11 /* Zebra */
188#define RTPROT_BIRD 12 /* BIRD */
189#define RTPROT_DNROUTED 13 /* DECnet routing daemon */
190#define RTPROT_XORP 14 /* XORP */
191
192/* rtm_scope
193
194 Really it is not scope, but sort of distance to the destination.
195 NOWHERE are reserved for not existing destinations, HOST is our
196 local addresses, LINK are destinations, located on directly attached
197 link and UNIVERSE is everywhere in the Universe.
198
199 Intermediate values are also possible f.e. interior routes
200 could be assigned a value between UNIVERSE and LINK.
201*/
202
203enum rt_scope_t
204{
205 RT_SCOPE_UNIVERSE=0,
206/* User defined values */
207 RT_SCOPE_SITE=200,
208 RT_SCOPE_LINK=253,
209 RT_SCOPE_HOST=254,
210 RT_SCOPE_NOWHERE=255
211};
212
213/* rtm_flags */
214
215#define RTM_F_NOTIFY 0x100 /* Notify user of route change */
216#define RTM_F_CLONED 0x200 /* This route is cloned */
217#define RTM_F_EQUALIZE 0x400 /* Multipath equalizer: NI */
218#define RTM_F_PREFIX 0x800 /* Prefix addresses */
219
220/* Reserved table identifiers */
221
222enum rt_class_t
223{
224 RT_TABLE_UNSPEC=0,
225/* User defined values */
226 RT_TABLE_DEFAULT=253,
227 RT_TABLE_MAIN=254,
228 RT_TABLE_LOCAL=255,
229 __RT_TABLE_MAX
230};
231#define RT_TABLE_MAX (__RT_TABLE_MAX - 1)
232
233
234
235/* Routing message attributes */
236
237enum rtattr_type_t
238{
239 RTA_UNSPEC,
240 RTA_DST,
241 RTA_SRC,
242 RTA_IIF,
243 RTA_OIF,
244 RTA_GATEWAY,
245 RTA_PRIORITY,
246 RTA_PREFSRC,
247 RTA_METRICS,
248 RTA_MULTIPATH,
249 RTA_PROTOINFO,
250 RTA_FLOW,
251 RTA_CACHEINFO,
252 RTA_SESSION,
253 RTA_MP_ALGO,
254 __RTA_MAX
255};
256
257#define RTA_MAX (__RTA_MAX - 1)
258
259#define RTM_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtmsg))))
260#define RTM_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct rtmsg))
261
262/* RTM_MULTIPATH --- array of struct rtnexthop.
263 *
264 * "struct rtnexthop" describes all necessary nexthop information,
265 * i.e. parameters of path to a destination via this nexthop.
266 *
267 * At the moment it is impossible to set different prefsrc, mtu, window
268 * and rtt for different paths from multipath.
269 */
270
271struct rtnexthop
272{
273 unsigned short rtnh_len;
274 unsigned char rtnh_flags;
275 unsigned char rtnh_hops;
276 int rtnh_ifindex;
277};
278
279/* rtnh_flags */
280
281#define RTNH_F_DEAD 1 /* Nexthop is dead (used by multipath) */
282#define RTNH_F_PERVASIVE 2 /* Do recursive gateway lookup */
283#define RTNH_F_ONLINK 4 /* Gateway is forced on link */
284
285/* Macros to handle hexthops */
286
287#define RTNH_ALIGNTO 4
288#define RTNH_ALIGN(len) ( ((len)+RTNH_ALIGNTO-1) & ~(RTNH_ALIGNTO-1) )
289#define RTNH_OK(rtnh,len) ((rtnh)->rtnh_len >= sizeof(struct rtnexthop) && \
290 ((int)(rtnh)->rtnh_len) <= (len))
291#define RTNH_NEXT(rtnh) ((struct rtnexthop*)(((char*)(rtnh)) + RTNH_ALIGN((rtnh)->rtnh_len)))
292#define RTNH_LENGTH(len) (RTNH_ALIGN(sizeof(struct rtnexthop)) + (len))
293#define RTNH_SPACE(len) RTNH_ALIGN(RTNH_LENGTH(len))
294#define RTNH_DATA(rtnh) ((struct rtattr*)(((char*)(rtnh)) + RTNH_LENGTH(0)))
295
296/* RTM_CACHEINFO */
297
298struct rta_cacheinfo
299{
300 __u32 rta_clntref;
301 __u32 rta_lastuse;
302 __s32 rta_expires;
303 __u32 rta_error;
304 __u32 rta_used;
305
306#define RTNETLINK_HAVE_PEERINFO 1
307 __u32 rta_id;
308 __u32 rta_ts;
309 __u32 rta_tsage;
310};
311
312/* RTM_METRICS --- array of struct rtattr with types of RTAX_* */
313
314enum
315{
316 RTAX_UNSPEC,
317#define RTAX_UNSPEC RTAX_UNSPEC
318 RTAX_LOCK,
319#define RTAX_LOCK RTAX_LOCK
320 RTAX_MTU,
321#define RTAX_MTU RTAX_MTU
322 RTAX_WINDOW,
323#define RTAX_WINDOW RTAX_WINDOW
324 RTAX_RTT,
325#define RTAX_RTT RTAX_RTT
326 RTAX_RTTVAR,
327#define RTAX_RTTVAR RTAX_RTTVAR
328 RTAX_SSTHRESH,
329#define RTAX_SSTHRESH RTAX_SSTHRESH
330 RTAX_CWND,
331#define RTAX_CWND RTAX_CWND
332 RTAX_ADVMSS,
333#define RTAX_ADVMSS RTAX_ADVMSS
334 RTAX_REORDERING,
335#define RTAX_REORDERING RTAX_REORDERING
336 RTAX_HOPLIMIT,
337#define RTAX_HOPLIMIT RTAX_HOPLIMIT
338 RTAX_INITCWND,
339#define RTAX_INITCWND RTAX_INITCWND
340 RTAX_FEATURES,
341#define RTAX_FEATURES RTAX_FEATURES
342 __RTAX_MAX
343};
344
345#define RTAX_MAX (__RTAX_MAX - 1)
346
347#define RTAX_FEATURE_ECN 0x00000001
348#define RTAX_FEATURE_SACK 0x00000002
349#define RTAX_FEATURE_TIMESTAMP 0x00000004
350#define RTAX_FEATURE_ALLFRAG 0x00000008
351
352struct rta_session
353{
354 __u8 proto;
355
356 union {
357 struct {
358 __u16 sport;
359 __u16 dport;
360 } ports;
361
362 struct {
363 __u8 type;
364 __u8 code;
365 __u16 ident;
366 } icmpt;
367
368 __u32 spi;
369 } u;
370};
371
372
373/*********************************************************
374 * Interface address.
375 ****/
376
377struct ifaddrmsg
378{
379 unsigned char ifa_family;
380 unsigned char ifa_prefixlen; /* The prefix length */
381 unsigned char ifa_flags; /* Flags */
382 unsigned char ifa_scope; /* See above */
383 int ifa_index; /* Link index */
384};
385
386enum
387{
388 IFA_UNSPEC,
389 IFA_ADDRESS,
390 IFA_LOCAL,
391 IFA_LABEL,
392 IFA_BROADCAST,
393 IFA_ANYCAST,
394 IFA_CACHEINFO,
395 IFA_MULTICAST,
396 __IFA_MAX
397};
398
399#define IFA_MAX (__IFA_MAX - 1)
400
401/* ifa_flags */
402
403#define IFA_F_SECONDARY 0x01
404#define IFA_F_TEMPORARY IFA_F_SECONDARY
405
406#define IFA_F_DEPRECATED 0x20
407#define IFA_F_TENTATIVE 0x40
408#define IFA_F_PERMANENT 0x80
409
410struct ifa_cacheinfo
411{
412 __u32 ifa_prefered;
413 __u32 ifa_valid;
414 __u32 cstamp; /* created timestamp, hundredths of seconds */
415 __u32 tstamp; /* updated timestamp, hundredths of seconds */
416};
417
418
419#define IFA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg))))
420#define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifaddrmsg))
421
422/*
423 Important comment:
424 IFA_ADDRESS is prefix address, rather than local interface address.
425 It makes no difference for normally configured broadcast interfaces,
426 but for point-to-point IFA_ADDRESS is DESTINATION address,
427 local address is supplied in IFA_LOCAL attribute.
428 */
429
430/**************************************************************
431 * Neighbour discovery.
432 ****/
433
434struct ndmsg
435{
436 unsigned char ndm_family;
437 unsigned char ndm_pad1;
438 unsigned short ndm_pad2;
439 int ndm_ifindex; /* Link index */
440 __u16 ndm_state;
441 __u8 ndm_flags;
442 __u8 ndm_type;
443};
444
445enum
446{
447 NDA_UNSPEC,
448 NDA_DST,
449 NDA_LLADDR,
450 NDA_CACHEINFO,
451 NDA_PROBES,
452 __NDA_MAX
453};
454
455#define NDA_MAX (__NDA_MAX - 1)
456
457#define NDA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ndmsg))))
458#define NDA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ndmsg))
459
460/*
461 * Neighbor Cache Entry Flags
462 */
463
464#define NTF_PROXY 0x08 /* == ATF_PUBL */
465#define NTF_ROUTER 0x80
466
467/*
468 * Neighbor Cache Entry States.
469 */
470
471#define NUD_INCOMPLETE 0x01
472#define NUD_REACHABLE 0x02
473#define NUD_STALE 0x04
474#define NUD_DELAY 0x08
475#define NUD_PROBE 0x10
476#define NUD_FAILED 0x20
477
478/* Dummy states */
479#define NUD_NOARP 0x40
480#define NUD_PERMANENT 0x80
481#define NUD_NONE 0x00
482
483
484struct nda_cacheinfo
485{
486 __u32 ndm_confirmed;
487 __u32 ndm_used;
488 __u32 ndm_updated;
489 __u32 ndm_refcnt;
490};
491
492/****
493 * General form of address family dependent message.
494 ****/
495
496struct rtgenmsg
497{
498 unsigned char rtgen_family;
499};
500
501/*****************************************************************
502 * Link layer specific messages.
503 ****/
504
505/* struct ifinfomsg
506 * passes link level specific information, not dependent
507 * on network protocol.
508 */
509
510struct ifinfomsg
511{
512 unsigned char ifi_family;
513 unsigned char __ifi_pad;
514 unsigned short ifi_type; /* ARPHRD_* */
515 int ifi_index; /* Link index */
516 unsigned ifi_flags; /* IFF_* flags */
517 unsigned ifi_change; /* IFF_* change mask */
518};
519
520/********************************************************************
521 * prefix information
522 ****/
523
524struct prefixmsg
525{
526 unsigned char prefix_family;
527 int prefix_ifindex;
528 unsigned char prefix_type;
529 unsigned char prefix_len;
530 unsigned char prefix_flags;
531};
532
533enum
534{
535 PREFIX_UNSPEC,
536 PREFIX_ADDRESS,
537 PREFIX_CACHEINFO,
538 __PREFIX_MAX
539};
540
541#define PREFIX_MAX (__PREFIX_MAX - 1)
542
543struct prefix_cacheinfo
544{
545 __u32 preferred_time;
546 __u32 valid_time;
547};
548
549/* The struct should be in sync with struct net_device_stats */
550struct rtnl_link_stats
551{
552 __u32 rx_packets; /* total packets received */
553 __u32 tx_packets; /* total packets transmitted */
554 __u32 rx_bytes; /* total bytes received */
555 __u32 tx_bytes; /* total bytes transmitted */
556 __u32 rx_errors; /* bad packets received */
557 __u32 tx_errors; /* packet transmit problems */
558 __u32 rx_dropped; /* no space in linux buffers */
559 __u32 tx_dropped; /* no space available in linux */
560 __u32 multicast; /* multicast packets received */
561 __u32 collisions;
562
563 /* detailed rx_errors: */
564 __u32 rx_length_errors;
565 __u32 rx_over_errors; /* receiver ring buff overflow */
566 __u32 rx_crc_errors; /* recved pkt with crc error */
567 __u32 rx_frame_errors; /* recv'd frame alignment error */
568 __u32 rx_fifo_errors; /* recv'r fifo overrun */
569 __u32 rx_missed_errors; /* receiver missed packet */
570
571 /* detailed tx_errors */
572 __u32 tx_aborted_errors;
573 __u32 tx_carrier_errors;
574 __u32 tx_fifo_errors;
575 __u32 tx_heartbeat_errors;
576 __u32 tx_window_errors;
577
578 /* for cslip etc */
579 __u32 rx_compressed;
580 __u32 tx_compressed;
581};
582
583/* The struct should be in sync with struct ifmap */
584struct rtnl_link_ifmap
585{
586 __u64 mem_start;
587 __u64 mem_end;
588 __u64 base_addr;
589 __u16 irq;
590 __u8 dma;
591 __u8 port;
592};
593
594enum
595{
596 IFLA_UNSPEC,
597 IFLA_ADDRESS,
598 IFLA_BROADCAST,
599 IFLA_IFNAME,
600 IFLA_MTU,
601 IFLA_LINK,
602 IFLA_QDISC,
603 IFLA_STATS,
604 IFLA_COST,
605#define IFLA_COST IFLA_COST
606 IFLA_PRIORITY,
607#define IFLA_PRIORITY IFLA_PRIORITY
608 IFLA_MASTER,
609#define IFLA_MASTER IFLA_MASTER
610 IFLA_WIRELESS, /* Wireless Extension event - see wireless.h */
611#define IFLA_WIRELESS IFLA_WIRELESS
612 IFLA_PROTINFO, /* Protocol specific information for a link */
613#define IFLA_PROTINFO IFLA_PROTINFO
614 IFLA_TXQLEN,
615#define IFLA_TXQLEN IFLA_TXQLEN
616 IFLA_MAP,
617#define IFLA_MAP IFLA_MAP
618 IFLA_WEIGHT,
619#define IFLA_WEIGHT IFLA_WEIGHT
620 __IFLA_MAX
621};
622
623
624#define IFLA_MAX (__IFLA_MAX - 1)
625
626#define IFLA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg))))
627#define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg))
628
629/* ifi_flags.
630
631 IFF_* flags.
632
633 The only change is:
634 IFF_LOOPBACK, IFF_BROADCAST and IFF_POINTOPOINT are
635 more not changeable by user. They describe link media
636 characteristics and set by device driver.
637
638 Comments:
639 - Combination IFF_BROADCAST|IFF_POINTOPOINT is invalid
640 - If neither of these three flags are set;
641 the interface is NBMA.
642
643 - IFF_MULTICAST does not mean anything special:
644 multicasts can be used on all not-NBMA links.
645 IFF_MULTICAST means that this media uses special encapsulation
646 for multicast frames. Apparently, all IFF_POINTOPOINT and
647 IFF_BROADCAST devices are able to use multicasts too.
648 */
649
650/* IFLA_LINK.
651 For usual devices it is equal ifi_index.
652 If it is a "virtual interface" (f.e. tunnel), ifi_link
653 can point to real physical interface (f.e. for bandwidth calculations),
654 or maybe 0, what means, that real media is unknown (usual
655 for IPIP tunnels, when route to endpoint is allowed to change)
656 */
657
658/* Subtype attributes for IFLA_PROTINFO */
659enum
660{
661 IFLA_INET6_UNSPEC,
662 IFLA_INET6_FLAGS, /* link flags */
663 IFLA_INET6_CONF, /* sysctl parameters */
664 IFLA_INET6_STATS, /* statistics */
665 IFLA_INET6_MCAST, /* MC things. What of them? */
666 IFLA_INET6_CACHEINFO, /* time values and max reasm size */
667 __IFLA_INET6_MAX
668};
669
670#define IFLA_INET6_MAX (__IFLA_INET6_MAX - 1)
671
672struct ifla_cacheinfo
673{
674 __u32 max_reasm_len;
675 __u32 tstamp; /* ipv6InterfaceTable updated timestamp */
676 __u32 reachable_time;
677 __u32 retrans_time;
678};
679
680/*****************************************************************
681 * Traffic control messages.
682 ****/
683
684struct tcmsg
685{
686 unsigned char tcm_family;
687 unsigned char tcm__pad1;
688 unsigned short tcm__pad2;
689 int tcm_ifindex;
690 __u32 tcm_handle;
691 __u32 tcm_parent;
692 __u32 tcm_info;
693};
694
695enum
696{
697 TCA_UNSPEC,
698 TCA_KIND,
699 TCA_OPTIONS,
700 TCA_STATS,
701 TCA_XSTATS,
702 TCA_RATE,
703 TCA_FCNT,
704 TCA_STATS2,
705 __TCA_MAX
706};
707
708#define TCA_MAX (__TCA_MAX - 1)
709
710#define TCA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcmsg))))
711#define TCA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcmsg))
712
713
714/* RTnetlink multicast groups */
715
716#define RTMGRP_LINK 1
717#define RTMGRP_NOTIFY 2
718#define RTMGRP_NEIGH 4
719#define RTMGRP_TC 8
720
721#define RTMGRP_IPV4_IFADDR 0x10
722#define RTMGRP_IPV4_MROUTE 0x20
723#define RTMGRP_IPV4_ROUTE 0x40
724
725#define RTMGRP_IPV6_IFADDR 0x100
726#define RTMGRP_IPV6_MROUTE 0x200
727#define RTMGRP_IPV6_ROUTE 0x400
728#define RTMGRP_IPV6_IFINFO 0x800
729
730#define RTMGRP_DECnet_IFADDR 0x1000
731#define RTMGRP_DECnet_ROUTE 0x4000
732
733#define RTMGRP_IPV6_PREFIX 0x20000
734
735/* TC action piece */
736struct tcamsg
737{
738 unsigned char tca_family;
739 unsigned char tca__pad1;
740 unsigned short tca__pad2;
741};
742#define TA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcamsg))))
743#define TA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcamsg))
744#define TCA_ACT_TAB 1 /* attr type must be >=1 */
745#define TCAA_MAX 1
746
747/* End of information exported to user level */
748
749#ifdef __KERNEL__
750
751#include <linux/config.h>
752
753extern size_t rtattr_strlcpy(char *dest, const struct rtattr *rta, size_t size);
754static __inline__ int rtattr_strcmp(const struct rtattr *rta, const char *str)
755{
756 int len = strlen(str) + 1;
757 return len > rta->rta_len || memcmp(RTA_DATA(rta), str, len);
758}
759
760extern int rtattr_parse(struct rtattr *tb[], int maxattr, struct rtattr *rta, int len);
761
762#define rtattr_parse_nested(tb, max, rta) \
763 rtattr_parse((tb), (max), RTA_DATA((rta)), RTA_PAYLOAD((rta)))
764
765extern struct sock *rtnl;
766
767struct rtnetlink_link
768{
769 int (*doit)(struct sk_buff *, struct nlmsghdr*, void *attr);
770 int (*dumpit)(struct sk_buff *, struct netlink_callback *cb);
771};
772
773extern struct rtnetlink_link * rtnetlink_links[NPROTO];
774extern int rtnetlink_send(struct sk_buff *skb, u32 pid, u32 group, int echo);
775extern int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics);
776
777extern void __rta_fill(struct sk_buff *skb, int attrtype, int attrlen, const void *data);
778
779#define RTA_PUT(skb, attrtype, attrlen, data) \
780({ if (unlikely(skb_tailroom(skb) < (int)RTA_SPACE(attrlen))) \
781 goto rtattr_failure; \
782 __rta_fill(skb, attrtype, attrlen, data); })
783
784#define RTA_PUT_NOHDR(skb, attrlen, data) \
785({ if (unlikely(skb_tailroom(skb) < (int)(attrlen))) \
786 goto rtattr_failure; \
787 memcpy(skb_put(skb, RTA_ALIGN(attrlen)), data, attrlen); })
788
789static inline struct rtattr *
790__rta_reserve(struct sk_buff *skb, int attrtype, int attrlen)
791{
792 struct rtattr *rta;
793 int size = RTA_LENGTH(attrlen);
794
795 rta = (struct rtattr*)skb_put(skb, RTA_ALIGN(size));
796 rta->rta_type = attrtype;
797 rta->rta_len = size;
798 return rta;
799}
800
801#define __RTA_PUT(skb, attrtype, attrlen) \
802({ if (unlikely(skb_tailroom(skb) < (int)RTA_SPACE(attrlen))) \
803 goto rtattr_failure; \
804 __rta_reserve(skb, attrtype, attrlen); })
805
806extern void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change);
807
808extern struct semaphore rtnl_sem;
809
810#define rtnl_shlock() down(&rtnl_sem)
811#define rtnl_shlock_nowait() down_trylock(&rtnl_sem)
812
813#define rtnl_shunlock() do { up(&rtnl_sem); \
814 if (rtnl && rtnl->sk_receive_queue.qlen) \
815 rtnl->sk_data_ready(rtnl, 0); \
816 } while(0)
817
818extern void rtnl_lock(void);
819extern int rtnl_lock_interruptible(void);
820extern void rtnl_unlock(void);
821extern void rtnetlink_init(void);
822
823#define ASSERT_RTNL() do { \
824 if (unlikely(down_trylock(&rtnl_sem) == 0)) { \
825 up(&rtnl_sem); \
826 printk(KERN_ERR "RTNL: assertion failed at %s (%d)\n", \
827 __FILE__, __LINE__); \
828 dump_stack(); \
829 } \
830} while(0)
831
832#define BUG_TRAP(x) do { \
833 if (unlikely(!(x))) { \
834 printk(KERN_ERR "KERNEL: assertion (%s) failed at %s (%d)\n", \
835 #x, __FILE__ , __LINE__); \
836 } \
837} while(0)
838
839#endif /* __KERNEL__ */
840
841
842#endif /* __LINUX_RTNETLINK_H */
diff --git a/include/linux/rwsem-spinlock.h b/include/linux/rwsem-spinlock.h
new file mode 100644
index 000000000000..b52a2af25f1f
--- /dev/null
+++ b/include/linux/rwsem-spinlock.h
@@ -0,0 +1,65 @@
1/* rwsem-spinlock.h: fallback C implementation
2 *
3 * Copyright (c) 2001 David Howells (dhowells@redhat.com).
4 * - Derived partially from ideas by Andrea Arcangeli <andrea@suse.de>
5 * - Derived also from comments by Linus
6 */
7
8#ifndef _LINUX_RWSEM_SPINLOCK_H
9#define _LINUX_RWSEM_SPINLOCK_H
10
11#ifndef _LINUX_RWSEM_H
12#error "please don't include linux/rwsem-spinlock.h directly, use linux/rwsem.h instead"
13#endif
14
15#include <linux/spinlock.h>
16#include <linux/list.h>
17
18#ifdef __KERNEL__
19
20#include <linux/types.h>
21
22struct rwsem_waiter;
23
24/*
25 * the rw-semaphore definition
26 * - if activity is 0 then there are no active readers or writers
27 * - if activity is +ve then that is the number of active readers
28 * - if activity is -1 then there is one active writer
29 * - if wait_list is not empty, then there are processes waiting for the semaphore
30 */
31struct rw_semaphore {
32 __s32 activity;
33 spinlock_t wait_lock;
34 struct list_head wait_list;
35#if RWSEM_DEBUG
36 int debug;
37#endif
38};
39
40/*
41 * initialisation
42 */
43#if RWSEM_DEBUG
44#define __RWSEM_DEBUG_INIT , 0
45#else
46#define __RWSEM_DEBUG_INIT /* */
47#endif
48
49#define __RWSEM_INITIALIZER(name) \
50{ 0, SPIN_LOCK_UNLOCKED, LIST_HEAD_INIT((name).wait_list) __RWSEM_DEBUG_INIT }
51
52#define DECLARE_RWSEM(name) \
53 struct rw_semaphore name = __RWSEM_INITIALIZER(name)
54
55extern void FASTCALL(init_rwsem(struct rw_semaphore *sem));
56extern void FASTCALL(__down_read(struct rw_semaphore *sem));
57extern int FASTCALL(__down_read_trylock(struct rw_semaphore *sem));
58extern void FASTCALL(__down_write(struct rw_semaphore *sem));
59extern int FASTCALL(__down_write_trylock(struct rw_semaphore *sem));
60extern void FASTCALL(__up_read(struct rw_semaphore *sem));
61extern void FASTCALL(__up_write(struct rw_semaphore *sem));
62extern void FASTCALL(__downgrade_write(struct rw_semaphore *sem));
63
64#endif /* __KERNEL__ */
65#endif /* _LINUX_RWSEM_SPINLOCK_H */
diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h
new file mode 100644
index 000000000000..bfb988885002
--- /dev/null
+++ b/include/linux/rwsem.h
@@ -0,0 +1,115 @@
1/* rwsem.h: R/W semaphores, public interface
2 *
3 * Written by David Howells (dhowells@redhat.com).
4 * Derived from asm-i386/semaphore.h
5 */
6
7#ifndef _LINUX_RWSEM_H
8#define _LINUX_RWSEM_H
9
10#include <linux/linkage.h>
11
12#define RWSEM_DEBUG 0
13
14#ifdef __KERNEL__
15
16#include <linux/config.h>
17#include <linux/types.h>
18#include <linux/kernel.h>
19#include <asm/system.h>
20#include <asm/atomic.h>
21
22struct rw_semaphore;
23
24#ifdef CONFIG_RWSEM_GENERIC_SPINLOCK
25#include <linux/rwsem-spinlock.h> /* use a generic implementation */
26#else
27#include <asm/rwsem.h> /* use an arch-specific implementation */
28#endif
29
30#ifndef rwsemtrace
31#if RWSEM_DEBUG
32extern void FASTCALL(rwsemtrace(struct rw_semaphore *sem, const char *str));
33#else
34#define rwsemtrace(SEM,FMT)
35#endif
36#endif
37
38/*
39 * lock for reading
40 */
41static inline void down_read(struct rw_semaphore *sem)
42{
43 might_sleep();
44 rwsemtrace(sem,"Entering down_read");
45 __down_read(sem);
46 rwsemtrace(sem,"Leaving down_read");
47}
48
49/*
50 * trylock for reading -- returns 1 if successful, 0 if contention
51 */
52static inline int down_read_trylock(struct rw_semaphore *sem)
53{
54 int ret;
55 rwsemtrace(sem,"Entering down_read_trylock");
56 ret = __down_read_trylock(sem);
57 rwsemtrace(sem,"Leaving down_read_trylock");
58 return ret;
59}
60
61/*
62 * lock for writing
63 */
64static inline void down_write(struct rw_semaphore *sem)
65{
66 might_sleep();
67 rwsemtrace(sem,"Entering down_write");
68 __down_write(sem);
69 rwsemtrace(sem,"Leaving down_write");
70}
71
72/*
73 * trylock for writing -- returns 1 if successful, 0 if contention
74 */
75static inline int down_write_trylock(struct rw_semaphore *sem)
76{
77 int ret;
78 rwsemtrace(sem,"Entering down_write_trylock");
79 ret = __down_write_trylock(sem);
80 rwsemtrace(sem,"Leaving down_write_trylock");
81 return ret;
82}
83
84/*
85 * release a read lock
86 */
87static inline void up_read(struct rw_semaphore *sem)
88{
89 rwsemtrace(sem,"Entering up_read");
90 __up_read(sem);
91 rwsemtrace(sem,"Leaving up_read");
92}
93
94/*
95 * release a write lock
96 */
97static inline void up_write(struct rw_semaphore *sem)
98{
99 rwsemtrace(sem,"Entering up_write");
100 __up_write(sem);
101 rwsemtrace(sem,"Leaving up_write");
102}
103
104/*
105 * downgrade write lock to read lock
106 */
107static inline void downgrade_write(struct rw_semaphore *sem)
108{
109 rwsemtrace(sem,"Entering downgrade_write");
110 __downgrade_write(sem);
111 rwsemtrace(sem,"Leaving downgrade_write");
112}
113
114#endif /* __KERNEL__ */
115#endif /* _LINUX_RWSEM_H */
diff --git a/include/linux/sc26198.h b/include/linux/sc26198.h
new file mode 100644
index 000000000000..7ca35abad387
--- /dev/null
+++ b/include/linux/sc26198.h
@@ -0,0 +1,533 @@
1/*****************************************************************************/
2
3/*
4 * sc26198.h -- SC26198 UART hardware info.
5 *
6 * Copyright (C) 1995-1998 Stallion Technologies
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., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23/*****************************************************************************/
24#ifndef _SC26198_H
25#define _SC26198_H
26/*****************************************************************************/
27
28/*
29 * Define the number of async ports per sc26198 uart device.
30 */
31#define SC26198_PORTS 8
32
33/*
34 * Baud rate timing clocks. All derived from a master 14.7456 MHz clock.
35 */
36#define SC26198_MASTERCLOCK 14745600L
37#define SC26198_DCLK (SC26198_MASTERCLOCK)
38#define SC26198_CCLK (SC26198_MASTERCLOCK / 2)
39#define SC26198_BCLK (SC26198_MASTERCLOCK / 4)
40
41/*
42 * Define internal FIFO sizes for the 26198 ports.
43 */
44#define SC26198_TXFIFOSIZE 16
45#define SC26198_RXFIFOSIZE 16
46
47/*****************************************************************************/
48
49/*
50 * Global register definitions. These registers are global to each 26198
51 * device, not specific ports on it.
52 */
53#define TSTR 0x0d
54#define GCCR 0x0f
55#define ICR 0x1b
56#define WDTRCR 0x1d
57#define IVR 0x1f
58#define BRGTRUA 0x84
59#define GPOSR 0x87
60#define GPOC 0x8b
61#define UCIR 0x8c
62#define CIR 0x8c
63#define BRGTRUB 0x8d
64#define GRXFIFO 0x8e
65#define GTXFIFO 0x8e
66#define GCCR2 0x8f
67#define BRGTRLA 0x94
68#define GPOR 0x97
69#define GPOD 0x9b
70#define BRGTCR 0x9c
71#define GICR 0x9c
72#define BRGTRLB 0x9d
73#define GIBCR 0x9d
74#define GITR 0x9f
75
76/*
77 * Per port channel registers. These are the register offsets within
78 * the port address space, so need to have the port address (0 to 7)
79 * inserted in bit positions 4:6.
80 */
81#define MR0 0x00
82#define MR1 0x01
83#define IOPCR 0x02
84#define BCRBRK 0x03
85#define BCRCOS 0x04
86#define BCRX 0x06
87#define BCRA 0x07
88#define XONCR 0x08
89#define XOFFCR 0x09
90#define ARCR 0x0a
91#define RXCSR 0x0c
92#define TXCSR 0x0e
93#define MR2 0x80
94#define SR 0x81
95#define SCCR 0x81
96#define ISR 0x82
97#define IMR 0x82
98#define TXFIFO 0x83
99#define RXFIFO 0x83
100#define IPR 0x84
101#define IOPIOR 0x85
102#define XISR 0x86
103
104/*
105 * For any given port calculate the address to use to access a specified
106 * register. This is only used for unusual access, mostly this is done
107 * through the assembler access routines.
108 */
109#define SC26198_PORTREG(port,reg) ((((port) & 0x07) << 4) | (reg))
110
111/*****************************************************************************/
112
113/*
114 * Global configuration control register bit definitions.
115 */
116#define GCCR_NOACK 0x00
117#define GCCR_IVRACK 0x02
118#define GCCR_IVRCHANACK 0x04
119#define GCCR_IVRTYPCHANACK 0x06
120#define GCCR_ASYNCCYCLE 0x00
121#define GCCR_SYNCCYCLE 0x40
122
123/*****************************************************************************/
124
125/*
126 * Mode register 0 bit definitions.
127 */
128#define MR0_ADDRNONE 0x00
129#define MR0_AUTOWAKE 0x01
130#define MR0_AUTODOZE 0x02
131#define MR0_AUTOWAKEDOZE 0x03
132#define MR0_SWFNONE 0x00
133#define MR0_SWFTX 0x04
134#define MR0_SWFRX 0x08
135#define MR0_SWFRXTX 0x0c
136#define MR0_TXMASK 0x30
137#define MR0_TXEMPTY 0x00
138#define MR0_TXHIGH 0x10
139#define MR0_TXHALF 0x20
140#define MR0_TXRDY 0x00
141#define MR0_ADDRNT 0x00
142#define MR0_ADDRT 0x40
143#define MR0_SWFNT 0x00
144#define MR0_SWFT 0x80
145
146/*
147 * Mode register 1 bit definitions.
148 */
149#define MR1_CS5 0x00
150#define MR1_CS6 0x01
151#define MR1_CS7 0x02
152#define MR1_CS8 0x03
153#define MR1_PAREVEN 0x00
154#define MR1_PARODD 0x04
155#define MR1_PARENB 0x00
156#define MR1_PARFORCE 0x08
157#define MR1_PARNONE 0x10
158#define MR1_PARSPECIAL 0x18
159#define MR1_ERRCHAR 0x00
160#define MR1_ERRBLOCK 0x20
161#define MR1_ISRUNMASKED 0x00
162#define MR1_ISRMASKED 0x40
163#define MR1_AUTORTS 0x80
164
165/*
166 * Mode register 2 bit definitions.
167 */
168#define MR2_STOP1 0x00
169#define MR2_STOP15 0x01
170#define MR2_STOP2 0x02
171#define MR2_STOP916 0x03
172#define MR2_RXFIFORDY 0x00
173#define MR2_RXFIFOHALF 0x04
174#define MR2_RXFIFOHIGH 0x08
175#define MR2_RXFIFOFULL 0x0c
176#define MR2_AUTOCTS 0x10
177#define MR2_TXRTS 0x20
178#define MR2_MODENORM 0x00
179#define MR2_MODEAUTOECHO 0x40
180#define MR2_MODELOOP 0x80
181#define MR2_MODEREMECHO 0xc0
182
183/*****************************************************************************/
184
185/*
186 * Baud Rate Generator (BRG) selector values.
187 */
188#define BRG_50 0x00
189#define BRG_75 0x01
190#define BRG_150 0x02
191#define BRG_200 0x03
192#define BRG_300 0x04
193#define BRG_450 0x05
194#define BRG_600 0x06
195#define BRG_900 0x07
196#define BRG_1200 0x08
197#define BRG_1800 0x09
198#define BRG_2400 0x0a
199#define BRG_3600 0x0b
200#define BRG_4800 0x0c
201#define BRG_7200 0x0d
202#define BRG_9600 0x0e
203#define BRG_14400 0x0f
204#define BRG_19200 0x10
205#define BRG_28200 0x11
206#define BRG_38400 0x12
207#define BRG_57600 0x13
208#define BRG_115200 0x14
209#define BRG_230400 0x15
210#define BRG_GIN0 0x16
211#define BRG_GIN1 0x17
212#define BRG_CT0 0x18
213#define BRG_CT1 0x19
214#define BRG_RX2TX316 0x1b
215#define BRG_RX2TX31 0x1c
216
217#define SC26198_MAXBAUD 921600
218
219/*****************************************************************************/
220
221/*
222 * Command register command definitions.
223 */
224#define CR_NULL 0x04
225#define CR_ADDRNORMAL 0x0c
226#define CR_RXRESET 0x14
227#define CR_TXRESET 0x1c
228#define CR_CLEARRXERR 0x24
229#define CR_BREAKRESET 0x2c
230#define CR_TXSTARTBREAK 0x34
231#define CR_TXSTOPBREAK 0x3c
232#define CR_RTSON 0x44
233#define CR_RTSOFF 0x4c
234#define CR_ADDRINIT 0x5c
235#define CR_RXERRBLOCK 0x6c
236#define CR_TXSENDXON 0x84
237#define CR_TXSENDXOFF 0x8c
238#define CR_GANGXONSET 0x94
239#define CR_GANGXOFFSET 0x9c
240#define CR_GANGXONINIT 0xa4
241#define CR_GANGXOFFINIT 0xac
242#define CR_HOSTXON 0xb4
243#define CR_HOSTXOFF 0xbc
244#define CR_CANCELXOFF 0xc4
245#define CR_ADDRRESET 0xdc
246#define CR_RESETALLPORTS 0xf4
247#define CR_RESETALL 0xfc
248
249#define CR_RXENABLE 0x01
250#define CR_TXENABLE 0x02
251
252/*****************************************************************************/
253
254/*
255 * Channel status register.
256 */
257#define SR_RXRDY 0x01
258#define SR_RXFULL 0x02
259#define SR_TXRDY 0x04
260#define SR_TXEMPTY 0x08
261#define SR_RXOVERRUN 0x10
262#define SR_RXPARITY 0x20
263#define SR_RXFRAMING 0x40
264#define SR_RXBREAK 0x80
265
266#define SR_RXERRS (SR_RXPARITY | SR_RXFRAMING | SR_RXOVERRUN)
267
268/*****************************************************************************/
269
270/*
271 * Interrupt status register and interrupt mask register bit definitions.
272 */
273#define IR_TXRDY 0x01
274#define IR_RXRDY 0x02
275#define IR_RXBREAK 0x04
276#define IR_XONXOFF 0x10
277#define IR_ADDRRECOG 0x20
278#define IR_RXWATCHDOG 0x40
279#define IR_IOPORT 0x80
280
281/*****************************************************************************/
282
283/*
284 * Interrupt vector register field definitions.
285 */
286#define IVR_CHANMASK 0x07
287#define IVR_TYPEMASK 0x18
288#define IVR_CONSTMASK 0xc0
289
290#define IVR_RXDATA 0x10
291#define IVR_RXBADDATA 0x18
292#define IVR_TXDATA 0x08
293#define IVR_OTHER 0x00
294
295/*****************************************************************************/
296
297/*
298 * BRG timer control register bit definitions.
299 */
300#define BRGCTCR_DISABCLK0 0x00
301#define BRGCTCR_ENABCLK0 0x08
302#define BRGCTCR_DISABCLK1 0x00
303#define BRGCTCR_ENABCLK1 0x80
304
305#define BRGCTCR_0SCLK16 0x00
306#define BRGCTCR_0SCLK32 0x01
307#define BRGCTCR_0SCLK64 0x02
308#define BRGCTCR_0SCLK128 0x03
309#define BRGCTCR_0X1 0x04
310#define BRGCTCR_0X12 0x05
311#define BRGCTCR_0IO1A 0x06
312#define BRGCTCR_0GIN0 0x07
313
314#define BRGCTCR_1SCLK16 0x00
315#define BRGCTCR_1SCLK32 0x10
316#define BRGCTCR_1SCLK64 0x20
317#define BRGCTCR_1SCLK128 0x30
318#define BRGCTCR_1X1 0x40
319#define BRGCTCR_1X12 0x50
320#define BRGCTCR_1IO1B 0x60
321#define BRGCTCR_1GIN1 0x70
322
323/*****************************************************************************/
324
325/*
326 * Watch dog timer enable register.
327 */
328#define WDTRCR_ENABALL 0xff
329
330/*****************************************************************************/
331
332/*
333 * XON/XOFF interrupt status register.
334 */
335#define XISR_TXCHARMASK 0x03
336#define XISR_TXCHARNORMAL 0x00
337#define XISR_TXWAIT 0x01
338#define XISR_TXXOFFPEND 0x02
339#define XISR_TXXONPEND 0x03
340
341#define XISR_TXFLOWMASK 0x0c
342#define XISR_TXNORMAL 0x00
343#define XISR_TXSTOPPEND 0x04
344#define XISR_TXSTARTED 0x08
345#define XISR_TXSTOPPED 0x0c
346
347#define XISR_RXFLOWMASK 0x30
348#define XISR_RXFLOWNONE 0x00
349#define XISR_RXXONSENT 0x10
350#define XISR_RXXOFFSENT 0x20
351
352#define XISR_RXXONGOT 0x40
353#define XISR_RXXOFFGOT 0x80
354
355/*****************************************************************************/
356
357/*
358 * Current interrupt register.
359 */
360#define CIR_TYPEMASK 0xc0
361#define CIR_TYPEOTHER 0x00
362#define CIR_TYPETX 0x40
363#define CIR_TYPERXGOOD 0x80
364#define CIR_TYPERXBAD 0xc0
365
366#define CIR_RXDATA 0x80
367#define CIR_RXBADDATA 0x40
368#define CIR_TXDATA 0x40
369
370#define CIR_CHANMASK 0x07
371#define CIR_CNTMASK 0x38
372
373#define CIR_SUBTYPEMASK 0x38
374#define CIR_SUBNONE 0x00
375#define CIR_SUBCOS 0x08
376#define CIR_SUBADDR 0x10
377#define CIR_SUBXONXOFF 0x18
378#define CIR_SUBBREAK 0x28
379
380/*****************************************************************************/
381
382/*
383 * Global interrupting channel register.
384 */
385#define GICR_CHANMASK 0x07
386
387/*****************************************************************************/
388
389/*
390 * Global interrupting byte count register.
391 */
392#define GICR_COUNTMASK 0x0f
393
394/*****************************************************************************/
395
396/*
397 * Global interrupting type register.
398 */
399#define GITR_RXMASK 0xc0
400#define GITR_RXNONE 0x00
401#define GITR_RXBADDATA 0x80
402#define GITR_RXGOODDATA 0xc0
403#define GITR_TXDATA 0x20
404
405#define GITR_SUBTYPEMASK 0x07
406#define GITR_SUBNONE 0x00
407#define GITR_SUBCOS 0x01
408#define GITR_SUBADDR 0x02
409#define GITR_SUBXONXOFF 0x03
410#define GITR_SUBBREAK 0x05
411
412/*****************************************************************************/
413
414/*
415 * Input port change register.
416 */
417#define IPR_CTS 0x01
418#define IPR_DTR 0x02
419#define IPR_RTS 0x04
420#define IPR_DCD 0x08
421#define IPR_CTSCHANGE 0x10
422#define IPR_DTRCHANGE 0x20
423#define IPR_RTSCHANGE 0x40
424#define IPR_DCDCHANGE 0x80
425
426#define IPR_CHANGEMASK 0xf0
427
428/*****************************************************************************/
429
430/*
431 * IO port interrupt and output register.
432 */
433#define IOPR_CTS 0x01
434#define IOPR_DTR 0x02
435#define IOPR_RTS 0x04
436#define IOPR_DCD 0x08
437#define IOPR_CTSCOS 0x10
438#define IOPR_DTRCOS 0x20
439#define IOPR_RTSCOS 0x40
440#define IOPR_DCDCOS 0x80
441
442/*****************************************************************************/
443
444/*
445 * IO port configuration register.
446 */
447#define IOPCR_SETCTS 0x00
448#define IOPCR_SETDTR 0x04
449#define IOPCR_SETRTS 0x10
450#define IOPCR_SETDCD 0x00
451
452#define IOPCR_SETSIGS (IOPCR_SETRTS | IOPCR_SETRTS | IOPCR_SETDTR | IOPCR_SETDCD)
453
454/*****************************************************************************/
455
456/*
457 * General purpose output select register.
458 */
459#define GPORS_TXC1XA 0x08
460#define GPORS_TXC16XA 0x09
461#define GPORS_RXC16XA 0x0a
462#define GPORS_TXC16XB 0x0b
463#define GPORS_GPOR3 0x0c
464#define GPORS_GPOR2 0x0d
465#define GPORS_GPOR1 0x0e
466#define GPORS_GPOR0 0x0f
467
468/*****************************************************************************/
469
470/*
471 * General purpose output register.
472 */
473#define GPOR_0 0x01
474#define GPOR_1 0x02
475#define GPOR_2 0x04
476#define GPOR_3 0x08
477
478/*****************************************************************************/
479
480/*
481 * General purpose output clock register.
482 */
483#define GPORC_0NONE 0x00
484#define GPORC_0GIN0 0x01
485#define GPORC_0GIN1 0x02
486#define GPORC_0IO3A 0x02
487
488#define GPORC_1NONE 0x00
489#define GPORC_1GIN0 0x04
490#define GPORC_1GIN1 0x08
491#define GPORC_1IO3C 0x0c
492
493#define GPORC_2NONE 0x00
494#define GPORC_2GIN0 0x10
495#define GPORC_2GIN1 0x20
496#define GPORC_2IO3E 0x20
497
498#define GPORC_3NONE 0x00
499#define GPORC_3GIN0 0x40
500#define GPORC_3GIN1 0x80
501#define GPORC_3IO3G 0xc0
502
503/*****************************************************************************/
504
505/*
506 * General purpose output data register.
507 */
508#define GPOD_0MASK 0x03
509#define GPOD_0SET1 0x00
510#define GPOD_0SET0 0x01
511#define GPOD_0SETR0 0x02
512#define GPOD_0SETIO3B 0x03
513
514#define GPOD_1MASK 0x0c
515#define GPOD_1SET1 0x00
516#define GPOD_1SET0 0x04
517#define GPOD_1SETR0 0x08
518#define GPOD_1SETIO3D 0x0c
519
520#define GPOD_2MASK 0x30
521#define GPOD_2SET1 0x00
522#define GPOD_2SET0 0x10
523#define GPOD_2SETR0 0x20
524#define GPOD_2SETIO3F 0x30
525
526#define GPOD_3MASK 0xc0
527#define GPOD_3SET1 0x00
528#define GPOD_3SET0 0x40
529#define GPOD_3SETR0 0x80
530#define GPOD_3SETIO3H 0xc0
531
532/*****************************************************************************/
533#endif
diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
new file mode 100644
index 000000000000..7f717e95ae37
--- /dev/null
+++ b/include/linux/scatterlist.h
@@ -0,0 +1,14 @@
1#ifndef _LINUX_SCATTERLIST_H
2#define _LINUX_SCATTERLIST_H
3
4static inline void sg_init_one(struct scatterlist *sg,
5 u8 *buf, unsigned int buflen)
6{
7 memset(sg, 0, sizeof(*sg));
8
9 sg->page = virt_to_page(buf);
10 sg->offset = offset_in_page(buf);
11 sg->length = buflen;
12}
13
14#endif /* _LINUX_SCATTERLIST_H */
diff --git a/include/linux/scc.h b/include/linux/scc.h
new file mode 100644
index 000000000000..885a4a02b23c
--- /dev/null
+++ b/include/linux/scc.h
@@ -0,0 +1,253 @@
1/* $Id: scc.h,v 1.29 1997/04/02 14:56:45 jreuter Exp jreuter $ */
2
3#ifndef _SCC_H
4#define _SCC_H
5
6#include <linux/config.h>
7
8/* selection of hardware types */
9
10#define PA0HZP 0x00 /* hardware type for PA0HZP SCC card and compatible */
11#define EAGLE 0x01 /* hardware type for EAGLE card */
12#define PC100 0x02 /* hardware type for PC100 card */
13#define PRIMUS 0x04 /* hardware type for PRIMUS-PC (DG9BL) card */
14#define DRSI 0x08 /* hardware type for DRSI PC*Packet card */
15#define BAYCOM 0x10 /* hardware type for BayCom (U)SCC */
16
17/* DEV ioctl() commands */
18
19enum SCC_ioctl_cmds {
20 SIOCSCCRESERVED = SIOCDEVPRIVATE,
21 SIOCSCCCFG,
22 SIOCSCCINI,
23 SIOCSCCCHANINI,
24 SIOCSCCSMEM,
25 SIOCSCCGKISS,
26 SIOCSCCSKISS,
27 SIOCSCCGSTAT,
28 SIOCSCCCAL
29};
30
31/* Device parameter control (from WAMPES) */
32
33enum L1_params {
34 PARAM_DATA,
35 PARAM_TXDELAY,
36 PARAM_PERSIST,
37 PARAM_SLOTTIME,
38 PARAM_TXTAIL,
39 PARAM_FULLDUP,
40 PARAM_SOFTDCD, /* was: PARAM_HW */
41 PARAM_MUTE, /* ??? */
42 PARAM_DTR,
43 PARAM_RTS,
44 PARAM_SPEED,
45 PARAM_ENDDELAY, /* ??? */
46 PARAM_GROUP,
47 PARAM_IDLE,
48 PARAM_MIN,
49 PARAM_MAXKEY,
50 PARAM_WAIT,
51 PARAM_MAXDEFER,
52 PARAM_TX,
53 PARAM_HWEVENT = 31,
54 PARAM_RETURN = 255 /* reset kiss mode */
55};
56
57/* fulldup parameter */
58
59enum FULLDUP_modes {
60 KISS_DUPLEX_HALF, /* normal CSMA operation */
61 KISS_DUPLEX_FULL, /* fullduplex, key down trx after transmission */
62 KISS_DUPLEX_LINK, /* fullduplex, key down trx after 'idletime' sec */
63 KISS_DUPLEX_OPTIMA /* fullduplex, let the protocol layer control the hw */
64};
65
66/* misc. parameters */
67
68#define TIMER_OFF 65535U /* to switch off timers */
69#define NO_SUCH_PARAM 65534U /* param not implemented */
70
71/* HWEVENT parameter */
72
73enum HWEVENT_opts {
74 HWEV_DCD_ON,
75 HWEV_DCD_OFF,
76 HWEV_ALL_SENT
77};
78
79/* channel grouping */
80
81#define RXGROUP 0100 /* if set, only tx when all channels clear */
82#define TXGROUP 0200 /* if set, don't transmit simultaneously */
83
84/* Tx/Rx clock sources */
85
86enum CLOCK_sources {
87 CLK_DPLL, /* normal halfduplex operation */
88 CLK_EXTERNAL, /* external clocking (G3RUH/DF9IC modems) */
89 CLK_DIVIDER, /* Rx = DPLL, Tx = divider (fullduplex with */
90 /* modems without clock regeneration */
91 CLK_BRG /* experimental fullduplex mode with DPLL/BRG for */
92 /* MODEMs without clock recovery */
93};
94
95/* Tx state */
96
97enum TX_state {
98 TXS_IDLE, /* Transmitter off, no data pending */
99 TXS_BUSY, /* waiting for permission to send / tailtime */
100 TXS_ACTIVE, /* Transmitter on, sending data */
101 TXS_NEWFRAME, /* reset CRC and send (next) frame */
102 TXS_IDLE2, /* Transmitter on, no data pending */
103 TXS_WAIT, /* Waiting for Mintime to expire */
104 TXS_TIMEOUT /* We had a transmission timeout */
105};
106
107typedef unsigned long io_port; /* type definition for an 'io port address' */
108
109/* SCC statistical information */
110
111struct scc_stat {
112 long rxints; /* Receiver interrupts */
113 long txints; /* Transmitter interrupts */
114 long exints; /* External/status interrupts */
115 long spints; /* Special receiver interrupts */
116
117 long txframes; /* Packets sent */
118 long rxframes; /* Number of Frames Actually Received */
119 long rxerrs; /* CRC Errors */
120 long txerrs; /* KISS errors */
121
122 unsigned int nospace; /* "Out of buffers" */
123 unsigned int rx_over; /* Receiver Overruns */
124 unsigned int tx_under; /* Transmitter Underruns */
125
126 unsigned int tx_state; /* Transmitter state */
127 int tx_queued; /* tx frames enqueued */
128
129 unsigned int maxqueue; /* allocated tx_buffers */
130 unsigned int bufsize; /* used buffersize */
131};
132
133struct scc_modem {
134 long speed; /* Line speed, bps */
135 char clocksrc; /* 0 = DPLL, 1 = external, 2 = divider */
136 char nrz; /* NRZ instead of NRZI */
137};
138
139struct scc_kiss_cmd {
140 int command; /* one of the KISS-Commands defined above */
141 unsigned param; /* KISS-Param */
142};
143
144struct scc_hw_config {
145 io_port data_a; /* data port channel A */
146 io_port ctrl_a; /* control port channel A */
147 io_port data_b; /* data port channel B */
148 io_port ctrl_b; /* control port channel B */
149 io_port vector_latch; /* INTACK-Latch (#) */
150 io_port special; /* special function port */
151
152 int irq; /* irq */
153 long clock; /* clock */
154 char option; /* command for function port */
155
156 char brand; /* hardware type */
157 char escc; /* use ext. features of a 8580/85180/85280 */
158};
159
160/* (#) only one INTACK latch allowed. */
161
162
163struct scc_mem_config {
164 unsigned int dummy;
165 unsigned int bufsize;
166};
167
168struct scc_calibrate {
169 unsigned int time;
170 unsigned char pattern;
171};
172
173#ifdef __KERNEL__
174
175enum {TX_OFF, TX_ON}; /* command for scc_key_trx() */
176
177/* Vector masks in RR2B */
178
179#define VECTOR_MASK 0x06
180#define TXINT 0x00
181#define EXINT 0x02
182#define RXINT 0x04
183#define SPINT 0x06
184
185#ifdef CONFIG_SCC_DELAY
186#define Inb(port) inb_p(port)
187#define Outb(port, val) outb_p(val, port)
188#else
189#define Inb(port) inb(port)
190#define Outb(port, val) outb(val, port)
191#endif
192
193/* SCC channel control structure for KISS */
194
195struct scc_kiss {
196 unsigned char txdelay; /* Transmit Delay 10 ms/cnt */
197 unsigned char persist; /* Persistence (0-255) as a % */
198 unsigned char slottime; /* Delay to wait on persistence hit */
199 unsigned char tailtime; /* Delay after last byte written */
200 unsigned char fulldup; /* Full Duplex mode 0=CSMA 1=DUP 2=ALWAYS KEYED */
201 unsigned char waittime; /* Waittime before any transmit attempt */
202 unsigned int maxkeyup; /* Maximum time to transmit (seconds) */
203 unsigned int mintime; /* Minimal offtime after MAXKEYUP timeout (seconds) */
204 unsigned int idletime; /* Maximum idle time in ALWAYS KEYED mode (seconds) */
205 unsigned int maxdefer; /* Timer for CSMA channel busy limit */
206 unsigned char tx_inhibit; /* Transmit is not allowed when set */
207 unsigned char group; /* Group ID for AX.25 TX interlocking */
208 unsigned char mode; /* 'normal' or 'hwctrl' mode (unused) */
209 unsigned char softdcd; /* Use DPLL instead of DCD pin for carrier detect */
210};
211
212
213/* SCC channel structure */
214
215struct scc_channel {
216 int init; /* channel exists? */
217
218 struct net_device *dev; /* link to device control structure */
219 struct net_device_stats dev_stat;/* device statistics */
220
221 char brand; /* manufacturer of the board */
222 long clock; /* used clock */
223
224 io_port ctrl; /* I/O address of CONTROL register */
225 io_port data; /* I/O address of DATA register */
226 io_port special; /* I/O address of special function port */
227 int irq; /* Number of Interrupt */
228
229 char option;
230 char enhanced; /* Enhanced SCC support */
231
232 unsigned char wreg[16]; /* Copy of last written value in WRx */
233 unsigned char status; /* Copy of R0 at last external interrupt */
234 unsigned char dcd; /* DCD status */
235
236 struct scc_kiss kiss; /* control structure for KISS params */
237 struct scc_stat stat; /* statistical information */
238 struct scc_modem modem; /* modem information */
239
240 struct sk_buff_head tx_queue; /* next tx buffer */
241 struct sk_buff *rx_buff; /* pointer to frame currently received */
242 struct sk_buff *tx_buff; /* pointer to frame currently transmitted */
243
244 /* Timer */
245 struct timer_list tx_t; /* tx timer for this channel */
246 struct timer_list tx_wdog; /* tx watchdogs */
247
248 /* Channel lock */
249 spinlock_t lock; /* Channel guard lock */
250};
251
252#endif /* defined(__KERNEL__) */
253#endif /* defined(_SCC_H) */
diff --git a/include/linux/sched.h b/include/linux/sched.h
new file mode 100644
index 000000000000..a30e91f40da6
--- /dev/null
+++ b/include/linux/sched.h
@@ -0,0 +1,1273 @@
1#ifndef _LINUX_SCHED_H
2#define _LINUX_SCHED_H
3
4#include <asm/param.h> /* for HZ */
5
6#include <linux/config.h>
7#include <linux/capability.h>
8#include <linux/threads.h>
9#include <linux/kernel.h>
10#include <linux/types.h>
11#include <linux/timex.h>
12#include <linux/jiffies.h>
13#include <linux/rbtree.h>
14#include <linux/thread_info.h>
15#include <linux/cpumask.h>
16#include <linux/errno.h>
17#include <linux/nodemask.h>
18
19#include <asm/system.h>
20#include <asm/semaphore.h>
21#include <asm/page.h>
22#include <asm/ptrace.h>
23#include <asm/mmu.h>
24#include <asm/cputime.h>
25
26#include <linux/smp.h>
27#include <linux/sem.h>
28#include <linux/signal.h>
29#include <linux/securebits.h>
30#include <linux/fs_struct.h>
31#include <linux/compiler.h>
32#include <linux/completion.h>
33#include <linux/pid.h>
34#include <linux/percpu.h>
35#include <linux/topology.h>
36#include <linux/seccomp.h>
37
38struct exec_domain;
39
40/*
41 * cloning flags:
42 */
43#define CSIGNAL 0x000000ff /* signal mask to be sent at exit */
44#define CLONE_VM 0x00000100 /* set if VM shared between processes */
45#define CLONE_FS 0x00000200 /* set if fs info shared between processes */
46#define CLONE_FILES 0x00000400 /* set if open files shared between processes */
47#define CLONE_SIGHAND 0x00000800 /* set if signal handlers and blocked signals shared */
48#define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */
49#define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */
50#define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */
51#define CLONE_THREAD 0x00010000 /* Same thread group? */
52#define CLONE_NEWNS 0x00020000 /* New namespace group? */
53#define CLONE_SYSVSEM 0x00040000 /* share system V SEM_UNDO semantics */
54#define CLONE_SETTLS 0x00080000 /* create a new TLS for the child */
55#define CLONE_PARENT_SETTID 0x00100000 /* set the TID in the parent */
56#define CLONE_CHILD_CLEARTID 0x00200000 /* clear the TID in the child */
57#define CLONE_DETACHED 0x00400000 /* Unused, ignored */
58#define CLONE_UNTRACED 0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */
59#define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */
60#define CLONE_STOPPED 0x02000000 /* Start in stopped state */
61
62/*
63 * List of flags we want to share for kernel threads,
64 * if only because they are not used by them anyway.
65 */
66#define CLONE_KERNEL (CLONE_FS | CLONE_FILES | CLONE_SIGHAND)
67
68/*
69 * These are the constant used to fake the fixed-point load-average
70 * counting. Some notes:
71 * - 11 bit fractions expand to 22 bits by the multiplies: this gives
72 * a load-average precision of 10 bits integer + 11 bits fractional
73 * - if you want to count load-averages more often, you need more
74 * precision, or rounding will get you. With 2-second counting freq,
75 * the EXP_n values would be 1981, 2034 and 2043 if still using only
76 * 11 bit fractions.
77 */
78extern unsigned long avenrun[]; /* Load averages */
79
80#define FSHIFT 11 /* nr of bits of precision */
81#define FIXED_1 (1<<FSHIFT) /* 1.0 as fixed-point */
82#define LOAD_FREQ (5*HZ) /* 5 sec intervals */
83#define EXP_1 1884 /* 1/exp(5sec/1min) as fixed-point */
84#define EXP_5 2014 /* 1/exp(5sec/5min) */
85#define EXP_15 2037 /* 1/exp(5sec/15min) */
86
87#define CALC_LOAD(load,exp,n) \
88 load *= exp; \
89 load += n*(FIXED_1-exp); \
90 load >>= FSHIFT;
91
92extern unsigned long total_forks;
93extern int nr_threads;
94extern int last_pid;
95DECLARE_PER_CPU(unsigned long, process_counts);
96extern int nr_processes(void);
97extern unsigned long nr_running(void);
98extern unsigned long nr_uninterruptible(void);
99extern unsigned long nr_iowait(void);
100
101#include <linux/time.h>
102#include <linux/param.h>
103#include <linux/resource.h>
104#include <linux/timer.h>
105
106#include <asm/processor.h>
107
108#define TASK_RUNNING 0
109#define TASK_INTERRUPTIBLE 1
110#define TASK_UNINTERRUPTIBLE 2
111#define TASK_STOPPED 4
112#define TASK_TRACED 8
113#define EXIT_ZOMBIE 16
114#define EXIT_DEAD 32
115
116#define __set_task_state(tsk, state_value) \
117 do { (tsk)->state = (state_value); } while (0)
118#define set_task_state(tsk, state_value) \
119 set_mb((tsk)->state, (state_value))
120
121#define __set_current_state(state_value) \
122 do { current->state = (state_value); } while (0)
123#define set_current_state(state_value) \
124 set_mb(current->state, (state_value))
125
126/* Task command name length */
127#define TASK_COMM_LEN 16
128
129/*
130 * Scheduling policies
131 */
132#define SCHED_NORMAL 0
133#define SCHED_FIFO 1
134#define SCHED_RR 2
135
136struct sched_param {
137 int sched_priority;
138};
139
140#ifdef __KERNEL__
141
142#include <linux/spinlock.h>
143
144/*
145 * This serializes "schedule()" and also protects
146 * the run-queue from deletions/modifications (but
147 * _adding_ to the beginning of the run-queue has
148 * a separate lock).
149 */
150extern rwlock_t tasklist_lock;
151extern spinlock_t mmlist_lock;
152
153typedef struct task_struct task_t;
154
155extern void sched_init(void);
156extern void sched_init_smp(void);
157extern void init_idle(task_t *idle, int cpu);
158
159extern cpumask_t nohz_cpu_mask;
160
161extern void show_state(void);
162extern void show_regs(struct pt_regs *);
163
164/*
165 * TASK is a pointer to the task whose backtrace we want to see (or NULL for current
166 * task), SP is the stack pointer of the first frame that should be shown in the back
167 * trace (or NULL if the entire call-chain of the task should be shown).
168 */
169extern void show_stack(struct task_struct *task, unsigned long *sp);
170
171void io_schedule(void);
172long io_schedule_timeout(long timeout);
173
174extern void cpu_init (void);
175extern void trap_init(void);
176extern void update_process_times(int user);
177extern void scheduler_tick(void);
178
179/* Attach to any functions which should be ignored in wchan output. */
180#define __sched __attribute__((__section__(".sched.text")))
181/* Is this address in the __sched functions? */
182extern int in_sched_functions(unsigned long addr);
183
184#define MAX_SCHEDULE_TIMEOUT LONG_MAX
185extern signed long FASTCALL(schedule_timeout(signed long timeout));
186asmlinkage void schedule(void);
187
188struct namespace;
189
190/* Maximum number of active map areas.. This is a random (large) number */
191#define DEFAULT_MAX_MAP_COUNT 65536
192
193extern int sysctl_max_map_count;
194
195#include <linux/aio.h>
196
197extern unsigned long
198arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
199 unsigned long, unsigned long);
200extern unsigned long
201arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr,
202 unsigned long len, unsigned long pgoff,
203 unsigned long flags);
204extern void arch_unmap_area(struct vm_area_struct *area);
205extern void arch_unmap_area_topdown(struct vm_area_struct *area);
206
207#define set_mm_counter(mm, member, value) (mm)->_##member = (value)
208#define get_mm_counter(mm, member) ((mm)->_##member)
209#define add_mm_counter(mm, member, value) (mm)->_##member += (value)
210#define inc_mm_counter(mm, member) (mm)->_##member++
211#define dec_mm_counter(mm, member) (mm)->_##member--
212typedef unsigned long mm_counter_t;
213
214struct mm_struct {
215 struct vm_area_struct * mmap; /* list of VMAs */
216 struct rb_root mm_rb;
217 struct vm_area_struct * mmap_cache; /* last find_vma result */
218 unsigned long (*get_unmapped_area) (struct file *filp,
219 unsigned long addr, unsigned long len,
220 unsigned long pgoff, unsigned long flags);
221 void (*unmap_area) (struct vm_area_struct *area);
222 unsigned long mmap_base; /* base of mmap area */
223 unsigned long free_area_cache; /* first hole */
224 pgd_t * pgd;
225 atomic_t mm_users; /* How many users with user space? */
226 atomic_t mm_count; /* How many references to "struct mm_struct" (users count as 1) */
227 int map_count; /* number of VMAs */
228 struct rw_semaphore mmap_sem;
229 spinlock_t page_table_lock; /* Protects page tables and some counters */
230
231 struct list_head mmlist; /* List of maybe swapped mm's. These are globally strung
232 * together off init_mm.mmlist, and are protected
233 * by mmlist_lock
234 */
235
236 unsigned long start_code, end_code, start_data, end_data;
237 unsigned long start_brk, brk, start_stack;
238 unsigned long arg_start, arg_end, env_start, env_end;
239 unsigned long total_vm, locked_vm, shared_vm;
240 unsigned long exec_vm, stack_vm, reserved_vm, def_flags, nr_ptes;
241
242 /* Special counters protected by the page_table_lock */
243 mm_counter_t _rss;
244 mm_counter_t _anon_rss;
245
246 unsigned long saved_auxv[42]; /* for /proc/PID/auxv */
247
248 unsigned dumpable:1;
249 cpumask_t cpu_vm_mask;
250
251 /* Architecture-specific MM context */
252 mm_context_t context;
253
254 /* Token based thrashing protection. */
255 unsigned long swap_token_time;
256 char recent_pagein;
257
258 /* coredumping support */
259 int core_waiters;
260 struct completion *core_startup_done, core_done;
261
262 /* aio bits */
263 rwlock_t ioctx_list_lock;
264 struct kioctx *ioctx_list;
265
266 struct kioctx default_kioctx;
267
268 unsigned long hiwater_rss; /* High-water RSS usage */
269 unsigned long hiwater_vm; /* High-water virtual memory usage */
270};
271
272struct sighand_struct {
273 atomic_t count;
274 struct k_sigaction action[_NSIG];
275 spinlock_t siglock;
276};
277
278/*
279 * NOTE! "signal_struct" does not have it's own
280 * locking, because a shared signal_struct always
281 * implies a shared sighand_struct, so locking
282 * sighand_struct is always a proper superset of
283 * the locking of signal_struct.
284 */
285struct signal_struct {
286 atomic_t count;
287 atomic_t live;
288
289 wait_queue_head_t wait_chldexit; /* for wait4() */
290
291 /* current thread group signal load-balancing target: */
292 task_t *curr_target;
293
294 /* shared signal handling: */
295 struct sigpending shared_pending;
296
297 /* thread group exit support */
298 int group_exit_code;
299 /* overloaded:
300 * - notify group_exit_task when ->count is equal to notify_count
301 * - everyone except group_exit_task is stopped during signal delivery
302 * of fatal signals, group_exit_task processes the signal.
303 */
304 struct task_struct *group_exit_task;
305 int notify_count;
306
307 /* thread group stop support, overloads group_exit_code too */
308 int group_stop_count;
309 unsigned int flags; /* see SIGNAL_* flags below */
310
311 /* POSIX.1b Interval Timers */
312 struct list_head posix_timers;
313
314 /* ITIMER_REAL timer for the process */
315 struct timer_list real_timer;
316 unsigned long it_real_value, it_real_incr;
317
318 /* ITIMER_PROF and ITIMER_VIRTUAL timers for the process */
319 cputime_t it_prof_expires, it_virt_expires;
320 cputime_t it_prof_incr, it_virt_incr;
321
322 /* job control IDs */
323 pid_t pgrp;
324 pid_t tty_old_pgrp;
325 pid_t session;
326 /* boolean value for session group leader */
327 int leader;
328
329 struct tty_struct *tty; /* NULL if no tty */
330
331 /*
332 * Cumulative resource counters for dead threads in the group,
333 * and for reaped dead child processes forked by this group.
334 * Live threads maintain their own counters and add to these
335 * in __exit_signal, except for the group leader.
336 */
337 cputime_t utime, stime, cutime, cstime;
338 unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw;
339 unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt;
340
341 /*
342 * Cumulative ns of scheduled CPU time for dead threads in the
343 * group, not including a zombie group leader. (This only differs
344 * from jiffies_to_ns(utime + stime) if sched_clock uses something
345 * other than jiffies.)
346 */
347 unsigned long long sched_time;
348
349 /*
350 * We don't bother to synchronize most readers of this at all,
351 * because there is no reader checking a limit that actually needs
352 * to get both rlim_cur and rlim_max atomically, and either one
353 * alone is a single word that can safely be read normally.
354 * getrlimit/setrlimit use task_lock(current->group_leader) to
355 * protect this instead of the siglock, because they really
356 * have no need to disable irqs.
357 */
358 struct rlimit rlim[RLIM_NLIMITS];
359
360 struct list_head cpu_timers[3];
361
362 /* keep the process-shared keyrings here so that they do the right
363 * thing in threads created with CLONE_THREAD */
364#ifdef CONFIG_KEYS
365 struct key *session_keyring; /* keyring inherited over fork */
366 struct key *process_keyring; /* keyring private to this process */
367#endif
368};
369
370/*
371 * Bits in flags field of signal_struct.
372 */
373#define SIGNAL_STOP_STOPPED 0x00000001 /* job control stop in effect */
374#define SIGNAL_STOP_DEQUEUED 0x00000002 /* stop signal dequeued */
375#define SIGNAL_STOP_CONTINUED 0x00000004 /* SIGCONT since WCONTINUED reap */
376#define SIGNAL_GROUP_EXIT 0x00000008 /* group exit in progress */
377
378
379/*
380 * Priority of a process goes from 0..MAX_PRIO-1, valid RT
381 * priority is 0..MAX_RT_PRIO-1, and SCHED_NORMAL tasks are
382 * in the range MAX_RT_PRIO..MAX_PRIO-1. Priority values
383 * are inverted: lower p->prio value means higher priority.
384 *
385 * The MAX_USER_RT_PRIO value allows the actual maximum
386 * RT priority to be separate from the value exported to
387 * user-space. This allows kernel threads to set their
388 * priority to a value higher than any user task. Note:
389 * MAX_RT_PRIO must not be smaller than MAX_USER_RT_PRIO.
390 */
391
392#define MAX_USER_RT_PRIO 100
393#define MAX_RT_PRIO MAX_USER_RT_PRIO
394
395#define MAX_PRIO (MAX_RT_PRIO + 40)
396
397#define rt_task(p) (unlikely((p)->prio < MAX_RT_PRIO))
398
399/*
400 * Some day this will be a full-fledged user tracking system..
401 */
402struct user_struct {
403 atomic_t __count; /* reference count */
404 atomic_t processes; /* How many processes does this user have? */
405 atomic_t files; /* How many open files does this user have? */
406 atomic_t sigpending; /* How many pending signals does this user have? */
407 /* protected by mq_lock */
408 unsigned long mq_bytes; /* How many bytes can be allocated to mqueue? */
409 unsigned long locked_shm; /* How many pages of mlocked shm ? */
410
411#ifdef CONFIG_KEYS
412 struct key *uid_keyring; /* UID specific keyring */
413 struct key *session_keyring; /* UID's default session keyring */
414#endif
415
416 /* Hash table maintenance information */
417 struct list_head uidhash_list;
418 uid_t uid;
419};
420
421extern struct user_struct *find_user(uid_t);
422
423extern struct user_struct root_user;
424#define INIT_USER (&root_user)
425
426typedef struct prio_array prio_array_t;
427struct backing_dev_info;
428struct reclaim_state;
429
430#ifdef CONFIG_SCHEDSTATS
431struct sched_info {
432 /* cumulative counters */
433 unsigned long cpu_time, /* time spent on the cpu */
434 run_delay, /* time spent waiting on a runqueue */
435 pcnt; /* # of timeslices run on this cpu */
436
437 /* timestamps */
438 unsigned long last_arrival, /* when we last ran on a cpu */
439 last_queued; /* when we were last queued to run */
440};
441
442extern struct file_operations proc_schedstat_operations;
443#endif
444
445enum idle_type
446{
447 SCHED_IDLE,
448 NOT_IDLE,
449 NEWLY_IDLE,
450 MAX_IDLE_TYPES
451};
452
453/*
454 * sched-domains (multiprocessor balancing) declarations:
455 */
456#ifdef CONFIG_SMP
457#define SCHED_LOAD_SCALE 128UL /* increase resolution of load */
458
459#define SD_LOAD_BALANCE 1 /* Do load balancing on this domain. */
460#define SD_BALANCE_NEWIDLE 2 /* Balance when about to become idle */
461#define SD_BALANCE_EXEC 4 /* Balance on exec */
462#define SD_WAKE_IDLE 8 /* Wake to idle CPU on task wakeup */
463#define SD_WAKE_AFFINE 16 /* Wake task to waking CPU */
464#define SD_WAKE_BALANCE 32 /* Perform balancing at task wakeup */
465#define SD_SHARE_CPUPOWER 64 /* Domain members share cpu power */
466
467struct sched_group {
468 struct sched_group *next; /* Must be a circular list */
469 cpumask_t cpumask;
470
471 /*
472 * CPU power of this group, SCHED_LOAD_SCALE being max power for a
473 * single CPU. This is read only (except for setup, hotplug CPU).
474 */
475 unsigned long cpu_power;
476};
477
478struct sched_domain {
479 /* These fields must be setup */
480 struct sched_domain *parent; /* top domain must be null terminated */
481 struct sched_group *groups; /* the balancing groups of the domain */
482 cpumask_t span; /* span of all CPUs in this domain */
483 unsigned long min_interval; /* Minimum balance interval ms */
484 unsigned long max_interval; /* Maximum balance interval ms */
485 unsigned int busy_factor; /* less balancing by factor if busy */
486 unsigned int imbalance_pct; /* No balance until over watermark */
487 unsigned long long cache_hot_time; /* Task considered cache hot (ns) */
488 unsigned int cache_nice_tries; /* Leave cache hot tasks for # tries */
489 unsigned int per_cpu_gain; /* CPU % gained by adding domain cpus */
490 int flags; /* See SD_* */
491
492 /* Runtime fields. */
493 unsigned long last_balance; /* init to jiffies. units in jiffies */
494 unsigned int balance_interval; /* initialise to 1. units in ms. */
495 unsigned int nr_balance_failed; /* initialise to 0 */
496
497#ifdef CONFIG_SCHEDSTATS
498 /* load_balance() stats */
499 unsigned long lb_cnt[MAX_IDLE_TYPES];
500 unsigned long lb_failed[MAX_IDLE_TYPES];
501 unsigned long lb_balanced[MAX_IDLE_TYPES];
502 unsigned long lb_imbalance[MAX_IDLE_TYPES];
503 unsigned long lb_gained[MAX_IDLE_TYPES];
504 unsigned long lb_hot_gained[MAX_IDLE_TYPES];
505 unsigned long lb_nobusyg[MAX_IDLE_TYPES];
506 unsigned long lb_nobusyq[MAX_IDLE_TYPES];
507
508 /* Active load balancing */
509 unsigned long alb_cnt;
510 unsigned long alb_failed;
511 unsigned long alb_pushed;
512
513 /* sched_balance_exec() stats */
514 unsigned long sbe_attempts;
515 unsigned long sbe_pushed;
516
517 /* try_to_wake_up() stats */
518 unsigned long ttwu_wake_remote;
519 unsigned long ttwu_move_affine;
520 unsigned long ttwu_move_balance;
521#endif
522};
523
524#ifdef ARCH_HAS_SCHED_DOMAIN
525/* Useful helpers that arch setup code may use. Defined in kernel/sched.c */
526extern cpumask_t cpu_isolated_map;
527extern void init_sched_build_groups(struct sched_group groups[],
528 cpumask_t span, int (*group_fn)(int cpu));
529extern void cpu_attach_domain(struct sched_domain *sd, int cpu);
530#endif /* ARCH_HAS_SCHED_DOMAIN */
531#endif /* CONFIG_SMP */
532
533
534struct io_context; /* See blkdev.h */
535void exit_io_context(void);
536struct cpuset;
537
538#define NGROUPS_SMALL 32
539#define NGROUPS_PER_BLOCK ((int)(PAGE_SIZE / sizeof(gid_t)))
540struct group_info {
541 int ngroups;
542 atomic_t usage;
543 gid_t small_block[NGROUPS_SMALL];
544 int nblocks;
545 gid_t *blocks[0];
546};
547
548/*
549 * get_group_info() must be called with the owning task locked (via task_lock())
550 * when task != current. The reason being that the vast majority of callers are
551 * looking at current->group_info, which can not be changed except by the
552 * current task. Changing current->group_info requires the task lock, too.
553 */
554#define get_group_info(group_info) do { \
555 atomic_inc(&(group_info)->usage); \
556} while (0)
557
558#define put_group_info(group_info) do { \
559 if (atomic_dec_and_test(&(group_info)->usage)) \
560 groups_free(group_info); \
561} while (0)
562
563struct group_info *groups_alloc(int gidsetsize);
564void groups_free(struct group_info *group_info);
565int set_current_groups(struct group_info *group_info);
566/* access the groups "array" with this macro */
567#define GROUP_AT(gi, i) \
568 ((gi)->blocks[(i)/NGROUPS_PER_BLOCK][(i)%NGROUPS_PER_BLOCK])
569
570
571struct audit_context; /* See audit.c */
572struct mempolicy;
573
574struct task_struct {
575 volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */
576 struct thread_info *thread_info;
577 atomic_t usage;
578 unsigned long flags; /* per process flags, defined below */
579 unsigned long ptrace;
580
581 int lock_depth; /* Lock depth */
582
583 int prio, static_prio;
584 struct list_head run_list;
585 prio_array_t *array;
586
587 unsigned long sleep_avg;
588 unsigned long long timestamp, last_ran;
589 unsigned long long sched_time; /* sched_clock time spent running */
590 int activated;
591
592 unsigned long policy;
593 cpumask_t cpus_allowed;
594 unsigned int time_slice, first_time_slice;
595
596#ifdef CONFIG_SCHEDSTATS
597 struct sched_info sched_info;
598#endif
599
600 struct list_head tasks;
601 /*
602 * ptrace_list/ptrace_children forms the list of my children
603 * that were stolen by a ptracer.
604 */
605 struct list_head ptrace_children;
606 struct list_head ptrace_list;
607
608 struct mm_struct *mm, *active_mm;
609
610/* task state */
611 struct linux_binfmt *binfmt;
612 long exit_state;
613 int exit_code, exit_signal;
614 int pdeath_signal; /* The signal sent when the parent dies */
615 /* ??? */
616 unsigned long personality;
617 unsigned did_exec:1;
618 pid_t pid;
619 pid_t tgid;
620 /*
621 * pointers to (original) parent process, youngest child, younger sibling,
622 * older sibling, respectively. (p->father can be replaced with
623 * p->parent->pid)
624 */
625 struct task_struct *real_parent; /* real parent process (when being debugged) */
626 struct task_struct *parent; /* parent process */
627 /*
628 * children/sibling forms the list of my children plus the
629 * tasks I'm ptracing.
630 */
631 struct list_head children; /* list of my children */
632 struct list_head sibling; /* linkage in my parent's children list */
633 struct task_struct *group_leader; /* threadgroup leader */
634
635 /* PID/PID hash table linkage. */
636 struct pid pids[PIDTYPE_MAX];
637
638 struct completion *vfork_done; /* for vfork() */
639 int __user *set_child_tid; /* CLONE_CHILD_SETTID */
640 int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
641
642 unsigned long rt_priority;
643 cputime_t utime, stime;
644 unsigned long nvcsw, nivcsw; /* context switch counts */
645 struct timespec start_time;
646/* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */
647 unsigned long min_flt, maj_flt;
648
649 cputime_t it_prof_expires, it_virt_expires;
650 unsigned long long it_sched_expires;
651 struct list_head cpu_timers[3];
652
653/* process credentials */
654 uid_t uid,euid,suid,fsuid;
655 gid_t gid,egid,sgid,fsgid;
656 struct group_info *group_info;
657 kernel_cap_t cap_effective, cap_inheritable, cap_permitted;
658 unsigned keep_capabilities:1;
659 struct user_struct *user;
660#ifdef CONFIG_KEYS
661 struct key *thread_keyring; /* keyring private to this thread */
662#endif
663 int oomkilladj; /* OOM kill score adjustment (bit shift). */
664 char comm[TASK_COMM_LEN];
665/* file system info */
666 int link_count, total_link_count;
667/* ipc stuff */
668 struct sysv_sem sysvsem;
669/* CPU-specific state of this task */
670 struct thread_struct thread;
671/* filesystem information */
672 struct fs_struct *fs;
673/* open file information */
674 struct files_struct *files;
675/* namespace */
676 struct namespace *namespace;
677/* signal handlers */
678 struct signal_struct *signal;
679 struct sighand_struct *sighand;
680
681 sigset_t blocked, real_blocked;
682 struct sigpending pending;
683
684 unsigned long sas_ss_sp;
685 size_t sas_ss_size;
686 int (*notifier)(void *priv);
687 void *notifier_data;
688 sigset_t *notifier_mask;
689
690 void *security;
691 struct audit_context *audit_context;
692 seccomp_t seccomp;
693
694/* Thread group tracking */
695 u32 parent_exec_id;
696 u32 self_exec_id;
697/* Protection of (de-)allocation: mm, files, fs, tty, keyrings */
698 spinlock_t alloc_lock;
699/* Protection of proc_dentry: nesting proc_lock, dcache_lock, write_lock_irq(&tasklist_lock); */
700 spinlock_t proc_lock;
701/* context-switch lock */
702 spinlock_t switch_lock;
703
704/* journalling filesystem info */
705 void *journal_info;
706
707/* VM state */
708 struct reclaim_state *reclaim_state;
709
710 struct dentry *proc_dentry;
711 struct backing_dev_info *backing_dev_info;
712
713 struct io_context *io_context;
714
715 unsigned long ptrace_message;
716 siginfo_t *last_siginfo; /* For ptrace use. */
717/*
718 * current io wait handle: wait queue entry to use for io waits
719 * If this thread is processing aio, this points at the waitqueue
720 * inside the currently handled kiocb. It may be NULL (i.e. default
721 * to a stack based synchronous wait) if its doing sync IO.
722 */
723 wait_queue_t *io_wait;
724/* i/o counters(bytes read/written, #syscalls */
725 u64 rchar, wchar, syscr, syscw;
726#if defined(CONFIG_BSD_PROCESS_ACCT)
727 u64 acct_rss_mem1; /* accumulated rss usage */
728 u64 acct_vm_mem1; /* accumulated virtual memory usage */
729 clock_t acct_stimexpd; /* clock_t-converted stime since last update */
730#endif
731#ifdef CONFIG_NUMA
732 struct mempolicy *mempolicy;
733 short il_next;
734#endif
735#ifdef CONFIG_CPUSETS
736 struct cpuset *cpuset;
737 nodemask_t mems_allowed;
738 int cpuset_mems_generation;
739#endif
740};
741
742static inline pid_t process_group(struct task_struct *tsk)
743{
744 return tsk->signal->pgrp;
745}
746
747/**
748 * pid_alive - check that a task structure is not stale
749 * @p: Task structure to be checked.
750 *
751 * Test if a process is not yet dead (at most zombie state)
752 * If pid_alive fails, then pointers within the task structure
753 * can be stale and must not be dereferenced.
754 */
755static inline int pid_alive(struct task_struct *p)
756{
757 return p->pids[PIDTYPE_PID].nr != 0;
758}
759
760extern void free_task(struct task_struct *tsk);
761extern void __put_task_struct(struct task_struct *tsk);
762#define get_task_struct(tsk) do { atomic_inc(&(tsk)->usage); } while(0)
763#define put_task_struct(tsk) \
764do { if (atomic_dec_and_test(&(tsk)->usage)) __put_task_struct(tsk); } while(0)
765
766/*
767 * Per process flags
768 */
769#define PF_ALIGNWARN 0x00000001 /* Print alignment warning msgs */
770 /* Not implemented yet, only for 486*/
771#define PF_STARTING 0x00000002 /* being created */
772#define PF_EXITING 0x00000004 /* getting shut down */
773#define PF_DEAD 0x00000008 /* Dead */
774#define PF_FORKNOEXEC 0x00000040 /* forked but didn't exec */
775#define PF_SUPERPRIV 0x00000100 /* used super-user privileges */
776#define PF_DUMPCORE 0x00000200 /* dumped core */
777#define PF_SIGNALED 0x00000400 /* killed by a signal */
778#define PF_MEMALLOC 0x00000800 /* Allocating memory */
779#define PF_FLUSHER 0x00001000 /* responsible for disk writeback */
780#define PF_USED_MATH 0x00002000 /* if unset the fpu must be initialized before use */
781#define PF_FREEZE 0x00004000 /* this task is being frozen for suspend now */
782#define PF_NOFREEZE 0x00008000 /* this thread should not be frozen */
783#define PF_FROZEN 0x00010000 /* frozen for system suspend */
784#define PF_FSTRANS 0x00020000 /* inside a filesystem transaction */
785#define PF_KSWAPD 0x00040000 /* I am kswapd */
786#define PF_SWAPOFF 0x00080000 /* I am in swapoff */
787#define PF_LESS_THROTTLE 0x00100000 /* Throttle me less: I clean memory */
788#define PF_SYNCWRITE 0x00200000 /* I am doing a sync write */
789#define PF_BORROWED_MM 0x00400000 /* I am a kthread doing use_mm */
790#define PF_RANDOMIZE 0x00800000 /* randomize virtual address space */
791
792/*
793 * Only the _current_ task can read/write to tsk->flags, but other
794 * tasks can access tsk->flags in readonly mode for example
795 * with tsk_used_math (like during threaded core dumping).
796 * There is however an exception to this rule during ptrace
797 * or during fork: the ptracer task is allowed to write to the
798 * child->flags of its traced child (same goes for fork, the parent
799 * can write to the child->flags), because we're guaranteed the
800 * child is not running and in turn not changing child->flags
801 * at the same time the parent does it.
802 */
803#define clear_stopped_child_used_math(child) do { (child)->flags &= ~PF_USED_MATH; } while (0)
804#define set_stopped_child_used_math(child) do { (child)->flags |= PF_USED_MATH; } while (0)
805#define clear_used_math() clear_stopped_child_used_math(current)
806#define set_used_math() set_stopped_child_used_math(current)
807#define conditional_stopped_child_used_math(condition, child) \
808 do { (child)->flags &= ~PF_USED_MATH, (child)->flags |= (condition) ? PF_USED_MATH : 0; } while (0)
809#define conditional_used_math(condition) \
810 conditional_stopped_child_used_math(condition, current)
811#define copy_to_stopped_child_used_math(child) \
812 do { (child)->flags &= ~PF_USED_MATH, (child)->flags |= current->flags & PF_USED_MATH; } while (0)
813/* NOTE: this will return 0 or PF_USED_MATH, it will never return 1 */
814#define tsk_used_math(p) ((p)->flags & PF_USED_MATH)
815#define used_math() tsk_used_math(current)
816
817#ifdef CONFIG_SMP
818extern int set_cpus_allowed(task_t *p, cpumask_t new_mask);
819#else
820static inline int set_cpus_allowed(task_t *p, cpumask_t new_mask)
821{
822 if (!cpus_intersects(new_mask, cpu_online_map))
823 return -EINVAL;
824 return 0;
825}
826#endif
827
828extern unsigned long long sched_clock(void);
829extern unsigned long long current_sched_time(const task_t *current_task);
830
831/* sched_exec is called by processes performing an exec */
832#ifdef CONFIG_SMP
833extern void sched_exec(void);
834#else
835#define sched_exec() {}
836#endif
837
838#ifdef CONFIG_HOTPLUG_CPU
839extern void idle_task_exit(void);
840#else
841static inline void idle_task_exit(void) {}
842#endif
843
844extern void sched_idle_next(void);
845extern void set_user_nice(task_t *p, long nice);
846extern int task_prio(const task_t *p);
847extern int task_nice(const task_t *p);
848extern int task_curr(const task_t *p);
849extern int idle_cpu(int cpu);
850extern int sched_setscheduler(struct task_struct *, int, struct sched_param *);
851extern task_t *idle_task(int cpu);
852
853void yield(void);
854
855/*
856 * The default (Linux) execution domain.
857 */
858extern struct exec_domain default_exec_domain;
859
860union thread_union {
861 struct thread_info thread_info;
862 unsigned long stack[THREAD_SIZE/sizeof(long)];
863};
864
865#ifndef __HAVE_ARCH_KSTACK_END
866static inline int kstack_end(void *addr)
867{
868 /* Reliable end of stack detection:
869 * Some APM bios versions misalign the stack
870 */
871 return !(((unsigned long)addr+sizeof(void*)-1) & (THREAD_SIZE-sizeof(void*)));
872}
873#endif
874
875extern union thread_union init_thread_union;
876extern struct task_struct init_task;
877
878extern struct mm_struct init_mm;
879
880#define find_task_by_pid(nr) find_task_by_pid_type(PIDTYPE_PID, nr)
881extern struct task_struct *find_task_by_pid_type(int type, int pid);
882extern void set_special_pids(pid_t session, pid_t pgrp);
883extern void __set_special_pids(pid_t session, pid_t pgrp);
884
885/* per-UID process charging. */
886extern struct user_struct * alloc_uid(uid_t);
887static inline struct user_struct *get_uid(struct user_struct *u)
888{
889 atomic_inc(&u->__count);
890 return u;
891}
892extern void free_uid(struct user_struct *);
893extern void switch_uid(struct user_struct *);
894
895#include <asm/current.h>
896
897extern void do_timer(struct pt_regs *);
898
899extern int FASTCALL(wake_up_state(struct task_struct * tsk, unsigned int state));
900extern int FASTCALL(wake_up_process(struct task_struct * tsk));
901extern void FASTCALL(wake_up_new_task(struct task_struct * tsk,
902 unsigned long clone_flags));
903#ifdef CONFIG_SMP
904 extern void kick_process(struct task_struct *tsk);
905#else
906 static inline void kick_process(struct task_struct *tsk) { }
907#endif
908extern void FASTCALL(sched_fork(task_t * p));
909extern void FASTCALL(sched_exit(task_t * p));
910
911extern int in_group_p(gid_t);
912extern int in_egroup_p(gid_t);
913
914extern void proc_caches_init(void);
915extern void flush_signals(struct task_struct *);
916extern void flush_signal_handlers(struct task_struct *, int force_default);
917extern int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info);
918
919static inline int dequeue_signal_lock(struct task_struct *tsk, sigset_t *mask, siginfo_t *info)
920{
921 unsigned long flags;
922 int ret;
923
924 spin_lock_irqsave(&tsk->sighand->siglock, flags);
925 ret = dequeue_signal(tsk, mask, info);
926 spin_unlock_irqrestore(&tsk->sighand->siglock, flags);
927
928 return ret;
929}
930
931extern void block_all_signals(int (*notifier)(void *priv), void *priv,
932 sigset_t *mask);
933extern void unblock_all_signals(void);
934extern void release_task(struct task_struct * p);
935extern int send_sig_info(int, struct siginfo *, struct task_struct *);
936extern int send_group_sig_info(int, struct siginfo *, struct task_struct *);
937extern int force_sigsegv(int, struct task_struct *);
938extern int force_sig_info(int, struct siginfo *, struct task_struct *);
939extern int __kill_pg_info(int sig, struct siginfo *info, pid_t pgrp);
940extern int kill_pg_info(int, struct siginfo *, pid_t);
941extern int kill_proc_info(int, struct siginfo *, pid_t);
942extern void do_notify_parent(struct task_struct *, int);
943extern void force_sig(int, struct task_struct *);
944extern void force_sig_specific(int, struct task_struct *);
945extern int send_sig(int, struct task_struct *, int);
946extern void zap_other_threads(struct task_struct *p);
947extern int kill_pg(pid_t, int, int);
948extern int kill_sl(pid_t, int, int);
949extern int kill_proc(pid_t, int, int);
950extern struct sigqueue *sigqueue_alloc(void);
951extern void sigqueue_free(struct sigqueue *);
952extern int send_sigqueue(int, struct sigqueue *, struct task_struct *);
953extern int send_group_sigqueue(int, struct sigqueue *, struct task_struct *);
954extern int do_sigaction(int, const struct k_sigaction *, struct k_sigaction *);
955extern int do_sigaltstack(const stack_t __user *, stack_t __user *, unsigned long);
956
957/* These can be the second arg to send_sig_info/send_group_sig_info. */
958#define SEND_SIG_NOINFO ((struct siginfo *) 0)
959#define SEND_SIG_PRIV ((struct siginfo *) 1)
960#define SEND_SIG_FORCED ((struct siginfo *) 2)
961
962/* True if we are on the alternate signal stack. */
963
964static inline int on_sig_stack(unsigned long sp)
965{
966 return (sp - current->sas_ss_sp < current->sas_ss_size);
967}
968
969static inline int sas_ss_flags(unsigned long sp)
970{
971 return (current->sas_ss_size == 0 ? SS_DISABLE
972 : on_sig_stack(sp) ? SS_ONSTACK : 0);
973}
974
975
976#ifdef CONFIG_SECURITY
977/* code is in security.c */
978extern int capable(int cap);
979#else
980static inline int capable(int cap)
981{
982 if (cap_raised(current->cap_effective, cap)) {
983 current->flags |= PF_SUPERPRIV;
984 return 1;
985 }
986 return 0;
987}
988#endif
989
990/*
991 * Routines for handling mm_structs
992 */
993extern struct mm_struct * mm_alloc(void);
994
995/* mmdrop drops the mm and the page tables */
996extern void FASTCALL(__mmdrop(struct mm_struct *));
997static inline void mmdrop(struct mm_struct * mm)
998{
999 if (atomic_dec_and_test(&mm->mm_count))
1000 __mmdrop(mm);
1001}
1002
1003/* mmput gets rid of the mappings and all user-space */
1004extern void mmput(struct mm_struct *);
1005/* Grab a reference to a task's mm, if it is not already going away */
1006extern struct mm_struct *get_task_mm(struct task_struct *task);
1007/* Remove the current tasks stale references to the old mm_struct */
1008extern void mm_release(struct task_struct *, struct mm_struct *);
1009
1010extern int copy_thread(int, unsigned long, unsigned long, unsigned long, struct task_struct *, struct pt_regs *);
1011extern void flush_thread(void);
1012extern void exit_thread(void);
1013
1014extern void exit_mm(struct task_struct *);
1015extern void exit_files(struct task_struct *);
1016extern void exit_signal(struct task_struct *);
1017extern void __exit_signal(struct task_struct *);
1018extern void exit_sighand(struct task_struct *);
1019extern void __exit_sighand(struct task_struct *);
1020extern void exit_itimers(struct signal_struct *);
1021
1022extern NORET_TYPE void do_group_exit(int);
1023
1024extern void reparent_to_init(void);
1025extern void daemonize(const char *, ...);
1026extern int allow_signal(int);
1027extern int disallow_signal(int);
1028extern task_t *child_reaper;
1029
1030extern int do_execve(char *, char __user * __user *, char __user * __user *, struct pt_regs *);
1031extern long do_fork(unsigned long, unsigned long, struct pt_regs *, unsigned long, int __user *, int __user *);
1032task_t *fork_idle(int);
1033
1034extern void set_task_comm(struct task_struct *tsk, char *from);
1035extern void get_task_comm(char *to, struct task_struct *tsk);
1036
1037#ifdef CONFIG_SMP
1038extern void wait_task_inactive(task_t * p);
1039#else
1040#define wait_task_inactive(p) do { } while (0)
1041#endif
1042
1043#define remove_parent(p) list_del_init(&(p)->sibling)
1044#define add_parent(p, parent) list_add_tail(&(p)->sibling,&(parent)->children)
1045
1046#define REMOVE_LINKS(p) do { \
1047 if (thread_group_leader(p)) \
1048 list_del_init(&(p)->tasks); \
1049 remove_parent(p); \
1050 } while (0)
1051
1052#define SET_LINKS(p) do { \
1053 if (thread_group_leader(p)) \
1054 list_add_tail(&(p)->tasks,&init_task.tasks); \
1055 add_parent(p, (p)->parent); \
1056 } while (0)
1057
1058#define next_task(p) list_entry((p)->tasks.next, struct task_struct, tasks)
1059#define prev_task(p) list_entry((p)->tasks.prev, struct task_struct, tasks)
1060
1061#define for_each_process(p) \
1062 for (p = &init_task ; (p = next_task(p)) != &init_task ; )
1063
1064/*
1065 * Careful: do_each_thread/while_each_thread is a double loop so
1066 * 'break' will not work as expected - use goto instead.
1067 */
1068#define do_each_thread(g, t) \
1069 for (g = t = &init_task ; (g = t = next_task(g)) != &init_task ; ) do
1070
1071#define while_each_thread(g, t) \
1072 while ((t = next_thread(t)) != g)
1073
1074extern task_t * FASTCALL(next_thread(const task_t *p));
1075
1076#define thread_group_leader(p) (p->pid == p->tgid)
1077
1078static inline int thread_group_empty(task_t *p)
1079{
1080 return list_empty(&p->pids[PIDTYPE_TGID].pid_list);
1081}
1082
1083#define delay_group_leader(p) \
1084 (thread_group_leader(p) && !thread_group_empty(p))
1085
1086extern void unhash_process(struct task_struct *p);
1087
1088/*
1089 * Protects ->fs, ->files, ->mm, ->ptrace, ->group_info, ->comm, keyring
1090 * subscriptions and synchronises with wait4(). Also used in procfs.
1091 *
1092 * Nests both inside and outside of read_lock(&tasklist_lock).
1093 * It must not be nested with write_lock_irq(&tasklist_lock),
1094 * neither inside nor outside.
1095 */
1096static inline void task_lock(struct task_struct *p)
1097{
1098 spin_lock(&p->alloc_lock);
1099}
1100
1101static inline void task_unlock(struct task_struct *p)
1102{
1103 spin_unlock(&p->alloc_lock);
1104}
1105
1106/* set thread flags in other task's structures
1107 * - see asm/thread_info.h for TIF_xxxx flags available
1108 */
1109static inline void set_tsk_thread_flag(struct task_struct *tsk, int flag)
1110{
1111 set_ti_thread_flag(tsk->thread_info,flag);
1112}
1113
1114static inline void clear_tsk_thread_flag(struct task_struct *tsk, int flag)
1115{
1116 clear_ti_thread_flag(tsk->thread_info,flag);
1117}
1118
1119static inline int test_and_set_tsk_thread_flag(struct task_struct *tsk, int flag)
1120{
1121 return test_and_set_ti_thread_flag(tsk->thread_info,flag);
1122}
1123
1124static inline int test_and_clear_tsk_thread_flag(struct task_struct *tsk, int flag)
1125{
1126 return test_and_clear_ti_thread_flag(tsk->thread_info,flag);
1127}
1128
1129static inline int test_tsk_thread_flag(struct task_struct *tsk, int flag)
1130{
1131 return test_ti_thread_flag(tsk->thread_info,flag);
1132}
1133
1134static inline void set_tsk_need_resched(struct task_struct *tsk)
1135{
1136 set_tsk_thread_flag(tsk,TIF_NEED_RESCHED);
1137}
1138
1139static inline void clear_tsk_need_resched(struct task_struct *tsk)
1140{
1141 clear_tsk_thread_flag(tsk,TIF_NEED_RESCHED);
1142}
1143
1144static inline int signal_pending(struct task_struct *p)
1145{
1146 return unlikely(test_tsk_thread_flag(p,TIF_SIGPENDING));
1147}
1148
1149static inline int need_resched(void)
1150{
1151 return unlikely(test_thread_flag(TIF_NEED_RESCHED));
1152}
1153
1154/*
1155 * cond_resched() and cond_resched_lock(): latency reduction via
1156 * explicit rescheduling in places that are safe. The return
1157 * value indicates whether a reschedule was done in fact.
1158 * cond_resched_lock() will drop the spinlock before scheduling,
1159 * cond_resched_softirq() will enable bhs before scheduling.
1160 */
1161extern int cond_resched(void);
1162extern int cond_resched_lock(spinlock_t * lock);
1163extern int cond_resched_softirq(void);
1164
1165/*
1166 * Does a critical section need to be broken due to another
1167 * task waiting?:
1168 */
1169#if defined(CONFIG_PREEMPT) && defined(CONFIG_SMP)
1170# define need_lockbreak(lock) ((lock)->break_lock)
1171#else
1172# define need_lockbreak(lock) 0
1173#endif
1174
1175/*
1176 * Does a critical section need to be broken due to another
1177 * task waiting or preemption being signalled:
1178 */
1179static inline int lock_need_resched(spinlock_t *lock)
1180{
1181 if (need_lockbreak(lock) || need_resched())
1182 return 1;
1183 return 0;
1184}
1185
1186/* Reevaluate whether the task has signals pending delivery.
1187 This is required every time the blocked sigset_t changes.
1188 callers must hold sighand->siglock. */
1189
1190extern FASTCALL(void recalc_sigpending_tsk(struct task_struct *t));
1191extern void recalc_sigpending(void);
1192
1193extern void signal_wake_up(struct task_struct *t, int resume_stopped);
1194
1195/*
1196 * Wrappers for p->thread_info->cpu access. No-op on UP.
1197 */
1198#ifdef CONFIG_SMP
1199
1200static inline unsigned int task_cpu(const struct task_struct *p)
1201{
1202 return p->thread_info->cpu;
1203}
1204
1205static inline void set_task_cpu(struct task_struct *p, unsigned int cpu)
1206{
1207 p->thread_info->cpu = cpu;
1208}
1209
1210#else
1211
1212static inline unsigned int task_cpu(const struct task_struct *p)
1213{
1214 return 0;
1215}
1216
1217static inline void set_task_cpu(struct task_struct *p, unsigned int cpu)
1218{
1219}
1220
1221#endif /* CONFIG_SMP */
1222
1223#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1224extern void arch_pick_mmap_layout(struct mm_struct *mm);
1225#else
1226static inline void arch_pick_mmap_layout(struct mm_struct *mm)
1227{
1228 mm->mmap_base = TASK_UNMAPPED_BASE;
1229 mm->get_unmapped_area = arch_get_unmapped_area;
1230 mm->unmap_area = arch_unmap_area;
1231}
1232#endif
1233
1234extern long sched_setaffinity(pid_t pid, cpumask_t new_mask);
1235extern long sched_getaffinity(pid_t pid, cpumask_t *mask);
1236
1237#ifdef CONFIG_MAGIC_SYSRQ
1238
1239extern void normalize_rt_tasks(void);
1240
1241#endif
1242
1243/* try_to_freeze
1244 *
1245 * Checks whether we need to enter the refrigerator
1246 * and returns 1 if we did so.
1247 */
1248#ifdef CONFIG_PM
1249extern void refrigerator(unsigned long);
1250extern int freeze_processes(void);
1251extern void thaw_processes(void);
1252
1253static inline int try_to_freeze(unsigned long refrigerator_flags)
1254{
1255 if (unlikely(current->flags & PF_FREEZE)) {
1256 refrigerator(refrigerator_flags);
1257 return 1;
1258 } else
1259 return 0;
1260}
1261#else
1262static inline void refrigerator(unsigned long flag) {}
1263static inline int freeze_processes(void) { BUG(); return 0; }
1264static inline void thaw_processes(void) {}
1265
1266static inline int try_to_freeze(unsigned long refrigerator_flags)
1267{
1268 return 0;
1269}
1270#endif /* CONFIG_PM */
1271#endif /* __KERNEL__ */
1272
1273#endif
diff --git a/include/linux/sctp.h b/include/linux/sctp.h
new file mode 100644
index 000000000000..6ec66dec29f7
--- /dev/null
+++ b/include/linux/sctp.h
@@ -0,0 +1,594 @@
1/* SCTP kernel reference Implementation
2 * (C) Copyright IBM Corp. 2001, 2004
3 * Copyright (c) 1999-2000 Cisco, Inc.
4 * Copyright (c) 1999-2001 Motorola, Inc.
5 * Copyright (c) 2001 Intel Corp.
6 * Copyright (c) 2001 Nokia, Inc.
7 * Copyright (c) 2001 La Monte H.P. Yarroll
8 *
9 * This file is part of the SCTP kernel reference Implementation
10 *
11 * Various protocol defined structures.
12 *
13 * The SCTP reference implementation is free software;
14 * you can redistribute it and/or modify it under the terms of
15 * the GNU General Public License as published by
16 * the Free Software Foundation; either version 2, or (at your option)
17 * any later version.
18 *
19 * The SCTP reference implementation is distributed in the hope that it
20 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
21 * ************************
22 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23 * See the GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with GNU CC; see the file COPYING. If not, write to
27 * the Free Software Foundation, 59 Temple Place - Suite 330,
28 * Boston, MA 02111-1307, USA.
29 *
30 * Please send any bug reports or fixes you make to the
31 * email address(es):
32 * lksctp developers <lksctp-developerst@lists.sourceforge.net>
33 *
34 * Or submit a bug report through the following website:
35 * http://www.sf.net/projects/lksctp
36 *
37 * Written or modified by:
38 * La Monte H.P. Yarroll <piggy@acm.org>
39 * Karl Knutson <karl@athena.chicago.il.us>
40 * Jon Grimm <jgrimm@us.ibm.com>
41 * Xingang Guo <xingang.guo@intel.com>
42 * randall@sctp.chicago.il.us
43 * kmorneau@cisco.com
44 * qxie1@email.mot.com
45 * Sridhar Samudrala <sri@us.ibm.com>
46 * Kevin Gao <kevin.gao@intel.com>
47 *
48 * Any bugs reported given to us we will try to fix... any fixes shared will
49 * be incorporated into the next SCTP release.
50 */
51#ifndef __LINUX_SCTP_H__
52#define __LINUX_SCTP_H__
53
54#include <linux/in.h> /* We need in_addr. */
55#include <linux/in6.h> /* We need in6_addr. */
56
57
58/* Section 3.1. SCTP Common Header Format */
59typedef struct sctphdr {
60 __u16 source;
61 __u16 dest;
62 __u32 vtag;
63 __u32 checksum;
64} __attribute__((packed)) sctp_sctphdr_t;
65
66/* Section 3.2. Chunk Field Descriptions. */
67typedef struct sctp_chunkhdr {
68 __u8 type;
69 __u8 flags;
70 __u16 length;
71} __attribute__((packed)) sctp_chunkhdr_t;
72
73
74/* Section 3.2. Chunk Type Values.
75 * [Chunk Type] identifies the type of information contained in the Chunk
76 * Value field. It takes a value from 0 to 254. The value of 255 is
77 * reserved for future use as an extension field.
78 */
79typedef enum {
80 SCTP_CID_DATA = 0,
81 SCTP_CID_INIT = 1,
82 SCTP_CID_INIT_ACK = 2,
83 SCTP_CID_SACK = 3,
84 SCTP_CID_HEARTBEAT = 4,
85 SCTP_CID_HEARTBEAT_ACK = 5,
86 SCTP_CID_ABORT = 6,
87 SCTP_CID_SHUTDOWN = 7,
88 SCTP_CID_SHUTDOWN_ACK = 8,
89 SCTP_CID_ERROR = 9,
90 SCTP_CID_COOKIE_ECHO = 10,
91 SCTP_CID_COOKIE_ACK = 11,
92 SCTP_CID_ECN_ECNE = 12,
93 SCTP_CID_ECN_CWR = 13,
94 SCTP_CID_SHUTDOWN_COMPLETE = 14,
95
96 /* PR-SCTP Sec 3.2 */
97 SCTP_CID_FWD_TSN = 0xC0,
98
99 /* Use hex, as defined in ADDIP sec. 3.1 */
100 SCTP_CID_ASCONF = 0xC1,
101 SCTP_CID_ASCONF_ACK = 0x80,
102} sctp_cid_t; /* enum */
103
104
105/* Section 3.2
106 * Chunk Types are encoded such that the highest-order two bits specify
107 * the action that must be taken if the processing endpoint does not
108 * recognize the Chunk Type.
109 */
110typedef enum {
111 SCTP_CID_ACTION_DISCARD = 0x00,
112 SCTP_CID_ACTION_DISCARD_ERR = 0x40,
113 SCTP_CID_ACTION_SKIP = 0x80,
114 SCTP_CID_ACTION_SKIP_ERR = 0xc0,
115} sctp_cid_action_t;
116
117enum { SCTP_CID_ACTION_MASK = 0xc0, };
118
119/* This flag is used in Chunk Flags for ABORT and SHUTDOWN COMPLETE.
120 *
121 * 3.3.7 Abort Association (ABORT) (6):
122 * The T bit is set to 0 if the sender had a TCB that it destroyed.
123 * If the sender did not have a TCB it should set this bit to 1.
124 */
125enum { SCTP_CHUNK_FLAG_T = 0x01 };
126
127/*
128 * Set the T bit
129 *
130 * 0 1 2 3
131 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
132 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
133 * | Type = 14 |Reserved |T| Length = 4 |
134 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
135 *
136 * Chunk Flags: 8 bits
137 *
138 * Reserved: 7 bits
139 * Set to 0 on transmit and ignored on receipt.
140 *
141 * T bit: 1 bit
142 * The T bit is set to 0 if the sender had a TCB that it destroyed. If
143 * the sender did NOT have a TCB it should set this bit to 1.
144 *
145 * Note: Special rules apply to this chunk for verification, please
146 * see Section 8.5.1 for details.
147 */
148
149#define sctp_test_T_bit(c) ((c)->chunk_hdr->flags & SCTP_CHUNK_FLAG_T)
150
151/* RFC 2960
152 * Section 3.2.1 Optional/Variable-length Parmaeter Format.
153 */
154
155typedef struct sctp_paramhdr {
156 __u16 type;
157 __u16 length;
158} __attribute__((packed)) sctp_paramhdr_t;
159
160typedef enum {
161
162 /* RFC 2960 Section 3.3.5 */
163 SCTP_PARAM_HEARTBEAT_INFO = __constant_htons(1),
164 /* RFC 2960 Section 3.3.2.1 */
165 SCTP_PARAM_IPV4_ADDRESS = __constant_htons(5),
166 SCTP_PARAM_IPV6_ADDRESS = __constant_htons(6),
167 SCTP_PARAM_STATE_COOKIE = __constant_htons(7),
168 SCTP_PARAM_UNRECOGNIZED_PARAMETERS = __constant_htons(8),
169 SCTP_PARAM_COOKIE_PRESERVATIVE = __constant_htons(9),
170 SCTP_PARAM_HOST_NAME_ADDRESS = __constant_htons(11),
171 SCTP_PARAM_SUPPORTED_ADDRESS_TYPES = __constant_htons(12),
172 SCTP_PARAM_ECN_CAPABLE = __constant_htons(0x8000),
173
174 /* PR-SCTP Sec 3.1 */
175 SCTP_PARAM_FWD_TSN_SUPPORT = __constant_htons(0xc000),
176
177 /* Add-IP Extension. Section 3.2 */
178 SCTP_PARAM_ADD_IP = __constant_htons(0xc001),
179 SCTP_PARAM_DEL_IP = __constant_htons(0xc002),
180 SCTP_PARAM_ERR_CAUSE = __constant_htons(0xc003),
181 SCTP_PARAM_SET_PRIMARY = __constant_htons(0xc004),
182 SCTP_PARAM_SUCCESS_REPORT = __constant_htons(0xc005),
183 SCTP_PARAM_ADAPTION_LAYER_IND = __constant_htons(0xc006),
184
185} sctp_param_t; /* enum */
186
187
188/* RFC 2960 Section 3.2.1
189 * The Parameter Types are encoded such that the highest-order two bits
190 * specify the action that must be taken if the processing endpoint does
191 * not recognize the Parameter Type.
192 *
193 */
194typedef enum {
195 SCTP_PARAM_ACTION_DISCARD = __constant_htons(0x0000),
196 SCTP_PARAM_ACTION_DISCARD_ERR = __constant_htons(0x4000),
197 SCTP_PARAM_ACTION_SKIP = __constant_htons(0x8000),
198 SCTP_PARAM_ACTION_SKIP_ERR = __constant_htons(0xc000),
199} sctp_param_action_t;
200
201enum { SCTP_PARAM_ACTION_MASK = __constant_htons(0xc000), };
202
203/* RFC 2960 Section 3.3.1 Payload Data (DATA) (0) */
204
205typedef struct sctp_datahdr {
206 __u32 tsn;
207 __u16 stream;
208 __u16 ssn;
209 __u32 ppid;
210 __u8 payload[0];
211} __attribute__((packed)) sctp_datahdr_t;
212
213typedef struct sctp_data_chunk {
214 sctp_chunkhdr_t chunk_hdr;
215 sctp_datahdr_t data_hdr;
216} __attribute__((packed)) sctp_data_chunk_t;
217
218/* DATA Chuck Specific Flags */
219enum {
220 SCTP_DATA_MIDDLE_FRAG = 0x00,
221 SCTP_DATA_LAST_FRAG = 0x01,
222 SCTP_DATA_FIRST_FRAG = 0x02,
223 SCTP_DATA_NOT_FRAG = 0x03,
224 SCTP_DATA_UNORDERED = 0x04,
225};
226enum { SCTP_DATA_FRAG_MASK = 0x03, };
227
228
229/* RFC 2960 Section 3.3.2 Initiation (INIT) (1)
230 *
231 * This chunk is used to initiate a SCTP association between two
232 * endpoints.
233 */
234typedef struct sctp_inithdr {
235 __u32 init_tag;
236 __u32 a_rwnd;
237 __u16 num_outbound_streams;
238 __u16 num_inbound_streams;
239 __u32 initial_tsn;
240 __u8 params[0];
241} __attribute__((packed)) sctp_inithdr_t;
242
243typedef struct sctp_init_chunk {
244 sctp_chunkhdr_t chunk_hdr;
245 sctp_inithdr_t init_hdr;
246} __attribute__((packed)) sctp_init_chunk_t;
247
248
249/* Section 3.3.2.1. IPv4 Address Parameter (5) */
250typedef struct sctp_ipv4addr_param {
251 sctp_paramhdr_t param_hdr;
252 struct in_addr addr;
253} __attribute__((packed)) sctp_ipv4addr_param_t;
254
255/* Section 3.3.2.1. IPv6 Address Parameter (6) */
256typedef struct sctp_ipv6addr_param {
257 sctp_paramhdr_t param_hdr;
258 struct in6_addr addr;
259} __attribute__((packed)) sctp_ipv6addr_param_t;
260
261/* Section 3.3.2.1 Cookie Preservative (9) */
262typedef struct sctp_cookie_preserve_param {
263 sctp_paramhdr_t param_hdr;
264 uint32_t lifespan_increment;
265} __attribute__((packed)) sctp_cookie_preserve_param_t;
266
267/* Section 3.3.2.1 Host Name Address (11) */
268typedef struct sctp_hostname_param {
269 sctp_paramhdr_t param_hdr;
270 uint8_t hostname[0];
271} __attribute__((packed)) sctp_hostname_param_t;
272
273/* Section 3.3.2.1 Supported Address Types (12) */
274typedef struct sctp_supported_addrs_param {
275 sctp_paramhdr_t param_hdr;
276 uint16_t types[0];
277} __attribute__((packed)) sctp_supported_addrs_param_t;
278
279/* Appendix A. ECN Capable (32768) */
280typedef struct sctp_ecn_capable_param {
281 sctp_paramhdr_t param_hdr;
282} __attribute__((packed)) sctp_ecn_capable_param_t;
283
284/* ADDIP Section 3.2.6 Adaption Layer Indication */
285typedef struct sctp_adaption_ind_param {
286 struct sctp_paramhdr param_hdr;
287 __u32 adaption_ind;
288} __attribute__((packed)) sctp_adaption_ind_param_t;
289
290/* RFC 2960. Section 3.3.3 Initiation Acknowledgement (INIT ACK) (2):
291 * The INIT ACK chunk is used to acknowledge the initiation of an SCTP
292 * association.
293 */
294typedef sctp_init_chunk_t sctp_initack_chunk_t;
295
296/* Section 3.3.3.1 State Cookie (7) */
297typedef struct sctp_cookie_param {
298 sctp_paramhdr_t p;
299 __u8 body[0];
300} __attribute__((packed)) sctp_cookie_param_t;
301
302/* Section 3.3.3.1 Unrecognized Parameters (8) */
303typedef struct sctp_unrecognized_param {
304 sctp_paramhdr_t param_hdr;
305 sctp_paramhdr_t unrecognized;
306} __attribute__((packed)) sctp_unrecognized_param_t;
307
308
309
310/*
311 * 3.3.4 Selective Acknowledgement (SACK) (3):
312 *
313 * This chunk is sent to the peer endpoint to acknowledge received DATA
314 * chunks and to inform the peer endpoint of gaps in the received
315 * subsequences of DATA chunks as represented by their TSNs.
316 */
317
318typedef struct sctp_gap_ack_block {
319 __u16 start;
320 __u16 end;
321} __attribute__((packed)) sctp_gap_ack_block_t;
322
323typedef uint32_t sctp_dup_tsn_t;
324
325typedef union {
326 sctp_gap_ack_block_t gab;
327 sctp_dup_tsn_t dup;
328} sctp_sack_variable_t;
329
330typedef struct sctp_sackhdr {
331 __u32 cum_tsn_ack;
332 __u32 a_rwnd;
333 __u16 num_gap_ack_blocks;
334 __u16 num_dup_tsns;
335 sctp_sack_variable_t variable[0];
336} __attribute__((packed)) sctp_sackhdr_t;
337
338typedef struct sctp_sack_chunk {
339 sctp_chunkhdr_t chunk_hdr;
340 sctp_sackhdr_t sack_hdr;
341} __attribute__((packed)) sctp_sack_chunk_t;
342
343
344/* RFC 2960. Section 3.3.5 Heartbeat Request (HEARTBEAT) (4):
345 *
346 * An endpoint should send this chunk to its peer endpoint to probe the
347 * reachability of a particular destination transport address defined in
348 * the present association.
349 */
350
351typedef struct sctp_heartbeathdr {
352 sctp_paramhdr_t info;
353} __attribute__((packed)) sctp_heartbeathdr_t;
354
355typedef struct sctp_heartbeat_chunk {
356 sctp_chunkhdr_t chunk_hdr;
357 sctp_heartbeathdr_t hb_hdr;
358} __attribute__((packed)) sctp_heartbeat_chunk_t;
359
360
361/* For the abort and shutdown ACK we must carry the init tag in the
362 * common header. Just the common header is all that is needed with a
363 * chunk descriptor.
364 */
365typedef struct sctp_abort_chunk {
366 sctp_chunkhdr_t uh;
367} __attribute__((packed)) sctp_abort_chunk_t;
368
369
370/* For the graceful shutdown we must carry the tag (in common header)
371 * and the highest consecutive acking value.
372 */
373typedef struct sctp_shutdownhdr {
374 __u32 cum_tsn_ack;
375} __attribute__((packed)) sctp_shutdownhdr_t;
376
377struct sctp_shutdown_chunk_t {
378 sctp_chunkhdr_t chunk_hdr;
379 sctp_shutdownhdr_t shutdown_hdr;
380} __attribute__ ((packed));
381
382/* RFC 2960. Section 3.3.10 Operation Error (ERROR) (9) */
383
384typedef struct sctp_errhdr {
385 __u16 cause;
386 __u16 length;
387 __u8 variable[0];
388} __attribute__((packed)) sctp_errhdr_t;
389
390typedef struct sctp_operr_chunk {
391 sctp_chunkhdr_t chunk_hdr;
392 sctp_errhdr_t err_hdr;
393} __attribute__((packed)) sctp_operr_chunk_t;
394
395/* RFC 2960 3.3.10 - Operation Error
396 *
397 * Cause Code: 16 bits (unsigned integer)
398 *
399 * Defines the type of error conditions being reported.
400 * Cause Code
401 * Value Cause Code
402 * --------- ----------------
403 * 1 Invalid Stream Identifier
404 * 2 Missing Mandatory Parameter
405 * 3 Stale Cookie Error
406 * 4 Out of Resource
407 * 5 Unresolvable Address
408 * 6 Unrecognized Chunk Type
409 * 7 Invalid Mandatory Parameter
410 * 8 Unrecognized Parameters
411 * 9 No User Data
412 * 10 Cookie Received While Shutting Down
413 */
414typedef enum {
415
416 SCTP_ERROR_NO_ERROR = __constant_htons(0x00),
417 SCTP_ERROR_INV_STRM = __constant_htons(0x01),
418 SCTP_ERROR_MISS_PARAM = __constant_htons(0x02),
419 SCTP_ERROR_STALE_COOKIE = __constant_htons(0x03),
420 SCTP_ERROR_NO_RESOURCE = __constant_htons(0x04),
421 SCTP_ERROR_DNS_FAILED = __constant_htons(0x05),
422 SCTP_ERROR_UNKNOWN_CHUNK = __constant_htons(0x06),
423 SCTP_ERROR_INV_PARAM = __constant_htons(0x07),
424 SCTP_ERROR_UNKNOWN_PARAM = __constant_htons(0x08),
425 SCTP_ERROR_NO_DATA = __constant_htons(0x09),
426 SCTP_ERROR_COOKIE_IN_SHUTDOWN = __constant_htons(0x0a),
427
428
429 /* SCTP Implementation Guide:
430 * 11 Restart of an association with new addresses
431 * 12 User Initiated Abort
432 * 13 Protocol Violation
433 */
434
435 SCTP_ERROR_RESTART = __constant_htons(0x0b),
436 SCTP_ERROR_USER_ABORT = __constant_htons(0x0c),
437 SCTP_ERROR_PROTO_VIOLATION = __constant_htons(0x0d),
438
439 /* ADDIP Section 3.3 New Error Causes
440 *
441 * Four new Error Causes are added to the SCTP Operational Errors,
442 * primarily for use in the ASCONF-ACK chunk.
443 *
444 * Value Cause Code
445 * --------- ----------------
446 * 0x0100 Request to Delete Last Remaining IP Address.
447 * 0x0101 Operation Refused Due to Resource Shortage.
448 * 0x0102 Request to Delete Source IP Address.
449 * 0x0103 Association Aborted due to illegal ASCONF-ACK
450 * 0x0104 Request refused - no authorization.
451 */
452 SCTP_ERROR_DEL_LAST_IP = __constant_htons(0x0100),
453 SCTP_ERROR_RSRC_LOW = __constant_htons(0x0101),
454 SCTP_ERROR_DEL_SRC_IP = __constant_htons(0x0102),
455 SCTP_ERROR_ASCONF_ACK = __constant_htons(0x0103),
456 SCTP_ERROR_REQ_REFUSED = __constant_htons(0x0104)
457} sctp_error_t;
458
459
460
461/* RFC 2960. Appendix A. Explicit Congestion Notification.
462 * Explicit Congestion Notification Echo (ECNE) (12)
463 */
464typedef struct sctp_ecnehdr {
465 __u32 lowest_tsn;
466} sctp_ecnehdr_t;
467
468typedef struct sctp_ecne_chunk {
469 sctp_chunkhdr_t chunk_hdr;
470 sctp_ecnehdr_t ence_hdr;
471} __attribute__((packed)) sctp_ecne_chunk_t;
472
473/* RFC 2960. Appendix A. Explicit Congestion Notification.
474 * Congestion Window Reduced (CWR) (13)
475 */
476typedef struct sctp_cwrhdr {
477 __u32 lowest_tsn;
478} sctp_cwrhdr_t;
479
480typedef struct sctp_cwr_chunk {
481 sctp_chunkhdr_t chunk_hdr;
482 sctp_cwrhdr_t cwr_hdr;
483} __attribute__((packed)) sctp_cwr_chunk_t;
484
485/* PR-SCTP
486 * 3.2 Forward Cumulative TSN Chunk Definition (FORWARD TSN)
487 *
488 * Forward Cumulative TSN chunk has the following format:
489 *
490 * 0 1 2 3
491 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
492 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
493 * | Type = 192 | Flags = 0x00 | Length = Variable |
494 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
495 * | New Cumulative TSN |
496 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
497 * | Stream-1 | Stream Sequence-1 |
498 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
499 * \ /
500 * / \
501 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
502 * | Stream-N | Stream Sequence-N |
503 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
504 *
505 * Chunk Flags:
506 *
507 * Set to all zeros on transmit and ignored on receipt.
508 *
509 * New Cumulative TSN: 32 bit u_int
510 *
511 * This indicates the new cumulative TSN to the data receiver. Upon
512 * the reception of this value, the data receiver MUST consider
513 * any missing TSNs earlier than or equal to this value as received
514 * and stop reporting them as gaps in any subsequent SACKs.
515 *
516 * Stream-N: 16 bit u_int
517 *
518 * This field holds a stream number that was skipped by this
519 * FWD-TSN.
520 *
521 * Stream Sequence-N: 16 bit u_int
522 * This field holds the sequence number associated with the stream
523 * that was skipped. The stream sequence field holds the largest stream
524 * sequence number in this stream being skipped. The receiver of
525 * the FWD-TSN's can use the Stream-N and Stream Sequence-N fields
526 * to enable delivery of any stranded TSN's that remain on the stream
527 * re-ordering queues. This field MUST NOT report TSN's corresponding
528 * to DATA chunk that are marked as unordered. For ordered DATA
529 * chunks this field MUST be filled in.
530 */
531struct sctp_fwdtsn_skip {
532 __u16 stream;
533 __u16 ssn;
534} __attribute__((packed));
535
536struct sctp_fwdtsn_hdr {
537 __u32 new_cum_tsn;
538 struct sctp_fwdtsn_skip skip[0];
539} __attribute((packed));
540
541struct sctp_fwdtsn_chunk {
542 struct sctp_chunkhdr chunk_hdr;
543 struct sctp_fwdtsn_hdr fwdtsn_hdr;
544} __attribute((packed));
545
546
547/* ADDIP
548 * Section 3.1.1 Address Configuration Change Chunk (ASCONF)
549 *
550 * Serial Number: 32 bits (unsigned integer)
551 * This value represents a Serial Number for the ASCONF Chunk. The
552 * valid range of Serial Number is from 0 to 2^32-1.
553 * Serial Numbers wrap back to 0 after reaching 2^32 -1.
554 *
555 * Address Parameter: 8 or 20 bytes (depending on type)
556 * The address is an address of the sender of the ASCONF chunk,
557 * the address MUST be considered part of the association by the
558 * peer endpoint. This field may be used by the receiver of the
559 * ASCONF to help in finding the association. This parameter MUST
560 * be present in every ASCONF message i.e. it is a mandatory TLV
561 * parameter.
562 *
563 * ASCONF Parameter: TLV format
564 * Each Address configuration change is represented by a TLV
565 * parameter as defined in Section 3.2. One or more requests may
566 * be present in an ASCONF Chunk.
567 *
568 * Section 3.1.2 Address Configuration Acknowledgement Chunk (ASCONF-ACK)
569 *
570 * Serial Number: 32 bits (unsigned integer)
571 * This value represents the Serial Number for the received ASCONF
572 * Chunk that is acknowledged by this chunk. This value is copied
573 * from the received ASCONF Chunk.
574 *
575 * ASCONF Parameter Response: TLV format
576 * The ASCONF Parameter Response is used in the ASCONF-ACK to
577 * report status of ASCONF processing.
578 */
579typedef struct sctp_addip_param {
580 sctp_paramhdr_t param_hdr;
581 __u32 crr_id;
582} __attribute__((packed)) sctp_addip_param_t;
583
584typedef struct sctp_addiphdr {
585 __u32 serial;
586 __u8 params[0];
587} __attribute__((packed)) sctp_addiphdr_t;
588
589typedef struct sctp_addip_chunk {
590 sctp_chunkhdr_t chunk_hdr;
591 sctp_addiphdr_t addip_hdr;
592} __attribute__((packed)) sctp_addip_chunk_t;
593
594#endif /* __LINUX_SCTP_H__ */
diff --git a/include/linux/scx200.h b/include/linux/scx200.h
new file mode 100644
index 000000000000..a22f9e173ad2
--- /dev/null
+++ b/include/linux/scx200.h
@@ -0,0 +1,58 @@
1/* linux/include/linux/scx200.h
2
3 Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com>
4
5 Defines for the National Semiconductor SCx200 Processors
6*/
7
8/* Interesting stuff for the National Semiconductor SCx200 CPU */
9
10extern unsigned scx200_cb_base;
11
12#define scx200_cb_present() (scx200_cb_base!=0)
13
14/* F0 PCI Header/Bridge Configuration Registers */
15#define SCx200_DOCCS_BASE 0x78 /* DOCCS Base Address Register */
16#define SCx200_DOCCS_CTRL 0x7c /* DOCCS Control Register */
17
18/* GPIO Register Block */
19#define SCx200_GPIO_SIZE 0x2c /* Size of GPIO register block */
20
21/* General Configuration Block */
22#define SCx200_CB_BASE_FIXED 0x9000 /* Base fixed at 0x9000 according to errata? */
23
24/* Watchdog Timer */
25#define SCx200_WDT_OFFSET 0x00 /* offset within configuration block */
26#define SCx200_WDT_SIZE 0x05 /* size */
27
28#define SCx200_WDT_WDTO 0x00 /* Time-Out Register */
29#define SCx200_WDT_WDCNFG 0x02 /* Configuration Register */
30#define SCx200_WDT_WDSTS 0x04 /* Status Register */
31#define SCx200_WDT_WDSTS_WDOVF (1<<0) /* Overflow bit */
32
33/* High Resolution Timer */
34#define SCx200_TIMER_OFFSET 0x08
35#define SCx200_TIMER_SIZE 0x05
36
37/* Clock Generators */
38#define SCx200_CLOCKGEN_OFFSET 0x10
39#define SCx200_CLOCKGEN_SIZE 0x10
40
41/* Pin Multiplexing and Miscellaneous Configuration Registers */
42#define SCx200_MISC_OFFSET 0x30
43#define SCx200_MISC_SIZE 0x10
44
45#define SCx200_PMR 0x30 /* Pin Multiplexing Register */
46#define SCx200_MCR 0x34 /* Miscellaneous Configuration Register */
47#define SCx200_INTSEL 0x38 /* Interrupt Selection Register */
48#define SCx200_IID 0x3c /* IA On a Chip Identification Number Reg */
49#define SCx200_REV 0x3d /* Revision Register */
50#define SCx200_CBA 0x3e /* Configuration Base Address Register */
51#define SCx200_CBA_SCRATCH 0x64 /* Configuration Base Address Scratchpad */
52
53/*
54 Local variables:
55 compile-command: "make -C ../.. bzImage modules"
56 c-basic-offset: 8
57 End:
58*/
diff --git a/include/linux/scx200_gpio.h b/include/linux/scx200_gpio.h
new file mode 100644
index 000000000000..30cdd648ba79
--- /dev/null
+++ b/include/linux/scx200_gpio.h
@@ -0,0 +1,96 @@
1#include <linux/spinlock.h>
2
3u32 scx200_gpio_configure(int index, u32 set, u32 clear);
4
5extern unsigned scx200_gpio_base;
6extern long scx200_gpio_shadow[2];
7
8#define scx200_gpio_present() (scx200_gpio_base!=0)
9
10/* Definitions to make sure I do the same thing in all functions */
11#define __SCx200_GPIO_BANK unsigned bank = index>>5
12#define __SCx200_GPIO_IOADDR unsigned short ioaddr = scx200_gpio_base+0x10*bank
13#define __SCx200_GPIO_SHADOW long *shadow = scx200_gpio_shadow+bank
14#define __SCx200_GPIO_INDEX index &= 31
15
16#define __SCx200_GPIO_OUT __asm__ __volatile__("outsl":"=mS" (shadow):"d" (ioaddr), "0" (shadow))
17
18/* returns the value of the GPIO pin */
19
20static inline int scx200_gpio_get(int index) {
21 __SCx200_GPIO_BANK;
22 __SCx200_GPIO_IOADDR + 0x04;
23 __SCx200_GPIO_INDEX;
24
25 return (inl(ioaddr) & (1<<index)) ? 1 : 0;
26}
27
28/* return the value driven on the GPIO signal (the value that will be
29 driven if the GPIO is configured as an output, it might not be the
30 state of the GPIO right now if the GPIO is configured as an input) */
31
32static inline int scx200_gpio_current(int index) {
33 __SCx200_GPIO_BANK;
34 __SCx200_GPIO_INDEX;
35
36 return (scx200_gpio_shadow[bank] & (1<<index)) ? 1 : 0;
37}
38
39/* drive the GPIO signal high */
40
41static inline void scx200_gpio_set_high(int index) {
42 __SCx200_GPIO_BANK;
43 __SCx200_GPIO_IOADDR;
44 __SCx200_GPIO_SHADOW;
45 __SCx200_GPIO_INDEX;
46 set_bit(index, shadow);
47 __SCx200_GPIO_OUT;
48}
49
50/* drive the GPIO signal low */
51
52static inline void scx200_gpio_set_low(int index) {
53 __SCx200_GPIO_BANK;
54 __SCx200_GPIO_IOADDR;
55 __SCx200_GPIO_SHADOW;
56 __SCx200_GPIO_INDEX;
57 clear_bit(index, shadow);
58 __SCx200_GPIO_OUT;
59}
60
61/* drive the GPIO signal to state */
62
63static inline void scx200_gpio_set(int index, int state) {
64 __SCx200_GPIO_BANK;
65 __SCx200_GPIO_IOADDR;
66 __SCx200_GPIO_SHADOW;
67 __SCx200_GPIO_INDEX;
68 if (state)
69 set_bit(index, shadow);
70 else
71 clear_bit(index, shadow);
72 __SCx200_GPIO_OUT;
73}
74
75/* toggle the GPIO signal */
76static inline void scx200_gpio_change(int index) {
77 __SCx200_GPIO_BANK;
78 __SCx200_GPIO_IOADDR;
79 __SCx200_GPIO_SHADOW;
80 __SCx200_GPIO_INDEX;
81 change_bit(index, shadow);
82 __SCx200_GPIO_OUT;
83}
84
85#undef __SCx200_GPIO_BANK
86#undef __SCx200_GPIO_IOADDR
87#undef __SCx200_GPIO_SHADOW
88#undef __SCx200_GPIO_INDEX
89#undef __SCx200_GPIO_OUT
90
91/*
92 Local variables:
93 compile-command: "make -C ../.. bzImage modules"
94 c-basic-offset: 8
95 End:
96*/
diff --git a/include/linux/sdla.h b/include/linux/sdla.h
new file mode 100644
index 000000000000..3b6afb8caa42
--- /dev/null
+++ b/include/linux/sdla.h
@@ -0,0 +1,339 @@
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Global definitions for the Frame relay interface.
7 *
8 * Version: @(#)if_ifrad.h 0.20 13 Apr 96
9 *
10 * Author: Mike McLagan <mike.mclagan@linux.org>
11 *
12 * Changes:
13 * 0.15 Mike McLagan Structure packing
14 *
15 * 0.20 Mike McLagan New flags for S508 buffer handling
16 *
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License
19 * as published by the Free Software Foundation; either version
20 * 2 of the License, or (at your option) any later version.
21 */
22
23#ifndef SDLA_H
24#define SDLA_H
25
26/* adapter type */
27#define SDLA_TYPES
28#define SDLA_S502A 5020
29#define SDLA_S502E 5021
30#define SDLA_S503 5030
31#define SDLA_S507 5070
32#define SDLA_S508 5080
33#define SDLA_S509 5090
34#define SDLA_UNKNOWN -1
35
36/* port selection flags for the S508 */
37#define SDLA_S508_PORT_V35 0x00
38#define SDLA_S508_PORT_RS232 0x02
39
40/* Z80 CPU speeds */
41#define SDLA_CPU_3M 0x00
42#define SDLA_CPU_5M 0x01
43#define SDLA_CPU_7M 0x02
44#define SDLA_CPU_8M 0x03
45#define SDLA_CPU_10M 0x04
46#define SDLA_CPU_16M 0x05
47#define SDLA_CPU_12M 0x06
48
49/* some private IOCTLs */
50#define SDLA_IDENTIFY (FRAD_LAST_IOCTL + 1)
51#define SDLA_CPUSPEED (FRAD_LAST_IOCTL + 2)
52#define SDLA_PROTOCOL (FRAD_LAST_IOCTL + 3)
53
54#define SDLA_CLEARMEM (FRAD_LAST_IOCTL + 4)
55#define SDLA_WRITEMEM (FRAD_LAST_IOCTL + 5)
56#define SDLA_READMEM (FRAD_LAST_IOCTL + 6)
57
58struct sdla_mem {
59 int addr;
60 int len;
61 void __user *data;
62};
63
64#define SDLA_START (FRAD_LAST_IOCTL + 7)
65#define SDLA_STOP (FRAD_LAST_IOCTL + 8)
66
67/* some offsets in the Z80's memory space */
68#define SDLA_NMIADDR 0x0000
69#define SDLA_CONF_ADDR 0x0010
70#define SDLA_S502A_NMIADDR 0x0066
71#define SDLA_CODE_BASEADDR 0x0100
72#define SDLA_WINDOW_SIZE 0x2000
73#define SDLA_ADDR_MASK 0x1FFF
74
75/* largest handleable block of data */
76#define SDLA_MAX_DATA 4080
77#define SDLA_MAX_MTU 4072 /* MAX_DATA - sizeof(fradhdr) */
78#define SDLA_MAX_DLCI 24
79
80/* this should be the same as frad_conf */
81struct sdla_conf {
82 short station;
83 short config;
84 short kbaud;
85 short clocking;
86 short max_frm;
87 short T391;
88 short T392;
89 short N391;
90 short N392;
91 short N393;
92 short CIR_fwd;
93 short Bc_fwd;
94 short Be_fwd;
95 short CIR_bwd;
96 short Bc_bwd;
97 short Be_bwd;
98};
99
100/* this should be the same as dlci_conf */
101struct sdla_dlci_conf {
102 short config;
103 short CIR_fwd;
104 short Bc_fwd;
105 short Be_fwd;
106 short CIR_bwd;
107 short Bc_bwd;
108 short Be_bwd;
109 short Tc_fwd;
110 short Tc_bwd;
111 short Tf_max;
112 short Tb_max;
113};
114
115#ifndef __KERNEL__
116
117void sdla(void *cfg_info, char *dev, struct frad_conf *conf, int quiet);
118
119#else
120
121/* important Z80 window addresses */
122#define SDLA_CONTROL_WND 0xE000
123
124#define SDLA_502_CMD_BUF 0xEF60
125#define SDLA_502_RCV_BUF 0xA900
126#define SDLA_502_TXN_AVAIL 0xFFF1
127#define SDLA_502_RCV_AVAIL 0xFFF2
128#define SDLA_502_EVENT_FLAGS 0xFFF3
129#define SDLA_502_MDM_STATUS 0xFFF4
130#define SDLA_502_IRQ_INTERFACE 0xFFFD
131#define SDLA_502_IRQ_PERMISSION 0xFFFE
132#define SDLA_502_DATA_OFS 0x0010
133
134#define SDLA_508_CMD_BUF 0xE000
135#define SDLA_508_TXBUF_INFO 0xF100
136#define SDLA_508_RXBUF_INFO 0xF120
137#define SDLA_508_EVENT_FLAGS 0xF003
138#define SDLA_508_MDM_STATUS 0xF004
139#define SDLA_508_IRQ_INTERFACE 0xF010
140#define SDLA_508_IRQ_PERMISSION 0xF011
141#define SDLA_508_TSE_OFFSET 0xF012
142
143/* Event flags */
144#define SDLA_EVENT_STATUS 0x01
145#define SDLA_EVENT_DLCI_STATUS 0x02
146#define SDLA_EVENT_BAD_DLCI 0x04
147#define SDLA_EVENT_LINK_DOWN 0x40
148
149/* IRQ Trigger flags */
150#define SDLA_INTR_RX 0x01
151#define SDLA_INTR_TX 0x02
152#define SDLA_INTR_MODEM 0x04
153#define SDLA_INTR_COMPLETE 0x08
154#define SDLA_INTR_STATUS 0x10
155#define SDLA_INTR_TIMER 0x20
156
157/* DLCI status bits */
158#define SDLA_DLCI_DELETED 0x01
159#define SDLA_DLCI_ACTIVE 0x02
160#define SDLA_DLCI_WAITING 0x04
161#define SDLA_DLCI_NEW 0x08
162#define SDLA_DLCI_INCLUDED 0x40
163
164/* valid command codes */
165#define SDLA_INFORMATION_WRITE 0x01
166#define SDLA_INFORMATION_READ 0x02
167#define SDLA_ISSUE_IN_CHANNEL_SIGNAL 0x03
168#define SDLA_SET_DLCI_CONFIGURATION 0x10
169#define SDLA_READ_DLCI_CONFIGURATION 0x11
170#define SDLA_DISABLE_COMMUNICATIONS 0x12
171#define SDLA_ENABLE_COMMUNICATIONS 0x13
172#define SDLA_READ_DLC_STATUS 0x14
173#define SDLA_READ_DLC_STATISTICS 0x15
174#define SDLA_FLUSH_DLC_STATISTICS 0x16
175#define SDLA_LIST_ACTIVE_DLCI 0x17
176#define SDLA_FLUSH_INFORMATION_BUFFERS 0x18
177#define SDLA_ADD_DLCI 0x20
178#define SDLA_DELETE_DLCI 0x21
179#define SDLA_ACTIVATE_DLCI 0x22
180#define SDLA_DEACTIVATE_DLCI 0x23
181#define SDLA_READ_MODEM_STATUS 0x30
182#define SDLA_SET_MODEM_STATUS 0x31
183#define SDLA_READ_COMMS_ERR_STATS 0x32
184#define SDLA_FLUSH_COMMS_ERR_STATS 0x33
185#define SDLA_READ_CODE_VERSION 0x40
186#define SDLA_SET_IRQ_TRIGGER 0x50
187#define SDLA_GET_IRQ_TRIGGER 0x51
188
189/* In channel signal types */
190#define SDLA_ICS_LINK_VERIFY 0x02
191#define SDLA_ICS_STATUS_ENQ 0x03
192
193/* modem status flags */
194#define SDLA_MODEM_DTR_HIGH 0x01
195#define SDLA_MODEM_RTS_HIGH 0x02
196#define SDLA_MODEM_DCD_HIGH 0x08
197#define SDLA_MODEM_CTS_HIGH 0x20
198
199/* used for RET_MODEM interpretation */
200#define SDLA_MODEM_DCD_LOW 0x01
201#define SDLA_MODEM_CTS_LOW 0x02
202
203/* return codes */
204#define SDLA_RET_OK 0x00
205#define SDLA_RET_COMMUNICATIONS 0x01
206#define SDLA_RET_CHANNEL_INACTIVE 0x02
207#define SDLA_RET_DLCI_INACTIVE 0x03
208#define SDLA_RET_DLCI_CONFIG 0x04
209#define SDLA_RET_BUF_TOO_BIG 0x05
210#define SDLA_RET_NO_DATA 0x05
211#define SDLA_RET_BUF_OVERSIZE 0x06
212#define SDLA_RET_CIR_OVERFLOW 0x07
213#define SDLA_RET_NO_BUFS 0x08
214#define SDLA_RET_TIMEOUT 0x0A
215#define SDLA_RET_MODEM 0x10
216#define SDLA_RET_CHANNEL_OFF 0x11
217#define SDLA_RET_CHANNEL_ON 0x12
218#define SDLA_RET_DLCI_STATUS 0x13
219#define SDLA_RET_DLCI_UNKNOWN 0x14
220#define SDLA_RET_COMMAND_INVALID 0x1F
221
222/* Configuration flags */
223#define SDLA_DIRECT_RECV 0x0080
224#define SDLA_TX_NO_EXCEPT 0x0020
225#define SDLA_NO_ICF_MSGS 0x1000
226#define SDLA_TX50_RX50 0x0000
227#define SDLA_TX70_RX30 0x2000
228#define SDLA_TX30_RX70 0x4000
229
230/* IRQ selection flags */
231#define SDLA_IRQ_RECEIVE 0x01
232#define SDLA_IRQ_TRANSMIT 0x02
233#define SDLA_IRQ_MODEM_STAT 0x04
234#define SDLA_IRQ_COMMAND 0x08
235#define SDLA_IRQ_CHANNEL 0x10
236#define SDLA_IRQ_TIMER 0x20
237
238/* definitions for PC memory mapping */
239#define SDLA_8K_WINDOW 0x01
240#define SDLA_S502_SEG_A 0x10
241#define SDLA_S502_SEG_C 0x20
242#define SDLA_S502_SEG_D 0x00
243#define SDLA_S502_SEG_E 0x30
244#define SDLA_S507_SEG_A 0x00
245#define SDLA_S507_SEG_B 0x40
246#define SDLA_S507_SEG_C 0x80
247#define SDLA_S507_SEG_E 0xC0
248#define SDLA_S508_SEG_A 0x00
249#define SDLA_S508_SEG_C 0x10
250#define SDLA_S508_SEG_D 0x08
251#define SDLA_S508_SEG_E 0x18
252
253/* SDLA adapter port constants */
254#define SDLA_IO_EXTENTS 0x04
255
256#define SDLA_REG_CONTROL 0x00
257#define SDLA_REG_PC_WINDOW 0x01 /* offset for PC window select latch */
258#define SDLA_REG_Z80_WINDOW 0x02 /* offset for Z80 window select latch */
259#define SDLA_REG_Z80_CONTROL 0x03 /* offset for Z80 control latch */
260
261#define SDLA_S502_STS 0x00 /* status reg for 502, 502E, 507 */
262#define SDLA_S508_GNRL 0x00 /* general purp. reg for 508 */
263#define SDLA_S508_STS 0x01 /* status reg for 508 */
264#define SDLA_S508_IDR 0x02 /* ID reg for 508 */
265
266/* control register flags */
267#define SDLA_S502A_START 0x00 /* start the CPU */
268#define SDLA_S502A_INTREQ 0x02
269#define SDLA_S502A_INTEN 0x04
270#define SDLA_S502A_HALT 0x08 /* halt the CPU */
271#define SDLA_S502A_NMI 0x10 /* issue an NMI to the CPU */
272
273#define SDLA_S502E_CPUEN 0x01
274#define SDLA_S502E_ENABLE 0x02
275#define SDLA_S502E_INTACK 0x04
276
277#define SDLA_S507_ENABLE 0x01
278#define SDLA_S507_IRQ3 0x00
279#define SDLA_S507_IRQ4 0x20
280#define SDLA_S507_IRQ5 0x40
281#define SDLA_S507_IRQ7 0x60
282#define SDLA_S507_IRQ10 0x80
283#define SDLA_S507_IRQ11 0xA0
284#define SDLA_S507_IRQ12 0xC0
285#define SDLA_S507_IRQ15 0xE0
286
287#define SDLA_HALT 0x00
288#define SDLA_CPUEN 0x02
289#define SDLA_MEMEN 0x04
290#define SDLA_S507_EPROMWR 0x08
291#define SDLA_S507_EPROMCLK 0x10
292#define SDLA_S508_INTRQ 0x08
293#define SDLA_S508_INTEN 0x10
294
295struct sdla_cmd {
296 char opp_flag __attribute__((packed));
297 char cmd __attribute__((packed));
298 short length __attribute__((packed));
299 char retval __attribute__((packed));
300 short dlci __attribute__((packed));
301 char flags __attribute__((packed));
302 short rxlost_int __attribute__((packed));
303 long rxlost_app __attribute__((packed));
304 char reserve[2] __attribute__((packed));
305 char data[SDLA_MAX_DATA] __attribute__((packed)); /* transfer data buffer */
306};
307
308struct intr_info {
309 char flags __attribute__((packed));
310 short txlen __attribute__((packed));
311 char irq __attribute__((packed));
312 char flags2 __attribute__((packed));
313 short timeout __attribute__((packed));
314};
315
316/* found in the 508's control window at RXBUF_INFO */
317struct buf_info {
318 unsigned short rse_num __attribute__((packed));
319 unsigned long rse_base __attribute__((packed));
320 unsigned long rse_next __attribute__((packed));
321 unsigned long buf_base __attribute__((packed));
322 unsigned short reserved __attribute__((packed));
323 unsigned long buf_top __attribute__((packed));
324};
325
326/* structure pointed to by rse_base in RXBUF_INFO struct */
327struct buf_entry {
328 char opp_flag __attribute__((packed));
329 short length __attribute__((packed));
330 short dlci __attribute__((packed));
331 char flags __attribute__((packed));
332 short timestamp __attribute__((packed));
333 short reserved[2] __attribute__((packed));
334 long buf_addr __attribute__((packed));
335};
336
337#endif
338
339#endif
diff --git a/include/linux/sdla_asy.h b/include/linux/sdla_asy.h
new file mode 100644
index 000000000000..f62242537c86
--- /dev/null
+++ b/include/linux/sdla_asy.h
@@ -0,0 +1,226 @@
1/*****************************************************************************
2* sdla_asy.h Header file for the Sangoma S508/S514 asynchronous code API
3*
4* Author: Gideon Hack
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 Gideon Hack Initial Version
15*
16*****************************************************************************/
17
18
19#ifndef _WANPIPE_ASYNC_H
20#define _WANPIPE_ASYNC_H
21
22/* ----------------------------------------------------------------------------
23 * Interface commands
24 * --------------------------------------------------------------------------*/
25
26#define SET_ASY_CONFIGURATION 0xE2 /* set the asychronous operational configuration */
27#define READ_ASY_CONFIGURATION 0xE3 /* read the current asychronous operational configuration */
28#define ENABLE_ASY_COMMUNICATIONS 0xE4 /* enable asychronous communications */
29#define DISABLE_ASY_COMMUNICATIONS 0xE5 /* disable asychronous communications */
30#define READ_ASY_OPERATIONAL_STATS 0xE7 /* retrieve the asychronous operational statistics */
31#define FLUSH_ASY_OPERATIONAL_STATS 0xE8 /* flush the asychronous operational statistics */
32#define TRANSMIT_ASY_BREAK_SIGNAL 0xEC /* transmit an asychronous break signal */
33
34
35
36/* ----------------------------------------------------------------------------
37 * Return codes from interface commands
38 * --------------------------------------------------------------------------*/
39
40#define COMMAND_INVALID_FOR_PORT 0x50 /* the command is invalid for the selected port */
41#define DISABLE_ASY_COMMS_BEFORE_CFG 0xE1 /* communications must be disabled before setting the configuration */
42#define ASY_COMMS_ENABLED 0xE1 /* communications are currently enabled */
43#define ASY_COMMS_DISABLED 0xE1 /* communications are currently disabled */
44#define ASY_CFG_BEFORE_COMMS_ENABLED 0xE2 /* perform a SET_ASY_CONFIGURATION before enabling comms */
45#define LGTH_ASY_CFG_DATA_INVALID 0xE2 /* the length of the passed configuration data is invalid */
46#define INVALID_ASY_CFG_DATA 0xE3 /* the passed configuration data is invalid */
47#define ASY_BREAK_SIGNAL_BUSY 0xEC /* a break signal is being transmitted */
48
49
50
51/* ----------------------------------------------------------------------------
52 * Constants for the SET_ASY_CONFIGURATION/READ_ASY_CONFIGURATION command
53 * --------------------------------------------------------------------------*/
54
55/* the asynchronous configuration structure */
56typedef struct {
57 unsigned long baud_rate PACKED; /* the baud rate */
58 unsigned short line_config_options PACKED; /* line configuration options */
59 unsigned short modem_config_options PACKED; /* modem configuration options */
60 unsigned short asy_API_options PACKED; /* asynchronous API options */
61 unsigned short asy_protocol_options PACKED; /* asynchronous protocol options */
62 unsigned short Tx_bits_per_char PACKED; /* number of bits per tx character */
63 unsigned short Rx_bits_per_char PACKED; /* number of bits per received character */
64 unsigned short stop_bits PACKED; /* number of stop bits per character */
65 unsigned short parity PACKED; /* parity definition */
66 unsigned short break_timer PACKED; /* the break signal timer */
67 unsigned short asy_Rx_inter_char_timer PACKED; /* the receive inter-character timer */
68 unsigned short asy_Rx_complete_length PACKED; /* the receive 'buffer complete' length */
69 unsigned short XON_char PACKED; /* the XON character */
70 unsigned short XOFF_char PACKED; /* the XOFF character */
71 unsigned short asy_statistics_options PACKED; /* async operational stat options */
72 unsigned long ptr_shared_mem_info_struct PACKED;/* ptr to the shared memory area information structure */
73 unsigned long ptr_asy_Tx_stat_el_cfg_struct PACKED;/* ptr to the transmit status element configuration structure */
74 unsigned long ptr_asy_Rx_stat_el_cfg_struct PACKED;/* ptr to the receive status element configuration structure */
75} ASY_CONFIGURATION_STRUCT;
76
77/* permitted minimum and maximum values for setting the asynchronous configuration */
78#define MIN_ASY_BAUD_RATE 50 /* maximum baud rate */
79#define MAX_ASY_BAUD_RATE 250000 /* minimum baud rate */
80#define MIN_ASY_BITS_PER_CHAR 5 /* minimum number of bits per character */
81#define MAX_ASY_BITS_PER_CHAR 8 /* maximum number of bits per character */
82#define MIN_BREAK_TMR_VAL 0 /* minimum break signal timer */
83#define MAX_BREAK_TMR_VAL 5000 /* maximum break signal timer */
84#define MIN_ASY_RX_INTER_CHAR_TMR 0 /* minimum receive inter-character timer */
85#define MAX_ASY_RX_INTER_CHAR_TMR 30000 /* maximum receive inter-character timer */
86#define MIN_ASY_RX_CPLT_LENGTH 0 /* minimum receive 'length complete' value */
87#define MAX_ASY_RX_CPLT_LENGTH 2000 /* maximum receive 'length complete' value */
88
89/* bit settings for the 'asy_API_options' */
90#define ASY_RX_DATA_TRANSPARENT 0x0001 /* do not strip parity and unused bits from received characters */
91
92/* bit settings for the 'asy_protocol_options' */
93#define ASY_RTS_HS_FOR_RX 0x0001 /* RTS handshaking is used for reception control */
94#define ASY_XON_XOFF_HS_FOR_RX 0x0002 /* XON/XOFF handshaking is used for reception control */
95#define ASY_XON_XOFF_HS_FOR_TX 0x0004 /* XON/XOFF handshaking is used for transmission control */
96#define ASY_DCD_HS_FOR_TX 0x0008 /* DCD handshaking is used for transmission control */
97#define ASY_CTS_HS_FOR_TX 0x0020 /* CTS handshaking is used for transmission control */
98
99/* bit settings for the 'stop_bits' definition */
100#define ONE_STOP_BIT 1 /* representation for 1 stop bit */
101#define TWO_STOP_BITS 2 /* representation for 2 stop bits */
102#define ONE_AND_A_HALF_STOP_BITS 3 /* representation for 1.5 stop bits */
103
104/* bit settings for the 'parity' definition */
105#define NO_PARITY 0 /* representation for no parity */
106#define ODD_PARITY 1 /* representation for odd parity */
107#define EVEN_PARITY 2 /* representation for even parity */
108
109
110
111/* ----------------------------------------------------------------------------
112 * Constants for the READ_COMMS_ERROR_STATS command (asynchronous mode)
113 * --------------------------------------------------------------------------*/
114
115/* the communications error statistics structure */
116typedef struct {
117 unsigned short Rx_overrun_err_count PACKED; /* receiver overrun error count */
118 unsigned short Rx_parity_err_count PACKED; /* parity errors received count */
119 unsigned short Rx_framing_err_count PACKED; /* framing errors received count */
120 unsigned short comms_err_stat_reserved_1 PACKED;/* reserved for later use */
121 unsigned short comms_err_stat_reserved_2 PACKED;/* reserved for later use */
122 unsigned short comms_err_stat_reserved_3 PACKED;/* reserved for later use */
123 unsigned short comms_err_stat_reserved_4 PACKED;/* reserved for later use */
124 unsigned short comms_err_stat_reserved_5 PACKED;/* reserved for later use */
125 unsigned short DCD_state_change_count PACKED; /* DCD state change count */
126 unsigned short CTS_state_change_count PACKED; /* CTS state change count */
127} ASY_COMMS_ERROR_STATS_STRUCT;
128
129
130
131/* ----------------------------------------------------------------------------
132 * Constants for the READ_ASY_OPERATIONAL_STATS command
133 * --------------------------------------------------------------------------*/
134
135/* the asynchronous operational statistics structure */
136typedef struct {
137
138 /* Data transmission statistics */
139 unsigned long Data_blocks_Tx_count PACKED;/* number of blocks transmitted */
140 unsigned long Data_bytes_Tx_count PACKED;/* number of bytes transmitted */
141 unsigned long Data_Tx_throughput PACKED;/* transmit throughput */
142 unsigned long no_ms_for_Data_Tx_thruput_comp PACKED;/* millisecond time used for the Tx throughput computation */
143 unsigned long Tx_Data_discard_lgth_err_count PACKED;/* number of Data blocks discarded (length error) */
144 unsigned long reserved_Data_frm_Tx_stat1 PACKED;/* reserved for later use */
145 unsigned long reserved_Data_frm_Tx_stat2 PACKED;/* reserved for later use */
146 unsigned long reserved_Data_frm_Tx_stat3 PACKED;/* reserved for later use */
147
148 /* Data reception statistics */
149 unsigned long Data_blocks_Rx_count PACKED;/* number of blocks received */
150 unsigned long Data_bytes_Rx_count PACKED;/* number of bytes received */
151 unsigned long Data_Rx_throughput PACKED;/* receive throughput */
152 unsigned long no_ms_for_Data_Rx_thruput_comp PACKED;/* millisecond time used for the Rx throughput computation */
153 unsigned long Rx_Data_bytes_discard_count PACKED;/* received Data bytes discarded */
154 unsigned long reserved_Data_frm_Rx_stat1 PACKED;/* reserved for later use */
155
156 /* handshaking protocol statistics */
157 unsigned short XON_chars_Tx_count PACKED; /* number of XON characters transmitted */
158 unsigned short XOFF_chars_Tx_count PACKED; /* number of XOFF characters transmitted */
159 unsigned short XON_chars_Rx_count PACKED; /* number of XON characters received */
160 unsigned short XOFF_chars_Rx_count PACKED; /* number of XOFF characters received */
161 unsigned short Tx_halt_modem_low_count PACKED; /* number of times Tx halted (modem line low) */
162 unsigned short Rx_halt_RTS_low_count PACKED; /* number of times Rx halted by setting RTS low */
163 unsigned long reserved_handshaking_stat1 PACKED;/* reserved for later use */
164
165 /* break statistics */
166 unsigned short break_Tx_count PACKED; /* number of break sequences transmitted */
167 unsigned short break_Rx_count PACKED; /* number of break sequences received */
168 unsigned long reserved_break_stat1 PACKED;/* reserved for later use */
169
170 /* miscellaneous statistics */
171 unsigned long reserved_misc_stat1 PACKED; /* reserved for later use */
172 unsigned long reserved_misc_stat2 PACKED; /* reserved for later use */
173
174} ASY_OPERATIONAL_STATS_STRUCT;
175
176
177
178/* ----------------------------------------------------------------------------
179 * Constants for Data transmission
180 * --------------------------------------------------------------------------*/
181
182/* the Data block transmit status element configuration structure */
183typedef struct {
184 unsigned short number_Tx_status_elements PACKED; /* number of transmit status elements */
185 unsigned long base_addr_Tx_status_elements PACKED; /* base address of the transmit element list */
186 unsigned long next_Tx_status_element_to_use PACKED; /* pointer to the next transmit element to be used */
187} ASY_TX_STATUS_EL_CFG_STRUCT;
188
189
190/* the Data block transmit status element structure */
191typedef struct {
192 unsigned char opp_flag PACKED; /* opp flag */
193 unsigned short data_length PACKED; /* length of the block to be transmitted */
194 unsigned char reserved_1 PACKED; /* reserved for internal use */
195 unsigned long reserved_2 PACKED; /* reserved for internal use */
196 unsigned long reserved_3 PACKED; /* reserved for internal use */
197 unsigned long ptr_data_bfr PACKED; /* pointer to the data area */
198} ASY_DATA_TX_STATUS_EL_STRUCT;
199
200
201
202/* ----------------------------------------------------------------------------
203 * Constants for Data reception
204 * --------------------------------------------------------------------------*/
205
206/* the Data block receive status element configuration structure */
207typedef struct {
208 unsigned short number_Rx_status_elements PACKED;/* number of receive status elements */
209 unsigned long base_addr_Rx_status_elements PACKED;/* base address of the receive element list */
210 unsigned long next_Rx_status_element_to_use PACKED;/* pointer to the next receive element to be used */
211 unsigned long base_addr_Rx_buffer PACKED;/* base address of the receive data buffer */
212 unsigned long end_addr_Rx_buffer PACKED;/* end address of the receive data buffer */
213} ASY_RX_STATUS_EL_CFG_STRUCT;
214
215/* the Data block receive status element structure */
216typedef struct {
217 unsigned char opp_flag PACKED; /* opp flag */
218 unsigned short data_length PACKED; /* length of the received data block */
219 unsigned char reserved_1 PACKED; /* reserved for internal use */
220 unsigned short time_stamp PACKED; /* receive time stamp (HDLC_STREAMING_MODE) */
221 unsigned short data_buffered PACKED; /* the number of data bytes still buffered */
222 unsigned long reserved_2 PACKED; /* reserved for internal use */
223 unsigned long ptr_data_bfr PACKED; /* pointer to the data area */
224} ASY_DATA_RX_STATUS_EL_STRUCT;
225
226#endif
diff --git a/include/linux/sdla_chdlc.h b/include/linux/sdla_chdlc.h
new file mode 100644
index 000000000000..d2e35a299034
--- /dev/null
+++ b/include/linux/sdla_chdlc.h
@@ -0,0 +1,813 @@
1/*************************************************************************
2 sdla_chdlc.h Sangoma Cisco HDLC firmware API definitions
3
4 Author: Gideon Hack
5 Nenad Corbic <ncorbic@sangoma.com>
6
7 Copyright: (c) 1995-2000 Sangoma Technologies Inc.
8
9 This program is free software; you can redistribute it and/or
10 modify it under the term of the GNU General Public License
11 as published by the Free Software Foundation; either version
12 2 of the License, or (at your option) any later version.
13
14===========================================================================
15 Oct 04, 1999 Nenad Corbic Updated API support
16 Jun 02, 1999 Gideon Hack Changes for S514 usage.
17 Oct 28, 1998 Jaspreet Singh Made changes for Dual Port CHDLC.
18 Jun 11, 1998 David Fong Initial version.
19===========================================================================
20
21 Organization
22 - Compatibility notes
23 - Constants defining the shared memory control block (mailbox)
24 - Interface commands
25 - Return code from interface commands
26 - Constants for the commands (structures for casting data)
27 - UDP Management constants and structures
28
29*************************************************************************/
30
31#ifndef _SDLA_CHDLC_H
32# define _SDLC_CHDLC_H
33
34/*------------------------------------------------------------------------
35 Notes:
36
37 All structres defined in this file are byte-aligned.
38
39 Compiler Platform
40 ------------------------
41 GNU C Linux
42
43------------------------------------------------------------------------*/
44
45#ifndef PACKED
46#define PACKED __attribute__((packed))
47#endif /* PACKED */
48
49
50/* ----------------------------------------------------------------------------
51 * Constants defining the shared memory control block (mailbox)
52 * --------------------------------------------------------------------------*/
53
54#define PRI_BASE_ADDR_MB_STRUCT 0xE000 /* the base address of the mailbox structure on the adapter */
55#define SEC_BASE_ADDR_MB_STRUCT 0xE800 /* the base address of the mailbox structure on the adapter */
56#define SIZEOF_MB_DATA_BFR 2032 /* the size of the actual mailbox data area */
57#define NUMBER_MB_RESERVED_BYTES 0x0B /* the number of reserved bytes in the mailbox header area */
58
59
60#define MIN_LGTH_CHDLC_DATA_CFG 300 /* min length of the CHDLC data field (for configuration purposes) */
61#define PRI_MAX_NO_DATA_BYTES_IN_FRAME 15354 /* PRIMARY - max length of the CHDLC data field */
62
63typedef struct {
64 unsigned char opp_flag PACKED; /* the opp flag */
65 unsigned char command PACKED; /* the user command */
66 unsigned short buffer_length PACKED; /* the data length */
67 unsigned char return_code PACKED; /* the return code */
68 unsigned char MB_reserved[NUMBER_MB_RESERVED_BYTES] PACKED; /* reserved for later */
69 unsigned char data[SIZEOF_MB_DATA_BFR] PACKED; /* the data area */
70} CHDLC_MAILBOX_STRUCT;
71
72typedef struct {
73 pid_t pid_num PACKED;
74 CHDLC_MAILBOX_STRUCT cmdarea PACKED;
75
76} CMDBLOCK_STRUCT;
77
78
79
80
81/* ----------------------------------------------------------------------------
82 * Interface commands
83 * --------------------------------------------------------------------------*/
84
85/* global interface commands */
86#define READ_GLOBAL_EXCEPTION_CONDITION 0x01
87#define SET_GLOBAL_CONFIGURATION 0x02
88#define READ_GLOBAL_CONFIGURATION 0x03
89#define READ_GLOBAL_STATISTICS 0x04
90#define FLUSH_GLOBAL_STATISTICS 0x05
91#define SET_MODEM_STATUS 0x06 /* set status of DTR or RTS */
92#define READ_MODEM_STATUS 0x07 /* read status of CTS and DCD */
93#define READ_COMMS_ERROR_STATS 0x08
94#define FLUSH_COMMS_ERROR_STATS 0x09
95#define SET_TRACE_CONFIGURATION 0x0A /* set the line trace config */
96#define READ_TRACE_CONFIGURATION 0x0B /* read the line trace config */
97#define READ_TRACE_STATISTICS 0x0C /* read the trace statistics */
98#define FLUSH_TRACE_STATISTICS 0x0D /* flush the trace statistics */
99#define FT1_MONITOR_STATUS_CTRL 0x1C /* set the status of the S508/FT1 monitoring */
100#define SET_FT1_CONFIGURATION 0x18 /* set the FT1 configuration */
101#define READ_FT1_CONFIGURATION 0x19 /* read the FT1 configuration */
102#define TRANSMIT_ASYNC_DATA_TO_FT1 0x1A /* output asynchronous data to the FT1 */
103#define RECEIVE_ASYNC_DATA_FROM_FT1 0x1B /* receive asynchronous data from the FT1 */
104#define FT1_MONITOR_STATUS_CTRL 0x1C /* set the status of the FT1 monitoring */
105
106#define READ_FT1_OPERATIONAL_STATS 0x1D /* read the S508/FT1 operational statistics */
107#define SET_FT1_MODE 0x1E /* set the operational mode of the S508/FT1 module */
108
109/* CHDLC-level interface commands */
110#define READ_CHDLC_CODE_VERSION 0x20
111#define READ_CHDLC_EXCEPTION_CONDITION 0x21 /* read exception condition from the adapter */
112#define SET_CHDLC_CONFIGURATION 0x22
113#define READ_CHDLC_CONFIGURATION 0x23
114#define ENABLE_CHDLC_COMMUNICATIONS 0x24
115#define DISABLE_CHDLC_COMMUNICATIONS 0x25
116#define READ_CHDLC_LINK_STATUS 0x26
117#define READ_CHDLC_OPERATIONAL_STATS 0x27
118#define FLUSH_CHDLC_OPERATIONAL_STATS 0x28
119#define SET_CHDLC_INTERRUPT_TRIGGERS 0x30 /* set application interrupt triggers */
120#define READ_CHDLC_INTERRUPT_TRIGGERS 0x31 /* read application interrupt trigger configuration */
121
122/* Special UDP drivers management commands */
123#define CPIPE_ENABLE_TRACING 0x50
124#define CPIPE_DISABLE_TRACING 0x51
125#define CPIPE_GET_TRACE_INFO 0x52
126#define CPIPE_GET_IBA_DATA 0x53
127#define CPIPE_FT1_READ_STATUS 0x54
128#define CPIPE_DRIVER_STAT_IFSEND 0x55
129#define CPIPE_DRIVER_STAT_INTR 0x56
130#define CPIPE_DRIVER_STAT_GEN 0x57
131#define CPIPE_FLUSH_DRIVER_STATS 0x58
132#define CPIPE_ROUTER_UP_TIME 0x59
133
134/* Driver specific commands for API */
135#define CHDLC_READ_TRACE_DATA 0xE4 /* read trace data */
136#define TRACE_ALL 0x00
137#define TRACE_PROT 0x01
138#define TRACE_DATA 0x02
139
140#define DISCARD_RX_ERROR_FRAMES 0x0001
141
142/* ----------------------------------------------------------------------------
143 * Return codes from interface commands
144 * --------------------------------------------------------------------------*/
145
146#define COMMAND_OK 0x00
147
148/* return codes from global interface commands */
149#define NO_GLOBAL_EXCEP_COND_TO_REPORT 0x01 /* there is no CHDLC exception condition to report */
150#define LGTH_GLOBAL_CFG_DATA_INVALID 0x01 /* the length of the passed global configuration data is invalid */
151#define LGTH_TRACE_CFG_DATA_INVALID 0x01 /* the length of the passed trace configuration data is invalid */
152#define IRQ_TIMEOUT_VALUE_INVALID 0x02 /* an invalid application IRQ timeout value was selected */
153#define TRACE_CONFIG_INVALID 0x02 /* the passed line trace configuration is invalid */
154#define ADAPTER_OPERATING_FREQ_INVALID 0x03 /* an invalid adapter operating frequency was selected */
155#define TRC_DEAC_TMR_INVALID 0x03 /* the trace deactivation timer is invalid */
156#define S508_FT1_ADPTR_NOT_PRESENT 0x0C /* the S508/FT1 adapter is not present */
157#define INVALID_FT1_STATUS_SELECTION 0x0D /* the S508/FT1 status selection is invalid */
158#define FT1_OP_STATS_NOT_ENABLED 0x0D /* the FT1 operational statistics have not been enabled */
159#define FT1_OP_STATS_NOT_AVAILABLE 0x0E /* the FT1 operational statistics are not currently available */
160#define S508_FT1_MODE_SELECTION_BUSY 0x0E /* the S508/FT1 adapter is busy selecting the operational mode */
161
162/* return codes from command READ_GLOBAL_EXCEPTION_CONDITION */
163#define EXCEP_MODEM_STATUS_CHANGE 0x10 /* a modem status change occurred */
164#define EXCEP_TRC_DISABLED 0x11 /* the trace has been disabled */
165#define EXCEP_IRQ_TIMEOUT 0x12 /* IRQ timeout */
166
167/* return codes from CHDLC-level interface commands */
168#define NO_CHDLC_EXCEP_COND_TO_REPORT 0x21 /* there is no CHDLC exception condition to report */
169#define CHDLC_COMMS_DISABLED 0x21 /* communications are not currently enabled */
170#define CHDLC_COMMS_ENABLED 0x21 /* communications are currently enabled */
171#define DISABLE_CHDLC_COMMS_BEFORE_CFG 0x21 /* CHDLC communications must be disabled before setting the configuration */
172#define ENABLE_CHDLC_COMMS_BEFORE_CONN 0x21 /* communications must be enabled before using the CHDLC_CONNECT conmmand */
173#define CHDLC_CFG_BEFORE_COMMS_ENABLED 0x22 /* perform a SET_CHDLC_CONFIGURATION before enabling comms */
174#define LGTH_CHDLC_CFG_DATA_INVALID 0x22 /* the length of the passed CHDLC configuration data is invalid */
175#define LGTH_INT_TRIGGERS_DATA_INVALID 0x22 /* the length of the passed interrupt trigger data is invalid */
176#define INVALID_IRQ_SELECTED 0x23 /* in invalid IRQ was selected in the SET_CHDLC_INTERRUPT_TRIGGERS */
177#define INVALID_CHDLC_CFG_DATA 0x23 /* the passed CHDLC configuration data is invalid */
178#define IRQ_TMR_VALUE_INVALID 0x24 /* an invalid application IRQ timer value was selected */
179#define LARGER_PERCENT_TX_BFR_REQUIRED 0x24 /* a larger Tx buffer percentage is required */
180#define LARGER_PERCENT_RX_BFR_REQUIRED 0x25 /* a larger Rx buffer percentage is required */
181#define S514_BOTH_PORTS_SAME_CLK_MODE 0x26 /* S514 - both ports must have same clock mode */
182#define INVALID_CMND_HDLC_STREAM_MODE 0x4E /* the CHDLC interface command is invalid for HDLC streaming mode */
183#define INVALID_CHDLC_COMMAND 0x4F /* the defined CHDLC interface command is invalid */
184
185/* return codes from command READ_CHDLC_EXCEPTION_CONDITION */
186#define EXCEP_LINK_ACTIVE 0x30 /* the CHDLC link has become active */
187#define EXCEP_LINK_INACTIVE_MODEM 0x31 /* the CHDLC link has become inactive (modem status) */
188#define EXCEP_LINK_INACTIVE_KPALV 0x32 /* the CHDLC link has become inactive (keepalive status) */
189#define EXCEP_IP_ADDRESS_DISCOVERED 0x33 /* the IP address has been discovered */
190#define EXCEP_LOOPBACK_CONDITION 0x34 /* a loopback condition has occurred */
191
192
193/* return code from command CHDLC_SEND_WAIT and CHDLC_SEND_NO_WAIT */
194#define LINK_DISCONNECTED 0x21
195#define NO_TX_BFRS_AVAIL 0x24
196
197
198/* ----------------------------------------------------------------------------
199 * Constants for the SET_GLOBAL_CONFIGURATION/READ_GLOBAL_CONFIGURATION commands
200 * --------------------------------------------------------------------------*/
201
202/* the global configuration structure */
203typedef struct {
204 unsigned short adapter_config_options PACKED; /* adapter config options */
205 unsigned short app_IRQ_timeout PACKED; /* application IRQ timeout */
206 unsigned long adapter_operating_frequency PACKED; /* adapter operating frequency */
207} GLOBAL_CONFIGURATION_STRUCT;
208
209/* settings for the 'app_IRQ_timeout' */
210#define MAX_APP_IRQ_TIMEOUT_VALUE 5000 /* the maximum permitted IRQ timeout */
211
212
213
214/* ----------------------------------------------------------------------------
215 * Constants for the READ_GLOBAL_STATISTICS command
216 * --------------------------------------------------------------------------*/
217
218/* the global statistics structure */
219typedef struct {
220 unsigned short app_IRQ_timeout_count PACKED;
221} GLOBAL_STATS_STRUCT;
222
223
224
225/* ----------------------------------------------------------------------------
226 * Constants for the READ_COMMS_ERROR_STATS command
227 * --------------------------------------------------------------------------*/
228
229/* the communications error statistics structure */
230typedef struct {
231 unsigned short Rx_overrun_err_count PACKED;
232 unsigned short CRC_err_count PACKED; /* receiver CRC error count */
233 unsigned short Rx_abort_count PACKED; /* abort frames recvd count */
234 unsigned short Rx_dis_pri_bfrs_full_count PACKED;/* receiver disabled */
235 unsigned short comms_err_stat_reserved_1 PACKED;/* reserved for later */
236 unsigned short sec_Tx_abort_msd_Tx_int_count PACKED; /* secondary - abort frames transmitted count (missed Tx interrupt) */
237 unsigned short missed_Tx_und_int_count PACKED; /* missed tx underrun interrupt count */
238 unsigned short sec_Tx_abort_count PACKED; /*secondary-abort frames tx count */
239 unsigned short DCD_state_change_count PACKED; /* DCD state change */
240 unsigned short CTS_state_change_count PACKED; /* CTS state change */
241} COMMS_ERROR_STATS_STRUCT;
242
243
244
245/* ----------------------------------------------------------------------------
246 * Constants used for line tracing
247 * --------------------------------------------------------------------------*/
248
249/* the trace configuration structure (SET_TRACE_CONFIGURATION/READ_TRACE_CONFIGURATION commands) */
250typedef struct {
251 unsigned char trace_config PACKED; /* trace configuration */
252 unsigned short trace_deactivation_timer PACKED; /* trace deactivation timer */
253 unsigned long ptr_trace_stat_el_cfg_struct PACKED; /* a pointer to the line trace element configuration structure */
254} LINE_TRACE_CONFIG_STRUCT;
255
256/* 'trace_config' bit settings */
257#define TRACE_INACTIVE 0x00 /* trace is inactive */
258#define TRACE_ACTIVE 0x01 /* trace is active */
259#define TRACE_DELAY_MODE 0x04 /* operate the trace in delay mode */
260#define TRACE_DATA_FRAMES 0x08 /* trace Data frames */
261#define TRACE_SLARP_FRAMES 0x10 /* trace SLARP frames */
262#define TRACE_CDP_FRAMES 0x20 /* trace CDP frames */
263
264/* the line trace status element configuration structure */
265typedef struct {
266 unsigned short number_trace_status_elements PACKED; /* number of line trace elements */
267 unsigned long base_addr_trace_status_elements PACKED; /* base address of the trace element list */
268 unsigned long next_trace_element_to_use PACKED; /* pointer to the next trace element to be used */
269 unsigned long base_addr_trace_buffer PACKED; /* base address of the trace data buffer */
270 unsigned long end_addr_trace_buffer PACKED; /* end address of the trace data buffer */
271} TRACE_STATUS_EL_CFG_STRUCT;
272
273/* the line trace status element structure */
274typedef struct {
275 unsigned char opp_flag PACKED; /* opp flag */
276 unsigned short trace_length PACKED; /* trace length */
277 unsigned char trace_type PACKED; /* trace type */
278 unsigned short trace_time_stamp PACKED; /* time stamp */
279 unsigned short trace_reserved_1 PACKED; /* reserved for later use */
280 unsigned long trace_reserved_2 PACKED; /* reserved for later use */
281 unsigned long ptr_data_bfr PACKED; /* ptr to the trace data buffer */
282} TRACE_STATUS_ELEMENT_STRUCT;
283
284/* "trace_type" bit settings */
285#define TRACE_INCOMING 0x00
286#define TRACE_OUTGOINGING 0x01
287#define TRACE_INCOMING_ABORTED 0x10
288#define TRACE_INCOMING_CRC_ERROR 0x20
289#define TRACE_INCOMING_OVERRUN_ERROR 0x40
290
291
292
293/* the line trace statistics structure */
294typedef struct {
295 unsigned long frames_traced_count PACKED; /* number of frames traced */
296 unsigned long trc_frms_not_recorded_count PACKED; /* number of trace frames discarded */
297} LINE_TRACE_STATS_STRUCT;
298
299
300/* ----------------------------------------------------------------------------
301 * Constants for the FT1_MONITOR_STATUS_CTRL command
302 * --------------------------------------------------------------------------*/
303
304#define DISABLE_FT1_STATUS_STATISTICS 0x00 /* disable the FT1 status and statistics monitoring */
305#define ENABLE_READ_FT1_STATUS 0x01 /* read the FT1 operational status */
306#define ENABLE_READ_FT1_OP_STATS 0x02 /* read the FT1 operational statistics */
307#define FLUSH_FT1_OP_STATS 0x04 /* flush the FT1 operational statistics */
308
309
310
311
312/* ----------------------------------------------------------------------------
313 * Constants for the SET_CHDLC_CONFIGURATION command
314 * --------------------------------------------------------------------------*/
315
316/* the CHDLC configuration structure */
317typedef struct {
318 unsigned long baud_rate PACKED; /* the baud rate */
319 unsigned short line_config_options PACKED; /* line configuration options */
320 unsigned short modem_config_options PACKED; /* modem configration options */
321 unsigned short modem_status_timer PACKED; /* timer for monitoring modem status changes */
322 unsigned short CHDLC_API_options PACKED; /* CHDLC API options */
323 unsigned short CHDLC_protocol_options PACKED; /* CHDLC protocol options */
324 unsigned short percent_data_buffer_for_Tx PACKED; /* percentage data buffering used for Tx */
325 unsigned short CHDLC_statistics_options PACKED; /* CHDLC operational statistics options */
326 unsigned short max_CHDLC_data_field_length PACKED; /* the maximum length of the CHDLC Data field */
327 unsigned short transmit_keepalive_timer PACKED; /* the transmit keepalive timer */
328 unsigned short receive_keepalive_timer PACKED; /* the receive keepalive timer */
329 unsigned short keepalive_error_tolerance PACKED; /* the receive keepalive error tolerance */
330 unsigned short SLARP_request_timer PACKED; /* the SLARP request timer */
331 unsigned long IP_address PACKED; /* the IP address */
332 unsigned long IP_netmask PACKED; /* the IP netmask */
333 unsigned long ptr_shared_mem_info_struct PACKED; /* a pointer to the shared memory area information structure */
334 unsigned long ptr_CHDLC_Tx_stat_el_cfg_struct PACKED; /* a pointer to the transmit status element configuration structure */
335 unsigned long ptr_CHDLC_Rx_stat_el_cfg_struct PACKED; /* a pointer to the receive status element configuration structure */
336} CHDLC_CONFIGURATION_STRUCT;
337
338/* settings for the 'line_config_options' */
339#define INTERFACE_LEVEL_V35 0x0000 /* V.35 interface level */
340#define INTERFACE_LEVEL_RS232 0x0001 /* RS-232 interface level */
341
342/* settings for the 'modem_config_options' */
343
344#define DONT_RAISE_DTR_RTS_ON_EN_COMMS 0x0001
345/* don't automatically raise DTR and RTS when performing an
346 ENABLE_CHDLC_COMMUNICATIONS command */
347
348#define DONT_REPORT_CHG_IN_MODEM_STAT 0x0002
349/* don't report changes in modem status to the application */
350
351
352/* bit settings for the 'CHDLC_protocol_options' byte */
353
354#define IGNORE_DCD_FOR_LINK_STAT 0x0001
355/* ignore DCD in determining the CHDLC link status */
356
357#define IGNORE_CTS_FOR_LINK_STAT 0x0002
358/* ignore CTS in determining the CHDLC link status */
359
360#define IGNORE_KPALV_FOR_LINK_STAT 0x0004
361/* ignore keepalive frames in determining the CHDLC link status */
362
363#define SINGLE_TX_BUFFER 0x4000
364/* configure a single transmit buffer */
365
366#define HDLC_STREAMING_MODE 0x8000
367
368/* settings for the 'CHDLC_statistics_options' */
369
370#define CHDLC_TX_DATA_BYTE_COUNT_STAT 0x0001
371/* record the number of Data bytes transmitted */
372
373#define CHDLC_RX_DATA_BYTE_COUNT_STAT 0x0002
374/* record the number of Data bytes received */
375
376#define CHDLC_TX_THROUGHPUT_STAT 0x0004
377/* compute the Data frame transmit throughput */
378
379#define CHDLC_RX_THROUGHPUT_STAT 0x0008
380/* compute the Data frame receive throughput */
381
382
383/* permitted minimum and maximum values for setting the CHDLC configuration */
384#define PRI_MAX_BAUD_RATE_S508 2666666 /* PRIMARY - maximum baud rate (S508) */
385#define SEC_MAX_BAUD_RATE_S508 258064 /* SECONDARY - maximum baud rate (S508) */
386#define PRI_MAX_BAUD_RATE_S514 2750000 /* PRIMARY - maximum baud rate (S508) */
387#define SEC_MAX_BAUD_RATE_S514 515625 /* SECONDARY - maximum baud rate (S508) */
388
389#define MIN_MODEM_TIMER 0 /* minimum modem status timer */
390#define MAX_MODEM_TIMER 5000 /* maximum modem status timer */
391
392#define SEC_MAX_NO_DATA_BYTES_IN_FRAME 2048 /* SECONDARY - max length of the CHDLC data field */
393
394#define MIN_Tx_KPALV_TIMER 0 /* minimum transmit keepalive timer */
395#define MAX_Tx_KPALV_TIMER 60000 /* maximum transmit keepalive timer */
396#define DEFAULT_Tx_KPALV_TIMER 10000 /* default transmit keepalive timer */
397
398#define MIN_Rx_KPALV_TIMER 10 /* minimum receive keepalive timer */
399#define MAX_Rx_KPALV_TIMER 60000 /* maximum receive keepalive timer */
400#define DEFAULT_Rx_KPALV_TIMER 10000 /* default receive keepalive timer */
401
402#define MIN_KPALV_ERR_TOL 1 /* min kpalv error tolerance count */
403#define MAX_KPALV_ERR_TOL 20 /* max kpalv error tolerance count */
404#define DEFAULT_KPALV_ERR_TOL 3 /* default value */
405
406#define MIN_SLARP_REQ_TIMER 0 /* min transmit SLARP Request timer */
407#define MAX_SLARP_REQ_TIMER 60000 /* max transmit SLARP Request timer */
408#define DEFAULT_SLARP_REQ_TIMER 0 /* default value -- no SLARP */
409
410
411
412/* ----------------------------------------------------------------------------
413 * Constants for the READ_CHDLC_LINK_STATUS command
414 * --------------------------------------------------------------------------*/
415
416/* the CHDLC status structure */
417typedef struct {
418 unsigned char CHDLC_link_status PACKED; /* CHDLC link status */
419 unsigned char no_Data_frms_for_app PACKED; /* number of Data frames available for the application */
420 unsigned char receiver_status PACKED; /* enabled/disabled */
421 unsigned char SLARP_state PACKED; /* internal SLARP state */
422} CHDLC_LINK_STATUS_STRUCT;
423
424/* settings for the 'CHDLC_link_status' variable */
425#define CHDLC_LINK_INACTIVE 0x00 /* the CHDLC link is inactive */
426#define CHDLC_LINK_ACTIVE 0x01 /* the CHDLC link is active */
427
428
429
430/* ----------------------------------------------------------------------------
431 * Constants for the READ_CHDLC_OPERATIONAL_STATS command
432 * --------------------------------------------------------------------------*/
433
434/* the CHDLC operational statistics structure */
435typedef struct {
436
437 /* Data frame transmission statistics */
438 unsigned long Data_frames_Tx_count PACKED; /* # of frames transmitted */
439 unsigned long Data_bytes_Tx_count PACKED; /* # of bytes transmitted */
440 unsigned long Data_Tx_throughput PACKED; /* transmit throughput */
441 unsigned long no_ms_for_Data_Tx_thruput_comp PACKED; /* millisecond time used for the Tx throughput computation */
442 unsigned long Tx_Data_discard_lgth_err_count PACKED; /* number of Data frames discarded (length error) */
443 unsigned long reserved_Data_frm_Tx_stat1 PACKED; /* reserved for later */
444 unsigned long reserved_Data_frm_Tx_stat2 PACKED; /* reserved for later */
445 unsigned long reserved_Data_frm_Tx_stat3 PACKED; /* reserved for later */
446
447 /* Data frame reception statistics */
448 unsigned long Data_frames_Rx_count PACKED; /* number of frames received */
449 unsigned long Data_bytes_Rx_count PACKED; /* number of bytes received */
450 unsigned long Data_Rx_throughput PACKED; /* receive throughput */
451 unsigned long no_ms_for_Data_Rx_thruput_comp PACKED; /* millisecond time used for the Rx throughput computation */
452 unsigned long Rx_Data_discard_short_count PACKED; /* received Data frames discarded (too short) */
453 unsigned long Rx_Data_discard_long_count PACKED; /* received Data frames discarded (too long) */
454 unsigned long Rx_Data_discard_inactive_count PACKED; /* received Data frames discarded (link inactive) */
455 unsigned long reserved_Data_frm_Rx_stat1 PACKED; /* reserved for later */
456
457 /* SLARP frame transmission/reception statistics */
458 unsigned long CHDLC_SLARP_REQ_Tx_count PACKED; /* number of SLARP Request frames transmitted */
459 unsigned long CHDLC_SLARP_REQ_Rx_count PACKED; /* number of SLARP Request frames received */
460 unsigned long CHDLC_SLARP_REPLY_Tx_count PACKED; /* number of SLARP Reply frames transmitted */
461 unsigned long CHDLC_SLARP_REPLY_Rx_count PACKED; /* number of SLARP Reply frames received */
462 unsigned long CHDLC_SLARP_KPALV_Tx_count PACKED; /* number of SLARP keepalive frames transmitted */
463 unsigned long CHDLC_SLARP_KPALV_Rx_count PACKED; /* number of SLARP keepalive frames received */
464 unsigned long reserved_SLARP_stat1 PACKED; /* reserved for later */
465 unsigned long reserved_SLARP_stat2 PACKED; /* reserved for later */
466
467 /* CDP frame transmission/reception statistics */
468 unsigned long CHDLC_CDP_Tx_count PACKED; /* number of CDP frames transmitted */
469 unsigned long CHDLC_CDP_Rx_count PACKED; /* number of CDP frames received */
470 unsigned long reserved_CDP_stat1 PACKED; /* reserved for later */
471 unsigned long reserved_CDP_stat2 PACKED; /* reserved for later */
472 unsigned long reserved_CDP_stat3 PACKED; /* reserved for later */
473 unsigned long reserved_CDP_stat4 PACKED; /* reserved for later */
474 unsigned long reserved_CDP_stat5 PACKED; /* reserved for later */
475 unsigned long reserved_CDP_stat6 PACKED; /* reserved for later */
476
477 /* Incoming frames with a format error statistics */
478 unsigned short Rx_frm_incomp_CHDLC_hdr_count PACKED; /* frames received of with incomplete Cisco HDLC header */
479 unsigned short Rx_frms_too_long_count PACKED; /* frames received of excessive length count */
480 unsigned short Rx_invalid_CHDLC_addr_count PACKED; /* frames received with an invalid CHDLC address count */
481 unsigned short Rx_invalid_CHDLC_ctrl_count PACKED; /* frames received with an invalid CHDLC control field count */
482 unsigned short Rx_invalid_CHDLC_type_count PACKED; /* frames received of an invalid CHDLC frame type count */
483 unsigned short Rx_SLARP_invalid_code_count PACKED; /* SLARP frame received with an invalid packet code */
484 unsigned short Rx_SLARP_Reply_bad_IP_addr PACKED; /* SLARP Reply received - bad IP address */
485 unsigned short Rx_SLARP_Reply_bad_netmask PACKED; /* SLARP Reply received - bad netmask */
486 unsigned long reserved_frm_format_err1 PACKED; /* reserved for later */
487 unsigned long reserved_frm_format_err2 PACKED; /* reserved for later */
488 unsigned long reserved_frm_format_err3 PACKED; /* reserved for later */
489 unsigned long reserved_frm_format_err4 PACKED; /* reserved for later */
490
491 /* CHDLC timeout/retry statistics */
492 unsigned short SLARP_Rx_keepalive_TO_count PACKED; /* timeout count for incoming SLARP frames */
493 unsigned short SLARP_Request_TO_count PACKED; /* timeout count for SLARP Request frames */
494 unsigned long To_retry_reserved_stat1 PACKED; /* reserved for later */
495 unsigned long To_retry_reserved_stat2 PACKED; /* reserved for later */
496 unsigned long To_retry_reserved_stat3 PACKED; /* reserved for later */
497
498 /* CHDLC link active/inactive and loopback statistics */
499 unsigned short link_active_count PACKED; /* number of times that the link went active */
500 unsigned short link_inactive_modem_count PACKED; /* number of times that the link went inactive (modem failure) */
501 unsigned short link_inactive_keepalive_count PACKED; /* number of times that the link went inactive (keepalive failure) */
502 unsigned short link_looped_count PACKED; /* link looped count */
503 unsigned long link_status_reserved_stat1 PACKED; /* reserved for later use */
504 unsigned long link_status_reserved_stat2 PACKED; /* reserved for later use */
505
506 /* miscellaneous statistics */
507 unsigned long reserved_misc_stat1 PACKED; /* reserved for later */
508 unsigned long reserved_misc_stat2 PACKED; /* reserved for later */
509 unsigned long reserved_misc_stat3 PACKED; /* reserved for later */
510 unsigned long reserved_misc_stat4 PACKED; /* reserved for later */
511
512} CHDLC_OPERATIONAL_STATS_STRUCT;
513
514
515
516/* ----------------------------------------------------------------------------
517 * Constants for using application interrupts
518 * --------------------------------------------------------------------------*/
519
520/* the structure used for the SET_CHDLC_INTERRUPT_TRIGGERS/READ_CHDLC_INTERRUPT_TRIGGERS command */
521typedef struct {
522 unsigned char CHDLC_interrupt_triggers PACKED; /* CHDLC interrupt trigger configuration */
523 unsigned char IRQ PACKED; /* IRQ to be used */
524 unsigned short interrupt_timer PACKED; /* interrupt timer */
525 unsigned short misc_interrupt_bits PACKED; /* miscellaneous bits */
526} CHDLC_INT_TRIGGERS_STRUCT;
527
528/* 'CHDLC_interrupt_triggers' bit settings */
529#define APP_INT_ON_RX_FRAME 0x01 /* interrupt on Data frame reception */
530#define APP_INT_ON_TX_FRAME 0x02 /* interrupt when an Data frame may be transmitted */
531#define APP_INT_ON_COMMAND_COMPLETE 0x04 /* interrupt when an interface command is complete */
532#define APP_INT_ON_TIMER 0x08 /* interrupt on a defined millisecond timeout */
533#define APP_INT_ON_GLOBAL_EXCEP_COND 0x10 /* interrupt on a global exception condition */
534#define APP_INT_ON_CHDLC_EXCEP_COND 0x20 /* interrupt on an CHDLC exception condition */
535#define APP_INT_ON_TRACE_DATA_AVAIL 0x80 /* interrupt when trace data is available */
536
537/* interrupt types indicated at 'interrupt_type' byte of the INTERRUPT_INFORMATION_STRUCT */
538#define NO_APP_INTS_PEND 0x00 /* no interrups are pending */
539#define RX_APP_INT_PEND 0x01 /* a receive interrupt is pending */
540#define TX_APP_INT_PEND 0x02 /* a transmit interrupt is pending */
541#define COMMAND_COMPLETE_APP_INT_PEND 0x04 /* a 'command complete' interrupt is pending */
542#define TIMER_APP_INT_PEND 0x08 /* a timer interrupt is pending */
543#define GLOBAL_EXCEP_COND_APP_INT_PEND 0x10 /* a global exception condition interrupt is pending */
544#define CHDLC_EXCEP_COND_APP_INT_PEND 0x20 /* an CHDLC exception condition interrupt is pending */
545#define TRACE_DATA_AVAIL_APP_INT_PEND 0x80 /* a trace data available interrupt is pending */
546
547
548/* modem status changes */
549#define DCD_HIGH 0x08
550#define CTS_HIGH 0x20
551
552
553/* ----------------------------------------------------------------------------
554 * Constants for Data frame transmission
555 * --------------------------------------------------------------------------*/
556
557/* the Data frame transmit status element configuration structure */
558typedef struct {
559 unsigned short number_Tx_status_elements PACKED; /* number of transmit status elements */
560 unsigned long base_addr_Tx_status_elements PACKED; /* base address of the transmit element list */
561 unsigned long next_Tx_status_element_to_use PACKED; /* pointer to the next transmit element to be used */
562} CHDLC_TX_STATUS_EL_CFG_STRUCT;
563
564/* the Data frame transmit status element structure */
565typedef struct {
566 unsigned char opp_flag PACKED; /* opp flag */
567 unsigned short frame_length PACKED; /* length of the frame to be transmitted */
568 unsigned char reserved_1 PACKED; /* reserved for internal use */
569 unsigned long reserved_2 PACKED; /* reserved for internal use */
570 unsigned long reserved_3 PACKED; /* reserved for internal use */
571 unsigned long ptr_data_bfr PACKED; /* pointer to the data area */
572} CHDLC_DATA_TX_STATUS_EL_STRUCT;
573
574
575
576/* ----------------------------------------------------------------------------
577 * Constants for Data frame reception
578 * --------------------------------------------------------------------------*/
579
580/* the Data frame receive status element configuration structure */
581typedef struct {
582 unsigned short number_Rx_status_elements PACKED; /* number of receive status elements */
583 unsigned long base_addr_Rx_status_elements PACKED; /* base address of the receive element list */
584 unsigned long next_Rx_status_element_to_use PACKED; /* pointer to the next receive element to be used */
585 unsigned long base_addr_Rx_buffer PACKED; /* base address of the receive data buffer */
586 unsigned long end_addr_Rx_buffer PACKED; /* end address of the receive data buffer */
587} CHDLC_RX_STATUS_EL_CFG_STRUCT;
588
589/* the Data frame receive status element structure */
590typedef struct {
591 unsigned char opp_flag PACKED; /* opp flag */
592 unsigned short frame_length PACKED; /* length of the received frame */
593 unsigned char error_flag PACKED; /* frame errors (HDLC_STREAMING_MODE)*/
594 unsigned short time_stamp PACKED; /* receive time stamp (HDLC_STREAMING_MODE) */
595 unsigned long reserved_1 PACKED; /* reserved for internal use */
596 unsigned short reserved_2 PACKED; /* reserved for internal use */
597 unsigned long ptr_data_bfr PACKED; /* pointer to the data area */
598} CHDLC_DATA_RX_STATUS_EL_STRUCT;
599
600
601
602/* ----------------------------------------------------------------------------
603 * Constants defining the shared memory information area
604 * --------------------------------------------------------------------------*/
605
606/* the global information structure */
607typedef struct {
608 unsigned char global_status PACKED; /* global status */
609 unsigned char modem_status PACKED; /* current modem status */
610 unsigned char global_excep_conditions PACKED; /* global exception conditions */
611 unsigned char glob_info_reserved[5] PACKED; /* reserved */
612 unsigned char codename[4] PACKED; /* Firmware name */
613 unsigned char codeversion[4] PACKED; /* Firmware version */
614} GLOBAL_INFORMATION_STRUCT;
615
616/* the CHDLC information structure */
617typedef struct {
618 unsigned char CHDLC_status PACKED; /* CHDLC status */
619 unsigned char CHDLC_excep_conditions PACKED; /* CHDLC exception conditions */
620 unsigned char CHDLC_info_reserved[14] PACKED; /* reserved */
621} CHDLC_INFORMATION_STRUCT;
622
623/* the interrupt information structure */
624typedef struct {
625 unsigned char interrupt_type PACKED; /* type of interrupt triggered */
626 unsigned char interrupt_permission PACKED; /* interrupt permission mask */
627 unsigned char int_info_reserved[14] PACKED; /* reserved */
628} INTERRUPT_INFORMATION_STRUCT;
629
630/* the S508/FT1 information structure */
631typedef struct {
632 unsigned char parallel_port_A_input PACKED; /* input - parallel port A */
633 unsigned char parallel_port_B_input PACKED; /* input - parallel port B */
634 unsigned char FT1_info_reserved[14] PACKED; /* reserved */
635} FT1_INFORMATION_STRUCT;
636
637/* the shared memory area information structure */
638typedef struct {
639 GLOBAL_INFORMATION_STRUCT global_info_struct PACKED; /* the global information structure */
640 CHDLC_INFORMATION_STRUCT CHDLC_info_struct PACKED; /* the CHDLC information structure */
641 INTERRUPT_INFORMATION_STRUCT interrupt_info_struct PACKED; /* the interrupt information structure */
642 FT1_INFORMATION_STRUCT FT1_info_struct PACKED; /* the S508/FT1 information structure */
643} SHARED_MEMORY_INFO_STRUCT;
644
645/* ----------------------------------------------------------------------------
646 * UDP Management constants and structures
647 * --------------------------------------------------------------------------*/
648
649/* The embedded control block for UDP mgmt
650 This is essentially a mailbox structure, without the large data field */
651
652typedef struct {
653 unsigned char opp_flag PACKED; /* the opp flag */
654 unsigned char command PACKED; /* the user command */
655 unsigned short buffer_length PACKED; /* the data length */
656 unsigned char return_code PACKED; /* the return code */
657 unsigned char MB_reserved[NUMBER_MB_RESERVED_BYTES] PACKED; /* reserved for later */
658} cblock_t;
659
660
661/* UDP management packet layout (data area of ip packet) */
662/*
663typedef struct {
664 unsigned char signature[8] PACKED;
665 unsigned char request_reply PACKED;
666 unsigned char id PACKED;
667 unsigned char reserved[6] PACKED;
668 cblock_t cblock PACKED;
669 unsigned char num_frames PACKED;
670 unsigned char ismoredata PACKED;
671 unsigned char data[SIZEOF_MB_DATA_BFR] PACKED;
672} udp_management_packet_t;
673
674*/
675
676typedef struct {
677 unsigned char num_frames PACKED;
678 unsigned char ismoredata PACKED;
679} trace_info_t;
680
681typedef struct {
682 ip_pkt_t ip_pkt PACKED;
683 udp_pkt_t udp_pkt PACKED;
684 wp_mgmt_t wp_mgmt PACKED;
685 cblock_t cblock PACKED;
686 trace_info_t trace_info PACKED;
687 unsigned char data[SIZEOF_MB_DATA_BFR] PACKED;
688} chdlc_udp_pkt_t;
689
690typedef struct ft1_exec_cmd{
691 unsigned char command PACKED; /* the user command */
692 unsigned short buffer_length PACKED; /* the data length */
693 unsigned char return_code PACKED; /* the return code */
694 unsigned char MB_reserved[NUMBER_MB_RESERVED_BYTES] PACKED;
695} ft1_exec_cmd_t;
696
697typedef struct {
698 unsigned char opp_flag PACKED;
699 ft1_exec_cmd_t cmd PACKED;
700 unsigned char data[SIZEOF_MB_DATA_BFR] PACKED;
701} ft1_exec_t;
702
703#define UDPMGMT_SIGNATURE "CTPIPEAB"
704
705
706/* UDP/IP packet (for UDP management) layout */
707/*
708typedef struct {
709 unsigned char reserved[2] PACKED;
710 unsigned short ip_length PACKED;
711 unsigned char reserved2[4] PACKED;
712 unsigned char ip_ttl PACKED;
713 unsigned char ip_protocol PACKED;
714 unsigned short ip_checksum PACKED;
715 unsigned long ip_src_address PACKED;
716 unsigned long ip_dst_address PACKED;
717 unsigned short udp_src_port PACKED;
718 unsigned short udp_dst_port PACKED;
719 unsigned short udp_length PACKED;
720 unsigned short udp_checksum PACKED;
721 udp_management_packet_t um_packet PACKED;
722} ip_packet_t;
723*/
724
725/* valid ip_protocol for UDP management */
726#define UDPMGMT_UDP_PROTOCOL 0x11
727
728
729typedef struct {
730 unsigned char status PACKED;
731 unsigned char data_avail PACKED;
732 unsigned short real_length PACKED;
733 unsigned short time_stamp PACKED;
734 unsigned char data[1] PACKED;
735} trace_pkt_t;
736
737typedef struct {
738 unsigned char error_flag PACKED;
739 unsigned short time_stamp PACKED;
740 unsigned char reserved[13] PACKED;
741} api_rx_hdr_t;
742
743typedef struct {
744 api_rx_hdr_t api_rx_hdr PACKED;
745 void * data PACKED;
746} api_rx_element_t;
747
748typedef struct {
749 unsigned char attr PACKED;
750 unsigned char reserved[15] PACKED;
751} api_tx_hdr_t;
752
753typedef struct {
754 api_tx_hdr_t api_tx_hdr PACKED;
755 void * data PACKED;
756} api_tx_element_t;
757
758/* ----------------------------------------------------------------------------
759 * Constants for the SET_FT1_CONFIGURATION/READ_FT1_CONFIGURATION command
760 * --------------------------------------------------------------------------*/
761
762/* the FT1 configuration structure */
763typedef struct {
764 unsigned short framing_mode;
765 unsigned short encoding_mode;
766 unsigned short line_build_out;
767 unsigned short channel_base;
768 unsigned short baud_rate_kbps; /* the baud rate (in kbps) */
769 unsigned short clock_mode;
770} ft1_config_t;
771
772/* settings for the 'framing_mode' */
773#define ESF_FRAMING 0x00 /* ESF framing */
774#define D4_FRAMING 0x01 /* D4 framing */
775
776/* settings for the 'encoding_mode' */
777#define B8ZS_ENCODING 0x00 /* B8ZS encoding */
778#define AMI_ENCODING 0x01 /* AMI encoding */
779
780/* settings for the 'line_build_out' */
781#define LN_BLD_CSU_0dB_DSX1_0_to_133 0x00 /* set build out to CSU (0db) or DSX-1 (0-133ft) */
782#define LN_BLD_DSX1_133_to_266 0x01 /* set build out DSX-1 (133-266ft) */
783#define LN_BLD_DSX1_266_to_399 0x02 /* set build out DSX-1 (266-399ft) */
784#define LN_BLD_DSX1_399_to_533 0x03 /* set build out DSX-1 (399-533ft) */
785#define LN_BLD_DSX1_533_to_655 0x04 /* set build out DSX-1 (533-655ft) */
786#define LN_BLD_CSU_NEG_7dB 0x05 /* set build out to CSU (-7.5db) */
787#define LN_BLD_CSU_NEG_15dB 0x06 /* set build out to CSU (-15db) */
788#define LN_BLD_CSU_NEG_22dB 0x07 /* set build out to CSU (-22.5db) */
789
790/* settings for the 'channel_base' */
791#define MIN_CHANNEL_BASE_VALUE 1 /* the minimum permitted channel base value */
792#define MAX_CHANNEL_BASE_VALUE 24 /* the maximum permitted channel base value */
793
794/* settings for the 'baud_rate_kbps' */
795#define MIN_BAUD_RATE_KBPS 0 /* the minimum permitted baud rate (kbps) */
796#define MAX_BAUD_RATE_KBPS 1536 /* the maximum permitted baud rate (kbps) */
797#define BAUD_RATE_FT1_AUTO_CONFIG 0xFFFF /* the baud rate used to trigger an automatic FT1 configuration */
798
799/* settings for the 'clock_mode' */
800#define CLOCK_MODE_NORMAL 0x00 /* clock mode set to normal (slave) */
801#define CLOCK_MODE_MASTER 0x01 /* clock mode set to master */
802
803
804#define BAUD_RATE_FT1_AUTO_CONFIG 0xFFFF
805#define AUTO_FT1_CONFIG_NOT_COMPLETE 0x08
806#define AUTO_FT1_CFG_FAIL_OP_MODE 0x0C
807#define AUTO_FT1_CFG_FAIL_INVALID_LINE 0x0D
808
809
810#ifdef _MSC_
811# pragma pack()
812#endif
813#endif /* _SDLA_CHDLC_H */
diff --git a/include/linux/sdla_fr.h b/include/linux/sdla_fr.h
new file mode 100644
index 000000000000..cdfa77fcb06b
--- /dev/null
+++ b/include/linux/sdla_fr.h
@@ -0,0 +1,638 @@
1/*****************************************************************************
2* sdla_fr.h Sangoma frame relay firmware API definitions.
3*
4* Author: Gideon Hack
5* Nenad Corbic <ncorbic@sangoma.com>
6*
7* Copyright: (c) 1995-2000 Sangoma Technologies Inc.
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
11* as published by the Free Software Foundation; either version
12* 2 of the License, or (at your option) any later version.
13* ============================================================================
14* Oct 04, 1999 Gideon Hack Updated API structures
15* Jun 02, 1999 Gideon Hack Modifications for S514 support
16* Oct 12, 1997 Jaspreet Singh Added FR_READ_DLCI_IB_MAPPING
17* Jul 21, 1997 Jaspreet Singh Changed FRRES_TOO_LONG and FRRES_TOO_MANY to
18* 0x05 and 0x06 respectively.
19* Dec 23, 1996 Gene Kozin v2.0
20* Apr 29, 1996 Gene Kozin v1.0 (merged version S502 & S508 definitions).
21* Sep 26, 1995 Gene Kozin Initial version.
22*****************************************************************************/
23#ifndef _SDLA_FR_H
24#define _SDLA_FR_H
25
26/*----------------------------------------------------------------------------
27 * Notes:
28 * ------
29 * 1. All structures defined in this file are byte-alined.
30 *
31 * Compiler Platform
32 * -------- --------
33 * GNU C Linux
34 */
35
36#ifndef PACKED
37# define PACKED __attribute__((packed))
38#endif /* PACKED */
39
40/* Adapter memory layout */
41#define FR_MB_VECTOR 0xE000 /* mailbox window vector */
42#define FR502_RX_VECTOR 0xA000 /* S502 direct receive window vector */
43#define FR502_MBOX_OFFS 0xF60 /* S502 mailbox offset */
44#define FR508_MBOX_OFFS 0 /* S508 mailbox offset */
45#define FR502_FLAG_OFFS 0x1FF0 /* S502 status flags offset */
46#define FR508_FLAG_OFFS 0x1000 /* S508 status flags offset */
47#define FR502_RXMB_OFFS 0x900 /* S502 direct receive mailbox offset */
48#define FR508_TXBC_OFFS 0x1100 /* S508 Tx buffer info offset */
49#define FR508_RXBC_OFFS 0x1120 /* S508 Rx buffer info offset */
50
51/* Important constants */
52#define FR502_MAX_DATA 4096 /* maximum data buffer length */
53#define FR508_MAX_DATA 4080 /* maximum data buffer length */
54#define MIN_LGTH_FR_DATA_CFG 300 /* min Information frame length
55(for configuration purposes) */
56#define FR_MAX_NO_DATA_BYTES_IN_FRAME 15354 /* max Information frame length */
57
58#define HIGHEST_VALID_DLCI 991
59
60/****** Data Structures *****************************************************/
61
62/*----------------------------------------------------------------------------
63 * Frame relay command block.
64 */
65typedef struct fr_cmd
66{
67 unsigned char command PACKED; /* command code */
68 unsigned short length PACKED; /* length of data buffer */
69 unsigned char result PACKED; /* return code */
70 unsigned short dlci PACKED; /* DLCI number */
71 unsigned char attr PACKED; /* FECN, BECN, DE and C/R bits */
72 unsigned short rxlost1 PACKED; /* frames discarded at int. level */
73 unsigned long rxlost2 PACKED; /* frames discarded at app. level */
74 unsigned char rsrv[2] PACKED; /* reserved for future use */
75} fr_cmd_t;
76
77/* 'command' field defines */
78#define FR_WRITE 0x01
79#define FR_READ 0x02
80#define FR_ISSUE_IS_FRAME 0x03
81#define FR_SET_CONFIG 0x10
82#define FR_READ_CONFIG 0x11
83#define FR_COMM_DISABLE 0x12
84#define FR_COMM_ENABLE 0x13
85#define FR_READ_STATUS 0x14
86#define FR_READ_STATISTICS 0x15
87#define FR_FLUSH_STATISTICS 0x16
88#define FR_LIST_ACTIVE_DLCI 0x17
89#define FR_FLUSH_DATA_BUFFERS 0x18
90#define FR_READ_ADD_DLC_STATS 0x19
91#define FR_ADD_DLCI 0x20
92#define FR_DELETE_DLCI 0x21
93#define FR_ACTIVATE_DLCI 0x22
94#define FR_DEACTIVATE_DLCI 0x22
95#define FR_READ_MODEM_STATUS 0x30
96#define FR_SET_MODEM_STATUS 0x31
97#define FR_READ_ERROR_STATS 0x32
98#define FR_FLUSH_ERROR_STATS 0x33
99#define FR_READ_DLCI_IB_MAPPING 0x34
100#define FR_READ_CODE_VERSION 0x40
101#define FR_SET_INTR_MODE 0x50
102#define FR_READ_INTR_MODE 0x51
103#define FR_SET_TRACE_CONFIG 0x60
104#define FR_FT1_STATUS_CTRL 0x80
105#define FR_SET_FT1_MODE 0x81
106
107/* Special UDP drivers management commands */
108#define FPIPE_ENABLE_TRACING 0x41
109#define FPIPE_DISABLE_TRACING 0x42
110#define FPIPE_GET_TRACE_INFO 0x43
111#define FPIPE_FT1_READ_STATUS 0x44
112#define FPIPE_DRIVER_STAT_IFSEND 0x45
113#define FPIPE_DRIVER_STAT_INTR 0x46
114#define FPIPE_DRIVER_STAT_GEN 0x47
115#define FPIPE_FLUSH_DRIVER_STATS 0x48
116#define FPIPE_ROUTER_UP_TIME 0x49
117
118/* 'result' field defines */
119#define FRRES_OK 0x00 /* command executed successfully */
120#define FRRES_DISABLED 0x01 /* communications not enabled */
121#define FRRES_INOPERATIVE 0x02 /* channel inoperative */
122#define FRRES_DLCI_INACTIVE 0x03 /* DLCI is inactive */
123#define FRRES_DLCI_INVALID 0x04 /* DLCI is not configured */
124#define FRRES_TOO_LONG 0x05
125#define FRRES_TOO_MANY 0x06
126#define FRRES_CIR_OVERFLOW 0x07 /* Tx throughput has exceeded CIR */
127#define FRRES_BUFFER_OVERFLOW 0x08
128#define FRRES_MODEM_FAILURE 0x10 /* DCD and/or CTS dropped */
129#define FRRES_CHANNEL_DOWN 0x11 /* channel became inoperative */
130#define FRRES_CHANNEL_UP 0x12 /* channel became operative */
131#define FRRES_DLCI_CHANGE 0x13 /* DLCI status (or number) changed */
132#define FRRES_DLCI_MISMATCH 0x14
133#define FRRES_INVALID_CMD 0x1F /* invalid command */
134
135/* 'attr' field defines */
136#define FRATTR_
137
138/*----------------------------------------------------------------------------
139 * Frame relay mailbox.
140 * This structure is located at offset FR50?_MBOX_OFFS into FR_MB_VECTOR.
141 * For S502 it is also located at offset FR502_RXMB_OFFS into
142 * FR502_RX_VECTOR.
143 */
144typedef struct fr_mbox
145{
146 unsigned char opflag PACKED; /* 00h: execution flag */
147 fr_cmd_t cmd PACKED; /* 01h: command block */
148 unsigned char data[1] PACKED; /* 10h: variable length data buffer */
149} fr_mbox_t;
150
151/*----------------------------------------------------------------------------
152 * S502 frame relay status flags.
153 * This structure is located at offset FR502_FLAG_OFFS into FR_MB_VECTOR.
154 */
155typedef struct fr502_flags
156{
157 unsigned char rsrv1[1] PACKED; /* 00h: */
158 unsigned char tx_ready PACKED; /* 01h: Tx buffer available */
159 unsigned char rx_ready PACKED; /* 02h: Rx frame available */
160 unsigned char event PACKED; /* 03h: asynchronous event */
161 unsigned char mstatus PACKED; /* 04h: modem status */
162 unsigned char rsrv2[8] PACKED; /* 05h: */
163 unsigned char iflag PACKED; /* 0Dh: interrupt flag */
164 unsigned char imask PACKED; /* 0Eh: interrupt mask */
165} fr502_flags_t;
166
167/*----------------------------------------------------------------------------
168 * S508 frame relay status flags.
169 * This structure is located at offset FR508_FLAG_OFFS into FR_MB_VECTOR.
170 */
171typedef struct fr508_flags
172{
173 unsigned char rsrv1[3] PACKED; /* 00h: reserved */
174 unsigned char event PACKED; /* 03h: asynchronous event */
175 unsigned char mstatus PACKED; /* 04h: modem status */
176 unsigned char rsrv2[11] PACKED; /* 05h: reserved */
177 unsigned char iflag PACKED; /* 10h: interrupt flag */
178 unsigned char imask PACKED; /* 11h: interrupt mask */
179 unsigned long tse_offs PACKED; /* 12h: Tx status element */
180 unsigned short dlci PACKED; /* 16h: DLCI NUMBER */
181} fr508_flags_t;
182
183/* 'event' field defines */
184#define FR_EVENT_STATUS 0x01 /* channel status change */
185#define FR_EVENT_DLC_STATUS 0x02 /* DLC status change */
186#define FR_EVENT_BAD_DLCI 0x04 /* FSR included wrong DLCI */
187#define FR_EVENT_LINK_DOWN 0x40 /* DCD or CTS low */
188
189/* 'mstatus' field defines */
190#define FR_MDM_DCD 0x08 /* mdm_status: DCD */
191#define FR_MDM_CTS 0x20 /* mdm_status: CTS */
192
193/* 'iflag' & 'imask' fields defines */
194#define FR_INTR_RXRDY 0x01 /* Rx ready */
195#define FR_INTR_TXRDY 0x02 /* Tx ready */
196#define FR_INTR_MODEM 0x04 /* modem status change (DCD, CTS) */
197#define FR_INTR_READY 0x08 /* interface command completed */
198#define FR_INTR_DLC 0x10 /* DLC status change */
199#define FR_INTR_TIMER 0x20 /* millisecond timer */
200#define FR_INTR_TX_MULT_DLCIs 0x80 /* Tx interrupt on multiple DLCIs */
201
202
203/*----------------------------------------------------------------------------
204 * Receive Buffer Configuration Info. S508 only!
205 * This structure is located at offset FR508_RXBC_OFFS into FR_MB_VECTOR.
206 */
207typedef struct fr_buf_info
208{
209 unsigned short rse_num PACKED; /* 00h: number of status elements */
210 unsigned long rse_base PACKED; /* 02h: receive status array base */
211 unsigned long rse_next PACKED; /* 06h: next status element */
212 unsigned long buf_base PACKED; /* 0Ah: rotational buffer base */
213 unsigned short reserved PACKED; /* 0Eh: */
214 unsigned long buf_top PACKED; /* 10h: rotational buffer top */
215} fr_buf_info_t;
216
217/*----------------------------------------------------------------------------
218 * Buffer Status Element. S508 only!
219 * Array of structures of this type is located at offset defined by the
220 * 'rse_base' field of the frBufInfo_t structure into absolute adapter
221 * memory address space.
222 */
223typedef struct fr_rx_buf_ctl
224{
225 unsigned char flag PACKED; /* 00h: ready flag */
226 unsigned short length PACKED; /* 01h: frame length */
227 unsigned short dlci PACKED; /* 03h: DLCI */
228 unsigned char attr PACKED; /* 05h: FECN/BECN/DE/CR */
229 unsigned short tmstamp PACKED; /* 06h: time stamp */
230 unsigned short rsrv[2] PACKED; /* 08h: */
231 unsigned long offset PACKED; /* 0Ch: buffer absolute address */
232} fr_rx_buf_ctl_t;
233
234typedef struct fr_tx_buf_ctl
235{
236 unsigned char flag PACKED; /* 00h: ready flag */
237 unsigned short rsrv0[2] PACKED; /* 01h: */
238 unsigned short length PACKED; /* 05h: frame length */
239 unsigned short dlci PACKED; /* 07h: DLCI */
240 unsigned char attr PACKED; /* 09h: FECN/BECN/DE/CR */
241 unsigned short rsrv1 PACKED; /* 0Ah: */
242 unsigned long offset PACKED; /* 0Ch: buffer absolute address */
243} fr_tx_buf_ctl_t;
244
245/*----------------------------------------------------------------------------
246 * Global Configuration Block. Passed to FR_SET_CONFIG command when dlci == 0.
247 */
248typedef struct fr_conf
249{
250 unsigned short station PACKED; /* 00h: CPE/Node */
251 unsigned short options PACKED; /* 02h: configuration options */
252 unsigned short kbps PACKED; /* 04h: baud rate in kbps */
253 unsigned short port PACKED; /* 06h: RS-232/V.35 */
254 unsigned short mtu PACKED; /* 08h: max. transmit length */
255 unsigned short t391 PACKED; /* 0Ah: */
256 unsigned short t392 PACKED; /* 0Ch: */
257 unsigned short n391 PACKED; /* 0Eh: */
258 unsigned short n392 PACKED; /* 10h: */
259 unsigned short n393 PACKED; /* 12h: */
260 unsigned short cir_fwd PACKED; /* 14h: */
261 unsigned short bc_fwd PACKED; /* 16h: */
262 unsigned short be_fwd PACKED; /* 18h: */
263 unsigned short cir_bwd PACKED; /* 1Ah: */
264 unsigned short bc_bwd PACKED; /* 1Ch: */
265 unsigned short be_bwd PACKED; /* 1Eh: */
266 unsigned short dlci[0] PACKED; /* 20h: */
267} fr_conf_t;
268
269/* 'station_type' defines */
270#define FRCFG_STATION_CPE 0
271#define FRCFG_STATION_NODE 1
272
273/* 'conf_flags' defines */
274#define FRCFG_IGNORE_TX_CIR 0x0001
275#define FRCFG_IGNORE_RX_CIR 0x0002
276#define FRCFG_DONT_RETRANSMIT 0x0004
277#define FRCFG_IGNORE_CBS 0x0008
278#define FRCFG_THROUGHPUT 0x0010 /* enable throughput calculation */
279#define FRCFG_DIRECT_RX 0x0080 /* enable direct receive buffer */
280#define FRCFG_AUTO_CONFIG 0x8000 /* enable auto DLCI configuration */
281
282/* 'baud_rate' defines */
283#define FRCFG_BAUD_1200 12
284#define FRCFG_BAUD_2400 24
285#define FRCFG_BAUD_4800 48
286#define FRCFG_BAUD_9600 96
287#define FRCFG_BAUD_19200 19
288#define FRCFG_BAUD_38400 38
289#define FRCFG_BAUD_56000 56
290#define FRCFG_BAUD_64000 64
291#define FRCFG_BAUD_128000 128
292
293/* 'port_mode' defines */
294#define FRCFG_MODE_EXT_CLK 0x0000
295#define FRCFG_MODE_INT_CLK 0x0001
296#define FRCFG_MODE_V35 0x0000 /* S508 only */
297#define FRCFG_MODE_RS232 0x0002 /* S508 only */
298
299/* defines for line tracing */
300
301/* the line trace status element presented by the frame relay code */
302typedef struct {
303 unsigned char flag PACKED; /* ready flag */
304 unsigned short length PACKED; /* trace length */
305 unsigned char rsrv0[2] PACKED; /* reserved */
306 unsigned char attr PACKED; /* trace attributes */
307 unsigned short tmstamp PACKED; /* time stamp */
308 unsigned char rsrv1[4] PACKED; /* reserved */
309 unsigned long offset PACKED; /* buffer absolute address */
310} fr_trc_el_t;
311
312typedef struct {
313 unsigned char status PACKED; /* status flag */
314 unsigned char data_passed PACKED; /* 0 if no data passed, 1 if */
315 /* data passed */
316 unsigned short length PACKED; /* frame length */
317 unsigned short tmstamp PACKED; /* time stamp */
318} fpipemon_trc_hdr_t;
319
320typedef struct {
321 fpipemon_trc_hdr_t fpipemon_trc_hdr PACKED;
322 unsigned char data[FR_MAX_NO_DATA_BYTES_IN_FRAME] PACKED;
323} fpipemon_trc_t;
324
325/* bit settings for the 'status' byte - note that bits 1, 2 and 3 are used */
326/* for returning the number of frames being passed to fpipemon */
327#define TRC_OUTGOING_FRM 0x01
328#define TRC_ABORT_ERROR 0x10
329#define TRC_CRC_ERROR 0x20
330#define TRC_OVERRUN_ERROR 0x40
331#define MORE_TRC_DATA 0x80
332
333#define MAX_FRMS_TRACED 0x07
334
335#define NO_TRC_ELEMENTS_OFF 0x9000
336#define BASE_TRC_ELEMENTS_OFF 0x9002
337#define TRC_ACTIVE 0x01
338#define FLUSH_TRC_BUFFERS 0x02
339#define FLUSH_TRC_STATISTICS 0x04
340#define TRC_SIGNALLING_FRMS 0x10
341#define TRC_INFO_FRMS 0x20
342#define ACTIVATE_TRC (TRC_ACTIVE | TRC_SIGNALLING_FRMS | TRC_INFO_FRMS)
343#define RESET_TRC (FLUSH_TRC_BUFFERS | FLUSH_TRC_STATISTICS)
344
345/*----------------------------------------------------------------------------
346 * Channel configuration.
347 * This structure is passed to the FR_SET_CONFIG command when dlci != 0.
348 */
349typedef struct fr_dlc_conf
350{
351 unsigned short conf_flags PACKED; /* 00h: configuration bits */
352 unsigned short cir_fwd PACKED; /* 02h: */
353 unsigned short bc_fwd PACKED; /* 04h: */
354 unsigned short be_fwd PACKED; /* 06h: */
355 unsigned short cir_bwd PACKED; /* 08h: */
356 unsigned short bc_bwd PACKED; /* 0Ah: */
357 unsigned short be_bwd PACKED; /* 0Ch: */
358} fr_dlc_conf_t;
359
360/*----------------------------------------------------------------------------
361 * S502 interrupt mode control block.
362 * This structure is passed to the FR_SET_INTR_FLAGS and returned by the
363 * FR_READ_INTR_FLAGS commands.
364 */
365typedef struct fr502_intr_ctl
366{
367 unsigned char mode PACKED; /* 00h: interrupt enable flags */
368 unsigned short tx_len PACKED; /* 01h: required Tx buffer size */
369} fr502_intr_ctl_t;
370
371/*----------------------------------------------------------------------------
372 * S508 interrupt mode control block.
373 * This structure is passed to the FR_SET_INTR_FLAGS and returned by the
374 * FR_READ_INTR_FLAGS commands.
375 */
376typedef struct fr508_intr_ctl
377{
378 unsigned char mode PACKED; /* 00h: interrupt enable flags */
379 unsigned short tx_len PACKED; /* 01h: required Tx buffer size */
380 unsigned char irq PACKED; /* 03h: IRQ level to activate */
381 unsigned char flags PACKED; /* 04h: ?? */
382 unsigned short timeout PACKED; /* 05h: ms, for timer interrupt */
383} fr508_intr_ctl_t;
384
385/*----------------------------------------------------------------------------
386 * Channel status.
387 * This structure is returned by the FR_READ_STATUS command.
388 */
389typedef struct fr_dlc_Status
390{
391 unsigned char status PACKED; /* 00h: link/DLCI status */
392 struct
393 {
394 unsigned short dlci PACKED; /* 01h: DLCI number */
395 unsigned char status PACKED; /* 03h: DLCI status */
396 } circuit[1] PACKED;
397} fr_dlc_status_t;
398
399/* 'status' defines */
400#define FR_LINK_INOPER 0x00 /* for global status (DLCI == 0) */
401#define FR_LINK_OPER 0x01
402#define FR_DLCI_DELETED 0x01 /* for circuit status (DLCI != 0) */
403#define FR_DLCI_ACTIVE 0x02
404#define FR_DLCI_WAITING 0x04
405#define FR_DLCI_NEW 0x08
406#define FR_DLCI_REPORT 0x40
407
408/*----------------------------------------------------------------------------
409 * Global Statistics Block.
410 * This structure is returned by the FR_READ_STATISTICS command when
411 * dcli == 0.
412 */
413typedef struct fr_link_stat
414{
415 unsigned short rx_too_long PACKED; /* 00h: */
416 unsigned short rx_dropped PACKED; /* 02h: */
417 unsigned short rx_dropped2 PACKED; /* 04h: */
418 unsigned short rx_bad_dlci PACKED; /* 06h: */
419 unsigned short rx_bad_format PACKED; /* 08h: */
420 unsigned short retransmitted PACKED; /* 0Ah: */
421 unsigned short cpe_tx_FSE PACKED; /* 0Ch: */
422 unsigned short cpe_tx_LIV PACKED; /* 0Eh: */
423 unsigned short cpe_rx_FSR PACKED; /* 10h: */
424 unsigned short cpe_rx_LIV PACKED; /* 12h: */
425 unsigned short node_rx_FSE PACKED; /* 14h: */
426 unsigned short node_rx_LIV PACKED; /* 16h: */
427 unsigned short node_tx_FSR PACKED; /* 18h: */
428 unsigned short node_tx_LIV PACKED; /* 1Ah: */
429 unsigned short rx_ISF_err PACKED; /* 1Ch: */
430 unsigned short rx_unsolicited PACKED; /* 1Eh: */
431 unsigned short rx_SSN_err PACKED; /* 20h: */
432 unsigned short rx_RSN_err PACKED; /* 22h: */
433 unsigned short T391_timeouts PACKED; /* 24h: */
434 unsigned short T392_timeouts PACKED; /* 26h: */
435 unsigned short N392_reached PACKED; /* 28h: */
436 unsigned short cpe_SSN_RSN PACKED; /* 2Ah: */
437 unsigned short current_SSN PACKED; /* 2Ch: */
438 unsigned short current_RSN PACKED; /* 2Eh: */
439 unsigned short curreny_T391 PACKED; /* 30h: */
440 unsigned short current_T392 PACKED; /* 32h: */
441 unsigned short current_N392 PACKED; /* 34h: */
442 unsigned short current_N393 PACKED; /* 36h: */
443} fr_link_stat_t;
444
445/*----------------------------------------------------------------------------
446 * DLCI statistics.
447 * This structure is returned by the FR_READ_STATISTICS command when
448 * dlci != 0.
449 */
450typedef struct fr_dlci_stat
451{
452 unsigned long tx_frames PACKED; /* 00h: */
453 unsigned long tx_bytes PACKED; /* 04h: */
454 unsigned long rx_frames PACKED; /* 08h: */
455 unsigned long rx_bytes PACKED; /* 0Ch: */
456 unsigned long rx_dropped PACKED; /* 10h: */
457 unsigned long rx_inactive PACKED; /* 14h: */
458 unsigned long rx_exceed_CIR PACKED; /* 18h: */
459 unsigned long rx_DE_set PACKED; /* 1Ch: */
460 unsigned long tx_throughput PACKED; /* 20h: */
461 unsigned long tx_calc_timer PACKED; /* 24h: */
462 unsigned long rx_throughput PACKED; /* 28h: */
463 unsigned long rx_calc_timer PACKED; /* 2Ch: */
464} fr_dlci_stat_t;
465
466/*----------------------------------------------------------------------------
467 * Communications error statistics.
468 * This structure is returned by the FR_READ_ERROR_STATS command.
469 */
470typedef struct fr_comm_stat
471{
472 unsigned char rx_overruns PACKED; /* 00h: */
473 unsigned char rx_bad_crc PACKED; /* 01h: */
474 unsigned char rx_aborts PACKED; /* 02h: */
475 unsigned char rx_too_long PACKED; /* 03h: */
476 unsigned char tx_aborts PACKED; /* 04h: */
477 unsigned char tx_underruns PACKED; /* 05h: */
478 unsigned char tx_missed_undr PACKED; /* 06h: */
479 unsigned char dcd_dropped PACKED; /* 07h: */
480 unsigned char cts_dropped PACKED; /* 08h: */
481} fr_comm_stat_t;
482
483/*----------------------------------------------------------------------------
484 * Defines for the FR_ISSUE_IS_FRAME command.
485 */
486#define FR_ISF_LVE 2 /* issue Link Verification Enquiry */
487#define FR_ISF_FSE 3 /* issue Full Status Enquiry */
488
489/*----------------------------------------------------------------------------
490 * Frame Relay ARP Header -- Used for Dynamic route creation with InvARP
491 */
492
493typedef struct arphdr_fr
494 {
495 unsigned short ar_hrd PACKED; /* format of hardware addr */
496 unsigned short ar_pro PACKED; /* format of protocol addr */
497 unsigned char ar_hln PACKED; /* length of hardware addr */
498 unsigned char ar_pln PACKED; /* length of protocol addr */
499 unsigned short ar_op PACKED; /* ARP opcode */
500 unsigned short ar_sha PACKED; /* Sender DLCI addr 2 bytes */
501 unsigned long ar_sip PACKED; /* Sender IP addr 4 bytes */
502 unsigned short ar_tha PACKED; /* Target DLCI addr 2 bytes */
503 unsigned long ar_tip PACKED; /* Target IP addr 4 bytes */
504 } arphdr_fr_t;
505
506/*----------------------------------------------------------------------------
507 * Frame Relay RFC 1490 SNAP Header -- Used to check for ARP packets
508 */
509typedef struct arphdr_1490
510 {
511 unsigned char control PACKED; /* UI, etc... */
512 unsigned char pad PACKED; /* Pad */
513 unsigned char NLPID PACKED; /* SNAP */
514 unsigned char OUI[3] PACKED; /* Ethertype, etc... */
515 unsigned short PID PACKED; /* ARP, IP, etc... */
516 } arphdr_1490_t;
517
518/* UDP/IP packet (for UDP management) layout */
519
520/* The embedded control block for UDP mgmt
521 This is essentially a mailbox structure, without the large data field */
522
523typedef struct {
524 unsigned char opp_flag PACKED; /* the opp flag */
525 unsigned char command PACKED; /* command code */
526 unsigned short length PACKED; /* length of data buffer */
527 unsigned char result PACKED; /* return code */
528 unsigned short dlci PACKED; /* DLCI number */
529 unsigned char attr PACKED; /* FECN, BECN, DE and C/R bits */
530 unsigned short rxlost1 PACKED; /* frames discarded at int. level */
531 unsigned long rxlost2 PACKED; /* frames discarded at app. level */
532 unsigned char rsrv[2] PACKED; /* reserved for future use */
533} cblock_t;
534
535
536/* UDP management packet layout (data area of ip packet) */
537
538typedef struct {
539 unsigned char control PACKED;
540 unsigned char NLPID PACKED;
541} fr_encap_hdr_t;
542
543typedef struct {
544// fr_encap_hdr_t fr_encap_hdr PACKED;
545 ip_pkt_t ip_pkt PACKED;
546 udp_pkt_t udp_pkt PACKED;
547 wp_mgmt_t wp_mgmt PACKED;
548 cblock_t cblock PACKED;
549 unsigned char data[4080] PACKED;
550} fr_udp_pkt_t;
551
552
553/* valid ip_protocol for UDP management */
554#define UDPMGMT_UDP_PROTOCOL 0x11
555
556#define UDPMGMT_FPIPE_SIGNATURE "FPIPE8ND"
557#define UDPMGMT_DRVRSTATS_SIGNATURE "DRVSTATS"
558
559/* values for request/reply byte */
560#define UDPMGMT_REQUEST 0x01
561#define UDPMGMT_REPLY 0x02
562#define UDP_OFFSET 12
563
564typedef struct {
565 unsigned long if_send_entry;
566 unsigned long if_send_skb_null;
567 unsigned long if_send_broadcast;
568 unsigned long if_send_multicast;
569 unsigned long if_send_critical_ISR;
570 unsigned long if_send_critical_non_ISR;
571 unsigned long if_send_busy;
572 unsigned long if_send_busy_timeout;
573 unsigned long if_send_DRVSTATS_request;
574 unsigned long if_send_FPIPE_request;
575 unsigned long if_send_wan_disconnected;
576 unsigned long if_send_dlci_disconnected;
577 unsigned long if_send_no_bfrs;
578 unsigned long if_send_adptr_bfrs_full;
579 unsigned long if_send_bfrs_passed_to_adptr;
580 unsigned long if_send_consec_send_fail;
581} drvstats_if_send_t;
582
583typedef struct {
584 unsigned long rx_intr_no_socket;
585 unsigned long rx_intr_dev_not_started;
586 unsigned long rx_intr_DRVSTATS_request;
587 unsigned long rx_intr_FPIPE_request;
588 unsigned long rx_intr_bfr_not_passed_to_stack;
589 unsigned long rx_intr_bfr_passed_to_stack;
590 } drvstats_rx_intr_t;
591
592typedef struct {
593 unsigned long UDP_FPIPE_mgmt_kmalloc_err;
594 unsigned long UDP_FPIPE_mgmt_direction_err;
595 unsigned long UDP_FPIPE_mgmt_adptr_type_err;
596 unsigned long UDP_FPIPE_mgmt_adptr_cmnd_OK;
597 unsigned long UDP_FPIPE_mgmt_adptr_cmnd_timeout;
598 unsigned long UDP_FPIPE_mgmt_adptr_send_passed;
599 unsigned long UDP_FPIPE_mgmt_adptr_send_failed;
600 unsigned long UDP_FPIPE_mgmt_not_passed_to_stack;
601 unsigned long UDP_FPIPE_mgmt_passed_to_stack;
602 unsigned long UDP_FPIPE_mgmt_no_socket;
603 unsigned long UDP_DRVSTATS_mgmt_kmalloc_err;
604 unsigned long UDP_DRVSTATS_mgmt_adptr_cmnd_OK;
605 unsigned long UDP_DRVSTATS_mgmt_adptr_cmnd_timeout;
606 unsigned long UDP_DRVSTATS_mgmt_adptr_send_passed;
607 unsigned long UDP_DRVSTATS_mgmt_adptr_send_failed;
608 unsigned long UDP_DRVSTATS_mgmt_not_passed_to_stack;
609 unsigned long UDP_DRVSTATS_mgmt_passed_to_stack;
610 unsigned long UDP_DRVSTATS_mgmt_no_socket;
611} drvstats_gen_t;
612
613typedef struct {
614 unsigned char attr PACKED;
615 unsigned short time_stamp PACKED;
616 unsigned char reserved[13] PACKED;
617} api_rx_hdr_t;
618
619typedef struct {
620 api_rx_hdr_t api_rx_hdr PACKED;
621 void * data PACKED;
622} api_rx_element_t;
623
624typedef struct {
625 unsigned char attr PACKED;
626 unsigned char reserved[15] PACKED;
627} api_tx_hdr_t;
628
629typedef struct {
630 api_tx_hdr_t api_tx_hdr PACKED;
631 void * data PACKED;
632} api_tx_element_t;
633
634#ifdef _MSC_
635# pragma pack()
636#endif
637#endif /* _SDLA_FR_H */
638
diff --git a/include/linux/sdla_ppp.h b/include/linux/sdla_ppp.h
new file mode 100644
index 000000000000..6f3923179c29
--- /dev/null
+++ b/include/linux/sdla_ppp.h
@@ -0,0 +1,575 @@
1/*****************************************************************************
2* sdla_ppp.h Sangoma PPP firmware API definitions.
3*
4* Author: Nenad Corbic <ncorbic@sangoma.com>
5*
6* Copyright: (c) 1995-1997 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* Feb 24, 2000 Nenad Corbic v2.1.2
14* Jan 06, 1997 Gene Kozin v2.0
15* Apr 11, 1996 Gene Kozin Initial version.
16*****************************************************************************/
17#ifndef _SDLA_PPP_H
18#define _SDLA_PPP_H
19
20/*----------------------------------------------------------------------------
21 * Notes:
22 * ------
23 * 1. All structures defined in this file are byte-alined.
24 *
25 * Compiler Platform
26 * -------- --------
27 * GNU C Linux
28 */
29
30#ifndef PACKED
31# define PACKED __attribute__((packed))
32#endif /* PACKED */
33
34/* Adapter memory layout and important constants */
35#define PPP508_MB_VECT 0xE000 /* mailbox window vector */
36#define PPP508_MB_OFFS 0 /* mailbox offset */
37#define PPP508_FLG_OFFS 0x1000 /* status flags offset */
38#define PPP508_BUF_OFFS 0x1100 /* buffer info block offset */
39#define PPP514_MB_OFFS 0xE000 /* mailbox offset */
40#define PPP514_FLG_OFFS 0xF000 /* status flags offset */
41#define PPP514_BUF_OFFS 0xF100 /* buffer info block offset */
42
43#define PPP_MAX_DATA 1008 /* command block data buffer length */
44
45/****** Data Structures *****************************************************/
46
47/*----------------------------------------------------------------------------
48 * PPP Command Block.
49 */
50typedef struct ppp_cmd{
51 unsigned char command PACKED; /* command code */
52 unsigned short length PACKED; /* length of data buffer */
53 unsigned char result PACKED; /* return code */
54 unsigned char rsrv[11] PACKED; /* reserved for future use */
55} ppp_cmd_t;
56
57typedef struct cblock{
58 unsigned char opp_flag PACKED;
59 unsigned char command PACKED; /* command code */
60 unsigned short length PACKED; /* length of data buffer */
61 unsigned char result PACKED; /* return code */
62 unsigned char rsrv[11] PACKED; /* reserved for future use */
63} cblock_t;
64
65typedef struct ppp_udp_pkt{
66 ip_pkt_t ip_pkt PACKED;
67 udp_pkt_t udp_pkt PACKED;
68 wp_mgmt_t wp_mgmt PACKED;
69 cblock_t cblock PACKED;
70 unsigned char data[MAX_LGTH_UDP_MGNT_PKT] PACKED;
71} ppp_udp_pkt_t;
72
73typedef struct {
74 unsigned char status PACKED;
75 unsigned char data_avail PACKED;
76 unsigned short real_length PACKED;
77 unsigned short time_stamp PACKED;
78 unsigned char data[1] PACKED;
79} trace_pkt_t;
80
81
82typedef struct {
83 unsigned char opp_flag PACKED;
84 unsigned char trace_type PACKED;
85 unsigned short trace_length PACKED;
86 unsigned short trace_data_ptr PACKED;
87 unsigned short trace_time_stamp PACKED;
88} trace_element_t;
89
90/* 'command' field defines */
91#define PPP_READ_CODE_VERSION 0x10 /* configuration commands */
92#define PPP_SET_CONFIG 0x05
93#define PPP_READ_CONFIG 0x06
94#define PPP_SET_INTR_FLAGS 0x20
95#define PPP_READ_INTR_FLAGS 0x21
96#define PPP_SET_INBOUND_AUTH 0x30
97#define PPP_SET_OUTBOUND_AUTH 0x31
98#define PPP_GET_CONNECTION_INFO 0x32
99
100#define PPP_COMM_ENABLE 0x03 /* operational commands */
101#define PPP_COMM_DISABLE 0x04
102#define PPP_SEND_SIGN_FRAME 0x23
103#define PPP_READ_SIGN_RESPONSE 0x24
104#define PPP_DATALINE_MONITOR 0x33
105
106#define PPP_READ_STATISTICS 0x07 /* statistics commands */
107#define PPP_FLUSH_STATISTICS 0x08
108#define PPP_READ_ERROR_STATS 0x09
109#define PPP_FLUSH_ERROR_STATS 0x0A
110#define PPP_READ_PACKET_STATS 0x12
111#define PPP_FLUSH_PACKET_STATS 0x13
112#define PPP_READ_LCP_STATS 0x14
113#define PPP_FLUSH_LCP_STATS 0x15
114#define PPP_READ_LPBK_STATS 0x16
115#define PPP_FLUSH_LPBK_STATS 0x17
116#define PPP_READ_IPCP_STATS 0x18
117#define PPP_FLUSH_IPCP_STATS 0x19
118#define PPP_READ_IPXCP_STATS 0x1A
119#define PPP_FLUSH_IPXCP_STATS 0x1B
120#define PPP_READ_PAP_STATS 0x1C
121#define PPP_FLUSH_PAP_STATS 0x1D
122#define PPP_READ_CHAP_STATS 0x1E
123#define PPP_FLUSH_CHAP_STATS 0x1F
124
125/* 'result' field defines */
126#define PPPRES_OK 0x00 /* command executed successfully */
127#define PPPRES_INVALID_STATE 0x09 /* invalid command in this context */
128
129/*----------------------------------------------------------------------------
130 * PPP Mailbox.
131 * This structure is located at offset PPP???_MB_OFFS into PPP???_MB_VECT
132 */
133typedef struct ppp_mbox
134{
135 unsigned char flag PACKED; /* 00h: command execution flag */
136 ppp_cmd_t cmd PACKED; /* 01h: command block */
137 unsigned char data[1] PACKED; /* 10h: variable length data buffer */
138} ppp_mbox_t;
139
140/*----------------------------------------------------------------------------
141 * PPP Status Flags.
142 * This structure is located at offset PPP???_FLG_OFFS into
143 * PPP???_MB_VECT.
144 */
145typedef struct ppp_flags
146{
147 unsigned char iflag PACKED; /* 00: interrupt flag */
148 unsigned char imask PACKED; /* 01: interrupt mask */
149 unsigned char resrv PACKED;
150 unsigned char mstatus PACKED; /* 03: modem status */
151 unsigned char lcp_state PACKED; /* 04: LCP state */
152 unsigned char ppp_phase PACKED; /* 05: PPP phase */
153 unsigned char ip_state PACKED; /* 06: IPCP state */
154 unsigned char ipx_state PACKED; /* 07: IPXCP state */
155 unsigned char pap_state PACKED; /* 08: PAP state */
156 unsigned char chap_state PACKED; /* 09: CHAP state */
157 unsigned short disc_cause PACKED; /* 0A: disconnection cause */
158} ppp_flags_t;
159
160/* 'iflag' defines */
161#define PPP_INTR_RXRDY 0x01 /* Rx ready */
162#define PPP_INTR_TXRDY 0x02 /* Tx ready */
163#define PPP_INTR_MODEM 0x04 /* modem status change (DCD, CTS) */
164#define PPP_INTR_CMD 0x08 /* interface command completed */
165#define PPP_INTR_DISC 0x10 /* data link disconnected */
166#define PPP_INTR_OPEN 0x20 /* data link open */
167#define PPP_INTR_DROP_DTR 0x40 /* DTR drop timeout expired */
168#define PPP_INTR_TIMER 0x80 /* timer interrupt */
169
170
171/* 'mstatus' defines */
172#define PPP_MDM_DCD 0x08 /* mdm_status: DCD */
173#define PPP_MDM_CTS 0x20 /* mdm_status: CTS */
174
175/* 'disc_cause' defines */
176#define PPP_LOCAL_TERMINATION 0x0001 /* Local Request by PPP termination phase */
177#define PPP_DCD_CTS_DROP 0x0002 /* DCD and/or CTS dropped. Link down */
178#define PPP_REMOTE_TERMINATION 0x0800 /* Remote Request by PPP termination phase */
179
180/* 'misc_config_bits' defines */
181#define DONT_RE_TX_ABORTED_I_FRAMES 0x01
182#define TX_FRM_BYTE_COUNT_STATS 0x02
183#define RX_FRM_BYTE_COUNT_STATS 0x04
184#define TIME_STAMP_IN_RX_FRAMES 0x08
185#define NON_STD_ADPTR_FREQ 0x10
186#define INTERFACE_LEVEL_RS232 0x20
187#define AUTO_LINK_RECOVERY 0x100
188#define DONT_TERMINATE_LNK_MAX_CONFIG 0x200
189
190/* 'authentication options' defines */
191#define NO_AUTHENTICATION 0x00
192#define INBOUND_AUTH 0x80
193#define PAP_AUTH 0x01
194#define CHAP_AUTH 0x02
195
196/* 'ip options' defines */
197#define L_AND_R_IP_NO_ASSIG 0x00
198#define L_IP_LOCAL_ASSIG 0x01
199#define L_IP_REMOTE_ASSIG 0x02
200#define R_IP_LOCAL_ASSIG 0x04
201#define R_IP_REMOTE_ASSIG 0x08
202#define ENABLE_IP 0x80
203
204/* 'ipx options' defines */
205#define ROUTING_PROT_DEFAULT 0x20
206#define ENABLE_IPX 0x80
207#define DISABLE_IPX 0x00
208
209/*----------------------------------------------------------------------------
210 * PPP Buffer Info.
211 * This structure is located at offset PPP508_BUF_OFFS into
212 * PPP508_MB_VECT.
213 */
214typedef struct ppp508_buf_info
215{
216 unsigned short txb_num PACKED; /* 00: number of transmit buffers */
217 unsigned long txb_ptr PACKED; /* 02: pointer to the buffer ctl. */
218 unsigned long txb_nxt PACKED;
219 unsigned char rsrv1[22] PACKED;
220 unsigned short rxb_num PACKED; /* 20: number of receive buffers */
221 unsigned long rxb_ptr PACKED; /* 22: pointer to the buffer ctl. */
222 unsigned long rxb1_ptr PACKED; /* 26: pointer to the first buf.ctl. */
223 unsigned long rxb_base PACKED; /* 2A: pointer to the buffer base */
224 unsigned char rsrv2[2] PACKED;
225 unsigned long rxb_end PACKED; /* 30: pointer to the buffer end */
226} ppp508_buf_info_t;
227
228/*----------------------------------------------------------------------------
229 * Transmit/Receive Buffer Control Block.
230 */
231typedef struct ppp_buf_ctl
232{
233 unsigned char flag PACKED; /* 00: 'buffer ready' flag */
234 unsigned short length PACKED; /* 01: length of data */
235 unsigned char reserved1[1] PACKED; /* 03: */
236 unsigned char proto PACKED; /* 04: protocol */
237 unsigned short timestamp PACKED; /* 05: time stamp (Rx only) */
238 unsigned char reserved2[5] PACKED; /* 07: */
239 union
240 {
241 unsigned short o_p[2]; /* 1C: buffer offset & page (S502) */
242 unsigned long ptr; /* 1C: buffer pointer (S508) */
243 } buf PACKED;
244} ppp_buf_ctl_t;
245
246/*----------------------------------------------------------------------------
247 * S508 Adapter Configuration Block (passed to the PPP_SET_CONFIG command).
248 */
249typedef struct ppp508_conf
250{
251 unsigned long line_speed PACKED; /* 00: baud rate, bps */
252 unsigned short txbuf_percent PACKED; /* 04: % of Tx buffer */
253 unsigned short conf_flags PACKED; /* 06: configuration bits */
254 unsigned short mtu_local PACKED; /* 08: local MTU */
255 unsigned short mtu_remote PACKED; /* 0A: remote MTU */
256 unsigned short restart_tmr PACKED; /* 0C: restart timer */
257 unsigned short auth_rsrt_tmr PACKED; /* 0E: authentication timer */
258 unsigned short auth_wait_tmr PACKED; /* 10: authentication timer */
259 unsigned short mdm_fail_tmr PACKED; /* 12: modem failure timer */
260 unsigned short dtr_drop_tmr PACKED; /* 14: DTR drop timer */
261 unsigned short connect_tmout PACKED; /* 16: connection timeout */
262 unsigned short conf_retry PACKED; /* 18: max. retry */
263 unsigned short term_retry PACKED; /* 1A: max. retry */
264 unsigned short fail_retry PACKED; /* 1C: max. retry */
265 unsigned short auth_retry PACKED; /* 1E: max. retry */
266 unsigned char auth_options PACKED; /* 20: authentication opt. */
267 unsigned char ip_options PACKED; /* 21: IP options */
268 unsigned long ip_local PACKED; /* 22: local IP address */
269 unsigned long ip_remote PACKED; /* 26: remote IP address */
270 unsigned char ipx_options PACKED; /* 2A: IPX options */
271 unsigned char ipx_netno[4] PACKED; /* 2B: IPX net number */
272 unsigned char ipx_local[6] PACKED; /* 2F: local IPX node number*/
273 unsigned char ipx_remote[6] PACKED; /* 35: remote IPX node num.*/
274 unsigned char ipx_router[48] PACKED; /* 3B: IPX router name*/
275 unsigned long alt_cpu_clock PACKED; /* 6B: */
276} ppp508_conf_t;
277
278/*----------------------------------------------------------------------------
279 * S508 Adapter Read Connection Information Block
280 * Returned by the PPP_GET_CONNECTION_INFO command
281 */
282typedef struct ppp508_connect_info
283{
284 unsigned short mru PACKED; /* 00-01 Remote Max Rec' Unit */
285 unsigned char ip_options PACKED; /* 02: Negotiated ip options */
286 unsigned long ip_local PACKED; /* 03-06: local IP address */
287 unsigned long ip_remote PACKED; /* 07-0A: remote IP address */
288 unsigned char ipx_options PACKED; /* 0B: Negotiated ipx options */
289 unsigned char ipx_netno[4] PACKED; /* 0C-0F: IPX net number */
290 unsigned char ipx_local[6] PACKED; /* 10-1F: local IPX node # */
291 unsigned char ipx_remote[6] PACKED; /* 16-1B: remote IPX node # */
292 unsigned char ipx_router[48] PACKED; /* 1C-4B: IPX router name */
293 unsigned char auth_status PACKED; /* 4C: Authentication Status */
294 unsigned char inbd_auth_peerID[1] PACKED; /* 4D: variable length inbound authenticated peer ID */
295} ppp508_connect_info_t;
296
297/* 'line_speed' field */
298#define PPP_BITRATE_1200 0x01
299#define PPP_BITRATE_2400 0x02
300#define PPP_BITRATE_4800 0x03
301#define PPP_BITRATE_9600 0x04
302#define PPP_BITRATE_19200 0x05
303#define PPP_BITRATE_38400 0x06
304#define PPP_BITRATE_45000 0x07
305#define PPP_BITRATE_56000 0x08
306#define PPP_BITRATE_64000 0x09
307#define PPP_BITRATE_74000 0x0A
308#define PPP_BITRATE_112000 0x0B
309#define PPP_BITRATE_128000 0x0C
310#define PPP_BITRATE_156000 0x0D
311
312/* Defines for the 'conf_flags' field */
313#define PPP_IGNORE_TX_ABORT 0x01 /* don't re-transmit aborted frames */
314#define PPP_ENABLE_TX_STATS 0x02 /* enable Tx statistics */
315#define PPP_ENABLE_RX_STATS 0x04 /* enable Rx statistics */
316#define PPP_ENABLE_TIMESTAMP 0x08 /* enable timestamp */
317
318/* 'ip_options' defines */
319#define PPP_LOCAL_IP_LOCAL 0x01
320#define PPP_LOCAL_IP_REMOTE 0x02
321#define PPP_REMOTE_IP_LOCAL 0x04
322#define PPP_REMOTE_IP_REMOTE 0x08
323
324/* 'ipx_options' defines */
325#define PPP_REMOTE_IPX_NETNO 0x01
326#define PPP_REMOTE_IPX_LOCAL 0x02
327#define PPP_REMOTE_IPX_REMOTE 0x04
328#define PPP_IPX_ROUTE_RIP_SAP 0x08
329#define PPP_IPX_ROUTE_NLSP 0x10
330#define PPP_IPX_ROUTE_DEFAULT 0x20
331#define PPP_IPX_CONF_COMPLETE 0x40
332#define PPP_IPX_ENABLE 0x80
333
334/*----------------------------------------------------------------------------
335 * S508 Adapter Configuration Block (returned by the PPP_READ_CONFIG command).
336 */
337typedef struct ppp508_get_conf
338{
339 unsigned long bps PACKED; /* 00: baud rate, bps */
340 ppp508_conf_t conf PACKED; /* 04: requested config. */
341 unsigned short txb_num PACKED; /* 6F: number of Tx buffers */
342 unsigned short rxb_num PACKED; /* 71: number of Rx buffers */
343} ppp508_get_conf_t;
344
345/*----------------------------------------------------------------------------
346 * S508 Operational Statistics (returned by the PPP_READ_STATISTIC command).
347 */
348typedef struct ppp508_stats
349{
350 unsigned short reserved1 PACKED; /* 00: */
351 unsigned short rx_bad_len PACKED; /* 02: */
352 unsigned short reserved2 PACKED; /* 04: */
353 unsigned long tx_frames PACKED; /* 06: */
354 unsigned long tx_bytes PACKED; /* 0A: */
355 unsigned long rx_frames PACKED; /* 0E: */
356 unsigned long rx_bytes PACKED; /* 12: */
357} ppp508_stats_t;
358
359/*----------------------------------------------------------------------------
360 * Adapter Error Statistics (returned by the PPP_READ_ERROR_STATS command).
361 */
362typedef struct ppp_err_stats
363{
364 unsigned char rx_overrun PACKED; /* 00: Rx overrun errors */
365 unsigned char rx_bad_crc PACKED; /* 01: Rx CRC errors */
366 unsigned char rx_abort PACKED; /* 02: Rx aborted frames */
367 unsigned char rx_lost PACKED; /* 03: Rx frames lost */
368 unsigned char tx_abort PACKED; /* 04: Tx aborted frames */
369 unsigned char tx_underrun PACKED; /* 05: Tx underrun errors */
370 unsigned char tx_missed_intr PACKED; /* 06: Tx underruns missed */
371 unsigned char reserved PACKED; /* 07: Tx underruns missed */
372 unsigned char dcd_trans PACKED; /* 08: DCD transitions */
373 unsigned char cts_trans PACKED; /* 09: CTS transitions */
374} ppp_err_stats_t;
375
376/*----------------------------------------------------------------------------
377 * Packet Statistics (returned by the PPP_READ_PACKET_STATS command).
378 */
379typedef struct ppp_pkt_stats
380{
381 unsigned short rx_bad_header PACKED; /* 00: */
382 unsigned short rx_prot_unknwn PACKED; /* 02: */
383 unsigned short rx_too_large PACKED; /* 04: */
384 unsigned short rx_lcp PACKED; /* 06: */
385 unsigned short tx_lcp PACKED; /* 08: */
386 unsigned short rx_ipcp PACKED; /* 0A: */
387 unsigned short tx_ipcp PACKED; /* 0C: */
388 unsigned short rx_ipxcp PACKED; /* 0E: */
389 unsigned short tx_ipxcp PACKED; /* 10: */
390 unsigned short rx_pap PACKED; /* 12: */
391 unsigned short tx_pap PACKED; /* 14: */
392 unsigned short rx_chap PACKED; /* 16: */
393 unsigned short tx_chap PACKED; /* 18: */
394 unsigned short rx_lqr PACKED; /* 1A: */
395 unsigned short tx_lqr PACKED; /* 1C: */
396 unsigned short rx_ip PACKED; /* 1E: */
397 unsigned short tx_ip PACKED; /* 20: */
398 unsigned short rx_ipx PACKED; /* 22: */
399 unsigned short tx_ipx PACKED; /* 24: */
400} ppp_pkt_stats_t;
401
402/*----------------------------------------------------------------------------
403 * LCP Statistics (returned by the PPP_READ_LCP_STATS command).
404 */
405typedef struct ppp_lcp_stats
406{
407 unsigned short rx_unknown PACKED; /* 00: unknown LCP type */
408 unsigned short rx_conf_rqst PACKED; /* 02: Configure-Request */
409 unsigned short rx_conf_ack PACKED; /* 04: Configure-Ack */
410 unsigned short rx_conf_nak PACKED; /* 06: Configure-Nak */
411 unsigned short rx_conf_rej PACKED; /* 08: Configure-Reject */
412 unsigned short rx_term_rqst PACKED; /* 0A: Terminate-Request */
413 unsigned short rx_term_ack PACKED; /* 0C: Terminate-Ack */
414 unsigned short rx_code_rej PACKED; /* 0E: Code-Reject */
415 unsigned short rx_proto_rej PACKED; /* 10: Protocol-Reject */
416 unsigned short rx_echo_rqst PACKED; /* 12: Echo-Request */
417 unsigned short rx_echo_reply PACKED; /* 14: Echo-Reply */
418 unsigned short rx_disc_rqst PACKED; /* 16: Discard-Request */
419 unsigned short tx_conf_rqst PACKED; /* 18: Configure-Request */
420 unsigned short tx_conf_ack PACKED; /* 1A: Configure-Ack */
421 unsigned short tx_conf_nak PACKED; /* 1C: Configure-Nak */
422 unsigned short tx_conf_rej PACKED; /* 1E: Configure-Reject */
423 unsigned short tx_term_rqst PACKED; /* 20: Terminate-Request */
424 unsigned short tx_term_ack PACKED; /* 22: Terminate-Ack */
425 unsigned short tx_code_rej PACKED; /* 24: Code-Reject */
426 unsigned short tx_proto_rej PACKED; /* 26: Protocol-Reject */
427 unsigned short tx_echo_rqst PACKED; /* 28: Echo-Request */
428 unsigned short tx_echo_reply PACKED; /* 2A: Echo-Reply */
429 unsigned short tx_disc_rqst PACKED; /* 2E: Discard-Request */
430 unsigned short rx_too_large PACKED; /* 30: packets too large */
431 unsigned short rx_ack_inval PACKED; /* 32: invalid Conf-Ack */
432 unsigned short rx_rej_inval PACKED; /* 34: invalid Conf-Reject */
433 unsigned short rx_rej_badid PACKED; /* 36: Conf-Reject w/bad ID */
434} ppp_lcp_stats_t;
435
436/*----------------------------------------------------------------------------
437 * Loopback Error Statistics (returned by the PPP_READ_LPBK_STATS command).
438 */
439typedef struct ppp_lpbk_stats
440{
441 unsigned short conf_magic PACKED; /* 00: */
442 unsigned short loc_echo_rqst PACKED; /* 02: */
443 unsigned short rem_echo_rqst PACKED; /* 04: */
444 unsigned short loc_echo_reply PACKED; /* 06: */
445 unsigned short rem_echo_reply PACKED; /* 08: */
446 unsigned short loc_disc_rqst PACKED; /* 0A: */
447 unsigned short rem_disc_rqst PACKED; /* 0C: */
448 unsigned short echo_tx_collsn PACKED; /* 0E: */
449 unsigned short echo_rx_collsn PACKED; /* 10: */
450} ppp_lpbk_stats_t;
451
452/*----------------------------------------------------------------------------
453 * Protocol Statistics (returned by the PPP_READ_IPCP_STATS and
454 * PPP_READ_IPXCP_STATS commands).
455 */
456typedef struct ppp_prot_stats
457{
458 unsigned short rx_unknown PACKED; /* 00: unknown type */
459 unsigned short rx_conf_rqst PACKED; /* 02: Configure-Request */
460 unsigned short rx_conf_ack PACKED; /* 04: Configure-Ack */
461 unsigned short rx_conf_nak PACKED; /* 06: Configure-Nak */
462 unsigned short rx_conf_rej PACKED; /* 08: Configure-Reject */
463 unsigned short rx_term_rqst PACKED; /* 0A: Terminate-Request */
464 unsigned short rx_term_ack PACKED; /* 0C: Terminate-Ack */
465 unsigned short rx_code_rej PACKED; /* 0E: Code-Reject */
466 unsigned short reserved PACKED; /* 10: */
467 unsigned short tx_conf_rqst PACKED; /* 12: Configure-Request */
468 unsigned short tx_conf_ack PACKED; /* 14: Configure-Ack */
469 unsigned short tx_conf_nak PACKED; /* 16: Configure-Nak */
470 unsigned short tx_conf_rej PACKED; /* 18: Configure-Reject */
471 unsigned short tx_term_rqst PACKED; /* 1A: Terminate-Request */
472 unsigned short tx_term_ack PACKED; /* 1C: Terminate-Ack */
473 unsigned short tx_code_rej PACKED; /* 1E: Code-Reject */
474 unsigned short rx_too_large PACKED; /* 20: packets too large */
475 unsigned short rx_ack_inval PACKED; /* 22: invalid Conf-Ack */
476 unsigned short rx_rej_inval PACKED; /* 24: invalid Conf-Reject */
477 unsigned short rx_rej_badid PACKED; /* 26: Conf-Reject w/bad ID */
478} ppp_prot_stats_t;
479
480/*----------------------------------------------------------------------------
481 * PAP Statistics (returned by the PPP_READ_PAP_STATS command).
482 */
483typedef struct ppp_pap_stats
484{
485 unsigned short rx_unknown PACKED; /* 00: unknown type */
486 unsigned short rx_auth_rqst PACKED; /* 02: Authenticate-Request */
487 unsigned short rx_auth_ack PACKED; /* 04: Authenticate-Ack */
488 unsigned short rx_auth_nak PACKED; /* 06: Authenticate-Nak */
489 unsigned short reserved PACKED; /* 08: */
490 unsigned short tx_auth_rqst PACKED; /* 0A: Authenticate-Request */
491 unsigned short tx_auth_ack PACKED; /* 0C: Authenticate-Ack */
492 unsigned short tx_auth_nak PACKED; /* 0E: Authenticate-Nak */
493 unsigned short rx_too_large PACKED; /* 10: packets too large */
494 unsigned short rx_bad_peerid PACKED; /* 12: invalid peer ID */
495 unsigned short rx_bad_passwd PACKED; /* 14: invalid password */
496} ppp_pap_stats_t;
497
498/*----------------------------------------------------------------------------
499 * CHAP Statistics (returned by the PPP_READ_CHAP_STATS command).
500 */
501typedef struct ppp_chap_stats
502{
503 unsigned short rx_unknown PACKED; /* 00: unknown type */
504 unsigned short rx_challenge PACKED; /* 02: Authenticate-Request */
505 unsigned short rx_response PACKED; /* 04: Authenticate-Ack */
506 unsigned short rx_success PACKED; /* 06: Authenticate-Nak */
507 unsigned short rx_failure PACKED; /* 08: Authenticate-Nak */
508 unsigned short reserved PACKED; /* 0A: */
509 unsigned short tx_challenge PACKED; /* 0C: Authenticate-Request */
510 unsigned short tx_response PACKED; /* 0E: Authenticate-Ack */
511 unsigned short tx_success PACKED; /* 10: Authenticate-Nak */
512 unsigned short tx_failure PACKED; /* 12: Authenticate-Nak */
513 unsigned short rx_too_large PACKED; /* 14: packets too large */
514 unsigned short rx_bad_peerid PACKED; /* 16: invalid peer ID */
515 unsigned short rx_bad_passwd PACKED; /* 18: invalid password */
516 unsigned short rx_bad_md5 PACKED; /* 1A: invalid MD5 format */
517 unsigned short rx_bad_resp PACKED; /* 1C: invalid response */
518} ppp_chap_stats_t;
519
520/*----------------------------------------------------------------------------
521 * Connection Information (returned by the PPP_GET_CONNECTION_INFO command).
522 */
523typedef struct ppp_conn_info
524{
525 unsigned short remote_mru PACKED; /* 00: */
526 unsigned char ip_options PACKED; /* 02: */
527 unsigned char ip_local[4] PACKED; /* 03: */
528 unsigned char ip_remote[4] PACKED; /* 07: */
529 unsigned char ipx_options PACKED; /* 0B: */
530 unsigned char ipx_network[4] PACKED; /* 0C: */
531 unsigned char ipx_local[6] PACKED; /* 10: */
532 unsigned char ipx_remote[6] PACKED; /* 16: */
533 unsigned char ipx_router[48] PACKED; /* 1C: */
534 unsigned char auth_status PACKED; /* 4C: */
535 unsigned char peer_id[0] PACKED; /* 4D: */
536} ppp_conn_info_t;
537
538/* Data structure for SET_TRIGGER_INTR command
539 */
540
541typedef struct ppp_intr_info{
542 unsigned char i_enable PACKED; /* 0 Interrupt enable bits */
543 unsigned char irq PACKED; /* 1 Irq number */
544 unsigned short timer_len PACKED; /* 2 Timer delay */
545} ppp_intr_info_t;
546
547
548#define FT1_MONITOR_STATUS_CTRL 0x80
549#define SET_FT1_MODE 0x81
550
551
552
553/* Special UDP drivers management commands */
554#define PPIPE_ENABLE_TRACING 0x20
555#define PPIPE_DISABLE_TRACING 0x21
556#define PPIPE_GET_TRACE_INFO 0x22
557#define PPIPE_GET_IBA_DATA 0x23
558#define PPIPE_KILL_BOARD 0x24
559#define PPIPE_FT1_READ_STATUS 0x25
560#define PPIPE_DRIVER_STAT_IFSEND 0x26
561#define PPIPE_DRIVER_STAT_INTR 0x27
562#define PPIPE_DRIVER_STAT_GEN 0x28
563#define PPIPE_FLUSH_DRIVER_STATS 0x29
564#define PPIPE_ROUTER_UP_TIME 0x30
565
566#define DISABLE_TRACING 0x00
567#define TRACE_SIGNALLING_FRAMES 0x01
568#define TRACE_DATA_FRAMES 0x02
569
570
571
572#ifdef _MSC_
573# pragma pack()
574#endif
575#endif /* _SDLA_PPP_H */
diff --git a/include/linux/sdla_x25.h b/include/linux/sdla_x25.h
new file mode 100644
index 000000000000..57db980e27ad
--- /dev/null
+++ b/include/linux/sdla_x25.h
@@ -0,0 +1,772 @@
1/*****************************************************************************
2* sdla_x25.h Sangoma X.25 firmware API definitions.
3*
4* Author: Nenad Corbic <ncorbic@sangoma.com>
5*
6* Copyright: (c) 1995-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* Feb 28, 2000 Nenad Corbic Updated for socket based x25api
14* Dec 13, 1996 Gene Kozin Initial version
15*****************************************************************************/
16#ifndef _SDLA_X25_H
17#define _SDLA_X25_H
18
19/*----------------------------------------------------------------------------
20 * Notes:
21 * ------
22 * 1. All structures defined in this file are byte-alined.
23 * Compiler Platform
24 * -------- --------
25 * GNU C Linux
26 *
27 */
28
29#ifndef PACKED
30# define PACKED __attribute__((packed))
31#endif /* PACKED */
32
33/****** CONSTANTS DEFINITIONS ***********************************************/
34
35#define X25_MAX_CHAN 255 /* max number of open X.25 circuits */
36#define X25_MAX_DATA 1024 /* max length of X.25 data buffer */
37/*
38 * X.25 shared memory layout.
39 */
40#define X25_MBOX_OFFS 0x16B0 /* general mailbox block */
41#define X25_RXMBOX_OFFS 0x1AD0 /* receive mailbox */
42#define X25_STATUS_OFFS 0x1EF0 /* X.25 status structure */
43#define X25_MB_VECTOR 0xE000 /* S514 mailbox window vecotr */
44#define X25_MISC_HDLC_BITS 0x1F00 /*X.25 miscallaneous HDLC bits */
45
46/* code levels */
47#define HDLC_LEVEL 0x01
48#define X25_LEVEL 0x02
49#define X25_AND_HDLC_LEVEL 0x03
50#define DO_HDLC_LEVEL_ERROR_CHECKING 0x04
51
52/****** DATA STRUCTURES *****************************************************/
53
54/*----------------------------------------------------------------------------
55 * X.25 Command Block.
56 */
57typedef struct X25Cmd
58{
59 unsigned char command PACKED; /* command code */
60 unsigned short length PACKED; /* transfer data length */
61 unsigned char result PACKED; /* return code */
62 unsigned char pf PACKED; /* P/F bit */
63 unsigned short lcn PACKED; /* logical channel */
64 unsigned char qdm PACKED; /* Q/D/M bits */
65 unsigned char cause PACKED; /* cause field */
66 unsigned char diagn PACKED; /* diagnostics */
67 unsigned char pktType PACKED; /* packet type */
68 unsigned char resrv[4] PACKED; /* reserved */
69} TX25Cmd;
70
71/*
72 * Defines for the 'command' field.
73 */
74/*----- General commands --------------*/
75#define X25_SET_GLOBAL_VARS 0x0B /* set global variables */
76#define X25_READ_MODEM_STATUS 0x0C /* read modem status */
77#define X25_READ_CODE_VERSION 0x15 /* read firmware version number */
78#define X25_TRACE_CONFIGURE 0x14 /* configure trace facility */
79#define X25_READ_TRACE_DATA 0x16 /* read trace data */
80#define X25_SET_INTERRUPT_MODE 0x17 /* set interrupt generation mode */
81#define X25_READ_INTERRUPT_MODE 0x18 /* read interrupt generation mode */
82/*----- HDLC-level commands -----------*/
83#define X25_HDLC_LINK_CONFIGURE 0x01 /* configure HDLC link level */
84#define X25_HDLC_LINK_OPEN 0x02 /* open HDLC link */
85#define X25_HDLC_LINK_CLOSE 0x03 /* close HDLC link */
86#define X25_HDLC_LINK_SETUP 0x04 /* set up HDLC link */
87#define X25_HDLC_LINK_DISC 0x05 /* disconnect DHLC link */
88#define X25_HDLC_LINK_STATUS 0x06 /* read DHLC link status */
89#define X25_HDLC_READ_STATS 0x07 /* read operational statistics */
90#define X25_HDLC_FLUSH_STATS 0x08 /* flush operational statistics */
91#define X25_HDLC_READ_COMM_ERR 0x09 /* read error statistics */
92#define X25_HDLC_FLUSH_COMM_ERR 0x0A /* flush error statistics */
93#define X25_HDLC_FLUSH_BUFFERS 0x0D /* flush HDLC-level data buffers */
94#define X25_HDLC_SPRVS_CNT_STAT 0x0F /* read surervisory count status */
95#define X25_HDLC_SEND_UI_FRAME 0x10 /* send unnumbered information frame */
96#define X25_HDLC_WRITE 0x11 /* send HDLC information frame */
97#define X25_HDLC_READ 0x21 /* read HDLC information frame */
98#define X25_HDLC_READ_CONFIG 0x12 /* read HDLC configuration */
99#define X25_HDLC_SET_CONFIG 0x13 /* set HDLC configuration */
100#define SET_PROTOCOL_LEVEL 0x1F /* set protocol level */
101/*----- X.25-level commands -----------*/
102#define X25_READ 0x22 /* read X.25 packet */
103#define X25_WRITE 0x23 /* send X.25 packet */
104#define X25_PLACE_CALL 0x30 /* place a call on SVC */
105#define X25_ACCEPT_CALL 0x31 /* accept incomming call */
106#define X25_CLEAR_CALL 0x32 /* clear call */
107#define X25_CLEAR_CONFRM 0x33 /* send clear confirmation packet */
108#define X25_RESET 0x34 /* send reset request packet */
109#define X25_RESET_CONFRM 0x35 /* send reset confirmation packet */
110#define X25_RESTART 0x36 /* send restart request packet */
111#define X25_RESTART_CONFRM 0x37 /* send restart confirmation packet */
112#define X25_INTERRUPT 0x38 /* send interrupt request packet */
113#define X25_INTERRUPT_CONFRM 0x39 /* send interrupt confirmation pkt */
114#define X25_REGISTRATION_RQST 0x3A /* send registration request packet */
115#define X25_REGISTRATION_CONFRM 0x3B /* send registration confirmation */
116#define X25_IS_DATA_AVAILABLE 0x40 /* querry receive queue */
117#define X25_INCOMMING_CALL_CTL 0x41 /* select incomming call options */
118#define X25_CONFIGURE_PVC 0x42 /* configure PVC */
119#define X25_GET_ACTIVE_CHANNELS 0x43 /* get a list of active circuits */
120#define X25_READ_CHANNEL_CONFIG 0x44 /* read virt. circuit configuration */
121#define X25_FLUSH_DATA_BUFFERS 0x45 /* flush X.25-level data buffers */
122#define X25_READ_HISTORY_TABLE 0x46 /* read asynchronous event log */
123#define X25_HISTORY_TABLE_CTL 0x47 /* control asynchronous event log */
124#define X25_GET_TX_D_BIT_STATUS 0x48 /* is packet with D-bit acknowleged */
125#define X25_READ_STATISTICS 0x49 /* read X.25-level statistics */
126#define X25_FLUSH_STATISTICS 0x4A /* flush X.25-level statistics */
127#define X25_READ_CONFIGURATION 0x50 /* read HDLC & X.25 configuration */
128#define X25_SET_CONFIGURATION 0x51 /* set HDLC & X.25 configuration */
129
130/*
131 * Defines for the 'result' field.
132 */
133/*----- General results ---------------*/
134#define X25RES_OK 0x00
135#define X25RES_ERROR 0x01
136#define X25RES_LINK_NOT_IN_ABM 0x02 /* link is not in ABM mode */
137#define X25RES_LINK_CLOSED 0x03
138#define X25RES_INVAL_LENGTH 0x04
139#define X25RES_INVAL_CMD 0x05
140#define X25RES_UNNUMBERED_FRAME 0x06 /* unnunbered frame received */
141#define X25RES_FRM_REJECT_MODE 0x07 /* link is in Frame Reject mode */
142#define X25RES_MODEM_FAILURE 0x08 /* DCD and/or CTS dropped */
143#define X25RES_N2_RETRY_LIMIT 0x09 /* N2 retry limit has been exceeded */
144#define X25RES_INVAL_LCN 0x30 /* invalid logical channel number */
145#define X25RES_INVAL_STATE 0x31 /* channel is not in data xfer mode */
146#define X25RES_INVAL_DATA_LEN 0x32 /* invalid data length */
147#define X25RES_NOT_READY 0x33 /* no data available / buffers full */
148#define X25RES_NETWORK_DOWN 0x34
149#define X25RES_CHANNEL_IN_USE 0x35 /* there is data queued on this LCN */
150#define X25RES_REGST_NOT_SUPPRT 0x36 /* registration not supported */
151#define X25RES_INVAL_FORMAT 0x37 /* invalid packet format */
152#define X25RES_D_BIT_NOT_SUPPRT 0x38 /* D-bit pragmatics not supported */
153#define X25RES_FACIL_NOT_SUPPRT 0x39 /* Call facility not supported */
154#define X25RES_INVAL_CALL_ARG 0x3A /* errorneous call arguments */
155#define X25RES_INVAL_CALL_DATA 0x3B /* errorneous call user data */
156#define X25RES_ASYNC_PACKET 0x40 /* asynchronous packet received */
157#define X25RES_PROTO_VIOLATION 0x41 /* protocol violation occurred */
158#define X25RES_PKT_TIMEOUT 0x42 /* X.25 packet time out */
159#define X25RES_PKT_RETRY_LIMIT 0x43 /* X.25 packet retry limit exceeded */
160/*----- Command-dependent results -----*/
161#define X25RES_LINK_DISC 0x00 /* HDLC_LINK_STATUS */
162#define X25RES_LINK_IN_ABM 0x01 /* HDLC_LINK_STATUS */
163#define X25RES_NO_DATA 0x01 /* HDLC_READ/READ_TRACE_DATA*/
164#define X25RES_TRACE_INACTIVE 0x02 /* READ_TRACE_DATA */
165#define X25RES_LINK_IS_OPEN 0x01 /* HDLC_LINK_OPEN */
166#define X25RES_LINK_IS_DISC 0x02 /* HDLC_LINK_DISC */
167#define X25RES_LINK_IS_CLOSED 0x03 /* HDLC_LINK_CLOSE */
168#define X25RES_INVAL_PARAM 0x31 /* INCOMMING_CALL_CTL */
169#define X25RES_INVAL_CONFIG 0x35 /* REGISTR_RQST/CONFRM */
170
171/*
172 * Defines for the 'qdm_bits' field.
173 */
174#define X25CMD_Q_BIT_MASK 0x04
175#define X25CMD_D_BIT_MASK 0x02
176#define X25CMD_M_BIT_MASK 0x01
177
178/*
179 * Defines for the 'pkt_type' field.
180 */
181/*----- Asynchronous events ------*/
182#define ASE_CLEAR_RQST 0x02
183#define ASE_RESET_RQST 0x04
184#define ASE_RESTART_RQST 0x08
185#define ASE_INTERRUPT 0x10
186#define ASE_DTE_REGISTR_RQST 0x20
187#define ASE_CALL_RQST 0x30
188#define ASE_CALL_ACCEPTED 0x31
189#define ASE_CLEAR_CONFRM 0x32
190#define ASE_RESET_CONFRM 0x33
191#define ASE_RESTART_CONFRM 0x34
192#define ASE_INTERRUPT_CONFRM 0x35
193#define ASE_DCE_REGISTR_CONFRM 0x36
194#define ASE_DIAGNOSTIC 0x37
195#define ASE_CALL_AUTO_CLEAR 0x38
196#define AUTO_RESPONSE_FLAG 0x80
197/*----- Time-Out events ----------*/
198#define TOE_RESTART_RQST 0x03
199#define TOE_CALL_RQST 0x05
200#define TOE_CLEAR_RQST 0x08
201#define TOE_RESET_RQST 0x0A
202/*----- Protocol Violation events */
203#define PVE_CLEAR_RQST 0x32
204#define PVE_RESET_RQST 0x33
205#define PVE_RESTART_RQST 0x34
206#define PVE_DIAGNOSTIC 0x37
207
208#define INTR_ON_RX_FRAME 0x01
209#define INTR_ON_TX_FRAME 0x02
210#define INTR_ON_MODEM_STATUS_CHANGE 0x04
211#define INTR_ON_COMMAND_COMPLETE 0x08
212#define INTR_ON_X25_ASY_TRANSACTION 0x10
213#define INTR_ON_TIMER 0x40
214#define DIRECT_RX_INTR_USAGE 0x80
215
216#define NO_INTR_PENDING 0x00
217#define RX_INTR_PENDING 0x01
218#define TX_INTR_PENDING 0x02
219#define MODEM_INTR_PENDING 0x04
220#define COMMAND_COMPLETE_INTR_PENDING 0x08
221#define X25_ASY_TRANS_INTR_PENDING 0x10
222#define TIMER_INTR_PENDING 0x40
223
224/*----------------------------------------------------------------------------
225 * X.25 Mailbox.
226 * This structure is located at offsets X25_MBOX_OFFS and X25_RXMBOX_OFFS
227 * into shared memory window.
228 */
229typedef struct X25Mbox
230{
231 unsigned char opflag PACKED; /* 00h: execution flag */
232 TX25Cmd cmd PACKED; /* 01h: command block */
233 unsigned char data[1] PACKED; /* 10h: data buffer */
234} TX25Mbox;
235
236/*----------------------------------------------------------------------------
237 * X.25 Time Stamp Structure.
238 */
239typedef struct X25TimeStamp
240{
241 unsigned char month PACKED;
242 unsigned char date PACKED;
243 unsigned char sec PACKED;
244 unsigned char min PACKED;
245 unsigned char hour PACKED;
246} TX25TimeStamp;
247
248/*----------------------------------------------------------------------------
249 * X.25 Status Block.
250 * This structure is located at offset X25_STATUS_OFF into shared memory
251 * window.
252 */
253typedef struct X25Status
254{
255 unsigned short pvc_map PACKED; /* 00h: PVC map */
256 unsigned short icc_map PACKED; /* 02h: Incomming Chan. map */
257 unsigned short twc_map PACKED; /* 04h: Two-way Cnan. map */
258 unsigned short ogc_map PACKED; /* 06h: Outgoing Chan. map */
259 TX25TimeStamp tstamp PACKED; /* 08h: timestamp (BCD) */
260 unsigned char iflags PACKED; /* 0Dh: interrupt flags */
261 unsigned char imask PACKED; /* 0Eh: interrupt mask */
262 unsigned char resrv PACKED; /* 0Eh: */
263 unsigned char gflags PACKED; /* 10h: misc. HDLC/X25 flags */
264 unsigned char cflags[X25_MAX_CHAN] PACKED; /* channel status bytes */
265} TX25Status;
266
267/*
268 * Bitmasks for the 'iflags' field.
269 */
270#define X25_RX_INTR 0x01 /* receive interrupt */
271#define X25_TX_INTR 0x02 /* transmit interrupt */
272#define X25_MODEM_INTR 0x04 /* modem status interrupt (CTS/DCD) */
273#define X25_EVENT_INTR 0x10 /* asyncronous event encountered */
274#define X25_CMD_INTR 0x08 /* interface command complete */
275
276/*
277 * Bitmasks for the 'gflags' field.
278 */
279#define X25_HDLC_ABM 0x01 /* HDLC is in ABM mode */
280#define X25_RX_READY 0x02 /* X.25 data available */
281#define X25_TRACE_READY 0x08 /* trace data available */
282#define X25_EVENT_IND 0x20 /* asynchronous event indicator */
283#define X25_TX_READY 0x40 /* space is available in Tx buf.*/
284
285/*
286 * Bitmasks for the 'cflags' field.
287 */
288#define X25_XFER_MODE 0x80 /* channel is in data transfer mode */
289#define X25_TXWIN_OPEN 0x40 /* transmit window open */
290#define X25_RXBUF_MASK 0x3F /* number of data buffers available */
291
292/*****************************************************************************
293 * Following definitions structurize contents of the TX25Mbox.data field for
294 * different X.25 interface commands.
295 ****************************************************************************/
296
297/* ---------------------------------------------------------------------------
298 * X25_SET_GLOBAL_VARS Command.
299 */
300typedef struct X25GlobalVars
301{
302 unsigned char resrv PACKED; /* 00h: reserved */
303 unsigned char dtrCtl PACKED; /* 01h: DTR control code */
304 unsigned char resErr PACKED; /* 01h: '1' - reset modem error */
305} TX25GlobalVars;
306
307/*
308 * Defines for the 'dtrCtl' field.
309 */
310#define X25_RAISE_DTR 0x01
311#define X25_DROP_DTR 0x02
312
313/* ---------------------------------------------------------------------------
314 * X25_READ_MODEM_STATUS Command.
315 */
316typedef struct X25ModemStatus
317{
318 unsigned char status PACKED; /* 00h: modem status */
319} TX25ModemStatus;
320
321/*
322 * Defines for the 'status' field.
323 */
324#define X25_CTS_MASK 0x20
325#define X25_DCD_MASK 0x08
326
327/* ---------------------------------------------------------------------------
328 * X25_HDLC_LINK_STATUS Command.
329 */
330typedef struct X25LinkStatus
331{
332 unsigned char txQueued PACKED; /* 00h: queued Tx I-frames*/
333 unsigned char rxQueued PACKED; /* 01h: queued Rx I-frames*/
334 unsigned char station PACKED; /* 02h: DTE/DCE config. */
335 unsigned char reserved PACKED; /* 03h: reserved */
336 unsigned char sfTally PACKED; /* 04h: supervisory frame tally */
337} TX25LinkStatus;
338
339/*
340 * Defines for the 'station' field.
341 */
342#define X25_STATION_DTE 0x01 /* station configured as DTE */
343#define X25_STATION_DCE 0x02 /* station configured as DCE */
344
345/* ---------------------------------------------------------------------------
346 * X25_HDLC_READ_STATS Command.
347 */
348typedef struct HdlcStats
349{ /* a number of ... */
350 unsigned short rxIFrames PACKED; /* 00h: ready Rx I-frames */
351 unsigned short rxNoseq PACKED; /* 02h: frms out-of-sequence */
352 unsigned short rxNodata PACKED; /* 04h: I-frms without data */
353 unsigned short rxDiscarded PACKED; /* 06h: discarded frames */
354 unsigned short rxTooLong PACKED; /* 08h: frames too long */
355 unsigned short rxBadAddr PACKED; /* 0Ah: frms with inval.addr*/
356 unsigned short txAcked PACKED; /* 0Ch: acknowledged I-frms */
357 unsigned short txRetransm PACKED; /* 0Eh: re-transmit. I-frms */
358 unsigned short t1Timeout PACKED; /* 10h: T1 timeouts */
359 unsigned short rxSABM PACKED; /* 12h: received SABM frames */
360 unsigned short rxDISC PACKED; /* 14h: received DISC frames */
361 unsigned short rxDM PACKED; /* 16h: received DM frames */
362 unsigned short rxFRMR PACKED; /* 18h: FRMR frames received */
363 unsigned short txSABM PACKED; /* 1Ah: transm. SABM frames*/
364 unsigned short txDISC PACKED; /* 1Ch: transm. DISC frames*/
365 unsigned short txDM PACKED; /* 1Eh: transm. DM frames */
366 unsigned short txFRMR PACKED; /* 20h: transm. FRMR frames*/
367} THdlcStats;
368
369/* ---------------------------------------------------------------------------
370 * X25_HDLC_READ_COMM_ERR Command.
371 */
372typedef struct HdlcCommErr
373{ /* a number of ... */
374 unsigned char rxOverrun PACKED; /* 00h: Rx overrun errors */
375 unsigned char rxBadCrc PACKED; /* 01h: Rx CRC errors */
376 unsigned char rxAborted PACKED; /* 02h: Rx aborted frames */
377 unsigned char rxDropped PACKED; /* 03h: frames lost */
378 unsigned char txAborted PACKED; /* 04h: Tx aborted frames */
379 unsigned char txUnderrun PACKED; /* 05h: Tx underrun errors */
380 unsigned char txMissIntr PACKED; /* 06h: missed underrun ints */
381 unsigned char reserved PACKED; /* 07h: reserved */
382 unsigned char droppedDCD PACKED; /* 08h: times DCD dropped */
383 unsigned char droppedCTS PACKED; /* 09h: times CTS dropped */
384} THdlcCommErr;
385
386/* ---------------------------------------------------------------------------
387 * X25_SET_CONFIGURATION & X25_READ_CONFIGURATION Commands.
388 */
389typedef struct X25Config
390{
391unsigned char baudRate PACKED; /* 00h: */
392 unsigned char t1 PACKED; /* 01h: */
393 unsigned char t2 PACKED; /* 02h: */
394 unsigned char n2 PACKED; /* 03h: */
395 unsigned short hdlcMTU PACKED; /* 04h: */
396 unsigned char hdlcWindow PACKED; /* 06h: */
397 unsigned char t4 PACKED; /* 07h: */
398 unsigned char autoModem PACKED; /* 08h: */
399 unsigned char autoHdlc PACKED; /* 09h: */
400 unsigned char hdlcOptions PACKED; /* 0Ah: */
401 unsigned char station PACKED; /* 0Bh: */
402 unsigned char pktWindow PACKED; /* 0Ch: */
403 unsigned short defPktSize PACKED; /* 0Dh: */
404 unsigned short pktMTU PACKED; /* 0Fh: */
405 unsigned short loPVC PACKED; /* 11h: */
406 unsigned short hiPVC PACKED; /* 13h: */
407 unsigned short loIncommingSVC PACKED; /* 15h: */
408 unsigned short hiIncommingSVC PACKED; /* 17h: */
409 unsigned short loTwoWaySVC PACKED; /* 19h: */
410 unsigned short hiTwoWaySVC PACKED; /* 1Bh: */
411 unsigned short loOutgoingSVC PACKED; /* 1Dh: */
412 unsigned short hiOutgoingSVC PACKED; /* 1Fh: */
413 unsigned short options PACKED; /* 21h: */
414 unsigned char responseOpt PACKED; /* 23h: */
415 unsigned short facil1 PACKED; /* 24h: */
416 unsigned short facil2 PACKED; /* 26h: */
417 unsigned short ccittFacil PACKED; /* 28h: */
418 unsigned short otherFacil PACKED; /* 2Ah: */
419 unsigned short ccittCompat PACKED; /* 2Ch: */
420 unsigned char t10t20 PACKED; /* 2Eh: */
421 unsigned char t11t21 PACKED; /* 2Fh: */
422 unsigned char t12t22 PACKED; /* 30h: */
423 unsigned char t13t23 PACKED; /* 31h: */
424 unsigned char t16t26 PACKED; /* 32H: */
425 unsigned char t28 PACKED; /* 33h: */
426 unsigned char r10r20 PACKED; /* 34h: */
427 unsigned char r12r22 PACKED; /* 35h: */
428 unsigned char r13r23 PACKED; /* 36h: */
429} TX25Config;
430
431/* ---------------------------------------------------------------------------
432 * X25_READ_CHANNEL_CONFIG Command.
433 */
434typedef struct X25ChanAlloc /*----- Channel allocation -*/
435{
436 unsigned short loPVC PACKED; /* 00h: lowest PVC number */
437 unsigned short hiPVC PACKED; /* 02h: highest PVC number */
438 unsigned short loIncommingSVC PACKED; /* 04h: lowest incoming SVC */
439 unsigned short hiIncommingSVC PACKED; /* 06h: highest incoming SVC */
440 unsigned short loTwoWaySVC PACKED; /* 08h: lowest two-way SVC */
441 unsigned short hiTwoWaySVC PACKED; /* 0Ah: highest two-way SVC */
442 unsigned short loOutgoingSVC PACKED; /* 0Ch: lowest outgoing SVC */
443 unsigned short hiOutgoingSVC PACKED; /* 0Eh: highest outgoing SVC */
444} TX25ChanAlloc;
445
446typedef struct X25ChanCfg /*------ Channel configuration -----*/
447{
448 unsigned char type PACKED; /* 00h: channel type */
449 unsigned char txConf PACKED; /* 01h: Tx packet and window sizes */
450 unsigned char rxConf PACKED; /* 01h: Rx packet and window sizes */
451} TX25ChanCfg;
452
453/*
454 * Defines for the 'type' field.
455 */
456#define X25_PVC 0x01 /* PVC */
457#define X25_SVC_IN 0x03 /* Incoming SVC */
458#define X25_SVC_TWOWAY 0x07 /* Two-way SVC */
459#define X25_SVC_OUT 0x0B /* Outgoing SVC */
460
461/*----------------------------------------------------------------------------
462 * X25_READ_STATISTICS Command.
463 */
464typedef struct X25Stats
465{ /* number of packets Tx/Rx'ed */
466 unsigned short txRestartRqst PACKED; /* 00h: Restart Request */
467 unsigned short rxRestartRqst PACKED; /* 02h: Restart Request */
468 unsigned short txRestartConf PACKED; /* 04h: Restart Confirmation */
469 unsigned short rxRestartConf PACKED; /* 06h: Restart Confirmation */
470 unsigned short txResetRqst PACKED; /* 08h: Reset Request */
471 unsigned short rxResetRqst PACKED; /* 0Ah: Reset Request */
472 unsigned short txResetConf PACKED; /* 0Ch: Reset Confirmation */
473 unsigned short rxResetConf PACKED; /* 0Eh: Reset Confirmation */
474 unsigned short txCallRequest PACKED; /* 10h: Call Request */
475 unsigned short rxCallRequest PACKED; /* 12h: Call Request */
476 unsigned short txCallAccept PACKED; /* 14h: Call Accept */
477 unsigned short rxCallAccept PACKED; /* 16h: Call Accept */
478 unsigned short txClearRqst PACKED; /* 18h: Clear Request */
479 unsigned short rxClearRqst PACKED; /* 1Ah: Clear Request */
480 unsigned short txClearConf PACKED; /* 1Ch: Clear Confirmation */
481 unsigned short rxClearConf PACKED; /* 1Eh: Clear Confirmation */
482 unsigned short txDiagnostic PACKED; /* 20h: Diagnostic */
483 unsigned short rxDiagnostic PACKED; /* 22h: Diagnostic */
484 unsigned short txRegRqst PACKED; /* 24h: Registration Request */
485 unsigned short rxRegRqst PACKED; /* 26h: Registration Request */
486 unsigned short txRegConf PACKED; /* 28h: Registration Confirm.*/
487 unsigned short rxRegConf PACKED; /* 2Ah: Registration Confirm.*/
488 unsigned short txInterrupt PACKED; /* 2Ch: Interrupt */
489 unsigned short rxInterrupt PACKED; /* 2Eh: Interrupt */
490 unsigned short txIntrConf PACKED; /* 30h: Interrupt Confirm. */
491 unsigned short rxIntrConf PACKED; /* 32h: Interrupt Confirm. */
492 unsigned short txData PACKED; /* 34h: Data */
493 unsigned short rxData PACKED; /* 36h: Data */
494 unsigned short txRR PACKED; /* 38h: RR */
495 unsigned short rxRR PACKED; /* 3Ah: RR */
496 unsigned short txRNR PACKED; /* 3Ch: RNR */
497 unsigned short rxRNR PACKED; /* 3Eh: RNR */
498} TX25Stats;
499
500/*----------------------------------------------------------------------------
501 * X25_READ_HISTORY_TABLE Command.
502 */
503typedef struct X25EventLog
504{
505 unsigned char type PACKED; /* 00h: transaction type */
506 unsigned short lcn PACKED; /* 01h: logical channel num */
507 unsigned char packet PACKED; /* 03h: async packet type */
508 unsigned char cause PACKED; /* 04h: X.25 cause field */
509 unsigned char diag PACKED; /* 05h: X.25 diag field */
510 TX25TimeStamp ts PACKED; /* 06h: time stamp */
511} TX25EventLog;
512
513/*
514 * Defines for the 'type' field.
515 */
516#define X25LOG_INCOMMING 0x00
517#define X25LOG_APPLICATION 0x01
518#define X25LOG_AUTOMATIC 0x02
519#define X25LOG_ERROR 0x04
520#define X25LOG_TIMEOUT 0x08
521#define X25LOG_RECOVERY 0x10
522
523/*
524 * Defines for the 'packet' field.
525 */
526#define X25LOG_CALL_RQST 0x0B
527#define X25LOG_CALL_ACCEPTED 0x0F
528#define X25LOG_CLEAR_RQST 0x13
529#define X25LOG_CLEAR_CONFRM 0x17
530#define X25LOG_RESET_RQST 0x1B
531#define X25LOG_RESET_CONFRM 0x1F
532#define X25LOG_RESTART_RQST 0xFB
533#define X25LOG_RESTART_COMFRM 0xFF
534#define X25LOG_DIAGNOSTIC 0xF1
535#define X25LOG_DTE_REG_RQST 0xF3
536#define X25LOG_DTE_REG_COMFRM 0xF7
537
538/* ---------------------------------------------------------------------------
539 * X25_TRACE_CONFIGURE Command.
540 */
541typedef struct X25TraceCfg
542{
543 unsigned char flags PACKED; /* 00h: trace configuration flags */
544 unsigned char timeout PACKED; /* 01h: timeout for trace delay mode*/
545} TX25TraceCfg;
546
547/*
548 * Defines for the 'flags' field.
549 */
550#define X25_TRC_ENABLE 0x01 /* bit0: '1' - trace enabled */
551#define X25_TRC_TIMESTAMP 0x02 /* bit1: '1' - time stamping enabled*/
552#define X25_TRC_DELAY 0x04 /* bit2: '1' - trace delay enabled */
553#define X25_TRC_DATA 0x08 /* bit3: '1' - trace data packets */
554#define X25_TRC_SUPERVISORY 0x10 /* bit4: '1' - trace suprvisory pkts*/
555#define X25_TRC_ASYNCHRONOUS 0x20 /* bit5: '1' - trace asynch. packets*/
556#define X25_TRC_HDLC 0x40 /* bit6: '1' - trace all packets */
557#define X25_TRC_READ 0x80 /* bit7: '1' - get current config. */
558
559/* ---------------------------------------------------------------------------
560 * X25_READ_TRACE_DATA Command.
561 */
562typedef struct X25Trace /*----- Trace data structure -------*/
563{
564 unsigned short length PACKED; /* 00h: trace data length */
565 unsigned char type PACKED; /* 02h: trace type */
566 unsigned char lost_cnt PACKED; /* 03h: N of traces lost */
567 TX25TimeStamp tstamp PACKED; /* 04h: mon/date/sec/min/hour */
568 unsigned short millisec PACKED; /* 09h: ms time stamp */
569 unsigned char data[0] PACKED; /* 0Bh: traced frame */
570} TX25Trace;
571
572/*
573 * Defines for the 'type' field.
574 */
575#define X25_TRC_TYPE_MASK 0x0F /* bits 0..3: trace type */
576#define X25_TRC_TYPE_RX_FRAME 0x00 /* received frame trace */
577#define X25_TRC_TYPE_TX_FRAME 0x01 /* transmitted frame */
578#define X25_TRC_TYPE_ERR_FRAME 0x02 /* error frame */
579
580#define X25_TRC_ERROR_MASK 0xF0 /* bits 4..7: error code */
581#define X25_TRCERR_RX_ABORT 0x10 /* receive abort error */
582#define X25_TRCERR_RX_BADCRC 0x20 /* receive CRC error */
583#define X25_TRCERR_RX_OVERRUN 0x30 /* receiver overrun error */
584#define X25_TRCERR_RX_TOO_LONG 0x40 /* excessive frame length error */
585#define X25_TRCERR_TX_ABORT 0x70 /* aborted frame transmittion error */
586#define X25_TRCERR_TX_UNDERRUN 0x80 /* transmit underrun error */
587
588/*****************************************************************************
589 * Following definitions describe HDLC frame and X.25 packet formats.
590 ****************************************************************************/
591
592typedef struct HDLCFrame /*----- DHLC Frame Format ----------*/
593{
594 unsigned char addr PACKED; /* address field */
595 unsigned char cntl PACKED; /* control field */
596 unsigned char data[0] PACKED;
597} THDLCFrame;
598
599typedef struct X25Pkt /*----- X.25 Paket Format ----------*/
600{
601 unsigned char lcn_hi PACKED; /* 4 MSB of Logical Channel Number */
602 unsigned char lcn_lo PACKED; /* 8 LSB of Logical Channel Number */
603 unsigned char type PACKED;
604 unsigned char data[0] PACKED;
605} TX25Pkt;
606
607/*
608 * Defines for the 'lcn_hi' field.
609 */
610#define X25_Q_BIT_MASK 0x80 /* Data Qualifier Bit mask */
611#define X25_D_BIT_MASK 0x40 /* Delivery Confirmation Bit mask */
612#define X25_M_BITS_MASK 0x30 /* Modulo Bits mask */
613#define X25_LCN_MSB_MASK 0x0F /* LCN most significant bits mask */
614
615/*
616 * Defines for the 'type' field.
617 */
618#define X25PKT_DATA 0x01 /* Data packet mask */
619#define X25PKT_SUPERVISORY 0x02 /* Supervisory packet mask */
620#define X25PKT_CALL_RQST 0x0B /* Call Request/Incoming */
621#define X25PKT_CALL_ACCEPTED 0x0F /* Call Accepted/Connected */
622#define X25PKT_CLEAR_RQST 0x13 /* Clear Request/Indication */
623#define X25PKT_CLEAR_CONFRM 0x17 /* Clear Confirmation */
624#define X25PKT_RESET_RQST 0x1B /* Reset Request/Indication */
625#define X25PKT_RESET_CONFRM 0x1F /* Reset Confirmation */
626#define X25PKT_RESTART_RQST 0xFB /* Restart Request/Indication */
627#define X25PKT_RESTART_CONFRM 0xFF /* Restart Confirmation */
628#define X25PKT_INTERRUPT 0x23 /* Interrupt */
629#define X25PKT_INTERRUPT_CONFRM 0x27 /* Interrupt Confirmation */
630#define X25PKT_DIAGNOSTIC 0xF1 /* Diagnostic */
631#define X25PKT_REGISTR_RQST 0xF3 /* Registration Request */
632#define X25PKT_REGISTR_CONFRM 0xF7 /* Registration Confirmation */
633#define X25PKT_RR_MASKED 0x01 /* Receive Ready packet after masking */
634#define X25PKT_RNR_MASKED 0x05 /* Receive Not Ready after masking */
635
636
637typedef struct {
638 TX25Cmd cmd PACKED;
639 char data[X25_MAX_DATA] PACKED;
640} mbox_cmd_t;
641
642
643typedef struct {
644 unsigned char qdm PACKED; /* Q/D/M bits */
645 unsigned char cause PACKED; /* cause field */
646 unsigned char diagn PACKED; /* diagnostics */
647 unsigned char pktType PACKED;
648 unsigned short length PACKED;
649 unsigned char result PACKED;
650 unsigned short lcn PACKED;
651 char reserved[7] PACKED;
652}x25api_hdr_t;
653
654
655typedef struct {
656 x25api_hdr_t hdr PACKED;
657 char data[X25_MAX_DATA] PACKED;
658}x25api_t;
659
660
661/*
662 * XPIPEMON Definitions
663 */
664
665/* valid ip_protocol for UDP management */
666#define UDPMGMT_UDP_PROTOCOL 0x11
667#define UDPMGMT_XPIPE_SIGNATURE "XLINK8ND"
668#define UDPMGMT_DRVRSTATS_SIGNATURE "DRVSTATS"
669
670/* values for request/reply byte */
671#define UDPMGMT_REQUEST 0x01
672#define UDPMGMT_REPLY 0x02
673#define UDP_OFFSET 12
674
675
676typedef struct {
677 unsigned char opp_flag PACKED; /* the opp flag */
678 unsigned char command PACKED; /* command code */
679 unsigned short length PACKED; /* transfer data length */
680 unsigned char result PACKED; /* return code */
681 unsigned char pf PACKED; /* P/F bit */
682 unsigned short lcn PACKED; /* logical channel */
683 unsigned char qdm PACKED; /* Q/D/M bits */
684 unsigned char cause PACKED; /* cause field */
685 unsigned char diagn PACKED; /* diagnostics */
686 unsigned char pktType PACKED; /* packet type */
687 unsigned char resrv[4] PACKED; /* reserved */
688} cblock_t;
689
690typedef struct {
691 ip_pkt_t ip_pkt PACKED;
692 udp_pkt_t udp_pkt PACKED;
693 wp_mgmt_t wp_mgmt PACKED;
694 cblock_t cblock PACKED;
695 unsigned char data[4080] PACKED;
696} x25_udp_pkt_t;
697
698
699typedef struct read_hdlc_stat {
700 unsigned short inf_frames_rx_ok PACKED;
701 unsigned short inf_frames_rx_out_of_seq PACKED;
702 unsigned short inf_frames_rx_no_data PACKED;
703 unsigned short inf_frames_rx_dropped PACKED;
704 unsigned short inf_frames_rx_data_too_long PACKED;
705 unsigned short inf_frames_rx_invalid_addr PACKED;
706 unsigned short inf_frames_tx_ok PACKED;
707 unsigned short inf_frames_tx_retransmit PACKED;
708 unsigned short T1_timeouts PACKED;
709 unsigned short SABM_frames_rx PACKED;
710 unsigned short DISC_frames_rx PACKED;
711 unsigned short DM_frames_rx PACKED;
712 unsigned short FRMR_frames_rx PACKED;
713 unsigned short SABM_frames_tx PACKED;
714 unsigned short DISC_frames_tx PACKED;
715 unsigned short DM_frames_tx PACKED;
716 unsigned short FRMR_frames_tx PACKED;
717} read_hdlc_stat_t;
718
719typedef struct read_comms_err_stats{
720 unsigned char overrun_err_rx PACKED;
721 unsigned char CRC_err PACKED;
722 unsigned char abort_frames_rx PACKED;
723 unsigned char frames_dropped_buf_full PACKED;
724 unsigned char abort_frames_tx PACKED;
725 unsigned char transmit_underruns PACKED;
726 unsigned char missed_tx_underruns_intr PACKED;
727 unsigned char reserved PACKED;
728 unsigned char DCD_drop PACKED;
729 unsigned char CTS_drop PACKED;
730} read_comms_err_stats_t;
731
732typedef struct trace_data {
733 unsigned short length PACKED;
734 unsigned char type PACKED;
735 unsigned char trace_dropped PACKED;
736 unsigned char reserved[5] PACKED;
737 unsigned short timestamp PACKED;
738 unsigned char data PACKED;
739} trace_data_t;
740
741enum {UDP_XPIPE_TYPE};
742
743#define XPIPE_ENABLE_TRACING 0x14
744#define XPIPE_DISABLE_TRACING 0x14
745#define XPIPE_GET_TRACE_INFO 0x16
746#define XPIPE_FT1_READ_STATUS 0x74
747#define XPIPE_DRIVER_STAT_IFSEND 0x75
748#define XPIPE_DRIVER_STAT_INTR 0x76
749#define XPIPE_DRIVER_STAT_GEN 0x77
750#define XPIPE_FLUSH_DRIVER_STATS 0x78
751#define XPIPE_ROUTER_UP_TIME 0x79
752#define XPIPE_SET_FT1_MODE 0x81
753#define XPIPE_FT1_STATUS_CTRL 0x80
754
755
756/* error messages */
757#define NO_BUFFS_OR_CLOSED_WIN 0x33
758#define DATA_LENGTH_TOO_BIG 0x32
759#define NO_DATA_AVAILABLE 0x33
760#define Z80_TIMEOUT_ERROR 0x0a
761#define NO_BUFFS 0x08
762
763
764/* Trace options */
765#define TRACE_DEFAULT 0x03
766#define TRACE_SUPERVISOR_FRMS 0x10
767#define TRACE_ASYNC_FRMS 0x20
768#define TRACE_ALL_HDLC_FRMS 0x40
769#define TRACE_DATA_FRMS 0x08
770
771
772#endif /* _SDLA_X25_H */
diff --git a/include/linux/sdladrv.h b/include/linux/sdladrv.h
new file mode 100644
index 000000000000..78f634007fc6
--- /dev/null
+++ b/include/linux/sdladrv.h
@@ -0,0 +1,70 @@
1/*****************************************************************************
2* sdladrv.h SDLA Support Module. Kernel API Definitions.
3*
4* Author: Gideon Hack
5*
6* Copyright: (c) 1995-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* Jun 02, 1999 Gideon Hack Added support for the S514 PCI adapter.
14* Dec 11, 1996 Gene Kozin Complete overhaul.
15* Oct 17, 1996 Gene Kozin Minor bug fixes.
16* Jun 12, 1996 Gene Kozin Added support for S503 card.
17* Dec 06, 1995 Gene Kozin Initial version.
18*****************************************************************************/
19#ifndef _SDLADRV_H
20#define _SDLADRV_H
21
22
23#define SDLA_MAXIORANGE 4 /* maximum I/O port range */
24#define SDLA_WINDOWSIZE 0x2000 /* default dual-port memory window size */
25/****** Data Structures *****************************************************/
26
27/*----------------------------------------------------------------------------
28 * Adapter hardware configuration. Pointer to this structure is passed to all
29 * APIs.
30 */
31typedef struct sdlahw
32{
33 unsigned type; /* adapter type */
34 unsigned fwid; /* firmware ID */
35 unsigned port; /* adapter I/O port base */
36 int irq; /* interrupt request level */
37 char S514_cpu_no[1]; /* PCI CPU Number */
38 unsigned char S514_slot_no; /* PCI Slot Number */
39 char auto_pci_cfg; /* Autodetect PCI Slot */
40 struct pci_dev *pci_dev; /* PCI device */
41 void * dpmbase; /* dual-port memory base */
42 unsigned dpmsize; /* dual-port memory size */
43 unsigned pclk; /* CPU clock rate, kHz */
44 unsigned long memory; /* memory size */
45 unsigned long vector; /* local offset of the DPM window */
46 unsigned io_range; /* I/O port range */
47 unsigned char regs[SDLA_MAXIORANGE]; /* was written to registers */
48 unsigned reserved[5];
49} sdlahw_t;
50
51/****** Function Prototypes *************************************************/
52
53extern int sdla_setup (sdlahw_t* hw, void* sfm, unsigned len);
54extern int sdla_down (sdlahw_t* hw);
55extern int sdla_inten (sdlahw_t* hw);
56extern int sdla_intde (sdlahw_t* hw);
57extern int sdla_intack (sdlahw_t* hw);
58extern void S514_intack (sdlahw_t* hw, u32 int_status);
59extern void read_S514_int_stat (sdlahw_t* hw, u32* int_status);
60extern int sdla_intr (sdlahw_t* hw);
61extern int sdla_mapmem (sdlahw_t* hw, unsigned long addr);
62extern int sdla_peek (sdlahw_t* hw, unsigned long addr, void* buf,
63 unsigned len);
64extern int sdla_poke (sdlahw_t* hw, unsigned long addr, void* buf,
65 unsigned len);
66extern int sdla_exec (void* opflag);
67
68extern unsigned wanpipe_hw_probe(void);
69
70#endif /* _SDLADRV_H */
diff --git a/include/linux/sdlapci.h b/include/linux/sdlapci.h
new file mode 100644
index 000000000000..6f7c904f188d
--- /dev/null
+++ b/include/linux/sdlapci.h
@@ -0,0 +1,72 @@
1/*****************************************************************************
2* sdlapci.h WANPIPE(tm) Multiprotocol WAN Link Driver.
3* Definitions for the SDLA PCI adapter.
4*
5* Author: Gideon Hack <ghack@sangoma.com>
6*
7* Copyright: (c) 1999-2000 Sangoma Technologies Inc.
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
11* as published by the Free Software Foundation; either version
12* 2 of the License, or (at your option) any later version.
13* ============================================================================
14* Jun 02, 1999 Gideon Hack Initial version.
15*****************************************************************************/
16#ifndef _SDLAPCI_H
17#define _SDLAPCI_H
18
19/****** Defines *************************************************************/
20
21/* Definitions for identifying and finding S514 PCI adapters */
22#define V3_VENDOR_ID 0x11B0 /* V3 vendor ID number */
23#define V3_DEVICE_ID 0x0002 /* V3 device ID number */
24#define SANGOMA_SUBSYS_VENDOR 0x4753 /* ID for Sangoma */
25#define PCI_DEV_SLOT_MASK 0x1F /* mask for slot numbering */
26#define PCI_IRQ_NOT_ALLOCATED 0xFF /* interrupt line for no IRQ */
27
28/* Local PCI register offsets */
29#define PCI_VENDOR_ID_WORD 0x00 /* vendor ID */
30#define PCI_IO_BASE_DWORD 0x10 /* IO base */
31#define PCI_MEM_BASE0_DWORD 0x14 /* memory base - apperture 0 */
32#define PCI_MEM_BASE1_DWORD 0x18 /* memory base - apperture 1 */
33#define PCI_SUBSYS_VENDOR_WORD 0x2C /* subsystem vendor ID */
34#define PCI_INT_LINE_BYTE 0x3C /* interrupt line */
35#define PCI_INT_PIN_BYTE 0x3D /* interrupt pin */
36#define PCI_MAP0_DWORD 0x40 /* PCI to local bus address 0 */
37#define PCI_MAP1_DWORD 0x44 /* PCI to local bus address 1 */
38#define PCI_INT_STATUS 0x48 /* interrupt status */
39#define PCI_INT_CONFIG 0x4C /* interrupt configuration */
40
41/* Local PCI register usage */
42#define PCI_MEMORY_ENABLE 0x00000003 /* enable PCI memory */
43#define PCI_CPU_A_MEM_DISABLE 0x00000002 /* disable CPU A memory */
44#define PCI_CPU_B_MEM_DISABLE 0x00100002 /* disable CPU B memory */
45#define PCI_ENABLE_IRQ_CPU_A 0x005A0004 /* enable IRQ for CPU A */
46#define PCI_ENABLE_IRQ_CPU_B 0x005A0008 /* enable IRQ for CPU B */
47#define PCI_DISABLE_IRQ_CPU_A 0x00000004 /* disable IRQ for CPU A */
48#define PCI_DISABLE_IRQ_CPU_B 0x00000008 /* disable IRQ for CPU B */
49
50/* Setting for the Interrupt Status register */
51#define IRQ_CPU_A 0x04 /* IRQ for CPU A */
52#define IRQ_CPU_B 0x08 /* IRQ for CPU B */
53
54/* The maximum size of the S514 memory */
55#define MAX_SIZEOF_S514_MEMORY (256 * 1024)
56
57/* S514 control register offsets within the memory address space */
58#define S514_CTRL_REG_BYTE 0x80000
59
60/* S514 adapter control bytes */
61#define S514_CPU_HALT 0x00
62#define S514_CPU_START 0x01
63
64/* The maximum number of S514 adapters supported */
65#define MAX_S514_CARDS 20
66
67#define PCI_CARD_TYPE 0x2E
68#define S514_DUAL_CPU 0x12
69#define S514_SINGLE_CPU 0x11
70
71#endif /* _SDLAPCI_H */
72
diff --git a/include/linux/sdlasfm.h b/include/linux/sdlasfm.h
new file mode 100644
index 000000000000..94aaa8ada667
--- /dev/null
+++ b/include/linux/sdlasfm.h
@@ -0,0 +1,104 @@
1/*****************************************************************************
2* sdlasfm.h WANPIPE(tm) Multiprotocol WAN Link Driver.
3* Definitions for the SDLA Firmware Module (SFM).
4*
5* Author: Gideon Hack
6*
7* Copyright: (c) 1995-1999 Sangoma Technologies Inc.
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
11* as published by the Free Software Foundation; either version
12* 2 of the License, or (at your option) any later version.
13* ============================================================================
14* Jun 02, 1999 Gideon Hack Added support for the S514 adapter.
15* Dec 11, 1996 Gene Kozin Cosmetic changes
16* Apr 16, 1996 Gene Kozin Changed adapter & firmware IDs. Version 2
17* Dec 15, 1995 Gene Kozin Structures chaned
18* Nov 09, 1995 Gene Kozin Initial version.
19*****************************************************************************/
20#ifndef _SDLASFM_H
21#define _SDLASFM_H
22
23/****** Defines *************************************************************/
24
25#define SFM_VERSION 2
26#define SFM_SIGNATURE "SFM - Sangoma SDLA Firmware Module"
27
28/* min/max */
29#define SFM_IMAGE_SIZE 0x8000 /* max size of SDLA code image file */
30#define SFM_DESCR_LEN 256 /* max length of description string */
31#define SFM_MAX_SDLA 16 /* max number of compatible adapters */
32
33/* Adapter types */
34#define SDLA_S502A 5020
35#define SDLA_S502E 5021
36#define SDLA_S503 5030
37#define SDLA_S508 5080
38#define SDLA_S507 5070
39#define SDLA_S509 5090
40#define SDLA_S514 5140
41
42/* S514 PCI adapter CPU numbers */
43#define S514_CPU_A 'A'
44#define S514_CPU_B 'B'
45
46
47/* Firmware identification numbers:
48 * 0 .. 999 Test & Diagnostics
49 * 1000 .. 1999 Streaming HDLC
50 * 2000 .. 2999 Bisync
51 * 3000 .. 3999 SDLC
52 * 4000 .. 4999 HDLC
53 * 5000 .. 5999 X.25
54 * 6000 .. 6999 Frame Relay
55 * 7000 .. 7999 PPP
56 * 8000 .. 8999 Cisco HDLC
57 */
58#define SFID_CALIB502 200
59#define SFID_STRM502 1200
60#define SFID_STRM508 1800
61#define SFID_BSC502 2200
62#define SFID_SDLC502 3200
63#define SFID_HDLC502 4200
64#define SFID_HDLC508 4800
65#define SFID_X25_502 5200
66#define SFID_X25_508 5800
67#define SFID_FR502 6200
68#define SFID_FR508 6800
69#define SFID_PPP502 7200
70#define SFID_PPP508 7800
71#define SFID_PPP514 7140
72#define SFID_CHDLC508 8800
73#define SFID_CHDLC514 8140
74
75/****** Data Types **********************************************************/
76
77typedef struct sfm_info /* firmware module information */
78{
79 unsigned short codeid; /* firmware ID */
80 unsigned short version; /* firmaware version number */
81 unsigned short adapter[SFM_MAX_SDLA]; /* compatible adapter types */
82 unsigned long memsize; /* minimum memory size */
83 unsigned short reserved[2]; /* reserved */
84 unsigned short startoffs; /* entry point offset */
85 unsigned short winoffs; /* dual-port memory window offset */
86 unsigned short codeoffs; /* code load offset */
87 unsigned short codesize; /* code size */
88 unsigned short dataoffs; /* configuration data load offset */
89 unsigned short datasize; /* configuration data size */
90} sfm_info_t;
91
92typedef struct sfm /* SDLA firmware file structire */
93{
94 char signature[80]; /* SFM file signature */
95 unsigned short version; /* file format version */
96 unsigned short checksum; /* info + image */
97 unsigned short reserved[6]; /* reserved */
98 char descr[SFM_DESCR_LEN]; /* description string */
99 sfm_info_t info; /* firmware module info */
100 unsigned char image[1]; /* code image (variable size) */
101} sfm_t;
102
103#endif /* _SDLASFM_H */
104
diff --git a/include/linux/seccomp.h b/include/linux/seccomp.h
new file mode 100644
index 000000000000..3a2702bbb1d6
--- /dev/null
+++ b/include/linux/seccomp.h
@@ -0,0 +1,34 @@
1#ifndef _LINUX_SECCOMP_H
2#define _LINUX_SECCOMP_H
3
4#include <linux/config.h>
5
6#ifdef CONFIG_SECCOMP
7
8#define NR_SECCOMP_MODES 1
9
10#include <linux/thread_info.h>
11#include <asm/seccomp.h>
12
13typedef struct { int mode; } seccomp_t;
14
15extern void __secure_computing(int);
16static inline void secure_computing(int this_syscall)
17{
18 if (unlikely(test_thread_flag(TIF_SECCOMP)))
19 __secure_computing(this_syscall);
20}
21
22#else /* CONFIG_SECCOMP */
23
24#if (__GNUC__ > 2)
25 typedef struct { } seccomp_t;
26#else
27 typedef struct { int gcc_is_buggy; } seccomp_t;
28#endif
29
30#define secure_computing(x) do { } while (0)
31
32#endif /* CONFIG_SECCOMP */
33
34#endif /* _LINUX_SECCOMP_H */
diff --git a/include/linux/securebits.h b/include/linux/securebits.h
new file mode 100644
index 000000000000..5b0617840fa4
--- /dev/null
+++ b/include/linux/securebits.h
@@ -0,0 +1,30 @@
1#ifndef _LINUX_SECUREBITS_H
2#define _LINUX_SECUREBITS_H 1
3
4#define SECUREBITS_DEFAULT 0x00000000
5
6extern unsigned securebits;
7
8/* When set UID 0 has no special privileges. When unset, we support
9 inheritance of root-permissions and suid-root executable under
10 compatibility mode. We raise the effective and inheritable bitmasks
11 *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
13 executable file. */
14#define SECURE_NOROOT 0
15
16/* 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
18 privileges. When unset, setuid doesn't change privileges. */
19#define SECURE_NO_SETUID_FIXUP 2
20
21/* Each securesetting is implemented using two bits. One bit specify
22 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
24 from user-level. */
25
26#define issecure(X) ( (1 << (X+1)) & SECUREBITS_DEFAULT ? \
27 (1 << (X)) & SECUREBITS_DEFAULT : \
28 (1 << (X)) & securebits )
29
30#endif /* !_LINUX_SECUREBITS_H */
diff --git a/include/linux/security.h b/include/linux/security.h
new file mode 100644
index 000000000000..b42095a68b1c
--- /dev/null
+++ b/include/linux/security.h
@@ -0,0 +1,2858 @@
1/*
2 * Linux Security plug
3 *
4 * Copyright (C) 2001 WireX Communications, Inc <chris@wirex.com>
5 * Copyright (C) 2001 Greg Kroah-Hartman <greg@kroah.com>
6 * Copyright (C) 2001 Networks Associates Technology, Inc <ssmalley@nai.com>
7 * Copyright (C) 2001 James Morris <jmorris@intercode.com.au>
8 * Copyright (C) 2001 Silicon Graphics, Inc. (Trust Technology Group)
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 * Due to this file being licensed under the GPL there is controversy over
16 * whether this permits you to write a module that #includes this file
17 * without placing your module under the GPL. Please consult a lawyer for
18 * advice before doing this.
19 *
20 */
21
22#ifndef __LINUX_SECURITY_H
23#define __LINUX_SECURITY_H
24
25#include <linux/fs.h>
26#include <linux/binfmts.h>
27#include <linux/signal.h>
28#include <linux/resource.h>
29#include <linux/sem.h>
30#include <linux/shm.h>
31#include <linux/msg.h>
32#include <linux/sched.h>
33
34struct ctl_table;
35
36/*
37 * These functions are in security/capability.c and are used
38 * as the default capabilities functions
39 */
40extern int cap_capable (struct task_struct *tsk, int cap);
41extern int cap_settime (struct timespec *ts, struct timezone *tz);
42extern int cap_ptrace (struct task_struct *parent, struct task_struct *child);
43extern int cap_capget (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
44extern int cap_capset_check (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
45extern void cap_capset_set (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
46extern int cap_bprm_set_security (struct linux_binprm *bprm);
47extern void cap_bprm_apply_creds (struct linux_binprm *bprm, int unsafe);
48extern int cap_bprm_secureexec(struct linux_binprm *bprm);
49extern int cap_inode_setxattr(struct dentry *dentry, char *name, void *value, size_t size, int flags);
50extern int cap_inode_removexattr(struct dentry *dentry, char *name);
51extern int cap_task_post_setuid (uid_t old_ruid, uid_t old_euid, uid_t old_suid, int flags);
52extern void cap_task_reparent_to_init (struct task_struct *p);
53extern int cap_syslog (int type);
54extern int cap_vm_enough_memory (long pages);
55
56struct msghdr;
57struct sk_buff;
58struct sock;
59struct sockaddr;
60struct socket;
61
62extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
63extern int cap_netlink_recv(struct sk_buff *skb);
64
65/*
66 * Values used in the task_security_ops calls
67 */
68/* setuid or setgid, id0 == uid or gid */
69#define LSM_SETID_ID 1
70
71/* setreuid or setregid, id0 == real, id1 == eff */
72#define LSM_SETID_RE 2
73
74/* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
75#define LSM_SETID_RES 4
76
77/* setfsuid or setfsgid, id0 == fsuid or fsgid */
78#define LSM_SETID_FS 8
79
80/* forward declares to avoid warnings */
81struct nfsctl_arg;
82struct sched_param;
83struct swap_info_struct;
84
85/* bprm_apply_creds unsafe reasons */
86#define LSM_UNSAFE_SHARE 1
87#define LSM_UNSAFE_PTRACE 2
88#define LSM_UNSAFE_PTRACE_CAP 4
89
90#ifdef CONFIG_SECURITY
91
92/**
93 * struct security_operations - main security structure
94 *
95 * Security hooks for program execution operations.
96 *
97 * @bprm_alloc_security:
98 * Allocate and attach a security structure to the @bprm->security field.
99 * The security field is initialized to NULL when the bprm structure is
100 * allocated.
101 * @bprm contains the linux_binprm structure to be modified.
102 * Return 0 if operation was successful.
103 * @bprm_free_security:
104 * @bprm contains the linux_binprm structure to be modified.
105 * Deallocate and clear the @bprm->security field.
106 * @bprm_apply_creds:
107 * Compute and set the security attributes of a process being transformed
108 * by an execve operation based on the old attributes (current->security)
109 * and the information saved in @bprm->security by the set_security hook.
110 * Since this hook function (and its caller) are void, this hook can not
111 * return an error. However, it can leave the security attributes of the
112 * process unchanged if an access failure occurs at this point.
113 * bprm_apply_creds is called under task_lock. @unsafe indicates various
114 * reasons why it may be unsafe to change security state.
115 * @bprm contains the linux_binprm structure.
116 * @bprm_post_apply_creds:
117 * Runs after bprm_apply_creds with the task_lock dropped, so that
118 * functions which cannot be called safely under the task_lock can
119 * be used. This hook is a good place to perform state changes on
120 * the process such as closing open file descriptors to which access
121 * is no longer granted if the attributes were changed.
122 * Note that a security module might need to save state between
123 * bprm_apply_creds and bprm_post_apply_creds to store the decision
124 * on whether the process may proceed.
125 * @bprm contains the linux_binprm structure.
126 * @bprm_set_security:
127 * Save security information in the bprm->security field, typically based
128 * on information about the bprm->file, for later use by the apply_creds
129 * hook. This hook may also optionally check permissions (e.g. for
130 * transitions between security domains).
131 * This hook may be called multiple times during a single execve, e.g. for
132 * interpreters. The hook can tell whether it has already been called by
133 * checking to see if @bprm->security is non-NULL. If so, then the hook
134 * may decide either to retain the security information saved earlier or
135 * to replace it.
136 * @bprm contains the linux_binprm structure.
137 * Return 0 if the hook is successful and permission is granted.
138 * @bprm_check_security:
139 * This hook mediates the point when a search for a binary handler will
140 * begin. It allows a check the @bprm->security value which is set in
141 * the preceding set_security call. The primary difference from
142 * set_security is that the argv list and envp list are reliably
143 * available in @bprm. This hook may be called multiple times
144 * during a single execve; and in each pass set_security is called
145 * first.
146 * @bprm contains the linux_binprm structure.
147 * Return 0 if the hook is successful and permission is granted.
148 * @bprm_secureexec:
149 * Return a boolean value (0 or 1) indicating whether a "secure exec"
150 * is required. The flag is passed in the auxiliary table
151 * on the initial stack to the ELF interpreter to indicate whether libc
152 * should enable secure mode.
153 * @bprm contains the linux_binprm structure.
154 *
155 * Security hooks for filesystem operations.
156 *
157 * @sb_alloc_security:
158 * Allocate and attach a security structure to the sb->s_security field.
159 * The s_security field is initialized to NULL when the structure is
160 * allocated.
161 * @sb contains the super_block structure to be modified.
162 * Return 0 if operation was successful.
163 * @sb_free_security:
164 * Deallocate and clear the sb->s_security field.
165 * @sb contains the super_block structure to be modified.
166 * @sb_statfs:
167 * Check permission before obtaining filesystem statistics for the @sb
168 * filesystem.
169 * @sb contains the super_block structure for the filesystem.
170 * Return 0 if permission is granted.
171 * @sb_mount:
172 * Check permission before an object specified by @dev_name is mounted on
173 * the mount point named by @nd. For an ordinary mount, @dev_name
174 * identifies a device if the file system type requires a device. For a
175 * remount (@flags & MS_REMOUNT), @dev_name is irrelevant. For a
176 * loopback/bind mount (@flags & MS_BIND), @dev_name identifies the
177 * pathname of the object being mounted.
178 * @dev_name contains the name for object being mounted.
179 * @nd contains the nameidata structure for mount point object.
180 * @type contains the filesystem type.
181 * @flags contains the mount flags.
182 * @data contains the filesystem-specific data.
183 * Return 0 if permission is granted.
184 * @sb_copy_data:
185 * Allow mount option data to be copied prior to parsing by the filesystem,
186 * so that the security module can extract security-specific mount
187 * options cleanly (a filesystem may modify the data e.g. with strsep()).
188 * This also allows the original mount data to be stripped of security-
189 * specific options to avoid having to make filesystems aware of them.
190 * @type the type of filesystem being mounted.
191 * @orig the original mount data copied from userspace.
192 * @copy copied data which will be passed to the security module.
193 * Returns 0 if the copy was successful.
194 * @sb_check_sb:
195 * Check permission before the device with superblock @mnt->sb is mounted
196 * on the mount point named by @nd.
197 * @mnt contains the vfsmount for device being mounted.
198 * @nd contains the nameidata object for the mount point.
199 * Return 0 if permission is granted.
200 * @sb_umount:
201 * Check permission before the @mnt file system is unmounted.
202 * @mnt contains the mounted file system.
203 * @flags contains the unmount flags, e.g. MNT_FORCE.
204 * Return 0 if permission is granted.
205 * @sb_umount_close:
206 * Close any files in the @mnt mounted filesystem that are held open by
207 * the security module. This hook is called during an umount operation
208 * prior to checking whether the filesystem is still busy.
209 * @mnt contains the mounted filesystem.
210 * @sb_umount_busy:
211 * Handle a failed umount of the @mnt mounted filesystem, e.g. re-opening
212 * any files that were closed by umount_close. This hook is called during
213 * an umount operation if the umount fails after a call to the
214 * umount_close hook.
215 * @mnt contains the mounted filesystem.
216 * @sb_post_remount:
217 * Update the security module's state when a filesystem is remounted.
218 * This hook is only called if the remount was successful.
219 * @mnt contains the mounted file system.
220 * @flags contains the new filesystem flags.
221 * @data contains the filesystem-specific data.
222 * @sb_post_mountroot:
223 * Update the security module's state when the root filesystem is mounted.
224 * This hook is only called if the mount was successful.
225 * @sb_post_addmount:
226 * Update the security module's state when a filesystem is mounted.
227 * This hook is called any time a mount is successfully grafetd to
228 * the tree.
229 * @mnt contains the mounted filesystem.
230 * @mountpoint_nd contains the nameidata structure for the mount point.
231 * @sb_pivotroot:
232 * Check permission before pivoting the root filesystem.
233 * @old_nd contains the nameidata structure for the new location of the current root (put_old).
234 * @new_nd contains the nameidata structure for the new root (new_root).
235 * Return 0 if permission is granted.
236 * @sb_post_pivotroot:
237 * Update module state after a successful pivot.
238 * @old_nd contains the nameidata structure for the old root.
239 * @new_nd contains the nameidata structure for the new root.
240 *
241 * Security hooks for inode operations.
242 *
243 * @inode_alloc_security:
244 * Allocate and attach a security structure to @inode->i_security. The
245 * i_security field is initialized to NULL when the inode structure is
246 * allocated.
247 * @inode contains the inode structure.
248 * Return 0 if operation was successful.
249 * @inode_free_security:
250 * @inode contains the inode structure.
251 * Deallocate the inode security structure and set @inode->i_security to
252 * NULL.
253 * @inode_create:
254 * Check permission to create a regular file.
255 * @dir contains inode structure of the parent of the new file.
256 * @dentry contains the dentry structure for the file to be created.
257 * @mode contains the file mode of the file to be created.
258 * Return 0 if permission is granted.
259 * @inode_post_create:
260 * Set the security attributes on a newly created regular file. This hook
261 * is called after a file has been successfully created.
262 * @dir contains the inode structure of the parent directory of the new file.
263 * @dentry contains the the dentry structure for the newly created file.
264 * @mode contains the file mode.
265 * @inode_link:
266 * Check permission before creating a new hard link to a file.
267 * @old_dentry contains the dentry structure for an existing link to the file.
268 * @dir contains the inode structure of the parent directory of the new link.
269 * @new_dentry contains the dentry structure for the new link.
270 * Return 0 if permission is granted.
271 * @inode_post_link:
272 * Set security attributes for a new hard link to a file.
273 * @old_dentry contains the dentry structure for the existing link.
274 * @dir contains the inode structure of the parent directory of the new file.
275 * @new_dentry contains the dentry structure for the new file link.
276 * @inode_unlink:
277 * Check the permission to remove a hard link to a file.
278 * @dir contains the inode structure of parent directory of the file.
279 * @dentry contains the dentry structure for file to be unlinked.
280 * Return 0 if permission is granted.
281 * @inode_symlink:
282 * Check the permission to create a symbolic link to a file.
283 * @dir contains the inode structure of parent directory of the symbolic link.
284 * @dentry contains the dentry structure of the symbolic link.
285 * @old_name contains the pathname of file.
286 * Return 0 if permission is granted.
287 * @inode_post_symlink:
288 * @dir contains the inode structure of the parent directory of the new link.
289 * @dentry contains the dentry structure of new symbolic link.
290 * @old_name contains the pathname of file.
291 * Set security attributes for a newly created symbolic link. Note that
292 * @dentry->d_inode may be NULL, since the filesystem might not
293 * instantiate the dentry (e.g. NFS).
294 * @inode_mkdir:
295 * Check permissions to create a new directory in the existing directory
296 * associated with inode strcture @dir.
297 * @dir containst the inode structure of parent of the directory to be created.
298 * @dentry contains the dentry structure of new directory.
299 * @mode contains the mode of new directory.
300 * Return 0 if permission is granted.
301 * @inode_post_mkdir:
302 * Set security attributes on a newly created directory.
303 * @dir contains the inode structure of parent of the directory to be created.
304 * @dentry contains the dentry structure of new directory.
305 * @mode contains the mode of new directory.
306 * @inode_rmdir:
307 * Check the permission to remove a directory.
308 * @dir contains the inode structure of parent of the directory to be removed.
309 * @dentry contains the dentry structure of directory to be removed.
310 * Return 0 if permission is granted.
311 * @inode_mknod:
312 * Check permissions when creating a special file (or a socket or a fifo
313 * file created via the mknod system call). Note that if mknod operation
314 * is being done for a regular file, then the create hook will be called
315 * and not this hook.
316 * @dir contains the inode structure of parent of the new file.
317 * @dentry contains the dentry structure of the new file.
318 * @mode contains the mode of the new file.
319 * @dev contains the the device number.
320 * Return 0 if permission is granted.
321 * @inode_post_mknod:
322 * Set security attributes on a newly created special file (or socket or
323 * fifo file created via the mknod system call).
324 * @dir contains the inode structure of parent of the new node.
325 * @dentry contains the dentry structure of the new node.
326 * @mode contains the mode of the new node.
327 * @dev contains the the device number.
328 * @inode_rename:
329 * Check for permission to rename a file or directory.
330 * @old_dir contains the inode structure for parent of the old link.
331 * @old_dentry contains the dentry structure of the old link.
332 * @new_dir contains the inode structure for parent of the new link.
333 * @new_dentry contains the dentry structure of the new link.
334 * Return 0 if permission is granted.
335 * @inode_post_rename:
336 * Set security attributes on a renamed file or directory.
337 * @old_dir contains the inode structure for parent of the old link.
338 * @old_dentry contains the dentry structure of the old link.
339 * @new_dir contains the inode structure for parent of the new link.
340 * @new_dentry contains the dentry structure of the new link.
341 * @inode_readlink:
342 * Check the permission to read the symbolic link.
343 * @dentry contains the dentry structure for the file link.
344 * Return 0 if permission is granted.
345 * @inode_follow_link:
346 * Check permission to follow a symbolic link when looking up a pathname.
347 * @dentry contains the dentry structure for the link.
348 * @nd contains the nameidata structure for the parent directory.
349 * Return 0 if permission is granted.
350 * @inode_permission:
351 * Check permission before accessing an inode. This hook is called by the
352 * existing Linux permission function, so a security module can use it to
353 * provide additional checking for existing Linux permission checks.
354 * Notice that this hook is called when a file is opened (as well as many
355 * other operations), whereas the file_security_ops permission hook is
356 * called when the actual read/write operations are performed.
357 * @inode contains the inode structure to check.
358 * @mask contains the permission mask.
359 * @nd contains the nameidata (may be NULL).
360 * Return 0 if permission is granted.
361 * @inode_setattr:
362 * Check permission before setting file attributes. Note that the kernel
363 * call to notify_change is performed from several locations, whenever
364 * file attributes change (such as when a file is truncated, chown/chmod
365 * operations, transferring disk quotas, etc).
366 * @dentry contains the dentry structure for the file.
367 * @attr is the iattr structure containing the new file attributes.
368 * Return 0 if permission is granted.
369 * @inode_getattr:
370 * Check permission before obtaining file attributes.
371 * @mnt is the vfsmount where the dentry was looked up
372 * @dentry contains the dentry structure for the file.
373 * Return 0 if permission is granted.
374 * @inode_delete:
375 * @inode contains the inode structure for deleted inode.
376 * This hook is called when a deleted inode is released (i.e. an inode
377 * with no hard links has its use count drop to zero). A security module
378 * can use this hook to release any persistent label associated with the
379 * inode.
380 * @inode_setxattr:
381 * Check permission before setting the extended attributes
382 * @value identified by @name for @dentry.
383 * Return 0 if permission is granted.
384 * @inode_post_setxattr:
385 * Update inode security field after successful setxattr operation.
386 * @value identified by @name for @dentry.
387 * @inode_getxattr:
388 * Check permission before obtaining the extended attributes
389 * identified by @name for @dentry.
390 * Return 0 if permission is granted.
391 * @inode_listxattr:
392 * Check permission before obtaining the list of extended attribute
393 * names for @dentry.
394 * Return 0 if permission is granted.
395 * @inode_removexattr:
396 * Check permission before removing the extended attribute
397 * identified by @name for @dentry.
398 * Return 0 if permission is granted.
399 * @inode_getsecurity:
400 * Copy the extended attribute representation of the security label
401 * associated with @name for @inode into @buffer. @buffer may be
402 * NULL to request the size of the buffer required. @size indicates
403 * the size of @buffer in bytes. Note that @name is the remainder
404 * of the attribute name after the security. prefix has been removed.
405 * Return number of bytes used/required on success.
406 * @inode_setsecurity:
407 * Set the security label associated with @name for @inode from the
408 * extended attribute value @value. @size indicates the size of the
409 * @value in bytes. @flags may be XATTR_CREATE, XATTR_REPLACE, or 0.
410 * Note that @name is the remainder of the attribute name after the
411 * security. prefix has been removed.
412 * Return 0 on success.
413 * @inode_listsecurity:
414 * Copy the extended attribute names for the security labels
415 * associated with @inode into @buffer. The maximum size of @buffer
416 * is specified by @buffer_size. @buffer may be NULL to request
417 * the size of the buffer required.
418 * Returns number of bytes used/required on success.
419 *
420 * Security hooks for file operations
421 *
422 * @file_permission:
423 * Check file permissions before accessing an open file. This hook is
424 * called by various operations that read or write files. A security
425 * module can use this hook to perform additional checking on these
426 * operations, e.g. to revalidate permissions on use to support privilege
427 * bracketing or policy changes. Notice that this hook is used when the
428 * actual read/write operations are performed, whereas the
429 * inode_security_ops hook is called when a file is opened (as well as
430 * many other operations).
431 * Caveat: Although this hook can be used to revalidate permissions for
432 * various system call operations that read or write files, it does not
433 * address the revalidation of permissions for memory-mapped files.
434 * Security modules must handle this separately if they need such
435 * revalidation.
436 * @file contains the file structure being accessed.
437 * @mask contains the requested permissions.
438 * Return 0 if permission is granted.
439 * @file_alloc_security:
440 * Allocate and attach a security structure to the file->f_security field.
441 * The security field is initialized to NULL when the structure is first
442 * created.
443 * @file contains the file structure to secure.
444 * Return 0 if the hook is successful and permission is granted.
445 * @file_free_security:
446 * Deallocate and free any security structures stored in file->f_security.
447 * @file contains the file structure being modified.
448 * @file_ioctl:
449 * @file contains the file structure.
450 * @cmd contains the operation to perform.
451 * @arg contains the operational arguments.
452 * Check permission for an ioctl operation on @file. Note that @arg can
453 * sometimes represents a user space pointer; in other cases, it may be a
454 * simple integer value. When @arg represents a user space pointer, it
455 * should never be used by the security module.
456 * Return 0 if permission is granted.
457 * @file_mmap :
458 * Check permissions for a mmap operation. The @file may be NULL, e.g.
459 * if mapping anonymous memory.
460 * @file contains the file structure for file to map (may be NULL).
461 * @reqprot contains the protection requested by the application.
462 * @prot contains the protection that will be applied by the kernel.
463 * @flags contains the operational flags.
464 * Return 0 if permission is granted.
465 * @file_mprotect:
466 * Check permissions before changing memory access permissions.
467 * @vma contains the memory region to modify.
468 * @reqprot contains the protection requested by the application.
469 * @prot contains the protection that will be applied by the kernel.
470 * Return 0 if permission is granted.
471 * @file_lock:
472 * Check permission before performing file locking operations.
473 * Note: this hook mediates both flock and fcntl style locks.
474 * @file contains the file structure.
475 * @cmd contains the posix-translated lock operation to perform
476 * (e.g. F_RDLCK, F_WRLCK).
477 * Return 0 if permission is granted.
478 * @file_fcntl:
479 * Check permission before allowing the file operation specified by @cmd
480 * from being performed on the file @file. Note that @arg can sometimes
481 * represents a user space pointer; in other cases, it may be a simple
482 * integer value. When @arg represents a user space pointer, it should
483 * never be used by the security module.
484 * @file contains the file structure.
485 * @cmd contains the operation to be performed.
486 * @arg contains the operational arguments.
487 * Return 0 if permission is granted.
488 * @file_set_fowner:
489 * Save owner security information (typically from current->security) in
490 * file->f_security for later use by the send_sigiotask hook.
491 * @file contains the file structure to update.
492 * Return 0 on success.
493 * @file_send_sigiotask:
494 * Check permission for the file owner @fown to send SIGIO or SIGURG to the
495 * process @tsk. Note that this hook is sometimes called from interrupt.
496 * Note that the fown_struct, @fown, is never outside the context of a
497 * struct file, so the file structure (and associated security information)
498 * can always be obtained:
499 * (struct file *)((long)fown - offsetof(struct file,f_owner));
500 * @tsk contains the structure of task receiving signal.
501 * @fown contains the file owner information.
502 * @sig is the signal that will be sent. When 0, kernel sends SIGIO.
503 * Return 0 if permission is granted.
504 * @file_receive:
505 * This hook allows security modules to control the ability of a process
506 * to receive an open file descriptor via socket IPC.
507 * @file contains the file structure being received.
508 * Return 0 if permission is granted.
509 *
510 * Security hooks for task operations.
511 *
512 * @task_create:
513 * Check permission before creating a child process. See the clone(2)
514 * manual page for definitions of the @clone_flags.
515 * @clone_flags contains the flags indicating what should be shared.
516 * Return 0 if permission is granted.
517 * @task_alloc_security:
518 * @p contains the task_struct for child process.
519 * Allocate and attach a security structure to the p->security field. The
520 * security field is initialized to NULL when the task structure is
521 * allocated.
522 * Return 0 if operation was successful.
523 * @task_free_security:
524 * @p contains the task_struct for process.
525 * Deallocate and clear the p->security field.
526 * @task_setuid:
527 * Check permission before setting one or more of the user identity
528 * attributes of the current process. The @flags parameter indicates
529 * which of the set*uid system calls invoked this hook and how to
530 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
531 * definitions at the beginning of this file for the @flags values and
532 * their meanings.
533 * @id0 contains a uid.
534 * @id1 contains a uid.
535 * @id2 contains a uid.
536 * @flags contains one of the LSM_SETID_* values.
537 * Return 0 if permission is granted.
538 * @task_post_setuid:
539 * Update the module's state after setting one or more of the user
540 * identity attributes of the current process. The @flags parameter
541 * indicates which of the set*uid system calls invoked this hook. If
542 * @flags is LSM_SETID_FS, then @old_ruid is the old fs uid and the other
543 * parameters are not used.
544 * @old_ruid contains the old real uid (or fs uid if LSM_SETID_FS).
545 * @old_euid contains the old effective uid (or -1 if LSM_SETID_FS).
546 * @old_suid contains the old saved uid (or -1 if LSM_SETID_FS).
547 * @flags contains one of the LSM_SETID_* values.
548 * Return 0 on success.
549 * @task_setgid:
550 * Check permission before setting one or more of the group identity
551 * attributes of the current process. The @flags parameter indicates
552 * which of the set*gid system calls invoked this hook and how to
553 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
554 * definitions at the beginning of this file for the @flags values and
555 * their meanings.
556 * @id0 contains a gid.
557 * @id1 contains a gid.
558 * @id2 contains a gid.
559 * @flags contains one of the LSM_SETID_* values.
560 * Return 0 if permission is granted.
561 * @task_setpgid:
562 * Check permission before setting the process group identifier of the
563 * process @p to @pgid.
564 * @p contains the task_struct for process being modified.
565 * @pgid contains the new pgid.
566 * Return 0 if permission is granted.
567 * @task_getpgid:
568 * Check permission before getting the process group identifier of the
569 * process @p.
570 * @p contains the task_struct for the process.
571 * Return 0 if permission is granted.
572 * @task_getsid:
573 * Check permission before getting the session identifier of the process
574 * @p.
575 * @p contains the task_struct for the process.
576 * Return 0 if permission is granted.
577 * @task_setgroups:
578 * Check permission before setting the supplementary group set of the
579 * current process.
580 * @group_info contains the new group information.
581 * Return 0 if permission is granted.
582 * @task_setnice:
583 * Check permission before setting the nice value of @p to @nice.
584 * @p contains the task_struct of process.
585 * @nice contains the new nice value.
586 * Return 0 if permission is granted.
587 * @task_setrlimit:
588 * Check permission before setting the resource limits of the current
589 * process for @resource to @new_rlim. The old resource limit values can
590 * be examined by dereferencing (current->signal->rlim + resource).
591 * @resource contains the resource whose limit is being set.
592 * @new_rlim contains the new limits for @resource.
593 * Return 0 if permission is granted.
594 * @task_setscheduler:
595 * Check permission before setting scheduling policy and/or parameters of
596 * process @p based on @policy and @lp.
597 * @p contains the task_struct for process.
598 * @policy contains the scheduling policy.
599 * @lp contains the scheduling parameters.
600 * Return 0 if permission is granted.
601 * @task_getscheduler:
602 * Check permission before obtaining scheduling information for process
603 * @p.
604 * @p contains the task_struct for process.
605 * Return 0 if permission is granted.
606 * @task_kill:
607 * Check permission before sending signal @sig to @p. @info can be NULL,
608 * the constant 1, or a pointer to a siginfo structure. If @info is 1 or
609 * SI_FROMKERNEL(info) is true, then the signal should be viewed as coming
610 * from the kernel and should typically be permitted.
611 * SIGIO signals are handled separately by the send_sigiotask hook in
612 * file_security_ops.
613 * @p contains the task_struct for process.
614 * @info contains the signal information.
615 * @sig contains the signal value.
616 * Return 0 if permission is granted.
617 * @task_wait:
618 * Check permission before allowing a process to reap a child process @p
619 * and collect its status information.
620 * @p contains the task_struct for process.
621 * Return 0 if permission is granted.
622 * @task_prctl:
623 * Check permission before performing a process control operation on the
624 * current process.
625 * @option contains the operation.
626 * @arg2 contains a argument.
627 * @arg3 contains a argument.
628 * @arg4 contains a argument.
629 * @arg5 contains a argument.
630 * Return 0 if permission is granted.
631 * @task_reparent_to_init:
632 * Set the security attributes in @p->security for a kernel thread that
633 * is being reparented to the init task.
634 * @p contains the task_struct for the kernel thread.
635 * @task_to_inode:
636 * Set the security attributes for an inode based on an associated task's
637 * security attributes, e.g. for /proc/pid inodes.
638 * @p contains the task_struct for the task.
639 * @inode contains the inode structure for the inode.
640 *
641 * Security hooks for Netlink messaging.
642 *
643 * @netlink_send:
644 * Save security information for a netlink message so that permission
645 * checking can be performed when the message is processed. The security
646 * information can be saved using the eff_cap field of the
647 * netlink_skb_parms structure. Also may be used to provide fine
648 * grained control over message transmission.
649 * @sk associated sock of task sending the message.,
650 * @skb contains the sk_buff structure for the netlink message.
651 * Return 0 if the information was successfully saved and message
652 * is allowed to be transmitted.
653 * @netlink_recv:
654 * Check permission before processing the received netlink message in
655 * @skb.
656 * @skb contains the sk_buff structure for the netlink message.
657 * Return 0 if permission is granted.
658 *
659 * Security hooks for Unix domain networking.
660 *
661 * @unix_stream_connect:
662 * Check permissions before establishing a Unix domain stream connection
663 * between @sock and @other.
664 * @sock contains the socket structure.
665 * @other contains the peer socket structure.
666 * Return 0 if permission is granted.
667 * @unix_may_send:
668 * Check permissions before connecting or sending datagrams from @sock to
669 * @other.
670 * @sock contains the socket structure.
671 * @sock contains the peer socket structure.
672 * Return 0 if permission is granted.
673 *
674 * The @unix_stream_connect and @unix_may_send hooks were necessary because
675 * Linux provides an alternative to the conventional file name space for Unix
676 * domain sockets. Whereas binding and connecting to sockets in the file name
677 * space is mediated by the typical file permissions (and caught by the mknod
678 * and permission hooks in inode_security_ops), binding and connecting to
679 * sockets in the abstract name space is completely unmediated. Sufficient
680 * control of Unix domain sockets in the abstract name space isn't possible
681 * using only the socket layer hooks, since we need to know the actual target
682 * socket, which is not looked up until we are inside the af_unix code.
683 *
684 * Security hooks for socket operations.
685 *
686 * @socket_create:
687 * Check permissions prior to creating a new socket.
688 * @family contains the requested protocol family.
689 * @type contains the requested communications type.
690 * @protocol contains the requested protocol.
691 * @kern set to 1 if a kernel socket.
692 * Return 0 if permission is granted.
693 * @socket_post_create:
694 * This hook allows a module to update or allocate a per-socket security
695 * structure. Note that the security field was not added directly to the
696 * socket structure, but rather, the socket security information is stored
697 * in the associated inode. Typically, the inode alloc_security hook will
698 * allocate and and attach security information to
699 * sock->inode->i_security. This hook may be used to update the
700 * sock->inode->i_security field with additional information that wasn't
701 * available when the inode was allocated.
702 * @sock contains the newly created socket structure.
703 * @family contains the requested protocol family.
704 * @type contains the requested communications type.
705 * @protocol contains the requested protocol.
706 * @kern set to 1 if a kernel socket.
707 * @socket_bind:
708 * Check permission before socket protocol layer bind operation is
709 * performed and the socket @sock is bound to the address specified in the
710 * @address parameter.
711 * @sock contains the socket structure.
712 * @address contains the address to bind to.
713 * @addrlen contains the length of address.
714 * Return 0 if permission is granted.
715 * @socket_connect:
716 * Check permission before socket protocol layer connect operation
717 * attempts to connect socket @sock to a remote address, @address.
718 * @sock contains the socket structure.
719 * @address contains the address of remote endpoint.
720 * @addrlen contains the length of address.
721 * Return 0 if permission is granted.
722 * @socket_listen:
723 * Check permission before socket protocol layer listen operation.
724 * @sock contains the socket structure.
725 * @backlog contains the maximum length for the pending connection queue.
726 * Return 0 if permission is granted.
727 * @socket_accept:
728 * Check permission before accepting a new connection. Note that the new
729 * socket, @newsock, has been created and some information copied to it,
730 * but the accept operation has not actually been performed.
731 * @sock contains the listening socket structure.
732 * @newsock contains the newly created server socket for connection.
733 * Return 0 if permission is granted.
734 * @socket_post_accept:
735 * This hook allows a security module to copy security
736 * information into the newly created socket's inode.
737 * @sock contains the listening socket structure.
738 * @newsock contains the newly created server socket for connection.
739 * @socket_sendmsg:
740 * Check permission before transmitting a message to another socket.
741 * @sock contains the socket structure.
742 * @msg contains the message to be transmitted.
743 * @size contains the size of message.
744 * Return 0 if permission is granted.
745 * @socket_recvmsg:
746 * Check permission before receiving a message from a socket.
747 * @sock contains the socket structure.
748 * @msg contains the message structure.
749 * @size contains the size of message structure.
750 * @flags contains the operational flags.
751 * Return 0 if permission is granted.
752 * @socket_getsockname:
753 * Check permission before the local address (name) of the socket object
754 * @sock is retrieved.
755 * @sock contains the socket structure.
756 * Return 0 if permission is granted.
757 * @socket_getpeername:
758 * Check permission before the remote address (name) of a socket object
759 * @sock is retrieved.
760 * @sock contains the socket structure.
761 * Return 0 if permission is granted.
762 * @socket_getsockopt:
763 * Check permissions before retrieving the options associated with socket
764 * @sock.
765 * @sock contains the socket structure.
766 * @level contains the protocol level to retrieve option from.
767 * @optname contains the name of option to retrieve.
768 * Return 0 if permission is granted.
769 * @socket_setsockopt:
770 * Check permissions before setting the options associated with socket
771 * @sock.
772 * @sock contains the socket structure.
773 * @level contains the protocol level to set options for.
774 * @optname contains the name of the option to set.
775 * Return 0 if permission is granted.
776 * @socket_shutdown:
777 * Checks permission before all or part of a connection on the socket
778 * @sock is shut down.
779 * @sock contains the socket structure.
780 * @how contains the flag indicating how future sends and receives are handled.
781 * Return 0 if permission is granted.
782 * @socket_sock_rcv_skb:
783 * Check permissions on incoming network packets. This hook is distinct
784 * from Netfilter's IP input hooks since it is the first time that the
785 * incoming sk_buff @skb has been associated with a particular socket, @sk.
786 * @sk contains the sock (not socket) associated with the incoming sk_buff.
787 * @skb contains the incoming network data.
788 * @socket_getpeersec:
789 * This hook allows the security module to provide peer socket security
790 * state to userspace via getsockopt SO_GETPEERSEC.
791 * @sock is the local socket.
792 * @optval userspace memory where the security state is to be copied.
793 * @optlen userspace int where the module should copy the actual length
794 * of the security state.
795 * @len as input is the maximum length to copy to userspace provided
796 * by the caller.
797 * Return 0 if all is well, otherwise, typical getsockopt return
798 * values.
799 * @sk_alloc_security:
800 * Allocate and attach a security structure to the sk->sk_security field,
801 * which is used to copy security attributes between local stream sockets.
802 * @sk_free_security:
803 * Deallocate security structure.
804 *
805 * Security hooks affecting all System V IPC operations.
806 *
807 * @ipc_permission:
808 * Check permissions for access to IPC
809 * @ipcp contains the kernel IPC permission structure
810 * @flag contains the desired (requested) permission set
811 * Return 0 if permission is granted.
812 *
813 * Security hooks for individual messages held in System V IPC message queues
814 * @msg_msg_alloc_security:
815 * Allocate and attach a security structure to the msg->security field.
816 * The security field is initialized to NULL when the structure is first
817 * created.
818 * @msg contains the message structure to be modified.
819 * Return 0 if operation was successful and permission is granted.
820 * @msg_msg_free_security:
821 * Deallocate the security structure for this message.
822 * @msg contains the message structure to be modified.
823 *
824 * Security hooks for System V IPC Message Queues
825 *
826 * @msg_queue_alloc_security:
827 * Allocate and attach a security structure to the
828 * msq->q_perm.security field. The security field is initialized to
829 * NULL when the structure is first created.
830 * @msq contains the message queue structure to be modified.
831 * Return 0 if operation was successful and permission is granted.
832 * @msg_queue_free_security:
833 * Deallocate security structure for this message queue.
834 * @msq contains the message queue structure to be modified.
835 * @msg_queue_associate:
836 * Check permission when a message queue is requested through the
837 * msgget system call. This hook is only called when returning the
838 * message queue identifier for an existing message queue, not when a
839 * new message queue is created.
840 * @msq contains the message queue to act upon.
841 * @msqflg contains the operation control flags.
842 * Return 0 if permission is granted.
843 * @msg_queue_msgctl:
844 * Check permission when a message control operation specified by @cmd
845 * is to be performed on the message queue @msq.
846 * The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO.
847 * @msq contains the message queue to act upon. May be NULL.
848 * @cmd contains the operation to be performed.
849 * Return 0 if permission is granted.
850 * @msg_queue_msgsnd:
851 * Check permission before a message, @msg, is enqueued on the message
852 * queue, @msq.
853 * @msq contains the message queue to send message to.
854 * @msg contains the message to be enqueued.
855 * @msqflg contains operational flags.
856 * Return 0 if permission is granted.
857 * @msg_queue_msgrcv:
858 * Check permission before a message, @msg, is removed from the message
859 * queue, @msq. The @target task structure contains a pointer to the
860 * process that will be receiving the message (not equal to the current
861 * process when inline receives are being performed).
862 * @msq contains the message queue to retrieve message from.
863 * @msg contains the message destination.
864 * @target contains the task structure for recipient process.
865 * @type contains the type of message requested.
866 * @mode contains the operational flags.
867 * Return 0 if permission is granted.
868 *
869 * Security hooks for System V Shared Memory Segments
870 *
871 * @shm_alloc_security:
872 * Allocate and attach a security structure to the shp->shm_perm.security
873 * field. The security field is initialized to NULL when the structure is
874 * first created.
875 * @shp contains the shared memory structure to be modified.
876 * Return 0 if operation was successful and permission is granted.
877 * @shm_free_security:
878 * Deallocate the security struct for this memory segment.
879 * @shp contains the shared memory structure to be modified.
880 * @shm_associate:
881 * Check permission when a shared memory region is requested through the
882 * shmget system call. This hook is only called when returning the shared
883 * memory region identifier for an existing region, not when a new shared
884 * memory region is created.
885 * @shp contains the shared memory structure to be modified.
886 * @shmflg contains the operation control flags.
887 * Return 0 if permission is granted.
888 * @shm_shmctl:
889 * Check permission when a shared memory control operation specified by
890 * @cmd is to be performed on the shared memory region @shp.
891 * The @shp may be NULL, e.g. for IPC_INFO or SHM_INFO.
892 * @shp contains shared memory structure to be modified.
893 * @cmd contains the operation to be performed.
894 * Return 0 if permission is granted.
895 * @shm_shmat:
896 * Check permissions prior to allowing the shmat system call to attach the
897 * shared memory segment @shp to the data segment of the calling process.
898 * The attaching address is specified by @shmaddr.
899 * @shp contains the shared memory structure to be modified.
900 * @shmaddr contains the address to attach memory region to.
901 * @shmflg contains the operational flags.
902 * Return 0 if permission is granted.
903 *
904 * Security hooks for System V Semaphores
905 *
906 * @sem_alloc_security:
907 * Allocate and attach a security structure to the sma->sem_perm.security
908 * field. The security field is initialized to NULL when the structure is
909 * first created.
910 * @sma contains the semaphore structure
911 * Return 0 if operation was successful and permission is granted.
912 * @sem_free_security:
913 * deallocate security struct for this semaphore
914 * @sma contains the semaphore structure.
915 * @sem_associate:
916 * Check permission when a semaphore is requested through the semget
917 * system call. This hook is only called when returning the semaphore
918 * identifier for an existing semaphore, not when a new one must be
919 * created.
920 * @sma contains the semaphore structure.
921 * @semflg contains the operation control flags.
922 * Return 0 if permission is granted.
923 * @sem_semctl:
924 * Check permission when a semaphore operation specified by @cmd is to be
925 * performed on the semaphore @sma. The @sma may be NULL, e.g. for
926 * IPC_INFO or SEM_INFO.
927 * @sma contains the semaphore structure. May be NULL.
928 * @cmd contains the operation to be performed.
929 * Return 0 if permission is granted.
930 * @sem_semop
931 * Check permissions before performing operations on members of the
932 * semaphore set @sma. If the @alter flag is nonzero, the semaphore set
933 * may be modified.
934 * @sma contains the semaphore structure.
935 * @sops contains the operations to perform.
936 * @nsops contains the number of operations to perform.
937 * @alter contains the flag indicating whether changes are to be made.
938 * Return 0 if permission is granted.
939 *
940 * @ptrace:
941 * Check permission before allowing the @parent process to trace the
942 * @child process.
943 * Security modules may also want to perform a process tracing check
944 * during an execve in the set_security or apply_creds hooks of
945 * binprm_security_ops if the process is being traced and its security
946 * attributes would be changed by the execve.
947 * @parent contains the task_struct structure for parent process.
948 * @child contains the task_struct structure for child process.
949 * Return 0 if permission is granted.
950 * @capget:
951 * Get the @effective, @inheritable, and @permitted capability sets for
952 * the @target process. The hook may also perform permission checking to
953 * determine if the current process is allowed to see the capability sets
954 * of the @target process.
955 * @target contains the task_struct structure for target process.
956 * @effective contains the effective capability set.
957 * @inheritable contains the inheritable capability set.
958 * @permitted contains the permitted capability set.
959 * Return 0 if the capability sets were successfully obtained.
960 * @capset_check:
961 * Check permission before setting the @effective, @inheritable, and
962 * @permitted capability sets for the @target process.
963 * Caveat: @target is also set to current if a set of processes is
964 * specified (i.e. all processes other than current and init or a
965 * particular process group). Hence, the capset_set hook may need to
966 * revalidate permission to the actual target process.
967 * @target contains the task_struct structure for target process.
968 * @effective contains the effective capability set.
969 * @inheritable contains the inheritable capability set.
970 * @permitted contains the permitted capability set.
971 * Return 0 if permission is granted.
972 * @capset_set:
973 * Set the @effective, @inheritable, and @permitted capability sets for
974 * the @target process. Since capset_check cannot always check permission
975 * to the real @target process, this hook may also perform permission
976 * checking to determine if the current process is allowed to set the
977 * capability sets of the @target process. However, this hook has no way
978 * of returning an error due to the structure of the sys_capset code.
979 * @target contains the task_struct structure for target process.
980 * @effective contains the effective capability set.
981 * @inheritable contains the inheritable capability set.
982 * @permitted contains the permitted capability set.
983 * @acct:
984 * Check permission before enabling or disabling process accounting. If
985 * accounting is being enabled, then @file refers to the open file used to
986 * store accounting records. If accounting is being disabled, then @file
987 * is NULL.
988 * @file contains the file structure for the accounting file (may be NULL).
989 * Return 0 if permission is granted.
990 * @sysctl:
991 * Check permission before accessing the @table sysctl variable in the
992 * manner specified by @op.
993 * @table contains the ctl_table structure for the sysctl variable.
994 * @op contains the operation (001 = search, 002 = write, 004 = read).
995 * Return 0 if permission is granted.
996 * @capable:
997 * Check whether the @tsk process has the @cap capability.
998 * @tsk contains the task_struct for the process.
999 * @cap contains the capability <include/linux/capability.h>.
1000 * Return 0 if the capability is granted for @tsk.
1001 * @syslog:
1002 * Check permission before accessing the kernel message ring or changing
1003 * logging to the console.
1004 * See the syslog(2) manual page for an explanation of the @type values.
1005 * @type contains the type of action.
1006 * Return 0 if permission is granted.
1007 * @settime:
1008 * Check permission to change the system time.
1009 * struct timespec and timezone are defined in include/linux/time.h
1010 * @ts contains new time
1011 * @tz contains new timezone
1012 * Return 0 if permission is granted.
1013 * @vm_enough_memory:
1014 * Check permissions for allocating a new virtual mapping.
1015 * @pages contains the number of pages.
1016 * Return 0 if permission is granted.
1017 *
1018 * @register_security:
1019 * allow module stacking.
1020 * @name contains the name of the security module being stacked.
1021 * @ops contains a pointer to the struct security_operations of the module to stack.
1022 * @unregister_security:
1023 * remove a stacked module.
1024 * @name contains the name of the security module being unstacked.
1025 * @ops contains a pointer to the struct security_operations of the module to unstack.
1026 *
1027 * This is the main security structure.
1028 */
1029struct security_operations {
1030 int (*ptrace) (struct task_struct * parent, struct task_struct * child);
1031 int (*capget) (struct task_struct * target,
1032 kernel_cap_t * effective,
1033 kernel_cap_t * inheritable, kernel_cap_t * permitted);
1034 int (*capset_check) (struct task_struct * target,
1035 kernel_cap_t * effective,
1036 kernel_cap_t * inheritable,
1037 kernel_cap_t * permitted);
1038 void (*capset_set) (struct task_struct * target,
1039 kernel_cap_t * effective,
1040 kernel_cap_t * inheritable,
1041 kernel_cap_t * permitted);
1042 int (*acct) (struct file * file);
1043 int (*sysctl) (struct ctl_table * table, int op);
1044 int (*capable) (struct task_struct * tsk, int cap);
1045 int (*quotactl) (int cmds, int type, int id, struct super_block * sb);
1046 int (*quota_on) (struct dentry * dentry);
1047 int (*syslog) (int type);
1048 int (*settime) (struct timespec *ts, struct timezone *tz);
1049 int (*vm_enough_memory) (long pages);
1050
1051 int (*bprm_alloc_security) (struct linux_binprm * bprm);
1052 void (*bprm_free_security) (struct linux_binprm * bprm);
1053 void (*bprm_apply_creds) (struct linux_binprm * bprm, int unsafe);
1054 void (*bprm_post_apply_creds) (struct linux_binprm * bprm);
1055 int (*bprm_set_security) (struct linux_binprm * bprm);
1056 int (*bprm_check_security) (struct linux_binprm * bprm);
1057 int (*bprm_secureexec) (struct linux_binprm * bprm);
1058
1059 int (*sb_alloc_security) (struct super_block * sb);
1060 void (*sb_free_security) (struct super_block * sb);
1061 int (*sb_copy_data)(struct file_system_type *type,
1062 void *orig, void *copy);
1063 int (*sb_kern_mount) (struct super_block *sb, void *data);
1064 int (*sb_statfs) (struct super_block * sb);
1065 int (*sb_mount) (char *dev_name, struct nameidata * nd,
1066 char *type, unsigned long flags, void *data);
1067 int (*sb_check_sb) (struct vfsmount * mnt, struct nameidata * nd);
1068 int (*sb_umount) (struct vfsmount * mnt, int flags);
1069 void (*sb_umount_close) (struct vfsmount * mnt);
1070 void (*sb_umount_busy) (struct vfsmount * mnt);
1071 void (*sb_post_remount) (struct vfsmount * mnt,
1072 unsigned long flags, void *data);
1073 void (*sb_post_mountroot) (void);
1074 void (*sb_post_addmount) (struct vfsmount * mnt,
1075 struct nameidata * mountpoint_nd);
1076 int (*sb_pivotroot) (struct nameidata * old_nd,
1077 struct nameidata * new_nd);
1078 void (*sb_post_pivotroot) (struct nameidata * old_nd,
1079 struct nameidata * new_nd);
1080
1081 int (*inode_alloc_security) (struct inode *inode);
1082 void (*inode_free_security) (struct inode *inode);
1083 int (*inode_create) (struct inode *dir,
1084 struct dentry *dentry, int mode);
1085 void (*inode_post_create) (struct inode *dir,
1086 struct dentry *dentry, int mode);
1087 int (*inode_link) (struct dentry *old_dentry,
1088 struct inode *dir, struct dentry *new_dentry);
1089 void (*inode_post_link) (struct dentry *old_dentry,
1090 struct inode *dir, struct dentry *new_dentry);
1091 int (*inode_unlink) (struct inode *dir, struct dentry *dentry);
1092 int (*inode_symlink) (struct inode *dir,
1093 struct dentry *dentry, const char *old_name);
1094 void (*inode_post_symlink) (struct inode *dir,
1095 struct dentry *dentry,
1096 const char *old_name);
1097 int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode);
1098 void (*inode_post_mkdir) (struct inode *dir, struct dentry *dentry,
1099 int mode);
1100 int (*inode_rmdir) (struct inode *dir, struct dentry *dentry);
1101 int (*inode_mknod) (struct inode *dir, struct dentry *dentry,
1102 int mode, dev_t dev);
1103 void (*inode_post_mknod) (struct inode *dir, struct dentry *dentry,
1104 int mode, dev_t dev);
1105 int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
1106 struct inode *new_dir, struct dentry *new_dentry);
1107 void (*inode_post_rename) (struct inode *old_dir,
1108 struct dentry *old_dentry,
1109 struct inode *new_dir,
1110 struct dentry *new_dentry);
1111 int (*inode_readlink) (struct dentry *dentry);
1112 int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
1113 int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd);
1114 int (*inode_setattr) (struct dentry *dentry, struct iattr *attr);
1115 int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
1116 void (*inode_delete) (struct inode *inode);
1117 int (*inode_setxattr) (struct dentry *dentry, char *name, void *value,
1118 size_t size, int flags);
1119 void (*inode_post_setxattr) (struct dentry *dentry, char *name, void *value,
1120 size_t size, int flags);
1121 int (*inode_getxattr) (struct dentry *dentry, char *name);
1122 int (*inode_listxattr) (struct dentry *dentry);
1123 int (*inode_removexattr) (struct dentry *dentry, char *name);
1124 int (*inode_getsecurity)(struct inode *inode, const char *name, void *buffer, size_t size);
1125 int (*inode_setsecurity)(struct inode *inode, const char *name, const void *value, size_t size, int flags);
1126 int (*inode_listsecurity)(struct inode *inode, char *buffer, size_t buffer_size);
1127
1128 int (*file_permission) (struct file * file, int mask);
1129 int (*file_alloc_security) (struct file * file);
1130 void (*file_free_security) (struct file * file);
1131 int (*file_ioctl) (struct file * file, unsigned int cmd,
1132 unsigned long arg);
1133 int (*file_mmap) (struct file * file,
1134 unsigned long reqprot,
1135 unsigned long prot, unsigned long flags);
1136 int (*file_mprotect) (struct vm_area_struct * vma,
1137 unsigned long reqprot,
1138 unsigned long prot);
1139 int (*file_lock) (struct file * file, unsigned int cmd);
1140 int (*file_fcntl) (struct file * file, unsigned int cmd,
1141 unsigned long arg);
1142 int (*file_set_fowner) (struct file * file);
1143 int (*file_send_sigiotask) (struct task_struct * tsk,
1144 struct fown_struct * fown, int sig);
1145 int (*file_receive) (struct file * file);
1146
1147 int (*task_create) (unsigned long clone_flags);
1148 int (*task_alloc_security) (struct task_struct * p);
1149 void (*task_free_security) (struct task_struct * p);
1150 int (*task_setuid) (uid_t id0, uid_t id1, uid_t id2, int flags);
1151 int (*task_post_setuid) (uid_t old_ruid /* or fsuid */ ,
1152 uid_t old_euid, uid_t old_suid, int flags);
1153 int (*task_setgid) (gid_t id0, gid_t id1, gid_t id2, int flags);
1154 int (*task_setpgid) (struct task_struct * p, pid_t pgid);
1155 int (*task_getpgid) (struct task_struct * p);
1156 int (*task_getsid) (struct task_struct * p);
1157 int (*task_setgroups) (struct group_info *group_info);
1158 int (*task_setnice) (struct task_struct * p, int nice);
1159 int (*task_setrlimit) (unsigned int resource, struct rlimit * new_rlim);
1160 int (*task_setscheduler) (struct task_struct * p, int policy,
1161 struct sched_param * lp);
1162 int (*task_getscheduler) (struct task_struct * p);
1163 int (*task_kill) (struct task_struct * p,
1164 struct siginfo * info, int sig);
1165 int (*task_wait) (struct task_struct * p);
1166 int (*task_prctl) (int option, unsigned long arg2,
1167 unsigned long arg3, unsigned long arg4,
1168 unsigned long arg5);
1169 void (*task_reparent_to_init) (struct task_struct * p);
1170 void (*task_to_inode)(struct task_struct *p, struct inode *inode);
1171
1172 int (*ipc_permission) (struct kern_ipc_perm * ipcp, short flag);
1173
1174 int (*msg_msg_alloc_security) (struct msg_msg * msg);
1175 void (*msg_msg_free_security) (struct msg_msg * msg);
1176
1177 int (*msg_queue_alloc_security) (struct msg_queue * msq);
1178 void (*msg_queue_free_security) (struct msg_queue * msq);
1179 int (*msg_queue_associate) (struct msg_queue * msq, int msqflg);
1180 int (*msg_queue_msgctl) (struct msg_queue * msq, int cmd);
1181 int (*msg_queue_msgsnd) (struct msg_queue * msq,
1182 struct msg_msg * msg, int msqflg);
1183 int (*msg_queue_msgrcv) (struct msg_queue * msq,
1184 struct msg_msg * msg,
1185 struct task_struct * target,
1186 long type, int mode);
1187
1188 int (*shm_alloc_security) (struct shmid_kernel * shp);
1189 void (*shm_free_security) (struct shmid_kernel * shp);
1190 int (*shm_associate) (struct shmid_kernel * shp, int shmflg);
1191 int (*shm_shmctl) (struct shmid_kernel * shp, int cmd);
1192 int (*shm_shmat) (struct shmid_kernel * shp,
1193 char __user *shmaddr, int shmflg);
1194
1195 int (*sem_alloc_security) (struct sem_array * sma);
1196 void (*sem_free_security) (struct sem_array * sma);
1197 int (*sem_associate) (struct sem_array * sma, int semflg);
1198 int (*sem_semctl) (struct sem_array * sma, int cmd);
1199 int (*sem_semop) (struct sem_array * sma,
1200 struct sembuf * sops, unsigned nsops, int alter);
1201
1202 int (*netlink_send) (struct sock * sk, struct sk_buff * skb);
1203 int (*netlink_recv) (struct sk_buff * skb);
1204
1205 /* allow module stacking */
1206 int (*register_security) (const char *name,
1207 struct security_operations *ops);
1208 int (*unregister_security) (const char *name,
1209 struct security_operations *ops);
1210
1211 void (*d_instantiate) (struct dentry *dentry, struct inode *inode);
1212
1213 int (*getprocattr)(struct task_struct *p, char *name, void *value, size_t size);
1214 int (*setprocattr)(struct task_struct *p, char *name, void *value, size_t size);
1215
1216#ifdef CONFIG_SECURITY_NETWORK
1217 int (*unix_stream_connect) (struct socket * sock,
1218 struct socket * other, struct sock * newsk);
1219 int (*unix_may_send) (struct socket * sock, struct socket * other);
1220
1221 int (*socket_create) (int family, int type, int protocol, int kern);
1222 void (*socket_post_create) (struct socket * sock, int family,
1223 int type, int protocol, int kern);
1224 int (*socket_bind) (struct socket * sock,
1225 struct sockaddr * address, int addrlen);
1226 int (*socket_connect) (struct socket * sock,
1227 struct sockaddr * address, int addrlen);
1228 int (*socket_listen) (struct socket * sock, int backlog);
1229 int (*socket_accept) (struct socket * sock, struct socket * newsock);
1230 void (*socket_post_accept) (struct socket * sock,
1231 struct socket * newsock);
1232 int (*socket_sendmsg) (struct socket * sock,
1233 struct msghdr * msg, int size);
1234 int (*socket_recvmsg) (struct socket * sock,
1235 struct msghdr * msg, int size, int flags);
1236 int (*socket_getsockname) (struct socket * sock);
1237 int (*socket_getpeername) (struct socket * sock);
1238 int (*socket_getsockopt) (struct socket * sock, int level, int optname);
1239 int (*socket_setsockopt) (struct socket * sock, int level, int optname);
1240 int (*socket_shutdown) (struct socket * sock, int how);
1241 int (*socket_sock_rcv_skb) (struct sock * sk, struct sk_buff * skb);
1242 int (*socket_getpeersec) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len);
1243 int (*sk_alloc_security) (struct sock *sk, int family, int priority);
1244 void (*sk_free_security) (struct sock *sk);
1245#endif /* CONFIG_SECURITY_NETWORK */
1246};
1247
1248/* global variables */
1249extern struct security_operations *security_ops;
1250
1251/* inline stuff */
1252static inline int security_ptrace (struct task_struct * parent, struct task_struct * child)
1253{
1254 return security_ops->ptrace (parent, child);
1255}
1256
1257static inline int security_capget (struct task_struct *target,
1258 kernel_cap_t *effective,
1259 kernel_cap_t *inheritable,
1260 kernel_cap_t *permitted)
1261{
1262 return security_ops->capget (target, effective, inheritable, permitted);
1263}
1264
1265static inline int security_capset_check (struct task_struct *target,
1266 kernel_cap_t *effective,
1267 kernel_cap_t *inheritable,
1268 kernel_cap_t *permitted)
1269{
1270 return security_ops->capset_check (target, effective, inheritable, permitted);
1271}
1272
1273static inline void security_capset_set (struct task_struct *target,
1274 kernel_cap_t *effective,
1275 kernel_cap_t *inheritable,
1276 kernel_cap_t *permitted)
1277{
1278 security_ops->capset_set (target, effective, inheritable, permitted);
1279}
1280
1281static inline int security_acct (struct file *file)
1282{
1283 return security_ops->acct (file);
1284}
1285
1286static inline int security_sysctl(struct ctl_table *table, int op)
1287{
1288 return security_ops->sysctl(table, op);
1289}
1290
1291static inline int security_quotactl (int cmds, int type, int id,
1292 struct super_block *sb)
1293{
1294 return security_ops->quotactl (cmds, type, id, sb);
1295}
1296
1297static inline int security_quota_on (struct dentry * dentry)
1298{
1299 return security_ops->quota_on (dentry);
1300}
1301
1302static inline int security_syslog(int type)
1303{
1304 return security_ops->syslog(type);
1305}
1306
1307static inline int security_settime(struct timespec *ts, struct timezone *tz)
1308{
1309 return security_ops->settime(ts, tz);
1310}
1311
1312
1313static inline int security_vm_enough_memory(long pages)
1314{
1315 return security_ops->vm_enough_memory(pages);
1316}
1317
1318static inline int security_bprm_alloc (struct linux_binprm *bprm)
1319{
1320 return security_ops->bprm_alloc_security (bprm);
1321}
1322static inline void security_bprm_free (struct linux_binprm *bprm)
1323{
1324 security_ops->bprm_free_security (bprm);
1325}
1326static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
1327{
1328 security_ops->bprm_apply_creds (bprm, unsafe);
1329}
1330static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
1331{
1332 security_ops->bprm_post_apply_creds (bprm);
1333}
1334static inline int security_bprm_set (struct linux_binprm *bprm)
1335{
1336 return security_ops->bprm_set_security (bprm);
1337}
1338
1339static inline int security_bprm_check (struct linux_binprm *bprm)
1340{
1341 return security_ops->bprm_check_security (bprm);
1342}
1343
1344static inline int security_bprm_secureexec (struct linux_binprm *bprm)
1345{
1346 return security_ops->bprm_secureexec (bprm);
1347}
1348
1349static inline int security_sb_alloc (struct super_block *sb)
1350{
1351 return security_ops->sb_alloc_security (sb);
1352}
1353
1354static inline void security_sb_free (struct super_block *sb)
1355{
1356 security_ops->sb_free_security (sb);
1357}
1358
1359static inline int security_sb_copy_data (struct file_system_type *type,
1360 void *orig, void *copy)
1361{
1362 return security_ops->sb_copy_data (type, orig, copy);
1363}
1364
1365static inline int security_sb_kern_mount (struct super_block *sb, void *data)
1366{
1367 return security_ops->sb_kern_mount (sb, data);
1368}
1369
1370static inline int security_sb_statfs (struct super_block *sb)
1371{
1372 return security_ops->sb_statfs (sb);
1373}
1374
1375static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
1376 char *type, unsigned long flags,
1377 void *data)
1378{
1379 return security_ops->sb_mount (dev_name, nd, type, flags, data);
1380}
1381
1382static inline int security_sb_check_sb (struct vfsmount *mnt,
1383 struct nameidata *nd)
1384{
1385 return security_ops->sb_check_sb (mnt, nd);
1386}
1387
1388static inline int security_sb_umount (struct vfsmount *mnt, int flags)
1389{
1390 return security_ops->sb_umount (mnt, flags);
1391}
1392
1393static inline void security_sb_umount_close (struct vfsmount *mnt)
1394{
1395 security_ops->sb_umount_close (mnt);
1396}
1397
1398static inline void security_sb_umount_busy (struct vfsmount *mnt)
1399{
1400 security_ops->sb_umount_busy (mnt);
1401}
1402
1403static inline void security_sb_post_remount (struct vfsmount *mnt,
1404 unsigned long flags, void *data)
1405{
1406 security_ops->sb_post_remount (mnt, flags, data);
1407}
1408
1409static inline void security_sb_post_mountroot (void)
1410{
1411 security_ops->sb_post_mountroot ();
1412}
1413
1414static inline void security_sb_post_addmount (struct vfsmount *mnt,
1415 struct nameidata *mountpoint_nd)
1416{
1417 security_ops->sb_post_addmount (mnt, mountpoint_nd);
1418}
1419
1420static inline int security_sb_pivotroot (struct nameidata *old_nd,
1421 struct nameidata *new_nd)
1422{
1423 return security_ops->sb_pivotroot (old_nd, new_nd);
1424}
1425
1426static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
1427 struct nameidata *new_nd)
1428{
1429 security_ops->sb_post_pivotroot (old_nd, new_nd);
1430}
1431
1432static inline int security_inode_alloc (struct inode *inode)
1433{
1434 if (unlikely (IS_PRIVATE (inode)))
1435 return 0;
1436 return security_ops->inode_alloc_security (inode);
1437}
1438
1439static inline void security_inode_free (struct inode *inode)
1440{
1441 if (unlikely (IS_PRIVATE (inode)))
1442 return;
1443 security_ops->inode_free_security (inode);
1444}
1445
1446static inline int security_inode_create (struct inode *dir,
1447 struct dentry *dentry,
1448 int mode)
1449{
1450 if (unlikely (IS_PRIVATE (dir)))
1451 return 0;
1452 return security_ops->inode_create (dir, dentry, mode);
1453}
1454
1455static inline void security_inode_post_create (struct inode *dir,
1456 struct dentry *dentry,
1457 int mode)
1458{
1459 if (dentry->d_inode && unlikely (IS_PRIVATE (dentry->d_inode)))
1460 return;
1461 security_ops->inode_post_create (dir, dentry, mode);
1462}
1463
1464static inline int security_inode_link (struct dentry *old_dentry,
1465 struct inode *dir,
1466 struct dentry *new_dentry)
1467{
1468 if (unlikely (IS_PRIVATE (old_dentry->d_inode)))
1469 return 0;
1470 return security_ops->inode_link (old_dentry, dir, new_dentry);
1471}
1472
1473static inline void security_inode_post_link (struct dentry *old_dentry,
1474 struct inode *dir,
1475 struct dentry *new_dentry)
1476{
1477 if (new_dentry->d_inode && unlikely (IS_PRIVATE (new_dentry->d_inode)))
1478 return;
1479 security_ops->inode_post_link (old_dentry, dir, new_dentry);
1480}
1481
1482static inline int security_inode_unlink (struct inode *dir,
1483 struct dentry *dentry)
1484{
1485 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1486 return 0;
1487 return security_ops->inode_unlink (dir, dentry);
1488}
1489
1490static inline int security_inode_symlink (struct inode *dir,
1491 struct dentry *dentry,
1492 const char *old_name)
1493{
1494 if (unlikely (IS_PRIVATE (dir)))
1495 return 0;
1496 return security_ops->inode_symlink (dir, dentry, old_name);
1497}
1498
1499static inline void security_inode_post_symlink (struct inode *dir,
1500 struct dentry *dentry,
1501 const char *old_name)
1502{
1503 if (dentry->d_inode && unlikely (IS_PRIVATE (dentry->d_inode)))
1504 return;
1505 security_ops->inode_post_symlink (dir, dentry, old_name);
1506}
1507
1508static inline int security_inode_mkdir (struct inode *dir,
1509 struct dentry *dentry,
1510 int mode)
1511{
1512 if (unlikely (IS_PRIVATE (dir)))
1513 return 0;
1514 return security_ops->inode_mkdir (dir, dentry, mode);
1515}
1516
1517static inline void security_inode_post_mkdir (struct inode *dir,
1518 struct dentry *dentry,
1519 int mode)
1520{
1521 if (dentry->d_inode && unlikely (IS_PRIVATE (dentry->d_inode)))
1522 return;
1523 security_ops->inode_post_mkdir (dir, dentry, mode);
1524}
1525
1526static inline int security_inode_rmdir (struct inode *dir,
1527 struct dentry *dentry)
1528{
1529 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1530 return 0;
1531 return security_ops->inode_rmdir (dir, dentry);
1532}
1533
1534static inline int security_inode_mknod (struct inode *dir,
1535 struct dentry *dentry,
1536 int mode, dev_t dev)
1537{
1538 if (unlikely (IS_PRIVATE (dir)))
1539 return 0;
1540 return security_ops->inode_mknod (dir, dentry, mode, dev);
1541}
1542
1543static inline void security_inode_post_mknod (struct inode *dir,
1544 struct dentry *dentry,
1545 int mode, dev_t dev)
1546{
1547 if (dentry->d_inode && unlikely (IS_PRIVATE (dentry->d_inode)))
1548 return;
1549 security_ops->inode_post_mknod (dir, dentry, mode, dev);
1550}
1551
1552static inline int security_inode_rename (struct inode *old_dir,
1553 struct dentry *old_dentry,
1554 struct inode *new_dir,
1555 struct dentry *new_dentry)
1556{
1557 if (unlikely (IS_PRIVATE (old_dentry->d_inode) ||
1558 (new_dentry->d_inode && IS_PRIVATE (new_dentry->d_inode))))
1559 return 0;
1560 return security_ops->inode_rename (old_dir, old_dentry,
1561 new_dir, new_dentry);
1562}
1563
1564static inline void security_inode_post_rename (struct inode *old_dir,
1565 struct dentry *old_dentry,
1566 struct inode *new_dir,
1567 struct dentry *new_dentry)
1568{
1569 if (unlikely (IS_PRIVATE (old_dentry->d_inode) ||
1570 (new_dentry->d_inode && IS_PRIVATE (new_dentry->d_inode))))
1571 return;
1572 security_ops->inode_post_rename (old_dir, old_dentry,
1573 new_dir, new_dentry);
1574}
1575
1576static inline int security_inode_readlink (struct dentry *dentry)
1577{
1578 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1579 return 0;
1580 return security_ops->inode_readlink (dentry);
1581}
1582
1583static inline int security_inode_follow_link (struct dentry *dentry,
1584 struct nameidata *nd)
1585{
1586 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1587 return 0;
1588 return security_ops->inode_follow_link (dentry, nd);
1589}
1590
1591static inline int security_inode_permission (struct inode *inode, int mask,
1592 struct nameidata *nd)
1593{
1594 if (unlikely (IS_PRIVATE (inode)))
1595 return 0;
1596 return security_ops->inode_permission (inode, mask, nd);
1597}
1598
1599static inline int security_inode_setattr (struct dentry *dentry,
1600 struct iattr *attr)
1601{
1602 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1603 return 0;
1604 return security_ops->inode_setattr (dentry, attr);
1605}
1606
1607static inline int security_inode_getattr (struct vfsmount *mnt,
1608 struct dentry *dentry)
1609{
1610 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1611 return 0;
1612 return security_ops->inode_getattr (mnt, dentry);
1613}
1614
1615static inline void security_inode_delete (struct inode *inode)
1616{
1617 if (unlikely (IS_PRIVATE (inode)))
1618 return;
1619 security_ops->inode_delete (inode);
1620}
1621
1622static inline int security_inode_setxattr (struct dentry *dentry, char *name,
1623 void *value, size_t size, int flags)
1624{
1625 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1626 return 0;
1627 return security_ops->inode_setxattr (dentry, name, value, size, flags);
1628}
1629
1630static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
1631 void *value, size_t size, int flags)
1632{
1633 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1634 return;
1635 security_ops->inode_post_setxattr (dentry, name, value, size, flags);
1636}
1637
1638static inline int security_inode_getxattr (struct dentry *dentry, char *name)
1639{
1640 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1641 return 0;
1642 return security_ops->inode_getxattr (dentry, name);
1643}
1644
1645static inline int security_inode_listxattr (struct dentry *dentry)
1646{
1647 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1648 return 0;
1649 return security_ops->inode_listxattr (dentry);
1650}
1651
1652static inline int security_inode_removexattr (struct dentry *dentry, char *name)
1653{
1654 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1655 return 0;
1656 return security_ops->inode_removexattr (dentry, name);
1657}
1658
1659static inline int security_inode_getsecurity(struct inode *inode, const char *name, void *buffer, size_t size)
1660{
1661 if (unlikely (IS_PRIVATE (inode)))
1662 return 0;
1663 return security_ops->inode_getsecurity(inode, name, buffer, size);
1664}
1665
1666static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
1667{
1668 if (unlikely (IS_PRIVATE (inode)))
1669 return 0;
1670 return security_ops->inode_setsecurity(inode, name, value, size, flags);
1671}
1672
1673static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
1674{
1675 if (unlikely (IS_PRIVATE (inode)))
1676 return 0;
1677 return security_ops->inode_listsecurity(inode, buffer, buffer_size);
1678}
1679
1680static inline int security_file_permission (struct file *file, int mask)
1681{
1682 return security_ops->file_permission (file, mask);
1683}
1684
1685static inline int security_file_alloc (struct file *file)
1686{
1687 return security_ops->file_alloc_security (file);
1688}
1689
1690static inline void security_file_free (struct file *file)
1691{
1692 security_ops->file_free_security (file);
1693}
1694
1695static inline int security_file_ioctl (struct file *file, unsigned int cmd,
1696 unsigned long arg)
1697{
1698 return security_ops->file_ioctl (file, cmd, arg);
1699}
1700
1701static inline int security_file_mmap (struct file *file, unsigned long reqprot,
1702 unsigned long prot,
1703 unsigned long flags)
1704{
1705 return security_ops->file_mmap (file, reqprot, prot, flags);
1706}
1707
1708static inline int security_file_mprotect (struct vm_area_struct *vma,
1709 unsigned long reqprot,
1710 unsigned long prot)
1711{
1712 return security_ops->file_mprotect (vma, reqprot, prot);
1713}
1714
1715static inline int security_file_lock (struct file *file, unsigned int cmd)
1716{
1717 return security_ops->file_lock (file, cmd);
1718}
1719
1720static inline int security_file_fcntl (struct file *file, unsigned int cmd,
1721 unsigned long arg)
1722{
1723 return security_ops->file_fcntl (file, cmd, arg);
1724}
1725
1726static inline int security_file_set_fowner (struct file *file)
1727{
1728 return security_ops->file_set_fowner (file);
1729}
1730
1731static inline int security_file_send_sigiotask (struct task_struct *tsk,
1732 struct fown_struct *fown,
1733 int sig)
1734{
1735 return security_ops->file_send_sigiotask (tsk, fown, sig);
1736}
1737
1738static inline int security_file_receive (struct file *file)
1739{
1740 return security_ops->file_receive (file);
1741}
1742
1743static inline int security_task_create (unsigned long clone_flags)
1744{
1745 return security_ops->task_create (clone_flags);
1746}
1747
1748static inline int security_task_alloc (struct task_struct *p)
1749{
1750 return security_ops->task_alloc_security (p);
1751}
1752
1753static inline void security_task_free (struct task_struct *p)
1754{
1755 security_ops->task_free_security (p);
1756}
1757
1758static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
1759 int flags)
1760{
1761 return security_ops->task_setuid (id0, id1, id2, flags);
1762}
1763
1764static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
1765 uid_t old_suid, int flags)
1766{
1767 return security_ops->task_post_setuid (old_ruid, old_euid, old_suid, flags);
1768}
1769
1770static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
1771 int flags)
1772{
1773 return security_ops->task_setgid (id0, id1, id2, flags);
1774}
1775
1776static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
1777{
1778 return security_ops->task_setpgid (p, pgid);
1779}
1780
1781static inline int security_task_getpgid (struct task_struct *p)
1782{
1783 return security_ops->task_getpgid (p);
1784}
1785
1786static inline int security_task_getsid (struct task_struct *p)
1787{
1788 return security_ops->task_getsid (p);
1789}
1790
1791static inline int security_task_setgroups (struct group_info *group_info)
1792{
1793 return security_ops->task_setgroups (group_info);
1794}
1795
1796static inline int security_task_setnice (struct task_struct *p, int nice)
1797{
1798 return security_ops->task_setnice (p, nice);
1799}
1800
1801static inline int security_task_setrlimit (unsigned int resource,
1802 struct rlimit *new_rlim)
1803{
1804 return security_ops->task_setrlimit (resource, new_rlim);
1805}
1806
1807static inline int security_task_setscheduler (struct task_struct *p,
1808 int policy,
1809 struct sched_param *lp)
1810{
1811 return security_ops->task_setscheduler (p, policy, lp);
1812}
1813
1814static inline int security_task_getscheduler (struct task_struct *p)
1815{
1816 return security_ops->task_getscheduler (p);
1817}
1818
1819static inline int security_task_kill (struct task_struct *p,
1820 struct siginfo *info, int sig)
1821{
1822 return security_ops->task_kill (p, info, sig);
1823}
1824
1825static inline int security_task_wait (struct task_struct *p)
1826{
1827 return security_ops->task_wait (p);
1828}
1829
1830static inline int security_task_prctl (int option, unsigned long arg2,
1831 unsigned long arg3,
1832 unsigned long arg4,
1833 unsigned long arg5)
1834{
1835 return security_ops->task_prctl (option, arg2, arg3, arg4, arg5);
1836}
1837
1838static inline void security_task_reparent_to_init (struct task_struct *p)
1839{
1840 security_ops->task_reparent_to_init (p);
1841}
1842
1843static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
1844{
1845 security_ops->task_to_inode(p, inode);
1846}
1847
1848static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
1849 short flag)
1850{
1851 return security_ops->ipc_permission (ipcp, flag);
1852}
1853
1854static inline int security_msg_msg_alloc (struct msg_msg * msg)
1855{
1856 return security_ops->msg_msg_alloc_security (msg);
1857}
1858
1859static inline void security_msg_msg_free (struct msg_msg * msg)
1860{
1861 security_ops->msg_msg_free_security(msg);
1862}
1863
1864static inline int security_msg_queue_alloc (struct msg_queue *msq)
1865{
1866 return security_ops->msg_queue_alloc_security (msq);
1867}
1868
1869static inline void security_msg_queue_free (struct msg_queue *msq)
1870{
1871 security_ops->msg_queue_free_security (msq);
1872}
1873
1874static inline int security_msg_queue_associate (struct msg_queue * msq,
1875 int msqflg)
1876{
1877 return security_ops->msg_queue_associate (msq, msqflg);
1878}
1879
1880static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
1881{
1882 return security_ops->msg_queue_msgctl (msq, cmd);
1883}
1884
1885static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
1886 struct msg_msg * msg, int msqflg)
1887{
1888 return security_ops->msg_queue_msgsnd (msq, msg, msqflg);
1889}
1890
1891static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
1892 struct msg_msg * msg,
1893 struct task_struct * target,
1894 long type, int mode)
1895{
1896 return security_ops->msg_queue_msgrcv (msq, msg, target, type, mode);
1897}
1898
1899static inline int security_shm_alloc (struct shmid_kernel *shp)
1900{
1901 return security_ops->shm_alloc_security (shp);
1902}
1903
1904static inline void security_shm_free (struct shmid_kernel *shp)
1905{
1906 security_ops->shm_free_security (shp);
1907}
1908
1909static inline int security_shm_associate (struct shmid_kernel * shp,
1910 int shmflg)
1911{
1912 return security_ops->shm_associate(shp, shmflg);
1913}
1914
1915static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
1916{
1917 return security_ops->shm_shmctl (shp, cmd);
1918}
1919
1920static inline int security_shm_shmat (struct shmid_kernel * shp,
1921 char __user *shmaddr, int shmflg)
1922{
1923 return security_ops->shm_shmat(shp, shmaddr, shmflg);
1924}
1925
1926static inline int security_sem_alloc (struct sem_array *sma)
1927{
1928 return security_ops->sem_alloc_security (sma);
1929}
1930
1931static inline void security_sem_free (struct sem_array *sma)
1932{
1933 security_ops->sem_free_security (sma);
1934}
1935
1936static inline int security_sem_associate (struct sem_array * sma, int semflg)
1937{
1938 return security_ops->sem_associate (sma, semflg);
1939}
1940
1941static inline int security_sem_semctl (struct sem_array * sma, int cmd)
1942{
1943 return security_ops->sem_semctl(sma, cmd);
1944}
1945
1946static inline int security_sem_semop (struct sem_array * sma,
1947 struct sembuf * sops, unsigned nsops,
1948 int alter)
1949{
1950 return security_ops->sem_semop(sma, sops, nsops, alter);
1951}
1952
1953static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
1954{
1955 if (unlikely (inode && IS_PRIVATE (inode)))
1956 return;
1957 security_ops->d_instantiate (dentry, inode);
1958}
1959
1960static inline int security_getprocattr(struct task_struct *p, char *name, void *value, size_t size)
1961{
1962 return security_ops->getprocattr(p, name, value, size);
1963}
1964
1965static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
1966{
1967 return security_ops->setprocattr(p, name, value, size);
1968}
1969
1970static inline int security_netlink_send(struct sock *sk, struct sk_buff * skb)
1971{
1972 return security_ops->netlink_send(sk, skb);
1973}
1974
1975static inline int security_netlink_recv(struct sk_buff * skb)
1976{
1977 return security_ops->netlink_recv(skb);
1978}
1979
1980/* prototypes */
1981extern int security_init (void);
1982extern int register_security (struct security_operations *ops);
1983extern int unregister_security (struct security_operations *ops);
1984extern int mod_reg_security (const char *name, struct security_operations *ops);
1985extern int mod_unreg_security (const char *name, struct security_operations *ops);
1986
1987
1988#else /* CONFIG_SECURITY */
1989
1990/*
1991 * This is the default capabilities functionality. Most of these functions
1992 * are just stubbed out, but a few must call the proper capable code.
1993 */
1994
1995static inline int security_init(void)
1996{
1997 return 0;
1998}
1999
2000static inline int security_ptrace (struct task_struct *parent, struct task_struct * child)
2001{
2002 return cap_ptrace (parent, child);
2003}
2004
2005static inline int security_capget (struct task_struct *target,
2006 kernel_cap_t *effective,
2007 kernel_cap_t *inheritable,
2008 kernel_cap_t *permitted)
2009{
2010 return cap_capget (target, effective, inheritable, permitted);
2011}
2012
2013static inline int security_capset_check (struct task_struct *target,
2014 kernel_cap_t *effective,
2015 kernel_cap_t *inheritable,
2016 kernel_cap_t *permitted)
2017{
2018 return cap_capset_check (target, effective, inheritable, permitted);
2019}
2020
2021static inline void security_capset_set (struct task_struct *target,
2022 kernel_cap_t *effective,
2023 kernel_cap_t *inheritable,
2024 kernel_cap_t *permitted)
2025{
2026 cap_capset_set (target, effective, inheritable, permitted);
2027}
2028
2029static inline int security_acct (struct file *file)
2030{
2031 return 0;
2032}
2033
2034static inline int security_sysctl(struct ctl_table *table, int op)
2035{
2036 return 0;
2037}
2038
2039static inline int security_quotactl (int cmds, int type, int id,
2040 struct super_block * sb)
2041{
2042 return 0;
2043}
2044
2045static inline int security_quota_on (struct dentry * dentry)
2046{
2047 return 0;
2048}
2049
2050static inline int security_syslog(int type)
2051{
2052 return cap_syslog(type);
2053}
2054
2055static inline int security_settime(struct timespec *ts, struct timezone *tz)
2056{
2057 return cap_settime(ts, tz);
2058}
2059
2060static inline int security_vm_enough_memory(long pages)
2061{
2062 return cap_vm_enough_memory(pages);
2063}
2064
2065static inline int security_bprm_alloc (struct linux_binprm *bprm)
2066{
2067 return 0;
2068}
2069
2070static inline void security_bprm_free (struct linux_binprm *bprm)
2071{ }
2072
2073static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
2074{
2075 cap_bprm_apply_creds (bprm, unsafe);
2076}
2077
2078static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
2079{
2080 return;
2081}
2082
2083static inline int security_bprm_set (struct linux_binprm *bprm)
2084{
2085 return cap_bprm_set_security (bprm);
2086}
2087
2088static inline int security_bprm_check (struct linux_binprm *bprm)
2089{
2090 return 0;
2091}
2092
2093static inline int security_bprm_secureexec (struct linux_binprm *bprm)
2094{
2095 return cap_bprm_secureexec(bprm);
2096}
2097
2098static inline int security_sb_alloc (struct super_block *sb)
2099{
2100 return 0;
2101}
2102
2103static inline void security_sb_free (struct super_block *sb)
2104{ }
2105
2106static inline int security_sb_copy_data (struct file_system_type *type,
2107 void *orig, void *copy)
2108{
2109 return 0;
2110}
2111
2112static inline int security_sb_kern_mount (struct super_block *sb, void *data)
2113{
2114 return 0;
2115}
2116
2117static inline int security_sb_statfs (struct super_block *sb)
2118{
2119 return 0;
2120}
2121
2122static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
2123 char *type, unsigned long flags,
2124 void *data)
2125{
2126 return 0;
2127}
2128
2129static inline int security_sb_check_sb (struct vfsmount *mnt,
2130 struct nameidata *nd)
2131{
2132 return 0;
2133}
2134
2135static inline int security_sb_umount (struct vfsmount *mnt, int flags)
2136{
2137 return 0;
2138}
2139
2140static inline void security_sb_umount_close (struct vfsmount *mnt)
2141{ }
2142
2143static inline void security_sb_umount_busy (struct vfsmount *mnt)
2144{ }
2145
2146static inline void security_sb_post_remount (struct vfsmount *mnt,
2147 unsigned long flags, void *data)
2148{ }
2149
2150static inline void security_sb_post_mountroot (void)
2151{ }
2152
2153static inline void security_sb_post_addmount (struct vfsmount *mnt,
2154 struct nameidata *mountpoint_nd)
2155{ }
2156
2157static inline int security_sb_pivotroot (struct nameidata *old_nd,
2158 struct nameidata *new_nd)
2159{
2160 return 0;
2161}
2162
2163static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
2164 struct nameidata *new_nd)
2165{ }
2166
2167static inline int security_inode_alloc (struct inode *inode)
2168{
2169 return 0;
2170}
2171
2172static inline void security_inode_free (struct inode *inode)
2173{ }
2174
2175static inline int security_inode_create (struct inode *dir,
2176 struct dentry *dentry,
2177 int mode)
2178{
2179 return 0;
2180}
2181
2182static inline void security_inode_post_create (struct inode *dir,
2183 struct dentry *dentry,
2184 int mode)
2185{ }
2186
2187static inline int security_inode_link (struct dentry *old_dentry,
2188 struct inode *dir,
2189 struct dentry *new_dentry)
2190{
2191 return 0;
2192}
2193
2194static inline void security_inode_post_link (struct dentry *old_dentry,
2195 struct inode *dir,
2196 struct dentry *new_dentry)
2197{ }
2198
2199static inline int security_inode_unlink (struct inode *dir,
2200 struct dentry *dentry)
2201{
2202 return 0;
2203}
2204
2205static inline int security_inode_symlink (struct inode *dir,
2206 struct dentry *dentry,
2207 const char *old_name)
2208{
2209 return 0;
2210}
2211
2212static inline void security_inode_post_symlink (struct inode *dir,
2213 struct dentry *dentry,
2214 const char *old_name)
2215{ }
2216
2217static inline int security_inode_mkdir (struct inode *dir,
2218 struct dentry *dentry,
2219 int mode)
2220{
2221 return 0;
2222}
2223
2224static inline void security_inode_post_mkdir (struct inode *dir,
2225 struct dentry *dentry,
2226 int mode)
2227{ }
2228
2229static inline int security_inode_rmdir (struct inode *dir,
2230 struct dentry *dentry)
2231{
2232 return 0;
2233}
2234
2235static inline int security_inode_mknod (struct inode *dir,
2236 struct dentry *dentry,
2237 int mode, dev_t dev)
2238{
2239 return 0;
2240}
2241
2242static inline void security_inode_post_mknod (struct inode *dir,
2243 struct dentry *dentry,
2244 int mode, dev_t dev)
2245{ }
2246
2247static inline int security_inode_rename (struct inode *old_dir,
2248 struct dentry *old_dentry,
2249 struct inode *new_dir,
2250 struct dentry *new_dentry)
2251{
2252 return 0;
2253}
2254
2255static inline void security_inode_post_rename (struct inode *old_dir,
2256 struct dentry *old_dentry,
2257 struct inode *new_dir,
2258 struct dentry *new_dentry)
2259{ }
2260
2261static inline int security_inode_readlink (struct dentry *dentry)
2262{
2263 return 0;
2264}
2265
2266static inline int security_inode_follow_link (struct dentry *dentry,
2267 struct nameidata *nd)
2268{
2269 return 0;
2270}
2271
2272static inline int security_inode_permission (struct inode *inode, int mask,
2273 struct nameidata *nd)
2274{
2275 return 0;
2276}
2277
2278static inline int security_inode_setattr (struct dentry *dentry,
2279 struct iattr *attr)
2280{
2281 return 0;
2282}
2283
2284static inline int security_inode_getattr (struct vfsmount *mnt,
2285 struct dentry *dentry)
2286{
2287 return 0;
2288}
2289
2290static inline void security_inode_delete (struct inode *inode)
2291{ }
2292
2293static inline int security_inode_setxattr (struct dentry *dentry, char *name,
2294 void *value, size_t size, int flags)
2295{
2296 return cap_inode_setxattr(dentry, name, value, size, flags);
2297}
2298
2299static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
2300 void *value, size_t size, int flags)
2301{ }
2302
2303static inline int security_inode_getxattr (struct dentry *dentry, char *name)
2304{
2305 return 0;
2306}
2307
2308static inline int security_inode_listxattr (struct dentry *dentry)
2309{
2310 return 0;
2311}
2312
2313static inline int security_inode_removexattr (struct dentry *dentry, char *name)
2314{
2315 return cap_inode_removexattr(dentry, name);
2316}
2317
2318static inline int security_inode_getsecurity(struct inode *inode, const char *name, void *buffer, size_t size)
2319{
2320 return -EOPNOTSUPP;
2321}
2322
2323static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
2324{
2325 return -EOPNOTSUPP;
2326}
2327
2328static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
2329{
2330 return 0;
2331}
2332
2333static inline int security_file_permission (struct file *file, int mask)
2334{
2335 return 0;
2336}
2337
2338static inline int security_file_alloc (struct file *file)
2339{
2340 return 0;
2341}
2342
2343static inline void security_file_free (struct file *file)
2344{ }
2345
2346static inline int security_file_ioctl (struct file *file, unsigned int cmd,
2347 unsigned long arg)
2348{
2349 return 0;
2350}
2351
2352static inline int security_file_mmap (struct file *file, unsigned long reqprot,
2353 unsigned long prot,
2354 unsigned long flags)
2355{
2356 return 0;
2357}
2358
2359static inline int security_file_mprotect (struct vm_area_struct *vma,
2360 unsigned long reqprot,
2361 unsigned long prot)
2362{
2363 return 0;
2364}
2365
2366static inline int security_file_lock (struct file *file, unsigned int cmd)
2367{
2368 return 0;
2369}
2370
2371static inline int security_file_fcntl (struct file *file, unsigned int cmd,
2372 unsigned long arg)
2373{
2374 return 0;
2375}
2376
2377static inline int security_file_set_fowner (struct file *file)
2378{
2379 return 0;
2380}
2381
2382static inline int security_file_send_sigiotask (struct task_struct *tsk,
2383 struct fown_struct *fown,
2384 int sig)
2385{
2386 return 0;
2387}
2388
2389static inline int security_file_receive (struct file *file)
2390{
2391 return 0;
2392}
2393
2394static inline int security_task_create (unsigned long clone_flags)
2395{
2396 return 0;
2397}
2398
2399static inline int security_task_alloc (struct task_struct *p)
2400{
2401 return 0;
2402}
2403
2404static inline void security_task_free (struct task_struct *p)
2405{ }
2406
2407static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
2408 int flags)
2409{
2410 return 0;
2411}
2412
2413static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
2414 uid_t old_suid, int flags)
2415{
2416 return cap_task_post_setuid (old_ruid, old_euid, old_suid, flags);
2417}
2418
2419static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
2420 int flags)
2421{
2422 return 0;
2423}
2424
2425static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
2426{
2427 return 0;
2428}
2429
2430static inline int security_task_getpgid (struct task_struct *p)
2431{
2432 return 0;
2433}
2434
2435static inline int security_task_getsid (struct task_struct *p)
2436{
2437 return 0;
2438}
2439
2440static inline int security_task_setgroups (struct group_info *group_info)
2441{
2442 return 0;
2443}
2444
2445static inline int security_task_setnice (struct task_struct *p, int nice)
2446{
2447 return 0;
2448}
2449
2450static inline int security_task_setrlimit (unsigned int resource,
2451 struct rlimit *new_rlim)
2452{
2453 return 0;
2454}
2455
2456static inline int security_task_setscheduler (struct task_struct *p,
2457 int policy,
2458 struct sched_param *lp)
2459{
2460 return 0;
2461}
2462
2463static inline int security_task_getscheduler (struct task_struct *p)
2464{
2465 return 0;
2466}
2467
2468static inline int security_task_kill (struct task_struct *p,
2469 struct siginfo *info, int sig)
2470{
2471 return 0;
2472}
2473
2474static inline int security_task_wait (struct task_struct *p)
2475{
2476 return 0;
2477}
2478
2479static inline int security_task_prctl (int option, unsigned long arg2,
2480 unsigned long arg3,
2481 unsigned long arg4,
2482 unsigned long arg5)
2483{
2484 return 0;
2485}
2486
2487static inline void security_task_reparent_to_init (struct task_struct *p)
2488{
2489 cap_task_reparent_to_init (p);
2490}
2491
2492static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
2493{ }
2494
2495static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
2496 short flag)
2497{
2498 return 0;
2499}
2500
2501static inline int security_msg_msg_alloc (struct msg_msg * msg)
2502{
2503 return 0;
2504}
2505
2506static inline void security_msg_msg_free (struct msg_msg * msg)
2507{ }
2508
2509static inline int security_msg_queue_alloc (struct msg_queue *msq)
2510{
2511 return 0;
2512}
2513
2514static inline void security_msg_queue_free (struct msg_queue *msq)
2515{ }
2516
2517static inline int security_msg_queue_associate (struct msg_queue * msq,
2518 int msqflg)
2519{
2520 return 0;
2521}
2522
2523static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
2524{
2525 return 0;
2526}
2527
2528static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
2529 struct msg_msg * msg, int msqflg)
2530{
2531 return 0;
2532}
2533
2534static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
2535 struct msg_msg * msg,
2536 struct task_struct * target,
2537 long type, int mode)
2538{
2539 return 0;
2540}
2541
2542static inline int security_shm_alloc (struct shmid_kernel *shp)
2543{
2544 return 0;
2545}
2546
2547static inline void security_shm_free (struct shmid_kernel *shp)
2548{ }
2549
2550static inline int security_shm_associate (struct shmid_kernel * shp,
2551 int shmflg)
2552{
2553 return 0;
2554}
2555
2556static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
2557{
2558 return 0;
2559}
2560
2561static inline int security_shm_shmat (struct shmid_kernel * shp,
2562 char __user *shmaddr, int shmflg)
2563{
2564 return 0;
2565}
2566
2567static inline int security_sem_alloc (struct sem_array *sma)
2568{
2569 return 0;
2570}
2571
2572static inline void security_sem_free (struct sem_array *sma)
2573{ }
2574
2575static inline int security_sem_associate (struct sem_array * sma, int semflg)
2576{
2577 return 0;
2578}
2579
2580static inline int security_sem_semctl (struct sem_array * sma, int cmd)
2581{
2582 return 0;
2583}
2584
2585static inline int security_sem_semop (struct sem_array * sma,
2586 struct sembuf * sops, unsigned nsops,
2587 int alter)
2588{
2589 return 0;
2590}
2591
2592static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
2593{ }
2594
2595static inline int security_getprocattr(struct task_struct *p, char *name, void *value, size_t size)
2596{
2597 return -EINVAL;
2598}
2599
2600static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2601{
2602 return -EINVAL;
2603}
2604
2605static inline int security_netlink_send (struct sock *sk, struct sk_buff *skb)
2606{
2607 return cap_netlink_send (sk, skb);
2608}
2609
2610static inline int security_netlink_recv (struct sk_buff *skb)
2611{
2612 return cap_netlink_recv (skb);
2613}
2614
2615#endif /* CONFIG_SECURITY */
2616
2617#ifdef CONFIG_SECURITY_NETWORK
2618static inline int security_unix_stream_connect(struct socket * sock,
2619 struct socket * other,
2620 struct sock * newsk)
2621{
2622 return security_ops->unix_stream_connect(sock, other, newsk);
2623}
2624
2625
2626static inline int security_unix_may_send(struct socket * sock,
2627 struct socket * other)
2628{
2629 return security_ops->unix_may_send(sock, other);
2630}
2631
2632static inline int security_socket_create (int family, int type,
2633 int protocol, int kern)
2634{
2635 return security_ops->socket_create(family, type, protocol, kern);
2636}
2637
2638static inline void security_socket_post_create(struct socket * sock,
2639 int family,
2640 int type,
2641 int protocol, int kern)
2642{
2643 security_ops->socket_post_create(sock, family, type,
2644 protocol, kern);
2645}
2646
2647static inline int security_socket_bind(struct socket * sock,
2648 struct sockaddr * address,
2649 int addrlen)
2650{
2651 return security_ops->socket_bind(sock, address, addrlen);
2652}
2653
2654static inline int security_socket_connect(struct socket * sock,
2655 struct sockaddr * address,
2656 int addrlen)
2657{
2658 return security_ops->socket_connect(sock, address, addrlen);
2659}
2660
2661static inline int security_socket_listen(struct socket * sock, int backlog)
2662{
2663 return security_ops->socket_listen(sock, backlog);
2664}
2665
2666static inline int security_socket_accept(struct socket * sock,
2667 struct socket * newsock)
2668{
2669 return security_ops->socket_accept(sock, newsock);
2670}
2671
2672static inline void security_socket_post_accept(struct socket * sock,
2673 struct socket * newsock)
2674{
2675 security_ops->socket_post_accept(sock, newsock);
2676}
2677
2678static inline int security_socket_sendmsg(struct socket * sock,
2679 struct msghdr * msg, int size)
2680{
2681 return security_ops->socket_sendmsg(sock, msg, size);
2682}
2683
2684static inline int security_socket_recvmsg(struct socket * sock,
2685 struct msghdr * msg, int size,
2686 int flags)
2687{
2688 return security_ops->socket_recvmsg(sock, msg, size, flags);
2689}
2690
2691static inline int security_socket_getsockname(struct socket * sock)
2692{
2693 return security_ops->socket_getsockname(sock);
2694}
2695
2696static inline int security_socket_getpeername(struct socket * sock)
2697{
2698 return security_ops->socket_getpeername(sock);
2699}
2700
2701static inline int security_socket_getsockopt(struct socket * sock,
2702 int level, int optname)
2703{
2704 return security_ops->socket_getsockopt(sock, level, optname);
2705}
2706
2707static inline int security_socket_setsockopt(struct socket * sock,
2708 int level, int optname)
2709{
2710 return security_ops->socket_setsockopt(sock, level, optname);
2711}
2712
2713static inline int security_socket_shutdown(struct socket * sock, int how)
2714{
2715 return security_ops->socket_shutdown(sock, how);
2716}
2717
2718static inline int security_sock_rcv_skb (struct sock * sk,
2719 struct sk_buff * skb)
2720{
2721 return security_ops->socket_sock_rcv_skb (sk, skb);
2722}
2723
2724static inline int security_socket_getpeersec(struct socket *sock, char __user *optval,
2725 int __user *optlen, unsigned len)
2726{
2727 return security_ops->socket_getpeersec(sock, optval, optlen, len);
2728}
2729
2730static inline int security_sk_alloc(struct sock *sk, int family, int priority)
2731{
2732 return security_ops->sk_alloc_security(sk, family, priority);
2733}
2734
2735static inline void security_sk_free(struct sock *sk)
2736{
2737 return security_ops->sk_free_security(sk);
2738}
2739#else /* CONFIG_SECURITY_NETWORK */
2740static inline int security_unix_stream_connect(struct socket * sock,
2741 struct socket * other,
2742 struct sock * newsk)
2743{
2744 return 0;
2745}
2746
2747static inline int security_unix_may_send(struct socket * sock,
2748 struct socket * other)
2749{
2750 return 0;
2751}
2752
2753static inline int security_socket_create (int family, int type,
2754 int protocol, int kern)
2755{
2756 return 0;
2757}
2758
2759static inline void security_socket_post_create(struct socket * sock,
2760 int family,
2761 int type,
2762 int protocol, int kern)
2763{
2764}
2765
2766static inline int security_socket_bind(struct socket * sock,
2767 struct sockaddr * address,
2768 int addrlen)
2769{
2770 return 0;
2771}
2772
2773static inline int security_socket_connect(struct socket * sock,
2774 struct sockaddr * address,
2775 int addrlen)
2776{
2777 return 0;
2778}
2779
2780static inline int security_socket_listen(struct socket * sock, int backlog)
2781{
2782 return 0;
2783}
2784
2785static inline int security_socket_accept(struct socket * sock,
2786 struct socket * newsock)
2787{
2788 return 0;
2789}
2790
2791static inline void security_socket_post_accept(struct socket * sock,
2792 struct socket * newsock)
2793{
2794}
2795
2796static inline int security_socket_sendmsg(struct socket * sock,
2797 struct msghdr * msg, int size)
2798{
2799 return 0;
2800}
2801
2802static inline int security_socket_recvmsg(struct socket * sock,
2803 struct msghdr * msg, int size,
2804 int flags)
2805{
2806 return 0;
2807}
2808
2809static inline int security_socket_getsockname(struct socket * sock)
2810{
2811 return 0;
2812}
2813
2814static inline int security_socket_getpeername(struct socket * sock)
2815{
2816 return 0;
2817}
2818
2819static inline int security_socket_getsockopt(struct socket * sock,
2820 int level, int optname)
2821{
2822 return 0;
2823}
2824
2825static inline int security_socket_setsockopt(struct socket * sock,
2826 int level, int optname)
2827{
2828 return 0;
2829}
2830
2831static inline int security_socket_shutdown(struct socket * sock, int how)
2832{
2833 return 0;
2834}
2835static inline int security_sock_rcv_skb (struct sock * sk,
2836 struct sk_buff * skb)
2837{
2838 return 0;
2839}
2840
2841static inline int security_socket_getpeersec(struct socket *sock, char __user *optval,
2842 int __user *optlen, unsigned len)
2843{
2844 return -ENOPROTOOPT;
2845}
2846
2847static inline int security_sk_alloc(struct sock *sk, int family, int priority)
2848{
2849 return 0;
2850}
2851
2852static inline void security_sk_free(struct sock *sk)
2853{
2854}
2855#endif /* CONFIG_SECURITY_NETWORK */
2856
2857#endif /* ! __LINUX_SECURITY_H */
2858
diff --git a/include/linux/selection.h b/include/linux/selection.h
new file mode 100644
index 000000000000..ed3408b400f1
--- /dev/null
+++ b/include/linux/selection.h
@@ -0,0 +1,40 @@
1/*
2 * selection.h
3 *
4 * Interface between console.c, tty_io.c, vt.c, vc_screen.c and selection.c
5 */
6
7#ifndef _LINUX_SELECTION_H_
8#define _LINUX_SELECTION_H_
9
10#include <linux/tiocl.h>
11#include <linux/vt_buffer.h>
12
13extern struct vc_data *sel_cons;
14
15extern void clear_selection(void);
16extern int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *tty);
17extern int paste_selection(struct tty_struct *tty);
18extern int sel_loadlut(char __user *p);
19extern int mouse_reporting(void);
20extern void mouse_report(struct tty_struct * tty, int butt, int mrx, int mry);
21
22extern int console_blanked;
23
24extern unsigned char color_table[];
25extern int default_red[];
26extern int default_grn[];
27extern int default_blu[];
28
29extern unsigned short *screen_pos(struct vc_data *vc, int w_offset, int viewed);
30extern u16 screen_glyph(struct vc_data *vc, int offset);
31extern void complement_pos(struct vc_data *vc, int offset);
32extern void invert_screen(struct vc_data *vc, int offset, int count, int shift);
33
34extern void getconsxy(struct vc_data *vc, unsigned char *p);
35extern void putconsxy(struct vc_data *vc, unsigned char *p);
36
37extern u16 vcs_scr_readw(struct vc_data *vc, const u16 *org);
38extern void vcs_scr_writew(struct vc_data *vc, u16 val, u16 *org);
39
40#endif
diff --git a/include/linux/selinux_netlink.h b/include/linux/selinux_netlink.h
new file mode 100644
index 000000000000..957e6ebca4e6
--- /dev/null
+++ b/include/linux/selinux_netlink.h
@@ -0,0 +1,37 @@
1/*
2 * Netlink event notifications for SELinux.
3 *
4 * Author: James Morris <jmorris@redhat.com>
5 *
6 * Copyright (C) 2004 Red Hat, Inc., James Morris <jmorris@redhat.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 version 2,
10 * as published by the Free Software Foundation.
11 */
12#ifndef _LINUX_SELINUX_NETLINK_H
13#define _LINUX_SELINUX_NETLINK_H
14
15/* Message types. */
16#define SELNL_MSG_BASE 0x10
17enum {
18 SELNL_MSG_SETENFORCE = SELNL_MSG_BASE,
19 SELNL_MSG_POLICYLOAD,
20 SELNL_MSG_MAX
21};
22
23/* Multicast groups */
24#define SELNL_GRP_NONE 0x00000000
25#define SELNL_GRP_AVC 0x00000001 /* AVC notifications */
26#define SELNL_GRP_ALL 0xffffffff
27
28/* Message structures */
29struct selnl_msg_setenforce {
30 int32_t val;
31};
32
33struct selnl_msg_policyload {
34 u_int32_t seqno;
35};
36
37#endif /* _LINUX_SELINUX_NETLINK_H */
diff --git a/include/linux/sem.h b/include/linux/sem.h
new file mode 100644
index 000000000000..2d8516be9fd7
--- /dev/null
+++ b/include/linux/sem.h
@@ -0,0 +1,157 @@
1#ifndef _LINUX_SEM_H
2#define _LINUX_SEM_H
3
4#include <linux/ipc.h>
5#include <asm/atomic.h>
6
7/* semop flags */
8#define SEM_UNDO 0x1000 /* undo the operation on exit */
9
10/* semctl Command Definitions. */
11#define GETPID 11 /* get sempid */
12#define GETVAL 12 /* get semval */
13#define GETALL 13 /* get all semval's */
14#define GETNCNT 14 /* get semncnt */
15#define GETZCNT 15 /* get semzcnt */
16#define SETVAL 16 /* set semval */
17#define SETALL 17 /* set all semval's */
18
19/* ipcs ctl cmds */
20#define SEM_STAT 18
21#define SEM_INFO 19
22
23/* Obsolete, used only for backwards compatibility and libc5 compiles */
24struct semid_ds {
25 struct ipc_perm sem_perm; /* permissions .. see ipc.h */
26 __kernel_time_t sem_otime; /* last semop time */
27 __kernel_time_t sem_ctime; /* last change time */
28 struct sem *sem_base; /* ptr to first semaphore in array */
29 struct sem_queue *sem_pending; /* pending operations to be processed */
30 struct sem_queue **sem_pending_last; /* last pending operation */
31 struct sem_undo *undo; /* undo requests on this array */
32 unsigned short sem_nsems; /* no. of semaphores in array */
33};
34
35/* Include the definition of semid64_ds */
36#include <asm/sembuf.h>
37
38/* semop system calls takes an array of these. */
39struct sembuf {
40 unsigned short sem_num; /* semaphore index in array */
41 short sem_op; /* semaphore operation */
42 short sem_flg; /* operation flags */
43};
44
45/* arg for semctl system calls. */
46union semun {
47 int val; /* value for SETVAL */
48 struct semid_ds __user *buf; /* buffer for IPC_STAT & IPC_SET */
49 unsigned short __user *array; /* array for GETALL & SETALL */
50 struct seminfo __user *__buf; /* buffer for IPC_INFO */
51 void __user *__pad;
52};
53
54struct seminfo {
55 int semmap;
56 int semmni;
57 int semmns;
58 int semmnu;
59 int semmsl;
60 int semopm;
61 int semume;
62 int semusz;
63 int semvmx;
64 int semaem;
65};
66
67#define SEMMNI 128 /* <= IPCMNI max # of semaphore identifiers */
68#define SEMMSL 250 /* <= 8 000 max num of semaphores per id */
69#define SEMMNS (SEMMNI*SEMMSL) /* <= INT_MAX max # of semaphores in system */
70#define SEMOPM 32 /* <= 1 000 max num of ops per semop call */
71#define SEMVMX 32767 /* <= 32767 semaphore maximum value */
72#define SEMAEM SEMVMX /* adjust on exit max value */
73
74/* unused */
75#define SEMUME SEMOPM /* max num of undo entries per process */
76#define SEMMNU SEMMNS /* num of undo structures system wide */
77#define SEMMAP SEMMNS /* # of entries in semaphore map */
78#define SEMUSZ 20 /* sizeof struct sem_undo */
79
80#ifdef __KERNEL__
81
82/* One semaphore structure for each semaphore in the system. */
83struct sem {
84 int semval; /* current value */
85 int sempid; /* pid of last operation */
86};
87
88/* One sem_array data structure for each set of semaphores in the system. */
89struct sem_array {
90 struct kern_ipc_perm sem_perm; /* permissions .. see ipc.h */
91 time_t sem_otime; /* last semop time */
92 time_t sem_ctime; /* last change time */
93 struct sem *sem_base; /* ptr to first semaphore in array */
94 struct sem_queue *sem_pending; /* pending operations to be processed */
95 struct sem_queue **sem_pending_last; /* last pending operation */
96 struct sem_undo *undo; /* undo requests on this array */
97 unsigned long sem_nsems; /* no. of semaphores in array */
98};
99
100/* One queue for each sleeping process in the system. */
101struct sem_queue {
102 struct sem_queue * next; /* next entry in the queue */
103 struct sem_queue ** prev; /* previous entry in the queue, *(q->prev) == q */
104 struct task_struct* sleeper; /* this process */
105 struct sem_undo * undo; /* undo structure */
106 int pid; /* process id of requesting process */
107 int status; /* completion status of operation */
108 struct sem_array * sma; /* semaphore array for operations */
109 int id; /* internal sem id */
110 struct sembuf * sops; /* array of pending operations */
111 int nsops; /* number of operations */
112 int alter; /* does the operation alter the array? */
113};
114
115/* Each task has a list of undo requests. They are executed automatically
116 * when the process exits.
117 */
118struct sem_undo {
119 struct sem_undo * proc_next; /* next entry on this process */
120 struct sem_undo * id_next; /* next entry on this semaphore set */
121 int semid; /* semaphore set identifier */
122 short * semadj; /* array of adjustments, one per semaphore */
123};
124
125/* sem_undo_list controls shared access to the list of sem_undo structures
126 * that may be shared among all a CLONE_SYSVSEM task group.
127 */
128struct sem_undo_list {
129 atomic_t refcnt;
130 spinlock_t lock;
131 struct sem_undo *proc_list;
132};
133
134struct sysv_sem {
135 struct sem_undo_list *undo_list;
136};
137
138#ifdef CONFIG_SYSVIPC
139
140extern int copy_semundo(unsigned long clone_flags, struct task_struct *tsk);
141extern void exit_sem(struct task_struct *tsk);
142
143#else
144static inline int copy_semundo(unsigned long clone_flags, struct task_struct *tsk)
145{
146 return 0;
147}
148
149static inline void exit_sem(struct task_struct *tsk)
150{
151 return;
152}
153#endif
154
155#endif /* __KERNEL__ */
156
157#endif /* _LINUX_SEM_H */
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
new file mode 100644
index 000000000000..850a974ee505
--- /dev/null
+++ b/include/linux/seq_file.h
@@ -0,0 +1,54 @@
1#ifndef _LINUX_SEQ_FILE_H
2#define _LINUX_SEQ_FILE_H
3#ifdef __KERNEL__
4
5#include <linux/types.h>
6#include <linux/string.h>
7#include <asm/semaphore.h>
8
9struct seq_operations;
10struct file;
11struct vfsmount;
12struct dentry;
13struct inode;
14
15struct seq_file {
16 char *buf;
17 size_t size;
18 size_t from;
19 size_t count;
20 loff_t index;
21 loff_t version;
22 struct semaphore sem;
23 struct seq_operations *op;
24 void *private;
25};
26
27struct seq_operations {
28 void * (*start) (struct seq_file *m, loff_t *pos);
29 void (*stop) (struct seq_file *m, void *v);
30 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
31 int (*show) (struct seq_file *m, void *v);
32};
33
34int seq_open(struct file *, struct seq_operations *);
35ssize_t seq_read(struct file *, char __user *, size_t, loff_t *);
36loff_t seq_lseek(struct file *, loff_t, int);
37int seq_release(struct inode *, struct file *);
38int seq_escape(struct seq_file *, const char *, const char *);
39int seq_putc(struct seq_file *m, char c);
40int seq_puts(struct seq_file *m, const char *s);
41
42int seq_printf(struct seq_file *, const char *, ...)
43 __attribute__ ((format (printf,2,3)));
44
45int seq_path(struct seq_file *, struct vfsmount *, struct dentry *, char *);
46
47int single_open(struct file *, int (*)(struct seq_file *, void *), void *);
48int single_release(struct inode *, struct file *);
49int seq_release_private(struct inode *, struct file *);
50
51#define SEQ_START_TOKEN ((void *)1)
52
53#endif
54#endif
diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h
new file mode 100644
index 000000000000..fca9b0fb5b4e
--- /dev/null
+++ b/include/linux/seqlock.h
@@ -0,0 +1,175 @@
1#ifndef __LINUX_SEQLOCK_H
2#define __LINUX_SEQLOCK_H
3/*
4 * Reader/writer consistent mechanism without starving writers. This type of
5 * lock for data where the reader wants a consitent set of information
6 * and is willing to retry if the information changes. Readers never
7 * block but they may have to retry if a writer is in
8 * progress. Writers do not wait for readers.
9 *
10 * This is not as cache friendly as brlock. Also, this will not work
11 * for data that contains pointers, because any writer could
12 * invalidate a pointer that a reader was following.
13 *
14 * Expected reader usage:
15 * do {
16 * seq = read_seqbegin(&foo);
17 * ...
18 * } while (read_seqretry(&foo, seq));
19 *
20 *
21 * On non-SMP the spin locks disappear but the writer still needs
22 * to increment the sequence variables because an interrupt routine could
23 * change the state of the data.
24 *
25 * Based on x86_64 vsyscall gettimeofday
26 * by Keith Owens and Andrea Arcangeli
27 */
28
29#include <linux/config.h>
30#include <linux/spinlock.h>
31#include <linux/preempt.h>
32
33typedef struct {
34 unsigned sequence;
35 spinlock_t lock;
36} seqlock_t;
37
38/*
39 * These macros triggered gcc-3.x compile-time problems. We think these are
40 * OK now. Be cautious.
41 */
42#define SEQLOCK_UNLOCKED { 0, SPIN_LOCK_UNLOCKED }
43#define seqlock_init(x) do { *(x) = (seqlock_t) SEQLOCK_UNLOCKED; } while (0)
44
45
46/* Lock out other writers and update the count.
47 * Acts like a normal spin_lock/unlock.
48 * Don't need preempt_disable() because that is in the spin_lock already.
49 */
50static inline void write_seqlock(seqlock_t *sl)
51{
52 spin_lock(&sl->lock);
53 ++sl->sequence;
54 smp_wmb();
55}
56
57static inline void write_sequnlock(seqlock_t *sl)
58{
59 smp_wmb();
60 sl->sequence++;
61 spin_unlock(&sl->lock);
62}
63
64static inline int write_tryseqlock(seqlock_t *sl)
65{
66 int ret = spin_trylock(&sl->lock);
67
68 if (ret) {
69 ++sl->sequence;
70 smp_wmb();
71 }
72 return ret;
73}
74
75/* Start of read calculation -- fetch last complete writer token */
76static inline unsigned read_seqbegin(const seqlock_t *sl)
77{
78 unsigned ret = sl->sequence;
79 smp_rmb();
80 return ret;
81}
82
83/* Test if reader processed invalid data.
84 * If initial values is odd,
85 * then writer had already started when section was entered
86 * If sequence value changed
87 * then writer changed data while in section
88 *
89 * Using xor saves one conditional branch.
90 */
91static inline int read_seqretry(const seqlock_t *sl, unsigned iv)
92{
93 smp_rmb();
94 return (iv & 1) | (sl->sequence ^ iv);
95}
96
97
98/*
99 * Version using sequence counter only.
100 * This can be used when code has its own mutex protecting the
101 * updating starting before the write_seqcountbeqin() and ending
102 * after the write_seqcount_end().
103 */
104
105typedef struct seqcount {
106 unsigned sequence;
107} seqcount_t;
108
109#define SEQCNT_ZERO { 0 }
110#define seqcount_init(x) do { *(x) = (seqcount_t) SEQCNT_ZERO; } while (0)
111
112/* Start of read using pointer to a sequence counter only. */
113static inline unsigned read_seqcount_begin(const seqcount_t *s)
114{
115 unsigned ret = s->sequence;
116 smp_rmb();
117 return ret;
118}
119
120/* Test if reader processed invalid data.
121 * Equivalent to: iv is odd or sequence number has changed.
122 * (iv & 1) || (*s != iv)
123 * Using xor saves one conditional branch.
124 */
125static inline int read_seqcount_retry(const seqcount_t *s, unsigned iv)
126{
127 smp_rmb();
128 return (iv & 1) | (s->sequence ^ iv);
129}
130
131
132/*
133 * Sequence counter only version assumes that callers are using their
134 * own mutexing.
135 */
136static inline void write_seqcount_begin(seqcount_t *s)
137{
138 s->sequence++;
139 smp_wmb();
140}
141
142static inline void write_seqcount_end(seqcount_t *s)
143{
144 smp_wmb();
145 s->sequence++;
146}
147
148/*
149 * Possible sw/hw IRQ protected versions of the interfaces.
150 */
151#define write_seqlock_irqsave(lock, flags) \
152 do { local_irq_save(flags); write_seqlock(lock); } while (0)
153#define write_seqlock_irq(lock) \
154 do { local_irq_disable(); write_seqlock(lock); } while (0)
155#define write_seqlock_bh(lock) \
156 do { local_bh_disable(); write_seqlock(lock); } while (0)
157
158#define write_sequnlock_irqrestore(lock, flags) \
159 do { write_sequnlock(lock); local_irq_restore(flags); } while(0)
160#define write_sequnlock_irq(lock) \
161 do { write_sequnlock(lock); local_irq_enable(); } while(0)
162#define write_sequnlock_bh(lock) \
163 do { write_sequnlock(lock); local_bh_enable(); } while(0)
164
165#define read_seqbegin_irqsave(lock, flags) \
166 ({ local_irq_save(flags); read_seqbegin(lock); })
167
168#define read_seqretry_irqrestore(lock, iv, flags) \
169 ({ \
170 int ret = read_seqretry(lock, iv); \
171 local_irq_restore(flags); \
172 ret; \
173 })
174
175#endif /* __LINUX_SEQLOCK_H */
diff --git a/include/linux/serial.h b/include/linux/serial.h
new file mode 100644
index 000000000000..00145822fb74
--- /dev/null
+++ b/include/linux/serial.h
@@ -0,0 +1,188 @@
1/*
2 * include/linux/serial.h
3 *
4 * Copyright (C) 1992 by Theodore Ts'o.
5 *
6 * Redistribution of this file is permitted under the terms of the GNU
7 * Public License (GPL)
8 */
9
10#ifndef _LINUX_SERIAL_H
11#define _LINUX_SERIAL_H
12
13#ifdef __KERNEL__
14#include <asm/page.h>
15
16/*
17 * Counters of the input lines (CTS, DSR, RI, CD) interrupts
18 */
19
20struct async_icount {
21 __u32 cts, dsr, rng, dcd, tx, rx;
22 __u32 frame, parity, overrun, brk;
23 __u32 buf_overrun;
24};
25
26/*
27 * The size of the serial xmit buffer is 1 page, or 4096 bytes
28 */
29#define SERIAL_XMIT_SIZE PAGE_SIZE
30
31#endif
32
33struct serial_struct {
34 int type;
35 int line;
36 unsigned int port;
37 int irq;
38 int flags;
39 int xmit_fifo_size;
40 int custom_divisor;
41 int baud_base;
42 unsigned short close_delay;
43 char io_type;
44 char reserved_char[1];
45 int hub6;
46 unsigned short closing_wait; /* time to wait before closing */
47 unsigned short closing_wait2; /* no longer used... */
48 unsigned char *iomem_base;
49 unsigned short iomem_reg_shift;
50 unsigned int port_high;
51 unsigned long iomap_base; /* cookie passed into ioremap */
52};
53
54/*
55 * For the close wait times, 0 means wait forever for serial port to
56 * flush its output. 65535 means don't wait at all.
57 */
58#define ASYNC_CLOSING_WAIT_INF 0
59#define ASYNC_CLOSING_WAIT_NONE 65535
60
61/*
62 * These are the supported serial types.
63 */
64#define PORT_UNKNOWN 0
65#define PORT_8250 1
66#define PORT_16450 2
67#define PORT_16550 3
68#define PORT_16550A 4
69#define PORT_CIRRUS 5 /* usurped by cyclades.c */
70#define PORT_16650 6
71#define PORT_16650V2 7
72#define PORT_16750 8
73#define PORT_STARTECH 9 /* usurped by cyclades.c */
74#define PORT_16C950 10 /* Oxford Semiconductor */
75#define PORT_16654 11
76#define PORT_16850 12
77#define PORT_RSA 13 /* RSA-DV II/S card */
78#define PORT_MAX 13
79
80#define SERIAL_IO_PORT 0
81#define SERIAL_IO_HUB6 1
82#define SERIAL_IO_MEM 2
83
84struct serial_uart_config {
85 char *name;
86 int dfl_xmit_fifo_size;
87 int flags;
88};
89
90#define UART_CLEAR_FIFO 0x01
91#define UART_USE_FIFO 0x02
92#define UART_STARTECH 0x04
93#define UART_NATSEMI 0x08
94
95/*
96 * Definitions for async_struct (and serial_struct) flags field
97 */
98#define ASYNC_HUP_NOTIFY 0x0001 /* Notify getty on hangups and closes
99 on the callout port */
100#define ASYNC_FOURPORT 0x0002 /* Set OU1, OUT2 per AST Fourport settings */
101#define ASYNC_SAK 0x0004 /* Secure Attention Key (Orange book) */
102#define ASYNC_SPLIT_TERMIOS 0x0008 /* Separate termios for dialin/callout */
103
104#define ASYNC_SPD_MASK 0x1030
105#define ASYNC_SPD_HI 0x0010 /* Use 56000 instead of 38400 bps */
106
107#define ASYNC_SPD_VHI 0x0020 /* Use 115200 instead of 38400 bps */
108#define ASYNC_SPD_CUST 0x0030 /* Use user-specified divisor */
109
110#define ASYNC_SKIP_TEST 0x0040 /* Skip UART test during autoconfiguration */
111#define ASYNC_AUTO_IRQ 0x0080 /* Do automatic IRQ during autoconfiguration */
112#define ASYNC_SESSION_LOCKOUT 0x0100 /* Lock out cua opens based on session */
113#define ASYNC_PGRP_LOCKOUT 0x0200 /* Lock out cua opens based on pgrp */
114#define ASYNC_CALLOUT_NOHUP 0x0400 /* Don't do hangups for cua device */
115
116#define ASYNC_HARDPPS_CD 0x0800 /* Call hardpps when CD goes high */
117
118#define ASYNC_SPD_SHI 0x1000 /* Use 230400 instead of 38400 bps */
119#define ASYNC_SPD_WARP 0x1010 /* Use 460800 instead of 38400 bps */
120
121#define ASYNC_LOW_LATENCY 0x2000 /* Request low latency behaviour */
122
123#define ASYNC_BUGGY_UART 0x4000 /* This is a buggy UART, skip some safety
124 * checks. Note: can be dangerous! */
125
126#define ASYNC_AUTOPROBE 0x8000 /* Port was autoprobed by PCI or PNP code */
127
128#define ASYNC_FLAGS 0x7FFF /* Possible legal async flags */
129#define ASYNC_USR_MASK 0x3430 /* Legal flags that non-privileged
130 * users can set or reset */
131
132/* Internal flags used only by kernel/chr_drv/serial.c */
133#define ASYNC_INITIALIZED 0x80000000 /* Serial port was initialized */
134#define ASYNC_NORMAL_ACTIVE 0x20000000 /* Normal device is active */
135#define ASYNC_BOOT_AUTOCONF 0x10000000 /* Autoconfigure port on bootup */
136#define ASYNC_CLOSING 0x08000000 /* Serial port is closing */
137#define ASYNC_CTS_FLOW 0x04000000 /* Do CTS flow control */
138#define ASYNC_CHECK_CD 0x02000000 /* i.e., CLOCAL */
139#define ASYNC_SHARE_IRQ 0x01000000 /* for multifunction cards
140 --- no longer used */
141#define ASYNC_CONS_FLOW 0x00800000 /* flow control for console */
142
143#define ASYNC_BOOT_ONLYMCA 0x00400000 /* Probe only if MCA bus */
144#define ASYNC_INTERNAL_FLAGS 0xFFC00000 /* Internal flags */
145
146/*
147 * Multiport serial configuration structure --- external structure
148 */
149struct serial_multiport_struct {
150 int irq;
151 int port1;
152 unsigned char mask1, match1;
153 int port2;
154 unsigned char mask2, match2;
155 int port3;
156 unsigned char mask3, match3;
157 int port4;
158 unsigned char mask4, match4;
159 int port_monitor;
160 int reserved[32];
161};
162
163/*
164 * Serial input interrupt line counters -- external structure
165 * Four lines can interrupt: CTS, DSR, RI, DCD
166 */
167struct serial_icounter_struct {
168 int cts, dsr, rng, dcd;
169 int rx, tx;
170 int frame, overrun, parity, brk;
171 int buf_overrun;
172 int reserved[9];
173};
174
175
176#ifdef __KERNEL__
177/* Export to allow PCMCIA to use this - Dave Hinds */
178extern int register_serial(struct serial_struct *req);
179extern void unregister_serial(int line);
180
181/* Allow architectures to override entries in serial8250_ports[] at run time: */
182struct uart_port; /* forward declaration */
183extern int early_serial_setup(struct uart_port *port);
184extern int early_serial_console_init(char *options);
185extern int serial8250_start_console(struct uart_port *port, char *options);
186
187#endif /* __KERNEL__ */
188#endif /* _LINUX_SERIAL_H */
diff --git a/include/linux/serial167.h b/include/linux/serial167.h
new file mode 100644
index 000000000000..71b6df2516a6
--- /dev/null
+++ b/include/linux/serial167.h
@@ -0,0 +1,171 @@
1/*
2 * serial167.h
3 *
4 * Richard Hirst [richard@sleepie.demon.co.uk]
5 *
6 * Based on cyclades.h
7 */
8
9struct cyclades_monitor {
10 unsigned long int_count;
11 unsigned long char_count;
12 unsigned long char_max;
13 unsigned long char_last;
14};
15
16/*
17 * This is our internal structure for each serial port's state.
18 *
19 * Many fields are paralleled by the structure used by the serial_struct
20 * structure.
21 *
22 * For definitions of the flags field, see tty.h
23 */
24
25struct cyclades_port {
26 int magic;
27 int type;
28 int card;
29 int line;
30 int flags; /* defined in tty.h */
31 struct tty_struct *tty;
32 int read_status_mask;
33 int timeout;
34 int xmit_fifo_size;
35 int cor1,cor2,cor3,cor4,cor5,cor6,cor7;
36 int tbpr,tco,rbpr,rco;
37 int ignore_status_mask;
38 int close_delay;
39 int IER; /* Interrupt Enable Register */
40 unsigned long event;
41 unsigned long last_active;
42 int count; /* # of fd on device */
43 int x_char; /* to be pushed out ASAP */
44 int x_break;
45 int blocked_open; /* # of blocked opens */
46 unsigned char *xmit_buf;
47 int xmit_head;
48 int xmit_tail;
49 int xmit_cnt;
50 int default_threshold;
51 int default_timeout;
52 struct work_struct tqueue;
53 wait_queue_head_t open_wait;
54 wait_queue_head_t close_wait;
55 struct cyclades_monitor mon;
56};
57
58#define CYCLADES_MAGIC 0x4359
59
60#define CYGETMON 0x435901
61#define CYGETTHRESH 0x435902
62#define CYSETTHRESH 0x435903
63#define CYGETDEFTHRESH 0x435904
64#define CYSETDEFTHRESH 0x435905
65#define CYGETTIMEOUT 0x435906
66#define CYSETTIMEOUT 0x435907
67#define CYGETDEFTIMEOUT 0x435908
68#define CYSETDEFTIMEOUT 0x435909
69
70/*
71 * Events are used to schedule things to happen at timer-interrupt
72 * time, instead of at cy interrupt time.
73 */
74#define Cy_EVENT_READ_PROCESS 0
75#define Cy_EVENT_WRITE_WAKEUP 1
76#define Cy_EVENT_HANGUP 2
77#define Cy_EVENT_BREAK 3
78#define Cy_EVENT_OPEN_WAKEUP 4
79
80
81
82#define CyMaxChipsPerCard 1
83
84/**** cd2401 registers ****/
85
86#define CyGFRCR (0x81)
87#define CyCCR (0x13)
88#define CyCLR_CHAN (0x40)
89#define CyINIT_CHAN (0x20)
90#define CyCHIP_RESET (0x10)
91#define CyENB_XMTR (0x08)
92#define CyDIS_XMTR (0x04)
93#define CyENB_RCVR (0x02)
94#define CyDIS_RCVR (0x01)
95#define CyCAR (0xee)
96#define CyIER (0x11)
97#define CyMdmCh (0x80)
98#define CyRxExc (0x20)
99#define CyRxData (0x08)
100#define CyTxMpty (0x02)
101#define CyTxRdy (0x01)
102#define CyLICR (0x26)
103#define CyRISR (0x89)
104#define CyTIMEOUT (0x80)
105#define CySPECHAR (0x70)
106#define CyOVERRUN (0x08)
107#define CyPARITY (0x04)
108#define CyFRAME (0x02)
109#define CyBREAK (0x01)
110#define CyREOIR (0x84)
111#define CyTEOIR (0x85)
112#define CyMEOIR (0x86)
113#define CyNOTRANS (0x08)
114#define CyRFOC (0x30)
115#define CyRDR (0xf8)
116#define CyTDR (0xf8)
117#define CyMISR (0x8b)
118#define CyRISR (0x89)
119#define CyTISR (0x8a)
120#define CyMSVR1 (0xde)
121#define CyMSVR2 (0xdf)
122#define CyDSR (0x80)
123#define CyDCD (0x40)
124#define CyCTS (0x20)
125#define CyDTR (0x02)
126#define CyRTS (0x01)
127#define CyRTPRL (0x25)
128#define CyRTPRH (0x24)
129#define CyCOR1 (0x10)
130#define CyPARITY_NONE (0x00)
131#define CyPARITY_E (0x40)
132#define CyPARITY_O (0xC0)
133#define Cy_5_BITS (0x04)
134#define Cy_6_BITS (0x05)
135#define Cy_7_BITS (0x06)
136#define Cy_8_BITS (0x07)
137#define CyCOR2 (0x17)
138#define CyETC (0x20)
139#define CyCtsAE (0x02)
140#define CyCOR3 (0x16)
141#define Cy_1_STOP (0x02)
142#define Cy_2_STOP (0x04)
143#define CyCOR4 (0x15)
144#define CyREC_FIFO (0x0F) /* Receive FIFO threshold */
145#define CyCOR5 (0x14)
146#define CyCOR6 (0x18)
147#define CyCOR7 (0x07)
148#define CyRBPR (0xcb)
149#define CyRCOR (0xc8)
150#define CyTBPR (0xc3)
151#define CyTCOR (0xc0)
152#define CySCHR1 (0x1f)
153#define CySCHR2 (0x1e)
154#define CyTPR (0xda)
155#define CyPILR1 (0xe3)
156#define CyPILR2 (0xe0)
157#define CyPILR3 (0xe1)
158#define CyCMR (0x1b)
159#define CyASYNC (0x02)
160#define CyLICR (0x26)
161#define CyLIVR (0x09)
162#define CySCRL (0x23)
163#define CySCRH (0x22)
164#define CyTFTC (0x80)
165
166
167/* max number of chars in the FIFO */
168
169#define CyMAX_CHAR_FIFO 12
170
171/***************************************************************************/
diff --git a/include/linux/serialP.h b/include/linux/serialP.h
new file mode 100644
index 000000000000..2307f11d8a6b
--- /dev/null
+++ b/include/linux/serialP.h
@@ -0,0 +1,184 @@
1/*
2 * Private header file for the (dumb) serial driver
3 *
4 * Copyright (C) 1997 by Theodore Ts'o.
5 *
6 * Redistribution of this file is permitted under the terms of the GNU
7 * Public License (GPL)
8 */
9
10#ifndef _LINUX_SERIALP_H
11#define _LINUX_SERIALP_H
12
13/*
14 * This is our internal structure for each serial port's state.
15 *
16 * Many fields are paralleled by the structure used by the serial_struct
17 * structure.
18 *
19 * For definitions of the flags field, see tty.h
20 */
21
22#include <linux/version.h>
23#include <linux/config.h>
24#include <linux/termios.h>
25#include <linux/workqueue.h>
26#include <linux/interrupt.h>
27#include <linux/circ_buf.h>
28#include <linux/wait.h>
29
30struct serial_state {
31 int magic;
32 int baud_base;
33 unsigned long port;
34 int irq;
35 int flags;
36 int hub6;
37 int type;
38 int line;
39 int revision; /* Chip revision (950) */
40 int xmit_fifo_size;
41 int custom_divisor;
42 int count;
43 u8 *iomem_base;
44 u16 iomem_reg_shift;
45 unsigned short close_delay;
46 unsigned short closing_wait; /* time to wait before closing */
47 struct async_icount icount;
48 int io_type;
49 struct async_struct *info;
50 struct pci_dev *dev;
51};
52
53struct async_struct {
54 int magic;
55 unsigned long port;
56 int hub6;
57 int flags;
58 int xmit_fifo_size;
59 struct serial_state *state;
60 struct tty_struct *tty;
61 int read_status_mask;
62 int ignore_status_mask;
63 int timeout;
64 int quot;
65 int x_char; /* xon/xoff character */
66 int close_delay;
67 unsigned short closing_wait;
68 unsigned short closing_wait2; /* obsolete */
69 int IER; /* Interrupt Enable Register */
70 int MCR; /* Modem control register */
71 int LCR; /* Line control register */
72 int ACR; /* 16950 Additional Control Reg. */
73 unsigned long event;
74 unsigned long last_active;
75 int line;
76 int blocked_open; /* # of blocked opens */
77 struct circ_buf xmit;
78 spinlock_t xmit_lock;
79 u8 *iomem_base;
80 u16 iomem_reg_shift;
81 int io_type;
82 struct work_struct work;
83 struct tasklet_struct tlet;
84#ifdef DECLARE_WAITQUEUE
85 wait_queue_head_t open_wait;
86 wait_queue_head_t close_wait;
87 wait_queue_head_t delta_msr_wait;
88#else
89 struct wait_queue *open_wait;
90 struct wait_queue *close_wait;
91 struct wait_queue *delta_msr_wait;
92#endif
93 struct async_struct *next_port; /* For the linked list */
94 struct async_struct *prev_port;
95};
96
97#define CONFIGURED_SERIAL_PORT(info) ((info)->port || ((info)->iomem_base))
98
99#define SERIAL_MAGIC 0x5301
100#define SSTATE_MAGIC 0x5302
101
102/*
103 * Events are used to schedule things to happen at timer-interrupt
104 * time, instead of at rs interrupt time.
105 */
106#define RS_EVENT_WRITE_WAKEUP 0
107
108/*
109 * Multiport serial configuration structure --- internal structure
110 */
111struct rs_multiport_struct {
112 int port1;
113 unsigned char mask1, match1;
114 int port2;
115 unsigned char mask2, match2;
116 int port3;
117 unsigned char mask3, match3;
118 int port4;
119 unsigned char mask4, match4;
120 int port_monitor;
121};
122
123#if defined(__alpha__) && !defined(CONFIG_PCI)
124/*
125 * Digital did something really horribly wrong with the OUT1 and OUT2
126 * lines on at least some ALPHA's. The failure mode is that if either
127 * is cleared, the machine locks up with endless interrupts.
128 *
129 * This is still used by arch/mips/au1000/common/serial.c for some weird
130 * reason (mips != alpha!)
131 */
132#define ALPHA_KLUDGE_MCR (UART_MCR_OUT2 | UART_MCR_OUT1)
133#elif defined(CONFIG_SBC8560)
134/*
135 * WindRiver did something similarly broken on their SBC8560 board. The
136 * UART tristates its IRQ output while OUT2 is clear, but they pulled
137 * the interrupt line _up_ instead of down, so if we register the IRQ
138 * while the UART is in that state, we die in an IRQ storm. */
139#define ALPHA_KLUDGE_MCR (UART_MCR_OUT2)
140#else
141#define ALPHA_KLUDGE_MCR 0
142#endif
143
144/*
145 * Definitions for PCI support.
146 */
147#define SPCI_FL_BASE_MASK 0x0007
148#define SPCI_FL_BASE0 0x0000
149#define SPCI_FL_BASE1 0x0001
150#define SPCI_FL_BASE2 0x0002
151#define SPCI_FL_BASE3 0x0003
152#define SPCI_FL_BASE4 0x0004
153#define SPCI_FL_GET_BASE(x) (x & SPCI_FL_BASE_MASK)
154
155#define SPCI_FL_IRQ_MASK (0x0007 << 4)
156#define SPCI_FL_IRQBASE0 (0x0000 << 4)
157#define SPCI_FL_IRQBASE1 (0x0001 << 4)
158#define SPCI_FL_IRQBASE2 (0x0002 << 4)
159#define SPCI_FL_IRQBASE3 (0x0003 << 4)
160#define SPCI_FL_IRQBASE4 (0x0004 << 4)
161#define SPCI_FL_GET_IRQBASE(x) ((x & SPCI_FL_IRQ_MASK) >> 4)
162
163/* Use successive BARs (PCI base address registers),
164 else use offset into some specified BAR */
165#define SPCI_FL_BASE_TABLE 0x0100
166
167/* Use successive entries in the irq resource table */
168#define SPCI_FL_IRQ_TABLE 0x0200
169
170/* Use the irq resource table instead of dev->irq */
171#define SPCI_FL_IRQRESOURCE 0x0400
172
173/* Use the Base address register size to cap number of ports */
174#define SPCI_FL_REGION_SZ_CAP 0x0800
175
176/* Do not use irq sharing for this device */
177#define SPCI_FL_NO_SHIRQ 0x1000
178
179/* This is a PNP device */
180#define SPCI_FL_ISPNP 0x2000
181
182#define SPCI_FL_PNPDEFAULT (SPCI_FL_IRQRESOURCE|SPCI_FL_ISPNP)
183
184#endif /* _LINUX_SERIAL_H */
diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h
new file mode 100644
index 000000000000..823181af6ddf
--- /dev/null
+++ b/include/linux/serial_8250.h
@@ -0,0 +1,28 @@
1/*
2 * linux/include/linux/serial_8250.h
3 *
4 * Copyright (C) 2004 Russell King
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#ifndef _LINUX_SERIAL_8250_H
12#define _LINUX_SERIAL_8250_H
13
14#include <linux/serial_core.h>
15#include <linux/device.h>
16
17struct plat_serial8250_port {
18 unsigned long iobase; /* io base address */
19 void __iomem *membase; /* ioremap cookie or NULL */
20 unsigned long mapbase; /* resource base */
21 unsigned int irq; /* interrupt number */
22 unsigned int uartclk; /* UART clock rate */
23 unsigned char regshift; /* register shift */
24 unsigned char iotype; /* UPIO_* */
25 unsigned int flags; /* UPF_* flags */
26};
27
28#endif
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
new file mode 100644
index 000000000000..c3fb5984f250
--- /dev/null
+++ b/include/linux/serial_core.h
@@ -0,0 +1,491 @@
1/*
2 * linux/drivers/char/serial_core.h
3 *
4 * Copyright (C) 2000 Deep Blue Solutions Ltd.
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#ifndef LINUX_SERIAL_CORE_H
21#define LINUX_SERIAL_CORE_H
22
23/*
24 * The type definitions. These are from Ted Ts'o's serial.h
25 */
26#define PORT_UNKNOWN 0
27#define PORT_8250 1
28#define PORT_16450 2
29#define PORT_16550 3
30#define PORT_16550A 4
31#define PORT_CIRRUS 5
32#define PORT_16650 6
33#define PORT_16650V2 7
34#define PORT_16750 8
35#define PORT_STARTECH 9
36#define PORT_16C950 10
37#define PORT_16654 11
38#define PORT_16850 12
39#define PORT_RSA 13
40#define PORT_NS16550A 14
41#define PORT_XSCALE 15
42#define PORT_MAX_8250 15 /* max port ID */
43
44/*
45 * ARM specific type numbers. These are not currently guaranteed
46 * to be implemented, and will change in the future. These are
47 * separate so any additions to the old serial.c that occur before
48 * we are merged can be easily merged here.
49 */
50#define PORT_PXA 31
51#define PORT_AMBA 32
52#define PORT_CLPS711X 33
53#define PORT_SA1100 34
54#define PORT_UART00 35
55#define PORT_21285 37
56
57/* Sparc type numbers. */
58#define PORT_SUNZILOG 38
59#define PORT_SUNSAB 39
60
61/* NEC v850. */
62#define PORT_V850E_UART 40
63
64/* DZ */
65#define PORT_DZ 47
66
67/* Parisc type numbers. */
68#define PORT_MUX 48
69
70/* Macintosh Zilog type numbers */
71#define PORT_MAC_ZILOG 50 /* m68k : not yet implemented */
72#define PORT_PMAC_ZILOG 51
73
74/* SH-SCI */
75#define PORT_SCI 52
76#define PORT_SCIF 53
77#define PORT_IRDA 54
78
79/* Samsung S3C2410 SoC and derivatives thereof */
80#define PORT_S3C2410 55
81
82/* SGI IP22 aka Indy / Challenge S / Indigo 2 */
83#define PORT_IP22ZILOG 56
84
85/* Sharp LH7a40x -- an ARM9 SoC series */
86#define PORT_LH7A40X 57
87
88/* PPC CPM type number */
89#define PORT_CPM 58
90
91/* MPC52xx type numbers */
92#define PORT_MPC52xx 59
93
94/* IBM icom */
95#define PORT_ICOM 60
96
97/* Samsung S3C2440 SoC */
98#define PORT_S3C2440 61
99
100/* Motorola i.MX SoC */
101#define PORT_IMX 62
102
103/* Marvell MPSC */
104#define PORT_MPSC 63
105
106/* TXX9 type number */
107#define PORT_TXX9 64
108
109/* NEC VR4100 series SIU/DSIU */
110#define PORT_VR41XX_SIU 65
111#define PORT_VR41XX_DSIU 66
112
113/* Samsung S3C2400 SoC */
114#define PORT_S3C2400 67
115
116/* M32R SIO */
117#define PORT_M32R_SIO 68
118
119/*Digi jsm */
120#define PORT_JSM 65
121
122#ifdef __KERNEL__
123
124#include <linux/config.h>
125#include <linux/interrupt.h>
126#include <linux/circ_buf.h>
127#include <linux/spinlock.h>
128#include <linux/sched.h>
129#include <linux/tty.h>
130
131struct uart_port;
132struct uart_info;
133struct serial_struct;
134struct device;
135
136/*
137 * This structure describes all the operations that can be
138 * done on the physical hardware.
139 */
140struct uart_ops {
141 unsigned int (*tx_empty)(struct uart_port *);
142 void (*set_mctrl)(struct uart_port *, unsigned int mctrl);
143 unsigned int (*get_mctrl)(struct uart_port *);
144 void (*stop_tx)(struct uart_port *, unsigned int tty_stop);
145 void (*start_tx)(struct uart_port *, unsigned int tty_start);
146 void (*send_xchar)(struct uart_port *, char ch);
147 void (*stop_rx)(struct uart_port *);
148 void (*enable_ms)(struct uart_port *);
149 void (*break_ctl)(struct uart_port *, int ctl);
150 int (*startup)(struct uart_port *);
151 void (*shutdown)(struct uart_port *);
152 void (*set_termios)(struct uart_port *, struct termios *new,
153 struct termios *old);
154 void (*pm)(struct uart_port *, unsigned int state,
155 unsigned int oldstate);
156 int (*set_wake)(struct uart_port *, unsigned int state);
157
158 /*
159 * Return a string describing the type of the port
160 */
161 const char *(*type)(struct uart_port *);
162
163 /*
164 * Release IO and memory resources used by the port.
165 * This includes iounmap if necessary.
166 */
167 void (*release_port)(struct uart_port *);
168
169 /*
170 * Request IO and memory resources used by the port.
171 * This includes iomapping the port if necessary.
172 */
173 int (*request_port)(struct uart_port *);
174 void (*config_port)(struct uart_port *, int);
175 int (*verify_port)(struct uart_port *, struct serial_struct *);
176 int (*ioctl)(struct uart_port *, unsigned int, unsigned long);
177};
178
179#define UART_CONFIG_TYPE (1 << 0)
180#define UART_CONFIG_IRQ (1 << 1)
181
182struct uart_icount {
183 __u32 cts;
184 __u32 dsr;
185 __u32 rng;
186 __u32 dcd;
187 __u32 rx;
188 __u32 tx;
189 __u32 frame;
190 __u32 overrun;
191 __u32 parity;
192 __u32 brk;
193 __u32 buf_overrun;
194};
195
196struct uart_port {
197 spinlock_t lock; /* port lock */
198 unsigned int iobase; /* in/out[bwl] */
199 unsigned char __iomem *membase; /* read/write[bwl] */
200 unsigned int irq; /* irq number */
201 unsigned int uartclk; /* base uart clock */
202 unsigned char fifosize; /* tx fifo size */
203 unsigned char x_char; /* xon/xoff char */
204 unsigned char regshift; /* reg offset shift */
205 unsigned char iotype; /* io access style */
206
207#define UPIO_PORT (0)
208#define UPIO_HUB6 (1)
209#define UPIO_MEM (2)
210#define UPIO_MEM32 (3)
211
212 unsigned int read_status_mask; /* driver specific */
213 unsigned int ignore_status_mask; /* driver specific */
214 struct uart_info *info; /* pointer to parent info */
215 struct uart_icount icount; /* statistics */
216
217 struct console *cons; /* struct console, if any */
218#ifdef CONFIG_SERIAL_CORE_CONSOLE
219 unsigned long sysrq; /* sysrq timeout */
220#endif
221
222 unsigned int flags;
223
224#define UPF_FOURPORT (1 << 1)
225#define UPF_SAK (1 << 2)
226#define UPF_SPD_MASK (0x1030)
227#define UPF_SPD_HI (0x0010)
228#define UPF_SPD_VHI (0x0020)
229#define UPF_SPD_CUST (0x0030)
230#define UPF_SPD_SHI (0x1000)
231#define UPF_SPD_WARP (0x1010)
232#define UPF_SKIP_TEST (1 << 6)
233#define UPF_AUTO_IRQ (1 << 7)
234#define UPF_HARDPPS_CD (1 << 11)
235#define UPF_LOW_LATENCY (1 << 13)
236#define UPF_BUGGY_UART (1 << 14)
237#define UPF_AUTOPROBE (1 << 15)
238#define UPF_MAGIC_MULTIPLIER (1 << 16)
239#define UPF_BOOT_ONLYMCA (1 << 22)
240#define UPF_CONS_FLOW (1 << 23)
241#define UPF_SHARE_IRQ (1 << 24)
242#define UPF_BOOT_AUTOCONF (1 << 28)
243#define UPF_IOREMAP (1 << 31)
244
245#define UPF_CHANGE_MASK (0x17fff)
246#define UPF_USR_MASK (UPF_SPD_MASK|UPF_LOW_LATENCY)
247
248 unsigned int mctrl; /* current modem ctrl settings */
249 unsigned int timeout; /* character-based timeout */
250 unsigned int type; /* port type */
251 struct uart_ops *ops;
252 unsigned int custom_divisor;
253 unsigned int line; /* port index */
254 unsigned long mapbase; /* for ioremap */
255 struct device *dev; /* parent device */
256 unsigned char hub6; /* this should be in the 8250 driver */
257 unsigned char unused[3];
258};
259
260/*
261 * This is the state information which is persistent across opens.
262 * The low level driver must not to touch any elements contained
263 * within.
264 */
265struct uart_state {
266 unsigned int close_delay; /* msec */
267 unsigned int closing_wait; /* msec */
268
269#define USF_CLOSING_WAIT_INF (0)
270#define USF_CLOSING_WAIT_NONE (~0U)
271
272 int count;
273 int pm_state;
274 struct uart_info *info;
275 struct uart_port *port;
276
277 struct semaphore sem;
278};
279
280#define UART_XMIT_SIZE PAGE_SIZE
281/*
282 * This is the state information which is only valid when the port
283 * is open; it may be freed by the core driver once the device has
284 * been closed. Either the low level driver or the core can modify
285 * stuff here.
286 */
287struct uart_info {
288 struct tty_struct *tty;
289 struct circ_buf xmit;
290 unsigned int flags;
291
292/*
293 * These are the flags that specific to info->flags, and reflect our
294 * internal state. They can not be accessed via port->flags. Low
295 * level drivers must not change these, but may query them instead.
296 */
297#define UIF_CHECK_CD (1 << 25)
298#define UIF_CTS_FLOW (1 << 26)
299#define UIF_NORMAL_ACTIVE (1 << 29)
300#define UIF_INITIALIZED (1 << 31)
301
302 int blocked_open;
303
304 struct tasklet_struct tlet;
305
306 wait_queue_head_t open_wait;
307 wait_queue_head_t delta_msr_wait;
308};
309
310/* number of characters left in xmit buffer before we ask for more */
311#define WAKEUP_CHARS 256
312
313struct module;
314struct tty_driver;
315
316struct uart_driver {
317 struct module *owner;
318 const char *driver_name;
319 const char *dev_name;
320 const char *devfs_name;
321 int major;
322 int minor;
323 int nr;
324 struct console *cons;
325
326 /*
327 * these are private; the low level driver should not
328 * touch these; they should be initialised to NULL
329 */
330 struct uart_state *state;
331 struct tty_driver *tty_driver;
332};
333
334void uart_write_wakeup(struct uart_port *port);
335
336/*
337 * Baud rate helpers.
338 */
339void uart_update_timeout(struct uart_port *port, unsigned int cflag,
340 unsigned int baud);
341unsigned int uart_get_baud_rate(struct uart_port *port, struct termios *termios,
342 struct termios *old, unsigned int min,
343 unsigned int max);
344unsigned int uart_get_divisor(struct uart_port *port, unsigned int baud);
345
346/*
347 * Console helpers.
348 */
349struct uart_port *uart_get_console(struct uart_port *ports, int nr,
350 struct console *c);
351void uart_parse_options(char *options, int *baud, int *parity, int *bits,
352 int *flow);
353int uart_set_options(struct uart_port *port, struct console *co, int baud,
354 int parity, int bits, int flow);
355struct tty_driver *uart_console_device(struct console *co, int *index);
356
357/*
358 * Port/driver registration/removal
359 */
360int uart_register_driver(struct uart_driver *uart);
361void uart_unregister_driver(struct uart_driver *uart);
362void uart_unregister_port(struct uart_driver *reg, int line);
363int uart_register_port(struct uart_driver *reg, struct uart_port *port);
364int uart_add_one_port(struct uart_driver *reg, struct uart_port *port);
365int uart_remove_one_port(struct uart_driver *reg, struct uart_port *port);
366int uart_match_port(struct uart_port *port1, struct uart_port *port2);
367
368/*
369 * Power Management
370 */
371int uart_suspend_port(struct uart_driver *reg, struct uart_port *port);
372int uart_resume_port(struct uart_driver *reg, struct uart_port *port);
373
374#define uart_circ_empty(circ) ((circ)->head == (circ)->tail)
375#define uart_circ_clear(circ) ((circ)->head = (circ)->tail = 0)
376
377#define uart_circ_chars_pending(circ) \
378 (CIRC_CNT((circ)->head, (circ)->tail, UART_XMIT_SIZE))
379
380#define uart_circ_chars_free(circ) \
381 (CIRC_SPACE((circ)->head, (circ)->tail, UART_XMIT_SIZE))
382
383#define uart_tx_stopped(port) \
384 ((port)->info->tty->stopped || (port)->info->tty->hw_stopped)
385
386/*
387 * The following are helper functions for the low level drivers.
388 */
389#ifdef SUPPORT_SYSRQ
390static inline int
391uart_handle_sysrq_char(struct uart_port *port, unsigned int ch,
392 struct pt_regs *regs)
393{
394 if (port->sysrq) {
395 if (ch && time_before(jiffies, port->sysrq)) {
396 handle_sysrq(ch, regs, NULL);
397 port->sysrq = 0;
398 return 1;
399 }
400 port->sysrq = 0;
401 }
402 return 0;
403}
404#else
405#define uart_handle_sysrq_char(port,ch,regs) (0)
406#endif
407
408/*
409 * We do the SysRQ and SAK checking like this...
410 */
411static inline int uart_handle_break(struct uart_port *port)
412{
413 struct uart_info *info = port->info;
414#ifdef SUPPORT_SYSRQ
415 if (port->cons && port->cons->index == port->line) {
416 if (!port->sysrq) {
417 port->sysrq = jiffies + HZ*5;
418 return 1;
419 }
420 port->sysrq = 0;
421 }
422#endif
423 if (info->flags & UPF_SAK)
424 do_SAK(info->tty);
425 return 0;
426}
427
428/**
429 * uart_handle_dcd_change - handle a change of carrier detect state
430 * @port: uart_port structure for the open port
431 * @status: new carrier detect status, nonzero if active
432 */
433static inline void
434uart_handle_dcd_change(struct uart_port *port, unsigned int status)
435{
436 struct uart_info *info = port->info;
437
438 port->icount.dcd++;
439
440#ifdef CONFIG_HARD_PPS
441 if ((port->flags & UPF_HARDPPS_CD) && status)
442 hardpps();
443#endif
444
445 if (info->flags & UIF_CHECK_CD) {
446 if (status)
447 wake_up_interruptible(&info->open_wait);
448 else if (info->tty)
449 tty_hangup(info->tty);
450 }
451}
452
453/**
454 * uart_handle_cts_change - handle a change of clear-to-send state
455 * @port: uart_port structure for the open port
456 * @status: new clear to send status, nonzero if active
457 */
458static inline void
459uart_handle_cts_change(struct uart_port *port, unsigned int status)
460{
461 struct uart_info *info = port->info;
462 struct tty_struct *tty = info->tty;
463
464 port->icount.cts++;
465
466 if (info->flags & UIF_CTS_FLOW) {
467 if (tty->hw_stopped) {
468 if (status) {
469 tty->hw_stopped = 0;
470 port->ops->start_tx(port, 0);
471 uart_write_wakeup(port);
472 }
473 } else {
474 if (!status) {
475 tty->hw_stopped = 1;
476 port->ops->stop_tx(port, 0);
477 }
478 }
479 }
480}
481
482/*
483 * UART_ENABLE_MS - determine if port should enable modem status irqs
484 */
485#define UART_ENABLE_MS(port,cflag) ((port)->flags & UPF_HARDPPS_CD || \
486 (cflag) & CRTSCTS || \
487 !((cflag) & CLOCAL))
488
489#endif
490
491#endif /* LINUX_SERIAL_CORE_H */
diff --git a/include/linux/serial_reg.h b/include/linux/serial_reg.h
new file mode 100644
index 000000000000..6a2bb955844b
--- /dev/null
+++ b/include/linux/serial_reg.h
@@ -0,0 +1,325 @@
1/*
2 * include/linux/serial_reg.h
3 *
4 * Copyright (C) 1992, 1994 by Theodore Ts'o.
5 *
6 * Redistribution of this file is permitted under the terms of the GNU
7 * Public License (GPL)
8 *
9 * These are the UART port assignments, expressed as offsets from the base
10 * register. These assignments should hold for any serial port based on
11 * a 8250, 16450, or 16550(A).
12 */
13
14#ifndef _LINUX_SERIAL_REG_H
15#define _LINUX_SERIAL_REG_H
16
17/*
18 * DLAB=0
19 */
20#define UART_RX 0 /* In: Receive buffer */
21#define UART_TX 0 /* Out: Transmit buffer */
22
23#define UART_IER 1 /* Out: Interrupt Enable Register */
24#define UART_IER_MSI 0x08 /* Enable Modem status interrupt */
25#define UART_IER_RLSI 0x04 /* Enable receiver line status interrupt */
26#define UART_IER_THRI 0x02 /* Enable Transmitter holding register int. */
27#define UART_IER_RDI 0x01 /* Enable receiver data interrupt */
28/*
29 * Sleep mode for ST16650 and TI16750. For the ST16650, EFR[4]=1
30 */
31#define UART_IERX_SLEEP 0x10 /* Enable sleep mode */
32
33#define UART_IIR 2 /* In: Interrupt ID Register */
34#define UART_IIR_NO_INT 0x01 /* No interrupts pending */
35#define UART_IIR_ID 0x06 /* Mask for the interrupt ID */
36#define UART_IIR_MSI 0x00 /* Modem status interrupt */
37#define UART_IIR_THRI 0x02 /* Transmitter holding register empty */
38#define UART_IIR_RDI 0x04 /* Receiver data interrupt */
39#define UART_IIR_RLSI 0x06 /* Receiver line status interrupt */
40
41#define UART_FCR 2 /* Out: FIFO Control Register */
42#define UART_FCR_ENABLE_FIFO 0x01 /* Enable the FIFO */
43#define UART_FCR_CLEAR_RCVR 0x02 /* Clear the RCVR FIFO */
44#define UART_FCR_CLEAR_XMIT 0x04 /* Clear the XMIT FIFO */
45#define UART_FCR_DMA_SELECT 0x08 /* For DMA applications */
46/*
47 * Note: The FIFO trigger levels are chip specific:
48 * RX:76 = 00 01 10 11 TX:54 = 00 01 10 11
49 * PC16550D: 1 4 8 14 xx xx xx xx
50 * TI16C550A: 1 4 8 14 xx xx xx xx
51 * TI16C550C: 1 4 8 14 xx xx xx xx
52 * ST16C550: 1 4 8 14 xx xx xx xx
53 * ST16C650: 8 16 24 28 16 8 24 30 PORT_16650V2
54 * NS16C552: 1 4 8 14 xx xx xx xx
55 * ST16C654: 8 16 56 60 8 16 32 56 PORT_16654
56 * TI16C750: 1 16 32 56 xx xx xx xx PORT_16750
57 * TI16C752: 8 16 56 60 8 16 32 56
58 */
59#define UART_FCR_R_TRIG_00 0x00
60#define UART_FCR_R_TRIG_01 0x40
61#define UART_FCR_R_TRIG_10 0x80
62#define UART_FCR_R_TRIG_11 0xc0
63#define UART_FCR_T_TRIG_00 0x00
64#define UART_FCR_T_TRIG_01 0x10
65#define UART_FCR_T_TRIG_10 0x20
66#define UART_FCR_T_TRIG_11 0x30
67
68#define UART_FCR_TRIGGER_MASK 0xC0 /* Mask for the FIFO trigger range */
69#define UART_FCR_TRIGGER_1 0x00 /* Mask for trigger set at 1 */
70#define UART_FCR_TRIGGER_4 0x40 /* Mask for trigger set at 4 */
71#define UART_FCR_TRIGGER_8 0x80 /* Mask for trigger set at 8 */
72#define UART_FCR_TRIGGER_14 0xC0 /* Mask for trigger set at 14 */
73/* 16650 definitions */
74#define UART_FCR6_R_TRIGGER_8 0x00 /* Mask for receive trigger set at 1 */
75#define UART_FCR6_R_TRIGGER_16 0x40 /* Mask for receive trigger set at 4 */
76#define UART_FCR6_R_TRIGGER_24 0x80 /* Mask for receive trigger set at 8 */
77#define UART_FCR6_R_TRIGGER_28 0xC0 /* Mask for receive trigger set at 14 */
78#define UART_FCR6_T_TRIGGER_16 0x00 /* Mask for transmit trigger set at 16 */
79#define UART_FCR6_T_TRIGGER_8 0x10 /* Mask for transmit trigger set at 8 */
80#define UART_FCR6_T_TRIGGER_24 0x20 /* Mask for transmit trigger set at 24 */
81#define UART_FCR6_T_TRIGGER_30 0x30 /* Mask for transmit trigger set at 30 */
82#define UART_FCR7_64BYTE 0x20 /* Go into 64 byte mode (TI16C750) */
83
84#define UART_LCR 3 /* Out: Line Control Register */
85/*
86 * Note: if the word length is 5 bits (UART_LCR_WLEN5), then setting
87 * UART_LCR_STOP will select 1.5 stop bits, not 2 stop bits.
88 */
89#define UART_LCR_DLAB 0x80 /* Divisor latch access bit */
90#define UART_LCR_SBC 0x40 /* Set break control */
91#define UART_LCR_SPAR 0x20 /* Stick parity (?) */
92#define UART_LCR_EPAR 0x10 /* Even parity select */
93#define UART_LCR_PARITY 0x08 /* Parity Enable */
94#define UART_LCR_STOP 0x04 /* Stop bits: 0=1 bit, 1=2 bits */
95#define UART_LCR_WLEN5 0x00 /* Wordlength: 5 bits */
96#define UART_LCR_WLEN6 0x01 /* Wordlength: 6 bits */
97#define UART_LCR_WLEN7 0x02 /* Wordlength: 7 bits */
98#define UART_LCR_WLEN8 0x03 /* Wordlength: 8 bits */
99
100#define UART_MCR 4 /* Out: Modem Control Register */
101#define UART_MCR_CLKSEL 0x80 /* Divide clock by 4 (TI16C752, EFR[4]=1) */
102#define UART_MCR_TCRTLR 0x40 /* Access TCR/TLR (TI16C752, EFR[4]=1) */
103#define UART_MCR_XONANY 0x20 /* Enable Xon Any (TI16C752, EFR[4]=1) */
104#define UART_MCR_AFE 0x20 /* Enable auto-RTS/CTS (TI16C550C/TI16C750) */
105#define UART_MCR_LOOP 0x10 /* Enable loopback test mode */
106#define UART_MCR_OUT2 0x08 /* Out2 complement */
107#define UART_MCR_OUT1 0x04 /* Out1 complement */
108#define UART_MCR_RTS 0x02 /* RTS complement */
109#define UART_MCR_DTR 0x01 /* DTR complement */
110
111#define UART_LSR 5 /* In: Line Status Register */
112#define UART_LSR_TEMT 0x40 /* Transmitter empty */
113#define UART_LSR_THRE 0x20 /* Transmit-hold-register empty */
114#define UART_LSR_BI 0x10 /* Break interrupt indicator */
115#define UART_LSR_FE 0x08 /* Frame error indicator */
116#define UART_LSR_PE 0x04 /* Parity error indicator */
117#define UART_LSR_OE 0x02 /* Overrun error indicator */
118#define UART_LSR_DR 0x01 /* Receiver data ready */
119
120#define UART_MSR 6 /* In: Modem Status Register */
121#define UART_MSR_DCD 0x80 /* Data Carrier Detect */
122#define UART_MSR_RI 0x40 /* Ring Indicator */
123#define UART_MSR_DSR 0x20 /* Data Set Ready */
124#define UART_MSR_CTS 0x10 /* Clear to Send */
125#define UART_MSR_DDCD 0x08 /* Delta DCD */
126#define UART_MSR_TERI 0x04 /* Trailing edge ring indicator */
127#define UART_MSR_DDSR 0x02 /* Delta DSR */
128#define UART_MSR_DCTS 0x01 /* Delta CTS */
129#define UART_MSR_ANY_DELTA 0x0F /* Any of the delta bits! */
130
131#define UART_SCR 7 /* I/O: Scratch Register */
132
133/*
134 * DLAB=1
135 */
136#define UART_DLL 0 /* Out: Divisor Latch Low */
137#define UART_DLM 1 /* Out: Divisor Latch High */
138
139/*
140 * LCR=0xBF (or DLAB=1 for 16C660)
141 */
142#define UART_EFR 2 /* I/O: Extended Features Register */
143#define UART_EFR_CTS 0x80 /* CTS flow control */
144#define UART_EFR_RTS 0x40 /* RTS flow control */
145#define UART_EFR_SCD 0x20 /* Special character detect */
146#define UART_EFR_ECB 0x10 /* Enhanced control bit */
147/*
148 * the low four bits control software flow control
149 */
150
151/*
152 * LCR=0xBF, TI16C752, ST16650, ST16650A, ST16654
153 */
154#define UART_XON1 4 /* I/O: Xon character 1 */
155#define UART_XON2 5 /* I/O: Xon character 2 */
156#define UART_XOFF1 6 /* I/O: Xoff character 1 */
157#define UART_XOFF2 7 /* I/O: Xoff character 2 */
158
159/*
160 * EFR[4]=1 MCR[6]=1, TI16C752
161 */
162#define UART_TI752_TCR 6 /* I/O: transmission control register */
163#define UART_TI752_TLR 7 /* I/O: trigger level register */
164
165/*
166 * LCR=0xBF, XR16C85x
167 */
168#define UART_TRG 0 /* FCTR bit 7 selects Rx or Tx
169 * In: Fifo count
170 * Out: Fifo custom trigger levels */
171/*
172 * These are the definitions for the Programmable Trigger Register
173 */
174#define UART_TRG_1 0x01
175#define UART_TRG_4 0x04
176#define UART_TRG_8 0x08
177#define UART_TRG_16 0x10
178#define UART_TRG_32 0x20
179#define UART_TRG_64 0x40
180#define UART_TRG_96 0x60
181#define UART_TRG_120 0x78
182#define UART_TRG_128 0x80
183
184#define UART_FCTR 1 /* Feature Control Register */
185#define UART_FCTR_RTS_NODELAY 0x00 /* RTS flow control delay */
186#define UART_FCTR_RTS_4DELAY 0x01
187#define UART_FCTR_RTS_6DELAY 0x02
188#define UART_FCTR_RTS_8DELAY 0x03
189#define UART_FCTR_IRDA 0x04 /* IrDa data encode select */
190#define UART_FCTR_TX_INT 0x08 /* Tx interrupt type select */
191#define UART_FCTR_TRGA 0x00 /* Tx/Rx 550 trigger table select */
192#define UART_FCTR_TRGB 0x10 /* Tx/Rx 650 trigger table select */
193#define UART_FCTR_TRGC 0x20 /* Tx/Rx 654 trigger table select */
194#define UART_FCTR_TRGD 0x30 /* Tx/Rx 850 programmable trigger select */
195#define UART_FCTR_SCR_SWAP 0x40 /* Scratch pad register swap */
196#define UART_FCTR_RX 0x00 /* Programmable trigger mode select */
197#define UART_FCTR_TX 0x80 /* Programmable trigger mode select */
198
199/*
200 * LCR=0xBF, FCTR[6]=1
201 */
202#define UART_EMSR 7 /* Extended Mode Select Register */
203#define UART_EMSR_FIFO_COUNT 0x01 /* Rx/Tx select */
204#define UART_EMSR_ALT_COUNT 0x02 /* Alternating count select */
205
206/*
207 * The Intel XScale on-chip UARTs define these bits
208 */
209#define UART_IER_DMAE 0x80 /* DMA Requests Enable */
210#define UART_IER_UUE 0x40 /* UART Unit Enable */
211#define UART_IER_NRZE 0x20 /* NRZ coding Enable */
212#define UART_IER_RTOIE 0x10 /* Receiver Time Out Interrupt Enable */
213
214#define UART_IIR_TOD 0x08 /* Character Timeout Indication Detected */
215
216#define UART_FCR_PXAR1 0x00 /* receive FIFO treshold = 1 */
217#define UART_FCR_PXAR8 0x40 /* receive FIFO treshold = 8 */
218#define UART_FCR_PXAR16 0x80 /* receive FIFO treshold = 16 */
219#define UART_FCR_PXAR32 0xc0 /* receive FIFO treshold = 32 */
220
221
222
223
224/*
225 * These register definitions are for the 16C950
226 */
227#define UART_ASR 0x01 /* Additional Status Register */
228#define UART_RFL 0x03 /* Receiver FIFO level */
229#define UART_TFL 0x04 /* Transmitter FIFO level */
230#define UART_ICR 0x05 /* Index Control Register */
231
232/* The 16950 ICR registers */
233#define UART_ACR 0x00 /* Additional Control Register */
234#define UART_CPR 0x01 /* Clock Prescalar Register */
235#define UART_TCR 0x02 /* Times Clock Register */
236#define UART_CKS 0x03 /* Clock Select Register */
237#define UART_TTL 0x04 /* Transmitter Interrupt Trigger Level */
238#define UART_RTL 0x05 /* Receiver Interrupt Trigger Level */
239#define UART_FCL 0x06 /* Flow Control Level Lower */
240#define UART_FCH 0x07 /* Flow Control Level Higher */
241#define UART_ID1 0x08 /* ID #1 */
242#define UART_ID2 0x09 /* ID #2 */
243#define UART_ID3 0x0A /* ID #3 */
244#define UART_REV 0x0B /* Revision */
245#define UART_CSR 0x0C /* Channel Software Reset */
246#define UART_NMR 0x0D /* Nine-bit Mode Register */
247#define UART_CTR 0xFF
248
249/*
250 * The 16C950 Additional Control Reigster
251 */
252#define UART_ACR_RXDIS 0x01 /* Receiver disable */
253#define UART_ACR_TXDIS 0x02 /* Receiver disable */
254#define UART_ACR_DSRFC 0x04 /* DSR Flow Control */
255#define UART_ACR_TLENB 0x20 /* 950 trigger levels enable */
256#define UART_ACR_ICRRD 0x40 /* ICR Read enable */
257#define UART_ACR_ASREN 0x80 /* Additional status enable */
258
259
260
261/*
262 * These definitions are for the RSA-DV II/S card, from
263 *
264 * Kiyokazu SUTO <suto@ks-and-ks.ne.jp>
265 */
266
267#define UART_RSA_BASE (-8)
268
269#define UART_RSA_MSR ((UART_RSA_BASE) + 0) /* I/O: Mode Select Register */
270
271#define UART_RSA_MSR_SWAP (1 << 0) /* Swap low/high 8 bytes in I/O port addr */
272#define UART_RSA_MSR_FIFO (1 << 2) /* Enable the external FIFO */
273#define UART_RSA_MSR_FLOW (1 << 3) /* Enable the auto RTS/CTS flow control */
274#define UART_RSA_MSR_ITYP (1 << 4) /* Level (1) / Edge triger (0) */
275
276#define UART_RSA_IER ((UART_RSA_BASE) + 1) /* I/O: Interrupt Enable Register */
277
278#define UART_RSA_IER_Rx_FIFO_H (1 << 0) /* Enable Rx FIFO half full int. */
279#define UART_RSA_IER_Tx_FIFO_H (1 << 1) /* Enable Tx FIFO half full int. */
280#define UART_RSA_IER_Tx_FIFO_E (1 << 2) /* Enable Tx FIFO empty int. */
281#define UART_RSA_IER_Rx_TOUT (1 << 3) /* Enable char receive timeout int */
282#define UART_RSA_IER_TIMER (1 << 4) /* Enable timer interrupt */
283
284#define UART_RSA_SRR ((UART_RSA_BASE) + 2) /* IN: Status Read Register */
285
286#define UART_RSA_SRR_Tx_FIFO_NEMP (1 << 0) /* Tx FIFO is not empty (1) */
287#define UART_RSA_SRR_Tx_FIFO_NHFL (1 << 1) /* Tx FIFO is not half full (1) */
288#define UART_RSA_SRR_Tx_FIFO_NFUL (1 << 2) /* Tx FIFO is not full (1) */
289#define UART_RSA_SRR_Rx_FIFO_NEMP (1 << 3) /* Rx FIFO is not empty (1) */
290#define UART_RSA_SRR_Rx_FIFO_NHFL (1 << 4) /* Rx FIFO is not half full (1) */
291#define UART_RSA_SRR_Rx_FIFO_NFUL (1 << 5) /* Rx FIFO is not full (1) */
292#define UART_RSA_SRR_Rx_TOUT (1 << 6) /* Character reception timeout occurred (1) */
293#define UART_RSA_SRR_TIMER (1 << 7) /* Timer interrupt occurred */
294
295#define UART_RSA_FRR ((UART_RSA_BASE) + 2) /* OUT: FIFO Reset Register */
296
297#define UART_RSA_TIVSR ((UART_RSA_BASE) + 3) /* I/O: Timer Interval Value Set Register */
298
299#define UART_RSA_TCR ((UART_RSA_BASE) + 4) /* OUT: Timer Control Register */
300
301#define UART_RSA_TCR_SWITCH (1 << 0) /* Timer on */
302
303/*
304 * The RSA DSV/II board has two fixed clock frequencies. One is the
305 * standard rate, and the other is 8 times faster.
306 */
307#define SERIAL_RSA_BAUD_BASE (921600)
308#define SERIAL_RSA_BAUD_BASE_LO (SERIAL_RSA_BAUD_BASE / 8)
309
310/*
311 * Extra serial register definitions for the internal UARTs
312 * in TI OMAP processors.
313 */
314#define UART_OMAP_MDR1 0x08 /* Mode definition register */
315#define UART_OMAP_MDR2 0x09 /* Mode definition register 2 */
316#define UART_OMAP_SCR 0x10 /* Supplementary control register */
317#define UART_OMAP_SSR 0x11 /* Supplementary status register */
318#define UART_OMAP_EBLR 0x12 /* BOF length register */
319#define UART_OMAP_OSC_12M_SEL 0x13 /* OMAP1510 12MHz osc select */
320#define UART_OMAP_MVER 0x14 /* Module version register */
321#define UART_OMAP_SYSC 0x15 /* System configuration register */
322#define UART_OMAP_SYSS 0x16 /* System status register */
323
324#endif /* _LINUX_SERIAL_REG_H */
325
diff --git a/include/linux/serio.h b/include/linux/serio.h
new file mode 100644
index 000000000000..a2d3b9ae06f4
--- /dev/null
+++ b/include/linux/serio.h
@@ -0,0 +1,214 @@
1#ifndef _SERIO_H
2#define _SERIO_H
3
4/*
5 * Copyright (C) 1999-2002 Vojtech Pavlik
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#include <linux/ioctl.h>
13
14#define SPIOCSTYPE _IOW('q', 0x01, unsigned long)
15
16#ifdef __KERNEL__
17
18#include <linux/interrupt.h>
19#include <linux/list.h>
20#include <linux/spinlock.h>
21#include <linux/device.h>
22#include <linux/mod_devicetable.h>
23
24struct serio {
25 void *port_data;
26
27 char name[32];
28 char phys[32];
29
30 unsigned int manual_bind;
31
32 struct serio_device_id id;
33
34 spinlock_t lock; /* protects critical sections from port's interrupt handler */
35
36 int (*write)(struct serio *, unsigned char);
37 int (*open)(struct serio *);
38 void (*close)(struct serio *);
39 int (*start)(struct serio *);
40 void (*stop)(struct serio *);
41
42 struct serio *parent, *child;
43
44 struct serio_driver *drv; /* accessed from interrupt, must be protected by serio->lock and serio->sem */
45 struct semaphore drv_sem; /* protects serio->drv so attributes can pin driver */
46
47 struct device dev;
48 unsigned int registered; /* port has been fully registered with driver core */
49
50 struct list_head node;
51};
52#define to_serio_port(d) container_of(d, struct serio, dev)
53
54struct serio_driver {
55 void *private;
56 char *description;
57
58 struct serio_device_id *id_table;
59 unsigned int manual_bind;
60
61 void (*write_wakeup)(struct serio *);
62 irqreturn_t (*interrupt)(struct serio *, unsigned char,
63 unsigned int, struct pt_regs *);
64 int (*connect)(struct serio *, struct serio_driver *drv);
65 int (*reconnect)(struct serio *);
66 void (*disconnect)(struct serio *);
67 void (*cleanup)(struct serio *);
68
69 struct device_driver driver;
70};
71#define to_serio_driver(d) container_of(d, struct serio_driver, driver)
72
73int serio_open(struct serio *serio, struct serio_driver *drv);
74void serio_close(struct serio *serio);
75void serio_rescan(struct serio *serio);
76void serio_reconnect(struct serio *serio);
77irqreturn_t serio_interrupt(struct serio *serio, unsigned char data, unsigned int flags, struct pt_regs *regs);
78
79void __serio_register_port(struct serio *serio, struct module *owner);
80static inline void serio_register_port(struct serio *serio)
81{
82 __serio_register_port(serio, THIS_MODULE);
83}
84
85void serio_unregister_port(struct serio *serio);
86void __serio_unregister_port_delayed(struct serio *serio, struct module *owner);
87static inline void serio_unregister_port_delayed(struct serio *serio)
88{
89 __serio_unregister_port_delayed(serio, THIS_MODULE);
90}
91
92void __serio_register_driver(struct serio_driver *drv, struct module *owner);
93static inline void serio_register_driver(struct serio_driver *drv)
94{
95 __serio_register_driver(drv, THIS_MODULE);
96}
97
98void serio_unregister_driver(struct serio_driver *drv);
99
100static inline int serio_write(struct serio *serio, unsigned char data)
101{
102 if (serio->write)
103 return serio->write(serio, data);
104 else
105 return -1;
106}
107
108static inline void serio_drv_write_wakeup(struct serio *serio)
109{
110 if (serio->drv && serio->drv->write_wakeup)
111 serio->drv->write_wakeup(serio);
112}
113
114static inline void serio_cleanup(struct serio *serio)
115{
116 if (serio->drv && serio->drv->cleanup)
117 serio->drv->cleanup(serio);
118}
119
120/*
121 * Use the following fucntions to manipulate serio's per-port
122 * driver-specific data.
123 */
124static inline void *serio_get_drvdata(struct serio *serio)
125{
126 return dev_get_drvdata(&serio->dev);
127}
128
129static inline void serio_set_drvdata(struct serio *serio, void *data)
130{
131 dev_set_drvdata(&serio->dev, data);
132}
133
134/*
135 * Use the following fucntions to protect critical sections in
136 * driver code from port's interrupt handler
137 */
138static inline void serio_pause_rx(struct serio *serio)
139{
140 spin_lock_irq(&serio->lock);
141}
142
143static inline void serio_continue_rx(struct serio *serio)
144{
145 spin_unlock_irq(&serio->lock);
146}
147
148/*
149 * Use the following fucntions to pin serio's driver in process context
150 */
151static inline int serio_pin_driver(struct serio *serio)
152{
153 return down_interruptible(&serio->drv_sem);
154}
155
156static inline void serio_unpin_driver(struct serio *serio)
157{
158 up(&serio->drv_sem);
159}
160
161
162#endif
163
164/*
165 * bit masks for use in "interrupt" flags (3rd argument)
166 */
167#define SERIO_TIMEOUT 1
168#define SERIO_PARITY 2
169#define SERIO_FRAME 4
170
171/*
172 * Serio types
173 */
174#define SERIO_XT 0x00
175#define SERIO_8042 0x01
176#define SERIO_RS232 0x02
177#define SERIO_HIL_MLC 0x03
178#define SERIO_PS_PSTHRU 0x05
179#define SERIO_8042_XL 0x06
180
181/*
182 * Serio types
183 */
184#define SERIO_UNKNOWN 0x00
185#define SERIO_MSC 0x01
186#define SERIO_SUN 0x02
187#define SERIO_MS 0x03
188#define SERIO_MP 0x04
189#define SERIO_MZ 0x05
190#define SERIO_MZP 0x06
191#define SERIO_MZPP 0x07
192#define SERIO_VSXXXAA 0x08
193#define SERIO_SUNKBD 0x10
194#define SERIO_WARRIOR 0x18
195#define SERIO_SPACEORB 0x19
196#define SERIO_MAGELLAN 0x1a
197#define SERIO_SPACEBALL 0x1b
198#define SERIO_GUNZE 0x1c
199#define SERIO_IFORCE 0x1d
200#define SERIO_STINGER 0x1e
201#define SERIO_NEWTON 0x1f
202#define SERIO_STOWAWAY 0x20
203#define SERIO_H3600 0x21
204#define SERIO_PS2SER 0x22
205#define SERIO_TWIDKBD 0x23
206#define SERIO_TWIDJOY 0x24
207#define SERIO_HIL 0x25
208#define SERIO_SNES232 0x26
209#define SERIO_SEMTECH 0x27
210#define SERIO_LKKBD 0x28
211#define SERIO_ELO 0x29
212#define SERIO_MICROTOUCH 0x30
213
214#endif
diff --git a/include/linux/shm.h b/include/linux/shm.h
new file mode 100644
index 000000000000..80113a1f60bc
--- /dev/null
+++ b/include/linux/shm.h
@@ -0,0 +1,108 @@
1#ifndef _LINUX_SHM_H_
2#define _LINUX_SHM_H_
3
4#include <linux/ipc.h>
5#include <linux/errno.h>
6#include <asm/page.h>
7
8/*
9 * SHMMAX, SHMMNI and SHMALL are upper limits are defaults which can
10 * be increased by sysctl
11 */
12
13#define SHMMAX 0x2000000 /* max shared seg size (bytes) */
14#define SHMMIN 1 /* min shared seg size (bytes) */
15#define SHMMNI 4096 /* max num of segs system wide */
16#define SHMALL (SHMMAX/PAGE_SIZE*(SHMMNI/16)) /* max shm system wide (pages) */
17#define SHMSEG SHMMNI /* max shared segs per process */
18
19#include <asm/shmparam.h>
20
21/* Obsolete, used only for backwards compatibility and libc5 compiles */
22struct shmid_ds {
23 struct ipc_perm shm_perm; /* operation perms */
24 int shm_segsz; /* size of segment (bytes) */
25 __kernel_time_t shm_atime; /* last attach time */
26 __kernel_time_t shm_dtime; /* last detach time */
27 __kernel_time_t shm_ctime; /* last change time */
28 __kernel_ipc_pid_t shm_cpid; /* pid of creator */
29 __kernel_ipc_pid_t shm_lpid; /* pid of last operator */
30 unsigned short shm_nattch; /* no. of current attaches */
31 unsigned short shm_unused; /* compatibility */
32 void *shm_unused2; /* ditto - used by DIPC */
33 void *shm_unused3; /* unused */
34};
35
36/* Include the definition of shmid64_ds and shminfo64 */
37#include <asm/shmbuf.h>
38
39/* permission flag for shmget */
40#define SHM_R 0400 /* or S_IRUGO from <linux/stat.h> */
41#define SHM_W 0200 /* or S_IWUGO from <linux/stat.h> */
42
43/* mode for attach */
44#define SHM_RDONLY 010000 /* read-only access */
45#define SHM_RND 020000 /* round attach address to SHMLBA boundary */
46#define SHM_REMAP 040000 /* take-over region on attach */
47#define SHM_EXEC 0100000 /* execution access */
48
49/* super user shmctl commands */
50#define SHM_LOCK 11
51#define SHM_UNLOCK 12
52
53/* ipcs ctl commands */
54#define SHM_STAT 13
55#define SHM_INFO 14
56
57/* Obsolete, used only for backwards compatibility */
58struct shminfo {
59 int shmmax;
60 int shmmin;
61 int shmmni;
62 int shmseg;
63 int shmall;
64};
65
66struct shm_info {
67 int used_ids;
68 unsigned long shm_tot; /* total allocated shm */
69 unsigned long shm_rss; /* total resident shm */
70 unsigned long shm_swp; /* total swapped shm */
71 unsigned long swap_attempts;
72 unsigned long swap_successes;
73};
74
75#ifdef __KERNEL__
76struct shmid_kernel /* private to the kernel */
77{
78 struct kern_ipc_perm shm_perm;
79 struct file * shm_file;
80 int id;
81 unsigned long shm_nattch;
82 unsigned long shm_segsz;
83 time_t shm_atim;
84 time_t shm_dtim;
85 time_t shm_ctim;
86 pid_t shm_cprid;
87 pid_t shm_lprid;
88 struct user_struct *mlock_user;
89};
90
91/* shm_mode upper byte flags */
92#define SHM_DEST 01000 /* segment will be destroyed on last detach */
93#define SHM_LOCKED 02000 /* segment will not be swapped */
94#define SHM_HUGETLB 04000 /* segment will use huge TLB pages */
95
96#ifdef CONFIG_SYSVIPC
97long do_shmat(int shmid, char __user *shmaddr, int shmflg, unsigned long *addr);
98#else
99static inline long do_shmat(int shmid, char __user *shmaddr,
100 int shmflg, unsigned long *addr)
101{
102 return -ENOSYS;
103}
104#endif
105
106#endif /* __KERNEL__ */
107
108#endif /* _LINUX_SHM_H_ */
diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
new file mode 100644
index 000000000000..c3e598276e78
--- /dev/null
+++ b/include/linux/shmem_fs.h
@@ -0,0 +1,37 @@
1#ifndef __SHMEM_FS_H
2#define __SHMEM_FS_H
3
4#include <linux/swap.h>
5#include <linux/mempolicy.h>
6
7/* inode in-kernel data */
8
9#define SHMEM_NR_DIRECT 16
10
11struct shmem_inode_info {
12 spinlock_t lock;
13 unsigned long flags;
14 unsigned long alloced; /* data pages alloced to file */
15 unsigned long swapped; /* subtotal assigned to swap */
16 unsigned long next_index; /* highest alloced index + 1 */
17 struct shared_policy policy; /* NUMA memory alloc policy */
18 struct page *i_indirect; /* top indirect blocks page */
19 swp_entry_t i_direct[SHMEM_NR_DIRECT]; /* first blocks */
20 struct list_head swaplist; /* chain of maybes on swap */
21 struct inode vfs_inode;
22};
23
24struct shmem_sb_info {
25 unsigned long max_blocks; /* How many blocks are allowed */
26 unsigned long free_blocks; /* How many are left for allocation */
27 unsigned long max_inodes; /* How many inodes are allowed */
28 unsigned long free_inodes; /* How many are left for allocation */
29 spinlock_t stat_lock;
30};
31
32static inline struct shmem_inode_info *SHMEM_I(struct inode *inode)
33{
34 return container_of(inode, struct shmem_inode_info, vfs_inode);
35}
36
37#endif
diff --git a/include/linux/signal.h b/include/linux/signal.h
new file mode 100644
index 000000000000..99c97ad026c8
--- /dev/null
+++ b/include/linux/signal.h
@@ -0,0 +1,224 @@
1#ifndef _LINUX_SIGNAL_H
2#define _LINUX_SIGNAL_H
3
4#include <linux/list.h>
5#include <linux/spinlock.h>
6#include <asm/signal.h>
7#include <asm/siginfo.h>
8
9#ifdef __KERNEL__
10
11/*
12 * Real Time signals may be queued.
13 */
14
15struct sigqueue {
16 struct list_head list;
17 spinlock_t *lock;
18 int flags;
19 siginfo_t info;
20 struct user_struct *user;
21};
22
23/* flags values. */
24#define SIGQUEUE_PREALLOC 1
25
26struct sigpending {
27 struct list_head list;
28 sigset_t signal;
29};
30
31/*
32 * Define some primitives to manipulate sigset_t.
33 */
34
35#ifndef __HAVE_ARCH_SIG_BITOPS
36#include <linux/bitops.h>
37
38/* We don't use <linux/bitops.h> for these because there is no need to
39 be atomic. */
40static inline void sigaddset(sigset_t *set, int _sig)
41{
42 unsigned long sig = _sig - 1;
43 if (_NSIG_WORDS == 1)
44 set->sig[0] |= 1UL << sig;
45 else
46 set->sig[sig / _NSIG_BPW] |= 1UL << (sig % _NSIG_BPW);
47}
48
49static inline void sigdelset(sigset_t *set, int _sig)
50{
51 unsigned long sig = _sig - 1;
52 if (_NSIG_WORDS == 1)
53 set->sig[0] &= ~(1UL << sig);
54 else
55 set->sig[sig / _NSIG_BPW] &= ~(1UL << (sig % _NSIG_BPW));
56}
57
58static inline int sigismember(sigset_t *set, int _sig)
59{
60 unsigned long sig = _sig - 1;
61 if (_NSIG_WORDS == 1)
62 return 1 & (set->sig[0] >> sig);
63 else
64 return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
65}
66
67static inline int sigfindinword(unsigned long word)
68{
69 return ffz(~word);
70}
71
72#endif /* __HAVE_ARCH_SIG_BITOPS */
73
74#define sigmask(sig) (1UL << ((sig) - 1))
75
76#ifndef __HAVE_ARCH_SIG_SETOPS
77#include <linux/string.h>
78
79#define _SIG_SET_BINOP(name, op) \
80static inline void name(sigset_t *r, const sigset_t *a, const sigset_t *b) \
81{ \
82 extern void _NSIG_WORDS_is_unsupported_size(void); \
83 unsigned long a0, a1, a2, a3, b0, b1, b2, b3; \
84 \
85 switch (_NSIG_WORDS) { \
86 case 4: \
87 a3 = a->sig[3]; a2 = a->sig[2]; \
88 b3 = b->sig[3]; b2 = b->sig[2]; \
89 r->sig[3] = op(a3, b3); \
90 r->sig[2] = op(a2, b2); \
91 case 2: \
92 a1 = a->sig[1]; b1 = b->sig[1]; \
93 r->sig[1] = op(a1, b1); \
94 case 1: \
95 a0 = a->sig[0]; b0 = b->sig[0]; \
96 r->sig[0] = op(a0, b0); \
97 break; \
98 default: \
99 _NSIG_WORDS_is_unsupported_size(); \
100 } \
101}
102
103#define _sig_or(x,y) ((x) | (y))
104_SIG_SET_BINOP(sigorsets, _sig_or)
105
106#define _sig_and(x,y) ((x) & (y))
107_SIG_SET_BINOP(sigandsets, _sig_and)
108
109#define _sig_nand(x,y) ((x) & ~(y))
110_SIG_SET_BINOP(signandsets, _sig_nand)
111
112#undef _SIG_SET_BINOP
113#undef _sig_or
114#undef _sig_and
115#undef _sig_nand
116
117#define _SIG_SET_OP(name, op) \
118static inline void name(sigset_t *set) \
119{ \
120 extern void _NSIG_WORDS_is_unsupported_size(void); \
121 \
122 switch (_NSIG_WORDS) { \
123 case 4: set->sig[3] = op(set->sig[3]); \
124 set->sig[2] = op(set->sig[2]); \
125 case 2: set->sig[1] = op(set->sig[1]); \
126 case 1: set->sig[0] = op(set->sig[0]); \
127 break; \
128 default: \
129 _NSIG_WORDS_is_unsupported_size(); \
130 } \
131}
132
133#define _sig_not(x) (~(x))
134_SIG_SET_OP(signotset, _sig_not)
135
136#undef _SIG_SET_OP
137#undef _sig_not
138
139static inline void sigemptyset(sigset_t *set)
140{
141 switch (_NSIG_WORDS) {
142 default:
143 memset(set, 0, sizeof(sigset_t));
144 break;
145 case 2: set->sig[1] = 0;
146 case 1: set->sig[0] = 0;
147 break;
148 }
149}
150
151static inline void sigfillset(sigset_t *set)
152{
153 switch (_NSIG_WORDS) {
154 default:
155 memset(set, -1, sizeof(sigset_t));
156 break;
157 case 2: set->sig[1] = -1;
158 case 1: set->sig[0] = -1;
159 break;
160 }
161}
162
163/* Some extensions for manipulating the low 32 signals in particular. */
164
165static inline void sigaddsetmask(sigset_t *set, unsigned long mask)
166{
167 set->sig[0] |= mask;
168}
169
170static inline void sigdelsetmask(sigset_t *set, unsigned long mask)
171{
172 set->sig[0] &= ~mask;
173}
174
175static inline int sigtestsetmask(sigset_t *set, unsigned long mask)
176{
177 return (set->sig[0] & mask) != 0;
178}
179
180static inline void siginitset(sigset_t *set, unsigned long mask)
181{
182 set->sig[0] = mask;
183 switch (_NSIG_WORDS) {
184 default:
185 memset(&set->sig[1], 0, sizeof(long)*(_NSIG_WORDS-1));
186 break;
187 case 2: set->sig[1] = 0;
188 case 1: ;
189 }
190}
191
192static inline void siginitsetinv(sigset_t *set, unsigned long mask)
193{
194 set->sig[0] = ~mask;
195 switch (_NSIG_WORDS) {
196 default:
197 memset(&set->sig[1], -1, sizeof(long)*(_NSIG_WORDS-1));
198 break;
199 case 2: set->sig[1] = -1;
200 case 1: ;
201 }
202}
203
204#endif /* __HAVE_ARCH_SIG_SETOPS */
205
206static inline void init_sigpending(struct sigpending *sig)
207{
208 sigemptyset(&sig->signal);
209 INIT_LIST_HEAD(&sig->list);
210}
211
212extern int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p);
213extern int __group_send_sig_info(int, struct siginfo *, struct task_struct *);
214extern long do_sigpending(void __user *, unsigned long);
215extern int sigprocmask(int, sigset_t *, sigset_t *);
216
217#ifndef HAVE_ARCH_GET_SIGNAL_TO_DELIVER
218struct pt_regs;
219extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie);
220#endif
221
222#endif /* __KERNEL__ */
223
224#endif /* _LINUX_SIGNAL_H */
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
new file mode 100644
index 000000000000..aa35797ebfbf
--- /dev/null
+++ b/include/linux/skbuff.h
@@ -0,0 +1,1253 @@
1/*
2 * Definitions for the 'struct sk_buff' memory handlers.
3 *
4 * Authors:
5 * Alan Cox, <gw4pts@gw4pts.ampr.org>
6 * Florian La Roche, <rzsfl@rz.uni-sb.de>
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#ifndef _LINUX_SKBUFF_H
15#define _LINUX_SKBUFF_H
16
17#include <linux/config.h>
18#include <linux/kernel.h>
19#include <linux/compiler.h>
20#include <linux/time.h>
21#include <linux/cache.h>
22
23#include <asm/atomic.h>
24#include <asm/types.h>
25#include <linux/spinlock.h>
26#include <linux/mm.h>
27#include <linux/highmem.h>
28#include <linux/poll.h>
29#include <linux/net.h>
30#include <net/checksum.h>
31
32#define HAVE_ALLOC_SKB /* For the drivers to know */
33#define HAVE_ALIGNABLE_SKB /* Ditto 8) */
34#define SLAB_SKB /* Slabified skbuffs */
35
36#define CHECKSUM_NONE 0
37#define CHECKSUM_HW 1
38#define CHECKSUM_UNNECESSARY 2
39
40#define SKB_DATA_ALIGN(X) (((X) + (SMP_CACHE_BYTES - 1)) & \
41 ~(SMP_CACHE_BYTES - 1))
42#define SKB_MAX_ORDER(X, ORDER) (((PAGE_SIZE << (ORDER)) - (X) - \
43 sizeof(struct skb_shared_info)) & \
44 ~(SMP_CACHE_BYTES - 1))
45#define SKB_MAX_HEAD(X) (SKB_MAX_ORDER((X), 0))
46#define SKB_MAX_ALLOC (SKB_MAX_ORDER(0, 2))
47
48/* A. Checksumming of received packets by device.
49 *
50 * NONE: device failed to checksum this packet.
51 * skb->csum is undefined.
52 *
53 * UNNECESSARY: device parsed packet and wouldbe verified checksum.
54 * skb->csum is undefined.
55 * It is bad option, but, unfortunately, many of vendors do this.
56 * Apparently with secret goal to sell you new device, when you
57 * will add new protocol to your host. F.e. IPv6. 8)
58 *
59 * HW: the most generic way. Device supplied checksum of _all_
60 * the packet as seen by netif_rx in skb->csum.
61 * NOTE: Even if device supports only some protocols, but
62 * is able to produce some skb->csum, it MUST use HW,
63 * not UNNECESSARY.
64 *
65 * B. Checksumming on output.
66 *
67 * NONE: skb is checksummed by protocol or csum is not required.
68 *
69 * HW: device is required to csum packet as seen by hard_start_xmit
70 * from skb->h.raw to the end and to record the checksum
71 * at skb->h.raw+skb->csum.
72 *
73 * Device must show its capabilities in dev->features, set
74 * at device setup time.
75 * NETIF_F_HW_CSUM - it is clever device, it is able to checksum
76 * everything.
77 * NETIF_F_NO_CSUM - loopback or reliable single hop media.
78 * NETIF_F_IP_CSUM - device is dumb. It is able to csum only
79 * TCP/UDP over IPv4. Sigh. Vendors like this
80 * way by an unknown reason. Though, see comment above
81 * about CHECKSUM_UNNECESSARY. 8)
82 *
83 * Any questions? No questions, good. --ANK
84 */
85
86#ifdef __i386__
87#define NET_CALLER(arg) (*(((void **)&arg) - 1))
88#else
89#define NET_CALLER(arg) __builtin_return_address(0)
90#endif
91
92struct net_device;
93
94#ifdef CONFIG_NETFILTER
95struct nf_conntrack {
96 atomic_t use;
97 void (*destroy)(struct nf_conntrack *);
98};
99
100#ifdef CONFIG_BRIDGE_NETFILTER
101struct nf_bridge_info {
102 atomic_t use;
103 struct net_device *physindev;
104 struct net_device *physoutdev;
105#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
106 struct net_device *netoutdev;
107#endif
108 unsigned int mask;
109 unsigned long data[32 / sizeof(unsigned long)];
110};
111#endif
112
113#endif
114
115struct sk_buff_head {
116 /* These two members must be first. */
117 struct sk_buff *next;
118 struct sk_buff *prev;
119
120 __u32 qlen;
121 spinlock_t lock;
122};
123
124struct sk_buff;
125
126/* To allow 64K frame to be packed as single skb without frag_list */
127#define MAX_SKB_FRAGS (65536/PAGE_SIZE + 2)
128
129typedef struct skb_frag_struct skb_frag_t;
130
131struct skb_frag_struct {
132 struct page *page;
133 __u16 page_offset;
134 __u16 size;
135};
136
137/* This data is invariant across clones and lives at
138 * the end of the header data, ie. at skb->end.
139 */
140struct skb_shared_info {
141 atomic_t dataref;
142 unsigned int nr_frags;
143 unsigned short tso_size;
144 unsigned short tso_segs;
145 struct sk_buff *frag_list;
146 skb_frag_t frags[MAX_SKB_FRAGS];
147};
148
149/* We divide dataref into two halves. The higher 16 bits hold references
150 * to the payload part of skb->data. The lower 16 bits hold references to
151 * the entire skb->data. It is up to the users of the skb to agree on
152 * where the payload starts.
153 *
154 * All users must obey the rule that the skb->data reference count must be
155 * greater than or equal to the payload reference count.
156 *
157 * Holding a reference to the payload part means that the user does not
158 * care about modifications to the header part of skb->data.
159 */
160#define SKB_DATAREF_SHIFT 16
161#define SKB_DATAREF_MASK ((1 << SKB_DATAREF_SHIFT) - 1)
162
163/**
164 * struct sk_buff - socket buffer
165 * @next: Next buffer in list
166 * @prev: Previous buffer in list
167 * @list: List we are on
168 * @sk: Socket we are owned by
169 * @stamp: Time we arrived
170 * @dev: Device we arrived on/are leaving by
171 * @input_dev: Device we arrived on
172 * @real_dev: The real device we are using
173 * @h: Transport layer header
174 * @nh: Network layer header
175 * @mac: Link layer header
176 * @dst: FIXME: Describe this field
177 * @cb: Control buffer. Free for use by every layer. Put private vars here
178 * @len: Length of actual data
179 * @data_len: Data length
180 * @mac_len: Length of link layer header
181 * @csum: Checksum
182 * @__unused: Dead field, may be reused
183 * @cloned: Head may be cloned (check refcnt to be sure)
184 * @nohdr: Payload reference only, must not modify header
185 * @pkt_type: Packet class
186 * @ip_summed: Driver fed us an IP checksum
187 * @priority: Packet queueing priority
188 * @users: User count - see {datagram,tcp}.c
189 * @protocol: Packet protocol from driver
190 * @security: Security level of packet
191 * @truesize: Buffer size
192 * @head: Head of buffer
193 * @data: Data head pointer
194 * @tail: Tail pointer
195 * @end: End pointer
196 * @destructor: Destruct function
197 * @nfmark: Can be used for communication between hooks
198 * @nfcache: Cache info
199 * @nfct: Associated connection, if any
200 * @nfctinfo: Relationship of this skb to the connection
201 * @nf_debug: Netfilter debugging
202 * @nf_bridge: Saved data about a bridged frame - see br_netfilter.c
203 * @private: Data which is private to the HIPPI implementation
204 * @tc_index: Traffic control index
205 * @tc_verd: traffic control verdict
206 * @tc_classid: traffic control classid
207 */
208
209struct sk_buff {
210 /* These two members must be first. */
211 struct sk_buff *next;
212 struct sk_buff *prev;
213
214 struct sk_buff_head *list;
215 struct sock *sk;
216 struct timeval stamp;
217 struct net_device *dev;
218 struct net_device *input_dev;
219 struct net_device *real_dev;
220
221 union {
222 struct tcphdr *th;
223 struct udphdr *uh;
224 struct icmphdr *icmph;
225 struct igmphdr *igmph;
226 struct iphdr *ipiph;
227 struct ipv6hdr *ipv6h;
228 unsigned char *raw;
229 } h;
230
231 union {
232 struct iphdr *iph;
233 struct ipv6hdr *ipv6h;
234 struct arphdr *arph;
235 unsigned char *raw;
236 } nh;
237
238 union {
239 unsigned char *raw;
240 } mac;
241
242 struct dst_entry *dst;
243 struct sec_path *sp;
244
245 /*
246 * This is the control buffer. It is free to use for every
247 * layer. Please put your private variables there. If you
248 * want to keep them across layers you have to do a skb_clone()
249 * first. This is owned by whoever has the skb queued ATM.
250 */
251 char cb[40];
252
253 unsigned int len,
254 data_len,
255 mac_len,
256 csum;
257 unsigned char local_df,
258 cloned:1,
259 nohdr:1,
260 pkt_type,
261 ip_summed;
262 __u32 priority;
263 unsigned short protocol,
264 security;
265
266 void (*destructor)(struct sk_buff *skb);
267#ifdef CONFIG_NETFILTER
268 unsigned long nfmark;
269 __u32 nfcache;
270 __u32 nfctinfo;
271 struct nf_conntrack *nfct;
272#ifdef CONFIG_NETFILTER_DEBUG
273 unsigned int nf_debug;
274#endif
275#ifdef CONFIG_BRIDGE_NETFILTER
276 struct nf_bridge_info *nf_bridge;
277#endif
278#endif /* CONFIG_NETFILTER */
279#if defined(CONFIG_HIPPI)
280 union {
281 __u32 ifield;
282 } private;
283#endif
284#ifdef CONFIG_NET_SCHED
285 __u32 tc_index; /* traffic control index */
286#ifdef CONFIG_NET_CLS_ACT
287 __u32 tc_verd; /* traffic control verdict */
288 __u32 tc_classid; /* traffic control classid */
289#endif
290
291#endif
292
293
294 /* These elements must be at the end, see alloc_skb() for details. */
295 unsigned int truesize;
296 atomic_t users;
297 unsigned char *head,
298 *data,
299 *tail,
300 *end;
301};
302
303#ifdef __KERNEL__
304/*
305 * Handling routines are only of interest to the kernel
306 */
307#include <linux/slab.h>
308
309#include <asm/system.h>
310
311extern void __kfree_skb(struct sk_buff *skb);
312extern struct sk_buff *alloc_skb(unsigned int size, int priority);
313extern struct sk_buff *alloc_skb_from_cache(kmem_cache_t *cp,
314 unsigned int size, int priority);
315extern void kfree_skbmem(struct sk_buff *skb);
316extern struct sk_buff *skb_clone(struct sk_buff *skb, int priority);
317extern struct sk_buff *skb_copy(const struct sk_buff *skb, int priority);
318extern struct sk_buff *pskb_copy(struct sk_buff *skb, int gfp_mask);
319extern int pskb_expand_head(struct sk_buff *skb,
320 int nhead, int ntail, int gfp_mask);
321extern struct sk_buff *skb_realloc_headroom(struct sk_buff *skb,
322 unsigned int headroom);
323extern struct sk_buff *skb_copy_expand(const struct sk_buff *skb,
324 int newheadroom, int newtailroom,
325 int priority);
326extern struct sk_buff * skb_pad(struct sk_buff *skb, int pad);
327#define dev_kfree_skb(a) kfree_skb(a)
328extern void skb_over_panic(struct sk_buff *skb, int len,
329 void *here);
330extern void skb_under_panic(struct sk_buff *skb, int len,
331 void *here);
332
333/* Internal */
334#define skb_shinfo(SKB) ((struct skb_shared_info *)((SKB)->end))
335
336/**
337 * skb_queue_empty - check if a queue is empty
338 * @list: queue head
339 *
340 * Returns true if the queue is empty, false otherwise.
341 */
342static inline int skb_queue_empty(const struct sk_buff_head *list)
343{
344 return list->next == (struct sk_buff *)list;
345}
346
347/**
348 * skb_get - reference buffer
349 * @skb: buffer to reference
350 *
351 * Makes another reference to a socket buffer and returns a pointer
352 * to the buffer.
353 */
354static inline struct sk_buff *skb_get(struct sk_buff *skb)
355{
356 atomic_inc(&skb->users);
357 return skb;
358}
359
360/*
361 * If users == 1, we are the only owner and are can avoid redundant
362 * atomic change.
363 */
364
365/**
366 * kfree_skb - free an sk_buff
367 * @skb: buffer to free
368 *
369 * Drop a reference to the buffer and free it if the usage count has
370 * hit zero.
371 */
372static inline void kfree_skb(struct sk_buff *skb)
373{
374 if (likely(atomic_read(&skb->users) == 1))
375 smp_rmb();
376 else if (likely(!atomic_dec_and_test(&skb->users)))
377 return;
378 __kfree_skb(skb);
379}
380
381/**
382 * skb_cloned - is the buffer a clone
383 * @skb: buffer to check
384 *
385 * Returns true if the buffer was generated with skb_clone() and is
386 * one of multiple shared copies of the buffer. Cloned buffers are
387 * shared data so must not be written to under normal circumstances.
388 */
389static inline int skb_cloned(const struct sk_buff *skb)
390{
391 return skb->cloned &&
392 (atomic_read(&skb_shinfo(skb)->dataref) & SKB_DATAREF_MASK) != 1;
393}
394
395/**
396 * skb_header_cloned - is the header a clone
397 * @skb: buffer to check
398 *
399 * Returns true if modifying the header part of the buffer requires
400 * the data to be copied.
401 */
402static inline int skb_header_cloned(const struct sk_buff *skb)
403{
404 int dataref;
405
406 if (!skb->cloned)
407 return 0;
408
409 dataref = atomic_read(&skb_shinfo(skb)->dataref);
410 dataref = (dataref & SKB_DATAREF_MASK) - (dataref >> SKB_DATAREF_SHIFT);
411 return dataref != 1;
412}
413
414/**
415 * skb_header_release - release reference to header
416 * @skb: buffer to operate on
417 *
418 * Drop a reference to the header part of the buffer. This is done
419 * by acquiring a payload reference. You must not read from the header
420 * part of skb->data after this.
421 */
422static inline void skb_header_release(struct sk_buff *skb)
423{
424 BUG_ON(skb->nohdr);
425 skb->nohdr = 1;
426 atomic_add(1 << SKB_DATAREF_SHIFT, &skb_shinfo(skb)->dataref);
427}
428
429/**
430 * skb_shared - is the buffer shared
431 * @skb: buffer to check
432 *
433 * Returns true if more than one person has a reference to this
434 * buffer.
435 */
436static inline int skb_shared(const struct sk_buff *skb)
437{
438 return atomic_read(&skb->users) != 1;
439}
440
441/**
442 * skb_share_check - check if buffer is shared and if so clone it
443 * @skb: buffer to check
444 * @pri: priority for memory allocation
445 *
446 * If the buffer is shared the buffer is cloned and the old copy
447 * drops a reference. A new clone with a single reference is returned.
448 * If the buffer is not shared the original buffer is returned. When
449 * being called from interrupt status or with spinlocks held pri must
450 * be GFP_ATOMIC.
451 *
452 * NULL is returned on a memory allocation failure.
453 */
454static inline struct sk_buff *skb_share_check(struct sk_buff *skb, int pri)
455{
456 might_sleep_if(pri & __GFP_WAIT);
457 if (skb_shared(skb)) {
458 struct sk_buff *nskb = skb_clone(skb, pri);
459 kfree_skb(skb);
460 skb = nskb;
461 }
462 return skb;
463}
464
465/*
466 * Copy shared buffers into a new sk_buff. We effectively do COW on
467 * packets to handle cases where we have a local reader and forward
468 * and a couple of other messy ones. The normal one is tcpdumping
469 * a packet thats being forwarded.
470 */
471
472/**
473 * skb_unshare - make a copy of a shared buffer
474 * @skb: buffer to check
475 * @pri: priority for memory allocation
476 *
477 * If the socket buffer is a clone then this function creates a new
478 * copy of the data, drops a reference count on the old copy and returns
479 * the new copy with the reference count at 1. If the buffer is not a clone
480 * the original buffer is returned. When called with a spinlock held or
481 * from interrupt state @pri must be %GFP_ATOMIC
482 *
483 * %NULL is returned on a memory allocation failure.
484 */
485static inline struct sk_buff *skb_unshare(struct sk_buff *skb, int pri)
486{
487 might_sleep_if(pri & __GFP_WAIT);
488 if (skb_cloned(skb)) {
489 struct sk_buff *nskb = skb_copy(skb, pri);
490 kfree_skb(skb); /* Free our shared copy */
491 skb = nskb;
492 }
493 return skb;
494}
495
496/**
497 * skb_peek
498 * @list_: list to peek at
499 *
500 * Peek an &sk_buff. Unlike most other operations you _MUST_
501 * be careful with this one. A peek leaves the buffer on the
502 * list and someone else may run off with it. You must hold
503 * the appropriate locks or have a private queue to do this.
504 *
505 * Returns %NULL for an empty list or a pointer to the head element.
506 * The reference count is not incremented and the reference is therefore
507 * volatile. Use with caution.
508 */
509static inline struct sk_buff *skb_peek(struct sk_buff_head *list_)
510{
511 struct sk_buff *list = ((struct sk_buff *)list_)->next;
512 if (list == (struct sk_buff *)list_)
513 list = NULL;
514 return list;
515}
516
517/**
518 * skb_peek_tail
519 * @list_: list to peek at
520 *
521 * Peek an &sk_buff. Unlike most other operations you _MUST_
522 * be careful with this one. A peek leaves the buffer on the
523 * list and someone else may run off with it. You must hold
524 * the appropriate locks or have a private queue to do this.
525 *
526 * Returns %NULL for an empty list or a pointer to the tail element.
527 * The reference count is not incremented and the reference is therefore
528 * volatile. Use with caution.
529 */
530static inline struct sk_buff *skb_peek_tail(struct sk_buff_head *list_)
531{
532 struct sk_buff *list = ((struct sk_buff *)list_)->prev;
533 if (list == (struct sk_buff *)list_)
534 list = NULL;
535 return list;
536}
537
538/**
539 * skb_queue_len - get queue length
540 * @list_: list to measure
541 *
542 * Return the length of an &sk_buff queue.
543 */
544static inline __u32 skb_queue_len(const struct sk_buff_head *list_)
545{
546 return list_->qlen;
547}
548
549static inline void skb_queue_head_init(struct sk_buff_head *list)
550{
551 spin_lock_init(&list->lock);
552 list->prev = list->next = (struct sk_buff *)list;
553 list->qlen = 0;
554}
555
556/*
557 * Insert an sk_buff at the start of a list.
558 *
559 * The "__skb_xxxx()" functions are the non-atomic ones that
560 * can only be called with interrupts disabled.
561 */
562
563/**
564 * __skb_queue_head - queue a buffer at the list head
565 * @list: list to use
566 * @newsk: buffer to queue
567 *
568 * Queue a buffer at the start of a list. This function takes no locks
569 * and you must therefore hold required locks before calling it.
570 *
571 * A buffer cannot be placed on two lists at the same time.
572 */
573extern void skb_queue_head(struct sk_buff_head *list, struct sk_buff *newsk);
574static inline void __skb_queue_head(struct sk_buff_head *list,
575 struct sk_buff *newsk)
576{
577 struct sk_buff *prev, *next;
578
579 newsk->list = list;
580 list->qlen++;
581 prev = (struct sk_buff *)list;
582 next = prev->next;
583 newsk->next = next;
584 newsk->prev = prev;
585 next->prev = prev->next = newsk;
586}
587
588/**
589 * __skb_queue_tail - queue a buffer at the list tail
590 * @list: list to use
591 * @newsk: buffer to queue
592 *
593 * Queue a buffer at the end of a list. This function takes no locks
594 * and you must therefore hold required locks before calling it.
595 *
596 * A buffer cannot be placed on two lists at the same time.
597 */
598extern void skb_queue_tail(struct sk_buff_head *list, struct sk_buff *newsk);
599static inline void __skb_queue_tail(struct sk_buff_head *list,
600 struct sk_buff *newsk)
601{
602 struct sk_buff *prev, *next;
603
604 newsk->list = list;
605 list->qlen++;
606 next = (struct sk_buff *)list;
607 prev = next->prev;
608 newsk->next = next;
609 newsk->prev = prev;
610 next->prev = prev->next = newsk;
611}
612
613
614/**
615 * __skb_dequeue - remove from the head of the queue
616 * @list: list to dequeue from
617 *
618 * Remove the head of the list. This function does not take any locks
619 * so must be used with appropriate locks held only. The head item is
620 * returned or %NULL if the list is empty.
621 */
622extern struct sk_buff *skb_dequeue(struct sk_buff_head *list);
623static inline struct sk_buff *__skb_dequeue(struct sk_buff_head *list)
624{
625 struct sk_buff *next, *prev, *result;
626
627 prev = (struct sk_buff *) list;
628 next = prev->next;
629 result = NULL;
630 if (next != prev) {
631 result = next;
632 next = next->next;
633 list->qlen--;
634 next->prev = prev;
635 prev->next = next;
636 result->next = result->prev = NULL;
637 result->list = NULL;
638 }
639 return result;
640}
641
642
643/*
644 * Insert a packet on a list.
645 */
646extern void skb_insert(struct sk_buff *old, struct sk_buff *newsk);
647static inline void __skb_insert(struct sk_buff *newsk,
648 struct sk_buff *prev, struct sk_buff *next,
649 struct sk_buff_head *list)
650{
651 newsk->next = next;
652 newsk->prev = prev;
653 next->prev = prev->next = newsk;
654 newsk->list = list;
655 list->qlen++;
656}
657
658/*
659 * Place a packet after a given packet in a list.
660 */
661extern void skb_append(struct sk_buff *old, struct sk_buff *newsk);
662static inline void __skb_append(struct sk_buff *old, struct sk_buff *newsk)
663{
664 __skb_insert(newsk, old, old->next, old->list);
665}
666
667/*
668 * remove sk_buff from list. _Must_ be called atomically, and with
669 * the list known..
670 */
671extern void skb_unlink(struct sk_buff *skb);
672static inline void __skb_unlink(struct sk_buff *skb, struct sk_buff_head *list)
673{
674 struct sk_buff *next, *prev;
675
676 list->qlen--;
677 next = skb->next;
678 prev = skb->prev;
679 skb->next = skb->prev = NULL;
680 skb->list = NULL;
681 next->prev = prev;
682 prev->next = next;
683}
684
685
686/* XXX: more streamlined implementation */
687
688/**
689 * __skb_dequeue_tail - remove from the tail of the queue
690 * @list: list to dequeue from
691 *
692 * Remove the tail of the list. This function does not take any locks
693 * so must be used with appropriate locks held only. The tail item is
694 * returned or %NULL if the list is empty.
695 */
696extern struct sk_buff *skb_dequeue_tail(struct sk_buff_head *list);
697static inline struct sk_buff *__skb_dequeue_tail(struct sk_buff_head *list)
698{
699 struct sk_buff *skb = skb_peek_tail(list);
700 if (skb)
701 __skb_unlink(skb, list);
702 return skb;
703}
704
705
706static inline int skb_is_nonlinear(const struct sk_buff *skb)
707{
708 return skb->data_len;
709}
710
711static inline unsigned int skb_headlen(const struct sk_buff *skb)
712{
713 return skb->len - skb->data_len;
714}
715
716static inline int skb_pagelen(const struct sk_buff *skb)
717{
718 int i, len = 0;
719
720 for (i = (int)skb_shinfo(skb)->nr_frags - 1; i >= 0; i--)
721 len += skb_shinfo(skb)->frags[i].size;
722 return len + skb_headlen(skb);
723}
724
725static inline void skb_fill_page_desc(struct sk_buff *skb, int i,
726 struct page *page, int off, int size)
727{
728 skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
729
730 frag->page = page;
731 frag->page_offset = off;
732 frag->size = size;
733 skb_shinfo(skb)->nr_frags = i + 1;
734}
735
736#define SKB_PAGE_ASSERT(skb) BUG_ON(skb_shinfo(skb)->nr_frags)
737#define SKB_FRAG_ASSERT(skb) BUG_ON(skb_shinfo(skb)->frag_list)
738#define SKB_LINEAR_ASSERT(skb) BUG_ON(skb_is_nonlinear(skb))
739
740/*
741 * Add data to an sk_buff
742 */
743static inline unsigned char *__skb_put(struct sk_buff *skb, unsigned int len)
744{
745 unsigned char *tmp = skb->tail;
746 SKB_LINEAR_ASSERT(skb);
747 skb->tail += len;
748 skb->len += len;
749 return tmp;
750}
751
752/**
753 * skb_put - add data to a buffer
754 * @skb: buffer to use
755 * @len: amount of data to add
756 *
757 * This function extends the used data area of the buffer. If this would
758 * exceed the total buffer size the kernel will panic. A pointer to the
759 * first byte of the extra data is returned.
760 */
761static inline unsigned char *skb_put(struct sk_buff *skb, unsigned int len)
762{
763 unsigned char *tmp = skb->tail;
764 SKB_LINEAR_ASSERT(skb);
765 skb->tail += len;
766 skb->len += len;
767 if (unlikely(skb->tail>skb->end))
768 skb_over_panic(skb, len, current_text_addr());
769 return tmp;
770}
771
772static inline unsigned char *__skb_push(struct sk_buff *skb, unsigned int len)
773{
774 skb->data -= len;
775 skb->len += len;
776 return skb->data;
777}
778
779/**
780 * skb_push - add data to the start of a buffer
781 * @skb: buffer to use
782 * @len: amount of data to add
783 *
784 * This function extends the used data area of the buffer at the buffer
785 * start. If this would exceed the total buffer headroom the kernel will
786 * panic. A pointer to the first byte of the extra data is returned.
787 */
788static inline unsigned char *skb_push(struct sk_buff *skb, unsigned int len)
789{
790 skb->data -= len;
791 skb->len += len;
792 if (unlikely(skb->data<skb->head))
793 skb_under_panic(skb, len, current_text_addr());
794 return skb->data;
795}
796
797static inline unsigned char *__skb_pull(struct sk_buff *skb, unsigned int len)
798{
799 skb->len -= len;
800 BUG_ON(skb->len < skb->data_len);
801 return skb->data += len;
802}
803
804/**
805 * skb_pull - remove data from the start of a buffer
806 * @skb: buffer to use
807 * @len: amount of data to remove
808 *
809 * This function removes data from the start of a buffer, returning
810 * the memory to the headroom. A pointer to the next data in the buffer
811 * is returned. Once the data has been pulled future pushes will overwrite
812 * the old data.
813 */
814static inline unsigned char *skb_pull(struct sk_buff *skb, unsigned int len)
815{
816 return unlikely(len > skb->len) ? NULL : __skb_pull(skb, len);
817}
818
819extern unsigned char *__pskb_pull_tail(struct sk_buff *skb, int delta);
820
821static inline unsigned char *__pskb_pull(struct sk_buff *skb, unsigned int len)
822{
823 if (len > skb_headlen(skb) &&
824 !__pskb_pull_tail(skb, len-skb_headlen(skb)))
825 return NULL;
826 skb->len -= len;
827 return skb->data += len;
828}
829
830static inline unsigned char *pskb_pull(struct sk_buff *skb, unsigned int len)
831{
832 return unlikely(len > skb->len) ? NULL : __pskb_pull(skb, len);
833}
834
835static inline int pskb_may_pull(struct sk_buff *skb, unsigned int len)
836{
837 if (likely(len <= skb_headlen(skb)))
838 return 1;
839 if (unlikely(len > skb->len))
840 return 0;
841 return __pskb_pull_tail(skb, len-skb_headlen(skb)) != NULL;
842}
843
844/**
845 * skb_headroom - bytes at buffer head
846 * @skb: buffer to check
847 *
848 * Return the number of bytes of free space at the head of an &sk_buff.
849 */
850static inline int skb_headroom(const struct sk_buff *skb)
851{
852 return skb->data - skb->head;
853}
854
855/**
856 * skb_tailroom - bytes at buffer end
857 * @skb: buffer to check
858 *
859 * Return the number of bytes of free space at the tail of an sk_buff
860 */
861static inline int skb_tailroom(const struct sk_buff *skb)
862{
863 return skb_is_nonlinear(skb) ? 0 : skb->end - skb->tail;
864}
865
866/**
867 * skb_reserve - adjust headroom
868 * @skb: buffer to alter
869 * @len: bytes to move
870 *
871 * Increase the headroom of an empty &sk_buff by reducing the tail
872 * room. This is only allowed for an empty buffer.
873 */
874static inline void skb_reserve(struct sk_buff *skb, unsigned int len)
875{
876 skb->data += len;
877 skb->tail += len;
878}
879
880/*
881 * CPUs often take a performance hit when accessing unaligned memory
882 * locations. The actual performance hit varies, it can be small if the
883 * hardware handles it or large if we have to take an exception and fix it
884 * in software.
885 *
886 * Since an ethernet header is 14 bytes network drivers often end up with
887 * the IP header at an unaligned offset. The IP header can be aligned by
888 * shifting the start of the packet by 2 bytes. Drivers should do this
889 * with:
890 *
891 * skb_reserve(NET_IP_ALIGN);
892 *
893 * The downside to this alignment of the IP header is that the DMA is now
894 * unaligned. On some architectures the cost of an unaligned DMA is high
895 * and this cost outweighs the gains made by aligning the IP header.
896 *
897 * Since this trade off varies between architectures, we allow NET_IP_ALIGN
898 * to be overridden.
899 */
900#ifndef NET_IP_ALIGN
901#define NET_IP_ALIGN 2
902#endif
903
904extern int ___pskb_trim(struct sk_buff *skb, unsigned int len, int realloc);
905
906static inline void __skb_trim(struct sk_buff *skb, unsigned int len)
907{
908 if (!skb->data_len) {
909 skb->len = len;
910 skb->tail = skb->data + len;
911 } else
912 ___pskb_trim(skb, len, 0);
913}
914
915/**
916 * skb_trim - remove end from a buffer
917 * @skb: buffer to alter
918 * @len: new length
919 *
920 * Cut the length of a buffer down by removing data from the tail. If
921 * the buffer is already under the length specified it is not modified.
922 */
923static inline void skb_trim(struct sk_buff *skb, unsigned int len)
924{
925 if (skb->len > len)
926 __skb_trim(skb, len);
927}
928
929
930static inline int __pskb_trim(struct sk_buff *skb, unsigned int len)
931{
932 if (!skb->data_len) {
933 skb->len = len;
934 skb->tail = skb->data+len;
935 return 0;
936 }
937 return ___pskb_trim(skb, len, 1);
938}
939
940static inline int pskb_trim(struct sk_buff *skb, unsigned int len)
941{
942 return (len < skb->len) ? __pskb_trim(skb, len) : 0;
943}
944
945/**
946 * skb_orphan - orphan a buffer
947 * @skb: buffer to orphan
948 *
949 * If a buffer currently has an owner then we call the owner's
950 * destructor function and make the @skb unowned. The buffer continues
951 * to exist but is no longer charged to its former owner.
952 */
953static inline void skb_orphan(struct sk_buff *skb)
954{
955 if (skb->destructor)
956 skb->destructor(skb);
957 skb->destructor = NULL;
958 skb->sk = NULL;
959}
960
961/**
962 * __skb_queue_purge - empty a list
963 * @list: list to empty
964 *
965 * Delete all buffers on an &sk_buff list. Each buffer is removed from
966 * the list and one reference dropped. This function does not take the
967 * list lock and the caller must hold the relevant locks to use it.
968 */
969extern void skb_queue_purge(struct sk_buff_head *list);
970static inline void __skb_queue_purge(struct sk_buff_head *list)
971{
972 struct sk_buff *skb;
973 while ((skb = __skb_dequeue(list)) != NULL)
974 kfree_skb(skb);
975}
976
977/**
978 * __dev_alloc_skb - allocate an skbuff for sending
979 * @length: length to allocate
980 * @gfp_mask: get_free_pages mask, passed to alloc_skb
981 *
982 * Allocate a new &sk_buff and assign it a usage count of one. The
983 * buffer has unspecified headroom built in. Users should allocate
984 * the headroom they think they need without accounting for the
985 * built in space. The built in space is used for optimisations.
986 *
987 * %NULL is returned in there is no free memory.
988 */
989#ifndef CONFIG_HAVE_ARCH_DEV_ALLOC_SKB
990static inline struct sk_buff *__dev_alloc_skb(unsigned int length,
991 int gfp_mask)
992{
993 struct sk_buff *skb = alloc_skb(length + 16, gfp_mask);
994 if (likely(skb))
995 skb_reserve(skb, 16);
996 return skb;
997}
998#else
999extern struct sk_buff *__dev_alloc_skb(unsigned int length, int gfp_mask);
1000#endif
1001
1002/**
1003 * dev_alloc_skb - allocate an skbuff for sending
1004 * @length: length to allocate
1005 *
1006 * Allocate a new &sk_buff and assign it a usage count of one. The
1007 * buffer has unspecified headroom built in. Users should allocate
1008 * the headroom they think they need without accounting for the
1009 * built in space. The built in space is used for optimisations.
1010 *
1011 * %NULL is returned in there is no free memory. Although this function
1012 * allocates memory it can be called from an interrupt.
1013 */
1014static inline struct sk_buff *dev_alloc_skb(unsigned int length)
1015{
1016 return __dev_alloc_skb(length, GFP_ATOMIC);
1017}
1018
1019/**
1020 * skb_cow - copy header of skb when it is required
1021 * @skb: buffer to cow
1022 * @headroom: needed headroom
1023 *
1024 * If the skb passed lacks sufficient headroom or its data part
1025 * is shared, data is reallocated. If reallocation fails, an error
1026 * is returned and original skb is not changed.
1027 *
1028 * The result is skb with writable area skb->head...skb->tail
1029 * and at least @headroom of space at head.
1030 */
1031static inline int skb_cow(struct sk_buff *skb, unsigned int headroom)
1032{
1033 int delta = (headroom > 16 ? headroom : 16) - skb_headroom(skb);
1034
1035 if (delta < 0)
1036 delta = 0;
1037
1038 if (delta || skb_cloned(skb))
1039 return pskb_expand_head(skb, (delta + 15) & ~15, 0, GFP_ATOMIC);
1040 return 0;
1041}
1042
1043/**
1044 * skb_padto - pad an skbuff up to a minimal size
1045 * @skb: buffer to pad
1046 * @len: minimal length
1047 *
1048 * Pads up a buffer to ensure the trailing bytes exist and are
1049 * blanked. If the buffer already contains sufficient data it
1050 * is untouched. Returns the buffer, which may be a replacement
1051 * for the original, or NULL for out of memory - in which case
1052 * the original buffer is still freed.
1053 */
1054
1055static inline struct sk_buff *skb_padto(struct sk_buff *skb, unsigned int len)
1056{
1057 unsigned int size = skb->len;
1058 if (likely(size >= len))
1059 return skb;
1060 return skb_pad(skb, len-size);
1061}
1062
1063static inline int skb_add_data(struct sk_buff *skb,
1064 char __user *from, int copy)
1065{
1066 const int off = skb->len;
1067
1068 if (skb->ip_summed == CHECKSUM_NONE) {
1069 int err = 0;
1070 unsigned int csum = csum_and_copy_from_user(from,
1071 skb_put(skb, copy),
1072 copy, 0, &err);
1073 if (!err) {
1074 skb->csum = csum_block_add(skb->csum, csum, off);
1075 return 0;
1076 }
1077 } else if (!copy_from_user(skb_put(skb, copy), from, copy))
1078 return 0;
1079
1080 __skb_trim(skb, off);
1081 return -EFAULT;
1082}
1083
1084static inline int skb_can_coalesce(struct sk_buff *skb, int i,
1085 struct page *page, int off)
1086{
1087 if (i) {
1088 struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[i - 1];
1089
1090 return page == frag->page &&
1091 off == frag->page_offset + frag->size;
1092 }
1093 return 0;
1094}
1095
1096/**
1097 * skb_linearize - convert paged skb to linear one
1098 * @skb: buffer to linarize
1099 * @gfp: allocation mode
1100 *
1101 * If there is no free memory -ENOMEM is returned, otherwise zero
1102 * is returned and the old skb data released.
1103 */
1104extern int __skb_linearize(struct sk_buff *skb, int gfp);
1105static inline int skb_linearize(struct sk_buff *skb, int gfp)
1106{
1107 return __skb_linearize(skb, gfp);
1108}
1109
1110/**
1111 * skb_postpull_rcsum - update checksum for received skb after pull
1112 * @skb: buffer to update
1113 * @start: start of data before pull
1114 * @len: length of data pulled
1115 *
1116 * After doing a pull on a received packet, you need to call this to
1117 * update the CHECKSUM_HW checksum, or set ip_summed to CHECKSUM_NONE
1118 * so that it can be recomputed from scratch.
1119 */
1120
1121static inline void skb_postpull_rcsum(struct sk_buff *skb,
1122 const void *start, int len)
1123{
1124 if (skb->ip_summed == CHECKSUM_HW)
1125 skb->csum = csum_sub(skb->csum, csum_partial(start, len, 0));
1126}
1127
1128/**
1129 * pskb_trim_rcsum - trim received skb and update checksum
1130 * @skb: buffer to trim
1131 * @len: new length
1132 *
1133 * This is exactly the same as pskb_trim except that it ensures the
1134 * checksum of received packets are still valid after the operation.
1135 */
1136
1137static inline int pskb_trim_rcsum(struct sk_buff *skb, unsigned int len)
1138{
1139 if (len >= skb->len)
1140 return 0;
1141 if (skb->ip_summed == CHECKSUM_HW)
1142 skb->ip_summed = CHECKSUM_NONE;
1143 return __pskb_trim(skb, len);
1144}
1145
1146static inline void *kmap_skb_frag(const skb_frag_t *frag)
1147{
1148#ifdef CONFIG_HIGHMEM
1149 BUG_ON(in_irq());
1150
1151 local_bh_disable();
1152#endif
1153 return kmap_atomic(frag->page, KM_SKB_DATA_SOFTIRQ);
1154}
1155
1156static inline void kunmap_skb_frag(void *vaddr)
1157{
1158 kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ);
1159#ifdef CONFIG_HIGHMEM
1160 local_bh_enable();
1161#endif
1162}
1163
1164#define skb_queue_walk(queue, skb) \
1165 for (skb = (queue)->next; \
1166 prefetch(skb->next), (skb != (struct sk_buff *)(queue)); \
1167 skb = skb->next)
1168
1169
1170extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
1171 int noblock, int *err);
1172extern unsigned int datagram_poll(struct file *file, struct socket *sock,
1173 struct poll_table_struct *wait);
1174extern int skb_copy_datagram_iovec(const struct sk_buff *from,
1175 int offset, struct iovec *to,
1176 int size);
1177extern int skb_copy_and_csum_datagram_iovec(const
1178 struct sk_buff *skb,
1179 int hlen,
1180 struct iovec *iov);
1181extern void skb_free_datagram(struct sock *sk, struct sk_buff *skb);
1182extern unsigned int skb_checksum(const struct sk_buff *skb, int offset,
1183 int len, unsigned int csum);
1184extern int skb_copy_bits(const struct sk_buff *skb, int offset,
1185 void *to, int len);
1186extern unsigned int skb_copy_and_csum_bits(const struct sk_buff *skb,
1187 int offset, u8 *to, int len,
1188 unsigned int csum);
1189extern void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to);
1190extern void skb_split(struct sk_buff *skb,
1191 struct sk_buff *skb1, const u32 len);
1192
1193static inline void *skb_header_pointer(const struct sk_buff *skb, int offset,
1194 int len, void *buffer)
1195{
1196 int hlen = skb_headlen(skb);
1197
1198 if (offset + len <= hlen)
1199 return skb->data + offset;
1200
1201 if (skb_copy_bits(skb, offset, buffer, len) < 0)
1202 return NULL;
1203
1204 return buffer;
1205}
1206
1207extern void skb_init(void);
1208extern void skb_add_mtu(int mtu);
1209
1210#ifdef CONFIG_NETFILTER
1211static inline void nf_conntrack_put(struct nf_conntrack *nfct)
1212{
1213 if (nfct && atomic_dec_and_test(&nfct->use))
1214 nfct->destroy(nfct);
1215}
1216static inline void nf_conntrack_get(struct nf_conntrack *nfct)
1217{
1218 if (nfct)
1219 atomic_inc(&nfct->use);
1220}
1221static inline void nf_reset(struct sk_buff *skb)
1222{
1223 nf_conntrack_put(skb->nfct);
1224 skb->nfct = NULL;
1225#ifdef CONFIG_NETFILTER_DEBUG
1226 skb->nf_debug = 0;
1227#endif
1228}
1229static inline void nf_reset_debug(struct sk_buff *skb)
1230{
1231#ifdef CONFIG_NETFILTER_DEBUG
1232 skb->nf_debug = 0;
1233#endif
1234}
1235
1236#ifdef CONFIG_BRIDGE_NETFILTER
1237static inline void nf_bridge_put(struct nf_bridge_info *nf_bridge)
1238{
1239 if (nf_bridge && atomic_dec_and_test(&nf_bridge->use))
1240 kfree(nf_bridge);
1241}
1242static inline void nf_bridge_get(struct nf_bridge_info *nf_bridge)
1243{
1244 if (nf_bridge)
1245 atomic_inc(&nf_bridge->use);
1246}
1247#endif /* CONFIG_BRIDGE_NETFILTER */
1248#else /* CONFIG_NETFILTER */
1249static inline void nf_reset(struct sk_buff *skb) {}
1250#endif /* CONFIG_NETFILTER */
1251
1252#endif /* __KERNEL__ */
1253#endif /* _LINUX_SKBUFF_H */
diff --git a/include/linux/slab.h b/include/linux/slab.h
new file mode 100644
index 000000000000..3e3c3ab8ff94
--- /dev/null
+++ b/include/linux/slab.h
@@ -0,0 +1,129 @@
1/*
2 * linux/mm/slab.h
3 * Written by Mark Hemment, 1996.
4 * (markhe@nextd.demon.co.uk)
5 */
6
7#ifndef _LINUX_SLAB_H
8#define _LINUX_SLAB_H
9
10#if defined(__KERNEL__)
11
12typedef struct kmem_cache_s kmem_cache_t;
13
14#include <linux/config.h> /* kmalloc_sizes.h needs CONFIG_ options */
15#include <linux/gfp.h>
16#include <linux/init.h>
17#include <linux/types.h>
18#include <asm/page.h> /* kmalloc_sizes.h needs PAGE_SIZE */
19#include <asm/cache.h> /* kmalloc_sizes.h needs L1_CACHE_BYTES */
20
21/* flags for kmem_cache_alloc() */
22#define SLAB_NOFS GFP_NOFS
23#define SLAB_NOIO GFP_NOIO
24#define SLAB_ATOMIC GFP_ATOMIC
25#define SLAB_USER GFP_USER
26#define SLAB_KERNEL GFP_KERNEL
27#define SLAB_DMA GFP_DMA
28
29#define SLAB_LEVEL_MASK GFP_LEVEL_MASK
30
31#define SLAB_NO_GROW __GFP_NO_GROW /* don't grow a cache */
32
33/* flags to pass to kmem_cache_create().
34 * The first 3 are only valid when the allocator as been build
35 * SLAB_DEBUG_SUPPORT.
36 */
37#define SLAB_DEBUG_FREE 0x00000100UL /* Peform (expensive) checks on free */
38#define SLAB_DEBUG_INITIAL 0x00000200UL /* Call constructor (as verifier) */
39#define SLAB_RED_ZONE 0x00000400UL /* Red zone objs in a cache */
40#define SLAB_POISON 0x00000800UL /* Poison objects */
41#define SLAB_NO_REAP 0x00001000UL /* never reap from the cache */
42#define SLAB_HWCACHE_ALIGN 0x00002000UL /* align objs on a h/w cache lines */
43#define SLAB_CACHE_DMA 0x00004000UL /* use GFP_DMA memory */
44#define SLAB_MUST_HWCACHE_ALIGN 0x00008000UL /* force alignment */
45#define SLAB_STORE_USER 0x00010000UL /* store the last owner for bug hunting */
46#define SLAB_RECLAIM_ACCOUNT 0x00020000UL /* track pages allocated to indicate
47 what is reclaimable later*/
48#define SLAB_PANIC 0x00040000UL /* panic if kmem_cache_create() fails */
49#define SLAB_DESTROY_BY_RCU 0x00080000UL /* defer freeing pages to RCU */
50
51/* flags passed to a constructor func */
52#define SLAB_CTOR_CONSTRUCTOR 0x001UL /* if not set, then deconstructor */
53#define SLAB_CTOR_ATOMIC 0x002UL /* tell constructor it can't sleep */
54#define SLAB_CTOR_VERIFY 0x004UL /* tell constructor it's a verify call */
55
56/* prototypes */
57extern void __init kmem_cache_init(void);
58
59extern kmem_cache_t *kmem_cache_create(const char *, size_t, size_t, unsigned long,
60 void (*)(void *, kmem_cache_t *, unsigned long),
61 void (*)(void *, kmem_cache_t *, unsigned long));
62extern int kmem_cache_destroy(kmem_cache_t *);
63extern int kmem_cache_shrink(kmem_cache_t *);
64extern void *kmem_cache_alloc(kmem_cache_t *, unsigned int __nocast);
65#ifdef CONFIG_NUMA
66extern void *kmem_cache_alloc_node(kmem_cache_t *, int);
67#else
68static inline void *kmem_cache_alloc_node(kmem_cache_t *cachep, int node)
69{
70 return kmem_cache_alloc(cachep, GFP_KERNEL);
71}
72#endif
73extern void kmem_cache_free(kmem_cache_t *, void *);
74extern unsigned int kmem_cache_size(kmem_cache_t *);
75
76/* Size description struct for general caches. */
77struct cache_sizes {
78 size_t cs_size;
79 kmem_cache_t *cs_cachep;
80 kmem_cache_t *cs_dmacachep;
81};
82extern struct cache_sizes malloc_sizes[];
83extern void *__kmalloc(size_t, unsigned int __nocast);
84
85static inline void *kmalloc(size_t size, unsigned int __nocast flags)
86{
87 if (__builtin_constant_p(size)) {
88 int i = 0;
89#define CACHE(x) \
90 if (size <= x) \
91 goto found; \
92 else \
93 i++;
94#include "kmalloc_sizes.h"
95#undef CACHE
96 {
97 extern void __you_cannot_kmalloc_that_much(void);
98 __you_cannot_kmalloc_that_much();
99 }
100found:
101 return kmem_cache_alloc((flags & GFP_DMA) ?
102 malloc_sizes[i].cs_dmacachep :
103 malloc_sizes[i].cs_cachep, flags);
104 }
105 return __kmalloc(size, flags);
106}
107
108extern void *kcalloc(size_t, size_t, unsigned int __nocast);
109extern void kfree(const void *);
110extern unsigned int ksize(const void *);
111
112extern int FASTCALL(kmem_cache_reap(int));
113extern int FASTCALL(kmem_ptr_validate(kmem_cache_t *cachep, void *ptr));
114
115/* System wide caches */
116extern kmem_cache_t *vm_area_cachep;
117extern kmem_cache_t *names_cachep;
118extern kmem_cache_t *files_cachep;
119extern kmem_cache_t *filp_cachep;
120extern kmem_cache_t *fs_cachep;
121extern kmem_cache_t *signal_cachep;
122extern kmem_cache_t *sighand_cachep;
123extern kmem_cache_t *bio_cachep;
124
125extern atomic_t slab_reclaim_pages;
126
127#endif /* __KERNEL__ */
128
129#endif /* _LINUX_SLAB_H */
diff --git a/include/linux/smb.h b/include/linux/smb.h
new file mode 100644
index 000000000000..b0162208c963
--- /dev/null
+++ b/include/linux/smb.h
@@ -0,0 +1,117 @@
1/*
2 * smb.h
3 *
4 * Copyright (C) 1995, 1996 by Paal-Kr. Engstad and Volker Lendecke
5 * Copyright (C) 1997 by Volker Lendecke
6 *
7 */
8
9#ifndef _LINUX_SMB_H
10#define _LINUX_SMB_H
11
12#include <linux/types.h>
13
14enum smb_protocol {
15 SMB_PROTOCOL_NONE,
16 SMB_PROTOCOL_CORE,
17 SMB_PROTOCOL_COREPLUS,
18 SMB_PROTOCOL_LANMAN1,
19 SMB_PROTOCOL_LANMAN2,
20 SMB_PROTOCOL_NT1
21};
22
23enum smb_case_hndl {
24 SMB_CASE_DEFAULT,
25 SMB_CASE_LOWER,
26 SMB_CASE_UPPER
27};
28
29struct smb_dskattr {
30 __u16 total;
31 __u16 allocblocks;
32 __u16 blocksize;
33 __u16 free;
34};
35
36struct smb_conn_opt {
37
38 /* The socket */
39 unsigned int fd;
40
41 enum smb_protocol protocol;
42 enum smb_case_hndl case_handling;
43
44 /* Connection-Options */
45
46 __u32 max_xmit;
47 __u16 server_uid;
48 __u16 tid;
49
50 /* The following are LANMAN 1.0 options */
51 __u16 secmode;
52 __u16 maxmux;
53 __u16 maxvcs;
54 __u16 rawmode;
55 __u32 sesskey;
56
57 /* The following are NT LM 0.12 options */
58 __u32 maxraw;
59 __u32 capabilities;
60 __s16 serverzone;
61};
62
63#ifdef __KERNEL__
64
65#define SMB_NLS_MAXNAMELEN 20
66struct smb_nls_codepage {
67 char local_name[SMB_NLS_MAXNAMELEN];
68 char remote_name[SMB_NLS_MAXNAMELEN];
69};
70
71
72#define SMB_MAXNAMELEN 255
73#define SMB_MAXPATHLEN 1024
74
75/*
76 * Contains all relevant data on a SMB networked file.
77 */
78struct smb_fattr {
79 __u16 attr;
80
81 unsigned long f_ino;
82 umode_t f_mode;
83 nlink_t f_nlink;
84 uid_t f_uid;
85 gid_t f_gid;
86 dev_t f_rdev;
87 loff_t f_size;
88 struct timespec f_atime;
89 struct timespec f_mtime;
90 struct timespec f_ctime;
91 unsigned long f_blksize;
92 unsigned long f_blocks;
93 int f_unix;
94};
95
96enum smb_conn_state {
97 CONN_VALID, /* everything's fine */
98 CONN_INVALID, /* Something went wrong, but did not
99 try to reconnect yet. */
100 CONN_RETRIED, /* Tried a reconnection, but was refused */
101 CONN_RETRYING /* Currently trying to reconnect */
102};
103
104#define SMB_SUPER_MAGIC 0x517B
105
106#define SMB_HEADER_LEN 37 /* includes everything up to, but not
107 * including smb_bcc */
108
109#define SMB_INITIAL_PACKET_SIZE 4000
110#define SMB_MAX_PACKET_SIZE 32768
111
112/* reserve this much space for trans2 parameters. Shouldn't have to be more
113 than 10 or so, but OS/2 seems happier like this. */
114#define SMB_TRANS2_MAX_PARAM 64
115
116#endif
117#endif
diff --git a/include/linux/smb_fs.h b/include/linux/smb_fs.h
new file mode 100644
index 000000000000..c4153120ade6
--- /dev/null
+++ b/include/linux/smb_fs.h
@@ -0,0 +1,204 @@
1/*
2 * smb_fs.h
3 *
4 * Copyright (C) 1995 by Paal-Kr. Engstad and Volker Lendecke
5 * Copyright (C) 1997 by Volker Lendecke
6 *
7 */
8
9#ifndef _LINUX_SMB_FS_H
10#define _LINUX_SMB_FS_H
11
12#include <linux/smb.h>
13#include <linux/smb_fs_i.h>
14#include <linux/smb_fs_sb.h>
15
16/*
17 * ioctl commands
18 */
19#define SMB_IOC_GETMOUNTUID _IOR('u', 1, __kernel_old_uid_t)
20#define SMB_IOC_NEWCONN _IOW('u', 2, struct smb_conn_opt)
21
22/* __kernel_uid_t can never change, so we have to use __kernel_uid32_t */
23#define SMB_IOC_GETMOUNTUID32 _IOR('u', 3, __kernel_uid32_t)
24
25
26#ifdef __KERNEL__
27
28#include <linux/fs.h>
29#include <linux/pagemap.h>
30#include <linux/vmalloc.h>
31#include <linux/smb_mount.h>
32#include <asm/unaligned.h>
33
34static inline struct smb_sb_info *SMB_SB(struct super_block *sb)
35{
36 return sb->s_fs_info;
37}
38
39static inline struct smb_inode_info *SMB_I(struct inode *inode)
40{
41 return container_of(inode, struct smb_inode_info, vfs_inode);
42}
43
44/* macro names are short for word, double-word, long value (?) */
45#define WVAL(buf,pos) \
46 (le16_to_cpu(get_unaligned((u16 *)((u8 *)(buf) + (pos)))))
47#define DVAL(buf,pos) \
48 (le32_to_cpu(get_unaligned((u32 *)((u8 *)(buf) + (pos)))))
49#define LVAL(buf,pos) \
50 (le64_to_cpu(get_unaligned((u64 *)((u8 *)(buf) + (pos)))))
51#define WSET(buf,pos,val) \
52 put_unaligned(cpu_to_le16((u16)(val)), (u16 *)((u8 *)(buf) + (pos)))
53#define DSET(buf,pos,val) \
54 put_unaligned(cpu_to_le32((u32)(val)), (u32 *)((u8 *)(buf) + (pos)))
55#define LSET(buf,pos,val) \
56 put_unaligned(cpu_to_le64((u64)(val)), (u64 *)((u8 *)(buf) + (pos)))
57
58/* where to find the base of the SMB packet proper */
59#define smb_base(buf) ((u8 *)(((u8 *)(buf))+4))
60
61#ifdef DEBUG_SMB_MALLOC
62
63#include <linux/slab.h>
64
65extern int smb_malloced;
66extern int smb_current_vmalloced;
67extern int smb_current_kmalloced;
68
69static inline void *
70smb_vmalloc(unsigned int size)
71{
72 smb_malloced += 1;
73 smb_current_vmalloced += 1;
74 return vmalloc(size);
75}
76
77static inline void
78smb_vfree(void *obj)
79{
80 smb_current_vmalloced -= 1;
81 vfree(obj);
82}
83
84static inline void *
85smb_kmalloc(size_t size, int flags)
86{
87 smb_malloced += 1;
88 smb_current_kmalloced += 1;
89 return kmalloc(size, flags);
90}
91
92static inline void
93smb_kfree(void *obj)
94{
95 smb_current_kmalloced -= 1;
96 kfree(obj);
97}
98
99#else /* DEBUG_SMB_MALLOC */
100
101#define smb_kmalloc(s,p) kmalloc(s,p)
102#define smb_kfree(o) kfree(o)
103#define smb_vmalloc(s) vmalloc(s)
104#define smb_vfree(o) vfree(o)
105
106#endif /* DEBUG_SMB_MALLOC */
107
108/*
109 * Flags for the in-memory inode
110 */
111#define SMB_F_LOCALWRITE 0x02 /* file modified locally */
112
113
114/* NT1 protocol capability bits */
115#define SMB_CAP_RAW_MODE 0x00000001
116#define SMB_CAP_MPX_MODE 0x00000002
117#define SMB_CAP_UNICODE 0x00000004
118#define SMB_CAP_LARGE_FILES 0x00000008
119#define SMB_CAP_NT_SMBS 0x00000010
120#define SMB_CAP_RPC_REMOTE_APIS 0x00000020
121#define SMB_CAP_STATUS32 0x00000040
122#define SMB_CAP_LEVEL_II_OPLOCKS 0x00000080
123#define SMB_CAP_LOCK_AND_READ 0x00000100
124#define SMB_CAP_NT_FIND 0x00000200
125#define SMB_CAP_DFS 0x00001000
126#define SMB_CAP_LARGE_READX 0x00004000
127#define SMB_CAP_LARGE_WRITEX 0x00008000
128#define SMB_CAP_UNIX 0x00800000 /* unofficial ... */
129
130
131/*
132 * This is the time we allow an inode, dentry or dir cache to live. It is bad
133 * for performance to have shorter ttl on an inode than on the cache. It can
134 * cause refresh on each inode for a dir listing ... one-by-one
135 */
136#define SMB_MAX_AGE(server) (((server)->mnt->ttl * HZ) / 1000)
137
138static inline void
139smb_age_dentry(struct smb_sb_info *server, struct dentry *dentry)
140{
141 dentry->d_time = jiffies - SMB_MAX_AGE(server);
142}
143
144struct smb_cache_head {
145 time_t mtime; /* unused */
146 unsigned long time; /* cache age */
147 unsigned long end; /* last valid fpos in cache */
148 int eof;
149};
150
151#define SMB_DIRCACHE_SIZE ((int)(PAGE_CACHE_SIZE/sizeof(struct dentry *)))
152union smb_dir_cache {
153 struct smb_cache_head head;
154 struct dentry *dentry[SMB_DIRCACHE_SIZE];
155};
156
157#define SMB_FIRSTCACHE_SIZE ((int)((SMB_DIRCACHE_SIZE * \
158 sizeof(struct dentry *) - sizeof(struct smb_cache_head)) / \
159 sizeof(struct dentry *)))
160
161#define SMB_DIRCACHE_START (SMB_DIRCACHE_SIZE - SMB_FIRSTCACHE_SIZE)
162
163struct smb_cache_control {
164 struct smb_cache_head head;
165 struct page *page;
166 union smb_dir_cache *cache;
167 unsigned long fpos, ofs;
168 int filled, valid, idx;
169};
170
171#define SMB_OPS_NUM_STATIC 5
172struct smb_ops {
173 int (*read)(struct inode *inode, loff_t offset, int count,
174 char *data);
175 int (*write)(struct inode *inode, loff_t offset, int count, const
176 char *data);
177 int (*readdir)(struct file *filp, void *dirent, filldir_t filldir,
178 struct smb_cache_control *ctl);
179
180 int (*getattr)(struct smb_sb_info *server, struct dentry *dir,
181 struct smb_fattr *fattr);
182 /* int (*setattr)(...); */ /* setattr is really icky! */
183
184 int (*truncate)(struct inode *inode, loff_t length);
185
186
187 /* --- --- --- end of "static" entries --- --- --- */
188
189 int (*convert)(unsigned char *output, int olen,
190 const unsigned char *input, int ilen,
191 struct nls_table *nls_from,
192 struct nls_table *nls_to);
193};
194
195static inline int
196smb_is_open(struct inode *i)
197{
198 return (SMB_I(i)->open == server_from_inode(i)->generation);
199}
200
201extern void smb_install_null_ops(struct smb_ops *);
202#endif /* __KERNEL__ */
203
204#endif /* _LINUX_SMB_FS_H */
diff --git a/include/linux/smb_fs_i.h b/include/linux/smb_fs_i.h
new file mode 100644
index 000000000000..8516954a5141
--- /dev/null
+++ b/include/linux/smb_fs_i.h
@@ -0,0 +1,39 @@
1/*
2 * smb_fs_i.h
3 *
4 * Copyright (C) 1995 by Paal-Kr. Engstad and Volker Lendecke
5 * Copyright (C) 1997 by Volker Lendecke
6 *
7 */
8
9#ifndef _LINUX_SMB_FS_I
10#define _LINUX_SMB_FS_I
11
12#ifdef __KERNEL__
13#include <linux/types.h>
14#include <linux/fs.h>
15
16/*
17 * smb fs inode data (in memory only)
18 */
19struct smb_inode_info {
20
21 /*
22 * file handles are local to a connection. A file is open if
23 * (open == generation).
24 */
25 unsigned int open; /* open generation */
26 __u16 fileid; /* What id to handle a file with? */
27 __u16 attr; /* Attribute fields, DOS value */
28
29 __u16 access; /* Access mode */
30 __u16 flags;
31 unsigned long oldmtime; /* last time refreshed */
32 unsigned long closed; /* timestamp when closed */
33 unsigned openers; /* number of fileid users */
34
35 struct inode vfs_inode; /* must be at the end */
36};
37
38#endif
39#endif
diff --git a/include/linux/smb_fs_sb.h b/include/linux/smb_fs_sb.h
new file mode 100644
index 000000000000..5b4ae2cc445c
--- /dev/null
+++ b/include/linux/smb_fs_sb.h
@@ -0,0 +1,101 @@
1/*
2 * smb_fs_sb.h
3 *
4 * Copyright (C) 1995 by Paal-Kr. Engstad and Volker Lendecke
5 * Copyright (C) 1997 by Volker Lendecke
6 *
7 */
8
9#ifndef _SMB_FS_SB
10#define _SMB_FS_SB
11
12#ifdef __KERNEL__
13
14#include <linux/types.h>
15#include <linux/smb.h>
16
17/*
18 * Upper limit on the total number of active smb_request structs.
19 */
20#define MAX_REQUEST_HARD 256
21
22enum smb_receive_state {
23 SMB_RECV_START, /* No data read, looking for length + sig */
24 SMB_RECV_HEADER, /* Reading the header data */
25 SMB_RECV_HCOMPLETE, /* Done with the header */
26 SMB_RECV_PARAM, /* Reading parameter words */
27 SMB_RECV_DATA, /* Reading data bytes */
28 SMB_RECV_END, /* End of request */
29 SMB_RECV_DROP, /* Dropping this SMB */
30 SMB_RECV_REQUEST, /* Received a request and not a reply */
31};
32
33/* structure access macros */
34#define server_from_inode(inode) SMB_SB((inode)->i_sb)
35#define server_from_dentry(dentry) SMB_SB((dentry)->d_sb)
36#define SB_of(server) ((server)->super_block)
37
38struct smb_sb_info {
39 /* List of all smbfs superblocks */
40 struct list_head entry;
41
42 enum smb_conn_state state;
43 struct file * sock_file;
44 int conn_error;
45 enum smb_receive_state rstate;
46
47 atomic_t nr_requests;
48 struct list_head xmitq;
49 struct list_head recvq;
50 u16 mid;
51
52 struct smb_mount_data_kernel *mnt;
53
54 /* Connections are counted. Each time a new socket arrives,
55 * generation is incremented.
56 */
57 unsigned int generation;
58 pid_t conn_pid;
59 struct smb_conn_opt opt;
60 wait_queue_head_t conn_wq;
61 int conn_complete;
62 struct semaphore sem;
63
64 unsigned char header[SMB_HEADER_LEN + 20*2 + 2];
65 u32 header_len;
66 u32 smb_len;
67 u32 smb_read;
68
69 /* We use our own data_ready callback, but need the original one */
70 void *data_ready;
71
72 /* nls pointers for codepage conversions */
73 struct nls_table *remote_nls;
74 struct nls_table *local_nls;
75
76 struct smb_ops *ops;
77
78 struct super_block *super_block;
79};
80
81static inline int
82smb_lock_server_interruptible(struct smb_sb_info *server)
83{
84 return down_interruptible(&(server->sem));
85}
86
87static inline void
88smb_lock_server(struct smb_sb_info *server)
89{
90 down(&(server->sem));
91}
92
93static inline void
94smb_unlock_server(struct smb_sb_info *server)
95{
96 up(&(server->sem));
97}
98
99#endif /* __KERNEL__ */
100
101#endif
diff --git a/include/linux/smb_mount.h b/include/linux/smb_mount.h
new file mode 100644
index 000000000000..d10f00cb5703
--- /dev/null
+++ b/include/linux/smb_mount.h
@@ -0,0 +1,65 @@
1/*
2 * smb_mount.h
3 *
4 * Copyright (C) 1995, 1996 by Paal-Kr. Engstad and Volker Lendecke
5 * Copyright (C) 1997 by Volker Lendecke
6 *
7 */
8
9#ifndef _LINUX_SMB_MOUNT_H
10#define _LINUX_SMB_MOUNT_H
11
12#include <linux/types.h>
13
14#define SMB_MOUNT_VERSION 6
15
16struct smb_mount_data {
17 int version;
18 __kernel_uid_t mounted_uid; /* Who may umount() this filesystem? */
19 __kernel_uid_t uid;
20 __kernel_gid_t gid;
21 __kernel_mode_t file_mode;
22 __kernel_mode_t dir_mode;
23};
24
25
26#ifdef __KERNEL__
27
28/* "vers" in big-endian */
29#define SMB_MOUNT_ASCII 0x76657273
30
31#define SMB_MOUNT_OLDVERSION 6
32#undef SMB_MOUNT_VERSION
33#define SMB_MOUNT_VERSION 7
34
35/* flags */
36#define SMB_MOUNT_WIN95 0x0001 /* Win 95 server */
37#define SMB_MOUNT_OLDATTR 0x0002 /* Use core getattr (Win 95 speedup) */
38#define SMB_MOUNT_DIRATTR 0x0004 /* Use find_first for getattr */
39#define SMB_MOUNT_CASE 0x0008 /* Be case sensitive */
40#define SMB_MOUNT_UNICODE 0x0010 /* Server talks unicode */
41#define SMB_MOUNT_UID 0x0020 /* Use user specified uid */
42#define SMB_MOUNT_GID 0x0040 /* Use user specified gid */
43#define SMB_MOUNT_FMODE 0x0080 /* Use user specified file mode */
44#define SMB_MOUNT_DMODE 0x0100 /* Use user specified dir mode */
45
46struct smb_mount_data_kernel {
47 int version;
48
49 uid_t mounted_uid; /* Who may umount() this filesystem? */
50 uid_t uid;
51 gid_t gid;
52 mode_t file_mode;
53 mode_t dir_mode;
54
55 u32 flags;
56
57 /* maximum age in jiffies (inode, dentry and dircache) */
58 int ttl;
59
60 struct smb_nls_codepage codepage;
61};
62
63#endif
64
65#endif
diff --git a/include/linux/smbno.h b/include/linux/smbno.h
new file mode 100644
index 000000000000..f99e02d9ffe2
--- /dev/null
+++ b/include/linux/smbno.h
@@ -0,0 +1,363 @@
1#ifndef _SMBNO_H_
2#define _SMBNO_H_
3
4/* these define the attribute byte as seen by DOS */
5#define aRONLY (1L<<0)
6#define aHIDDEN (1L<<1)
7#define aSYSTEM (1L<<2)
8#define aVOLID (1L<<3)
9#define aDIR (1L<<4)
10#define aARCH (1L<<5)
11
12/* error classes */
13#define SUCCESS 0 /* The request was successful. */
14#define ERRDOS 0x01 /* Error is from the core DOS operating system set. */
15#define ERRSRV 0x02 /* Error is generated by the server network file manager.*/
16#define ERRHRD 0x03 /* Error is an hardware error. */
17#define ERRCMD 0xFF /* Command was not in the "SMB" format. */
18
19/* SMB X/Open error codes for the ERRdos error class */
20
21#define ERRbadfunc 1 /* Invalid function (or system call) */
22#define ERRbadfile 2 /* File not found (pathname error) */
23#define ERRbadpath 3 /* Directory not found */
24#define ERRnofids 4 /* Too many open files */
25#define ERRnoaccess 5 /* Access denied */
26#define ERRbadfid 6 /* Invalid fid */
27#define ERRbadmcb 7 /* Memory control blocks destroyed */
28#define ERRnomem 8 /* Out of memory */
29#define ERRbadmem 9 /* Invalid memory block address */
30#define ERRbadenv 10 /* Invalid environment */
31#define ERRbadformat 11 /* Invalid format */
32#define ERRbadaccess 12 /* Invalid open mode */
33#define ERRbaddata 13 /* Invalid data (only from ioctl call) */
34#define ERRres 14 /* reserved */
35#define ERRbaddrive 15 /* Invalid drive */
36#define ERRremcd 16 /* Attempt to delete current directory */
37#define ERRdiffdevice 17 /* rename/move across different filesystems */
38#define ERRnofiles 18 /* no more files found in file search */
39#define ERRbadshare 32 /* Share mode on file conflict with open mode */
40#define ERRlock 33 /* Lock request conflicts with existing lock */
41#define ERRfilexists 80 /* File in operation already exists */
42#define ERRbadpipe 230 /* Named pipe invalid */
43#define ERRpipebusy 231 /* All instances of pipe are busy */
44#define ERRpipeclosing 232 /* named pipe close in progress */
45#define ERRnotconnected 233 /* No process on other end of named pipe */
46#define ERRmoredata 234 /* More data to be returned */
47
48#define ERROR_INVALID_PARAMETER 87
49#define ERROR_DISK_FULL 112
50#define ERROR_INVALID_NAME 123
51#define ERROR_DIR_NOT_EMPTY 145
52#define ERROR_NOT_LOCKED 158
53#define ERROR_ALREADY_EXISTS 183 /* see also 80 ? */
54#define ERROR_EAS_DIDNT_FIT 275 /* Extended attributes didn't fit */
55#define ERROR_EAS_NOT_SUPPORTED 282 /* Extended attributes not supported */
56
57/* Error codes for the ERRSRV class */
58
59#define ERRerror 1 /* Non specific error code */
60#define ERRbadpw 2 /* Bad password */
61#define ERRbadtype 3 /* reserved */
62#define ERRaccess 4 /* No permissions to do the requested operation */
63#define ERRinvnid 5 /* tid invalid */
64#define ERRinvnetname 6 /* Invalid servername */
65#define ERRinvdevice 7 /* Invalid device */
66#define ERRqfull 49 /* Print queue full */
67#define ERRqtoobig 50 /* Queued item too big */
68#define ERRinvpfid 52 /* Invalid print file in smb_fid */
69#define ERRsmbcmd 64 /* Unrecognised command */
70#define ERRsrverror 65 /* smb server internal error */
71#define ERRfilespecs 67 /* fid and pathname invalid combination */
72#define ERRbadlink 68 /* reserved */
73#define ERRbadpermits 69 /* Access specified for a file is not valid */
74#define ERRbadpid 70 /* reserved */
75#define ERRsetattrmode 71 /* attribute mode invalid */
76#define ERRpaused 81 /* Message server paused */
77#define ERRmsgoff 82 /* Not receiving messages */
78#define ERRnoroom 83 /* No room for message */
79#define ERRrmuns 87 /* too many remote usernames */
80#define ERRtimeout 88 /* operation timed out */
81#define ERRnoresource 89 /* No resources currently available for request. */
82#define ERRtoomanyuids 90 /* too many userids */
83#define ERRbaduid 91 /* bad userid */
84#define ERRuseMPX 250 /* temporarily unable to use raw mode, use MPX mode */
85#define ERRuseSTD 251 /* temporarily unable to use raw mode, use std.mode */
86#define ERRcontMPX 252 /* resume MPX mode */
87#define ERRbadPW /* reserved */
88#define ERRnosupport 0xFFFF
89
90/* Error codes for the ERRHRD class */
91
92#define ERRnowrite 19 /* read only media */
93#define ERRbadunit 20 /* Unknown device */
94#define ERRnotready 21 /* Drive not ready */
95#define ERRbadcmd 22 /* Unknown command */
96#define ERRdata 23 /* Data (CRC) error */
97#define ERRbadreq 24 /* Bad request structure length */
98#define ERRseek 25
99#define ERRbadmedia 26
100#define ERRbadsector 27
101#define ERRnopaper 28
102#define ERRwrite 29 /* write fault */
103#define ERRread 30 /* read fault */
104#define ERRgeneral 31 /* General hardware failure */
105#define ERRwrongdisk 34
106#define ERRFCBunavail 35
107#define ERRsharebufexc 36 /* share buffer exceeded */
108#define ERRdiskfull 39
109
110/*
111 * Access modes when opening a file
112 */
113#define SMB_ACCMASK 0x0003
114#define SMB_O_RDONLY 0x0000
115#define SMB_O_WRONLY 0x0001
116#define SMB_O_RDWR 0x0002
117
118/* offsets into message for common items */
119#define smb_com 8
120#define smb_rcls 9
121#define smb_reh 10
122#define smb_err 11
123#define smb_flg 13
124#define smb_flg2 14
125#define smb_reb 13
126#define smb_tid 28
127#define smb_pid 30
128#define smb_uid 32
129#define smb_mid 34
130#define smb_wct 36
131#define smb_vwv 37
132#define smb_vwv0 37
133#define smb_vwv1 39
134#define smb_vwv2 41
135#define smb_vwv3 43
136#define smb_vwv4 45
137#define smb_vwv5 47
138#define smb_vwv6 49
139#define smb_vwv7 51
140#define smb_vwv8 53
141#define smb_vwv9 55
142#define smb_vwv10 57
143#define smb_vwv11 59
144#define smb_vwv12 61
145#define smb_vwv13 63
146#define smb_vwv14 65
147
148/* these are the trans2 sub fields for primary requests */
149#define smb_tpscnt smb_vwv0
150#define smb_tdscnt smb_vwv1
151#define smb_mprcnt smb_vwv2
152#define smb_mdrcnt smb_vwv3
153#define smb_msrcnt smb_vwv4
154#define smb_flags smb_vwv5
155#define smb_timeout smb_vwv6
156#define smb_pscnt smb_vwv9
157#define smb_psoff smb_vwv10
158#define smb_dscnt smb_vwv11
159#define smb_dsoff smb_vwv12
160#define smb_suwcnt smb_vwv13
161#define smb_setup smb_vwv14
162#define smb_setup0 smb_setup
163#define smb_setup1 (smb_setup+2)
164#define smb_setup2 (smb_setup+4)
165
166/* these are for the secondary requests */
167#define smb_spscnt smb_vwv2
168#define smb_spsoff smb_vwv3
169#define smb_spsdisp smb_vwv4
170#define smb_sdscnt smb_vwv5
171#define smb_sdsoff smb_vwv6
172#define smb_sdsdisp smb_vwv7
173#define smb_sfid smb_vwv8
174
175/* and these for responses */
176#define smb_tprcnt smb_vwv0
177#define smb_tdrcnt smb_vwv1
178#define smb_prcnt smb_vwv3
179#define smb_proff smb_vwv4
180#define smb_prdisp smb_vwv5
181#define smb_drcnt smb_vwv6
182#define smb_droff smb_vwv7
183#define smb_drdisp smb_vwv8
184
185/* the complete */
186#define SMBmkdir 0x00 /* create directory */
187#define SMBrmdir 0x01 /* delete directory */
188#define SMBopen 0x02 /* open file */
189#define SMBcreate 0x03 /* create file */
190#define SMBclose 0x04 /* close file */
191#define SMBflush 0x05 /* flush file */
192#define SMBunlink 0x06 /* delete file */
193#define SMBmv 0x07 /* rename file */
194#define SMBgetatr 0x08 /* get file attributes */
195#define SMBsetatr 0x09 /* set file attributes */
196#define SMBread 0x0A /* read from file */
197#define SMBwrite 0x0B /* write to file */
198#define SMBlock 0x0C /* lock byte range */
199#define SMBunlock 0x0D /* unlock byte range */
200#define SMBctemp 0x0E /* create temporary file */
201#define SMBmknew 0x0F /* make new file */
202#define SMBchkpth 0x10 /* check directory path */
203#define SMBexit 0x11 /* process exit */
204#define SMBlseek 0x12 /* seek */
205#define SMBtcon 0x70 /* tree connect */
206#define SMBtconX 0x75 /* tree connect and X*/
207#define SMBtdis 0x71 /* tree disconnect */
208#define SMBnegprot 0x72 /* negotiate protocol */
209#define SMBdskattr 0x80 /* get disk attributes */
210#define SMBsearch 0x81 /* search directory */
211#define SMBsplopen 0xC0 /* open print spool file */
212#define SMBsplwr 0xC1 /* write to print spool file */
213#define SMBsplclose 0xC2 /* close print spool file */
214#define SMBsplretq 0xC3 /* return print queue */
215#define SMBsends 0xD0 /* send single block message */
216#define SMBsendb 0xD1 /* send broadcast message */
217#define SMBfwdname 0xD2 /* forward user name */
218#define SMBcancelf 0xD3 /* cancel forward */
219#define SMBgetmac 0xD4 /* get machine name */
220#define SMBsendstrt 0xD5 /* send start of multi-block message */
221#define SMBsendend 0xD6 /* send end of multi-block message */
222#define SMBsendtxt 0xD7 /* send text of multi-block message */
223
224/* Core+ protocol */
225#define SMBlockread 0x13 /* Lock a range and read */
226#define SMBwriteunlock 0x14 /* Unlock a range then write */
227#define SMBreadbraw 0x1a /* read a block of data with no smb header */
228#define SMBwritebraw 0x1d /* write a block of data with no smb header */
229#define SMBwritec 0x20 /* secondary write request */
230#define SMBwriteclose 0x2c /* write a file then close it */
231
232/* dos extended protocol */
233#define SMBreadBraw 0x1A /* read block raw */
234#define SMBreadBmpx 0x1B /* read block multiplexed */
235#define SMBreadBs 0x1C /* read block (secondary response) */
236#define SMBwriteBraw 0x1D /* write block raw */
237#define SMBwriteBmpx 0x1E /* write block multiplexed */
238#define SMBwriteBs 0x1F /* write block (secondary request) */
239#define SMBwriteC 0x20 /* write complete response */
240#define SMBsetattrE 0x22 /* set file attributes expanded */
241#define SMBgetattrE 0x23 /* get file attributes expanded */
242#define SMBlockingX 0x24 /* lock/unlock byte ranges and X */
243#define SMBtrans 0x25 /* transaction - name, bytes in/out */
244#define SMBtranss 0x26 /* transaction (secondary request/response) */
245#define SMBioctl 0x27 /* IOCTL */
246#define SMBioctls 0x28 /* IOCTL (secondary request/response) */
247#define SMBcopy 0x29 /* copy */
248#define SMBmove 0x2A /* move */
249#define SMBecho 0x2B /* echo */
250#define SMBopenX 0x2D /* open and X */
251#define SMBreadX 0x2E /* read and X */
252#define SMBwriteX 0x2F /* write and X */
253#define SMBsesssetupX 0x73 /* Session Set Up & X (including User Logon) */
254#define SMBtconX 0x75 /* tree connect and X */
255#define SMBffirst 0x82 /* find first */
256#define SMBfunique 0x83 /* find unique */
257#define SMBfclose 0x84 /* find close */
258#define SMBinvalid 0xFE /* invalid command */
259
260
261/* Extended 2.0 protocol */
262#define SMBtrans2 0x32 /* TRANS2 protocol set */
263#define SMBtranss2 0x33 /* TRANS2 protocol set, secondary command */
264#define SMBfindclose 0x34 /* Terminate a TRANSACT2_FINDFIRST */
265#define SMBfindnclose 0x35 /* Terminate a TRANSACT2_FINDNOTIFYFIRST */
266#define SMBulogoffX 0x74 /* user logoff */
267
268/* these are the TRANS2 sub commands */
269#define TRANSACT2_OPEN 0
270#define TRANSACT2_FINDFIRST 1
271#define TRANSACT2_FINDNEXT 2
272#define TRANSACT2_QFSINFO 3
273#define TRANSACT2_SETFSINFO 4
274#define TRANSACT2_QPATHINFO 5
275#define TRANSACT2_SETPATHINFO 6
276#define TRANSACT2_QFILEINFO 7
277#define TRANSACT2_SETFILEINFO 8
278#define TRANSACT2_FSCTL 9
279#define TRANSACT2_IOCTL 10
280#define TRANSACT2_FINDNOTIFYFIRST 11
281#define TRANSACT2_FINDNOTIFYNEXT 12
282#define TRANSACT2_MKDIR 13
283
284/* Information Levels - Shared? */
285#define SMB_INFO_STANDARD 1
286#define SMB_INFO_QUERY_EA_SIZE 2
287#define SMB_INFO_QUERY_EAS_FROM_LIST 3
288#define SMB_INFO_QUERY_ALL_EAS 4
289#define SMB_INFO_IS_NAME_VALID 6
290
291/* Information Levels - TRANSACT2_FINDFIRST */
292#define SMB_FIND_FILE_DIRECTORY_INFO 0x101
293#define SMB_FIND_FILE_FULL_DIRECTORY_INFO 0x102
294#define SMB_FIND_FILE_NAMES_INFO 0x103
295#define SMB_FIND_FILE_BOTH_DIRECTORY_INFO 0x104
296
297/* Information Levels - TRANSACT2_QPATHINFO */
298#define SMB_QUERY_FILE_BASIC_INFO 0x101
299#define SMB_QUERY_FILE_STANDARD_INFO 0x102
300#define SMB_QUERY_FILE_EA_INFO 0x103
301#define SMB_QUERY_FILE_NAME_INFO 0x104
302#define SMB_QUERY_FILE_ALL_INFO 0x107
303#define SMB_QUERY_FILE_ALT_NAME_INFO 0x108
304#define SMB_QUERY_FILE_STREAM_INFO 0x109
305#define SMB_QUERY_FILE_COMPRESSION_INFO 0x10b
306
307/* Information Levels - TRANSACT2_SETFILEINFO */
308#define SMB_SET_FILE_BASIC_INFO 0x101
309#define SMB_SET_FILE_DISPOSITION_INFO 0x102
310#define SMB_SET_FILE_ALLOCATION_INFO 0x103
311#define SMB_SET_FILE_END_OF_FILE_INFO 0x104
312
313/* smb_flg field flags */
314#define SMB_FLAGS_SUPPORT_LOCKREAD 0x01
315#define SMB_FLAGS_CLIENT_BUF_AVAIL 0x02
316#define SMB_FLAGS_RESERVED 0x04
317#define SMB_FLAGS_CASELESS_PATHNAMES 0x08
318#define SMB_FLAGS_CANONICAL_PATHNAMES 0x10
319#define SMB_FLAGS_REQUEST_OPLOCK 0x20
320#define SMB_FLAGS_REQUEST_BATCH_OPLOCK 0x40
321#define SMB_FLAGS_REPLY 0x80
322
323/* smb_flg2 field flags (samba-2.2.0/source/include/smb.h) */
324#define SMB_FLAGS2_LONG_PATH_COMPONENTS 0x0001
325#define SMB_FLAGS2_EXTENDED_ATTRIBUTES 0x0002
326#define SMB_FLAGS2_DFS_PATHNAMES 0x1000
327#define SMB_FLAGS2_READ_PERMIT_NO_EXECUTE 0x2000
328#define SMB_FLAGS2_32_BIT_ERROR_CODES 0x4000
329#define SMB_FLAGS2_UNICODE_STRINGS 0x8000
330
331
332/*
333 * UNIX stuff (from samba trans2.h)
334 */
335#define MIN_UNIX_INFO_LEVEL 0x200
336#define MAX_UNIX_INFO_LEVEL 0x2FF
337#define SMB_FIND_FILE_UNIX 0x202
338#define SMB_QUERY_FILE_UNIX_BASIC 0x200
339#define SMB_QUERY_FILE_UNIX_LINK 0x201
340#define SMB_QUERY_FILE_UNIX_HLINK 0x202
341#define SMB_SET_FILE_UNIX_BASIC 0x200
342#define SMB_SET_FILE_UNIX_LINK 0x201
343#define SMB_SET_FILE_UNIX_HLINK 0x203
344#define SMB_QUERY_CIFS_UNIX_INFO 0x200
345
346/* values which means "don't change it" */
347#define SMB_MODE_NO_CHANGE 0xFFFFFFFF
348#define SMB_UID_NO_CHANGE 0xFFFFFFFF
349#define SMB_GID_NO_CHANGE 0xFFFFFFFF
350#define SMB_TIME_NO_CHANGE 0xFFFFFFFFFFFFFFFFULL
351#define SMB_SIZE_NO_CHANGE 0xFFFFFFFFFFFFFFFFULL
352
353/* UNIX filetype mappings. */
354#define UNIX_TYPE_FILE 0
355#define UNIX_TYPE_DIR 1
356#define UNIX_TYPE_SYMLINK 2
357#define UNIX_TYPE_CHARDEV 3
358#define UNIX_TYPE_BLKDEV 4
359#define UNIX_TYPE_FIFO 5
360#define UNIX_TYPE_SOCKET 6
361#define UNIX_TYPE_UNKNOWN 0xFFFFFFFF
362
363#endif /* _SMBNO_H_ */
diff --git a/include/linux/smp.h b/include/linux/smp.h
new file mode 100644
index 000000000000..dcf1db3b35d3
--- /dev/null
+++ b/include/linux/smp.h
@@ -0,0 +1,139 @@
1#ifndef __LINUX_SMP_H
2#define __LINUX_SMP_H
3
4/*
5 * Generic SMP support
6 * Alan Cox. <alan@redhat.com>
7 */
8
9#include <linux/config.h>
10
11extern void cpu_idle(void);
12
13#ifdef CONFIG_SMP
14
15#include <linux/preempt.h>
16#include <linux/kernel.h>
17#include <linux/compiler.h>
18#include <linux/thread_info.h>
19#include <asm/smp.h>
20#include <asm/bug.h>
21
22/*
23 * main cross-CPU interfaces, handles INIT, TLB flush, STOP, etc.
24 * (defined in asm header):
25 */
26
27/*
28 * stops all CPUs but the current one:
29 */
30extern void smp_send_stop(void);
31
32/*
33 * sends a 'reschedule' event to another CPU:
34 */
35extern void smp_send_reschedule(int cpu);
36
37
38/*
39 * Prepare machine for booting other CPUs.
40 */
41extern void smp_prepare_cpus(unsigned int max_cpus);
42
43/*
44 * Bring a CPU up
45 */
46extern int __cpu_up(unsigned int cpunum);
47
48/*
49 * Final polishing of CPUs
50 */
51extern void smp_cpus_done(unsigned int max_cpus);
52
53/*
54 * Call a function on all other processors
55 */
56extern int smp_call_function (void (*func) (void *info), void *info,
57 int retry, int wait);
58
59/*
60 * Call a function on all processors
61 */
62static inline int on_each_cpu(void (*func) (void *info), void *info,
63 int retry, int wait)
64{
65 int ret = 0;
66
67 preempt_disable();
68 ret = smp_call_function(func, info, retry, wait);
69 func(info);
70 preempt_enable();
71 return ret;
72}
73
74#define MSG_ALL_BUT_SELF 0x8000 /* Assume <32768 CPU's */
75#define MSG_ALL 0x8001
76
77#define MSG_INVALIDATE_TLB 0x0001 /* Remote processor TLB invalidate */
78#define MSG_STOP_CPU 0x0002 /* Sent to shut down slave CPU's
79 * when rebooting
80 */
81#define MSG_RESCHEDULE 0x0003 /* Reschedule request from master CPU*/
82#define MSG_CALL_FUNCTION 0x0004 /* Call function on all other CPUs */
83
84/*
85 * Mark the boot cpu "online" so that it can call console drivers in
86 * printk() and can access its per-cpu storage.
87 */
88void smp_prepare_boot_cpu(void);
89
90#else /* !SMP */
91
92/*
93 * These macros fold the SMP functionality into a single CPU system
94 */
95
96#if !defined(__smp_processor_id) || !defined(CONFIG_PREEMPT)
97# define smp_processor_id() 0
98#endif
99#define hard_smp_processor_id() 0
100#define smp_call_function(func,info,retry,wait) ({ 0; })
101#define on_each_cpu(func,info,retry,wait) ({ func(info); 0; })
102static inline void smp_send_reschedule(int cpu) { }
103#define num_booting_cpus() 1
104#define smp_prepare_boot_cpu() do {} while (0)
105
106#endif /* !SMP */
107
108/*
109 * DEBUG_PREEMPT support: check whether smp_processor_id() is being
110 * used in a preemption-safe way.
111 *
112 * An architecture has to enable this debugging code explicitly.
113 * It can do so by renaming the smp_processor_id() macro to
114 * __smp_processor_id(). This should only be done after some minimal
115 * testing, because usually there are a number of false positives
116 * that an architecture will trigger.
117 *
118 * To fix a false positive (i.e. smp_processor_id() use that the
119 * debugging code reports but which use for some reason is legal),
120 * change the smp_processor_id() reference to _smp_processor_id(),
121 * which is the nondebug variant. NOTE: don't use this to hack around
122 * real bugs.
123 */
124#ifdef __smp_processor_id
125# if defined(CONFIG_PREEMPT) && defined(CONFIG_DEBUG_PREEMPT)
126 extern unsigned int smp_processor_id(void);
127# else
128# define smp_processor_id() __smp_processor_id()
129# endif
130# define _smp_processor_id() __smp_processor_id()
131#else
132# define _smp_processor_id() smp_processor_id()
133#endif
134
135#define get_cpu() ({ preempt_disable(); smp_processor_id(); })
136#define put_cpu() preempt_enable()
137#define put_cpu_no_resched() preempt_enable_no_resched()
138
139#endif /* __LINUX_SMP_H */
diff --git a/include/linux/smp_lock.h b/include/linux/smp_lock.h
new file mode 100644
index 000000000000..b63ce7014093
--- /dev/null
+++ b/include/linux/smp_lock.h
@@ -0,0 +1,54 @@
1#ifndef __LINUX_SMPLOCK_H
2#define __LINUX_SMPLOCK_H
3
4#include <linux/config.h>
5#include <linux/sched.h>
6#include <linux/spinlock.h>
7
8#ifdef CONFIG_LOCK_KERNEL
9
10#define kernel_locked() (current->lock_depth >= 0)
11
12extern int __lockfunc __reacquire_kernel_lock(void);
13extern void __lockfunc __release_kernel_lock(void);
14
15/*
16 * Release/re-acquire global kernel lock for the scheduler
17 */
18#define release_kernel_lock(tsk) do { \
19 if (unlikely((tsk)->lock_depth >= 0)) \
20 __release_kernel_lock(); \
21} while (0)
22
23/*
24 * Non-SMP kernels will never block on the kernel lock,
25 * so we are better off returning a constant zero from
26 * reacquire_kernel_lock() so that the compiler can see
27 * it at compile-time.
28 */
29#if defined(CONFIG_SMP) && !defined(CONFIG_PREEMPT_BKL)
30# define return_value_on_smp return
31#else
32# define return_value_on_smp
33#endif
34
35static inline int reacquire_kernel_lock(struct task_struct *task)
36{
37 if (unlikely(task->lock_depth >= 0))
38 return_value_on_smp __reacquire_kernel_lock();
39 return 0;
40}
41
42extern void __lockfunc lock_kernel(void) __acquires(kernel_lock);
43extern void __lockfunc unlock_kernel(void) __releases(kernel_lock);
44
45#else
46
47#define lock_kernel() do { } while(0)
48#define unlock_kernel() do { } while(0)
49#define release_kernel_lock(task) do { } while(0)
50#define reacquire_kernel_lock(task) 0
51#define kernel_locked() 1
52
53#endif /* CONFIG_LOCK_KERNEL */
54#endif /* __LINUX_SMPLOCK_H */
diff --git a/include/linux/snmp.h b/include/linux/snmp.h
new file mode 100644
index 000000000000..4db25d5c7cd1
--- /dev/null
+++ b/include/linux/snmp.h
@@ -0,0 +1,266 @@
1/*
2 * Definitions for MIBs
3 *
4 * Author: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
5 */
6
7#ifndef _LINUX_SNMP_H
8#define _LINUX_SNMP_H
9
10/* ipstats mib definitions */
11/*
12 * RFC 1213: MIB-II
13 * RFC 2011 (updates 1213): SNMPv2-MIB-IP
14 * RFC 2863: Interfaces Group MIB
15 * RFC 2465: IPv6 MIB: General Group
16 * draft-ietf-ipv6-rfc2011-update-10.txt: MIB for IP: IP Statistics Tables
17 */
18enum
19{
20 IPSTATS_MIB_NUM = 0,
21 IPSTATS_MIB_INRECEIVES, /* InReceives */
22 IPSTATS_MIB_INHDRERRORS, /* InHdrErrors */
23 IPSTATS_MIB_INTOOBIGERRORS, /* InTooBigErrors */
24 IPSTATS_MIB_INNOROUTES, /* InNoRoutes */
25 IPSTATS_MIB_INADDRERRORS, /* InAddrErrors */
26 IPSTATS_MIB_INUNKNOWNPROTOS, /* InUnknownProtos */
27 IPSTATS_MIB_INTRUNCATEDPKTS, /* InTruncatedPkts */
28 IPSTATS_MIB_INDISCARDS, /* InDiscards */
29 IPSTATS_MIB_INDELIVERS, /* InDelivers */
30 IPSTATS_MIB_OUTFORWDATAGRAMS, /* OutForwDatagrams */
31 IPSTATS_MIB_OUTREQUESTS, /* OutRequests */
32 IPSTATS_MIB_OUTDISCARDS, /* OutDiscards */
33 IPSTATS_MIB_OUTNOROUTES, /* OutNoRoutes */
34 IPSTATS_MIB_REASMTIMEOUT, /* ReasmTimeout */
35 IPSTATS_MIB_REASMREQDS, /* ReasmReqds */
36 IPSTATS_MIB_REASMOKS, /* ReasmOKs */
37 IPSTATS_MIB_REASMFAILS, /* ReasmFails */
38 IPSTATS_MIB_FRAGOKS, /* FragOKs */
39 IPSTATS_MIB_FRAGFAILS, /* FragFails */
40 IPSTATS_MIB_FRAGCREATES, /* FragCreates */
41 IPSTATS_MIB_INMCASTPKTS, /* InMcastPkts */
42 IPSTATS_MIB_OUTMCASTPKTS, /* OutMcastPkts */
43 __IPSTATS_MIB_MAX
44};
45
46/* icmp mib definitions */
47/*
48 * RFC 1213: MIB-II ICMP Group
49 * RFC 2011 (updates 1213): SNMPv2 MIB for IP: ICMP group
50 */
51enum
52{
53 ICMP_MIB_NUM = 0,
54 ICMP_MIB_INMSGS, /* InMsgs */
55 ICMP_MIB_INERRORS, /* InErrors */
56 ICMP_MIB_INDESTUNREACHS, /* InDestUnreachs */
57 ICMP_MIB_INTIMEEXCDS, /* InTimeExcds */
58 ICMP_MIB_INPARMPROBS, /* InParmProbs */
59 ICMP_MIB_INSRCQUENCHS, /* InSrcQuenchs */
60 ICMP_MIB_INREDIRECTS, /* InRedirects */
61 ICMP_MIB_INECHOS, /* InEchos */
62 ICMP_MIB_INECHOREPS, /* InEchoReps */
63 ICMP_MIB_INTIMESTAMPS, /* InTimestamps */
64 ICMP_MIB_INTIMESTAMPREPS, /* InTimestampReps */
65 ICMP_MIB_INADDRMASKS, /* InAddrMasks */
66 ICMP_MIB_INADDRMASKREPS, /* InAddrMaskReps */
67 ICMP_MIB_OUTMSGS, /* OutMsgs */
68 ICMP_MIB_OUTERRORS, /* OutErrors */
69 ICMP_MIB_OUTDESTUNREACHS, /* OutDestUnreachs */
70 ICMP_MIB_OUTTIMEEXCDS, /* OutTimeExcds */
71 ICMP_MIB_OUTPARMPROBS, /* OutParmProbs */
72 ICMP_MIB_OUTSRCQUENCHS, /* OutSrcQuenchs */
73 ICMP_MIB_OUTREDIRECTS, /* OutRedirects */
74 ICMP_MIB_OUTECHOS, /* OutEchos */
75 ICMP_MIB_OUTECHOREPS, /* OutEchoReps */
76 ICMP_MIB_OUTTIMESTAMPS, /* OutTimestamps */
77 ICMP_MIB_OUTTIMESTAMPREPS, /* OutTimestampReps */
78 ICMP_MIB_OUTADDRMASKS, /* OutAddrMasks */
79 ICMP_MIB_OUTADDRMASKREPS, /* OutAddrMaskReps */
80 __ICMP_MIB_MAX
81};
82
83/* icmp6 mib definitions */
84/*
85 * RFC 2466: ICMPv6-MIB
86 */
87enum
88{
89 ICMP6_MIB_NUM = 0,
90 ICMP6_MIB_INMSGS, /* InMsgs */
91 ICMP6_MIB_INERRORS, /* InErrors */
92 ICMP6_MIB_INDESTUNREACHS, /* InDestUnreachs */
93 ICMP6_MIB_INPKTTOOBIGS, /* InPktTooBigs */
94 ICMP6_MIB_INTIMEEXCDS, /* InTimeExcds */
95 ICMP6_MIB_INPARMPROBLEMS, /* InParmProblems */
96 ICMP6_MIB_INECHOS, /* InEchos */
97 ICMP6_MIB_INECHOREPLIES, /* InEchoReplies */
98 ICMP6_MIB_INGROUPMEMBQUERIES, /* InGroupMembQueries */
99 ICMP6_MIB_INGROUPMEMBRESPONSES, /* InGroupMembResponses */
100 ICMP6_MIB_INGROUPMEMBREDUCTIONS, /* InGroupMembReductions */
101 ICMP6_MIB_INROUTERSOLICITS, /* InRouterSolicits */
102 ICMP6_MIB_INROUTERADVERTISEMENTS, /* InRouterAdvertisements */
103 ICMP6_MIB_INNEIGHBORSOLICITS, /* InNeighborSolicits */
104 ICMP6_MIB_INNEIGHBORADVERTISEMENTS, /* InNeighborAdvertisements */
105 ICMP6_MIB_INREDIRECTS, /* InRedirects */
106 ICMP6_MIB_OUTMSGS, /* OutMsgs */
107 ICMP6_MIB_OUTDESTUNREACHS, /* OutDestUnreachs */
108 ICMP6_MIB_OUTPKTTOOBIGS, /* OutPktTooBigs */
109 ICMP6_MIB_OUTTIMEEXCDS, /* OutTimeExcds */
110 ICMP6_MIB_OUTPARMPROBLEMS, /* OutParmProblems */
111 ICMP6_MIB_OUTECHOREPLIES, /* OutEchoReplies */
112 ICMP6_MIB_OUTROUTERSOLICITS, /* OutRouterSolicits */
113 ICMP6_MIB_OUTNEIGHBORSOLICITS, /* OutNeighborSolicits */
114 ICMP6_MIB_OUTNEIGHBORADVERTISEMENTS, /* OutNeighborAdvertisements */
115 ICMP6_MIB_OUTREDIRECTS, /* OutRedirects */
116 ICMP6_MIB_OUTGROUPMEMBRESPONSES, /* OutGroupMembResponses */
117 ICMP6_MIB_OUTGROUPMEMBREDUCTIONS, /* OutGroupMembReductions */
118 __ICMP6_MIB_MAX
119};
120
121/* tcp mib definitions */
122/*
123 * RFC 1213: MIB-II TCP group
124 * RFC 2012 (updates 1213): SNMPv2-MIB-TCP
125 */
126enum
127{
128 TCP_MIB_NUM = 0,
129 TCP_MIB_RTOALGORITHM, /* RtoAlgorithm */
130 TCP_MIB_RTOMIN, /* RtoMin */
131 TCP_MIB_RTOMAX, /* RtoMax */
132 TCP_MIB_MAXCONN, /* MaxConn */
133 TCP_MIB_ACTIVEOPENS, /* ActiveOpens */
134 TCP_MIB_PASSIVEOPENS, /* PassiveOpens */
135 TCP_MIB_ATTEMPTFAILS, /* AttemptFails */
136 TCP_MIB_ESTABRESETS, /* EstabResets */
137 TCP_MIB_CURRESTAB, /* CurrEstab */
138 TCP_MIB_INSEGS, /* InSegs */
139 TCP_MIB_OUTSEGS, /* OutSegs */
140 TCP_MIB_RETRANSSEGS, /* RetransSegs */
141 TCP_MIB_INERRS, /* InErrs */
142 TCP_MIB_OUTRSTS, /* OutRsts */
143 __TCP_MIB_MAX
144};
145
146/* udp mib definitions */
147/*
148 * RFC 1213: MIB-II UDP group
149 * RFC 2013 (updates 1213): SNMPv2-MIB-UDP
150 */
151enum
152{
153 UDP_MIB_NUM = 0,
154 UDP_MIB_INDATAGRAMS, /* InDatagrams */
155 UDP_MIB_NOPORTS, /* NoPorts */
156 UDP_MIB_INERRORS, /* InErrors */
157 UDP_MIB_OUTDATAGRAMS, /* OutDatagrams */
158 __UDP_MIB_MAX
159};
160
161/* sctp mib definitions */
162/*
163 * draft-ietf-sigtran-sctp-mib-07.txt
164 */
165enum
166{
167 SCTP_MIB_NUM = 0,
168 SCTP_MIB_CURRESTAB, /* CurrEstab */
169 SCTP_MIB_ACTIVEESTABS, /* ActiveEstabs */
170 SCTP_MIB_PASSIVEESTABS, /* PassiveEstabs */
171 SCTP_MIB_ABORTEDS, /* Aborteds */
172 SCTP_MIB_SHUTDOWNS, /* Shutdowns */
173 SCTP_MIB_OUTOFBLUES, /* OutOfBlues */
174 SCTP_MIB_CHECKSUMERRORS, /* ChecksumErrors */
175 SCTP_MIB_OUTCTRLCHUNKS, /* OutCtrlChunks */
176 SCTP_MIB_OUTORDERCHUNKS, /* OutOrderChunks */
177 SCTP_MIB_OUTUNORDERCHUNKS, /* OutUnorderChunks */
178 SCTP_MIB_INCTRLCHUNKS, /* InCtrlChunks */
179 SCTP_MIB_INORDERCHUNKS, /* InOrderChunks */
180 SCTP_MIB_INUNORDERCHUNKS, /* InUnorderChunks */
181 SCTP_MIB_FRAGUSRMSGS, /* FragUsrMsgs */
182 SCTP_MIB_REASMUSRMSGS, /* ReasmUsrMsgs */
183 SCTP_MIB_OUTSCTPPACKS, /* OutSCTPPacks */
184 SCTP_MIB_INSCTPPACKS, /* InSCTPPacks */
185 SCTP_MIB_RTOALGORITHM, /* RtoAlgorithm */
186 SCTP_MIB_RTOMIN, /* RtoMin */
187 SCTP_MIB_RTOMAX, /* RtoMax */
188 SCTP_MIB_RTOINITIAL, /* RtoInitial */
189 SCTP_MIB_VALCOOKIELIFE, /* ValCookieLife */
190 SCTP_MIB_MAXINITRETR, /* MaxInitRetr */
191 __SCTP_MIB_MAX
192};
193
194/* linux mib definitions */
195enum
196{
197 LINUX_MIB_NUM = 0,
198 LINUX_MIB_SYNCOOKIESSENT, /* SyncookiesSent */
199 LINUX_MIB_SYNCOOKIESRECV, /* SyncookiesRecv */
200 LINUX_MIB_SYNCOOKIESFAILED, /* SyncookiesFailed */
201 LINUX_MIB_EMBRYONICRSTS, /* EmbryonicRsts */
202 LINUX_MIB_PRUNECALLED, /* PruneCalled */
203 LINUX_MIB_RCVPRUNED, /* RcvPruned */
204 LINUX_MIB_OFOPRUNED, /* OfoPruned */
205 LINUX_MIB_OUTOFWINDOWICMPS, /* OutOfWindowIcmps */
206 LINUX_MIB_LOCKDROPPEDICMPS, /* LockDroppedIcmps */
207 LINUX_MIB_ARPFILTER, /* ArpFilter */
208 LINUX_MIB_TIMEWAITED, /* TimeWaited */
209 LINUX_MIB_TIMEWAITRECYCLED, /* TimeWaitRecycled */
210 LINUX_MIB_TIMEWAITKILLED, /* TimeWaitKilled */
211 LINUX_MIB_PAWSPASSIVEREJECTED, /* PAWSPassiveRejected */
212 LINUX_MIB_PAWSACTIVEREJECTED, /* PAWSActiveRejected */
213 LINUX_MIB_PAWSESTABREJECTED, /* PAWSEstabRejected */
214 LINUX_MIB_DELAYEDACKS, /* DelayedACKs */
215 LINUX_MIB_DELAYEDACKLOCKED, /* DelayedACKLocked */
216 LINUX_MIB_DELAYEDACKLOST, /* DelayedACKLost */
217 LINUX_MIB_LISTENOVERFLOWS, /* ListenOverflows */
218 LINUX_MIB_LISTENDROPS, /* ListenDrops */
219 LINUX_MIB_TCPPREQUEUED, /* TCPPrequeued */
220 LINUX_MIB_TCPDIRECTCOPYFROMBACKLOG, /* TCPDirectCopyFromBacklog */
221 LINUX_MIB_TCPDIRECTCOPYFROMPREQUEUE, /* TCPDirectCopyFromPrequeue */
222 LINUX_MIB_TCPPREQUEUEDROPPED, /* TCPPrequeueDropped */
223 LINUX_MIB_TCPHPHITS, /* TCPHPHits */
224 LINUX_MIB_TCPHPHITSTOUSER, /* TCPHPHitsToUser */
225 LINUX_MIB_TCPPUREACKS, /* TCPPureAcks */
226 LINUX_MIB_TCPHPACKS, /* TCPHPAcks */
227 LINUX_MIB_TCPRENORECOVERY, /* TCPRenoRecovery */
228 LINUX_MIB_TCPSACKRECOVERY, /* TCPSackRecovery */
229 LINUX_MIB_TCPSACKRENEGING, /* TCPSACKReneging */
230 LINUX_MIB_TCPFACKREORDER, /* TCPFACKReorder */
231 LINUX_MIB_TCPSACKREORDER, /* TCPSACKReorder */
232 LINUX_MIB_TCPRENOREORDER, /* TCPRenoReorder */
233 LINUX_MIB_TCPTSREORDER, /* TCPTSReorder */
234 LINUX_MIB_TCPFULLUNDO, /* TCPFullUndo */
235 LINUX_MIB_TCPPARTIALUNDO, /* TCPPartialUndo */
236 LINUX_MIB_TCPDSACKUNDO, /* TCPDSACKUndo */
237 LINUX_MIB_TCPLOSSUNDO, /* TCPLossUndo */
238 LINUX_MIB_TCPLOSS, /* TCPLoss */
239 LINUX_MIB_TCPLOSTRETRANSMIT, /* TCPLostRetransmit */
240 LINUX_MIB_TCPRENOFAILURES, /* TCPRenoFailures */
241 LINUX_MIB_TCPSACKFAILURES, /* TCPSackFailures */
242 LINUX_MIB_TCPLOSSFAILURES, /* TCPLossFailures */
243 LINUX_MIB_TCPFASTRETRANS, /* TCPFastRetrans */
244 LINUX_MIB_TCPFORWARDRETRANS, /* TCPForwardRetrans */
245 LINUX_MIB_TCPSLOWSTARTRETRANS, /* TCPSlowStartRetrans */
246 LINUX_MIB_TCPTIMEOUTS, /* TCPTimeouts */
247 LINUX_MIB_TCPRENORECOVERYFAIL, /* TCPRenoRecoveryFail */
248 LINUX_MIB_TCPSACKRECOVERYFAIL, /* TCPSackRecoveryFail */
249 LINUX_MIB_TCPSCHEDULERFAILED, /* TCPSchedulerFailed */
250 LINUX_MIB_TCPRCVCOLLAPSED, /* TCPRcvCollapsed */
251 LINUX_MIB_TCPDSACKOLDSENT, /* TCPDSACKOldSent */
252 LINUX_MIB_TCPDSACKOFOSENT, /* TCPDSACKOfoSent */
253 LINUX_MIB_TCPDSACKRECV, /* TCPDSACKRecv */
254 LINUX_MIB_TCPDSACKOFORECV, /* TCPDSACKOfoRecv */
255 LINUX_MIB_TCPABORTONSYN, /* TCPAbortOnSyn */
256 LINUX_MIB_TCPABORTONDATA, /* TCPAbortOnData */
257 LINUX_MIB_TCPABORTONCLOSE, /* TCPAbortOnClose */
258 LINUX_MIB_TCPABORTONMEMORY, /* TCPAbortOnMemory */
259 LINUX_MIB_TCPABORTONTIMEOUT, /* TCPAbortOnTimeout */
260 LINUX_MIB_TCPABORTONLINGER, /* TCPAbortOnLinger */
261 LINUX_MIB_TCPABORTFAILED, /* TCPAbortFailed */
262 LINUX_MIB_TCPMEMORYPRESSURES, /* TCPMemoryPressures */
263 __LINUX_MIB_MAX
264};
265
266#endif /* _LINUX_SNMP_H */
diff --git a/include/linux/socket.h b/include/linux/socket.h
new file mode 100644
index 000000000000..a5c7d96e4d2e
--- /dev/null
+++ b/include/linux/socket.h
@@ -0,0 +1,295 @@
1#ifndef _LINUX_SOCKET_H
2#define _LINUX_SOCKET_H
3
4/*
5 * Desired design of maximum size and alignment (see RFC2553)
6 */
7#define _K_SS_MAXSIZE 128 /* Implementation specific max size */
8#define _K_SS_ALIGNSIZE (__alignof__ (struct sockaddr *))
9 /* Implementation specific desired alignment */
10
11struct __kernel_sockaddr_storage {
12 unsigned short ss_family; /* address family */
13 /* Following field(s) are implementation specific */
14 char __data[_K_SS_MAXSIZE - sizeof(unsigned short)];
15 /* space to achieve desired size, */
16 /* _SS_MAXSIZE value minus size of ss_family */
17} __attribute__ ((aligned(_K_SS_ALIGNSIZE))); /* force desired alignment */
18
19#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
20
21#include <linux/config.h> /* for CONFIG_COMPAT */
22#include <linux/linkage.h>
23#include <asm/socket.h> /* arch-dependent defines */
24#include <linux/sockios.h> /* the SIOCxxx I/O controls */
25#include <linux/uio.h> /* iovec support */
26#include <linux/types.h> /* pid_t */
27#include <linux/compiler.h> /* __user */
28
29typedef unsigned short sa_family_t;
30
31/*
32 * 1003.1g requires sa_family_t and that sa_data is char.
33 */
34
35struct sockaddr {
36 sa_family_t sa_family; /* address family, AF_xxx */
37 char sa_data[14]; /* 14 bytes of protocol address */
38};
39
40struct linger {
41 int l_onoff; /* Linger active */
42 int l_linger; /* How long to linger for */
43};
44
45#define sockaddr_storage __kernel_sockaddr_storage
46
47/*
48 * As we do 4.4BSD message passing we use a 4.4BSD message passing
49 * system, not 4.3. Thus msg_accrights(len) are now missing. They
50 * belong in an obscure libc emulation or the bin.
51 */
52
53struct msghdr {
54 void * msg_name; /* Socket name */
55 int msg_namelen; /* Length of name */
56 struct iovec * msg_iov; /* Data blocks */
57 __kernel_size_t msg_iovlen; /* Number of blocks */
58 void * msg_control; /* Per protocol magic (eg BSD file descriptor passing) */
59 __kernel_size_t msg_controllen; /* Length of cmsg list */
60 unsigned msg_flags;
61};
62
63/*
64 * POSIX 1003.1g - ancillary data object information
65 * Ancillary data consits of a sequence of pairs of
66 * (cmsghdr, cmsg_data[])
67 */
68
69struct cmsghdr {
70 __kernel_size_t cmsg_len; /* data byte count, including hdr */
71 int cmsg_level; /* originating protocol */
72 int cmsg_type; /* protocol-specific type */
73};
74
75/*
76 * Ancilliary data object information MACROS
77 * Table 5-14 of POSIX 1003.1g
78 */
79
80#define __CMSG_NXTHDR(ctl, len, cmsg) __cmsg_nxthdr((ctl),(len),(cmsg))
81#define CMSG_NXTHDR(mhdr, cmsg) cmsg_nxthdr((mhdr), (cmsg))
82
83#define CMSG_ALIGN(len) ( ((len)+sizeof(long)-1) & ~(sizeof(long)-1) )
84
85#define CMSG_DATA(cmsg) ((void *)((char *)(cmsg) + CMSG_ALIGN(sizeof(struct cmsghdr))))
86#define CMSG_SPACE(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + CMSG_ALIGN(len))
87#define CMSG_LEN(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + (len))
88
89#define __CMSG_FIRSTHDR(ctl,len) ((len) >= sizeof(struct cmsghdr) ? \
90 (struct cmsghdr *)(ctl) : \
91 (struct cmsghdr *)NULL)
92#define CMSG_FIRSTHDR(msg) __CMSG_FIRSTHDR((msg)->msg_control, (msg)->msg_controllen)
93#define CMSG_OK(mhdr, cmsg) ((cmsg)->cmsg_len >= sizeof(struct cmsghdr) && \
94 (cmsg)->cmsg_len <= (unsigned long) \
95 ((mhdr)->msg_controllen - \
96 ((char *)(cmsg) - (char *)(mhdr)->msg_control)))
97
98/*
99 * This mess will go away with glibc
100 */
101
102#ifdef __KERNEL__
103#define __KINLINE static inline
104#elif defined(__GNUC__)
105#define __KINLINE static __inline__
106#elif defined(__cplusplus)
107#define __KINLINE static inline
108#else
109#define __KINLINE static
110#endif
111
112
113/*
114 * Get the next cmsg header
115 *
116 * PLEASE, do not touch this function. If you think, that it is
117 * incorrect, grep kernel sources and think about consequences
118 * before trying to improve it.
119 *
120 * Now it always returns valid, not truncated ancillary object
121 * HEADER. But caller still MUST check, that cmsg->cmsg_len is
122 * inside range, given by msg->msg_controllen before using
123 * ancillary object DATA. --ANK (980731)
124 */
125
126__KINLINE struct cmsghdr * __cmsg_nxthdr(void *__ctl, __kernel_size_t __size,
127 struct cmsghdr *__cmsg)
128{
129 struct cmsghdr * __ptr;
130
131 __ptr = (struct cmsghdr*)(((unsigned char *) __cmsg) + CMSG_ALIGN(__cmsg->cmsg_len));
132 if ((unsigned long)((char*)(__ptr+1) - (char *) __ctl) > __size)
133 return (struct cmsghdr *)0;
134
135 return __ptr;
136}
137
138__KINLINE struct cmsghdr * cmsg_nxthdr (struct msghdr *__msg, struct cmsghdr *__cmsg)
139{
140 return __cmsg_nxthdr(__msg->msg_control, __msg->msg_controllen, __cmsg);
141}
142
143/* "Socket"-level control message types: */
144
145#define SCM_RIGHTS 0x01 /* rw: access rights (array of int) */
146#define SCM_CREDENTIALS 0x02 /* rw: struct ucred */
147
148struct ucred {
149 __u32 pid;
150 __u32 uid;
151 __u32 gid;
152};
153
154/* Supported address families. */
155#define AF_UNSPEC 0
156#define AF_UNIX 1 /* Unix domain sockets */
157#define AF_LOCAL 1 /* POSIX name for AF_UNIX */
158#define AF_INET 2 /* Internet IP Protocol */
159#define AF_AX25 3 /* Amateur Radio AX.25 */
160#define AF_IPX 4 /* Novell IPX */
161#define AF_APPLETALK 5 /* AppleTalk DDP */
162#define AF_NETROM 6 /* Amateur Radio NET/ROM */
163#define AF_BRIDGE 7 /* Multiprotocol bridge */
164#define AF_ATMPVC 8 /* ATM PVCs */
165#define AF_X25 9 /* Reserved for X.25 project */
166#define AF_INET6 10 /* IP version 6 */
167#define AF_ROSE 11 /* Amateur Radio X.25 PLP */
168#define AF_DECnet 12 /* Reserved for DECnet project */
169#define AF_NETBEUI 13 /* Reserved for 802.2LLC project*/
170#define AF_SECURITY 14 /* Security callback pseudo AF */
171#define AF_KEY 15 /* PF_KEY key management API */
172#define AF_NETLINK 16
173#define AF_ROUTE AF_NETLINK /* Alias to emulate 4.4BSD */
174#define AF_PACKET 17 /* Packet family */
175#define AF_ASH 18 /* Ash */
176#define AF_ECONET 19 /* Acorn Econet */
177#define AF_ATMSVC 20 /* ATM SVCs */
178#define AF_SNA 22 /* Linux SNA Project (nutters!) */
179#define AF_IRDA 23 /* IRDA sockets */
180#define AF_PPPOX 24 /* PPPoX sockets */
181#define AF_WANPIPE 25 /* Wanpipe API Sockets */
182#define AF_LLC 26 /* Linux LLC */
183#define AF_BLUETOOTH 31 /* Bluetooth sockets */
184#define AF_MAX 32 /* For now.. */
185
186/* Protocol families, same as address families. */
187#define PF_UNSPEC AF_UNSPEC
188#define PF_UNIX AF_UNIX
189#define PF_LOCAL AF_LOCAL
190#define PF_INET AF_INET
191#define PF_AX25 AF_AX25
192#define PF_IPX AF_IPX
193#define PF_APPLETALK AF_APPLETALK
194#define PF_NETROM AF_NETROM
195#define PF_BRIDGE AF_BRIDGE
196#define PF_ATMPVC AF_ATMPVC
197#define PF_X25 AF_X25
198#define PF_INET6 AF_INET6
199#define PF_ROSE AF_ROSE
200#define PF_DECnet AF_DECnet
201#define PF_NETBEUI AF_NETBEUI
202#define PF_SECURITY AF_SECURITY
203#define PF_KEY AF_KEY
204#define PF_NETLINK AF_NETLINK
205#define PF_ROUTE AF_ROUTE
206#define PF_PACKET AF_PACKET
207#define PF_ASH AF_ASH
208#define PF_ECONET AF_ECONET
209#define PF_ATMSVC AF_ATMSVC
210#define PF_SNA AF_SNA
211#define PF_IRDA AF_IRDA
212#define PF_PPPOX AF_PPPOX
213#define PF_WANPIPE AF_WANPIPE
214#define PF_LLC AF_LLC
215#define PF_BLUETOOTH AF_BLUETOOTH
216#define PF_MAX AF_MAX
217
218/* Maximum queue length specifiable by listen. */
219#define SOMAXCONN 128
220
221/* Flags we can use with send/ and recv.
222 Added those for 1003.1g not all are supported yet
223 */
224
225#define MSG_OOB 1
226#define MSG_PEEK 2
227#define MSG_DONTROUTE 4
228#define MSG_TRYHARD 4 /* Synonym for MSG_DONTROUTE for DECnet */
229#define MSG_CTRUNC 8
230#define MSG_PROBE 0x10 /* Do not send. Only probe path f.e. for MTU */
231#define MSG_TRUNC 0x20
232#define MSG_DONTWAIT 0x40 /* Nonblocking io */
233#define MSG_EOR 0x80 /* End of record */
234#define MSG_WAITALL 0x100 /* Wait for a full request */
235#define MSG_FIN 0x200
236#define MSG_SYN 0x400
237#define MSG_CONFIRM 0x800 /* Confirm path validity */
238#define MSG_RST 0x1000
239#define MSG_ERRQUEUE 0x2000 /* Fetch message from error queue */
240#define MSG_NOSIGNAL 0x4000 /* Do not generate SIGPIPE */
241#define MSG_MORE 0x8000 /* Sender will send more */
242
243#define MSG_EOF MSG_FIN
244
245#if defined(CONFIG_COMPAT)
246#define MSG_CMSG_COMPAT 0x80000000 /* This message needs 32 bit fixups */
247#else
248#define MSG_CMSG_COMPAT 0 /* We never have 32 bit fixups */
249#endif
250
251
252/* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */
253#define SOL_IP 0
254/* #define SOL_ICMP 1 No-no-no! Due to Linux :-) we cannot use SOL_ICMP=1 */
255#define SOL_TCP 6
256#define SOL_UDP 17
257#define SOL_IPV6 41
258#define SOL_ICMPV6 58
259#define SOL_SCTP 132
260#define SOL_RAW 255
261#define SOL_IPX 256
262#define SOL_AX25 257
263#define SOL_ATALK 258
264#define SOL_NETROM 259
265#define SOL_ROSE 260
266#define SOL_DECNET 261
267#define SOL_X25 262
268#define SOL_PACKET 263
269#define SOL_ATM 264 /* ATM layer (cell level) */
270#define SOL_AAL 265 /* ATM Adaption Layer (packet level) */
271#define SOL_IRDA 266
272#define SOL_NETBEUI 267
273#define SOL_LLC 268
274
275/* IPX options */
276#define IPX_TYPE 1
277
278#ifdef __KERNEL__
279extern int memcpy_fromiovec(unsigned char *kdata, struct iovec *iov, int len);
280extern int memcpy_fromiovecend(unsigned char *kdata, struct iovec *iov,
281 int offset, int len);
282extern int csum_partial_copy_fromiovecend(unsigned char *kdata,
283 struct iovec *iov,
284 int offset,
285 unsigned int len, int *csump);
286
287extern int verify_iovec(struct msghdr *m, struct iovec *iov, char *address, int mode);
288extern int memcpy_toiovec(struct iovec *v, unsigned char *kdata, int len);
289extern int move_addr_to_user(void *kaddr, int klen, void __user *uaddr, int __user *ulen);
290extern int move_addr_to_kernel(void __user *uaddr, int ulen, void *kaddr);
291extern int put_cmsg(struct msghdr*, int level, int type, int len, void *data);
292
293#endif
294#endif /* not kernel and not glibc */
295#endif /* _LINUX_SOCKET_H */
diff --git a/include/linux/sockios.h b/include/linux/sockios.h
new file mode 100644
index 000000000000..5eb33205cc04
--- /dev/null
+++ b/include/linux/sockios.h
@@ -0,0 +1,143 @@
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Definitions of the socket-level I/O control calls.
7 *
8 * Version: @(#)sockios.h 1.0.2 03/09/93
9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu>
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version
16 * 2 of the License, or (at your option) any later version.
17 */
18#ifndef _LINUX_SOCKIOS_H
19#define _LINUX_SOCKIOS_H
20
21#include <asm/sockios.h>
22
23/* Linux-specific socket ioctls */
24#define SIOCINQ FIONREAD
25#define SIOCOUTQ TIOCOUTQ
26
27/* Routing table calls. */
28#define SIOCADDRT 0x890B /* add routing table entry */
29#define SIOCDELRT 0x890C /* delete routing table entry */
30#define SIOCRTMSG 0x890D /* call to routing system */
31
32/* Socket configuration controls. */
33#define SIOCGIFNAME 0x8910 /* get iface name */
34#define SIOCSIFLINK 0x8911 /* set iface channel */
35#define SIOCGIFCONF 0x8912 /* get iface list */
36#define SIOCGIFFLAGS 0x8913 /* get flags */
37#define SIOCSIFFLAGS 0x8914 /* set flags */
38#define SIOCGIFADDR 0x8915 /* get PA address */
39#define SIOCSIFADDR 0x8916 /* set PA address */
40#define SIOCGIFDSTADDR 0x8917 /* get remote PA address */
41#define SIOCSIFDSTADDR 0x8918 /* set remote PA address */
42#define SIOCGIFBRDADDR 0x8919 /* get broadcast PA address */
43#define SIOCSIFBRDADDR 0x891a /* set broadcast PA address */
44#define SIOCGIFNETMASK 0x891b /* get network PA mask */
45#define SIOCSIFNETMASK 0x891c /* set network PA mask */
46#define SIOCGIFMETRIC 0x891d /* get metric */
47#define SIOCSIFMETRIC 0x891e /* set metric */
48#define SIOCGIFMEM 0x891f /* get memory address (BSD) */
49#define SIOCSIFMEM 0x8920 /* set memory address (BSD) */
50#define SIOCGIFMTU 0x8921 /* get MTU size */
51#define SIOCSIFMTU 0x8922 /* set MTU size */
52#define SIOCSIFNAME 0x8923 /* set interface name */
53#define SIOCSIFHWADDR 0x8924 /* set hardware address */
54#define SIOCGIFENCAP 0x8925 /* get/set encapsulations */
55#define SIOCSIFENCAP 0x8926
56#define SIOCGIFHWADDR 0x8927 /* Get hardware address */
57#define SIOCGIFSLAVE 0x8929 /* Driver slaving support */
58#define SIOCSIFSLAVE 0x8930
59#define SIOCADDMULTI 0x8931 /* Multicast address lists */
60#define SIOCDELMULTI 0x8932
61#define SIOCGIFINDEX 0x8933 /* name -> if_index mapping */
62#define SIOGIFINDEX SIOCGIFINDEX /* misprint compatibility :-) */
63#define SIOCSIFPFLAGS 0x8934 /* set/get extended flags set */
64#define SIOCGIFPFLAGS 0x8935
65#define SIOCDIFADDR 0x8936 /* delete PA address */
66#define SIOCSIFHWBROADCAST 0x8937 /* set hardware broadcast addr */
67#define SIOCGIFCOUNT 0x8938 /* get number of devices */
68
69#define SIOCGIFBR 0x8940 /* Bridging support */
70#define SIOCSIFBR 0x8941 /* Set bridging options */
71
72#define SIOCGIFTXQLEN 0x8942 /* Get the tx queue length */
73#define SIOCSIFTXQLEN 0x8943 /* Set the tx queue length */
74
75#define SIOCGIFDIVERT 0x8944 /* Frame diversion support */
76#define SIOCSIFDIVERT 0x8945 /* Set frame diversion options */
77
78#define SIOCETHTOOL 0x8946 /* Ethtool interface */
79
80#define SIOCGMIIPHY 0x8947 /* Get address of MII PHY in use. */
81#define SIOCGMIIREG 0x8948 /* Read MII PHY register. */
82#define SIOCSMIIREG 0x8949 /* Write MII PHY register. */
83
84#define SIOCWANDEV 0x894A /* get/set netdev parameters */
85
86/* ARP cache control calls. */
87 /* 0x8950 - 0x8952 * obsolete calls, don't re-use */
88#define SIOCDARP 0x8953 /* delete ARP table entry */
89#define SIOCGARP 0x8954 /* get ARP table entry */
90#define SIOCSARP 0x8955 /* set ARP table entry */
91
92/* RARP cache control calls. */
93#define SIOCDRARP 0x8960 /* delete RARP table entry */
94#define SIOCGRARP 0x8961 /* get RARP table entry */
95#define SIOCSRARP 0x8962 /* set RARP table entry */
96
97/* Driver configuration calls */
98
99#define SIOCGIFMAP 0x8970 /* Get device parameters */
100#define SIOCSIFMAP 0x8971 /* Set device parameters */
101
102/* DLCI configuration calls */
103
104#define SIOCADDDLCI 0x8980 /* Create new DLCI device */
105#define SIOCDELDLCI 0x8981 /* Delete DLCI device */
106
107#define SIOCGIFVLAN 0x8982 /* 802.1Q VLAN support */
108#define SIOCSIFVLAN 0x8983 /* Set 802.1Q VLAN options */
109
110/* bonding calls */
111
112#define SIOCBONDENSLAVE 0x8990 /* enslave a device to the bond */
113#define SIOCBONDRELEASE 0x8991 /* release a slave from the bond*/
114#define SIOCBONDSETHWADDR 0x8992 /* set the hw addr of the bond */
115#define SIOCBONDSLAVEINFOQUERY 0x8993 /* rtn info about slave state */
116#define SIOCBONDINFOQUERY 0x8994 /* rtn info about bond state */
117#define SIOCBONDCHANGEACTIVE 0x8995 /* update to a new active slave */
118
119/* bridge calls */
120#define SIOCBRADDBR 0x89a0 /* create new bridge device */
121#define SIOCBRDELBR 0x89a1 /* remove bridge device */
122#define SIOCBRADDIF 0x89a2 /* add interface to bridge */
123#define SIOCBRDELIF 0x89a3 /* remove interface from bridge */
124
125/* Device private ioctl calls */
126
127/*
128 * These 16 ioctls are available to devices via the do_ioctl() device
129 * vector. Each device should include this file and redefine these names
130 * as their own. Because these are device dependent it is a good idea
131 * _NOT_ to issue them to random objects and hope.
132 *
133 * THESE IOCTLS ARE _DEPRECATED_ AND WILL DISAPPEAR IN 2.5.X -DaveM
134 */
135
136#define SIOCDEVPRIVATE 0x89F0 /* to 89FF */
137
138/*
139 * These 16 ioctl calls are protocol private
140 */
141
142#define SIOCPROTOPRIVATE 0x89E0 /* to 89EF */
143#endif /* _LINUX_SOCKIOS_H */
diff --git a/include/linux/som.h b/include/linux/som.h
new file mode 100644
index 000000000000..166594e4e7be
--- /dev/null
+++ b/include/linux/som.h
@@ -0,0 +1,154 @@
1#ifndef _LINUX_SOM_H
2#define _LINUX_SOM_H
3
4/* File format definition for SOM executables / shared libraries */
5
6/* we need struct timespec */
7#include <linux/time.h>
8
9#define SOM_PAGESIZE 4096
10
11/* this is the SOM header */
12struct som_hdr {
13 short system_id; /* magic number - system */
14 short a_magic; /* magic number - file type */
15 unsigned int version_id; /* versiod ID: YYMMDDHH */
16 struct timespec file_time; /* system clock */
17 unsigned int entry_space; /* space for entry point */
18 unsigned int entry_subspace; /* subspace for entry point */
19 unsigned int entry_offset; /* offset of entry point */
20 unsigned int aux_header_location; /* auxiliary header location */
21 unsigned int aux_header_size; /* auxiliary header size */
22 unsigned int som_length; /* length of entire SOM */
23 unsigned int presumed_dp; /* compiler's DP value */
24 unsigned int space_location; /* space dictionary location */
25 unsigned int space_total; /* number of space entries */
26 unsigned int subspace_location; /* subspace entries location */
27 unsigned int subspace_total; /* number of subspace entries */
28 unsigned int loader_fixup_location; /* MPE/iX loader fixup */
29 unsigned int loader_fixup_total; /* number of fixup records */
30 unsigned int space_strings_location; /* (sub)space names */
31 unsigned int space_strings_size; /* size of strings area */
32 unsigned int init_array_location; /* reserved */
33 unsigned int init_array_total; /* reserved */
34 unsigned int compiler_location; /* module dictionary */
35 unsigned int compiler_total; /* number of modules */
36 unsigned int symbol_location; /* symbol dictionary */
37 unsigned int symbol_total; /* number of symbols */
38 unsigned int fixup_request_location; /* fixup requests */
39 unsigned int fixup_request_total; /* number of fixup requests */
40 unsigned int symbol_strings_location;/* module & symbol names area */
41 unsigned int symbol_strings_size; /* size of strings area */
42 unsigned int unloadable_sp_location; /* unloadable spaces location */
43 unsigned int unloadable_sp_size; /* size of data */
44 unsigned int checksum;
45};
46
47/* values for system_id */
48
49#define SOM_SID_PARISC_1_0 0x020b
50#define SOM_SID_PARISC_1_1 0x0210
51#define SOM_SID_PARISC_2_0 0x0214
52
53/* values for a_magic */
54
55#define SOM_LIB_EXEC 0x0104
56#define SOM_RELOCATABLE 0x0106
57#define SOM_EXEC_NONSHARE 0x0107
58#define SOM_EXEC_SHARE 0x0108
59#define SOM_EXEC_DEMAND 0x010B
60#define SOM_LIB_DYN 0x010D
61#define SOM_LIB_SHARE 0x010E
62#define SOM_LIB_RELOC 0x0619
63
64/* values for version_id. Decimal not hex, yes. Grr. */
65
66#define SOM_ID_OLD 85082112
67#define SOM_ID_NEW 87102412
68
69struct aux_id {
70 unsigned int mandatory :1; /* the linker must understand this */
71 unsigned int copy :1; /* Must be copied by the linker */
72 unsigned int append :1; /* Must be merged by the linker */
73 unsigned int ignore :1; /* Discard section if unknown */
74 unsigned int reserved :12;
75 unsigned int type :16; /* Header type */
76 unsigned int length; /* length of _following_ data */
77};
78
79/* The Exec Auxiliary Header. Called The HP-UX Header within HP apparently. */
80struct som_exec_auxhdr {
81 struct aux_id som_auxhdr;
82 int exec_tsize; /* Text size in bytes */
83 int exec_tmem; /* Address to load text at */
84 int exec_tfile; /* Location of text in file */
85 int exec_dsize; /* Data size in bytes */
86 int exec_dmem; /* Address to load data at */
87 int exec_dfile; /* Location of data in file */
88 int exec_bsize; /* Uninitialised data (bss) */
89 int exec_entry; /* Address to start executing */
90 int exec_flags; /* loader flags */
91 int exec_bfill; /* initialisation value for bss */
92};
93
94/* Oh, the things people do to avoid casts. Shame it'll break with gcc's
95 * new aliasing rules really.
96 */
97union name_pt {
98 char * n_name;
99 unsigned int n_strx;
100};
101
102/* The Space Dictionary */
103struct space_dictionary_record {
104 union name_pt name; /* index to subspace name */
105 unsigned int is_loadable :1; /* loadable */
106 unsigned int is_defined :1; /* defined within file */
107 unsigned int is_private :1; /* not sharable */
108 unsigned int has_intermediate_code :1; /* contains intermediate code */
109 unsigned int is_tspecific :1; /* thread specific */
110 unsigned int reserved :11; /* for future expansion */
111 unsigned int sort_key :8; /* for linker */
112 unsigned int reserved2 :8; /* for future expansion */
113
114 int space_number; /* index */
115 int subspace_index; /* index into subspace dict */
116 unsigned int subspace_quantity; /* number of subspaces */
117 int loader_fix_index; /* for loader */
118 unsigned int loader_fix_quantity; /* for loader */
119 int init_pointer_index; /* data pointer array index */
120 unsigned int init_pointer_quantity; /* number of data pointers */
121};
122
123/* The Subspace Dictionary */
124struct subspace_dictionary_record {
125 int space_index;
126 unsigned int access_control_bits :7;
127 unsigned int memory_resident :1;
128 unsigned int dup_common :1;
129 unsigned int is_common :1;
130 unsigned int quadrant :2;
131 unsigned int initially_frozen :1;
132 unsigned int is_first :1;
133 unsigned int code_only :1;
134 unsigned int sort_key :8;
135 unsigned int replicate_init :1;
136 unsigned int continuation :1;
137 unsigned int is_tspecific :1;
138 unsigned int is_comdat :1;
139 unsigned int reserved :4;
140
141 int file_loc_init_value;
142 unsigned int initialization_length;
143 unsigned int subspace_start;
144 unsigned int subspace_length;
145
146 unsigned int reserved2 :5;
147 unsigned int alignment :27;
148
149 union name_pt name;
150 int fixup_request_index;
151 unsigned int fixup_request_quantity;
152};
153
154#endif /* _LINUX_SOM_H */
diff --git a/include/linux/sonet.h b/include/linux/sonet.h
new file mode 100644
index 000000000000..753680296e17
--- /dev/null
+++ b/include/linux/sonet.h
@@ -0,0 +1,75 @@
1/* sonet.h - SONET/SHD physical layer control */
2
3/* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */
4
5
6#ifndef LINUX_SONET_H
7#define LINUX_SONET_H
8
9#define __SONET_ITEMS \
10 __HANDLE_ITEM(section_bip); /* section parity errors (B1) */ \
11 __HANDLE_ITEM(line_bip); /* line parity errors (B2) */ \
12 __HANDLE_ITEM(path_bip); /* path parity errors (B3) */ \
13 __HANDLE_ITEM(line_febe); /* line parity errors at remote */ \
14 __HANDLE_ITEM(path_febe); /* path parity errors at remote */ \
15 __HANDLE_ITEM(corr_hcs); /* correctable header errors */ \
16 __HANDLE_ITEM(uncorr_hcs); /* uncorrectable header errors */ \
17 __HANDLE_ITEM(tx_cells); /* cells sent */ \
18 __HANDLE_ITEM(rx_cells); /* cells received */
19
20struct sonet_stats {
21#define __HANDLE_ITEM(i) int i
22 __SONET_ITEMS
23#undef __HANDLE_ITEM
24} __attribute__ ((packed));
25
26
27#define SONET_GETSTAT _IOR('a',ATMIOC_PHYTYP,struct sonet_stats)
28 /* get statistics */
29#define SONET_GETSTATZ _IOR('a',ATMIOC_PHYTYP+1,struct sonet_stats)
30 /* ... and zero counters */
31#define SONET_SETDIAG _IOWR('a',ATMIOC_PHYTYP+2,int)
32 /* set error insertion */
33#define SONET_CLRDIAG _IOWR('a',ATMIOC_PHYTYP+3,int)
34 /* clear error insertion */
35#define SONET_GETDIAG _IOR('a',ATMIOC_PHYTYP+4,int)
36 /* query error insertion */
37#define SONET_SETFRAMING _IO('a',ATMIOC_PHYTYP+5)
38 /* set framing mode (SONET/SDH) */
39#define SONET_GETFRAMING _IOR('a',ATMIOC_PHYTYP+6,int)
40 /* get framing mode */
41#define SONET_GETFRSENSE _IOR('a',ATMIOC_PHYTYP+7, \
42 unsigned char[SONET_FRSENSE_SIZE]) /* get framing sense information */
43
44#define SONET_INS_SBIP 1 /* section BIP */
45#define SONET_INS_LBIP 2 /* line BIP */
46#define SONET_INS_PBIP 4 /* path BIP */
47#define SONET_INS_FRAME 8 /* out of frame */
48#define SONET_INS_LOS 16 /* set line to zero */
49#define SONET_INS_LAIS 32 /* line alarm indication signal */
50#define SONET_INS_PAIS 64 /* path alarm indication signal */
51#define SONET_INS_HCS 128 /* insert HCS error */
52
53#define SONET_FRAME_SONET 0 /* SONET STS-3 framing */
54#define SONET_FRAME_SDH 1 /* SDH STM-1 framing */
55
56#define SONET_FRSENSE_SIZE 6 /* C1[3],H1[3] (0xff for unknown) */
57
58
59#ifdef __KERNEL__
60
61#include <asm/atomic.h>
62
63struct k_sonet_stats {
64#define __HANDLE_ITEM(i) atomic_t i
65 __SONET_ITEMS
66#undef __HANDLE_ITEM
67};
68
69extern void sonet_copy_stats(struct k_sonet_stats *from,struct sonet_stats *to);
70extern void sonet_subtract_stats(struct k_sonet_stats *from,
71 struct sonet_stats *to);
72
73#endif
74
75#endif
diff --git a/include/linux/sonypi.h b/include/linux/sonypi.h
new file mode 100644
index 000000000000..768cbba617d0
--- /dev/null
+++ b/include/linux/sonypi.h
@@ -0,0 +1,158 @@
1/*
2 * Sony Programmable I/O Control Device driver for VAIO
3 *
4 * Copyright (C) 2001-2005 Stelian Pop <stelian@popies.net>
5 *
6 * Copyright (C) 2005 Narayanan R S <nars@kadamba.org>
7
8 * Copyright (C) 2001-2002 Alcôve <www.alcove.com>
9 *
10 * Copyright (C) 2001 Michael Ashley <m.ashley@unsw.edu.au>
11 *
12 * Copyright (C) 2001 Junichi Morita <jun1m@mars.dti.ne.jp>
13 *
14 * Copyright (C) 2000 Takaya Kinjo <t-kinjo@tc4.so-net.ne.jp>
15 *
16 * Copyright (C) 2000 Andrew Tridgell <tridge@valinux.com>
17 *
18 * Earlier work by Werner Almesberger, Paul `Rusty' Russell and Paul Mackerras.
19 *
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
29 *
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
33 *
34 */
35
36#ifndef _SONYPI_H_
37#define _SONYPI_H_
38
39#include <linux/types.h>
40
41/* events the user application reading /dev/sonypi can use */
42
43#define SONYPI_EVENT_JOGDIAL_DOWN 1
44#define SONYPI_EVENT_JOGDIAL_UP 2
45#define SONYPI_EVENT_JOGDIAL_DOWN_PRESSED 3
46#define SONYPI_EVENT_JOGDIAL_UP_PRESSED 4
47#define SONYPI_EVENT_JOGDIAL_PRESSED 5
48#define SONYPI_EVENT_JOGDIAL_RELEASED 6 /* obsolete */
49#define SONYPI_EVENT_CAPTURE_PRESSED 7
50#define SONYPI_EVENT_CAPTURE_RELEASED 8 /* obsolete */
51#define SONYPI_EVENT_CAPTURE_PARTIALPRESSED 9
52#define SONYPI_EVENT_CAPTURE_PARTIALRELEASED 10
53#define SONYPI_EVENT_FNKEY_ESC 11
54#define SONYPI_EVENT_FNKEY_F1 12
55#define SONYPI_EVENT_FNKEY_F2 13
56#define SONYPI_EVENT_FNKEY_F3 14
57#define SONYPI_EVENT_FNKEY_F4 15
58#define SONYPI_EVENT_FNKEY_F5 16
59#define SONYPI_EVENT_FNKEY_F6 17
60#define SONYPI_EVENT_FNKEY_F7 18
61#define SONYPI_EVENT_FNKEY_F8 19
62#define SONYPI_EVENT_FNKEY_F9 20
63#define SONYPI_EVENT_FNKEY_F10 21
64#define SONYPI_EVENT_FNKEY_F11 22
65#define SONYPI_EVENT_FNKEY_F12 23
66#define SONYPI_EVENT_FNKEY_1 24
67#define SONYPI_EVENT_FNKEY_2 25
68#define SONYPI_EVENT_FNKEY_D 26
69#define SONYPI_EVENT_FNKEY_E 27
70#define SONYPI_EVENT_FNKEY_F 28
71#define SONYPI_EVENT_FNKEY_S 29
72#define SONYPI_EVENT_FNKEY_B 30
73#define SONYPI_EVENT_BLUETOOTH_PRESSED 31
74#define SONYPI_EVENT_PKEY_P1 32
75#define SONYPI_EVENT_PKEY_P2 33
76#define SONYPI_EVENT_PKEY_P3 34
77#define SONYPI_EVENT_BACK_PRESSED 35
78#define SONYPI_EVENT_LID_CLOSED 36
79#define SONYPI_EVENT_LID_OPENED 37
80#define SONYPI_EVENT_BLUETOOTH_ON 38
81#define SONYPI_EVENT_BLUETOOTH_OFF 39
82#define SONYPI_EVENT_HELP_PRESSED 40
83#define SONYPI_EVENT_FNKEY_ONLY 41
84#define SONYPI_EVENT_JOGDIAL_FAST_DOWN 42
85#define SONYPI_EVENT_JOGDIAL_FAST_UP 43
86#define SONYPI_EVENT_JOGDIAL_FAST_DOWN_PRESSED 44
87#define SONYPI_EVENT_JOGDIAL_FAST_UP_PRESSED 45
88#define SONYPI_EVENT_JOGDIAL_VFAST_DOWN 46
89#define SONYPI_EVENT_JOGDIAL_VFAST_UP 47
90#define SONYPI_EVENT_JOGDIAL_VFAST_DOWN_PRESSED 48
91#define SONYPI_EVENT_JOGDIAL_VFAST_UP_PRESSED 49
92#define SONYPI_EVENT_ZOOM_PRESSED 50
93#define SONYPI_EVENT_THUMBPHRASE_PRESSED 51
94#define SONYPI_EVENT_MEYE_FACE 52
95#define SONYPI_EVENT_MEYE_OPPOSITE 53
96#define SONYPI_EVENT_MEMORYSTICK_INSERT 54
97#define SONYPI_EVENT_MEMORYSTICK_EJECT 55
98#define SONYPI_EVENT_ANYBUTTON_RELEASED 56
99#define SONYPI_EVENT_BATTERY_INSERT 57
100#define SONYPI_EVENT_BATTERY_REMOVE 58
101#define SONYPI_EVENT_FNKEY_RELEASED 59
102
103/* get/set brightness */
104#define SONYPI_IOCGBRT _IOR('v', 0, __u8)
105#define SONYPI_IOCSBRT _IOW('v', 0, __u8)
106
107/* get battery full capacity/remaining capacity */
108#define SONYPI_IOCGBAT1CAP _IOR('v', 2, __u16)
109#define SONYPI_IOCGBAT1REM _IOR('v', 3, __u16)
110#define SONYPI_IOCGBAT2CAP _IOR('v', 4, __u16)
111#define SONYPI_IOCGBAT2REM _IOR('v', 5, __u16)
112
113/* get battery flags: battery1/battery2/ac adapter present */
114#define SONYPI_BFLAGS_B1 0x01
115#define SONYPI_BFLAGS_B2 0x02
116#define SONYPI_BFLAGS_AC 0x04
117#define SONYPI_IOCGBATFLAGS _IOR('v', 7, __u8)
118
119/* get/set bluetooth subsystem state on/off */
120#define SONYPI_IOCGBLUE _IOR('v', 8, __u8)
121#define SONYPI_IOCSBLUE _IOW('v', 9, __u8)
122
123/* get/set fan state on/off */
124#define SONYPI_IOCGFAN _IOR('v', 10, __u8)
125#define SONYPI_IOCSFAN _IOW('v', 11, __u8)
126
127/* get temperature (C) */
128#define SONYPI_IOCGTEMP _IOR('v', 12, __u8)
129
130#ifdef __KERNEL__
131
132/* used only for communication between v4l and sonypi */
133
134#define SONYPI_COMMAND_GETCAMERA 1 /* obsolete */
135#define SONYPI_COMMAND_SETCAMERA 2
136#define SONYPI_COMMAND_GETCAMERABRIGHTNESS 3 /* obsolete */
137#define SONYPI_COMMAND_SETCAMERABRIGHTNESS 4
138#define SONYPI_COMMAND_GETCAMERACONTRAST 5 /* obsolete */
139#define SONYPI_COMMAND_SETCAMERACONTRAST 6
140#define SONYPI_COMMAND_GETCAMERAHUE 7 /* obsolete */
141#define SONYPI_COMMAND_SETCAMERAHUE 8
142#define SONYPI_COMMAND_GETCAMERACOLOR 9 /* obsolete */
143#define SONYPI_COMMAND_SETCAMERACOLOR 10
144#define SONYPI_COMMAND_GETCAMERASHARPNESS 11 /* obsolete */
145#define SONYPI_COMMAND_SETCAMERASHARPNESS 12
146#define SONYPI_COMMAND_GETCAMERAPICTURE 13 /* obsolete */
147#define SONYPI_COMMAND_SETCAMERAPICTURE 14
148#define SONYPI_COMMAND_GETCAMERAAGC 15 /* obsolete */
149#define SONYPI_COMMAND_SETCAMERAAGC 16
150#define SONYPI_COMMAND_GETCAMERADIRECTION 17 /* obsolete */
151#define SONYPI_COMMAND_GETCAMERAROMVERSION 18 /* obsolete */
152#define SONYPI_COMMAND_GETCAMERAREVISION 19 /* obsolete */
153
154int sonypi_camera_command(int command, u8 value);
155
156#endif /* __KERNEL__ */
157
158#endif /* _SONYPI_H_ */
diff --git a/include/linux/sort.h b/include/linux/sort.h
new file mode 100644
index 000000000000..d534da2b5575
--- /dev/null
+++ b/include/linux/sort.h
@@ -0,0 +1,10 @@
1#ifndef _LINUX_SORT_H
2#define _LINUX_SORT_H
3
4#include <linux/types.h>
5
6void sort(void *base, size_t num, size_t size,
7 int (*cmp)(const void *, const void *),
8 void (*swap)(void *, void *, int));
9
10#endif
diff --git a/include/linux/sound.h b/include/linux/sound.h
new file mode 100644
index 000000000000..428f59794f48
--- /dev/null
+++ b/include/linux/sound.h
@@ -0,0 +1,42 @@
1
2/*
3 * Minor numbers for the sound driver.
4 */
5
6#include <linux/fs.h>
7
8#define SND_DEV_CTL 0 /* Control port /dev/mixer */
9#define SND_DEV_SEQ 1 /* Sequencer output /dev/sequencer (FM
10 synthesizer and MIDI output) */
11#define SND_DEV_MIDIN 2 /* Raw midi access */
12#define SND_DEV_DSP 3 /* Digitized voice /dev/dsp */
13#define SND_DEV_AUDIO 4 /* Sparc compatible /dev/audio */
14#define SND_DEV_DSP16 5 /* Like /dev/dsp but 16 bits/sample */
15/* #define SND_DEV_STATUS 6 */ /* /dev/sndstat (obsolete) */
16#define SND_DEV_UNUSED 6
17#define SND_DEV_AWFM 7 /* Reserved */
18#define SND_DEV_SEQ2 8 /* /dev/sequencer, level 2 interface */
19/* #define SND_DEV_SNDPROC 9 */ /* /dev/sndproc for programmable devices (not used) */
20/* #define SND_DEV_DMMIDI 9 */
21#define SND_DEV_SYNTH 9 /* Raw synth access /dev/synth (same as /dev/dmfm) */
22#define SND_DEV_DMFM 10 /* Raw synth access /dev/dmfm */
23#define SND_DEV_UNKNOWN11 11
24#define SND_DEV_ADSP 12 /* Like /dev/dsp (obsolete) */
25#define SND_DEV_AMIDI 13 /* Like /dev/midi (obsolete) */
26#define SND_DEV_ADMMIDI 14 /* Like /dev/dmmidi (onsolete) */
27
28/*
29 * Sound core interface functions
30 */
31
32extern int register_sound_special(struct file_operations *fops, int unit);
33extern int register_sound_mixer(struct file_operations *fops, int dev);
34extern int register_sound_midi(struct file_operations *fops, int dev);
35extern int register_sound_dsp(struct file_operations *fops, int dev);
36extern int register_sound_synth(struct file_operations *fops, int dev);
37
38extern void unregister_sound_special(int unit);
39extern void unregister_sound_mixer(int unit);
40extern void unregister_sound_midi(int unit);
41extern void unregister_sound_dsp(int unit);
42extern void unregister_sound_synth(int unit);
diff --git a/include/linux/soundcard.h b/include/linux/soundcard.h
new file mode 100644
index 000000000000..28d2d1881978
--- /dev/null
+++ b/include/linux/soundcard.h
@@ -0,0 +1,1298 @@
1#ifndef SOUNDCARD_H
2#define SOUNDCARD_H
3/*
4 * Copyright by Hannu Savolainen 1993-1997
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 2.
10 * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
18 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27
28/*
29 * OSS interface version. With versions earlier than 3.6 this value is
30 * an integer with value less than 361. In versions 3.6 and later
31 * it's a six digit hexadecimal value. For example value
32 * of 0x030600 represents OSS version 3.6.0.
33 * Use ioctl(fd, OSS_GETVERSION, &int) to get the version number of
34 * the currently active driver.
35 */
36#define SOUND_VERSION 0x030802
37#define OPEN_SOUND_SYSTEM
38
39/* In Linux we need to be prepared for cross compiling */
40#include <linux/ioctl.h>
41
42/*
43 * Supported card ID numbers (Should be somewhere else?)
44 */
45
46#define SNDCARD_ADLIB 1
47#define SNDCARD_SB 2
48#define SNDCARD_PAS 3
49#define SNDCARD_GUS 4
50#define SNDCARD_MPU401 5
51#define SNDCARD_SB16 6
52#define SNDCARD_SB16MIDI 7
53#define SNDCARD_UART6850 8
54#define SNDCARD_GUS16 9
55#define SNDCARD_MSS 10
56#define SNDCARD_PSS 11
57#define SNDCARD_SSCAPE 12
58#define SNDCARD_PSS_MPU 13
59#define SNDCARD_PSS_MSS 14
60#define SNDCARD_SSCAPE_MSS 15
61#define SNDCARD_TRXPRO 16
62#define SNDCARD_TRXPRO_SB 17
63#define SNDCARD_TRXPRO_MPU 18
64#define SNDCARD_MAD16 19
65#define SNDCARD_MAD16_MPU 20
66#define SNDCARD_CS4232 21
67#define SNDCARD_CS4232_MPU 22
68#define SNDCARD_MAUI 23
69#define SNDCARD_PSEUDO_MSS 24
70#define SNDCARD_GUSPNP 25
71#define SNDCARD_UART401 26
72/* Sound card numbers 27 to N are reserved. Don't add more numbers here. */
73
74/***********************************
75 * IOCTL Commands for /dev/sequencer
76 */
77
78#ifndef _SIOWR
79#if defined(_IOWR) && (defined(_AIX) || (!defined(sun) && !defined(sparc) && !defined(__sparc__) && !defined(__INCioctlh) && !defined(__Lynx__)))
80/* Use already defined ioctl defines if they exist (except with Sun or Sparc) */
81#define SIOCPARM_MASK IOCPARM_MASK
82#define SIOC_VOID IOC_VOID
83#define SIOC_OUT IOC_OUT
84#define SIOC_IN IOC_IN
85#define SIOC_INOUT IOC_INOUT
86#define _SIOC_SIZE _IOC_SIZE
87#define _SIOC_DIR _IOC_DIR
88#define _SIOC_NONE _IOC_NONE
89#define _SIOC_READ _IOC_READ
90#define _SIOC_WRITE _IOC_WRITE
91#define _SIO _IO
92#define _SIOR _IOR
93#define _SIOW _IOW
94#define _SIOWR _IOWR
95#else
96
97/* Ioctl's have the command encoded in the lower word,
98 * and the size of any in or out parameters in the upper
99 * word. The high 2 bits of the upper word are used
100 * to encode the in/out status of the parameter; for now
101 * we restrict parameters to at most 8191 bytes.
102 */
103/* #define SIOCTYPE (0xff<<8) */
104#define SIOCPARM_MASK 0x1fff /* parameters must be < 8192 bytes */
105#define SIOC_VOID 0x00000000 /* no parameters */
106#define SIOC_OUT 0x20000000 /* copy out parameters */
107#define SIOC_IN 0x40000000 /* copy in parameters */
108#define SIOC_INOUT (SIOC_IN|SIOC_OUT)
109/* the 0x20000000 is so we can distinguish new ioctl's from old */
110#define _SIO(x,y) ((int)(SIOC_VOID|(x<<8)|y))
111#define _SIOR(x,y,t) ((int)(SIOC_OUT|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y))
112#define _SIOW(x,y,t) ((int)(SIOC_IN|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y))
113/* this should be _SIORW, but stdio got there first */
114#define _SIOWR(x,y,t) ((int)(SIOC_INOUT|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y))
115#define _SIOC_SIZE(x) ((x>>16)&SIOCPARM_MASK)
116#define _SIOC_DIR(x) (x & 0xf0000000)
117#define _SIOC_NONE SIOC_VOID
118#define _SIOC_READ SIOC_OUT
119#define _SIOC_WRITE SIOC_IN
120# endif /* _IOWR */
121#endif /* !_SIOWR */
122
123#define SNDCTL_SEQ_RESET _SIO ('Q', 0)
124#define SNDCTL_SEQ_SYNC _SIO ('Q', 1)
125#define SNDCTL_SYNTH_INFO _SIOWR('Q', 2, struct synth_info)
126#define SNDCTL_SEQ_CTRLRATE _SIOWR('Q', 3, int) /* Set/get timer resolution (HZ) */
127#define SNDCTL_SEQ_GETOUTCOUNT _SIOR ('Q', 4, int)
128#define SNDCTL_SEQ_GETINCOUNT _SIOR ('Q', 5, int)
129#define SNDCTL_SEQ_PERCMODE _SIOW ('Q', 6, int)
130#define SNDCTL_FM_LOAD_INSTR _SIOW ('Q', 7, struct sbi_instrument) /* Obsolete. Don't use!!!!!! */
131#define SNDCTL_SEQ_TESTMIDI _SIOW ('Q', 8, int)
132#define SNDCTL_SEQ_RESETSAMPLES _SIOW ('Q', 9, int)
133#define SNDCTL_SEQ_NRSYNTHS _SIOR ('Q',10, int)
134#define SNDCTL_SEQ_NRMIDIS _SIOR ('Q',11, int)
135#define SNDCTL_MIDI_INFO _SIOWR('Q',12, struct midi_info)
136#define SNDCTL_SEQ_THRESHOLD _SIOW ('Q',13, int)
137#define SNDCTL_SYNTH_MEMAVL _SIOWR('Q',14, int) /* in=dev#, out=memsize */
138#define SNDCTL_FM_4OP_ENABLE _SIOW ('Q',15, int) /* in=dev# */
139#define SNDCTL_SEQ_PANIC _SIO ('Q',17)
140#define SNDCTL_SEQ_OUTOFBAND _SIOW ('Q',18, struct seq_event_rec)
141#define SNDCTL_SEQ_GETTIME _SIOR ('Q',19, int)
142#define SNDCTL_SYNTH_ID _SIOWR('Q',20, struct synth_info)
143#define SNDCTL_SYNTH_CONTROL _SIOWR('Q',21, struct synth_control)
144#define SNDCTL_SYNTH_REMOVESAMPLE _SIOWR('Q',22, struct remove_sample)
145
146typedef struct synth_control
147{
148 int devno; /* Synthesizer # */
149 char data[4000]; /* Device spesific command/data record */
150}synth_control;
151
152typedef struct remove_sample
153{
154 int devno; /* Synthesizer # */
155 int bankno; /* MIDI bank # (0=General MIDI) */
156 int instrno; /* MIDI instrument number */
157} remove_sample;
158
159typedef struct seq_event_rec {
160 unsigned char arr[8];
161} seq_event_rec;
162
163#define SNDCTL_TMR_TIMEBASE _SIOWR('T', 1, int)
164#define SNDCTL_TMR_START _SIO ('T', 2)
165#define SNDCTL_TMR_STOP _SIO ('T', 3)
166#define SNDCTL_TMR_CONTINUE _SIO ('T', 4)
167#define SNDCTL_TMR_TEMPO _SIOWR('T', 5, int)
168#define SNDCTL_TMR_SOURCE _SIOWR('T', 6, int)
169# define TMR_INTERNAL 0x00000001
170# define TMR_EXTERNAL 0x00000002
171# define TMR_MODE_MIDI 0x00000010
172# define TMR_MODE_FSK 0x00000020
173# define TMR_MODE_CLS 0x00000040
174# define TMR_MODE_SMPTE 0x00000080
175#define SNDCTL_TMR_METRONOME _SIOW ('T', 7, int)
176#define SNDCTL_TMR_SELECT _SIOW ('T', 8, int)
177
178/*
179 * Some big endian/little endian handling macros
180 */
181
182#if defined(_AIX) || defined(AIX) || defined(sparc) || defined(__sparc__) || defined(HPPA) || defined(PPC) || defined(__mc68000__)
183/* Big endian machines */
184# define _PATCHKEY(id) (0xfd00|id)
185# define AFMT_S16_NE AFMT_S16_BE
186#else
187# define _PATCHKEY(id) ((id<<8)|0xfd)
188# define AFMT_S16_NE AFMT_S16_LE
189#endif
190
191/*
192 * Sample loading mechanism for internal synthesizers (/dev/sequencer)
193 * The following patch_info structure has been designed to support
194 * Gravis UltraSound. It tries to be universal format for uploading
195 * sample based patches but is probably too limited.
196 *
197 * (PBD) As Hannu guessed, the GUS structure is too limited for
198 * the WaveFront, but this is the right place for a constant definition.
199 */
200
201struct patch_info {
202 unsigned short key; /* Use WAVE_PATCH here */
203#define WAVE_PATCH _PATCHKEY(0x04)
204#define GUS_PATCH WAVE_PATCH
205#define WAVEFRONT_PATCH _PATCHKEY(0x06)
206
207 short device_no; /* Synthesizer number */
208 short instr_no; /* Midi pgm# */
209
210 unsigned int mode;
211/*
212 * The least significant byte has the same format than the GUS .PAT
213 * files
214 */
215#define WAVE_16_BITS 0x01 /* bit 0 = 8 or 16 bit wave data. */
216#define WAVE_UNSIGNED 0x02 /* bit 1 = Signed - Unsigned data. */
217#define WAVE_LOOPING 0x04 /* bit 2 = looping enabled-1. */
218#define WAVE_BIDIR_LOOP 0x08 /* bit 3 = Set is bidirectional looping. */
219#define WAVE_LOOP_BACK 0x10 /* bit 4 = Set is looping backward. */
220#define WAVE_SUSTAIN_ON 0x20 /* bit 5 = Turn sustaining on. (Env. pts. 3)*/
221#define WAVE_ENVELOPES 0x40 /* bit 6 = Enable envelopes - 1 */
222#define WAVE_FAST_RELEASE 0x80 /* bit 7 = Shut off immediately after note off */
223 /* (use the env_rate/env_offs fields). */
224/* Linux specific bits */
225#define WAVE_VIBRATO 0x00010000 /* The vibrato info is valid */
226#define WAVE_TREMOLO 0x00020000 /* The tremolo info is valid */
227#define WAVE_SCALE 0x00040000 /* The scaling info is valid */
228#define WAVE_FRACTIONS 0x00080000 /* Fraction information is valid */
229/* Reserved bits */
230#define WAVE_ROM 0x40000000 /* For future use */
231#define WAVE_MULAW 0x20000000 /* For future use */
232/* Other bits must be zeroed */
233
234 int len; /* Size of the wave data in bytes */
235 int loop_start, loop_end; /* Byte offsets from the beginning */
236
237/*
238 * The base_freq and base_note fields are used when computing the
239 * playback speed for a note. The base_note defines the tone frequency
240 * which is heard if the sample is played using the base_freq as the
241 * playback speed.
242 *
243 * The low_note and high_note fields define the minimum and maximum note
244 * frequencies for which this sample is valid. It is possible to define
245 * more than one samples for an instrument number at the same time. The
246 * low_note and high_note fields are used to select the most suitable one.
247 *
248 * The fields base_note, high_note and low_note should contain
249 * the note frequency multiplied by 1000. For example value for the
250 * middle A is 440*1000.
251 */
252
253 unsigned int base_freq;
254 unsigned int base_note;
255 unsigned int high_note;
256 unsigned int low_note;
257 int panning; /* -128=left, 127=right */
258 int detuning;
259
260/* New fields introduced in version 1.99.5 */
261
262 /* Envelope. Enabled by mode bit WAVE_ENVELOPES */
263 unsigned char env_rate[ 6 ]; /* GUS HW ramping rate */
264 unsigned char env_offset[ 6 ]; /* 255 == 100% */
265
266 /*
267 * The tremolo, vibrato and scale info are not supported yet.
268 * Enable by setting the mode bits WAVE_TREMOLO, WAVE_VIBRATO or
269 * WAVE_SCALE
270 */
271
272 unsigned char tremolo_sweep;
273 unsigned char tremolo_rate;
274 unsigned char tremolo_depth;
275
276 unsigned char vibrato_sweep;
277 unsigned char vibrato_rate;
278 unsigned char vibrato_depth;
279
280 int scale_frequency;
281 unsigned int scale_factor; /* from 0 to 2048 or 0 to 2 */
282
283 int volume;
284 int fractions;
285 int reserved1;
286 int spare[2];
287 char data[1]; /* The waveform data starts here */
288 };
289
290struct sysex_info {
291 short key; /* Use SYSEX_PATCH or MAUI_PATCH here */
292#define SYSEX_PATCH _PATCHKEY(0x05)
293#define MAUI_PATCH _PATCHKEY(0x06)
294 short device_no; /* Synthesizer number */
295 int len; /* Size of the sysex data in bytes */
296 unsigned char data[1]; /* Sysex data starts here */
297 };
298
299/*
300 * /dev/sequencer input events.
301 *
302 * The data written to the /dev/sequencer is a stream of events. Events
303 * are records of 4 or 8 bytes. The first byte defines the size.
304 * Any number of events can be written with a write call. There
305 * is a set of macros for sending these events. Use these macros if you
306 * want to maximize portability of your program.
307 *
308 * Events SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO. Are also input events.
309 * (All input events are currently 4 bytes long. Be prepared to support
310 * 8 byte events also. If you receive any event having first byte >= 128,
311 * it's a 8 byte event.
312 *
313 * The events are documented at the end of this file.
314 *
315 * Normal events (4 bytes)
316 * There is also a 8 byte version of most of the 4 byte events. The
317 * 8 byte one is recommended.
318 */
319#define SEQ_NOTEOFF 0
320#define SEQ_FMNOTEOFF SEQ_NOTEOFF /* Just old name */
321#define SEQ_NOTEON 1
322#define SEQ_FMNOTEON SEQ_NOTEON
323#define SEQ_WAIT TMR_WAIT_ABS
324#define SEQ_PGMCHANGE 3
325#define SEQ_FMPGMCHANGE SEQ_PGMCHANGE
326#define SEQ_SYNCTIMER TMR_START
327#define SEQ_MIDIPUTC 5
328#define SEQ_DRUMON 6 /*** OBSOLETE ***/
329#define SEQ_DRUMOFF 7 /*** OBSOLETE ***/
330#define SEQ_ECHO TMR_ECHO /* For synching programs with output */
331#define SEQ_AFTERTOUCH 9
332#define SEQ_CONTROLLER 10
333
334/*******************************************
335 * Midi controller numbers
336 *******************************************
337 * Controllers 0 to 31 (0x00 to 0x1f) and
338 * 32 to 63 (0x20 to 0x3f) are continuous
339 * controllers.
340 * In the MIDI 1.0 these controllers are sent using
341 * two messages. Controller numbers 0 to 31 are used
342 * to send the MSB and the controller numbers 32 to 63
343 * are for the LSB. Note that just 7 bits are used in MIDI bytes.
344 */
345
346#define CTL_BANK_SELECT 0x00
347#define CTL_MODWHEEL 0x01
348#define CTL_BREATH 0x02
349/* undefined 0x03 */
350#define CTL_FOOT 0x04
351#define CTL_PORTAMENTO_TIME 0x05
352#define CTL_DATA_ENTRY 0x06
353#define CTL_MAIN_VOLUME 0x07
354#define CTL_BALANCE 0x08
355/* undefined 0x09 */
356#define CTL_PAN 0x0a
357#define CTL_EXPRESSION 0x0b
358/* undefined 0x0c */
359/* undefined 0x0d */
360/* undefined 0x0e */
361/* undefined 0x0f */
362#define CTL_GENERAL_PURPOSE1 0x10
363#define CTL_GENERAL_PURPOSE2 0x11
364#define CTL_GENERAL_PURPOSE3 0x12
365#define CTL_GENERAL_PURPOSE4 0x13
366/* undefined 0x14 - 0x1f */
367
368/* undefined 0x20 */
369/* The controller numbers 0x21 to 0x3f are reserved for the */
370/* least significant bytes of the controllers 0x00 to 0x1f. */
371/* These controllers are not recognised by the driver. */
372
373/* Controllers 64 to 69 (0x40 to 0x45) are on/off switches. */
374/* 0=OFF and 127=ON (intermediate values are possible) */
375#define CTL_DAMPER_PEDAL 0x40
376#define CTL_SUSTAIN 0x40 /* Alias */
377#define CTL_HOLD 0x40 /* Alias */
378#define CTL_PORTAMENTO 0x41
379#define CTL_SOSTENUTO 0x42
380#define CTL_SOFT_PEDAL 0x43
381/* undefined 0x44 */
382#define CTL_HOLD2 0x45
383/* undefined 0x46 - 0x4f */
384
385#define CTL_GENERAL_PURPOSE5 0x50
386#define CTL_GENERAL_PURPOSE6 0x51
387#define CTL_GENERAL_PURPOSE7 0x52
388#define CTL_GENERAL_PURPOSE8 0x53
389/* undefined 0x54 - 0x5a */
390#define CTL_EXT_EFF_DEPTH 0x5b
391#define CTL_TREMOLO_DEPTH 0x5c
392#define CTL_CHORUS_DEPTH 0x5d
393#define CTL_DETUNE_DEPTH 0x5e
394#define CTL_CELESTE_DEPTH 0x5e /* Alias for the above one */
395#define CTL_PHASER_DEPTH 0x5f
396#define CTL_DATA_INCREMENT 0x60
397#define CTL_DATA_DECREMENT 0x61
398#define CTL_NONREG_PARM_NUM_LSB 0x62
399#define CTL_NONREG_PARM_NUM_MSB 0x63
400#define CTL_REGIST_PARM_NUM_LSB 0x64
401#define CTL_REGIST_PARM_NUM_MSB 0x65
402/* undefined 0x66 - 0x78 */
403/* reserved 0x79 - 0x7f */
404
405/* Pseudo controllers (not midi compatible) */
406#define CTRL_PITCH_BENDER 255
407#define CTRL_PITCH_BENDER_RANGE 254
408#define CTRL_EXPRESSION 253 /* Obsolete */
409#define CTRL_MAIN_VOLUME 252 /* Obsolete */
410#define SEQ_BALANCE 11
411#define SEQ_VOLMODE 12
412
413/*
414 * Volume mode decides how volumes are used
415 */
416
417#define VOL_METHOD_ADAGIO 1
418#define VOL_METHOD_LINEAR 2
419
420/*
421 * Note! SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO are used also as
422 * input events.
423 */
424
425/*
426 * Event codes 0xf0 to 0xfc are reserved for future extensions.
427 */
428
429#define SEQ_FULLSIZE 0xfd /* Long events */
430/*
431 * SEQ_FULLSIZE events are used for loading patches/samples to the
432 * synthesizer devices. These events are passed directly to the driver
433 * of the associated synthesizer device. There is no limit to the size
434 * of the extended events. These events are not queued but executed
435 * immediately when the write() is called (execution can take several
436 * seconds of time).
437 *
438 * When a SEQ_FULLSIZE message is written to the device, it must
439 * be written using exactly one write() call. Other events cannot
440 * be mixed to the same write.
441 *
442 * For FM synths (YM3812/OPL3) use struct sbi_instrument and write it to the
443 * /dev/sequencer. Don't write other data together with the instrument structure
444 * Set the key field of the structure to FM_PATCH. The device field is used to
445 * route the patch to the corresponding device.
446 *
447 * For wave table use struct patch_info. Initialize the key field
448 * to WAVE_PATCH.
449 */
450#define SEQ_PRIVATE 0xfe /* Low level HW dependent events (8 bytes) */
451#define SEQ_EXTENDED 0xff /* Extended events (8 bytes) OBSOLETE */
452
453/*
454 * Record for FM patches
455 */
456
457typedef unsigned char sbi_instr_data[32];
458
459struct sbi_instrument {
460 unsigned short key; /* FM_PATCH or OPL3_PATCH */
461#define FM_PATCH _PATCHKEY(0x01)
462#define OPL3_PATCH _PATCHKEY(0x03)
463 short device; /* Synth# (0-4) */
464 int channel; /* Program# to be initialized */
465 sbi_instr_data operators; /* Register settings for operator cells (.SBI format) */
466 };
467
468struct synth_info { /* Read only */
469 char name[30];
470 int device; /* 0-N. INITIALIZE BEFORE CALLING */
471 int synth_type;
472#define SYNTH_TYPE_FM 0
473#define SYNTH_TYPE_SAMPLE 1
474#define SYNTH_TYPE_MIDI 2 /* Midi interface */
475
476 int synth_subtype;
477#define FM_TYPE_ADLIB 0x00
478#define FM_TYPE_OPL3 0x01
479#define MIDI_TYPE_MPU401 0x401
480
481#define SAMPLE_TYPE_BASIC 0x10
482#define SAMPLE_TYPE_GUS SAMPLE_TYPE_BASIC
483#define SAMPLE_TYPE_WAVEFRONT 0x11
484
485 int perc_mode; /* No longer supported */
486 int nr_voices;
487 int nr_drums; /* Obsolete field */
488 int instr_bank_size;
489 unsigned int capabilities;
490#define SYNTH_CAP_PERCMODE 0x00000001 /* No longer used */
491#define SYNTH_CAP_OPL3 0x00000002 /* Set if OPL3 supported */
492#define SYNTH_CAP_INPUT 0x00000004 /* Input (MIDI) device */
493 int dummies[19]; /* Reserve space */
494 };
495
496struct sound_timer_info {
497 char name[32];
498 int caps;
499 };
500
501#define MIDI_CAP_MPU401 1 /* MPU-401 intelligent mode */
502
503struct midi_info {
504 char name[30];
505 int device; /* 0-N. INITIALIZE BEFORE CALLING */
506 unsigned int capabilities; /* To be defined later */
507 int dev_type;
508 int dummies[18]; /* Reserve space */
509 };
510
511/********************************************
512 * ioctl commands for the /dev/midi##
513 */
514typedef struct {
515 unsigned char cmd;
516 char nr_args, nr_returns;
517 unsigned char data[30];
518 } mpu_command_rec;
519
520#define SNDCTL_MIDI_PRETIME _SIOWR('m', 0, int)
521#define SNDCTL_MIDI_MPUMODE _SIOWR('m', 1, int)
522#define SNDCTL_MIDI_MPUCMD _SIOWR('m', 2, mpu_command_rec)
523
524/********************************************
525 * IOCTL commands for /dev/dsp and /dev/audio
526 */
527
528#define SNDCTL_DSP_RESET _SIO ('P', 0)
529#define SNDCTL_DSP_SYNC _SIO ('P', 1)
530#define SNDCTL_DSP_SPEED _SIOWR('P', 2, int)
531#define SNDCTL_DSP_STEREO _SIOWR('P', 3, int)
532#define SNDCTL_DSP_GETBLKSIZE _SIOWR('P', 4, int)
533#define SNDCTL_DSP_SAMPLESIZE SNDCTL_DSP_SETFMT
534#define SNDCTL_DSP_CHANNELS _SIOWR('P', 6, int)
535#define SOUND_PCM_WRITE_CHANNELS SNDCTL_DSP_CHANNELS
536#define SOUND_PCM_WRITE_FILTER _SIOWR('P', 7, int)
537#define SNDCTL_DSP_POST _SIO ('P', 8)
538#define SNDCTL_DSP_SUBDIVIDE _SIOWR('P', 9, int)
539#define SNDCTL_DSP_SETFRAGMENT _SIOWR('P',10, int)
540
541/* Audio data formats (Note! U8=8 and S16_LE=16 for compatibility) */
542#define SNDCTL_DSP_GETFMTS _SIOR ('P',11, int) /* Returns a mask */
543#define SNDCTL_DSP_SETFMT _SIOWR('P',5, int) /* Selects ONE fmt*/
544# define AFMT_QUERY 0x00000000 /* Return current fmt */
545# define AFMT_MU_LAW 0x00000001
546# define AFMT_A_LAW 0x00000002
547# define AFMT_IMA_ADPCM 0x00000004
548# define AFMT_U8 0x00000008
549# define AFMT_S16_LE 0x00000010 /* Little endian signed 16*/
550# define AFMT_S16_BE 0x00000020 /* Big endian signed 16 */
551# define AFMT_S8 0x00000040
552# define AFMT_U16_LE 0x00000080 /* Little endian U16 */
553# define AFMT_U16_BE 0x00000100 /* Big endian U16 */
554# define AFMT_MPEG 0x00000200 /* MPEG (2) audio */
555# define AFMT_AC3 0x00000400 /* Dolby Digital AC3 */
556
557/*
558 * Buffer status queries.
559 */
560typedef struct audio_buf_info {
561 int fragments; /* # of available fragments (partially usend ones not counted) */
562 int fragstotal; /* Total # of fragments allocated */
563 int fragsize; /* Size of a fragment in bytes */
564
565 int bytes; /* Available space in bytes (includes partially used fragments) */
566 /* Note! 'bytes' could be more than fragments*fragsize */
567 } audio_buf_info;
568
569#define SNDCTL_DSP_GETOSPACE _SIOR ('P',12, audio_buf_info)
570#define SNDCTL_DSP_GETISPACE _SIOR ('P',13, audio_buf_info)
571#define SNDCTL_DSP_NONBLOCK _SIO ('P',14)
572#define SNDCTL_DSP_GETCAPS _SIOR ('P',15, int)
573# define DSP_CAP_REVISION 0x000000ff /* Bits for revision level (0 to 255) */
574# define DSP_CAP_DUPLEX 0x00000100 /* Full duplex record/playback */
575# define DSP_CAP_REALTIME 0x00000200 /* Real time capability */
576# define DSP_CAP_BATCH 0x00000400 /* Device has some kind of */
577 /* internal buffers which may */
578 /* cause some delays and */
579 /* decrease precision of timing */
580# define DSP_CAP_COPROC 0x00000800 /* Has a coprocessor */
581 /* Sometimes it's a DSP */
582 /* but usually not */
583# define DSP_CAP_TRIGGER 0x00001000 /* Supports SETTRIGGER */
584# define DSP_CAP_MMAP 0x00002000 /* Supports mmap() */
585# define DSP_CAP_MULTI 0x00004000 /* support multiple open */
586# define DSP_CAP_BIND 0x00008000 /* channel binding to front/rear/cneter/lfe */
587
588
589#define SNDCTL_DSP_GETTRIGGER _SIOR ('P',16, int)
590#define SNDCTL_DSP_SETTRIGGER _SIOW ('P',16, int)
591# define PCM_ENABLE_INPUT 0x00000001
592# define PCM_ENABLE_OUTPUT 0x00000002
593
594typedef struct count_info {
595 int bytes; /* Total # of bytes processed */
596 int blocks; /* # of fragment transitions since last time */
597 int ptr; /* Current DMA pointer value */
598 } count_info;
599
600#define SNDCTL_DSP_GETIPTR _SIOR ('P',17, count_info)
601#define SNDCTL_DSP_GETOPTR _SIOR ('P',18, count_info)
602
603typedef struct buffmem_desc {
604 unsigned *buffer;
605 int size;
606 } buffmem_desc;
607#define SNDCTL_DSP_MAPINBUF _SIOR ('P', 19, buffmem_desc)
608#define SNDCTL_DSP_MAPOUTBUF _SIOR ('P', 20, buffmem_desc)
609#define SNDCTL_DSP_SETSYNCRO _SIO ('P', 21)
610#define SNDCTL_DSP_SETDUPLEX _SIO ('P', 22)
611#define SNDCTL_DSP_GETODELAY _SIOR ('P', 23, int)
612
613#define SNDCTL_DSP_GETCHANNELMASK _SIOWR('P', 64, int)
614#define SNDCTL_DSP_BIND_CHANNEL _SIOWR('P', 65, int)
615# define DSP_BIND_QUERY 0x00000000
616# define DSP_BIND_FRONT 0x00000001
617# define DSP_BIND_SURR 0x00000002
618# define DSP_BIND_CENTER_LFE 0x00000004
619# define DSP_BIND_HANDSET 0x00000008
620# define DSP_BIND_MIC 0x00000010
621# define DSP_BIND_MODEM1 0x00000020
622# define DSP_BIND_MODEM2 0x00000040
623# define DSP_BIND_I2S 0x00000080
624# define DSP_BIND_SPDIF 0x00000100
625
626#define SNDCTL_DSP_SETSPDIF _SIOW ('P', 66, int)
627#define SNDCTL_DSP_GETSPDIF _SIOR ('P', 67, int)
628# define SPDIF_PRO 0x0001
629# define SPDIF_N_AUD 0x0002
630# define SPDIF_COPY 0x0004
631# define SPDIF_PRE 0x0008
632# define SPDIF_CC 0x07f0
633# define SPDIF_L 0x0800
634# define SPDIF_DRS 0x4000
635# define SPDIF_V 0x8000
636
637/*
638 * Application's profile defines the way how playback underrun situations should be handled.
639 *
640 * APF_NORMAL (the default) and APF_NETWORK make the driver to cleanup the
641 * playback buffer whenever an underrun occurs. This consumes some time
642 * prevents looping the existing buffer.
643 * APF_CPUINTENS is intended to be set by CPU intensive applications which
644 * are likely to run out of time occasionally. In this mode the buffer cleanup is
645 * disabled which saves CPU time but also let's the previous buffer content to
646 * be played during the "pause" after the underrun.
647 */
648#define SNDCTL_DSP_PROFILE _SIOW ('P', 23, int)
649#define APF_NORMAL 0 /* Normal applications */
650#define APF_NETWORK 1 /* Underruns probably caused by an "external" delay */
651#define APF_CPUINTENS 2 /* Underruns probably caused by "overheating" the CPU */
652
653#define SOUND_PCM_READ_RATE _SIOR ('P', 2, int)
654#define SOUND_PCM_READ_CHANNELS _SIOR ('P', 6, int)
655#define SOUND_PCM_READ_BITS _SIOR ('P', 5, int)
656#define SOUND_PCM_READ_FILTER _SIOR ('P', 7, int)
657
658/* Some alias names */
659#define SOUND_PCM_WRITE_BITS SNDCTL_DSP_SETFMT
660#define SOUND_PCM_WRITE_RATE SNDCTL_DSP_SPEED
661#define SOUND_PCM_POST SNDCTL_DSP_POST
662#define SOUND_PCM_RESET SNDCTL_DSP_RESET
663#define SOUND_PCM_SYNC SNDCTL_DSP_SYNC
664#define SOUND_PCM_SUBDIVIDE SNDCTL_DSP_SUBDIVIDE
665#define SOUND_PCM_SETFRAGMENT SNDCTL_DSP_SETFRAGMENT
666#define SOUND_PCM_GETFMTS SNDCTL_DSP_GETFMTS
667#define SOUND_PCM_SETFMT SNDCTL_DSP_SETFMT
668#define SOUND_PCM_GETOSPACE SNDCTL_DSP_GETOSPACE
669#define SOUND_PCM_GETISPACE SNDCTL_DSP_GETISPACE
670#define SOUND_PCM_NONBLOCK SNDCTL_DSP_NONBLOCK
671#define SOUND_PCM_GETCAPS SNDCTL_DSP_GETCAPS
672#define SOUND_PCM_GETTRIGGER SNDCTL_DSP_GETTRIGGER
673#define SOUND_PCM_SETTRIGGER SNDCTL_DSP_SETTRIGGER
674#define SOUND_PCM_SETSYNCRO SNDCTL_DSP_SETSYNCRO
675#define SOUND_PCM_GETIPTR SNDCTL_DSP_GETIPTR
676#define SOUND_PCM_GETOPTR SNDCTL_DSP_GETOPTR
677#define SOUND_PCM_MAPINBUF SNDCTL_DSP_MAPINBUF
678#define SOUND_PCM_MAPOUTBUF SNDCTL_DSP_MAPOUTBUF
679
680/*
681 * ioctl calls to be used in communication with coprocessors and
682 * DSP chips.
683 */
684
685typedef struct copr_buffer {
686 int command; /* Set to 0 if not used */
687 int flags;
688#define CPF_NONE 0x0000
689#define CPF_FIRST 0x0001 /* First block */
690#define CPF_LAST 0x0002 /* Last block */
691 int len;
692 int offs; /* If required by the device (0 if not used) */
693
694 unsigned char data[4000]; /* NOTE! 4000 is not 4k */
695 } copr_buffer;
696
697typedef struct copr_debug_buf {
698 int command; /* Used internally. Set to 0 */
699 int parm1;
700 int parm2;
701 int flags;
702 int len; /* Length of data in bytes */
703 } copr_debug_buf;
704
705typedef struct copr_msg {
706 int len;
707 unsigned char data[4000];
708 } copr_msg;
709
710#define SNDCTL_COPR_RESET _SIO ('C', 0)
711#define SNDCTL_COPR_LOAD _SIOWR('C', 1, copr_buffer)
712#define SNDCTL_COPR_RDATA _SIOWR('C', 2, copr_debug_buf)
713#define SNDCTL_COPR_RCODE _SIOWR('C', 3, copr_debug_buf)
714#define SNDCTL_COPR_WDATA _SIOW ('C', 4, copr_debug_buf)
715#define SNDCTL_COPR_WCODE _SIOW ('C', 5, copr_debug_buf)
716#define SNDCTL_COPR_RUN _SIOWR('C', 6, copr_debug_buf)
717#define SNDCTL_COPR_HALT _SIOWR('C', 7, copr_debug_buf)
718#define SNDCTL_COPR_SENDMSG _SIOWR('C', 8, copr_msg)
719#define SNDCTL_COPR_RCVMSG _SIOR ('C', 9, copr_msg)
720
721/*********************************************
722 * IOCTL commands for /dev/mixer
723 */
724
725/*
726 * Mixer devices
727 *
728 * There can be up to 20 different analog mixer channels. The
729 * SOUND_MIXER_NRDEVICES gives the currently supported maximum.
730 * The SOUND_MIXER_READ_DEVMASK returns a bitmask which tells
731 * the devices supported by the particular mixer.
732 */
733
734#define SOUND_MIXER_NRDEVICES 25
735#define SOUND_MIXER_VOLUME 0
736#define SOUND_MIXER_BASS 1
737#define SOUND_MIXER_TREBLE 2
738#define SOUND_MIXER_SYNTH 3
739#define SOUND_MIXER_PCM 4
740#define SOUND_MIXER_SPEAKER 5
741#define SOUND_MIXER_LINE 6
742#define SOUND_MIXER_MIC 7
743#define SOUND_MIXER_CD 8
744#define SOUND_MIXER_IMIX 9 /* Recording monitor */
745#define SOUND_MIXER_ALTPCM 10
746#define SOUND_MIXER_RECLEV 11 /* Recording level */
747#define SOUND_MIXER_IGAIN 12 /* Input gain */
748#define SOUND_MIXER_OGAIN 13 /* Output gain */
749/*
750 * The AD1848 codec and compatibles have three line level inputs
751 * (line, aux1 and aux2). Since each card manufacturer have assigned
752 * different meanings to these inputs, it's inpractical to assign
753 * specific meanings (line, cd, synth etc.) to them.
754 */
755#define SOUND_MIXER_LINE1 14 /* Input source 1 (aux1) */
756#define SOUND_MIXER_LINE2 15 /* Input source 2 (aux2) */
757#define SOUND_MIXER_LINE3 16 /* Input source 3 (line) */
758#define SOUND_MIXER_DIGITAL1 17 /* Digital (input) 1 */
759#define SOUND_MIXER_DIGITAL2 18 /* Digital (input) 2 */
760#define SOUND_MIXER_DIGITAL3 19 /* Digital (input) 3 */
761#define SOUND_MIXER_PHONEIN 20 /* Phone input */
762#define SOUND_MIXER_PHONEOUT 21 /* Phone output */
763#define SOUND_MIXER_VIDEO 22 /* Video/TV (audio) in */
764#define SOUND_MIXER_RADIO 23 /* Radio in */
765#define SOUND_MIXER_MONITOR 24 /* Monitor (usually mic) volume */
766
767/* Some on/off settings (SOUND_SPECIAL_MIN - SOUND_SPECIAL_MAX) */
768/* Not counted to SOUND_MIXER_NRDEVICES, but use the same number space */
769#define SOUND_ONOFF_MIN 28
770#define SOUND_ONOFF_MAX 30
771
772/* Note! Number 31 cannot be used since the sign bit is reserved */
773#define SOUND_MIXER_NONE 31
774
775/*
776 * The following unsupported macros are no longer functional.
777 * Use SOUND_MIXER_PRIVATE# macros in future.
778 */
779#define SOUND_MIXER_ENHANCE SOUND_MIXER_NONE
780#define SOUND_MIXER_MUTE SOUND_MIXER_NONE
781#define SOUND_MIXER_LOUD SOUND_MIXER_NONE
782
783
784#define SOUND_DEVICE_LABELS {"Vol ", "Bass ", "Trebl", "Synth", "Pcm ", "Spkr ", "Line ", \
785 "Mic ", "CD ", "Mix ", "Pcm2 ", "Rec ", "IGain", "OGain", \
786 "Line1", "Line2", "Line3", "Digital1", "Digital2", "Digital3", \
787 "PhoneIn", "PhoneOut", "Video", "Radio", "Monitor"}
788
789#define SOUND_DEVICE_NAMES {"vol", "bass", "treble", "synth", "pcm", "speaker", "line", \
790 "mic", "cd", "mix", "pcm2", "rec", "igain", "ogain", \
791 "line1", "line2", "line3", "dig1", "dig2", "dig3", \
792 "phin", "phout", "video", "radio", "monitor"}
793
794/* Device bitmask identifiers */
795
796#define SOUND_MIXER_RECSRC 0xff /* Arg contains a bit for each recording source */
797#define SOUND_MIXER_DEVMASK 0xfe /* Arg contains a bit for each supported device */
798#define SOUND_MIXER_RECMASK 0xfd /* Arg contains a bit for each supported recording source */
799#define SOUND_MIXER_CAPS 0xfc
800# define SOUND_CAP_EXCL_INPUT 0x00000001 /* Only one recording source at a time */
801#define SOUND_MIXER_STEREODEVS 0xfb /* Mixer channels supporting stereo */
802#define SOUND_MIXER_OUTSRC 0xfa /* Arg contains a bit for each input source to output */
803#define SOUND_MIXER_OUTMASK 0xf9 /* Arg contains a bit for each supported input source to output */
804
805/* Device mask bits */
806
807#define SOUND_MASK_VOLUME (1 << SOUND_MIXER_VOLUME)
808#define SOUND_MASK_BASS (1 << SOUND_MIXER_BASS)
809#define SOUND_MASK_TREBLE (1 << SOUND_MIXER_TREBLE)
810#define SOUND_MASK_SYNTH (1 << SOUND_MIXER_SYNTH)
811#define SOUND_MASK_PCM (1 << SOUND_MIXER_PCM)
812#define SOUND_MASK_SPEAKER (1 << SOUND_MIXER_SPEAKER)
813#define SOUND_MASK_LINE (1 << SOUND_MIXER_LINE)
814#define SOUND_MASK_MIC (1 << SOUND_MIXER_MIC)
815#define SOUND_MASK_CD (1 << SOUND_MIXER_CD)
816#define SOUND_MASK_IMIX (1 << SOUND_MIXER_IMIX)
817#define SOUND_MASK_ALTPCM (1 << SOUND_MIXER_ALTPCM)
818#define SOUND_MASK_RECLEV (1 << SOUND_MIXER_RECLEV)
819#define SOUND_MASK_IGAIN (1 << SOUND_MIXER_IGAIN)
820#define SOUND_MASK_OGAIN (1 << SOUND_MIXER_OGAIN)
821#define SOUND_MASK_LINE1 (1 << SOUND_MIXER_LINE1)
822#define SOUND_MASK_LINE2 (1 << SOUND_MIXER_LINE2)
823#define SOUND_MASK_LINE3 (1 << SOUND_MIXER_LINE3)
824#define SOUND_MASK_DIGITAL1 (1 << SOUND_MIXER_DIGITAL1)
825#define SOUND_MASK_DIGITAL2 (1 << SOUND_MIXER_DIGITAL2)
826#define SOUND_MASK_DIGITAL3 (1 << SOUND_MIXER_DIGITAL3)
827#define SOUND_MASK_PHONEIN (1 << SOUND_MIXER_PHONEIN)
828#define SOUND_MASK_PHONEOUT (1 << SOUND_MIXER_PHONEOUT)
829#define SOUND_MASK_RADIO (1 << SOUND_MIXER_RADIO)
830#define SOUND_MASK_VIDEO (1 << SOUND_MIXER_VIDEO)
831#define SOUND_MASK_MONITOR (1 << SOUND_MIXER_MONITOR)
832
833/* Obsolete macros */
834#define SOUND_MASK_MUTE (1 << SOUND_MIXER_MUTE)
835#define SOUND_MASK_ENHANCE (1 << SOUND_MIXER_ENHANCE)
836#define SOUND_MASK_LOUD (1 << SOUND_MIXER_LOUD)
837
838#define MIXER_READ(dev) _SIOR('M', dev, int)
839#define SOUND_MIXER_READ_VOLUME MIXER_READ(SOUND_MIXER_VOLUME)
840#define SOUND_MIXER_READ_BASS MIXER_READ(SOUND_MIXER_BASS)
841#define SOUND_MIXER_READ_TREBLE MIXER_READ(SOUND_MIXER_TREBLE)
842#define SOUND_MIXER_READ_SYNTH MIXER_READ(SOUND_MIXER_SYNTH)
843#define SOUND_MIXER_READ_PCM MIXER_READ(SOUND_MIXER_PCM)
844#define SOUND_MIXER_READ_SPEAKER MIXER_READ(SOUND_MIXER_SPEAKER)
845#define SOUND_MIXER_READ_LINE MIXER_READ(SOUND_MIXER_LINE)
846#define SOUND_MIXER_READ_MIC MIXER_READ(SOUND_MIXER_MIC)
847#define SOUND_MIXER_READ_CD MIXER_READ(SOUND_MIXER_CD)
848#define SOUND_MIXER_READ_IMIX MIXER_READ(SOUND_MIXER_IMIX)
849#define SOUND_MIXER_READ_ALTPCM MIXER_READ(SOUND_MIXER_ALTPCM)
850#define SOUND_MIXER_READ_RECLEV MIXER_READ(SOUND_MIXER_RECLEV)
851#define SOUND_MIXER_READ_IGAIN MIXER_READ(SOUND_MIXER_IGAIN)
852#define SOUND_MIXER_READ_OGAIN MIXER_READ(SOUND_MIXER_OGAIN)
853#define SOUND_MIXER_READ_LINE1 MIXER_READ(SOUND_MIXER_LINE1)
854#define SOUND_MIXER_READ_LINE2 MIXER_READ(SOUND_MIXER_LINE2)
855#define SOUND_MIXER_READ_LINE3 MIXER_READ(SOUND_MIXER_LINE3)
856
857/* Obsolete macros */
858#define SOUND_MIXER_READ_MUTE MIXER_READ(SOUND_MIXER_MUTE)
859#define SOUND_MIXER_READ_ENHANCE MIXER_READ(SOUND_MIXER_ENHANCE)
860#define SOUND_MIXER_READ_LOUD MIXER_READ(SOUND_MIXER_LOUD)
861
862#define SOUND_MIXER_READ_RECSRC MIXER_READ(SOUND_MIXER_RECSRC)
863#define SOUND_MIXER_READ_DEVMASK MIXER_READ(SOUND_MIXER_DEVMASK)
864#define SOUND_MIXER_READ_RECMASK MIXER_READ(SOUND_MIXER_RECMASK)
865#define SOUND_MIXER_READ_STEREODEVS MIXER_READ(SOUND_MIXER_STEREODEVS)
866#define SOUND_MIXER_READ_CAPS MIXER_READ(SOUND_MIXER_CAPS)
867
868#define MIXER_WRITE(dev) _SIOWR('M', dev, int)
869#define SOUND_MIXER_WRITE_VOLUME MIXER_WRITE(SOUND_MIXER_VOLUME)
870#define SOUND_MIXER_WRITE_BASS MIXER_WRITE(SOUND_MIXER_BASS)
871#define SOUND_MIXER_WRITE_TREBLE MIXER_WRITE(SOUND_MIXER_TREBLE)
872#define SOUND_MIXER_WRITE_SYNTH MIXER_WRITE(SOUND_MIXER_SYNTH)
873#define SOUND_MIXER_WRITE_PCM MIXER_WRITE(SOUND_MIXER_PCM)
874#define SOUND_MIXER_WRITE_SPEAKER MIXER_WRITE(SOUND_MIXER_SPEAKER)
875#define SOUND_MIXER_WRITE_LINE MIXER_WRITE(SOUND_MIXER_LINE)
876#define SOUND_MIXER_WRITE_MIC MIXER_WRITE(SOUND_MIXER_MIC)
877#define SOUND_MIXER_WRITE_CD MIXER_WRITE(SOUND_MIXER_CD)
878#define SOUND_MIXER_WRITE_IMIX MIXER_WRITE(SOUND_MIXER_IMIX)
879#define SOUND_MIXER_WRITE_ALTPCM MIXER_WRITE(SOUND_MIXER_ALTPCM)
880#define SOUND_MIXER_WRITE_RECLEV MIXER_WRITE(SOUND_MIXER_RECLEV)
881#define SOUND_MIXER_WRITE_IGAIN MIXER_WRITE(SOUND_MIXER_IGAIN)
882#define SOUND_MIXER_WRITE_OGAIN MIXER_WRITE(SOUND_MIXER_OGAIN)
883#define SOUND_MIXER_WRITE_LINE1 MIXER_WRITE(SOUND_MIXER_LINE1)
884#define SOUND_MIXER_WRITE_LINE2 MIXER_WRITE(SOUND_MIXER_LINE2)
885#define SOUND_MIXER_WRITE_LINE3 MIXER_WRITE(SOUND_MIXER_LINE3)
886
887/* Obsolete macros */
888#define SOUND_MIXER_WRITE_MUTE MIXER_WRITE(SOUND_MIXER_MUTE)
889#define SOUND_MIXER_WRITE_ENHANCE MIXER_WRITE(SOUND_MIXER_ENHANCE)
890#define SOUND_MIXER_WRITE_LOUD MIXER_WRITE(SOUND_MIXER_LOUD)
891
892#define SOUND_MIXER_WRITE_RECSRC MIXER_WRITE(SOUND_MIXER_RECSRC)
893
894typedef struct mixer_info
895{
896 char id[16];
897 char name[32];
898 int modify_counter;
899 int fillers[10];
900} mixer_info;
901
902typedef struct _old_mixer_info /* Obsolete */
903{
904 char id[16];
905 char name[32];
906} _old_mixer_info;
907
908#define SOUND_MIXER_INFO _SIOR ('M', 101, mixer_info)
909#define SOUND_OLD_MIXER_INFO _SIOR ('M', 101, _old_mixer_info)
910
911/*
912 * A mechanism for accessing "proprietary" mixer features. This method
913 * permits passing 128 bytes of arbitrary data between a mixer application
914 * and the mixer driver. Interpretation of the record is defined by
915 * the particular mixer driver.
916 */
917typedef unsigned char mixer_record[128];
918
919#define SOUND_MIXER_ACCESS _SIOWR('M', 102, mixer_record)
920
921/*
922 * Two ioctls for special souncard function
923 */
924#define SOUND_MIXER_AGC _SIOWR('M', 103, int)
925#define SOUND_MIXER_3DSE _SIOWR('M', 104, int)
926
927/*
928 * The SOUND_MIXER_PRIVATE# commands can be redefined by low level drivers.
929 * These features can be used when accessing device specific features.
930 */
931#define SOUND_MIXER_PRIVATE1 _SIOWR('M', 111, int)
932#define SOUND_MIXER_PRIVATE2 _SIOWR('M', 112, int)
933#define SOUND_MIXER_PRIVATE3 _SIOWR('M', 113, int)
934#define SOUND_MIXER_PRIVATE4 _SIOWR('M', 114, int)
935#define SOUND_MIXER_PRIVATE5 _SIOWR('M', 115, int)
936
937/*
938 * SOUND_MIXER_GETLEVELS and SOUND_MIXER_SETLEVELS calls can be used
939 * for querying current mixer settings from the driver and for loading
940 * default volume settings _prior_ activating the mixer (loading
941 * doesn't affect current state of the mixer hardware). These calls
942 * are for internal use only.
943 */
944
945typedef struct mixer_vol_table {
946 int num; /* Index to volume table */
947 char name[32];
948 int levels[32];
949} mixer_vol_table;
950
951#define SOUND_MIXER_GETLEVELS _SIOWR('M', 116, mixer_vol_table)
952#define SOUND_MIXER_SETLEVELS _SIOWR('M', 117, mixer_vol_table)
953
954/*
955 * An ioctl for identifying the driver version. It will return value
956 * of the SOUND_VERSION macro used when compiling the driver.
957 * This call was introduced in OSS version 3.6 and it will not work
958 * with earlier versions (returns EINVAL).
959 */
960#define OSS_GETVERSION _SIOR ('M', 118, int)
961
962/*
963 * Level 2 event types for /dev/sequencer
964 */
965
966/*
967 * The 4 most significant bits of byte 0 specify the class of
968 * the event:
969 *
970 * 0x8X = system level events,
971 * 0x9X = device/port specific events, event[1] = device/port,
972 * The last 4 bits give the subtype:
973 * 0x02 = Channel event (event[3] = chn).
974 * 0x01 = note event (event[4] = note).
975 * (0x01 is not used alone but always with bit 0x02).
976 * event[2] = MIDI message code (0x80=note off etc.)
977 *
978 */
979
980#define EV_SEQ_LOCAL 0x80
981#define EV_TIMING 0x81
982#define EV_CHN_COMMON 0x92
983#define EV_CHN_VOICE 0x93
984#define EV_SYSEX 0x94
985/*
986 * Event types 200 to 220 are reserved for application use.
987 * These numbers will not be used by the driver.
988 */
989
990/*
991 * Events for event type EV_CHN_VOICE
992 */
993
994#define MIDI_NOTEOFF 0x80
995#define MIDI_NOTEON 0x90
996#define MIDI_KEY_PRESSURE 0xA0
997
998/*
999 * Events for event type EV_CHN_COMMON
1000 */
1001
1002#define MIDI_CTL_CHANGE 0xB0
1003#define MIDI_PGM_CHANGE 0xC0
1004#define MIDI_CHN_PRESSURE 0xD0
1005#define MIDI_PITCH_BEND 0xE0
1006
1007#define MIDI_SYSTEM_PREFIX 0xF0
1008
1009/*
1010 * Timer event types
1011 */
1012#define TMR_WAIT_REL 1 /* Time relative to the prev time */
1013#define TMR_WAIT_ABS 2 /* Absolute time since TMR_START */
1014#define TMR_STOP 3
1015#define TMR_START 4
1016#define TMR_CONTINUE 5
1017#define TMR_TEMPO 6
1018#define TMR_ECHO 8
1019#define TMR_CLOCK 9 /* MIDI clock */
1020#define TMR_SPP 10 /* Song position pointer */
1021#define TMR_TIMESIG 11 /* Time signature */
1022
1023/*
1024 * Local event types
1025 */
1026#define LOCL_STARTAUDIO 1
1027
1028#if (!defined(__KERNEL__) && !defined(KERNEL) && !defined(INKERNEL) && !defined(_KERNEL)) || defined(USE_SEQ_MACROS)
1029/*
1030 * Some convenience macros to simplify programming of the
1031 * /dev/sequencer interface
1032 *
1033 * These macros define the API which should be used when possible.
1034 */
1035#define SEQ_DECLAREBUF() SEQ_USE_EXTBUF()
1036
1037void seqbuf_dump(void); /* This function must be provided by programs */
1038
1039extern int OSS_init(int seqfd, int buflen);
1040extern void OSS_seqbuf_dump(int fd, unsigned char *buf, int buflen);
1041extern void OSS_seq_advbuf(int len, int fd, unsigned char *buf, int buflen);
1042extern void OSS_seq_needbuf(int len, int fd, unsigned char *buf, int buflen);
1043extern void OSS_patch_caching(int dev, int chn, int patch,
1044 int fd, unsigned char *buf, int buflen);
1045extern void OSS_drum_caching(int dev, int chn, int patch,
1046 int fd, unsigned char *buf, int buflen);
1047extern void OSS_write_patch(int fd, unsigned char *buf, int len);
1048extern int OSS_write_patch2(int fd, unsigned char *buf, int len);
1049
1050#define SEQ_PM_DEFINES int __foo_bar___
1051#ifdef OSSLIB
1052# define SEQ_USE_EXTBUF() \
1053 extern unsigned char *_seqbuf; \
1054 extern int _seqbuflen;extern int _seqbufptr
1055# define SEQ_DEFINEBUF(len) SEQ_USE_EXTBUF();static int _requested_seqbuflen=len
1056# define _SEQ_ADVBUF(len) OSS_seq_advbuf(len, seqfd, _seqbuf, _seqbuflen)
1057# define _SEQ_NEEDBUF(len) OSS_seq_needbuf(len, seqfd, _seqbuf, _seqbuflen)
1058# define SEQ_DUMPBUF() OSS_seqbuf_dump(seqfd, _seqbuf, _seqbuflen)
1059
1060# define SEQ_LOAD_GMINSTR(dev, instr) \
1061 OSS_patch_caching(dev, -1, instr, seqfd, _seqbuf, _seqbuflen)
1062# define SEQ_LOAD_GMDRUM(dev, drum) \
1063 OSS_drum_caching(dev, -1, drum, seqfd, _seqbuf, _seqbuflen)
1064#else /* !OSSLIB */
1065
1066# define SEQ_LOAD_GMINSTR(dev, instr)
1067# define SEQ_LOAD_GMDRUM(dev, drum)
1068
1069# define SEQ_USE_EXTBUF() \
1070 extern unsigned char _seqbuf[]; \
1071 extern int _seqbuflen;extern int _seqbufptr
1072
1073#ifndef USE_SIMPLE_MACROS
1074/* Sample seqbuf_dump() implementation:
1075 *
1076 * SEQ_DEFINEBUF (2048); -- Defines a buffer for 2048 bytes
1077 *
1078 * int seqfd; -- The file descriptor for /dev/sequencer.
1079 *
1080 * void
1081 * seqbuf_dump ()
1082 * {
1083 * if (_seqbufptr)
1084 * if (write (seqfd, _seqbuf, _seqbufptr) == -1)
1085 * {
1086 * perror ("write /dev/sequencer");
1087 * exit (-1);
1088 * }
1089 * _seqbufptr = 0;
1090 * }
1091 */
1092
1093#define SEQ_DEFINEBUF(len) unsigned char _seqbuf[len]; int _seqbuflen = len;int _seqbufptr = 0
1094#define _SEQ_NEEDBUF(len) if ((_seqbufptr+(len)) > _seqbuflen) seqbuf_dump()
1095#define _SEQ_ADVBUF(len) _seqbufptr += len
1096#define SEQ_DUMPBUF seqbuf_dump
1097#else
1098/*
1099 * This variation of the sequencer macros is used just to format one event
1100 * using fixed buffer.
1101 *
1102 * The program using the macro library must define the following macros before
1103 * using this library.
1104 *
1105 * #define _seqbuf name of the buffer (unsigned char[])
1106 * #define _SEQ_ADVBUF(len) If the applic needs to know the exact
1107 * size of the event, this macro can be used.
1108 * Otherwise this must be defined as empty.
1109 * #define _seqbufptr Define the name of index variable or 0 if
1110 * not required.
1111 */
1112#define _SEQ_NEEDBUF(len) /* empty */
1113#endif
1114#endif /* !OSSLIB */
1115
1116#define SEQ_VOLUME_MODE(dev, mode) {_SEQ_NEEDBUF(8);\
1117 _seqbuf[_seqbufptr] = SEQ_EXTENDED;\
1118 _seqbuf[_seqbufptr+1] = SEQ_VOLMODE;\
1119 _seqbuf[_seqbufptr+2] = (dev);\
1120 _seqbuf[_seqbufptr+3] = (mode);\
1121 _seqbuf[_seqbufptr+4] = 0;\
1122 _seqbuf[_seqbufptr+5] = 0;\
1123 _seqbuf[_seqbufptr+6] = 0;\
1124 _seqbuf[_seqbufptr+7] = 0;\
1125 _SEQ_ADVBUF(8);}
1126
1127/*
1128 * Midi voice messages
1129 */
1130
1131#define _CHN_VOICE(dev, event, chn, note, parm) \
1132 {_SEQ_NEEDBUF(8);\
1133 _seqbuf[_seqbufptr] = EV_CHN_VOICE;\
1134 _seqbuf[_seqbufptr+1] = (dev);\
1135 _seqbuf[_seqbufptr+2] = (event);\
1136 _seqbuf[_seqbufptr+3] = (chn);\
1137 _seqbuf[_seqbufptr+4] = (note);\
1138 _seqbuf[_seqbufptr+5] = (parm);\
1139 _seqbuf[_seqbufptr+6] = (0);\
1140 _seqbuf[_seqbufptr+7] = 0;\
1141 _SEQ_ADVBUF(8);}
1142
1143#define SEQ_START_NOTE(dev, chn, note, vol) \
1144 _CHN_VOICE(dev, MIDI_NOTEON, chn, note, vol)
1145
1146#define SEQ_STOP_NOTE(dev, chn, note, vol) \
1147 _CHN_VOICE(dev, MIDI_NOTEOFF, chn, note, vol)
1148
1149#define SEQ_KEY_PRESSURE(dev, chn, note, pressure) \
1150 _CHN_VOICE(dev, MIDI_KEY_PRESSURE, chn, note, pressure)
1151
1152/*
1153 * Midi channel messages
1154 */
1155
1156#define _CHN_COMMON(dev, event, chn, p1, p2, w14) \
1157 {_SEQ_NEEDBUF(8);\
1158 _seqbuf[_seqbufptr] = EV_CHN_COMMON;\
1159 _seqbuf[_seqbufptr+1] = (dev);\
1160 _seqbuf[_seqbufptr+2] = (event);\
1161 _seqbuf[_seqbufptr+3] = (chn);\
1162 _seqbuf[_seqbufptr+4] = (p1);\
1163 _seqbuf[_seqbufptr+5] = (p2);\
1164 *(short *)&_seqbuf[_seqbufptr+6] = (w14);\
1165 _SEQ_ADVBUF(8);}
1166/*
1167 * SEQ_SYSEX permits sending of sysex messages. (It may look that it permits
1168 * sending any MIDI bytes but it's absolutely not possible. Trying to do
1169 * so _will_ cause problems with MPU401 intelligent mode).
1170 *
1171 * Sysex messages are sent in blocks of 1 to 6 bytes. Longer messages must be
1172 * sent by calling SEQ_SYSEX() several times (there must be no other events
1173 * between them). First sysex fragment must have 0xf0 in the first byte
1174 * and the last byte (buf[len-1] of the last fragment must be 0xf7. No byte
1175 * between these sysex start and end markers cannot be larger than 0x7f. Also
1176 * lengths of each fragments (except the last one) must be 6.
1177 *
1178 * Breaking the above rules may work with some MIDI ports but is likely to
1179 * cause fatal problems with some other devices (such as MPU401).
1180 */
1181#define SEQ_SYSEX(dev, buf, len) \
1182 {int ii, ll=(len); \
1183 unsigned char *bufp=buf;\
1184 if (ll>6)ll=6;\
1185 _SEQ_NEEDBUF(8);\
1186 _seqbuf[_seqbufptr] = EV_SYSEX;\
1187 _seqbuf[_seqbufptr+1] = (dev);\
1188 for(ii=0;ii<ll;ii++)\
1189 _seqbuf[_seqbufptr+ii+2] = bufp[ii];\
1190 for(ii=ll;ii<6;ii++)\
1191 _seqbuf[_seqbufptr+ii+2] = 0xff;\
1192 _SEQ_ADVBUF(8);}
1193
1194#define SEQ_CHN_PRESSURE(dev, chn, pressure) \
1195 _CHN_COMMON(dev, MIDI_CHN_PRESSURE, chn, pressure, 0, 0)
1196
1197#define SEQ_SET_PATCH SEQ_PGM_CHANGE
1198#ifdef OSSLIB
1199# define SEQ_PGM_CHANGE(dev, chn, patch) \
1200 {OSS_patch_caching(dev, chn, patch, seqfd, _seqbuf, _seqbuflen); \
1201 _CHN_COMMON(dev, MIDI_PGM_CHANGE, chn, patch, 0, 0);}
1202#else
1203# define SEQ_PGM_CHANGE(dev, chn, patch) \
1204 _CHN_COMMON(dev, MIDI_PGM_CHANGE, chn, patch, 0, 0)
1205#endif
1206
1207#define SEQ_CONTROL(dev, chn, controller, value) \
1208 _CHN_COMMON(dev, MIDI_CTL_CHANGE, chn, controller, 0, value)
1209
1210#define SEQ_BENDER(dev, chn, value) \
1211 _CHN_COMMON(dev, MIDI_PITCH_BEND, chn, 0, 0, value)
1212
1213
1214#define SEQ_V2_X_CONTROL(dev, voice, controller, value) {_SEQ_NEEDBUF(8);\
1215 _seqbuf[_seqbufptr] = SEQ_EXTENDED;\
1216 _seqbuf[_seqbufptr+1] = SEQ_CONTROLLER;\
1217 _seqbuf[_seqbufptr+2] = (dev);\
1218 _seqbuf[_seqbufptr+3] = (voice);\
1219 _seqbuf[_seqbufptr+4] = (controller);\
1220 _seqbuf[_seqbufptr+5] = ((value)&0xff);\
1221 _seqbuf[_seqbufptr+6] = ((value>>8)&0xff);\
1222 _seqbuf[_seqbufptr+7] = 0;\
1223 _SEQ_ADVBUF(8);}
1224/*
1225 * The following 5 macros are incorrectly implemented and obsolete.
1226 * Use SEQ_BENDER and SEQ_CONTROL (with proper controller) instead.
1227 */
1228#define SEQ_PITCHBEND(dev, voice, value) SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER, value)
1229#define SEQ_BENDER_RANGE(dev, voice, value) SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER_RANGE, value)
1230#define SEQ_EXPRESSION(dev, voice, value) SEQ_CONTROL(dev, voice, CTL_EXPRESSION, value*128)
1231#define SEQ_MAIN_VOLUME(dev, voice, value) SEQ_CONTROL(dev, voice, CTL_MAIN_VOLUME, (value*16383)/100)
1232#define SEQ_PANNING(dev, voice, pos) SEQ_CONTROL(dev, voice, CTL_PAN, (pos+128) / 2)
1233
1234/*
1235 * Timing and syncronization macros
1236 */
1237
1238#define _TIMER_EVENT(ev, parm) {_SEQ_NEEDBUF(8);\
1239 _seqbuf[_seqbufptr+0] = EV_TIMING; \
1240 _seqbuf[_seqbufptr+1] = (ev); \
1241 _seqbuf[_seqbufptr+2] = 0;\
1242 _seqbuf[_seqbufptr+3] = 0;\
1243 *(unsigned int *)&_seqbuf[_seqbufptr+4] = (parm); \
1244 _SEQ_ADVBUF(8);}
1245
1246#define SEQ_START_TIMER() _TIMER_EVENT(TMR_START, 0)
1247#define SEQ_STOP_TIMER() _TIMER_EVENT(TMR_STOP, 0)
1248#define SEQ_CONTINUE_TIMER() _TIMER_EVENT(TMR_CONTINUE, 0)
1249#define SEQ_WAIT_TIME(ticks) _TIMER_EVENT(TMR_WAIT_ABS, ticks)
1250#define SEQ_DELTA_TIME(ticks) _TIMER_EVENT(TMR_WAIT_REL, ticks)
1251#define SEQ_ECHO_BACK(key) _TIMER_EVENT(TMR_ECHO, key)
1252#define SEQ_SET_TEMPO(value) _TIMER_EVENT(TMR_TEMPO, value)
1253#define SEQ_SONGPOS(pos) _TIMER_EVENT(TMR_SPP, pos)
1254#define SEQ_TIME_SIGNATURE(sig) _TIMER_EVENT(TMR_TIMESIG, sig)
1255
1256/*
1257 * Local control events
1258 */
1259
1260#define _LOCAL_EVENT(ev, parm) {_SEQ_NEEDBUF(8);\
1261 _seqbuf[_seqbufptr+0] = EV_SEQ_LOCAL; \
1262 _seqbuf[_seqbufptr+1] = (ev); \
1263 _seqbuf[_seqbufptr+2] = 0;\
1264 _seqbuf[_seqbufptr+3] = 0;\
1265 *(unsigned int *)&_seqbuf[_seqbufptr+4] = (parm); \
1266 _SEQ_ADVBUF(8);}
1267
1268#define SEQ_PLAYAUDIO(devmask) _LOCAL_EVENT(LOCL_STARTAUDIO, devmask)
1269/*
1270 * Events for the level 1 interface only
1271 */
1272
1273#define SEQ_MIDIOUT(device, byte) {_SEQ_NEEDBUF(4);\
1274 _seqbuf[_seqbufptr] = SEQ_MIDIPUTC;\
1275 _seqbuf[_seqbufptr+1] = (byte);\
1276 _seqbuf[_seqbufptr+2] = (device);\
1277 _seqbuf[_seqbufptr+3] = 0;\
1278 _SEQ_ADVBUF(4);}
1279
1280/*
1281 * Patch loading.
1282 */
1283#ifdef OSSLIB
1284# define SEQ_WRPATCH(patchx, len) \
1285 OSS_write_patch(seqfd, (char*)(patchx), len)
1286# define SEQ_WRPATCH2(patchx, len) \
1287 OSS_write_patch2(seqfd, (char*)(patchx), len)
1288#else
1289# define SEQ_WRPATCH(patchx, len) \
1290 {if (_seqbufptr) SEQ_DUMPBUF();\
1291 if (write(seqfd, (char*)(patchx), len)==-1) \
1292 perror("Write patch: /dev/sequencer");}
1293# define SEQ_WRPATCH2(patchx, len) \
1294 (SEQ_DUMPBUF(), write(seqfd, (char*)(patchx), len))
1295#endif
1296
1297#endif
1298#endif
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
new file mode 100644
index 000000000000..e895f3eaf53a
--- /dev/null
+++ b/include/linux/spinlock.h
@@ -0,0 +1,606 @@
1#ifndef __LINUX_SPINLOCK_H
2#define __LINUX_SPINLOCK_H
3
4/*
5 * include/linux/spinlock.h - generic locking declarations
6 */
7
8#include <linux/config.h>
9#include <linux/preempt.h>
10#include <linux/linkage.h>
11#include <linux/compiler.h>
12#include <linux/thread_info.h>
13#include <linux/kernel.h>
14#include <linux/stringify.h>
15
16#include <asm/processor.h> /* for cpu relax */
17#include <asm/system.h>
18
19/*
20 * Must define these before including other files, inline functions need them
21 */
22#define LOCK_SECTION_NAME \
23 ".text.lock." __stringify(KBUILD_BASENAME)
24
25#define LOCK_SECTION_START(extra) \
26 ".subsection 1\n\t" \
27 extra \
28 ".ifndef " LOCK_SECTION_NAME "\n\t" \
29 LOCK_SECTION_NAME ":\n\t" \
30 ".endif\n"
31
32#define LOCK_SECTION_END \
33 ".previous\n\t"
34
35#define __lockfunc fastcall __attribute__((section(".spinlock.text")))
36
37/*
38 * If CONFIG_SMP is set, pull in the _raw_* definitions
39 */
40#ifdef CONFIG_SMP
41
42#define assert_spin_locked(x) BUG_ON(!spin_is_locked(x))
43#include <asm/spinlock.h>
44
45int __lockfunc _spin_trylock(spinlock_t *lock);
46int __lockfunc _read_trylock(rwlock_t *lock);
47int __lockfunc _write_trylock(rwlock_t *lock);
48
49void __lockfunc _spin_lock(spinlock_t *lock) __acquires(spinlock_t);
50void __lockfunc _read_lock(rwlock_t *lock) __acquires(rwlock_t);
51void __lockfunc _write_lock(rwlock_t *lock) __acquires(rwlock_t);
52
53void __lockfunc _spin_unlock(spinlock_t *lock) __releases(spinlock_t);
54void __lockfunc _read_unlock(rwlock_t *lock) __releases(rwlock_t);
55void __lockfunc _write_unlock(rwlock_t *lock) __releases(rwlock_t);
56
57unsigned long __lockfunc _spin_lock_irqsave(spinlock_t *lock) __acquires(spinlock_t);
58unsigned long __lockfunc _read_lock_irqsave(rwlock_t *lock) __acquires(rwlock_t);
59unsigned long __lockfunc _write_lock_irqsave(rwlock_t *lock) __acquires(rwlock_t);
60
61void __lockfunc _spin_lock_irq(spinlock_t *lock) __acquires(spinlock_t);
62void __lockfunc _spin_lock_bh(spinlock_t *lock) __acquires(spinlock_t);
63void __lockfunc _read_lock_irq(rwlock_t *lock) __acquires(rwlock_t);
64void __lockfunc _read_lock_bh(rwlock_t *lock) __acquires(rwlock_t);
65void __lockfunc _write_lock_irq(rwlock_t *lock) __acquires(rwlock_t);
66void __lockfunc _write_lock_bh(rwlock_t *lock) __acquires(rwlock_t);
67
68void __lockfunc _spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags) __releases(spinlock_t);
69void __lockfunc _spin_unlock_irq(spinlock_t *lock) __releases(spinlock_t);
70void __lockfunc _spin_unlock_bh(spinlock_t *lock) __releases(spinlock_t);
71void __lockfunc _read_unlock_irqrestore(rwlock_t *lock, unsigned long flags) __releases(rwlock_t);
72void __lockfunc _read_unlock_irq(rwlock_t *lock) __releases(rwlock_t);
73void __lockfunc _read_unlock_bh(rwlock_t *lock) __releases(rwlock_t);
74void __lockfunc _write_unlock_irqrestore(rwlock_t *lock, unsigned long flags) __releases(rwlock_t);
75void __lockfunc _write_unlock_irq(rwlock_t *lock) __releases(rwlock_t);
76void __lockfunc _write_unlock_bh(rwlock_t *lock) __releases(rwlock_t);
77
78int __lockfunc _spin_trylock_bh(spinlock_t *lock);
79int __lockfunc generic_raw_read_trylock(rwlock_t *lock);
80int in_lock_functions(unsigned long addr);
81
82#else
83
84#define in_lock_functions(ADDR) 0
85
86#if !defined(CONFIG_PREEMPT) && !defined(CONFIG_DEBUG_SPINLOCK)
87# define _atomic_dec_and_lock(atomic,lock) atomic_dec_and_test(atomic)
88# define ATOMIC_DEC_AND_LOCK
89#endif
90
91#ifdef CONFIG_DEBUG_SPINLOCK
92
93#define SPINLOCK_MAGIC 0x1D244B3C
94typedef struct {
95 unsigned long magic;
96 volatile unsigned long lock;
97 volatile unsigned int babble;
98 const char *module;
99 char *owner;
100 int oline;
101} spinlock_t;
102#define SPIN_LOCK_UNLOCKED (spinlock_t) { SPINLOCK_MAGIC, 0, 10, __FILE__ , NULL, 0}
103
104#define spin_lock_init(x) \
105 do { \
106 (x)->magic = SPINLOCK_MAGIC; \
107 (x)->lock = 0; \
108 (x)->babble = 5; \
109 (x)->module = __FILE__; \
110 (x)->owner = NULL; \
111 (x)->oline = 0; \
112 } while (0)
113
114#define CHECK_LOCK(x) \
115 do { \
116 if ((x)->magic != SPINLOCK_MAGIC) { \
117 printk(KERN_ERR "%s:%d: spin_is_locked on uninitialized spinlock %p.\n", \
118 __FILE__, __LINE__, (x)); \
119 } \
120 } while(0)
121
122#define _raw_spin_lock(x) \
123 do { \
124 CHECK_LOCK(x); \
125 if ((x)->lock&&(x)->babble) { \
126 (x)->babble--; \
127 printk("%s:%d: spin_lock(%s:%p) already locked by %s/%d\n", \
128 __FILE__,__LINE__, (x)->module, \
129 (x), (x)->owner, (x)->oline); \
130 } \
131 (x)->lock = 1; \
132 (x)->owner = __FILE__; \
133 (x)->oline = __LINE__; \
134 } while (0)
135
136/* without debugging, spin_is_locked on UP always says
137 * FALSE. --> printk if already locked. */
138#define spin_is_locked(x) \
139 ({ \
140 CHECK_LOCK(x); \
141 if ((x)->lock&&(x)->babble) { \
142 (x)->babble--; \
143 printk("%s:%d: spin_is_locked(%s:%p) already locked by %s/%d\n", \
144 __FILE__,__LINE__, (x)->module, \
145 (x), (x)->owner, (x)->oline); \
146 } \
147 0; \
148 })
149
150/* with debugging, assert_spin_locked() on UP does check
151 * the lock value properly */
152#define assert_spin_locked(x) \
153 ({ \
154 CHECK_LOCK(x); \
155 BUG_ON(!(x)->lock); \
156 })
157
158/* without debugging, spin_trylock on UP always says
159 * TRUE. --> printk if already locked. */
160#define _raw_spin_trylock(x) \
161 ({ \
162 CHECK_LOCK(x); \
163 if ((x)->lock&&(x)->babble) { \
164 (x)->babble--; \
165 printk("%s:%d: spin_trylock(%s:%p) already locked by %s/%d\n", \
166 __FILE__,__LINE__, (x)->module, \
167 (x), (x)->owner, (x)->oline); \
168 } \
169 (x)->lock = 1; \
170 (x)->owner = __FILE__; \
171 (x)->oline = __LINE__; \
172 1; \
173 })
174
175#define spin_unlock_wait(x) \
176 do { \
177 CHECK_LOCK(x); \
178 if ((x)->lock&&(x)->babble) { \
179 (x)->babble--; \
180 printk("%s:%d: spin_unlock_wait(%s:%p) owned by %s/%d\n", \
181 __FILE__,__LINE__, (x)->module, (x), \
182 (x)->owner, (x)->oline); \
183 }\
184 } while (0)
185
186#define _raw_spin_unlock(x) \
187 do { \
188 CHECK_LOCK(x); \
189 if (!(x)->lock&&(x)->babble) { \
190 (x)->babble--; \
191 printk("%s:%d: spin_unlock(%s:%p) not locked\n", \
192 __FILE__,__LINE__, (x)->module, (x));\
193 } \
194 (x)->lock = 0; \
195 } while (0)
196#else
197/*
198 * gcc versions before ~2.95 have a nasty bug with empty initializers.
199 */
200#if (__GNUC__ > 2)
201 typedef struct { } spinlock_t;
202 #define SPIN_LOCK_UNLOCKED (spinlock_t) { }
203#else
204 typedef struct { int gcc_is_buggy; } spinlock_t;
205 #define SPIN_LOCK_UNLOCKED (spinlock_t) { 0 }
206#endif
207
208/*
209 * If CONFIG_SMP is unset, declare the _raw_* definitions as nops
210 */
211#define spin_lock_init(lock) do { (void)(lock); } while(0)
212#define _raw_spin_lock(lock) do { (void)(lock); } while(0)
213#define spin_is_locked(lock) ((void)(lock), 0)
214#define assert_spin_locked(lock) do { (void)(lock); } while(0)
215#define _raw_spin_trylock(lock) (((void)(lock), 1))
216#define spin_unlock_wait(lock) (void)(lock)
217#define _raw_spin_unlock(lock) do { (void)(lock); } while(0)
218#endif /* CONFIG_DEBUG_SPINLOCK */
219
220/* RW spinlocks: No debug version */
221
222#if (__GNUC__ > 2)
223 typedef struct { } rwlock_t;
224 #define RW_LOCK_UNLOCKED (rwlock_t) { }
225#else
226 typedef struct { int gcc_is_buggy; } rwlock_t;
227 #define RW_LOCK_UNLOCKED (rwlock_t) { 0 }
228#endif
229
230#define rwlock_init(lock) do { (void)(lock); } while(0)
231#define _raw_read_lock(lock) do { (void)(lock); } while(0)
232#define _raw_read_unlock(lock) do { (void)(lock); } while(0)
233#define _raw_write_lock(lock) do { (void)(lock); } while(0)
234#define _raw_write_unlock(lock) do { (void)(lock); } while(0)
235#define read_can_lock(lock) (((void)(lock), 1))
236#define write_can_lock(lock) (((void)(lock), 1))
237#define _raw_read_trylock(lock) ({ (void)(lock); (1); })
238#define _raw_write_trylock(lock) ({ (void)(lock); (1); })
239
240#define _spin_trylock(lock) ({preempt_disable(); _raw_spin_trylock(lock) ? \
241 1 : ({preempt_enable(); 0;});})
242
243#define _read_trylock(lock) ({preempt_disable();_raw_read_trylock(lock) ? \
244 1 : ({preempt_enable(); 0;});})
245
246#define _write_trylock(lock) ({preempt_disable(); _raw_write_trylock(lock) ? \
247 1 : ({preempt_enable(); 0;});})
248
249#define _spin_trylock_bh(lock) ({preempt_disable(); local_bh_disable(); \
250 _raw_spin_trylock(lock) ? \
251 1 : ({preempt_enable(); local_bh_enable(); 0;});})
252
253#define _spin_lock(lock) \
254do { \
255 preempt_disable(); \
256 _raw_spin_lock(lock); \
257 __acquire(lock); \
258} while(0)
259
260#define _write_lock(lock) \
261do { \
262 preempt_disable(); \
263 _raw_write_lock(lock); \
264 __acquire(lock); \
265} while(0)
266
267#define _read_lock(lock) \
268do { \
269 preempt_disable(); \
270 _raw_read_lock(lock); \
271 __acquire(lock); \
272} while(0)
273
274#define _spin_unlock(lock) \
275do { \
276 _raw_spin_unlock(lock); \
277 preempt_enable(); \
278 __release(lock); \
279} while (0)
280
281#define _write_unlock(lock) \
282do { \
283 _raw_write_unlock(lock); \
284 preempt_enable(); \
285 __release(lock); \
286} while(0)
287
288#define _read_unlock(lock) \
289do { \
290 _raw_read_unlock(lock); \
291 preempt_enable(); \
292 __release(lock); \
293} while(0)
294
295#define _spin_lock_irqsave(lock, flags) \
296do { \
297 local_irq_save(flags); \
298 preempt_disable(); \
299 _raw_spin_lock(lock); \
300 __acquire(lock); \
301} while (0)
302
303#define _spin_lock_irq(lock) \
304do { \
305 local_irq_disable(); \
306 preempt_disable(); \
307 _raw_spin_lock(lock); \
308 __acquire(lock); \
309} while (0)
310
311#define _spin_lock_bh(lock) \
312do { \
313 local_bh_disable(); \
314 preempt_disable(); \
315 _raw_spin_lock(lock); \
316 __acquire(lock); \
317} while (0)
318
319#define _read_lock_irqsave(lock, flags) \
320do { \
321 local_irq_save(flags); \
322 preempt_disable(); \
323 _raw_read_lock(lock); \
324 __acquire(lock); \
325} while (0)
326
327#define _read_lock_irq(lock) \
328do { \
329 local_irq_disable(); \
330 preempt_disable(); \
331 _raw_read_lock(lock); \
332 __acquire(lock); \
333} while (0)
334
335#define _read_lock_bh(lock) \
336do { \
337 local_bh_disable(); \
338 preempt_disable(); \
339 _raw_read_lock(lock); \
340 __acquire(lock); \
341} while (0)
342
343#define _write_lock_irqsave(lock, flags) \
344do { \
345 local_irq_save(flags); \
346 preempt_disable(); \
347 _raw_write_lock(lock); \
348 __acquire(lock); \
349} while (0)
350
351#define _write_lock_irq(lock) \
352do { \
353 local_irq_disable(); \
354 preempt_disable(); \
355 _raw_write_lock(lock); \
356 __acquire(lock); \
357} while (0)
358
359#define _write_lock_bh(lock) \
360do { \
361 local_bh_disable(); \
362 preempt_disable(); \
363 _raw_write_lock(lock); \
364 __acquire(lock); \
365} while (0)
366
367#define _spin_unlock_irqrestore(lock, flags) \
368do { \
369 _raw_spin_unlock(lock); \
370 local_irq_restore(flags); \
371 preempt_enable(); \
372 __release(lock); \
373} while (0)
374
375#define _spin_unlock_irq(lock) \
376do { \
377 _raw_spin_unlock(lock); \
378 local_irq_enable(); \
379 preempt_enable(); \
380 __release(lock); \
381} while (0)
382
383#define _spin_unlock_bh(lock) \
384do { \
385 _raw_spin_unlock(lock); \
386 preempt_enable(); \
387 local_bh_enable(); \
388 __release(lock); \
389} while (0)
390
391#define _write_unlock_bh(lock) \
392do { \
393 _raw_write_unlock(lock); \
394 preempt_enable(); \
395 local_bh_enable(); \
396 __release(lock); \
397} while (0)
398
399#define _read_unlock_irqrestore(lock, flags) \
400do { \
401 _raw_read_unlock(lock); \
402 local_irq_restore(flags); \
403 preempt_enable(); \
404 __release(lock); \
405} while (0)
406
407#define _write_unlock_irqrestore(lock, flags) \
408do { \
409 _raw_write_unlock(lock); \
410 local_irq_restore(flags); \
411 preempt_enable(); \
412 __release(lock); \
413} while (0)
414
415#define _read_unlock_irq(lock) \
416do { \
417 _raw_read_unlock(lock); \
418 local_irq_enable(); \
419 preempt_enable(); \
420 __release(lock); \
421} while (0)
422
423#define _read_unlock_bh(lock) \
424do { \
425 _raw_read_unlock(lock); \
426 local_bh_enable(); \
427 preempt_enable(); \
428 __release(lock); \
429} while (0)
430
431#define _write_unlock_irq(lock) \
432do { \
433 _raw_write_unlock(lock); \
434 local_irq_enable(); \
435 preempt_enable(); \
436 __release(lock); \
437} while (0)
438
439#endif /* !SMP */
440
441/*
442 * Define the various spin_lock and rw_lock methods. Note we define these
443 * regardless of whether CONFIG_SMP or CONFIG_PREEMPT are set. The various
444 * methods are defined as nops in the case they are not required.
445 */
446#define spin_trylock(lock) __cond_lock(_spin_trylock(lock))
447#define read_trylock(lock) __cond_lock(_read_trylock(lock))
448#define write_trylock(lock) __cond_lock(_write_trylock(lock))
449
450#define spin_lock(lock) _spin_lock(lock)
451#define write_lock(lock) _write_lock(lock)
452#define read_lock(lock) _read_lock(lock)
453
454#ifdef CONFIG_SMP
455#define spin_lock_irqsave(lock, flags) flags = _spin_lock_irqsave(lock)
456#define read_lock_irqsave(lock, flags) flags = _read_lock_irqsave(lock)
457#define write_lock_irqsave(lock, flags) flags = _write_lock_irqsave(lock)
458#else
459#define spin_lock_irqsave(lock, flags) _spin_lock_irqsave(lock, flags)
460#define read_lock_irqsave(lock, flags) _read_lock_irqsave(lock, flags)
461#define write_lock_irqsave(lock, flags) _write_lock_irqsave(lock, flags)
462#endif
463
464#define spin_lock_irq(lock) _spin_lock_irq(lock)
465#define spin_lock_bh(lock) _spin_lock_bh(lock)
466
467#define read_lock_irq(lock) _read_lock_irq(lock)
468#define read_lock_bh(lock) _read_lock_bh(lock)
469
470#define write_lock_irq(lock) _write_lock_irq(lock)
471#define write_lock_bh(lock) _write_lock_bh(lock)
472
473#define spin_unlock(lock) _spin_unlock(lock)
474#define write_unlock(lock) _write_unlock(lock)
475#define read_unlock(lock) _read_unlock(lock)
476
477#define spin_unlock_irqrestore(lock, flags) _spin_unlock_irqrestore(lock, flags)
478#define spin_unlock_irq(lock) _spin_unlock_irq(lock)
479#define spin_unlock_bh(lock) _spin_unlock_bh(lock)
480
481#define read_unlock_irqrestore(lock, flags) _read_unlock_irqrestore(lock, flags)
482#define read_unlock_irq(lock) _read_unlock_irq(lock)
483#define read_unlock_bh(lock) _read_unlock_bh(lock)
484
485#define write_unlock_irqrestore(lock, flags) _write_unlock_irqrestore(lock, flags)
486#define write_unlock_irq(lock) _write_unlock_irq(lock)
487#define write_unlock_bh(lock) _write_unlock_bh(lock)
488
489#define spin_trylock_bh(lock) __cond_lock(_spin_trylock_bh(lock))
490
491#define spin_trylock_irq(lock) \
492({ \
493 local_irq_disable(); \
494 _spin_trylock(lock) ? \
495 1 : ({local_irq_enable(); 0; }); \
496})
497
498#define spin_trylock_irqsave(lock, flags) \
499({ \
500 local_irq_save(flags); \
501 _spin_trylock(lock) ? \
502 1 : ({local_irq_restore(flags); 0;}); \
503})
504
505#ifdef CONFIG_LOCKMETER
506extern void _metered_spin_lock (spinlock_t *lock);
507extern void _metered_spin_unlock (spinlock_t *lock);
508extern int _metered_spin_trylock(spinlock_t *lock);
509extern void _metered_read_lock (rwlock_t *lock);
510extern void _metered_read_unlock (rwlock_t *lock);
511extern void _metered_write_lock (rwlock_t *lock);
512extern void _metered_write_unlock (rwlock_t *lock);
513extern int _metered_read_trylock (rwlock_t *lock);
514extern int _metered_write_trylock(rwlock_t *lock);
515#endif
516
517/* "lock on reference count zero" */
518#ifndef ATOMIC_DEC_AND_LOCK
519#include <asm/atomic.h>
520extern int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock);
521#endif
522
523#define atomic_dec_and_lock(atomic,lock) __cond_lock(_atomic_dec_and_lock(atomic,lock))
524
525/*
526 * bit-based spin_lock()
527 *
528 * Don't use this unless you really need to: spin_lock() and spin_unlock()
529 * are significantly faster.
530 */
531static inline void bit_spin_lock(int bitnum, unsigned long *addr)
532{
533 /*
534 * Assuming the lock is uncontended, this never enters
535 * the body of the outer loop. If it is contended, then
536 * within the inner loop a non-atomic test is used to
537 * busywait with less bus contention for a good time to
538 * attempt to acquire the lock bit.
539 */
540 preempt_disable();
541#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
542 while (test_and_set_bit(bitnum, addr)) {
543 while (test_bit(bitnum, addr)) {
544 preempt_enable();
545 cpu_relax();
546 preempt_disable();
547 }
548 }
549#endif
550 __acquire(bitlock);
551}
552
553/*
554 * Return true if it was acquired
555 */
556static inline int bit_spin_trylock(int bitnum, unsigned long *addr)
557{
558 preempt_disable();
559#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
560 if (test_and_set_bit(bitnum, addr)) {
561 preempt_enable();
562 return 0;
563 }
564#endif
565 __acquire(bitlock);
566 return 1;
567}
568
569/*
570 * bit-based spin_unlock()
571 */
572static inline void bit_spin_unlock(int bitnum, unsigned long *addr)
573{
574#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
575 BUG_ON(!test_bit(bitnum, addr));
576 smp_mb__before_clear_bit();
577 clear_bit(bitnum, addr);
578#endif
579 preempt_enable();
580 __release(bitlock);
581}
582
583/*
584 * Return true if the lock is held.
585 */
586static inline int bit_spin_is_locked(int bitnum, unsigned long *addr)
587{
588#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
589 return test_bit(bitnum, addr);
590#elif defined CONFIG_PREEMPT
591 return preempt_count();
592#else
593 return 1;
594#endif
595}
596
597#define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED
598#define DEFINE_RWLOCK(x) rwlock_t x = RW_LOCK_UNLOCKED
599
600/**
601 * spin_can_lock - would spin_trylock() succeed?
602 * @lock: the spinlock in question.
603 */
604#define spin_can_lock(lock) (!spin_is_locked(lock))
605
606#endif /* __LINUX_SPINLOCK_H */
diff --git a/include/linux/stallion.h b/include/linux/stallion.h
new file mode 100644
index 000000000000..e89b77b6505a
--- /dev/null
+++ b/include/linux/stallion.h
@@ -0,0 +1,154 @@
1/*****************************************************************************/
2
3/*
4 * stallion.h -- stallion multiport serial driver.
5 *
6 * Copyright (C) 1996-1998 Stallion Technologies
7 * Copyright (C) 1994-1996 Greg Ungerer.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24#include <linux/version.h>
25
26/*****************************************************************************/
27#ifndef _STALLION_H
28#define _STALLION_H
29/*****************************************************************************/
30
31/*
32 * Define important driver constants here.
33 */
34#define STL_MAXBRDS 4
35#define STL_MAXPANELS 4
36#define STL_MAXBANKS 8
37#define STL_PORTSPERPANEL 16
38#define STL_MAXPORTS 64
39#define STL_MAXDEVS (STL_MAXBRDS * STL_MAXPORTS)
40
41
42/*
43 * Define a set of structures to hold all the board/panel/port info
44 * for our ports. These will be dynamically allocated as required.
45 */
46
47/*
48 * Define a ring queue structure for each port. This will hold the
49 * TX data waiting to be output. Characters are fed into this buffer
50 * from the line discipline (or even direct from user space!) and
51 * then fed into the UARTs during interrupts. Will use a classic ring
52 * queue here for this. The good thing about this type of ring queue
53 * is that the head and tail pointers can be updated without interrupt
54 * protection - since "write" code only needs to change the head, and
55 * interrupt code only needs to change the tail.
56 */
57typedef struct {
58 char *buf;
59 char *head;
60 char *tail;
61} stlrq_t;
62
63/*
64 * Port, panel and board structures to hold status info about each.
65 * The board structure contains pointers to structures for each panel
66 * connected to it, and in turn each panel structure contains pointers
67 * for each port structure for each port on that panel. Note that
68 * the port structure also contains the board and panel number that it
69 * is associated with, this makes it (fairly) easy to get back to the
70 * board/panel info for a port.
71 */
72typedef struct stlport {
73 unsigned long magic;
74 int portnr;
75 int panelnr;
76 int brdnr;
77 int ioaddr;
78 int uartaddr;
79 int pagenr;
80 long istate;
81 int flags;
82 int baud_base;
83 int custom_divisor;
84 int close_delay;
85 int closing_wait;
86 int refcount;
87 int openwaitcnt;
88 int brklen;
89 unsigned int sigs;
90 unsigned int rxignoremsk;
91 unsigned int rxmarkmsk;
92 unsigned int imr;
93 unsigned int crenable;
94 unsigned long clk;
95 unsigned long hwid;
96 void *uartp;
97 struct tty_struct *tty;
98 wait_queue_head_t open_wait;
99 wait_queue_head_t close_wait;
100 struct work_struct tqueue;
101 comstats_t stats;
102 stlrq_t tx;
103} stlport_t;
104
105typedef struct stlpanel {
106 unsigned long magic;
107 int panelnr;
108 int brdnr;
109 int pagenr;
110 int nrports;
111 int iobase;
112 void *uartp;
113 void (*isr)(struct stlpanel *panelp, unsigned int iobase);
114 unsigned int hwid;
115 unsigned int ackmask;
116 stlport_t *ports[STL_PORTSPERPANEL];
117} stlpanel_t;
118
119typedef struct stlbrd {
120 unsigned long magic;
121 int brdnr;
122 int brdtype;
123 int state;
124 int nrpanels;
125 int nrports;
126 int nrbnks;
127 int irq;
128 int irqtype;
129 int (*isr)(struct stlbrd *brdp);
130 unsigned int ioaddr1;
131 unsigned int ioaddr2;
132 unsigned int iosize1;
133 unsigned int iosize2;
134 unsigned int iostatus;
135 unsigned int ioctrl;
136 unsigned int ioctrlval;
137 unsigned int hwid;
138 unsigned long clk;
139 unsigned int bnkpageaddr[STL_MAXBANKS];
140 unsigned int bnkstataddr[STL_MAXBANKS];
141 stlpanel_t *bnk2panel[STL_MAXBANKS];
142 stlpanel_t *panels[STL_MAXPANELS];
143} stlbrd_t;
144
145
146/*
147 * Define MAGIC numbers used for above structures.
148 */
149#define STL_PORTMAGIC 0x5a7182c9
150#define STL_PANELMAGIC 0x7ef621a1
151#define STL_BOARDMAGIC 0xa2267f52
152
153/*****************************************************************************/
154#endif
diff --git a/include/linux/stat.h b/include/linux/stat.h
new file mode 100644
index 000000000000..8ff2a122dfef
--- /dev/null
+++ b/include/linux/stat.h
@@ -0,0 +1,77 @@
1#ifndef _LINUX_STAT_H
2#define _LINUX_STAT_H
3
4#ifdef __KERNEL__
5
6#include <asm/stat.h>
7
8#endif
9
10#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
11
12#define S_IFMT 00170000
13#define S_IFSOCK 0140000
14#define S_IFLNK 0120000
15#define S_IFREG 0100000
16#define S_IFBLK 0060000
17#define S_IFDIR 0040000
18#define S_IFCHR 0020000
19#define S_IFIFO 0010000
20#define S_ISUID 0004000
21#define S_ISGID 0002000
22#define S_ISVTX 0001000
23
24#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
25#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
26#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
27#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
28#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
29#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
30#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
31
32#define S_IRWXU 00700
33#define S_IRUSR 00400
34#define S_IWUSR 00200
35#define S_IXUSR 00100
36
37#define S_IRWXG 00070
38#define S_IRGRP 00040
39#define S_IWGRP 00020
40#define S_IXGRP 00010
41
42#define S_IRWXO 00007
43#define S_IROTH 00004
44#define S_IWOTH 00002
45#define S_IXOTH 00001
46
47#endif
48
49#ifdef __KERNEL__
50#define S_IRWXUGO (S_IRWXU|S_IRWXG|S_IRWXO)
51#define S_IALLUGO (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO)
52#define S_IRUGO (S_IRUSR|S_IRGRP|S_IROTH)
53#define S_IWUGO (S_IWUSR|S_IWGRP|S_IWOTH)
54#define S_IXUGO (S_IXUSR|S_IXGRP|S_IXOTH)
55
56#include <linux/types.h>
57#include <linux/time.h>
58
59struct kstat {
60 unsigned long ino;
61 dev_t dev;
62 umode_t mode;
63 unsigned int nlink;
64 uid_t uid;
65 gid_t gid;
66 dev_t rdev;
67 loff_t size;
68 struct timespec atime;
69 struct timespec mtime;
70 struct timespec ctime;
71 unsigned long blksize;
72 unsigned long blocks;
73};
74
75#endif
76
77#endif
diff --git a/include/linux/statfs.h b/include/linux/statfs.h
new file mode 100644
index 000000000000..ad83a2bdb821
--- /dev/null
+++ b/include/linux/statfs.h
@@ -0,0 +1,22 @@
1#ifndef _LINUX_STATFS_H
2#define _LINUX_STATFS_H
3
4#include <linux/types.h>
5
6#include <asm/statfs.h>
7
8struct kstatfs {
9 long f_type;
10 long f_bsize;
11 sector_t f_blocks;
12 sector_t f_bfree;
13 sector_t f_bavail;
14 sector_t f_files;
15 sector_t f_ffree;
16 __kernel_fsid_t f_fsid;
17 long f_namelen;
18 long f_frsize;
19 long f_spare[5];
20};
21
22#endif
diff --git a/include/linux/stddef.h b/include/linux/stddef.h
new file mode 100644
index 000000000000..b3a2cadf90f2
--- /dev/null
+++ b/include/linux/stddef.h
@@ -0,0 +1,20 @@
1#ifndef _LINUX_STDDEF_H
2#define _LINUX_STDDEF_H
3
4#include <linux/compiler.h>
5
6#undef NULL
7#if defined(__cplusplus)
8#define NULL 0
9#else
10#define NULL ((void *)0)
11#endif
12
13#undef offsetof
14#ifdef __compiler_offsetof
15#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
16#else
17#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
18#endif
19
20#endif
diff --git a/include/linux/stop_machine.h b/include/linux/stop_machine.h
new file mode 100644
index 000000000000..151a803ed0ed
--- /dev/null
+++ b/include/linux/stop_machine.h
@@ -0,0 +1,52 @@
1#ifndef _LINUX_STOP_MACHINE
2#define _LINUX_STOP_MACHINE
3/* "Bogolock": stop the entire machine, disable interrupts. This is a
4 very heavy lock, which is equivalent to grabbing every spinlock
5 (and more). So the "read" side to such a lock is anything which
6 diables preeempt. */
7#include <linux/config.h>
8#include <linux/cpu.h>
9#include <asm/system.h>
10
11#if defined(CONFIG_STOP_MACHINE) && defined(CONFIG_SMP)
12/**
13 * stop_machine_run: freeze the machine on all CPUs and run this function
14 * @fn: the function to run
15 * @data: the data ptr for the @fn()
16 * @cpu: the cpu to run @fn() on (or any, if @cpu == NR_CPUS.
17 *
18 * Description: This causes a thread to be scheduled on every other cpu,
19 * each of which disables interrupts, and finally interrupts are disabled
20 * on the current CPU. The result is that noone is holding a spinlock
21 * or inside any other preempt-disabled region when @fn() runs.
22 *
23 * This can be thought of as a very heavy write lock, equivalent to
24 * grabbing every spinlock in the kernel. */
25int stop_machine_run(int (*fn)(void *), void *data, unsigned int cpu);
26
27/**
28 * __stop_machine_run: freeze the machine on all CPUs and run this function
29 * @fn: the function to run
30 * @data: the data ptr for the @fn
31 * @cpu: the cpu to run @fn on (or any, if @cpu == NR_CPUS.
32 *
33 * Description: This is a special version of the above, which returns the
34 * thread which has run @fn(): kthread_stop will return the return value
35 * of @fn(). Used by hotplug cpu.
36 */
37struct task_struct *__stop_machine_run(int (*fn)(void *), void *data,
38 unsigned int cpu);
39
40#else
41
42static inline int stop_machine_run(int (*fn)(void *), void *data,
43 unsigned int cpu)
44{
45 int ret;
46 local_irq_disable();
47 ret = fn(data);
48 local_irq_enable();
49 return ret;
50}
51#endif /* CONFIG_SMP */
52#endif /* _LINUX_STOP_MACHINE */
diff --git a/include/linux/string.h b/include/linux/string.h
new file mode 100644
index 000000000000..b9fc59469956
--- /dev/null
+++ b/include/linux/string.h
@@ -0,0 +1,96 @@
1#ifndef _LINUX_STRING_H_
2#define _LINUX_STRING_H_
3
4/* We don't want strings.h stuff being user by user stuff by accident */
5
6#ifdef __KERNEL__
7
8#include <linux/compiler.h> /* for inline */
9#include <linux/types.h> /* for size_t */
10#include <linux/stddef.h> /* for NULL */
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
16extern char * strpbrk(const char *,const char *);
17extern char * strsep(char **,const char *);
18extern __kernel_size_t strspn(const char *,const char *);
19extern __kernel_size_t strcspn(const char *,const char *);
20
21/*
22 * Include machine specific inline routines
23 */
24#include <asm/string.h>
25
26#ifndef __HAVE_ARCH_STRCPY
27extern char * strcpy(char *,const char *);
28#endif
29#ifndef __HAVE_ARCH_STRNCPY
30extern char * strncpy(char *,const char *, __kernel_size_t);
31#endif
32#ifndef __HAVE_ARCH_STRLCPY
33size_t strlcpy(char *, const char *, size_t);
34#endif
35#ifndef __HAVE_ARCH_STRCAT
36extern char * strcat(char *, const char *);
37#endif
38#ifndef __HAVE_ARCH_STRNCAT
39extern char * strncat(char *, const char *, __kernel_size_t);
40#endif
41#ifndef __HAVE_ARCH_STRLCAT
42extern size_t strlcat(char *, const char *, __kernel_size_t);
43#endif
44#ifndef __HAVE_ARCH_STRCMP
45extern int strcmp(const char *,const char *);
46#endif
47#ifndef __HAVE_ARCH_STRNCMP
48extern int strncmp(const char *,const char *,__kernel_size_t);
49#endif
50#ifndef __HAVE_ARCH_STRNICMP
51extern int strnicmp(const char *, const char *, __kernel_size_t);
52#endif
53#ifndef __HAVE_ARCH_STRCHR
54extern char * strchr(const char *,int);
55#endif
56#ifndef __HAVE_ARCH_STRNCHR
57extern char * strnchr(const char *, size_t, int);
58#endif
59#ifndef __HAVE_ARCH_STRRCHR
60extern char * strrchr(const char *,int);
61#endif
62#ifndef __HAVE_ARCH_STRSTR
63extern char * strstr(const char *,const char *);
64#endif
65#ifndef __HAVE_ARCH_STRLEN
66extern __kernel_size_t strlen(const char *);
67#endif
68#ifndef __HAVE_ARCH_STRNLEN
69extern __kernel_size_t strnlen(const char *,__kernel_size_t);
70#endif
71
72#ifndef __HAVE_ARCH_MEMSET
73extern void * memset(void *,int,__kernel_size_t);
74#endif
75#ifndef __HAVE_ARCH_MEMCPY
76extern void * memcpy(void *,const void *,__kernel_size_t);
77#endif
78#ifndef __HAVE_ARCH_MEMMOVE
79extern void * memmove(void *,const void *,__kernel_size_t);
80#endif
81#ifndef __HAVE_ARCH_MEMSCAN
82extern void * memscan(void *,int,__kernel_size_t);
83#endif
84#ifndef __HAVE_ARCH_MEMCMP
85extern int memcmp(const void *,const void *,__kernel_size_t);
86#endif
87#ifndef __HAVE_ARCH_MEMCHR
88extern void * memchr(const void *,int,__kernel_size_t);
89#endif
90
91#ifdef __cplusplus
92}
93#endif
94
95#endif
96#endif /* _LINUX_STRING_H_ */
diff --git a/include/linux/stringify.h b/include/linux/stringify.h
new file mode 100644
index 000000000000..0b4388356c87
--- /dev/null
+++ b/include/linux/stringify.h
@@ -0,0 +1,12 @@
1#ifndef __LINUX_STRINGIFY_H
2#define __LINUX_STRINGIFY_H
3
4/* Indirect stringification. Doing two levels allows the parameter to be a
5 * macro itself. For example, compile with -DFOO=bar, __stringify(FOO)
6 * converts to "bar".
7 */
8
9#define __stringify_1(x) #x
10#define __stringify(x) __stringify_1(x)
11
12#endif /* !__LINUX_STRINGIFY_H */
diff --git a/include/linux/sunrpc/auth.h b/include/linux/sunrpc/auth.h
new file mode 100644
index 000000000000..04ebc24db348
--- /dev/null
+++ b/include/linux/sunrpc/auth.h
@@ -0,0 +1,149 @@
1/*
2 * linux/include/linux/sunrpc/auth.h
3 *
4 * Declarations for the RPC client authentication machinery.
5 *
6 * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
7 */
8
9#ifndef _LINUX_SUNRPC_AUTH_H
10#define _LINUX_SUNRPC_AUTH_H
11
12#ifdef __KERNEL__
13
14#include <linux/config.h>
15#include <linux/sunrpc/sched.h>
16#include <linux/sunrpc/msg_prot.h>
17#include <linux/sunrpc/xdr.h>
18
19#include <asm/atomic.h>
20
21/* size of the nodename buffer */
22#define UNX_MAXNODENAME 32
23
24/* Maximum size (in bytes) of an rpc credential or verifier */
25#define RPC_MAX_AUTH_SIZE (400)
26
27/* Work around the lack of a VFS credential */
28struct auth_cred {
29 uid_t uid;
30 gid_t gid;
31 struct group_info *group_info;
32};
33
34/*
35 * Client user credentials
36 */
37struct rpc_cred {
38 struct hlist_node cr_hash; /* hash chain */
39 struct rpc_credops * cr_ops;
40 unsigned long cr_expire; /* when to gc */
41 atomic_t cr_count; /* ref count */
42 unsigned short cr_flags; /* various flags */
43#ifdef RPC_DEBUG
44 unsigned long cr_magic; /* 0x0f4aa4f0 */
45#endif
46
47 uid_t cr_uid;
48
49 /* per-flavor data */
50};
51#define RPCAUTH_CRED_LOCKED 0x0001
52#define RPCAUTH_CRED_UPTODATE 0x0002
53
54#define RPCAUTH_CRED_MAGIC 0x0f4aa4f0
55
56/*
57 * Client authentication handle
58 */
59#define RPC_CREDCACHE_NR 8
60#define RPC_CREDCACHE_MASK (RPC_CREDCACHE_NR - 1)
61struct rpc_cred_cache {
62 struct hlist_head hashtable[RPC_CREDCACHE_NR];
63 unsigned long nextgc; /* next garbage collection */
64 unsigned long expire; /* cache expiry interval */
65};
66
67struct rpc_auth {
68 unsigned int au_cslack; /* call cred size estimate */
69 unsigned int au_rslack; /* reply verf size guess */
70 unsigned int au_flags; /* various flags */
71 struct rpc_authops * au_ops; /* operations */
72 rpc_authflavor_t au_flavor; /* pseudoflavor (note may
73 * differ from the flavor in
74 * au_ops->au_flavor in gss
75 * case) */
76 atomic_t au_count; /* Reference counter */
77
78 struct rpc_cred_cache * au_credcache;
79 /* per-flavor data */
80};
81#define RPC_AUTH_PROC_CREDS 0x0010 /* process creds (including
82 * uid/gid, fs[ug]id, gids)
83 */
84
85/*
86 * Client authentication ops
87 */
88struct rpc_authops {
89 struct module *owner;
90 rpc_authflavor_t au_flavor; /* flavor (RPC_AUTH_*) */
91#ifdef RPC_DEBUG
92 char * au_name;
93#endif
94 struct rpc_auth * (*create)(struct rpc_clnt *, rpc_authflavor_t);
95 void (*destroy)(struct rpc_auth *);
96
97 struct rpc_cred * (*lookup_cred)(struct rpc_auth *, struct auth_cred *, int);
98 struct rpc_cred * (*crcreate)(struct rpc_auth*, struct auth_cred *, int);
99};
100
101struct rpc_credops {
102 const char * cr_name; /* Name of the auth flavour */
103 void (*crdestroy)(struct rpc_cred *);
104
105 int (*crmatch)(struct auth_cred *, struct rpc_cred *, int);
106 u32 * (*crmarshal)(struct rpc_task *, u32 *);
107 int (*crrefresh)(struct rpc_task *);
108 u32 * (*crvalidate)(struct rpc_task *, u32 *);
109 int (*crwrap_req)(struct rpc_task *, kxdrproc_t,
110 void *, u32 *, void *);
111 int (*crunwrap_resp)(struct rpc_task *, kxdrproc_t,
112 void *, u32 *, void *);
113};
114
115extern struct rpc_authops authunix_ops;
116extern struct rpc_authops authnull_ops;
117#ifdef CONFIG_SUNRPC_SECURE
118extern struct rpc_authops authdes_ops;
119#endif
120
121int rpcauth_register(struct rpc_authops *);
122int rpcauth_unregister(struct rpc_authops *);
123struct rpc_auth * rpcauth_create(rpc_authflavor_t, struct rpc_clnt *);
124void rpcauth_destroy(struct rpc_auth *);
125struct rpc_cred * rpcauth_lookup_credcache(struct rpc_auth *, struct auth_cred *, int);
126struct rpc_cred * rpcauth_lookupcred(struct rpc_auth *, int);
127struct rpc_cred * rpcauth_bindcred(struct rpc_task *);
128void rpcauth_holdcred(struct rpc_task *);
129void put_rpccred(struct rpc_cred *);
130void rpcauth_unbindcred(struct rpc_task *);
131u32 * rpcauth_marshcred(struct rpc_task *, u32 *);
132u32 * rpcauth_checkverf(struct rpc_task *, u32 *);
133int rpcauth_wrap_req(struct rpc_task *task, kxdrproc_t encode, void *rqstp, u32 *data, void *obj);
134int rpcauth_unwrap_resp(struct rpc_task *task, kxdrproc_t decode, void *rqstp, u32 *data, void *obj);
135int rpcauth_refreshcred(struct rpc_task *);
136void rpcauth_invalcred(struct rpc_task *);
137int rpcauth_uptodatecred(struct rpc_task *);
138int rpcauth_init_credcache(struct rpc_auth *, unsigned long);
139void rpcauth_free_credcache(struct rpc_auth *);
140
141static inline
142struct rpc_cred * get_rpccred(struct rpc_cred *cred)
143{
144 atomic_inc(&cred->cr_count);
145 return cred;
146}
147
148#endif /* __KERNEL__ */
149#endif /* _LINUX_SUNRPC_AUTH_H */
diff --git a/include/linux/sunrpc/auth_gss.h b/include/linux/sunrpc/auth_gss.h
new file mode 100644
index 000000000000..03084dc4bb6a
--- /dev/null
+++ b/include/linux/sunrpc/auth_gss.h
@@ -0,0 +1,97 @@
1/*
2 * linux/include/linux/auth_gss.h
3 *
4 * Declarations for RPCSEC_GSS
5 *
6 * Dug Song <dugsong@monkey.org>
7 * Andy Adamson <andros@umich.edu>
8 * Bruce Fields <bfields@umich.edu>
9 * Copyright (c) 2000 The Regents of the University of Michigan
10 *
11 * $Id$
12 */
13
14#ifndef _LINUX_SUNRPC_AUTH_GSS_H
15#define _LINUX_SUNRPC_AUTH_GSS_H
16
17#ifdef __KERNEL__
18#include <linux/sunrpc/auth.h>
19#include <linux/sunrpc/svc.h>
20#include <linux/sunrpc/gss_api.h>
21
22#define RPC_GSS_VERSION 1
23
24#define MAXSEQ 0x80000000 /* maximum legal sequence number, from rfc 2203 */
25
26enum rpc_gss_proc {
27 RPC_GSS_PROC_DATA = 0,
28 RPC_GSS_PROC_INIT = 1,
29 RPC_GSS_PROC_CONTINUE_INIT = 2,
30 RPC_GSS_PROC_DESTROY = 3
31};
32
33enum rpc_gss_svc {
34 RPC_GSS_SVC_NONE = 1,
35 RPC_GSS_SVC_INTEGRITY = 2,
36 RPC_GSS_SVC_PRIVACY = 3
37};
38
39/* on-the-wire gss cred: */
40struct rpc_gss_wire_cred {
41 u32 gc_v; /* version */
42 u32 gc_proc; /* control procedure */
43 u32 gc_seq; /* sequence number */
44 u32 gc_svc; /* service */
45 struct xdr_netobj gc_ctx; /* context handle */
46};
47
48/* on-the-wire gss verifier: */
49struct rpc_gss_wire_verf {
50 u32 gv_flavor;
51 struct xdr_netobj gv_verf;
52};
53
54/* return from gss NULL PROC init sec context */
55struct rpc_gss_init_res {
56 struct xdr_netobj gr_ctx; /* context handle */
57 u32 gr_major; /* major status */
58 u32 gr_minor; /* minor status */
59 u32 gr_win; /* sequence window */
60 struct xdr_netobj gr_token; /* token */
61};
62
63/* The gss_cl_ctx struct holds all the information the rpcsec_gss client
64 * code needs to know about a single security context. In particular,
65 * gc_gss_ctx is the context handle that is used to do gss-api calls, while
66 * gc_wire_ctx is the context handle that is used to identify the context on
67 * the wire when communicating with a server. */
68
69struct gss_cl_ctx {
70 atomic_t count;
71 enum rpc_gss_proc gc_proc;
72 u32 gc_seq;
73 spinlock_t gc_seq_lock;
74 struct gss_ctx *gc_gss_ctx;
75 struct xdr_netobj gc_wire_ctx;
76 u32 gc_win;
77 unsigned long gc_expiry;
78};
79
80struct gss_upcall_msg;
81struct gss_cred {
82 struct rpc_cred gc_base;
83 enum rpc_gss_svc gc_service;
84 struct gss_cl_ctx *gc_ctx;
85 struct gss_upcall_msg *gc_upcall;
86};
87
88#define gc_uid gc_base.cr_uid
89#define gc_count gc_base.cr_count
90#define gc_flags gc_base.cr_flags
91#define gc_expire gc_base.cr_expire
92
93void print_hexl(u32 *p, u_int length, u_int offset);
94
95#endif /* __KERNEL__ */
96#endif /* _LINUX_SUNRPC_AUTH_GSS_H */
97
diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h
new file mode 100644
index 000000000000..6864063d1b9f
--- /dev/null
+++ b/include/linux/sunrpc/cache.h
@@ -0,0 +1,312 @@
1/*
2 * include/linux/sunrpc/cache.h
3 *
4 * Generic code for various authentication-related caches
5 * used by sunrpc clients and servers.
6 *
7 * Copyright (C) 2002 Neil Brown <neilb@cse.unsw.edu.au>
8 *
9 * Released under terms in GPL version 2. See COPYING.
10 *
11 */
12
13#ifndef _LINUX_SUNRPC_CACHE_H_
14#define _LINUX_SUNRPC_CACHE_H_
15
16#include <linux/slab.h>
17#include <asm/atomic.h>
18#include <linux/proc_fs.h>
19
20/*
21 * Each cache requires:
22 * - A 'struct cache_detail' which contains information specific to the cache
23 * for common code to use.
24 * - An item structure that must contain a "struct cache_head"
25 * - A lookup function defined using DefineCacheLookup
26 * - A 'put' function that can release a cache item. It will only
27 * be called after cache_put has succeed, so there are guarantee
28 * to be no references.
29 * - A function to calculate a hash of an item's key.
30 *
31 * as well as assorted code fragments (e.g. compare keys) and numbers
32 * (e.g. hash size, goal_age, etc).
33 *
34 * Each cache must be registered so that it can be cleaned regularly.
35 * When the cache is unregistered, it is flushed completely.
36 *
37 * Entries have a ref count and a 'hashed' flag which counts the existance
38 * in the hash table.
39 * We only expire entries when refcount is zero.
40 * Existance in the cache is counted the refcount.
41 */
42
43/* Every cache item has a common header that is used
44 * for expiring and refreshing entries.
45 *
46 */
47struct cache_head {
48 struct cache_head * next;
49 time_t expiry_time; /* After time time, don't use the data */
50 time_t last_refresh; /* If CACHE_PENDING, this is when upcall
51 * was sent, else this is when update was received
52 */
53 atomic_t refcnt;
54 unsigned long flags;
55};
56#define CACHE_VALID 0 /* Entry contains valid data */
57#define CACHE_NEGATIVE 1 /* Negative entry - there is no match for the key */
58#define CACHE_PENDING 2 /* An upcall has been sent but no reply received yet*/
59
60#define CACHE_NEW_EXPIRY 120 /* keep new things pending confirmation for 120 seconds */
61
62struct cache_detail {
63 int hash_size;
64 struct cache_head ** hash_table;
65 rwlock_t hash_lock;
66
67 atomic_t inuse; /* active user-space update or lookup */
68
69 char *name;
70 void (*cache_put)(struct cache_head *,
71 struct cache_detail*);
72
73 void (*cache_request)(struct cache_detail *cd,
74 struct cache_head *h,
75 char **bpp, int *blen);
76 int (*cache_parse)(struct cache_detail *,
77 char *buf, int len);
78
79 int (*cache_show)(struct seq_file *m,
80 struct cache_detail *cd,
81 struct cache_head *h);
82
83 /* fields below this comment are for internal use
84 * and should not be touched by cache owners
85 */
86 time_t flush_time; /* flush all cache items with last_refresh
87 * earlier than this */
88 struct list_head others;
89 time_t nextcheck;
90 int entries;
91
92 /* fields for communication over channel */
93 struct list_head queue;
94 struct proc_dir_entry *proc_ent;
95 struct proc_dir_entry *flush_ent, *channel_ent, *content_ent;
96
97 atomic_t readers; /* how many time is /chennel open */
98 time_t last_close; /* if no readers, when did last close */
99 time_t last_warn; /* when we last warned about no readers */
100 void (*warn_no_listener)(struct cache_detail *cd);
101};
102
103
104/* this must be embedded in any request structure that
105 * identifies an object that will want a callback on
106 * a cache fill
107 */
108struct cache_req {
109 struct cache_deferred_req *(*defer)(struct cache_req *req);
110};
111/* this must be embedded in a deferred_request that is being
112 * delayed awaiting cache-fill
113 */
114struct cache_deferred_req {
115 struct list_head hash; /* on hash chain */
116 struct list_head recent; /* on fifo */
117 struct cache_head *item; /* cache item we wait on */
118 time_t recv_time;
119 void *owner; /* we might need to discard all defered requests
120 * owned by someone */
121 void (*revisit)(struct cache_deferred_req *req,
122 int too_many);
123};
124
125/*
126 * just like a template in C++, this macro does cache lookup
127 * for us.
128 * The function is passed some sort of HANDLE from which a cache_detail
129 * structure can be determined (via SETUP, DETAIL), a template
130 * cache entry (type RTN*), and a "set" flag. Using the HASHFN and the
131 * TEST, the function will try to find a matching cache entry in the cache.
132 * If "set" == 0 :
133 * If an entry is found, it is returned
134 * If no entry is found, a new non-VALID entry is created.
135 * If "set" == 1 and INPLACE == 0 :
136 * If no entry is found a new one is inserted with data from "template"
137 * If a non-CACHE_VALID entry is found, it is updated from template using UPDATE
138 * If a CACHE_VALID entry is found, a new entry is swapped in with data
139 * from "template"
140 * If set == 1, and INPLACE == 1 :
141 * As above, except that if a CACHE_VALID entry is found, we UPDATE in place
142 * instead of swapping in a new entry.
143 *
144 * If the passed handle has the CACHE_NEGATIVE flag set, then UPDATE is not
145 * run but insteead CACHE_NEGATIVE is set in any new item.
146
147 * In any case, the new entry is returned with a reference count.
148 *
149 *
150 * RTN is a struct type for a cache entry
151 * MEMBER is the member of the cache which is cache_head, which must be first
152 * FNAME is the name for the function
153 * ARGS are arguments to function and must contain RTN *item, int set. May
154 * also contain something to be usedby SETUP or DETAIL to find cache_detail.
155 * SETUP locates the cache detail and makes it available as...
156 * DETAIL identifies the cache detail, possibly set up by SETUP
157 * HASHFN returns a hash value of the cache entry "item"
158 * TEST tests if "tmp" matches "item"
159 * INIT copies key information from "item" to "new"
160 * UPDATE copies content information from "item" to "tmp"
161 * INPLACE is true if updates can happen inplace rather than allocating a new structure
162 *
163 * WARNING: any substantial changes to this must be reflected in
164 * net/sunrpc/svcauth.c(auth_domain_lookup)
165 * which is a similar routine that is open-coded.
166 */
167#define DefineCacheLookup(RTN,MEMBER,FNAME,ARGS,SETUP,DETAIL,HASHFN,TEST,INIT,UPDATE,INPLACE) \
168RTN *FNAME ARGS \
169{ \
170 RTN *tmp, *new=NULL; \
171 struct cache_head **hp, **head; \
172 SETUP; \
173 head = &(DETAIL)->hash_table[HASHFN]; \
174 retry: \
175 if (set||new) write_lock(&(DETAIL)->hash_lock); \
176 else read_lock(&(DETAIL)->hash_lock); \
177 for(hp=head; *hp != NULL; hp = &tmp->MEMBER.next) { \
178 tmp = container_of(*hp, RTN, MEMBER); \
179 if (TEST) { /* found a match */ \
180 \
181 if (set && !INPLACE && test_bit(CACHE_VALID, &tmp->MEMBER.flags) && !new) \
182 break; \
183 \
184 if (new) \
185 {INIT;} \
186 if (set) { \
187 if (!INPLACE && test_bit(CACHE_VALID, &tmp->MEMBER.flags))\
188 { /* need to swap in new */ \
189 RTN *t2; \
190 \
191 new->MEMBER.next = tmp->MEMBER.next; \
192 *hp = &new->MEMBER; \
193 tmp->MEMBER.next = NULL; \
194 t2 = tmp; tmp = new; new = t2; \
195 } \
196 if (test_bit(CACHE_NEGATIVE, &item->MEMBER.flags)) \
197 set_bit(CACHE_NEGATIVE, &tmp->MEMBER.flags); \
198 else { \
199 UPDATE; \
200 clear_bit(CACHE_NEGATIVE, &tmp->MEMBER.flags); \
201 } \
202 } \
203 cache_get(&tmp->MEMBER); \
204 if (set||new) write_unlock(&(DETAIL)->hash_lock); \
205 else read_unlock(&(DETAIL)->hash_lock); \
206 if (set) \
207 cache_fresh(DETAIL, &tmp->MEMBER, item->MEMBER.expiry_time); \
208 if (set && !INPLACE && new) cache_fresh(DETAIL, &new->MEMBER, 0); \
209 if (new) (DETAIL)->cache_put(&new->MEMBER, DETAIL); \
210 return tmp; \
211 } \
212 } \
213 /* Didn't find anything */ \
214 if (new) { \
215 INIT; \
216 new->MEMBER.next = *head; \
217 *head = &new->MEMBER; \
218 (DETAIL)->entries ++; \
219 cache_get(&new->MEMBER); \
220 if (set) { \
221 tmp = new; \
222 if (test_bit(CACHE_NEGATIVE, &item->MEMBER.flags)) \
223 set_bit(CACHE_NEGATIVE, &tmp->MEMBER.flags); \
224 else {UPDATE;} \
225 } \
226 } \
227 if (set||new) write_unlock(&(DETAIL)->hash_lock); \
228 else read_unlock(&(DETAIL)->hash_lock); \
229 if (new && set) \
230 cache_fresh(DETAIL, &new->MEMBER, item->MEMBER.expiry_time); \
231 if (new) \
232 return new; \
233 new = kmalloc(sizeof(*new), GFP_KERNEL); \
234 if (new) { \
235 cache_init(&new->MEMBER); \
236 goto retry; \
237 } \
238 return NULL; \
239}
240
241#define DefineSimpleCacheLookup(STRUCT,INPLACE) \
242 DefineCacheLookup(struct STRUCT, h, STRUCT##_lookup, (struct STRUCT *item, int set), /*no setup */, \
243 & STRUCT##_cache, STRUCT##_hash(item), STRUCT##_match(item, tmp),\
244 STRUCT##_init(new, item), STRUCT##_update(tmp, item),INPLACE)
245
246#define cache_for_each(pos, detail, index, member) \
247 for (({read_lock(&(detail)->hash_lock); index = (detail)->hash_size;}) ; \
248 ({if (index==0)read_unlock(&(detail)->hash_lock); index--;}); \
249 ) \
250 for (pos = container_of((detail)->hash_table[index], typeof(*pos), member); \
251 &pos->member; \
252 pos = container_of(pos->member.next, typeof(*pos), member))
253
254
255
256extern void cache_clean_deferred(void *owner);
257
258static inline struct cache_head *cache_get(struct cache_head *h)
259{
260 atomic_inc(&h->refcnt);
261 return h;
262}
263
264
265static inline int cache_put(struct cache_head *h, struct cache_detail *cd)
266{
267 if (atomic_read(&h->refcnt) <= 2 &&
268 h->expiry_time < cd->nextcheck)
269 cd->nextcheck = h->expiry_time;
270 return atomic_dec_and_test(&h->refcnt);
271}
272
273extern void cache_init(struct cache_head *h);
274extern void cache_fresh(struct cache_detail *detail,
275 struct cache_head *head, time_t expiry);
276extern int cache_check(struct cache_detail *detail,
277 struct cache_head *h, struct cache_req *rqstp);
278extern void cache_flush(void);
279extern void cache_purge(struct cache_detail *detail);
280#define NEVER (0x7FFFFFFF)
281extern void cache_register(struct cache_detail *cd);
282extern int cache_unregister(struct cache_detail *cd);
283
284extern void qword_add(char **bpp, int *lp, char *str);
285extern void qword_addhex(char **bpp, int *lp, char *buf, int blen);
286extern int qword_get(char **bpp, char *dest, int bufsize);
287
288static inline int get_int(char **bpp, int *anint)
289{
290 char buf[50];
291 char *ep;
292 int rv;
293 int len = qword_get(bpp, buf, 50);
294 if (len < 0) return -EINVAL;
295 if (len ==0) return -ENOENT;
296 rv = simple_strtol(buf, &ep, 0);
297 if (*ep) return -EINVAL;
298 *anint = rv;
299 return 0;
300}
301
302static inline time_t get_expiry(char **bpp)
303{
304 int rv;
305 if (get_int(bpp, &rv))
306 return 0;
307 if (rv < 0)
308 return 0;
309 return rv;
310}
311
312#endif /* _LINUX_SUNRPC_CACHE_H_ */
diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
new file mode 100644
index 000000000000..2709caf4d128
--- /dev/null
+++ b/include/linux/sunrpc/clnt.h
@@ -0,0 +1,153 @@
1/*
2 * linux/include/linux/sunrpc/clnt.h
3 *
4 * Declarations for the high-level RPC client interface
5 *
6 * Copyright (C) 1995, 1996, Olaf Kirch <okir@monad.swb.de>
7 */
8
9#ifndef _LINUX_SUNRPC_CLNT_H
10#define _LINUX_SUNRPC_CLNT_H
11
12#include <linux/sunrpc/msg_prot.h>
13#include <linux/sunrpc/sched.h>
14#include <linux/sunrpc/xprt.h>
15#include <linux/sunrpc/auth.h>
16#include <linux/sunrpc/stats.h>
17#include <linux/sunrpc/xdr.h>
18#include <linux/sunrpc/timer.h>
19#include <asm/signal.h>
20
21/*
22 * This defines an RPC port mapping
23 */
24struct rpc_portmap {
25 __u32 pm_prog;
26 __u32 pm_vers;
27 __u32 pm_prot;
28 __u16 pm_port;
29 unsigned char pm_binding : 1; /* doing a getport() */
30 struct rpc_wait_queue pm_bindwait; /* waiting on getport() */
31};
32
33struct rpc_inode;
34
35/*
36 * The high-level client handle
37 */
38struct rpc_clnt {
39 atomic_t cl_count; /* Number of clones */
40 atomic_t cl_users; /* number of references */
41 struct rpc_xprt * cl_xprt; /* transport */
42 struct rpc_procinfo * cl_procinfo; /* procedure info */
43 u32 cl_maxproc; /* max procedure number */
44
45 char * cl_server; /* server machine name */
46 char * cl_protname; /* protocol name */
47 struct rpc_auth * cl_auth; /* authenticator */
48 struct rpc_stat * cl_stats; /* statistics */
49
50 unsigned int cl_softrtry : 1,/* soft timeouts */
51 cl_intr : 1,/* interruptible */
52 cl_chatty : 1,/* be verbose */
53 cl_autobind : 1,/* use getport() */
54 cl_oneshot : 1,/* dispose after use */
55 cl_dead : 1;/* abandoned */
56
57 struct rpc_rtt * cl_rtt; /* RTO estimator data */
58 struct rpc_portmap * cl_pmap; /* port mapping */
59
60 int cl_nodelen; /* nodename length */
61 char cl_nodename[UNX_MAXNODENAME];
62 char cl_pathname[30];/* Path in rpc_pipe_fs */
63 struct dentry * cl_dentry; /* inode */
64 struct rpc_clnt * cl_parent; /* Points to parent of clones */
65 struct rpc_rtt cl_rtt_default;
66 struct rpc_portmap cl_pmap_default;
67 char cl_inline_name[32];
68};
69#define cl_timeout cl_xprt->timeout
70#define cl_prog cl_pmap->pm_prog
71#define cl_vers cl_pmap->pm_vers
72#define cl_port cl_pmap->pm_port
73#define cl_prot cl_pmap->pm_prot
74
75/*
76 * General RPC program info
77 */
78#define RPC_MAXVERSION 4
79struct rpc_program {
80 char * name; /* protocol name */
81 u32 number; /* program number */
82 unsigned int nrvers; /* number of versions */
83 struct rpc_version ** version; /* version array */
84 struct rpc_stat * stats; /* statistics */
85 char * pipe_dir_name; /* path to rpc_pipefs dir */
86};
87
88struct rpc_version {
89 u32 number; /* version number */
90 unsigned int nrprocs; /* number of procs */
91 struct rpc_procinfo * procs; /* procedure array */
92};
93
94/*
95 * Procedure information
96 */
97struct rpc_procinfo {
98 u32 p_proc; /* RPC procedure number */
99 kxdrproc_t p_encode; /* XDR encode function */
100 kxdrproc_t p_decode; /* XDR decode function */
101 unsigned int p_bufsiz; /* req. buffer size */
102 unsigned int p_count; /* call count */
103 unsigned int p_timer; /* Which RTT timer to use */
104};
105
106#define RPC_CONGESTED(clnt) (RPCXPRT_CONGESTED((clnt)->cl_xprt))
107#define RPC_PEERADDR(clnt) (&(clnt)->cl_xprt->addr)
108
109#ifdef __KERNEL__
110
111struct rpc_clnt *rpc_create_client(struct rpc_xprt *xprt, char *servname,
112 struct rpc_program *info,
113 u32 version, rpc_authflavor_t authflavor);
114struct rpc_clnt *rpc_clone_client(struct rpc_clnt *);
115int rpc_shutdown_client(struct rpc_clnt *);
116int rpc_destroy_client(struct rpc_clnt *);
117void rpc_release_client(struct rpc_clnt *);
118void rpc_getport(struct rpc_task *, struct rpc_clnt *);
119int rpc_register(u32, u32, int, unsigned short, int *);
120
121void rpc_call_setup(struct rpc_task *, struct rpc_message *, int);
122
123int rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg,
124 int flags, rpc_action callback, void *clntdata);
125int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg,
126 int flags);
127void rpc_restart_call(struct rpc_task *);
128void rpc_clnt_sigmask(struct rpc_clnt *clnt, sigset_t *oldset);
129void rpc_clnt_sigunmask(struct rpc_clnt *clnt, sigset_t *oldset);
130void rpc_setbufsize(struct rpc_clnt *, unsigned int, unsigned int);
131size_t rpc_max_payload(struct rpc_clnt *);
132
133static __inline__
134int rpc_call(struct rpc_clnt *clnt, u32 proc, void *argp, void *resp, int flags)
135{
136 struct rpc_message msg = {
137 .rpc_proc = &clnt->cl_procinfo[proc],
138 .rpc_argp = argp,
139 .rpc_resp = resp,
140 .rpc_cred = NULL
141 };
142 return rpc_call_sync(clnt, &msg, flags);
143}
144
145extern void rpciod_wake_up(void);
146
147/*
148 * Helper function for NFSroot support
149 */
150int rpc_getport_external(struct sockaddr_in *, __u32, __u32, int);
151
152#endif /* __KERNEL__ */
153#endif /* _LINUX_SUNRPC_CLNT_H */
diff --git a/include/linux/sunrpc/debug.h b/include/linux/sunrpc/debug.h
new file mode 100644
index 000000000000..eadb31e3c198
--- /dev/null
+++ b/include/linux/sunrpc/debug.h
@@ -0,0 +1,99 @@
1/*
2 * linux/include/linux/sunrpc/debug.h
3 *
4 * Debugging support for sunrpc module
5 *
6 * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
7 */
8
9#ifndef _LINUX_SUNRPC_DEBUG_H_
10#define _LINUX_SUNRPC_DEBUG_H_
11
12#include <linux/config.h>
13
14#include <linux/timer.h>
15#include <linux/workqueue.h>
16
17/*
18 * Enable RPC debugging/profiling.
19 */
20#ifdef CONFIG_SYSCTL
21#define RPC_DEBUG
22#endif
23/* #define RPC_PROFILE */
24
25/*
26 * RPC debug facilities
27 */
28#define RPCDBG_XPRT 0x0001
29#define RPCDBG_CALL 0x0002
30#define RPCDBG_DEBUG 0x0004
31#define RPCDBG_NFS 0x0008
32#define RPCDBG_AUTH 0x0010
33#define RPCDBG_PMAP 0x0020
34#define RPCDBG_SCHED 0x0040
35#define RPCDBG_SVCSOCK 0x0100
36#define RPCDBG_SVCDSP 0x0200
37#define RPCDBG_MISC 0x0400
38#define RPCDBG_CACHE 0x0800
39#define RPCDBG_ALL 0x7fff
40
41#ifdef __KERNEL__
42
43/*
44 * Debugging macros etc
45 */
46#ifdef RPC_DEBUG
47extern unsigned int rpc_debug;
48extern unsigned int nfs_debug;
49extern unsigned int nfsd_debug;
50extern unsigned int nlm_debug;
51#endif
52
53#define dprintk(args...) dfprintk(FACILITY, ## args)
54
55#undef ifdebug
56#ifdef RPC_DEBUG
57# define ifdebug(fac) if (unlikely(rpc_debug & RPCDBG_##fac))
58# define dfprintk(fac, args...) do { ifdebug(fac) printk(args); } while(0)
59# define RPC_IFDEBUG(x) x
60#else
61# define ifdebug(fac) if (0)
62# define dfprintk(fac, args...) do ; while (0)
63# define RPC_IFDEBUG(x)
64#endif
65
66#ifdef RPC_PROFILE
67# define pprintk(args...) printk(## args)
68#else
69# define pprintk(args...) do ; while (0)
70#endif
71
72/*
73 * Sysctl interface for RPC debugging
74 */
75#ifdef RPC_DEBUG
76void rpc_register_sysctl(void);
77void rpc_unregister_sysctl(void);
78#endif
79
80#endif /* __KERNEL__ */
81
82/*
83 * Declarations for the sysctl debug interface, which allows to read or
84 * change the debug flags for rpc, nfs, nfsd, and lockd. Since the sunrpc
85 * module currently registers its sysctl table dynamically, the sysctl path
86 * for module FOO is <CTL_SUNRPC, CTL_FOODEBUG>.
87 */
88#define CTL_SUNRPC 7249 /* arbitrary and hopefully unused */
89
90enum {
91 CTL_RPCDEBUG = 1,
92 CTL_NFSDEBUG,
93 CTL_NFSDDEBUG,
94 CTL_NLMDEBUG,
95 CTL_SLOTTABLE_UDP,
96 CTL_SLOTTABLE_TCP,
97};
98
99#endif /* _LINUX_SUNRPC_DEBUG_H_ */
diff --git a/include/linux/sunrpc/gss_api.h b/include/linux/sunrpc/gss_api.h
new file mode 100644
index 000000000000..689262f63059
--- /dev/null
+++ b/include/linux/sunrpc/gss_api.h
@@ -0,0 +1,122 @@
1/*
2 * linux/include/linux/gss_api.h
3 *
4 * Somewhat simplified version of the gss api.
5 *
6 * Dug Song <dugsong@monkey.org>
7 * Andy Adamson <andros@umich.edu>
8 * Bruce Fields <bfields@umich.edu>
9 * Copyright (c) 2000 The Regents of the University of Michigan
10 *
11 * $Id$
12 */
13
14#ifndef _LINUX_SUNRPC_GSS_API_H
15#define _LINUX_SUNRPC_GSS_API_H
16
17#ifdef __KERNEL__
18#include <linux/sunrpc/xdr.h>
19#include <linux/uio.h>
20
21/* The mechanism-independent gss-api context: */
22struct gss_ctx {
23 struct gss_api_mech *mech_type;
24 void *internal_ctx_id;
25};
26
27#define GSS_C_NO_BUFFER ((struct xdr_netobj) 0)
28#define GSS_C_NO_CONTEXT ((struct gss_ctx *) 0)
29#define GSS_C_NULL_OID ((struct xdr_netobj) 0)
30
31/*XXX arbitrary length - is this set somewhere? */
32#define GSS_OID_MAX_LEN 32
33
34/* gss-api prototypes; note that these are somewhat simplified versions of
35 * the prototypes specified in RFC 2744. */
36int gss_import_sec_context(
37 const void* input_token,
38 size_t bufsize,
39 struct gss_api_mech *mech,
40 struct gss_ctx **ctx_id);
41u32 gss_get_mic(
42 struct gss_ctx *ctx_id,
43 u32 qop,
44 struct xdr_buf *message,
45 struct xdr_netobj *mic_token);
46u32 gss_verify_mic(
47 struct gss_ctx *ctx_id,
48 struct xdr_buf *message,
49 struct xdr_netobj *mic_token,
50 u32 *qstate);
51u32 gss_delete_sec_context(
52 struct gss_ctx **ctx_id);
53
54u32 gss_pseudoflavor_to_service(struct gss_api_mech *, u32 pseudoflavor);
55char *gss_service_to_auth_domain_name(struct gss_api_mech *, u32 service);
56
57struct pf_desc {
58 u32 pseudoflavor;
59 u32 qop;
60 u32 service;
61 char *name;
62 char *auth_domain_name;
63};
64
65/* Different mechanisms (e.g., krb5 or spkm3) may implement gss-api, and
66 * mechanisms may be dynamically registered or unregistered by modules. */
67
68/* Each mechanism is described by the following struct: */
69struct gss_api_mech {
70 struct list_head gm_list;
71 struct module *gm_owner;
72 struct xdr_netobj gm_oid;
73 char *gm_name;
74 struct gss_api_ops *gm_ops;
75 /* pseudoflavors supported by this mechanism: */
76 int gm_pf_num;
77 struct pf_desc * gm_pfs;
78};
79
80/* and must provide the following operations: */
81struct gss_api_ops {
82 int (*gss_import_sec_context)(
83 const void *input_token,
84 size_t bufsize,
85 struct gss_ctx *ctx_id);
86 u32 (*gss_get_mic)(
87 struct gss_ctx *ctx_id,
88 u32 qop,
89 struct xdr_buf *message,
90 struct xdr_netobj *mic_token);
91 u32 (*gss_verify_mic)(
92 struct gss_ctx *ctx_id,
93 struct xdr_buf *message,
94 struct xdr_netobj *mic_token,
95 u32 *qstate);
96 void (*gss_delete_sec_context)(
97 void *internal_ctx_id);
98};
99
100int gss_mech_register(struct gss_api_mech *);
101void gss_mech_unregister(struct gss_api_mech *);
102
103/* returns a mechanism descriptor given an OID, and increments the mechanism's
104 * reference count. */
105struct gss_api_mech * gss_mech_get_by_OID(struct xdr_netobj *);
106
107/* Returns a reference to a mechanism, given a name like "krb5" etc. */
108struct gss_api_mech *gss_mech_get_by_name(const char *);
109
110/* Similar, but get by pseudoflavor. */
111struct gss_api_mech *gss_mech_get_by_pseudoflavor(u32);
112
113/* Just increments the mechanism's reference count and returns its input: */
114struct gss_api_mech * gss_mech_get(struct gss_api_mech *);
115
116/* For every succesful gss_mech_get or gss_mech_get_by_* call there must be a
117 * corresponding call to gss_mech_put. */
118void gss_mech_put(struct gss_api_mech *);
119
120#endif /* __KERNEL__ */
121#endif /* _LINUX_SUNRPC_GSS_API_H */
122
diff --git a/include/linux/sunrpc/gss_asn1.h b/include/linux/sunrpc/gss_asn1.h
new file mode 100644
index 000000000000..3ccecd0ad229
--- /dev/null
+++ b/include/linux/sunrpc/gss_asn1.h
@@ -0,0 +1,81 @@
1/*
2 * linux/include/linux/sunrpc/gss_asn1.h
3 *
4 * minimal asn1 for generic encoding/decoding of gss tokens
5 *
6 * Adapted from MIT Kerberos 5-1.2.1 lib/include/krb5.h,
7 * lib/gssapi/krb5/gssapiP_krb5.h, and others
8 *
9 * Copyright (c) 2000 The Regents of the University of Michigan.
10 * All rights reserved.
11 *
12 * Andy Adamson <andros@umich.edu>
13 */
14
15/*
16 * Copyright 1995 by the Massachusetts Institute of Technology.
17 * All Rights Reserved.
18 *
19 * Export of this software from the United States of America may
20 * require a specific license from the United States Government.
21 * It is the responsibility of any person or organization contemplating
22 * export to obtain such a license before exporting.
23 *
24 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
25 * distribute this software and its documentation for any purpose and
26 * without fee is hereby granted, provided that the above copyright
27 * notice appear in all copies and that both that copyright notice and
28 * this permission notice appear in supporting documentation, and that
29 * the name of M.I.T. not be used in advertising or publicity pertaining
30 * to distribution of the software without specific, written prior
31 * permission. Furthermore if you modify this software you must label
32 * your software as modified software and not distribute it in such a
33 * fashion that it might be confused with the original M.I.T. software.
34 * M.I.T. makes no representations about the suitability of
35 * this software for any purpose. It is provided "as is" without express
36 * or implied warranty.
37 *
38 */
39
40
41#include <linux/sunrpc/gss_api.h>
42
43#define SIZEOF_INT 4
44
45/* from gssapi_err_generic.h */
46#define G_BAD_SERVICE_NAME (-2045022976L)
47#define G_BAD_STRING_UID (-2045022975L)
48#define G_NOUSER (-2045022974L)
49#define G_VALIDATE_FAILED (-2045022973L)
50#define G_BUFFER_ALLOC (-2045022972L)
51#define G_BAD_MSG_CTX (-2045022971L)
52#define G_WRONG_SIZE (-2045022970L)
53#define G_BAD_USAGE (-2045022969L)
54#define G_UNKNOWN_QOP (-2045022968L)
55#define G_NO_HOSTNAME (-2045022967L)
56#define G_BAD_HOSTNAME (-2045022966L)
57#define G_WRONG_MECH (-2045022965L)
58#define G_BAD_TOK_HEADER (-2045022964L)
59#define G_BAD_DIRECTION (-2045022963L)
60#define G_TOK_TRUNC (-2045022962L)
61#define G_REFLECT (-2045022961L)
62#define G_WRONG_TOKID (-2045022960L)
63
64#define g_OID_equal(o1,o2) \
65 (((o1)->len == (o2)->len) && \
66 (memcmp((o1)->data,(o2)->data,(int) (o1)->len) == 0))
67
68u32 g_verify_token_header(
69 struct xdr_netobj *mech,
70 int *body_size,
71 unsigned char **buf_in,
72 int toksize);
73
74int g_token_size(
75 struct xdr_netobj *mech,
76 unsigned int body_size);
77
78void g_make_token_header(
79 struct xdr_netobj *mech,
80 int body_size,
81 unsigned char **buf);
diff --git a/include/linux/sunrpc/gss_err.h b/include/linux/sunrpc/gss_err.h
new file mode 100644
index 000000000000..92608a2e574c
--- /dev/null
+++ b/include/linux/sunrpc/gss_err.h
@@ -0,0 +1,177 @@
1/*
2 * linux/include/sunrpc/gss_err.h
3 *
4 * Adapted from MIT Kerberos 5-1.2.1 include/gssapi/gssapi.h
5 *
6 * Copyright (c) 2002 The Regents of the University of Michigan.
7 * All rights reserved.
8 *
9 * Andy Adamson <andros@umich.edu>
10 */
11
12/*
13 * Copyright 1993 by OpenVision Technologies, Inc.
14 *
15 * Permission to use, copy, modify, distribute, and sell this software
16 * and its documentation for any purpose is hereby granted without fee,
17 * provided that the above copyright notice appears in all copies and
18 * that both that copyright notice and this permission notice appear in
19 * supporting documentation, and that the name of OpenVision not be used
20 * in advertising or publicity pertaining to distribution of the software
21 * without specific, written prior permission. OpenVision makes no
22 * representations about the suitability of this software for any
23 * purpose. It is provided "as is" without express or implied warranty.
24 *
25 * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
26 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
27 * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
28 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
29 * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
30 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
31 * PERFORMANCE OF THIS SOFTWARE.
32 */
33
34#ifndef _LINUX_SUNRPC_GSS_ERR_H
35#define _LINUX_SUNRPC_GSS_ERR_H
36
37#ifdef __KERNEL__
38
39typedef unsigned int OM_uint32;
40
41/*
42 * Flag bits for context-level services.
43 */
44#define GSS_C_DELEG_FLAG 1
45#define GSS_C_MUTUAL_FLAG 2
46#define GSS_C_REPLAY_FLAG 4
47#define GSS_C_SEQUENCE_FLAG 8
48#define GSS_C_CONF_FLAG 16
49#define GSS_C_INTEG_FLAG 32
50#define GSS_C_ANON_FLAG 64
51#define GSS_C_PROT_READY_FLAG 128
52#define GSS_C_TRANS_FLAG 256
53
54/*
55 * Credential usage options
56 */
57#define GSS_C_BOTH 0
58#define GSS_C_INITIATE 1
59#define GSS_C_ACCEPT 2
60
61/*
62 * Status code types for gss_display_status
63 */
64#define GSS_C_GSS_CODE 1
65#define GSS_C_MECH_CODE 2
66
67
68/*
69 * Define the default Quality of Protection for per-message services. Note
70 * that an implementation that offers multiple levels of QOP may either reserve
71 * a value (for example zero, as assumed here) to mean "default protection", or
72 * alternatively may simply equate GSS_C_QOP_DEFAULT to a specific explicit
73 * QOP value. However a value of 0 should always be interpreted by a GSSAPI
74 * implementation as a request for the default protection level.
75 */
76#define GSS_C_QOP_DEFAULT 0
77
78/*
79 * Expiration time of 2^32-1 seconds means infinite lifetime for a
80 * credential or security context
81 */
82#define GSS_C_INDEFINITE ((OM_uint32) 0xfffffffful)
83
84
85/* Major status codes */
86
87#define GSS_S_COMPLETE 0
88
89/*
90 * Some "helper" definitions to make the status code macros obvious.
91 */
92#define GSS_C_CALLING_ERROR_OFFSET 24
93#define GSS_C_ROUTINE_ERROR_OFFSET 16
94#define GSS_C_SUPPLEMENTARY_OFFSET 0
95#define GSS_C_CALLING_ERROR_MASK ((OM_uint32) 0377ul)
96#define GSS_C_ROUTINE_ERROR_MASK ((OM_uint32) 0377ul)
97#define GSS_C_SUPPLEMENTARY_MASK ((OM_uint32) 0177777ul)
98
99/*
100 * The macros that test status codes for error conditions. Note that the
101 * GSS_ERROR() macro has changed slightly from the V1 GSSAPI so that it now
102 * evaluates its argument only once.
103 */
104#define GSS_CALLING_ERROR(x) \
105 ((x) & (GSS_C_CALLING_ERROR_MASK << GSS_C_CALLING_ERROR_OFFSET))
106#define GSS_ROUTINE_ERROR(x) \
107 ((x) & (GSS_C_ROUTINE_ERROR_MASK << GSS_C_ROUTINE_ERROR_OFFSET))
108#define GSS_SUPPLEMENTARY_INFO(x) \
109 ((x) & (GSS_C_SUPPLEMENTARY_MASK << GSS_C_SUPPLEMENTARY_OFFSET))
110#define GSS_ERROR(x) \
111 ((x) & ((GSS_C_CALLING_ERROR_MASK << GSS_C_CALLING_ERROR_OFFSET) | \
112 (GSS_C_ROUTINE_ERROR_MASK << GSS_C_ROUTINE_ERROR_OFFSET)))
113
114/*
115 * Now the actual status code definitions
116 */
117
118/*
119 * Calling errors:
120 */
121#define GSS_S_CALL_INACCESSIBLE_READ \
122 (((OM_uint32) 1ul) << GSS_C_CALLING_ERROR_OFFSET)
123#define GSS_S_CALL_INACCESSIBLE_WRITE \
124 (((OM_uint32) 2ul) << GSS_C_CALLING_ERROR_OFFSET)
125#define GSS_S_CALL_BAD_STRUCTURE \
126 (((OM_uint32) 3ul) << GSS_C_CALLING_ERROR_OFFSET)
127
128/*
129 * Routine errors:
130 */
131#define GSS_S_BAD_MECH (((OM_uint32) 1ul) << GSS_C_ROUTINE_ERROR_OFFSET)
132#define GSS_S_BAD_NAME (((OM_uint32) 2ul) << GSS_C_ROUTINE_ERROR_OFFSET)
133#define GSS_S_BAD_NAMETYPE (((OM_uint32) 3ul) << GSS_C_ROUTINE_ERROR_OFFSET)
134#define GSS_S_BAD_BINDINGS (((OM_uint32) 4ul) << GSS_C_ROUTINE_ERROR_OFFSET)
135#define GSS_S_BAD_STATUS (((OM_uint32) 5ul) << GSS_C_ROUTINE_ERROR_OFFSET)
136#define GSS_S_BAD_SIG (((OM_uint32) 6ul) << GSS_C_ROUTINE_ERROR_OFFSET)
137#define GSS_S_NO_CRED (((OM_uint32) 7ul) << GSS_C_ROUTINE_ERROR_OFFSET)
138#define GSS_S_NO_CONTEXT (((OM_uint32) 8ul) << GSS_C_ROUTINE_ERROR_OFFSET)
139#define GSS_S_DEFECTIVE_TOKEN (((OM_uint32) 9ul) << GSS_C_ROUTINE_ERROR_OFFSET)
140#define GSS_S_DEFECTIVE_CREDENTIAL \
141 (((OM_uint32) 10ul) << GSS_C_ROUTINE_ERROR_OFFSET)
142#define GSS_S_CREDENTIALS_EXPIRED \
143 (((OM_uint32) 11ul) << GSS_C_ROUTINE_ERROR_OFFSET)
144#define GSS_S_CONTEXT_EXPIRED \
145 (((OM_uint32) 12ul) << GSS_C_ROUTINE_ERROR_OFFSET)
146#define GSS_S_FAILURE (((OM_uint32) 13ul) << GSS_C_ROUTINE_ERROR_OFFSET)
147#define GSS_S_BAD_QOP (((OM_uint32) 14ul) << GSS_C_ROUTINE_ERROR_OFFSET)
148#define GSS_S_UNAUTHORIZED (((OM_uint32) 15ul) << GSS_C_ROUTINE_ERROR_OFFSET)
149#define GSS_S_UNAVAILABLE (((OM_uint32) 16ul) << GSS_C_ROUTINE_ERROR_OFFSET)
150#define GSS_S_DUPLICATE_ELEMENT \
151 (((OM_uint32) 17ul) << GSS_C_ROUTINE_ERROR_OFFSET)
152#define GSS_S_NAME_NOT_MN \
153 (((OM_uint32) 18ul) << GSS_C_ROUTINE_ERROR_OFFSET)
154
155/*
156 * Supplementary info bits:
157 */
158#define GSS_S_CONTINUE_NEEDED (1 << (GSS_C_SUPPLEMENTARY_OFFSET + 0))
159#define GSS_S_DUPLICATE_TOKEN (1 << (GSS_C_SUPPLEMENTARY_OFFSET + 1))
160#define GSS_S_OLD_TOKEN (1 << (GSS_C_SUPPLEMENTARY_OFFSET + 2))
161#define GSS_S_UNSEQ_TOKEN (1 << (GSS_C_SUPPLEMENTARY_OFFSET + 3))
162#define GSS_S_GAP_TOKEN (1 << (GSS_C_SUPPLEMENTARY_OFFSET + 4))
163
164/* XXXX these are not part of the GSSAPI C bindings! (but should be) */
165
166#define GSS_CALLING_ERROR_FIELD(x) \
167 (((x) >> GSS_C_CALLING_ERROR_OFFSET) & GSS_C_CALLING_ERROR_MASK)
168#define GSS_ROUTINE_ERROR_FIELD(x) \
169 (((x) >> GSS_C_ROUTINE_ERROR_OFFSET) & GSS_C_ROUTINE_ERROR_MASK)
170#define GSS_SUPPLEMENTARY_INFO_FIELD(x) \
171 (((x) >> GSS_C_SUPPLEMENTARY_OFFSET) & GSS_C_SUPPLEMENTARY_MASK)
172
173/* XXXX This is a necessary evil until the spec is fixed */
174#define GSS_S_CRED_UNAVAIL GSS_S_FAILURE
175
176#endif /* __KERNEL__ */
177#endif /* __LINUX_SUNRPC_GSS_ERR_H */
diff --git a/include/linux/sunrpc/gss_krb5.h b/include/linux/sunrpc/gss_krb5.h
new file mode 100644
index 000000000000..ffe31d2eb9ec
--- /dev/null
+++ b/include/linux/sunrpc/gss_krb5.h
@@ -0,0 +1,148 @@
1/*
2 * linux/include/linux/sunrpc/gss_krb5_types.h
3 *
4 * Adapted from MIT Kerberos 5-1.2.1 lib/include/krb5.h,
5 * lib/gssapi/krb5/gssapiP_krb5.h, and others
6 *
7 * Copyright (c) 2000 The Regents of the University of Michigan.
8 * All rights reserved.
9 *
10 * Andy Adamson <andros@umich.edu>
11 * Bruce Fields <bfields@umich.edu>
12 */
13
14/*
15 * Copyright 1995 by the Massachusetts Institute of Technology.
16 * All Rights Reserved.
17 *
18 * Export of this software from the United States of America may
19 * require a specific license from the United States Government.
20 * It is the responsibility of any person or organization contemplating
21 * export to obtain such a license before exporting.
22 *
23 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
24 * distribute this software and its documentation for any purpose and
25 * without fee is hereby granted, provided that the above copyright
26 * notice appear in all copies and that both that copyright notice and
27 * this permission notice appear in supporting documentation, and that
28 * the name of M.I.T. not be used in advertising or publicity pertaining
29 * to distribution of the software without specific, written prior
30 * permission. Furthermore if you modify this software you must label
31 * your software as modified software and not distribute it in such a
32 * fashion that it might be confused with the original M.I.T. software.
33 * M.I.T. makes no representations about the suitability of
34 * this software for any purpose. It is provided "as is" without express
35 * or implied warranty.
36 *
37 */
38
39#include <linux/sunrpc/auth_gss.h>
40#include <linux/sunrpc/gss_err.h>
41#include <linux/sunrpc/gss_asn1.h>
42
43struct krb5_ctx {
44 int initiate; /* 1 = initiating, 0 = accepting */
45 int seed_init;
46 unsigned char seed[16];
47 int signalg;
48 int sealalg;
49 struct crypto_tfm *enc;
50 struct crypto_tfm *seq;
51 s32 endtime;
52 u32 seq_send;
53 struct xdr_netobj mech_used;
54};
55
56#define KG_TOK_MIC_MSG 0x0101
57#define KG_TOK_WRAP_MSG 0x0201
58
59enum sgn_alg {
60 SGN_ALG_DES_MAC_MD5 = 0x0000,
61 SGN_ALG_MD2_5 = 0x0001,
62 SGN_ALG_DES_MAC = 0x0002,
63 SGN_ALG_3 = 0x0003, /* not published */
64 SGN_ALG_HMAC_MD5 = 0x0011, /* microsoft w2k; no support */
65 SGN_ALG_HMAC_SHA1_DES3_KD = 0x0004
66};
67enum seal_alg {
68 SEAL_ALG_NONE = 0xffff,
69 SEAL_ALG_DES = 0x0000,
70 SEAL_ALG_1 = 0x0001, /* not published */
71 SEAL_ALG_MICROSOFT_RC4 = 0x0010,/* microsoft w2k; no support */
72 SEAL_ALG_DES3KD = 0x0002
73};
74
75#define KRB5_CKSUM_LENGTH 8
76
77#define CKSUMTYPE_CRC32 0x0001
78#define CKSUMTYPE_RSA_MD4 0x0002
79#define CKSUMTYPE_RSA_MD4_DES 0x0003
80#define CKSUMTYPE_DESCBC 0x0004
81#define CKSUMTYPE_RSA_MD5 0x0007
82#define CKSUMTYPE_RSA_MD5_DES 0x0008
83#define CKSUMTYPE_NIST_SHA 0x0009
84#define CKSUMTYPE_HMAC_SHA1_DES3 0x000c
85
86/* from gssapi_err_krb5.h */
87#define KG_CCACHE_NOMATCH (39756032L)
88#define KG_KEYTAB_NOMATCH (39756033L)
89#define KG_TGT_MISSING (39756034L)
90#define KG_NO_SUBKEY (39756035L)
91#define KG_CONTEXT_ESTABLISHED (39756036L)
92#define KG_BAD_SIGN_TYPE (39756037L)
93#define KG_BAD_LENGTH (39756038L)
94#define KG_CTX_INCOMPLETE (39756039L)
95#define KG_CONTEXT (39756040L)
96#define KG_CRED (39756041L)
97#define KG_ENC_DESC (39756042L)
98#define KG_BAD_SEQ (39756043L)
99#define KG_EMPTY_CCACHE (39756044L)
100#define KG_NO_CTYPES (39756045L)
101
102/* per Kerberos v5 protocol spec crypto types from the wire.
103 * these get mapped to linux kernel crypto routines.
104 */
105#define ENCTYPE_NULL 0x0000
106#define ENCTYPE_DES_CBC_CRC 0x0001 /* DES cbc mode with CRC-32 */
107#define ENCTYPE_DES_CBC_MD4 0x0002 /* DES cbc mode with RSA-MD4 */
108#define ENCTYPE_DES_CBC_MD5 0x0003 /* DES cbc mode with RSA-MD5 */
109#define ENCTYPE_DES_CBC_RAW 0x0004 /* DES cbc mode raw */
110/* XXX deprecated? */
111#define ENCTYPE_DES3_CBC_SHA 0x0005 /* DES-3 cbc mode with NIST-SHA */
112#define ENCTYPE_DES3_CBC_RAW 0x0006 /* DES-3 cbc mode raw */
113#define ENCTYPE_DES_HMAC_SHA1 0x0008
114#define ENCTYPE_DES3_CBC_SHA1 0x0010
115#define ENCTYPE_UNKNOWN 0x01ff
116
117s32
118make_checksum(s32 cksumtype, char *header, int hdrlen, struct xdr_buf *body,
119 struct xdr_netobj *cksum);
120
121u32
122krb5_make_token(struct krb5_ctx *context_handle, int qop_req,
123 struct xdr_buf *input_message_buffer,
124 struct xdr_netobj *output_message_buffer, int toktype);
125
126u32
127krb5_read_token(struct krb5_ctx *context_handle,
128 struct xdr_netobj *input_token_buffer,
129 struct xdr_buf *message_buffer,
130 int *qop_state, int toktype);
131
132u32
133krb5_encrypt(struct crypto_tfm * key,
134 void *iv, void *in, void *out, int length);
135
136u32
137krb5_decrypt(struct crypto_tfm * key,
138 void *iv, void *in, void *out, int length);
139
140s32
141krb5_make_seq_num(struct crypto_tfm * key,
142 int direction,
143 s32 seqnum, unsigned char *cksum, unsigned char *buf);
144
145s32
146krb5_get_seq_num(struct crypto_tfm * key,
147 unsigned char *cksum,
148 unsigned char *buf, int *direction, s32 * seqnum);
diff --git a/include/linux/sunrpc/gss_spkm3.h b/include/linux/sunrpc/gss_spkm3.h
new file mode 100644
index 000000000000..b5c9968c3c17
--- /dev/null
+++ b/include/linux/sunrpc/gss_spkm3.h
@@ -0,0 +1,61 @@
1/*
2 * linux/include/linux/sunrpc/gss_spkm3.h
3 *
4 * Copyright (c) 2000 The Regents of the University of Michigan.
5 * All rights reserved.
6 *
7 * Andy Adamson <andros@umich.edu>
8 */
9
10#include <linux/sunrpc/auth_gss.h>
11#include <linux/sunrpc/gss_err.h>
12#include <linux/sunrpc/gss_asn1.h>
13
14struct spkm3_ctx {
15 struct xdr_netobj ctx_id; /* per message context id */
16 int qop; /* negotiated qop */
17 struct xdr_netobj mech_used;
18 unsigned int ret_flags ;
19 unsigned int req_flags ;
20 struct xdr_netobj share_key;
21 int conf_alg;
22 struct crypto_tfm* derived_conf_key;
23 int intg_alg;
24 struct crypto_tfm* derived_integ_key;
25 int keyestb_alg; /* alg used to get share_key */
26 int owf_alg; /* one way function */
27};
28
29/* from openssl/objects.h */
30/* XXX need SEAL_ALG_NONE */
31#define NID_md5 4
32#define NID_dhKeyAgreement 28
33#define NID_des_cbc 31
34#define NID_sha1 64
35#define NID_cast5_cbc 108
36
37/* SPKM InnerContext Token types */
38
39#define SPKM_ERROR_TOK 3
40#define SPKM_MIC_TOK 4
41#define SPKM_WRAP_TOK 5
42#define SPKM_DEL_TOK 6
43
44u32 spkm3_make_token(struct spkm3_ctx *ctx, int qop_req, struct xdr_buf * text, struct xdr_netobj * token, int toktype);
45
46u32 spkm3_read_token(struct spkm3_ctx *ctx, struct xdr_netobj *read_token, struct xdr_buf *message_buffer, int *qop_state, int toktype);
47
48#define CKSUMTYPE_RSA_MD5 0x0007
49
50s32 make_checksum(s32 cksumtype, char *header, int hdrlen, struct xdr_buf *body,
51 struct xdr_netobj *cksum);
52void asn1_bitstring_len(struct xdr_netobj *in, int *enclen, int *zerobits);
53int decode_asn1_bitstring(struct xdr_netobj *out, char *in, int enclen,
54 int explen);
55void spkm3_mic_header(unsigned char **hdrbuf, unsigned int *hdrlen,
56 unsigned char *ctxhdr, int elen, int zbit);
57void spkm3_make_mic_token(unsigned char **tokp, int toklen,
58 struct xdr_netobj *mic_hdr,
59 struct xdr_netobj *md5cksum, int md5elen, int md5zbit);
60u32 spkm3_verify_mic_token(unsigned char **tokp, int *mic_hdrlen,
61 unsigned char **cksum);
diff --git a/include/linux/sunrpc/msg_prot.h b/include/linux/sunrpc/msg_prot.h
new file mode 100644
index 000000000000..15f115332389
--- /dev/null
+++ b/include/linux/sunrpc/msg_prot.h
@@ -0,0 +1,80 @@
1/*
2 * linux/include/net/sunrpc/msg_prot.h
3 *
4 * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
5 */
6
7#ifndef _LINUX_SUNRPC_MSGPROT_H_
8#define _LINUX_SUNRPC_MSGPROT_H_
9
10#ifdef __KERNEL__ /* user programs should get these from the rpc header files */
11
12#define RPC_VERSION 2
13
14/* spec defines authentication flavor as an unsigned 32 bit integer */
15typedef u32 rpc_authflavor_t;
16
17enum rpc_auth_flavors {
18 RPC_AUTH_NULL = 0,
19 RPC_AUTH_UNIX = 1,
20 RPC_AUTH_SHORT = 2,
21 RPC_AUTH_DES = 3,
22 RPC_AUTH_KRB = 4,
23 RPC_AUTH_GSS = 6,
24 RPC_AUTH_MAXFLAVOR = 8,
25 /* pseudoflavors: */
26 RPC_AUTH_GSS_KRB5 = 390003,
27 RPC_AUTH_GSS_KRB5I = 390004,
28 RPC_AUTH_GSS_KRB5P = 390005,
29 RPC_AUTH_GSS_LKEY = 390006,
30 RPC_AUTH_GSS_LKEYI = 390007,
31 RPC_AUTH_GSS_LKEYP = 390008,
32 RPC_AUTH_GSS_SPKM = 390009,
33 RPC_AUTH_GSS_SPKMI = 390010,
34 RPC_AUTH_GSS_SPKMP = 390011,
35};
36
37enum rpc_msg_type {
38 RPC_CALL = 0,
39 RPC_REPLY = 1
40};
41
42enum rpc_reply_stat {
43 RPC_MSG_ACCEPTED = 0,
44 RPC_MSG_DENIED = 1
45};
46
47enum rpc_accept_stat {
48 RPC_SUCCESS = 0,
49 RPC_PROG_UNAVAIL = 1,
50 RPC_PROG_MISMATCH = 2,
51 RPC_PROC_UNAVAIL = 3,
52 RPC_GARBAGE_ARGS = 4,
53 RPC_SYSTEM_ERR = 5
54};
55
56enum rpc_reject_stat {
57 RPC_MISMATCH = 0,
58 RPC_AUTH_ERROR = 1
59};
60
61enum rpc_auth_stat {
62 RPC_AUTH_OK = 0,
63 RPC_AUTH_BADCRED = 1,
64 RPC_AUTH_REJECTEDCRED = 2,
65 RPC_AUTH_BADVERF = 3,
66 RPC_AUTH_REJECTEDVERF = 4,
67 RPC_AUTH_TOOWEAK = 5,
68 /* RPCSEC_GSS errors */
69 RPCSEC_GSS_CREDPROBLEM = 13,
70 RPCSEC_GSS_CTXPROBLEM = 14
71};
72
73#define RPC_PMAP_PROGRAM 100000
74#define RPC_PMAP_VERSION 2
75#define RPC_PMAP_PORT 111
76
77#define RPC_MAXNETNAMELEN 256
78
79#endif /* __KERNEL__ */
80#endif /* _LINUX_SUNRPC_MSGPROT_H_ */
diff --git a/include/linux/sunrpc/rpc_pipe_fs.h b/include/linux/sunrpc/rpc_pipe_fs.h
new file mode 100644
index 000000000000..63929349571f
--- /dev/null
+++ b/include/linux/sunrpc/rpc_pipe_fs.h
@@ -0,0 +1,50 @@
1#ifndef _LINUX_SUNRPC_RPC_PIPE_FS_H
2#define _LINUX_SUNRPC_RPC_PIPE_FS_H
3
4#ifdef __KERNEL__
5
6struct rpc_pipe_msg {
7 struct list_head list;
8 void *data;
9 size_t len;
10 size_t copied;
11 int errno;
12};
13
14struct rpc_pipe_ops {
15 ssize_t (*upcall)(struct file *, struct rpc_pipe_msg *, char __user *, size_t);
16 ssize_t (*downcall)(struct file *, const char __user *, size_t);
17 void (*release_pipe)(struct inode *);
18 void (*destroy_msg)(struct rpc_pipe_msg *);
19};
20
21struct rpc_inode {
22 struct inode vfs_inode;
23 void *private;
24 struct list_head pipe;
25 struct list_head in_upcall;
26 int pipelen;
27 int nreaders;
28 int nwriters;
29 wait_queue_head_t waitq;
30#define RPC_PIPE_WAIT_FOR_OPEN 1
31 int flags;
32 struct rpc_pipe_ops *ops;
33 struct work_struct queue_timeout;
34};
35
36static inline struct rpc_inode *
37RPC_I(struct inode *inode)
38{
39 return container_of(inode, struct rpc_inode, vfs_inode);
40}
41
42extern int rpc_queue_upcall(struct inode *, struct rpc_pipe_msg *);
43
44extern struct dentry *rpc_mkdir(char *, struct rpc_clnt *);
45extern int rpc_rmdir(char *);
46extern struct dentry *rpc_mkpipe(char *, void *, struct rpc_pipe_ops *, int flags);
47extern int rpc_unlink(char *);
48
49#endif
50#endif
diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h
new file mode 100644
index 000000000000..99d17ed7cebb
--- /dev/null
+++ b/include/linux/sunrpc/sched.h
@@ -0,0 +1,273 @@
1/*
2 * linux/include/linux/sunrpc/sched.h
3 *
4 * Scheduling primitives for kernel Sun RPC.
5 *
6 * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
7 */
8
9#ifndef _LINUX_SUNRPC_SCHED_H_
10#define _LINUX_SUNRPC_SCHED_H_
11
12#include <linux/timer.h>
13#include <linux/sunrpc/types.h>
14#include <linux/spinlock.h>
15#include <linux/wait.h>
16#include <linux/workqueue.h>
17#include <linux/sunrpc/xdr.h>
18
19/*
20 * This is the actual RPC procedure call info.
21 */
22struct rpc_procinfo;
23struct rpc_message {
24 struct rpc_procinfo * rpc_proc; /* Procedure information */
25 void * rpc_argp; /* Arguments */
26 void * rpc_resp; /* Result */
27 struct rpc_cred * rpc_cred; /* Credentials */
28};
29
30struct rpc_wait_queue;
31struct rpc_wait {
32 struct list_head list; /* wait queue links */
33 struct list_head links; /* Links to related tasks */
34 wait_queue_head_t waitq; /* sync: sleep on this q */
35 struct rpc_wait_queue * rpc_waitq; /* RPC wait queue we're on */
36};
37
38/*
39 * This is the RPC task struct
40 */
41struct rpc_task {
42#ifdef RPC_DEBUG
43 unsigned long tk_magic; /* 0xf00baa */
44#endif
45 struct list_head tk_task; /* global list of tasks */
46 struct rpc_clnt * tk_client; /* RPC client */
47 struct rpc_rqst * tk_rqstp; /* RPC request */
48 int tk_status; /* result of last operation */
49
50 /*
51 * RPC call state
52 */
53 struct rpc_message tk_msg; /* RPC call info */
54 __u32 * tk_buffer; /* XDR buffer */
55 size_t tk_bufsize;
56 __u8 tk_garb_retry;
57 __u8 tk_cred_retry;
58
59 unsigned long tk_cookie; /* Cookie for batching tasks */
60
61 /*
62 * timeout_fn to be executed by timer bottom half
63 * callback to be executed after waking up
64 * action next procedure for async tasks
65 * exit exit async task and report to caller
66 */
67 void (*tk_timeout_fn)(struct rpc_task *);
68 void (*tk_callback)(struct rpc_task *);
69 void (*tk_action)(struct rpc_task *);
70 void (*tk_exit)(struct rpc_task *);
71 void (*tk_release)(struct rpc_task *);
72 void * tk_calldata;
73
74 /*
75 * tk_timer is used for async processing by the RPC scheduling
76 * primitives. You should not access this directly unless
77 * you have a pathological interest in kernel oopses.
78 */
79 struct timer_list tk_timer; /* kernel timer */
80 unsigned long tk_timeout; /* timeout for rpc_sleep() */
81 unsigned short tk_flags; /* misc flags */
82 unsigned char tk_active : 1;/* Task has been activated */
83 unsigned char tk_priority : 2;/* Task priority */
84 unsigned long tk_runstate; /* Task run status */
85 struct workqueue_struct *tk_workqueue; /* Normally rpciod, but could
86 * be any workqueue
87 */
88 union {
89 struct work_struct tk_work; /* Async task work queue */
90 struct rpc_wait tk_wait; /* RPC wait */
91 } u;
92#ifdef RPC_DEBUG
93 unsigned short tk_pid; /* debugging aid */
94#endif
95};
96#define tk_auth tk_client->cl_auth
97#define tk_xprt tk_client->cl_xprt
98
99/* support walking a list of tasks on a wait queue */
100#define task_for_each(task, pos, head) \
101 list_for_each(pos, head) \
102 if ((task=list_entry(pos, struct rpc_task, u.tk_wait.list)),1)
103
104#define task_for_first(task, head) \
105 if (!list_empty(head) && \
106 ((task=list_entry((head)->next, struct rpc_task, u.tk_wait.list)),1))
107
108/* .. and walking list of all tasks */
109#define alltask_for_each(task, pos, head) \
110 list_for_each(pos, head) \
111 if ((task=list_entry(pos, struct rpc_task, tk_task)),1)
112
113typedef void (*rpc_action)(struct rpc_task *);
114
115/*
116 * RPC task flags
117 */
118#define RPC_TASK_ASYNC 0x0001 /* is an async task */
119#define RPC_TASK_SWAPPER 0x0002 /* is swapping in/out */
120#define RPC_TASK_CHILD 0x0008 /* is child of other task */
121#define RPC_CALL_MAJORSEEN 0x0020 /* major timeout seen */
122#define RPC_TASK_ROOTCREDS 0x0040 /* force root creds */
123#define RPC_TASK_DYNAMIC 0x0080 /* task was kmalloc'ed */
124#define RPC_TASK_KILLED 0x0100 /* task was killed */
125#define RPC_TASK_SOFT 0x0200 /* Use soft timeouts */
126#define RPC_TASK_NOINTR 0x0400 /* uninterruptible task */
127
128#define RPC_IS_ASYNC(t) ((t)->tk_flags & RPC_TASK_ASYNC)
129#define RPC_IS_CHILD(t) ((t)->tk_flags & RPC_TASK_CHILD)
130#define RPC_IS_SWAPPER(t) ((t)->tk_flags & RPC_TASK_SWAPPER)
131#define RPC_DO_ROOTOVERRIDE(t) ((t)->tk_flags & RPC_TASK_ROOTCREDS)
132#define RPC_ASSASSINATED(t) ((t)->tk_flags & RPC_TASK_KILLED)
133#define RPC_IS_ACTIVATED(t) ((t)->tk_active)
134#define RPC_DO_CALLBACK(t) ((t)->tk_callback != NULL)
135#define RPC_IS_SOFT(t) ((t)->tk_flags & RPC_TASK_SOFT)
136#define RPC_TASK_UNINTERRUPTIBLE(t) ((t)->tk_flags & RPC_TASK_NOINTR)
137
138#define RPC_TASK_RUNNING 0
139#define RPC_TASK_QUEUED 1
140#define RPC_TASK_WAKEUP 2
141#define RPC_TASK_HAS_TIMER 3
142
143#define RPC_IS_RUNNING(t) (test_bit(RPC_TASK_RUNNING, &(t)->tk_runstate))
144#define rpc_set_running(t) (set_bit(RPC_TASK_RUNNING, &(t)->tk_runstate))
145#define rpc_test_and_set_running(t) \
146 (test_and_set_bit(RPC_TASK_RUNNING, &(t)->tk_runstate))
147#define rpc_clear_running(t) \
148 do { \
149 smp_mb__before_clear_bit(); \
150 clear_bit(RPC_TASK_RUNNING, &(t)->tk_runstate); \
151 smp_mb__after_clear_bit(); \
152 } while (0)
153
154#define RPC_IS_QUEUED(t) (test_bit(RPC_TASK_QUEUED, &(t)->tk_runstate))
155#define rpc_set_queued(t) (set_bit(RPC_TASK_QUEUED, &(t)->tk_runstate))
156#define rpc_clear_queued(t) \
157 do { \
158 smp_mb__before_clear_bit(); \
159 clear_bit(RPC_TASK_QUEUED, &(t)->tk_runstate); \
160 smp_mb__after_clear_bit(); \
161 } while (0)
162
163#define rpc_start_wakeup(t) \
164 (test_and_set_bit(RPC_TASK_WAKEUP, &(t)->tk_runstate) == 0)
165#define rpc_finish_wakeup(t) \
166 do { \
167 smp_mb__before_clear_bit(); \
168 clear_bit(RPC_TASK_WAKEUP, &(t)->tk_runstate); \
169 smp_mb__after_clear_bit(); \
170 } while (0)
171
172/*
173 * Task priorities.
174 * Note: if you change these, you must also change
175 * the task initialization definitions below.
176 */
177#define RPC_PRIORITY_LOW 0
178#define RPC_PRIORITY_NORMAL 1
179#define RPC_PRIORITY_HIGH 2
180#define RPC_NR_PRIORITY (RPC_PRIORITY_HIGH+1)
181
182/*
183 * RPC synchronization objects
184 */
185struct rpc_wait_queue {
186 spinlock_t lock;
187 struct list_head tasks[RPC_NR_PRIORITY]; /* task queue for each priority level */
188 unsigned long cookie; /* cookie of last task serviced */
189 unsigned char maxpriority; /* maximum priority (0 if queue is not a priority queue) */
190 unsigned char priority; /* current priority */
191 unsigned char count; /* # task groups remaining serviced so far */
192 unsigned char nr; /* # tasks remaining for cookie */
193#ifdef RPC_DEBUG
194 const char * name;
195#endif
196};
197
198/*
199 * This is the # requests to send consecutively
200 * from a single cookie. The aim is to improve
201 * performance of NFS operations such as read/write.
202 */
203#define RPC_BATCH_COUNT 16
204
205#ifndef RPC_DEBUG
206# define RPC_WAITQ_INIT(var,qname) { \
207 .lock = SPIN_LOCK_UNLOCKED, \
208 .tasks = { \
209 [0] = LIST_HEAD_INIT(var.tasks[0]), \
210 [1] = LIST_HEAD_INIT(var.tasks[1]), \
211 [2] = LIST_HEAD_INIT(var.tasks[2]), \
212 }, \
213 }
214#else
215# define RPC_WAITQ_INIT(var,qname) { \
216 .lock = SPIN_LOCK_UNLOCKED, \
217 .tasks = { \
218 [0] = LIST_HEAD_INIT(var.tasks[0]), \
219 [1] = LIST_HEAD_INIT(var.tasks[1]), \
220 [2] = LIST_HEAD_INIT(var.tasks[2]), \
221 }, \
222 .name = qname, \
223 }
224#endif
225# define RPC_WAITQ(var,qname) struct rpc_wait_queue var = RPC_WAITQ_INIT(var,qname)
226
227#define RPC_IS_PRIORITY(q) ((q)->maxpriority > 0)
228
229/*
230 * Function prototypes
231 */
232struct rpc_task *rpc_new_task(struct rpc_clnt *, rpc_action, int flags);
233struct rpc_task *rpc_new_child(struct rpc_clnt *, struct rpc_task *parent);
234void rpc_init_task(struct rpc_task *, struct rpc_clnt *,
235 rpc_action exitfunc, int flags);
236void rpc_release_task(struct rpc_task *);
237void rpc_killall_tasks(struct rpc_clnt *);
238int rpc_execute(struct rpc_task *);
239void rpc_run_child(struct rpc_task *parent, struct rpc_task *child,
240 rpc_action action);
241void rpc_init_priority_wait_queue(struct rpc_wait_queue *, const char *);
242void rpc_init_wait_queue(struct rpc_wait_queue *, const char *);
243void rpc_sleep_on(struct rpc_wait_queue *, struct rpc_task *,
244 rpc_action action, rpc_action timer);
245void rpc_wake_up_task(struct rpc_task *);
246void rpc_wake_up(struct rpc_wait_queue *);
247struct rpc_task *rpc_wake_up_next(struct rpc_wait_queue *);
248void rpc_wake_up_status(struct rpc_wait_queue *, int);
249void rpc_delay(struct rpc_task *, unsigned long);
250void * rpc_malloc(struct rpc_task *, size_t);
251int rpciod_up(void);
252void rpciod_down(void);
253void rpciod_wake_up(void);
254#ifdef RPC_DEBUG
255void rpc_show_tasks(void);
256#endif
257int rpc_init_mempool(void);
258void rpc_destroy_mempool(void);
259
260static inline void rpc_exit(struct rpc_task *task, int status)
261{
262 task->tk_status = status;
263 task->tk_action = NULL;
264}
265
266#ifdef RPC_DEBUG
267static inline const char * rpc_qname(struct rpc_wait_queue *q)
268{
269 return ((q && q->name) ? q->name : "unknown");
270}
271#endif
272
273#endif /* _LINUX_SUNRPC_SCHED_H_ */
diff --git a/include/linux/sunrpc/stats.h b/include/linux/sunrpc/stats.h
new file mode 100644
index 000000000000..0d6ed3c8bdc4
--- /dev/null
+++ b/include/linux/sunrpc/stats.h
@@ -0,0 +1,78 @@
1/*
2 * linux/include/linux/sunrpc/stats.h
3 *
4 * Client statistics collection for SUN RPC
5 *
6 * Copyright (C) 1996 Olaf Kirch <okir@monad.swb.de>
7 */
8
9#ifndef _LINUX_SUNRPC_STATS_H
10#define _LINUX_SUNRPC_STATS_H
11
12#include <linux/config.h>
13#include <linux/proc_fs.h>
14
15struct rpc_stat {
16 struct rpc_program * program;
17
18 unsigned int netcnt,
19 netudpcnt,
20 nettcpcnt,
21 nettcpconn,
22 netreconn;
23 unsigned int rpccnt,
24 rpcretrans,
25 rpcauthrefresh,
26 rpcgarbage;
27};
28
29struct svc_stat {
30 struct svc_program * program;
31
32 unsigned int netcnt,
33 netudpcnt,
34 nettcpcnt,
35 nettcpconn;
36 unsigned int rpccnt,
37 rpcbadfmt,
38 rpcbadauth,
39 rpcbadclnt;
40};
41
42void rpc_proc_init(void);
43void rpc_proc_exit(void);
44#ifdef MODULE
45void rpc_modcount(struct inode *, int);
46#endif
47
48#ifdef CONFIG_PROC_FS
49struct proc_dir_entry * rpc_proc_register(struct rpc_stat *);
50void rpc_proc_unregister(const char *);
51void rpc_proc_zero(struct rpc_program *);
52struct proc_dir_entry * svc_proc_register(struct svc_stat *,
53 struct file_operations *);
54void svc_proc_unregister(const char *);
55
56void svc_seq_show(struct seq_file *,
57 const struct svc_stat *);
58
59extern struct proc_dir_entry *proc_net_rpc;
60
61#else
62
63static inline struct proc_dir_entry *rpc_proc_register(struct rpc_stat *s) { return NULL; }
64static inline void rpc_proc_unregister(const char *p) {}
65static inline void rpc_proc_zero(struct rpc_program *p) {}
66
67static inline struct proc_dir_entry *svc_proc_register(struct svc_stat *s,
68 struct file_operations *f) { return NULL; }
69static inline void svc_proc_unregister(const char *p) {}
70
71static inline void svc_seq_show(struct seq_file *seq,
72 const struct svc_stat *st) {}
73
74#define proc_net_rpc NULL
75
76#endif
77
78#endif /* _LINUX_SUNRPC_STATS_H */
diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
new file mode 100644
index 000000000000..37003970cf2e
--- /dev/null
+++ b/include/linux/sunrpc/svc.h
@@ -0,0 +1,306 @@
1/*
2 * linux/include/linux/sunrpc/svc.h
3 *
4 * RPC server declarations.
5 *
6 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
7 */
8
9
10#ifndef SUNRPC_SVC_H
11#define SUNRPC_SVC_H
12
13#include <linux/in.h>
14#include <linux/sunrpc/types.h>
15#include <linux/sunrpc/xdr.h>
16#include <linux/sunrpc/svcauth.h>
17#include <linux/wait.h>
18#include <linux/mm.h>
19
20/*
21 * RPC service.
22 *
23 * An RPC service is a ``daemon,'' possibly multithreaded, which
24 * receives and processes incoming RPC messages.
25 * It has one or more transport sockets associated with it, and maintains
26 * a list of idle threads waiting for input.
27 *
28 * We currently do not support more than one RPC program per daemon.
29 */
30struct svc_serv {
31 struct list_head sv_threads; /* idle server threads */
32 struct list_head sv_sockets; /* pending sockets */
33 struct svc_program * sv_program; /* RPC program */
34 struct svc_stat * sv_stats; /* RPC statistics */
35 spinlock_t sv_lock;
36 unsigned int sv_nrthreads; /* # of server threads */
37 unsigned int sv_bufsz; /* datagram buffer size */
38 unsigned int sv_xdrsize; /* XDR buffer size */
39
40 struct list_head sv_permsocks; /* all permanent sockets */
41 struct list_head sv_tempsocks; /* all temporary sockets */
42 int sv_tmpcnt; /* count of temporary sockets */
43
44 char * sv_name; /* service name */
45};
46
47/*
48 * Maximum payload size supported by a kernel RPC server.
49 * This is use to determine the max number of pages nfsd is
50 * willing to return in a single READ operation.
51 */
52#define RPCSVC_MAXPAYLOAD (64*1024u)
53
54/*
55 * RPC Requsts and replies are stored in one or more pages.
56 * We maintain an array of pages for each server thread.
57 * Requests are copied into these pages as they arrive. Remaining
58 * pages are available to write the reply into.
59 *
60 * Pages are sent using ->sendpage so each server thread needs to
61 * allocate more to replace those used in sending. To help keep track
62 * of these pages we have a receive list where all pages initialy live,
63 * and a send list where pages are moved to when there are to be part
64 * of a reply.
65 *
66 * We use xdr_buf for holding responses as it fits well with NFS
67 * read responses (that have a header, and some data pages, and possibly
68 * a tail) and means we can share some client side routines.
69 *
70 * The xdr_buf.head kvec always points to the first page in the rq_*pages
71 * list. The xdr_buf.pages pointer points to the second page on that
72 * list. xdr_buf.tail points to the end of the first page.
73 * This assumes that the non-page part of an rpc reply will fit
74 * in a page - NFSd ensures this. lockd also has no trouble.
75 *
76 * Each request/reply pair can have at most one "payload", plus two pages,
77 * one for the request, and one for the reply.
78 */
79#define RPCSVC_MAXPAGES ((RPCSVC_MAXPAYLOAD+PAGE_SIZE-1)/PAGE_SIZE + 2)
80
81static inline u32 svc_getu32(struct kvec *iov)
82{
83 u32 val, *vp;
84 vp = iov->iov_base;
85 val = *vp++;
86 iov->iov_base = (void*)vp;
87 iov->iov_len -= sizeof(u32);
88 return val;
89}
90
91static inline void svc_ungetu32(struct kvec *iov)
92{
93 u32 *vp = (u32 *)iov->iov_base;
94 iov->iov_base = (void *)(vp - 1);
95 iov->iov_len += sizeof(*vp);
96}
97
98static inline void svc_putu32(struct kvec *iov, u32 val)
99{
100 u32 *vp = iov->iov_base + iov->iov_len;
101 *vp = val;
102 iov->iov_len += sizeof(u32);
103}
104
105
106/*
107 * The context of a single thread, including the request currently being
108 * processed.
109 * NOTE: First two items must be prev/next.
110 */
111struct svc_rqst {
112 struct list_head rq_list; /* idle list */
113 struct svc_sock * rq_sock; /* socket */
114 struct sockaddr_in rq_addr; /* peer address */
115 int rq_addrlen;
116
117 struct svc_serv * rq_server; /* RPC service definition */
118 struct svc_procedure * rq_procinfo; /* procedure info */
119 struct auth_ops * rq_authop; /* authentication flavour */
120 struct svc_cred rq_cred; /* auth info */
121 struct sk_buff * rq_skbuff; /* fast recv inet buffer */
122 struct svc_deferred_req*rq_deferred; /* deferred request we are replaying */
123
124 struct xdr_buf rq_arg;
125 struct xdr_buf rq_res;
126 struct page * rq_argpages[RPCSVC_MAXPAGES];
127 struct page * rq_respages[RPCSVC_MAXPAGES];
128 int rq_restailpage;
129 short rq_argused; /* pages used for argument */
130 short rq_arghi; /* pages available in argument page list */
131 short rq_resused; /* pages used for result */
132
133 u32 rq_xid; /* transmission id */
134 u32 rq_prog; /* program number */
135 u32 rq_vers; /* program version */
136 u32 rq_proc; /* procedure number */
137 u32 rq_prot; /* IP protocol */
138 unsigned short
139 rq_secure : 1; /* secure port */
140
141
142 __u32 rq_daddr; /* dest addr of request - reply from here */
143
144 void * rq_argp; /* decoded arguments */
145 void * rq_resp; /* xdr'd results */
146 void * rq_auth_data; /* flavor-specific data */
147
148 int rq_reserved; /* space on socket outq
149 * reserved for this request
150 */
151
152 struct cache_req rq_chandle; /* handle passed to caches for
153 * request delaying
154 */
155 /* Catering to nfsd */
156 struct auth_domain * rq_client; /* RPC peer info */
157 struct svc_cacherep * rq_cacherep; /* cache info */
158 struct knfsd_fh * rq_reffh; /* Referrence filehandle, used to
159 * determine what device number
160 * to report (real or virtual)
161 */
162
163 wait_queue_head_t rq_wait; /* synchronization */
164};
165
166/*
167 * Check buffer bounds after decoding arguments
168 */
169static inline int
170xdr_argsize_check(struct svc_rqst *rqstp, u32 *p)
171{
172 char *cp = (char *)p;
173 struct kvec *vec = &rqstp->rq_arg.head[0];
174 return cp - (char*)vec->iov_base <= vec->iov_len;
175}
176
177static inline int
178xdr_ressize_check(struct svc_rqst *rqstp, u32 *p)
179{
180 struct kvec *vec = &rqstp->rq_res.head[0];
181 char *cp = (char*)p;
182
183 vec->iov_len = cp - (char*)vec->iov_base;
184
185 return vec->iov_len <= PAGE_SIZE;
186}
187
188static inline int svc_take_page(struct svc_rqst *rqstp)
189{
190 if (rqstp->rq_arghi <= rqstp->rq_argused)
191 return -ENOMEM;
192 rqstp->rq_arghi--;
193 rqstp->rq_respages[rqstp->rq_resused] =
194 rqstp->rq_argpages[rqstp->rq_arghi];
195 rqstp->rq_resused++;
196 return 0;
197}
198
199static inline void svc_pushback_allpages(struct svc_rqst *rqstp)
200{
201 while (rqstp->rq_resused) {
202 if (rqstp->rq_respages[--rqstp->rq_resused] == NULL)
203 continue;
204 rqstp->rq_argpages[rqstp->rq_arghi++] =
205 rqstp->rq_respages[rqstp->rq_resused];
206 rqstp->rq_respages[rqstp->rq_resused] = NULL;
207 }
208}
209
210static inline void svc_pushback_unused_pages(struct svc_rqst *rqstp)
211{
212 while (rqstp->rq_resused &&
213 rqstp->rq_res.pages != &rqstp->rq_respages[rqstp->rq_resused]) {
214
215 if (rqstp->rq_respages[--rqstp->rq_resused] != NULL) {
216 rqstp->rq_argpages[rqstp->rq_arghi++] =
217 rqstp->rq_respages[rqstp->rq_resused];
218 rqstp->rq_respages[rqstp->rq_resused] = NULL;
219 }
220 }
221}
222
223static inline void svc_free_allpages(struct svc_rqst *rqstp)
224{
225 while (rqstp->rq_resused) {
226 if (rqstp->rq_respages[--rqstp->rq_resused] == NULL)
227 continue;
228 put_page(rqstp->rq_respages[rqstp->rq_resused]);
229 rqstp->rq_respages[rqstp->rq_resused] = NULL;
230 }
231}
232
233struct svc_deferred_req {
234 u32 prot; /* protocol (UDP or TCP) */
235 struct sockaddr_in addr;
236 struct svc_sock *svsk; /* where reply must go */
237 struct cache_deferred_req handle;
238 int argslen;
239 u32 args[0];
240};
241
242/*
243 * RPC program
244 */
245struct svc_program {
246 u32 pg_prog; /* program number */
247 unsigned int pg_lovers; /* lowest version */
248 unsigned int pg_hivers; /* lowest version */
249 unsigned int pg_nvers; /* number of versions */
250 struct svc_version ** pg_vers; /* version array */
251 char * pg_name; /* service name */
252 char * pg_class; /* class name: services sharing authentication */
253 struct svc_stat * pg_stats; /* rpc statistics */
254 int (*pg_authenticate)(struct svc_rqst *);
255};
256
257/*
258 * RPC program version
259 */
260struct svc_version {
261 u32 vs_vers; /* version number */
262 u32 vs_nproc; /* number of procedures */
263 struct svc_procedure * vs_proc; /* per-procedure info */
264 u32 vs_xdrsize; /* xdrsize needed for this version */
265
266 /* Override dispatch function (e.g. when caching replies).
267 * A return value of 0 means drop the request.
268 * vs_dispatch == NULL means use default dispatcher.
269 */
270 int (*vs_dispatch)(struct svc_rqst *, u32 *);
271};
272
273/*
274 * RPC procedure info
275 */
276typedef int (*svc_procfunc)(struct svc_rqst *, void *argp, void *resp);
277struct svc_procedure {
278 svc_procfunc pc_func; /* process the request */
279 kxdrproc_t pc_decode; /* XDR decode args */
280 kxdrproc_t pc_encode; /* XDR encode result */
281 kxdrproc_t pc_release; /* XDR free result */
282 unsigned int pc_argsize; /* argument struct size */
283 unsigned int pc_ressize; /* result struct size */
284 unsigned int pc_count; /* call count */
285 unsigned int pc_cachetype; /* cache info (NFS) */
286 unsigned int pc_xdrressize; /* maximum size of XDR reply */
287};
288
289/*
290 * This is the RPC server thread function prototype
291 */
292typedef void (*svc_thread_fn)(struct svc_rqst *);
293
294/*
295 * Function prototypes.
296 */
297struct svc_serv * svc_create(struct svc_program *, unsigned int);
298int svc_create_thread(svc_thread_fn, struct svc_serv *);
299void svc_exit_thread(struct svc_rqst *);
300void svc_destroy(struct svc_serv *);
301int svc_process(struct svc_serv *, struct svc_rqst *);
302int svc_register(struct svc_serv *, int, unsigned short);
303void svc_wake_up(struct svc_serv *);
304void svc_reserve(struct svc_rqst *rqstp, int space);
305
306#endif /* SUNRPC_SVC_H */
diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
new file mode 100644
index 000000000000..c119ce7cbd22
--- /dev/null
+++ b/include/linux/sunrpc/svcauth.h
@@ -0,0 +1,167 @@
1/*
2 * linux/include/linux/sunrpc/svcauth.h
3 *
4 * RPC server-side authentication stuff.
5 *
6 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
7 */
8
9#ifndef _LINUX_SUNRPC_SVCAUTH_H_
10#define _LINUX_SUNRPC_SVCAUTH_H_
11
12#ifdef __KERNEL__
13
14#include <linux/string.h>
15#include <linux/sunrpc/msg_prot.h>
16#include <linux/sunrpc/cache.h>
17#include <linux/hash.h>
18
19#define SVC_CRED_NGROUPS 32
20struct svc_cred {
21 uid_t cr_uid;
22 gid_t cr_gid;
23 struct group_info *cr_group_info;
24};
25
26struct svc_rqst; /* forward decl */
27
28/* Authentication is done in the context of a domain.
29 *
30 * Currently, the nfs server uses the auth_domain to stand
31 * for the "client" listed in /etc/exports.
32 *
33 * More generally, a domain might represent a group of clients using
34 * a common mechanism for authentication and having a common mapping
35 * between local identity (uid) and network identity. All clients
36 * in a domain have similar general access rights. Each domain can
37 * contain multiple principals which will have different specific right
38 * based on normal Discretionary Access Control.
39 *
40 * A domain is created by an authentication flavour module based on name
41 * only. Userspace then fills in detail on demand.
42 *
43 * In the case of auth_unix and auth_null, the auth_domain is also
44 * associated with entries in another cache representing the mapping
45 * of ip addresses to the given client.
46 */
47struct auth_domain {
48 struct cache_head h;
49 char *name;
50 int flavour;
51};
52
53/*
54 * Each authentication flavour registers an auth_ops
55 * structure.
56 * name is simply the name.
57 * flavour gives the auth flavour. It determines where the flavour is registered
58 * accept() is given a request and should verify it.
59 * It should inspect the authenticator and verifier, and possibly the data.
60 * If there is a problem with the authentication *authp should be set.
61 * The return value of accept() can indicate:
62 * OK - authorised. client and credential are set in rqstp.
63 * reqbuf points to arguments
64 * resbuf points to good place for results. verfier
65 * is (probably) already in place. Certainly space is
66 * reserved for it.
67 * DROP - simply drop the request. It may have been deferred
68 * GARBAGE - rpc garbage_args error
69 * SYSERR - rpc system_err error
70 * DENIED - authp holds reason for denial.
71 * COMPLETE - the reply is encoded already and ready to be sent; no
72 * further processing is necessary. (This is used for processing
73 * null procedure calls which are used to set up encryption
74 * contexts.)
75 *
76 * accept is passed the proc number so that it can accept NULL rpc requests
77 * even if it cannot authenticate the client (as is sometimes appropriate).
78 *
79 * release() is given a request after the procedure has been run.
80 * It should sign/encrypt the results if needed
81 * It should return:
82 * OK - the resbuf is ready to be sent
83 * DROP - the reply should be quitely dropped
84 * DENIED - authp holds a reason for MSG_DENIED
85 * SYSERR - rpc system_err
86 *
87 * domain_release()
88 * This call releases a domain.
89 */
90struct auth_ops {
91 char * name;
92 struct module *owner;
93 int flavour;
94 int (*accept)(struct svc_rqst *rq, u32 *authp);
95 int (*release)(struct svc_rqst *rq);
96 void (*domain_release)(struct auth_domain *);
97 int (*set_client)(struct svc_rqst *rq);
98};
99
100#define SVC_GARBAGE 1
101#define SVC_SYSERR 2
102#define SVC_VALID 3
103#define SVC_NEGATIVE 4
104#define SVC_OK 5
105#define SVC_DROP 6
106#define SVC_DENIED 7
107#define SVC_PENDING 8
108#define SVC_COMPLETE 9
109
110
111extern int svc_authenticate(struct svc_rqst *rqstp, u32 *authp);
112extern int svc_authorise(struct svc_rqst *rqstp);
113extern int svc_set_client(struct svc_rqst *rqstp);
114extern int svc_auth_register(rpc_authflavor_t flavor, struct auth_ops *aops);
115extern void svc_auth_unregister(rpc_authflavor_t flavor);
116
117extern struct auth_domain *unix_domain_find(char *name);
118extern void auth_domain_put(struct auth_domain *item);
119extern int auth_unix_add_addr(struct in_addr addr, struct auth_domain *dom);
120extern struct auth_domain *auth_domain_lookup(struct auth_domain *item, int set);
121extern struct auth_domain *auth_domain_find(char *name);
122extern struct auth_domain *auth_unix_lookup(struct in_addr addr);
123extern int auth_unix_forget_old(struct auth_domain *dom);
124extern void svcauth_unix_purge(void);
125
126static inline unsigned long hash_str(char *name, int bits)
127{
128 unsigned long hash = 0;
129 unsigned long l = 0;
130 int len = 0;
131 unsigned char c;
132 do {
133 if (unlikely(!(c = *name++))) {
134 c = (char)len; len = -1;
135 }
136 l = (l << 8) | c;
137 len++;
138 if ((len & (BITS_PER_LONG/8-1))==0)
139 hash = hash_long(hash^l, BITS_PER_LONG);
140 } while (len);
141 return hash >> (BITS_PER_LONG - bits);
142}
143
144static inline unsigned long hash_mem(char *buf, int length, int bits)
145{
146 unsigned long hash = 0;
147 unsigned long l = 0;
148 int len = 0;
149 unsigned char c;
150 do {
151 if (len == length) {
152 c = (char)len; len = -1;
153 } else
154 c = *buf++;
155 l = (l << 8) | c;
156 len++;
157 if ((len & (BITS_PER_LONG/8-1))==0)
158 hash = hash_long(hash^l, BITS_PER_LONG);
159 } while (len);
160 return hash >> (BITS_PER_LONG - bits);
161}
162
163extern struct cache_detail auth_domain_cache, ip_map_cache;
164
165#endif /* __KERNEL__ */
166
167#endif /* _LINUX_SUNRPC_SVCAUTH_H_ */
diff --git a/include/linux/sunrpc/svcauth_gss.h b/include/linux/sunrpc/svcauth_gss.h
new file mode 100644
index 000000000000..3a2206f61de0
--- /dev/null
+++ b/include/linux/sunrpc/svcauth_gss.h
@@ -0,0 +1,27 @@
1/*
2 * linux/include/linux/svcauth_gss.h
3 *
4 * Bruce Fields <bfields@umich.edu>
5 * Copyright (c) 2002 The Regents of the Unviersity of Michigan
6 *
7 * $Id$
8 *
9 */
10
11#ifndef _LINUX_SUNRPC_SVCAUTH_GSS_H
12#define _LINUX_SUNRPC_SVCAUTH_GSS_H
13
14#ifdef __KERNEL__
15#include <linux/sched.h>
16#include <linux/sunrpc/types.h>
17#include <linux/sunrpc/xdr.h>
18#include <linux/sunrpc/svcauth.h>
19#include <linux/sunrpc/svcsock.h>
20#include <linux/sunrpc/auth_gss.h>
21
22int gss_svc_init(void);
23void gss_svc_shutdown(void);
24int svcauth_gss_register_pseudoflavor(u32 pseudoflavor, char * name);
25
26#endif /* __KERNEL__ */
27#endif /* _LINUX_SUNRPC_SVCAUTH_GSS_H */
diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
new file mode 100644
index 000000000000..d33c6face032
--- /dev/null
+++ b/include/linux/sunrpc/svcsock.h
@@ -0,0 +1,65 @@
1/*
2 * linux/include/linux/sunrpc/svcsock.h
3 *
4 * RPC server socket I/O.
5 *
6 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
7 */
8
9#ifndef SUNRPC_SVCSOCK_H
10#define SUNRPC_SVCSOCK_H
11
12#include <linux/sunrpc/svc.h>
13
14/*
15 * RPC server socket.
16 */
17struct svc_sock {
18 struct list_head sk_ready; /* list of ready sockets */
19 struct list_head sk_list; /* list of all sockets */
20 struct socket * sk_sock; /* berkeley socket layer */
21 struct sock * sk_sk; /* INET layer */
22
23 struct svc_serv * sk_server; /* service for this socket */
24 unsigned int sk_inuse; /* use count */
25 unsigned long sk_flags;
26#define SK_BUSY 0 /* enqueued/receiving */
27#define SK_CONN 1 /* conn pending */
28#define SK_CLOSE 2 /* dead or dying */
29#define SK_DATA 3 /* data pending */
30#define SK_TEMP 4 /* temp (TCP) socket */
31#define SK_DEAD 6 /* socket closed */
32#define SK_CHNGBUF 7 /* need to change snd/rcv buffer sizes */
33#define SK_DEFERRED 8 /* request on sk_deferred */
34
35 int sk_reserved; /* space on outq that is reserved */
36
37 struct list_head sk_deferred; /* deferred requests that need to
38 * be revisted */
39 struct semaphore sk_sem; /* to serialize sending data */
40
41 int (*sk_recvfrom)(struct svc_rqst *rqstp);
42 int (*sk_sendto)(struct svc_rqst *rqstp);
43
44 /* We keep the old state_change and data_ready CB's here */
45 void (*sk_ostate)(struct sock *);
46 void (*sk_odata)(struct sock *, int bytes);
47 void (*sk_owspace)(struct sock *);
48
49 /* private TCP part */
50 int sk_reclen; /* length of record */
51 int sk_tcplen; /* current read length */
52 time_t sk_lastrecv; /* time of last received request */
53};
54
55/*
56 * Function prototypes.
57 */
58int svc_makesock(struct svc_serv *, int, unsigned short);
59void svc_delete_socket(struct svc_sock *);
60int svc_recv(struct svc_serv *, struct svc_rqst *, long);
61int svc_send(struct svc_rqst *);
62void svc_drop(struct svc_rqst *);
63void svc_sock_update_bufs(struct svc_serv *serv);
64
65#endif /* SUNRPC_SVCSOCK_H */
diff --git a/include/linux/sunrpc/timer.h b/include/linux/sunrpc/timer.h
new file mode 100644
index 000000000000..a67fd734c73b
--- /dev/null
+++ b/include/linux/sunrpc/timer.h
@@ -0,0 +1,49 @@
1/*
2 * linux/include/linux/sunrpc/timer.h
3 *
4 * Declarations for the RPC transport timer.
5 *
6 * Copyright (C) 2002 Trond Myklebust <trond.myklebust@fys.uio.no>
7 */
8
9#ifndef _LINUX_SUNRPC_TIMER_H
10#define _LINUX_SUNRPC_TIMER_H
11
12#include <asm/atomic.h>
13
14struct rpc_rtt {
15 unsigned long timeo; /* default timeout value */
16 unsigned long srtt[5]; /* smoothed round trip time << 3 */
17 unsigned long sdrtt[5]; /* smoothed medium deviation of RTT */
18 int ntimeouts[5]; /* Number of timeouts for the last request */
19};
20
21
22extern void rpc_init_rtt(struct rpc_rtt *rt, unsigned long timeo);
23extern void rpc_update_rtt(struct rpc_rtt *rt, unsigned timer, long m);
24extern unsigned long rpc_calc_rto(struct rpc_rtt *rt, unsigned timer);
25
26static inline void rpc_set_timeo(struct rpc_rtt *rt, int timer, int ntimeo)
27{
28 int *t;
29 if (!timer)
30 return;
31 t = &rt->ntimeouts[timer-1];
32 if (ntimeo < *t) {
33 if (*t > 0)
34 (*t)--;
35 } else {
36 if (ntimeo > 8)
37 ntimeo = 8;
38 *t = ntimeo;
39 }
40}
41
42static inline int rpc_ntimeo(struct rpc_rtt *rt, int timer)
43{
44 if (!timer)
45 return 0;
46 return rt->ntimeouts[timer-1];
47}
48
49#endif /* _LINUX_SUNRPC_TIMER_H */
diff --git a/include/linux/sunrpc/types.h b/include/linux/sunrpc/types.h
new file mode 100644
index 000000000000..d222f47550af
--- /dev/null
+++ b/include/linux/sunrpc/types.h
@@ -0,0 +1,22 @@
1/*
2 * linux/include/linux/sunrpc/types.h
3 *
4 * Generic types and misc stuff for RPC.
5 *
6 * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
7 */
8
9#ifndef _LINUX_SUNRPC_TYPES_H_
10#define _LINUX_SUNRPC_TYPES_H_
11
12#include <linux/timer.h>
13#include <linux/workqueue.h>
14#include <linux/sunrpc/debug.h>
15#include <linux/list.h>
16
17/*
18 * Shorthands
19 */
20#define signalled() (signal_pending(current))
21
22#endif /* _LINUX_SUNRPC_TYPES_H_ */
diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h
new file mode 100644
index 000000000000..541dcf838abf
--- /dev/null
+++ b/include/linux/sunrpc/xdr.h
@@ -0,0 +1,192 @@
1/*
2 * include/linux/sunrpc/xdr.h
3 *
4 * Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de>
5 */
6
7#ifndef _SUNRPC_XDR_H_
8#define _SUNRPC_XDR_H_
9
10#ifdef __KERNEL__
11
12#include <linux/uio.h>
13#include <asm/byteorder.h>
14
15/*
16 * Buffer adjustment
17 */
18#define XDR_QUADLEN(l) (((l) + 3) >> 2)
19
20/*
21 * Generic opaque `network object.' At the kernel level, this type
22 * is used only by lockd.
23 */
24#define XDR_MAX_NETOBJ 1024
25struct xdr_netobj {
26 unsigned int len;
27 u8 * data;
28};
29
30/*
31 * This is the generic XDR function. rqstp is either a rpc_rqst (client
32 * side) or svc_rqst pointer (server side).
33 * Encode functions always assume there's enough room in the buffer.
34 */
35typedef int (*kxdrproc_t)(void *rqstp, u32 *data, void *obj);
36
37/*
38 * Basic structure for transmission/reception of a client XDR message.
39 * Features a header (for a linear buffer containing RPC headers
40 * and the data payload for short messages), and then an array of
41 * pages.
42 * The tail iovec allows you to append data after the page array. Its
43 * main interest is for appending padding to the pages in order to
44 * satisfy the int_32-alignment requirements in RFC1832.
45 *
46 * For the future, we might want to string several of these together
47 * in a list if anybody wants to make use of NFSv4 COMPOUND
48 * operations and/or has a need for scatter/gather involving pages.
49 */
50struct xdr_buf {
51 struct kvec head[1], /* RPC header + non-page data */
52 tail[1]; /* Appended after page data */
53
54 struct page ** pages; /* Array of contiguous pages */
55 unsigned int page_base, /* Start of page data */
56 page_len; /* Length of page data */
57
58 unsigned int buflen, /* Total length of storage buffer */
59 len; /* Length of XDR encoded message */
60
61};
62
63/*
64 * pre-xdr'ed macros.
65 */
66
67#define xdr_zero __constant_htonl(0)
68#define xdr_one __constant_htonl(1)
69#define xdr_two __constant_htonl(2)
70
71#define rpc_success __constant_htonl(RPC_SUCCESS)
72#define rpc_prog_unavail __constant_htonl(RPC_PROG_UNAVAIL)
73#define rpc_prog_mismatch __constant_htonl(RPC_PROG_MISMATCH)
74#define rpc_proc_unavail __constant_htonl(RPC_PROC_UNAVAIL)
75#define rpc_garbage_args __constant_htonl(RPC_GARBAGE_ARGS)
76#define rpc_system_err __constant_htonl(RPC_SYSTEM_ERR)
77
78#define rpc_auth_ok __constant_htonl(RPC_AUTH_OK)
79#define rpc_autherr_badcred __constant_htonl(RPC_AUTH_BADCRED)
80#define rpc_autherr_rejectedcred __constant_htonl(RPC_AUTH_REJECTEDCRED)
81#define rpc_autherr_badverf __constant_htonl(RPC_AUTH_BADVERF)
82#define rpc_autherr_rejectedverf __constant_htonl(RPC_AUTH_REJECTEDVERF)
83#define rpc_autherr_tooweak __constant_htonl(RPC_AUTH_TOOWEAK)
84#define rpcsec_gsserr_credproblem __constant_htonl(RPCSEC_GSS_CREDPROBLEM)
85#define rpcsec_gsserr_ctxproblem __constant_htonl(RPCSEC_GSS_CTXPROBLEM)
86#define rpc_autherr_oldseqnum __constant_htonl(101)
87
88/*
89 * Miscellaneous XDR helper functions
90 */
91u32 * xdr_encode_opaque_fixed(u32 *p, const void *ptr, unsigned int len);
92u32 * xdr_encode_opaque(u32 *p, const void *ptr, unsigned int len);
93u32 * xdr_encode_string(u32 *p, const char *s);
94u32 * xdr_decode_string(u32 *p, char **sp, int *lenp, int maxlen);
95u32 * xdr_decode_string_inplace(u32 *p, char **sp, int *lenp, int maxlen);
96u32 * xdr_encode_netobj(u32 *p, const struct xdr_netobj *);
97u32 * xdr_decode_netobj(u32 *p, struct xdr_netobj *);
98
99void xdr_encode_pages(struct xdr_buf *, struct page **, unsigned int,
100 unsigned int);
101void xdr_inline_pages(struct xdr_buf *, unsigned int,
102 struct page **, unsigned int, unsigned int);
103
104static inline u32 *xdr_encode_array(u32 *p, const void *s, unsigned int len)
105{
106 return xdr_encode_opaque(p, s, len);
107}
108
109/*
110 * Decode 64bit quantities (NFSv3 support)
111 */
112static inline u32 *
113xdr_encode_hyper(u32 *p, __u64 val)
114{
115 *p++ = htonl(val >> 32);
116 *p++ = htonl(val & 0xFFFFFFFF);
117 return p;
118}
119
120static inline u32 *
121xdr_decode_hyper(u32 *p, __u64 *valp)
122{
123 *valp = ((__u64) ntohl(*p++)) << 32;
124 *valp |= ntohl(*p++);
125 return p;
126}
127
128/*
129 * Adjust kvec to reflect end of xdr'ed data (RPC client XDR)
130 */
131static inline int
132xdr_adjust_iovec(struct kvec *iov, u32 *p)
133{
134 return iov->iov_len = ((u8 *) p - (u8 *) iov->iov_base);
135}
136
137/*
138 * Maximum number of iov's we use.
139 */
140#define MAX_IOVEC (12)
141
142/*
143 * XDR buffer helper functions
144 */
145extern void xdr_shift_buf(struct xdr_buf *, size_t);
146extern void xdr_buf_from_iov(struct kvec *, struct xdr_buf *);
147extern int xdr_buf_subsegment(struct xdr_buf *, struct xdr_buf *, int, int);
148extern int xdr_buf_read_netobj(struct xdr_buf *, struct xdr_netobj *, int);
149extern int read_bytes_from_xdr_buf(struct xdr_buf *buf, int base, void *obj, int len);
150
151/*
152 * Helper structure for copying from an sk_buff.
153 */
154typedef struct {
155 struct sk_buff *skb;
156 unsigned int offset;
157 size_t count;
158 unsigned int csum;
159} skb_reader_t;
160
161typedef size_t (*skb_read_actor_t)(skb_reader_t *desc, void *to, size_t len);
162
163extern void xdr_partial_copy_from_skb(struct xdr_buf *, unsigned int,
164 skb_reader_t *, skb_read_actor_t);
165
166struct socket;
167struct sockaddr;
168extern int xdr_sendpages(struct socket *, struct sockaddr *, int,
169 struct xdr_buf *, unsigned int, int);
170
171/*
172 * Provide some simple tools for XDR buffer overflow-checking etc.
173 */
174struct xdr_stream {
175 uint32_t *p; /* start of available buffer */
176 struct xdr_buf *buf; /* XDR buffer to read/write */
177
178 uint32_t *end; /* end of available buffer space */
179 struct kvec *iov; /* pointer to the current kvec */
180};
181
182extern void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, uint32_t *p);
183extern uint32_t *xdr_reserve_space(struct xdr_stream *xdr, size_t nbytes);
184extern void xdr_write_pages(struct xdr_stream *xdr, struct page **pages,
185 unsigned int base, unsigned int len);
186extern void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, uint32_t *p);
187extern uint32_t *xdr_inline_decode(struct xdr_stream *xdr, size_t nbytes);
188extern void xdr_read_pages(struct xdr_stream *xdr, unsigned int len);
189
190#endif /* __KERNEL__ */
191
192#endif /* _SUNRPC_XDR_H_ */
diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h
new file mode 100644
index 000000000000..e618c1649814
--- /dev/null
+++ b/include/linux/sunrpc/xprt.h
@@ -0,0 +1,232 @@
1/*
2 * linux/include/linux/sunrpc/clnt_xprt.h
3 *
4 * Declarations for the RPC transport interface.
5 *
6 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
7 */
8
9#ifndef _LINUX_SUNRPC_XPRT_H
10#define _LINUX_SUNRPC_XPRT_H
11
12#include <linux/uio.h>
13#include <linux/socket.h>
14#include <linux/in.h>
15#include <linux/sunrpc/sched.h>
16#include <linux/sunrpc/xdr.h>
17
18/*
19 * The transport code maintains an estimate on the maximum number of out-
20 * standing RPC requests, using a smoothed version of the congestion
21 * avoidance implemented in 44BSD. This is basically the Van Jacobson
22 * congestion algorithm: If a retransmit occurs, the congestion window is
23 * halved; otherwise, it is incremented by 1/cwnd when
24 *
25 * - a reply is received and
26 * - a full number of requests are outstanding and
27 * - the congestion window hasn't been updated recently.
28 *
29 * Upper procedures may check whether a request would block waiting for
30 * a free RPC slot by using the RPC_CONGESTED() macro.
31 */
32extern unsigned int xprt_udp_slot_table_entries;
33extern unsigned int xprt_tcp_slot_table_entries;
34
35#define RPC_MIN_SLOT_TABLE (2U)
36#define RPC_DEF_SLOT_TABLE (16U)
37#define RPC_MAX_SLOT_TABLE (128U)
38
39#define RPC_CWNDSHIFT (8U)
40#define RPC_CWNDSCALE (1U << RPC_CWNDSHIFT)
41#define RPC_INITCWND RPC_CWNDSCALE
42#define RPC_MAXCWND(xprt) ((xprt)->max_reqs << RPC_CWNDSHIFT)
43#define RPCXPRT_CONGESTED(xprt) ((xprt)->cong >= (xprt)->cwnd)
44
45/* Default timeout values */
46#define RPC_MAX_UDP_TIMEOUT (60*HZ)
47#define RPC_MAX_TCP_TIMEOUT (600*HZ)
48
49/*
50 * Wait duration for an RPC TCP connection to be established. Solaris
51 * NFS over TCP uses 60 seconds, for example, which is in line with how
52 * long a server takes to reboot.
53 */
54#define RPC_CONNECT_TIMEOUT (60*HZ)
55
56/*
57 * Delay an arbitrary number of seconds before attempting to reconnect
58 * after an error.
59 */
60#define RPC_REESTABLISH_TIMEOUT (15*HZ)
61
62/* RPC call and reply header size as number of 32bit words (verifier
63 * size computed separately)
64 */
65#define RPC_CALLHDRSIZE 6
66#define RPC_REPHDRSIZE 4
67
68/*
69 * This describes a timeout strategy
70 */
71struct rpc_timeout {
72 unsigned long to_initval, /* initial timeout */
73 to_maxval, /* max timeout */
74 to_increment; /* if !exponential */
75 unsigned int to_retries; /* max # of retries */
76 unsigned char to_exponential;
77};
78
79/*
80 * This describes a complete RPC request
81 */
82struct rpc_rqst {
83 /*
84 * This is the user-visible part
85 */
86 struct rpc_xprt * rq_xprt; /* RPC client */
87 struct xdr_buf rq_snd_buf; /* send buffer */
88 struct xdr_buf rq_rcv_buf; /* recv buffer */
89
90 /*
91 * This is the private part
92 */
93 struct rpc_task * rq_task; /* RPC task data */
94 __u32 rq_xid; /* request XID */
95 int rq_cong; /* has incremented xprt->cong */
96 int rq_received; /* receive completed */
97 u32 rq_seqno; /* gss seq no. used on req. */
98
99 struct list_head rq_list;
100
101 struct xdr_buf rq_private_buf; /* The receive buffer
102 * used in the softirq.
103 */
104 unsigned long rq_majortimeo; /* major timeout alarm */
105 unsigned long rq_timeout; /* Current timeout value */
106 unsigned int rq_retries; /* # of retries */
107 /*
108 * For authentication (e.g. auth_des)
109 */
110 u32 rq_creddata[2];
111
112 /*
113 * Partial send handling
114 */
115
116 u32 rq_bytes_sent; /* Bytes we have sent */
117
118 unsigned long rq_xtime; /* when transmitted */
119 int rq_ntrans;
120};
121#define rq_svec rq_snd_buf.head
122#define rq_slen rq_snd_buf.len
123
124#define XPRT_LAST_FRAG (1 << 0)
125#define XPRT_COPY_RECM (1 << 1)
126#define XPRT_COPY_XID (1 << 2)
127#define XPRT_COPY_DATA (1 << 3)
128
129struct rpc_xprt {
130 struct socket * sock; /* BSD socket layer */
131 struct sock * inet; /* INET layer */
132
133 struct rpc_timeout timeout; /* timeout parms */
134 struct sockaddr_in addr; /* server address */
135 int prot; /* IP protocol */
136
137 unsigned long cong; /* current congestion */
138 unsigned long cwnd; /* congestion window */
139
140 unsigned int rcvsize, /* socket receive buffer size */
141 sndsize; /* socket send buffer size */
142
143 size_t max_payload; /* largest RPC payload size,
144 in bytes */
145
146 struct rpc_wait_queue sending; /* requests waiting to send */
147 struct rpc_wait_queue resend; /* requests waiting to resend */
148 struct rpc_wait_queue pending; /* requests in flight */
149 struct rpc_wait_queue backlog; /* waiting for slot */
150 struct list_head free; /* free slots */
151 struct rpc_rqst * slot; /* slot table storage */
152 unsigned int max_reqs; /* total slots */
153 unsigned long sockstate; /* Socket state */
154 unsigned char shutdown : 1, /* being shut down */
155 nocong : 1, /* no congestion control */
156 resvport : 1, /* use a reserved port */
157 stream : 1; /* TCP */
158
159 /*
160 * XID
161 */
162 __u32 xid; /* Next XID value to use */
163
164 /*
165 * State of TCP reply receive stuff
166 */
167 u32 tcp_recm, /* Fragment header */
168 tcp_xid, /* Current XID */
169 tcp_reclen, /* fragment length */
170 tcp_offset; /* fragment offset */
171 unsigned long tcp_copied, /* copied to request */
172 tcp_flags;
173 /*
174 * Connection of sockets
175 */
176 struct work_struct sock_connect;
177 unsigned short port;
178 /*
179 * Disconnection of idle sockets
180 */
181 struct work_struct task_cleanup;
182 struct timer_list timer;
183 unsigned long last_used;
184
185 /*
186 * Send stuff
187 */
188 spinlock_t sock_lock; /* lock socket info */
189 spinlock_t xprt_lock; /* lock xprt info */
190 struct rpc_task * snd_task; /* Task blocked in send */
191
192 struct list_head recv;
193
194
195 void (*old_data_ready)(struct sock *, int);
196 void (*old_state_change)(struct sock *);
197 void (*old_write_space)(struct sock *);
198
199 wait_queue_head_t cong_wait;
200};
201
202#ifdef __KERNEL__
203
204struct rpc_xprt * xprt_create_proto(int proto, struct sockaddr_in *addr,
205 struct rpc_timeout *toparms);
206int xprt_destroy(struct rpc_xprt *);
207void xprt_set_timeout(struct rpc_timeout *, unsigned int,
208 unsigned long);
209
210void xprt_reserve(struct rpc_task *);
211int xprt_prepare_transmit(struct rpc_task *);
212void xprt_transmit(struct rpc_task *);
213void xprt_receive(struct rpc_task *);
214int xprt_adjust_timeout(struct rpc_rqst *req);
215void xprt_release(struct rpc_task *);
216void xprt_connect(struct rpc_task *);
217void xprt_sock_setbufsize(struct rpc_xprt *);
218
219#define XPRT_LOCKED 0
220#define XPRT_CONNECT 1
221#define XPRT_CONNECTING 2
222
223#define xprt_connected(xp) (test_bit(XPRT_CONNECT, &(xp)->sockstate))
224#define xprt_set_connected(xp) (set_bit(XPRT_CONNECT, &(xp)->sockstate))
225#define xprt_test_and_set_connected(xp) (test_and_set_bit(XPRT_CONNECT, &(xp)->sockstate))
226#define xprt_test_and_clear_connected(xp) \
227 (test_and_clear_bit(XPRT_CONNECT, &(xp)->sockstate))
228#define xprt_clear_connected(xp) (clear_bit(XPRT_CONNECT, &(xp)->sockstate))
229
230#endif /* __KERNEL__*/
231
232#endif /* _LINUX_SUNRPC_XPRT_H */
diff --git a/include/linux/superhyway.h b/include/linux/superhyway.h
new file mode 100644
index 000000000000..c906c5a0aaef
--- /dev/null
+++ b/include/linux/superhyway.h
@@ -0,0 +1,79 @@
1/*
2 * include/linux/superhyway.h
3 *
4 * SuperHyway Bus definitions
5 *
6 * Copyright (C) 2004, 2005 Paul Mundt <lethal@linux-sh.org>
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 */
12#ifndef __LINUX_SUPERHYWAY_H
13#define __LINUX_SUPERHYWAY_H
14
15#include <linux/device.h>
16
17/*
18 * SuperHyway IDs
19 */
20#define SUPERHYWAY_DEVICE_ID_SH5_DMAC 0x0183
21
22struct vcr_info {
23 u8 perr_flags; /* P-port Error flags */
24 u8 merr_flags; /* Module Error flags */
25 u16 mod_vers; /* Module Version */
26 u16 mod_id; /* Module ID */
27 u8 bot_mb; /* Bottom Memory block */
28 u8 top_mb; /* Top Memory block */
29};
30
31struct superhyway_device_id {
32 unsigned int id;
33 unsigned long driver_data;
34};
35
36struct superhyway_device;
37extern struct bus_type superhyway_bus_type;
38
39struct superhyway_driver {
40 char *name;
41
42 const struct superhyway_device_id *id_table;
43 struct device_driver drv;
44
45 int (*probe)(struct superhyway_device *dev, const struct superhyway_device_id *id);
46 void (*remove)(struct superhyway_device *dev);
47};
48
49#define to_superhyway_driver(d) container_of((d), struct superhyway_driver, drv)
50
51struct superhyway_device {
52 char name[32];
53
54 struct device dev;
55
56 struct superhyway_device_id id;
57 struct superhyway_driver *drv;
58
59 struct resource resource;
60 struct vcr_info vcr;
61};
62
63#define to_superhyway_device(d) container_of((d), struct superhyway_device, dev)
64
65#define superhyway_get_drvdata(d) dev_get_drvdata(&(d)->dev)
66#define superhyway_set_drvdata(d,p) dev_set_drvdata(&(d)->dev, (p))
67
68extern int superhyway_scan_bus(void);
69
70/* drivers/sh/superhyway/superhyway.c */
71int superhyway_register_driver(struct superhyway_driver *);
72void superhyway_unregister_driver(struct superhyway_driver *);
73int superhyway_add_device(unsigned int, unsigned long, unsigned long long);
74
75/* drivers/sh/superhyway/superhyway-sysfs.c */
76extern struct device_attribute superhyway_dev_attrs[];
77
78#endif /* __LINUX_SUPERHYWAY_H */
79
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
new file mode 100644
index 000000000000..2bf0d5fabcdb
--- /dev/null
+++ b/include/linux/suspend.h
@@ -0,0 +1,75 @@
1#ifndef _LINUX_SWSUSP_H
2#define _LINUX_SWSUSP_H
3
4#if defined(CONFIG_X86) || defined(CONFIG_FRV) || defined(CONFIG_PPC32)
5#include <asm/suspend.h>
6#endif
7#include <linux/swap.h>
8#include <linux/notifier.h>
9#include <linux/config.h>
10#include <linux/init.h>
11#include <linux/pm.h>
12
13/* page backup entry */
14typedef struct pbe {
15 unsigned long address; /* address of the copy */
16 unsigned long orig_address; /* original address of page */
17 swp_entry_t swap_address;
18
19 struct pbe *next; /* also used as scratch space at
20 * end of page (see link, diskpage)
21 */
22} suspend_pagedir_t;
23
24#define for_each_pbe(pbe, pblist) \
25 for (pbe = pblist ; pbe ; pbe = pbe->next)
26
27#define PBES_PER_PAGE (PAGE_SIZE/sizeof(struct pbe))
28#define PB_PAGE_SKIP (PBES_PER_PAGE-1)
29
30#define for_each_pb_page(pbe, pblist) \
31 for (pbe = pblist ; pbe ; pbe = (pbe+PB_PAGE_SKIP)->next)
32
33
34#define SWAP_FILENAME_MAXLENGTH 32
35
36
37extern dev_t swsusp_resume_device;
38
39/* mm/vmscan.c */
40extern int shrink_mem(void);
41
42/* mm/page_alloc.c */
43extern void drain_local_pages(void);
44extern void mark_free_pages(struct zone *zone);
45
46#ifdef CONFIG_PM
47/* kernel/power/swsusp.c */
48extern int software_suspend(void);
49
50extern int pm_prepare_console(void);
51extern void pm_restore_console(void);
52
53#else
54static inline int software_suspend(void)
55{
56 printk("Warning: fake suspend called\n");
57 return -EPERM;
58}
59#endif
60
61#ifdef CONFIG_SMP
62extern void disable_nonboot_cpus(void);
63extern void enable_nonboot_cpus(void);
64#else
65static inline void disable_nonboot_cpus(void) {}
66static inline void enable_nonboot_cpus(void) {}
67#endif
68
69void save_processor_state(void);
70void restore_processor_state(void);
71struct saved_context;
72void __save_processor_state(struct saved_context *ctxt);
73void __restore_processor_state(struct saved_context *ctxt);
74
75#endif /* _LINUX_SWSUSP_H */
diff --git a/include/linux/swap.h b/include/linux/swap.h
new file mode 100644
index 000000000000..3bbc41be9bd0
--- /dev/null
+++ b/include/linux/swap.h
@@ -0,0 +1,293 @@
1#ifndef _LINUX_SWAP_H
2#define _LINUX_SWAP_H
3
4#include <linux/config.h>
5#include <linux/spinlock.h>
6#include <linux/linkage.h>
7#include <linux/mmzone.h>
8#include <linux/list.h>
9#include <linux/sched.h>
10#include <asm/atomic.h>
11#include <asm/page.h>
12
13#define SWAP_FLAG_PREFER 0x8000 /* set if swap priority specified */
14#define SWAP_FLAG_PRIO_MASK 0x7fff
15#define SWAP_FLAG_PRIO_SHIFT 0
16
17static inline int current_is_kswapd(void)
18{
19 return current->flags & PF_KSWAPD;
20}
21
22/*
23 * MAX_SWAPFILES defines the maximum number of swaptypes: things which can
24 * be swapped to. The swap type and the offset into that swap type are
25 * encoded into pte's and into pgoff_t's in the swapcache. Using five bits
26 * for the type means that the maximum number of swapcache pages is 27 bits
27 * on 32-bit-pgoff_t architectures. And that assumes that the architecture packs
28 * the type/offset into the pte as 5/27 as well.
29 */
30#define MAX_SWAPFILES_SHIFT 5
31#define MAX_SWAPFILES (1 << MAX_SWAPFILES_SHIFT)
32
33/*
34 * Magic header for a swap area. The first part of the union is
35 * what the swap magic looks like for the old (limited to 128MB)
36 * swap area format, the second part of the union adds - in the
37 * old reserved area - some extra information. Note that the first
38 * kilobyte is reserved for boot loader or disk label stuff...
39 *
40 * Having the magic at the end of the PAGE_SIZE makes detecting swap
41 * areas somewhat tricky on machines that support multiple page sizes.
42 * For 2.5 we'll probably want to move the magic to just beyond the
43 * bootbits...
44 */
45union swap_header {
46 struct {
47 char reserved[PAGE_SIZE - 10];
48 char magic[10]; /* SWAP-SPACE or SWAPSPACE2 */
49 } magic;
50 struct {
51 char bootbits[1024]; /* Space for disklabel etc. */
52 unsigned int version;
53 unsigned int last_page;
54 unsigned int nr_badpages;
55 unsigned int padding[125];
56 unsigned int badpages[1];
57 } info;
58};
59
60 /* A swap entry has to fit into a "unsigned long", as
61 * the entry is hidden in the "index" field of the
62 * swapper address space.
63 */
64typedef struct {
65 unsigned long val;
66} swp_entry_t;
67
68/*
69 * current->reclaim_state points to one of these when a task is running
70 * memory reclaim
71 */
72struct reclaim_state {
73 unsigned long reclaimed_slab;
74};
75
76#ifdef __KERNEL__
77
78struct address_space;
79struct sysinfo;
80struct writeback_control;
81struct zone;
82
83/*
84 * A swap extent maps a range of a swapfile's PAGE_SIZE pages onto a range of
85 * disk blocks. A list of swap extents maps the entire swapfile. (Where the
86 * term `swapfile' refers to either a blockdevice or an IS_REG file. Apart
87 * from setup, they're handled identically.
88 *
89 * We always assume that blocks are of size PAGE_SIZE.
90 */
91struct swap_extent {
92 struct list_head list;
93 pgoff_t start_page;
94 pgoff_t nr_pages;
95 sector_t start_block;
96};
97
98/*
99 * Max bad pages in the new format..
100 */
101#define __swapoffset(x) ((unsigned long)&((union swap_header *)0)->x)
102#define MAX_SWAP_BADPAGES \
103 ((__swapoffset(magic.magic) - __swapoffset(info.badpages)) / sizeof(int))
104
105enum {
106 SWP_USED = (1 << 0), /* is slot in swap_info[] used? */
107 SWP_WRITEOK = (1 << 1), /* ok to write to this swap? */
108 SWP_ACTIVE = (SWP_USED | SWP_WRITEOK),
109};
110
111#define SWAP_CLUSTER_MAX 32
112
113#define SWAP_MAP_MAX 0x7fff
114#define SWAP_MAP_BAD 0x8000
115
116/*
117 * The in-memory structure used to track swap areas.
118 * extent_list.prev points at the lowest-index extent. That list is
119 * sorted.
120 */
121struct swap_info_struct {
122 unsigned int flags;
123 spinlock_t sdev_lock;
124 struct file *swap_file;
125 struct block_device *bdev;
126 struct list_head extent_list;
127 int nr_extents;
128 struct swap_extent *curr_swap_extent;
129 unsigned old_block_size;
130 unsigned short * swap_map;
131 unsigned int lowest_bit;
132 unsigned int highest_bit;
133 unsigned int cluster_next;
134 unsigned int cluster_nr;
135 int prio; /* swap priority */
136 int pages;
137 unsigned long max;
138 unsigned long inuse_pages;
139 int next; /* next entry on swap list */
140};
141
142struct swap_list_t {
143 int head; /* head of priority-ordered swapfile list */
144 int next; /* swapfile to be used next */
145};
146
147/* Swap 50% full? Release swapcache more aggressively.. */
148#define vm_swap_full() (nr_swap_pages*2 < total_swap_pages)
149
150/* linux/mm/oom_kill.c */
151extern void out_of_memory(unsigned int __nocast gfp_mask);
152
153/* linux/mm/memory.c */
154extern void swapin_readahead(swp_entry_t, unsigned long, struct vm_area_struct *);
155
156/* linux/mm/page_alloc.c */
157extern unsigned long totalram_pages;
158extern unsigned long totalhigh_pages;
159extern long nr_swap_pages;
160extern unsigned int nr_free_pages(void);
161extern unsigned int nr_free_pages_pgdat(pg_data_t *pgdat);
162extern unsigned int nr_free_buffer_pages(void);
163extern unsigned int nr_free_pagecache_pages(void);
164
165/* linux/mm/swap.c */
166extern void FASTCALL(lru_cache_add(struct page *));
167extern void FASTCALL(lru_cache_add_active(struct page *));
168extern void FASTCALL(activate_page(struct page *));
169extern void FASTCALL(mark_page_accessed(struct page *));
170extern void lru_add_drain(void);
171extern int rotate_reclaimable_page(struct page *page);
172extern void swap_setup(void);
173
174/* linux/mm/vmscan.c */
175extern int try_to_free_pages(struct zone **, unsigned int, unsigned int);
176extern int shrink_all_memory(int);
177extern int vm_swappiness;
178
179#ifdef CONFIG_MMU
180/* linux/mm/shmem.c */
181extern int shmem_unuse(swp_entry_t entry, struct page *page);
182#endif /* CONFIG_MMU */
183
184extern void swap_unplug_io_fn(struct backing_dev_info *, struct page *);
185
186#ifdef CONFIG_SWAP
187/* linux/mm/page_io.c */
188extern int swap_readpage(struct file *, struct page *);
189extern int swap_writepage(struct page *page, struct writeback_control *wbc);
190extern int rw_swap_page_sync(int, swp_entry_t, struct page *);
191
192/* linux/mm/swap_state.c */
193extern struct address_space swapper_space;
194#define total_swapcache_pages swapper_space.nrpages
195extern void show_swap_cache_info(void);
196extern int add_to_swap(struct page *);
197extern void __delete_from_swap_cache(struct page *);
198extern void delete_from_swap_cache(struct page *);
199extern int move_to_swap_cache(struct page *, swp_entry_t);
200extern int move_from_swap_cache(struct page *, unsigned long,
201 struct address_space *);
202extern void free_page_and_swap_cache(struct page *);
203extern void free_pages_and_swap_cache(struct page **, int);
204extern struct page * lookup_swap_cache(swp_entry_t);
205extern struct page * read_swap_cache_async(swp_entry_t, struct vm_area_struct *vma,
206 unsigned long addr);
207/* linux/mm/swapfile.c */
208extern long total_swap_pages;
209extern unsigned int nr_swapfiles;
210extern struct swap_info_struct swap_info[];
211extern void si_swapinfo(struct sysinfo *);
212extern swp_entry_t get_swap_page(void);
213extern int swap_duplicate(swp_entry_t);
214extern int valid_swaphandles(swp_entry_t, unsigned long *);
215extern void swap_free(swp_entry_t);
216extern void free_swap_and_cache(swp_entry_t);
217extern sector_t map_swap_page(struct swap_info_struct *, pgoff_t);
218extern struct swap_info_struct *get_swap_info_struct(unsigned);
219extern int can_share_swap_page(struct page *);
220extern int remove_exclusive_swap_page(struct page *);
221struct backing_dev_info;
222
223extern struct swap_list_t swap_list;
224extern spinlock_t swaplock;
225
226#define swap_list_lock() spin_lock(&swaplock)
227#define swap_list_unlock() spin_unlock(&swaplock)
228#define swap_device_lock(p) spin_lock(&p->sdev_lock)
229#define swap_device_unlock(p) spin_unlock(&p->sdev_lock)
230
231/* linux/mm/thrash.c */
232extern struct mm_struct * swap_token_mm;
233extern unsigned long swap_token_default_timeout;
234extern void grab_swap_token(void);
235extern void __put_swap_token(struct mm_struct *);
236
237static inline int has_swap_token(struct mm_struct *mm)
238{
239 return (mm == swap_token_mm);
240}
241
242static inline void put_swap_token(struct mm_struct *mm)
243{
244 if (has_swap_token(mm))
245 __put_swap_token(mm);
246}
247
248#else /* CONFIG_SWAP */
249
250#define total_swap_pages 0
251#define total_swapcache_pages 0UL
252
253#define si_swapinfo(val) \
254 do { (val)->freeswap = (val)->totalswap = 0; } while (0)
255#define free_page_and_swap_cache(page) \
256 page_cache_release(page)
257#define free_pages_and_swap_cache(pages, nr) \
258 release_pages((pages), (nr), 0);
259
260#define show_swap_cache_info() /*NOTHING*/
261#define free_swap_and_cache(swp) /*NOTHING*/
262#define swap_duplicate(swp) /*NOTHING*/
263#define swap_free(swp) /*NOTHING*/
264#define read_swap_cache_async(swp,vma,addr) NULL
265#define lookup_swap_cache(swp) NULL
266#define valid_swaphandles(swp, off) 0
267#define can_share_swap_page(p) 0
268#define move_to_swap_cache(p, swp) 1
269#define move_from_swap_cache(p, i, m) 1
270#define __delete_from_swap_cache(p) /*NOTHING*/
271#define delete_from_swap_cache(p) /*NOTHING*/
272#define swap_token_default_timeout 0
273
274static inline int remove_exclusive_swap_page(struct page *p)
275{
276 return 0;
277}
278
279static inline swp_entry_t get_swap_page(void)
280{
281 swp_entry_t entry;
282 entry.val = 0;
283 return entry;
284}
285
286/* linux/mm/thrash.c */
287#define put_swap_token(x) do { } while(0)
288#define grab_swap_token() do { } while(0)
289#define has_swap_token(x) 0
290
291#endif /* CONFIG_SWAP */
292#endif /* __KERNEL__*/
293#endif /* _LINUX_SWAP_H */
diff --git a/include/linux/swapops.h b/include/linux/swapops.h
new file mode 100644
index 000000000000..d4c7db35e708
--- /dev/null
+++ b/include/linux/swapops.h
@@ -0,0 +1,69 @@
1/*
2 * swapcache pages are stored in the swapper_space radix tree. We want to
3 * get good packing density in that tree, so the index should be dense in
4 * the low-order bits.
5 *
6 * We arrange the `type' and `offset' fields so that `type' is at the five
7 * high-order bits of the smp_entry_t and `offset' is right-aligned in the
8 * remaining bits.
9 *
10 * swp_entry_t's are *never* stored anywhere in their arch-dependent format.
11 */
12#define SWP_TYPE_SHIFT(e) (sizeof(e.val) * 8 - MAX_SWAPFILES_SHIFT)
13#define SWP_OFFSET_MASK(e) ((1UL << SWP_TYPE_SHIFT(e)) - 1)
14
15/*
16 * Store a type+offset into a swp_entry_t in an arch-independent format
17 */
18static inline swp_entry_t swp_entry(unsigned long type, pgoff_t offset)
19{
20 swp_entry_t ret;
21
22 ret.val = (type << SWP_TYPE_SHIFT(ret)) |
23 (offset & SWP_OFFSET_MASK(ret));
24 return ret;
25}
26
27/*
28 * Extract the `type' field from a swp_entry_t. The swp_entry_t is in
29 * arch-independent format
30 */
31static inline unsigned swp_type(swp_entry_t entry)
32{
33 return (entry.val >> SWP_TYPE_SHIFT(entry));
34}
35
36/*
37 * Extract the `offset' field from a swp_entry_t. The swp_entry_t is in
38 * arch-independent format
39 */
40static inline pgoff_t swp_offset(swp_entry_t entry)
41{
42 return entry.val & SWP_OFFSET_MASK(entry);
43}
44
45/*
46 * Convert the arch-dependent pte representation of a swp_entry_t into an
47 * arch-independent swp_entry_t.
48 */
49static inline swp_entry_t pte_to_swp_entry(pte_t pte)
50{
51 swp_entry_t arch_entry;
52
53 BUG_ON(pte_file(pte));
54 arch_entry = __pte_to_swp_entry(pte);
55 return swp_entry(__swp_type(arch_entry), __swp_offset(arch_entry));
56}
57
58/*
59 * Convert the arch-independent representation of a swp_entry_t into the
60 * arch-dependent pte representation.
61 */
62static inline pte_t swp_entry_to_pte(swp_entry_t entry)
63{
64 swp_entry_t arch_entry;
65
66 arch_entry = __swp_entry(swp_type(entry), swp_offset(entry));
67 BUG_ON(pte_file(__swp_entry_to_pte(arch_entry)));
68 return __swp_entry_to_pte(arch_entry);
69}
diff --git a/include/linux/synclink.h b/include/linux/synclink.h
new file mode 100644
index 000000000000..763bd290f28d
--- /dev/null
+++ b/include/linux/synclink.h
@@ -0,0 +1,273 @@
1/*
2 * SyncLink Multiprotocol Serial Adapter Driver
3 *
4 * $Id: synclink.h,v 3.6 2002/02/20 21:58:20 paulkf Exp $
5 *
6 * Copyright (C) 1998-2000 by Microgate Corporation
7 *
8 * Redistribution of this file is permitted under
9 * the terms of the GNU Public License (GPL)
10 */
11
12#ifndef _SYNCLINK_H_
13#define _SYNCLINK_H_
14#define SYNCLINK_H_VERSION 3.6
15
16#define BOOLEAN int
17#define TRUE 1
18#define FALSE 0
19
20#define BIT0 0x0001
21#define BIT1 0x0002
22#define BIT2 0x0004
23#define BIT3 0x0008
24#define BIT4 0x0010
25#define BIT5 0x0020
26#define BIT6 0x0040
27#define BIT7 0x0080
28#define BIT8 0x0100
29#define BIT9 0x0200
30#define BIT10 0x0400
31#define BIT11 0x0800
32#define BIT12 0x1000
33#define BIT13 0x2000
34#define BIT14 0x4000
35#define BIT15 0x8000
36#define BIT16 0x00010000
37#define BIT17 0x00020000
38#define BIT18 0x00040000
39#define BIT19 0x00080000
40#define BIT20 0x00100000
41#define BIT21 0x00200000
42#define BIT22 0x00400000
43#define BIT23 0x00800000
44#define BIT24 0x01000000
45#define BIT25 0x02000000
46#define BIT26 0x04000000
47#define BIT27 0x08000000
48#define BIT28 0x10000000
49#define BIT29 0x20000000
50#define BIT30 0x40000000
51#define BIT31 0x80000000
52
53
54#define HDLC_MAX_FRAME_SIZE 65535
55#define MAX_ASYNC_TRANSMIT 4096
56#define MAX_ASYNC_BUFFER_SIZE 4096
57
58#define ASYNC_PARITY_NONE 0
59#define ASYNC_PARITY_EVEN 1
60#define ASYNC_PARITY_ODD 2
61#define ASYNC_PARITY_SPACE 3
62
63#define HDLC_FLAG_UNDERRUN_ABORT7 0x0000
64#define HDLC_FLAG_UNDERRUN_ABORT15 0x0001
65#define HDLC_FLAG_UNDERRUN_FLAG 0x0002
66#define HDLC_FLAG_UNDERRUN_CRC 0x0004
67#define HDLC_FLAG_SHARE_ZERO 0x0010
68#define HDLC_FLAG_AUTO_CTS 0x0020
69#define HDLC_FLAG_AUTO_DCD 0x0040
70#define HDLC_FLAG_AUTO_RTS 0x0080
71#define HDLC_FLAG_RXC_DPLL 0x0100
72#define HDLC_FLAG_RXC_BRG 0x0200
73#define HDLC_FLAG_RXC_TXCPIN 0x8000
74#define HDLC_FLAG_RXC_RXCPIN 0x0000
75#define HDLC_FLAG_TXC_DPLL 0x0400
76#define HDLC_FLAG_TXC_BRG 0x0800
77#define HDLC_FLAG_TXC_TXCPIN 0x0000
78#define HDLC_FLAG_TXC_RXCPIN 0x0008
79#define HDLC_FLAG_DPLL_DIV8 0x1000
80#define HDLC_FLAG_DPLL_DIV16 0x2000
81#define HDLC_FLAG_DPLL_DIV32 0x0000
82#define HDLC_FLAG_HDLC_LOOPMODE 0x4000
83
84#define HDLC_CRC_NONE 0
85#define HDLC_CRC_16_CCITT 1
86#define HDLC_CRC_32_CCITT 2
87#define HDLC_CRC_MASK 0x00ff
88#define HDLC_CRC_RETURN_EX 0x8000
89
90#define RX_OK 0
91#define RX_CRC_ERROR 1
92
93#define HDLC_TXIDLE_FLAGS 0
94#define HDLC_TXIDLE_ALT_ZEROS_ONES 1
95#define HDLC_TXIDLE_ZEROS 2
96#define HDLC_TXIDLE_ONES 3
97#define HDLC_TXIDLE_ALT_MARK_SPACE 4
98#define HDLC_TXIDLE_SPACE 5
99#define HDLC_TXIDLE_MARK 6
100
101#define HDLC_ENCODING_NRZ 0
102#define HDLC_ENCODING_NRZB 1
103#define HDLC_ENCODING_NRZI_MARK 2
104#define HDLC_ENCODING_NRZI_SPACE 3
105#define HDLC_ENCODING_NRZI HDLC_ENCODING_NRZI_SPACE
106#define HDLC_ENCODING_BIPHASE_MARK 4
107#define HDLC_ENCODING_BIPHASE_SPACE 5
108#define HDLC_ENCODING_BIPHASE_LEVEL 6
109#define HDLC_ENCODING_DIFF_BIPHASE_LEVEL 7
110
111#define HDLC_PREAMBLE_LENGTH_8BITS 0
112#define HDLC_PREAMBLE_LENGTH_16BITS 1
113#define HDLC_PREAMBLE_LENGTH_32BITS 2
114#define HDLC_PREAMBLE_LENGTH_64BITS 3
115
116#define HDLC_PREAMBLE_PATTERN_NONE 0
117#define HDLC_PREAMBLE_PATTERN_ZEROS 1
118#define HDLC_PREAMBLE_PATTERN_FLAGS 2
119#define HDLC_PREAMBLE_PATTERN_10 3
120#define HDLC_PREAMBLE_PATTERN_01 4
121#define HDLC_PREAMBLE_PATTERN_ONES 5
122
123#define MGSL_MODE_ASYNC 1
124#define MGSL_MODE_HDLC 2
125#define MGSL_MODE_RAW 6
126
127#define MGSL_BUS_TYPE_ISA 1
128#define MGSL_BUS_TYPE_EISA 2
129#define MGSL_BUS_TYPE_PCI 5
130
131#define MGSL_INTERFACE_DISABLE 0
132#define MGSL_INTERFACE_RS232 1
133#define MGSL_INTERFACE_V35 2
134#define MGSL_INTERFACE_RS422 3
135
136typedef struct _MGSL_PARAMS
137{
138 /* Common */
139
140 unsigned long mode; /* Asynchronous or HDLC */
141 unsigned char loopback; /* internal loopback mode */
142
143 /* HDLC Only */
144
145 unsigned short flags;
146 unsigned char encoding; /* NRZ, NRZI, etc. */
147 unsigned long clock_speed; /* external clock speed in bits per second */
148 unsigned char addr_filter; /* receive HDLC address filter, 0xFF = disable */
149 unsigned short crc_type; /* None, CRC16-CCITT, or CRC32-CCITT */
150 unsigned char preamble_length;
151 unsigned char preamble;
152
153 /* Async Only */
154
155 unsigned long data_rate; /* bits per second */
156 unsigned char data_bits; /* 7 or 8 data bits */
157 unsigned char stop_bits; /* 1 or 2 stop bits */
158 unsigned char parity; /* none, even, or odd */
159
160} MGSL_PARAMS, *PMGSL_PARAMS;
161
162#define MICROGATE_VENDOR_ID 0x13c0
163#define SYNCLINK_DEVICE_ID 0x0010
164#define MGSCC_DEVICE_ID 0x0020
165#define SYNCLINK_SCA_DEVICE_ID 0x0030
166#define MGSL_MAX_SERIAL_NUMBER 30
167
168/*
169** device diagnostics status
170*/
171
172#define DiagStatus_OK 0
173#define DiagStatus_AddressFailure 1
174#define DiagStatus_AddressConflict 2
175#define DiagStatus_IrqFailure 3
176#define DiagStatus_IrqConflict 4
177#define DiagStatus_DmaFailure 5
178#define DiagStatus_DmaConflict 6
179#define DiagStatus_PciAdapterNotFound 7
180#define DiagStatus_CantAssignPciResources 8
181#define DiagStatus_CantAssignPciMemAddr 9
182#define DiagStatus_CantAssignPciIoAddr 10
183#define DiagStatus_CantAssignPciIrq 11
184#define DiagStatus_MemoryError 12
185
186#define SerialSignal_DCD 0x01 /* Data Carrier Detect */
187#define SerialSignal_TXD 0x02 /* Transmit Data */
188#define SerialSignal_RI 0x04 /* Ring Indicator */
189#define SerialSignal_RXD 0x08 /* Receive Data */
190#define SerialSignal_CTS 0x10 /* Clear to Send */
191#define SerialSignal_RTS 0x20 /* Request to Send */
192#define SerialSignal_DSR 0x40 /* Data Set Ready */
193#define SerialSignal_DTR 0x80 /* Data Terminal Ready */
194
195
196/*
197 * Counters of the input lines (CTS, DSR, RI, CD) interrupts
198 */
199struct mgsl_icount {
200 __u32 cts, dsr, rng, dcd, tx, rx;
201 __u32 frame, parity, overrun, brk;
202 __u32 buf_overrun;
203 __u32 txok;
204 __u32 txunder;
205 __u32 txabort;
206 __u32 txtimeout;
207 __u32 rxshort;
208 __u32 rxlong;
209 __u32 rxabort;
210 __u32 rxover;
211 __u32 rxcrc;
212 __u32 rxok;
213 __u32 exithunt;
214 __u32 rxidle;
215};
216
217
218#define DEBUG_LEVEL_DATA 1
219#define DEBUG_LEVEL_ERROR 2
220#define DEBUG_LEVEL_INFO 3
221#define DEBUG_LEVEL_BH 4
222#define DEBUG_LEVEL_ISR 5
223
224/*
225** Event bit flags for use with MgslWaitEvent
226*/
227
228#define MgslEvent_DsrActive 0x0001
229#define MgslEvent_DsrInactive 0x0002
230#define MgslEvent_Dsr 0x0003
231#define MgslEvent_CtsActive 0x0004
232#define MgslEvent_CtsInactive 0x0008
233#define MgslEvent_Cts 0x000c
234#define MgslEvent_DcdActive 0x0010
235#define MgslEvent_DcdInactive 0x0020
236#define MgslEvent_Dcd 0x0030
237#define MgslEvent_RiActive 0x0040
238#define MgslEvent_RiInactive 0x0080
239#define MgslEvent_Ri 0x00c0
240#define MgslEvent_ExitHuntMode 0x0100
241#define MgslEvent_IdleReceived 0x0200
242
243/* Private IOCTL codes:
244 *
245 * MGSL_IOCSPARAMS set MGSL_PARAMS structure values
246 * MGSL_IOCGPARAMS get current MGSL_PARAMS structure values
247 * MGSL_IOCSTXIDLE set current transmit idle mode
248 * MGSL_IOCGTXIDLE get current transmit idle mode
249 * MGSL_IOCTXENABLE enable or disable transmitter
250 * MGSL_IOCRXENABLE enable or disable receiver
251 * MGSL_IOCTXABORT abort transmitting frame (HDLC)
252 * MGSL_IOCGSTATS return current statistics
253 * MGSL_IOCWAITEVENT wait for specified event to occur
254 * MGSL_LOOPTXDONE transmit in HDLC LoopMode done
255 * MGSL_IOCSIF set the serial interface type
256 * MGSL_IOCGIF get the serial interface type
257 */
258#define MGSL_MAGIC_IOC 'm'
259#define MGSL_IOCSPARAMS _IOW(MGSL_MAGIC_IOC,0,struct _MGSL_PARAMS)
260#define MGSL_IOCGPARAMS _IOR(MGSL_MAGIC_IOC,1,struct _MGSL_PARAMS)
261#define MGSL_IOCSTXIDLE _IO(MGSL_MAGIC_IOC,2)
262#define MGSL_IOCGTXIDLE _IO(MGSL_MAGIC_IOC,3)
263#define MGSL_IOCTXENABLE _IO(MGSL_MAGIC_IOC,4)
264#define MGSL_IOCRXENABLE _IO(MGSL_MAGIC_IOC,5)
265#define MGSL_IOCTXABORT _IO(MGSL_MAGIC_IOC,6)
266#define MGSL_IOCGSTATS _IO(MGSL_MAGIC_IOC,7)
267#define MGSL_IOCWAITEVENT _IOWR(MGSL_MAGIC_IOC,8,int)
268#define MGSL_IOCCLRMODCOUNT _IO(MGSL_MAGIC_IOC,15)
269#define MGSL_IOCLOOPTXDONE _IO(MGSL_MAGIC_IOC,9)
270#define MGSL_IOCSIF _IO(MGSL_MAGIC_IOC,10)
271#define MGSL_IOCGIF _IO(MGSL_MAGIC_IOC,11)
272
273#endif /* _SYNCLINK_H_ */
diff --git a/include/linux/sys.h b/include/linux/sys.h
new file mode 100644
index 000000000000..daa6008bfdc8
--- /dev/null
+++ b/include/linux/sys.h
@@ -0,0 +1,29 @@
1#ifndef _LINUX_SYS_H
2#define _LINUX_SYS_H
3
4/*
5 * This file is no longer used or needed
6 */
7
8/*
9 * These are system calls that will be removed at some time
10 * due to newer versions existing..
11 * (please be careful - ibcs2 may need some of these).
12 */
13#ifdef notdef
14#define _sys_waitpid _sys_old_syscall /* _sys_wait4 */
15#define _sys_olduname _sys_old_syscall /* _sys_newuname */
16#define _sys_uname _sys_old_syscall /* _sys_newuname */
17#define _sys_stat _sys_old_syscall /* _sys_newstat */
18#define _sys_fstat _sys_old_syscall /* _sys_newfstat */
19#define _sys_lstat _sys_old_syscall /* _sys_newlstat */
20#define _sys_signal _sys_old_syscall /* _sys_sigaction */
21#define _sys_sgetmask _sys_old_syscall /* _sys_sigprocmask */
22#define _sys_ssetmask _sys_old_syscall /* _sys_sigprocmask */
23#endif
24
25/*
26 * These are system calls that haven't been implemented yet
27 * but have an entry in the table for future expansion..
28 */
29#endif
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
new file mode 100644
index 000000000000..757cd9be7743
--- /dev/null
+++ b/include/linux/syscalls.h
@@ -0,0 +1,509 @@
1/*
2 * syscalls.h - Linux syscall interfaces (non-arch-specific)
3 *
4 * Copyright (c) 2004 Randy Dunlap
5 * Copyright (c) 2004 Open Source Development Labs
6 *
7 * This file is released under the GPLv2.
8 * See the file COPYING for more details.
9 */
10
11#ifndef _LINUX_SYSCALLS_H
12#define _LINUX_SYSCALLS_H
13
14struct epoll_event;
15struct iattr;
16struct inode;
17struct iocb;
18struct io_event;
19struct iovec;
20struct itimerspec;
21struct itimerval;
22struct kexec_segment;
23struct linux_dirent;
24struct linux_dirent64;
25struct list_head;
26struct msgbuf;
27struct msghdr;
28struct msqid_ds;
29struct new_utsname;
30struct nfsctl_arg;
31struct __old_kernel_stat;
32struct pollfd;
33struct rlimit;
34struct rusage;
35struct sched_param;
36struct semaphore;
37struct sembuf;
38struct shmid_ds;
39struct sockaddr;
40struct stat;
41struct stat64;
42struct statfs;
43struct statfs64;
44struct __sysctl_args;
45struct sysinfo;
46struct timespec;
47struct timeval;
48struct timex;
49struct timezone;
50struct tms;
51struct utimbuf;
52struct mq_attr;
53
54#include <linux/config.h>
55#include <linux/types.h>
56#include <linux/aio_abi.h>
57#include <linux/capability.h>
58#include <linux/list.h>
59#include <linux/sem.h>
60#include <asm/semaphore.h>
61#include <asm/siginfo.h>
62#include <asm/signal.h>
63#include <linux/quota.h>
64#include <linux/key.h>
65
66asmlinkage long sys_time(time_t __user *tloc);
67asmlinkage long sys_stime(time_t __user *tptr);
68asmlinkage long sys_gettimeofday(struct timeval __user *tv,
69 struct timezone __user *tz);
70asmlinkage long sys_settimeofday(struct timeval __user *tv,
71 struct timezone __user *tz);
72asmlinkage long sys_adjtimex(struct timex __user *txc_p);
73
74asmlinkage long sys_times(struct tms __user *tbuf);
75
76asmlinkage long sys_gettid(void);
77asmlinkage long sys_nanosleep(struct timespec __user *rqtp, struct timespec __user *rmtp);
78asmlinkage unsigned long sys_alarm(unsigned int seconds);
79asmlinkage long sys_getpid(void);
80asmlinkage long sys_getppid(void);
81asmlinkage long sys_getuid(void);
82asmlinkage long sys_geteuid(void);
83asmlinkage long sys_getgid(void);
84asmlinkage long sys_getegid(void);
85asmlinkage long sys_getresuid(uid_t __user *ruid, uid_t __user *euid, uid_t __user *suid);
86asmlinkage long sys_getresgid(gid_t __user *rgid, gid_t __user *egid, gid_t __user *sgid);
87asmlinkage long sys_getpgid(pid_t pid);
88asmlinkage long sys_getpgrp(void);
89asmlinkage long sys_getsid(pid_t pid);
90asmlinkage long sys_getgroups(int gidsetsize, gid_t __user *grouplist);
91
92asmlinkage long sys_setregid(gid_t rgid, gid_t egid);
93asmlinkage long sys_setgid(gid_t gid);
94asmlinkage long sys_setreuid(uid_t ruid, uid_t euid);
95asmlinkage long sys_setuid(uid_t uid);
96asmlinkage long sys_setresuid(uid_t ruid, uid_t euid, uid_t suid);
97asmlinkage long sys_setresgid(gid_t rgid, gid_t egid, gid_t sgid);
98asmlinkage long sys_setfsuid(uid_t uid);
99asmlinkage long sys_setfsgid(gid_t gid);
100asmlinkage long sys_setpgid(pid_t pid, pid_t pgid);
101asmlinkage long sys_setsid(void);
102asmlinkage long sys_setgroups(int gidsetsize, gid_t __user *grouplist);
103
104asmlinkage long sys_acct(const char __user *name);
105asmlinkage long sys_capget(cap_user_header_t header,
106 cap_user_data_t dataptr);
107asmlinkage long sys_capset(cap_user_header_t header,
108 const cap_user_data_t data);
109asmlinkage long sys_personality(u_long personality);
110
111asmlinkage long sys_sigpending(old_sigset_t __user *set);
112asmlinkage long sys_sigprocmask(int how, old_sigset_t __user *set,
113 old_sigset_t __user *oset);
114asmlinkage long sys_getitimer(int which, struct itimerval __user *value);
115asmlinkage long sys_setitimer(int which,
116 struct itimerval __user *value,
117 struct itimerval __user *ovalue);
118asmlinkage long sys_timer_create(clockid_t which_clock,
119 struct sigevent __user *timer_event_spec,
120 timer_t __user * created_timer_id);
121asmlinkage long sys_timer_gettime(timer_t timer_id,
122 struct itimerspec __user *setting);
123asmlinkage long sys_timer_getoverrun(timer_t timer_id);
124asmlinkage long sys_timer_settime(timer_t timer_id, int flags,
125 const struct itimerspec __user *new_setting,
126 struct itimerspec __user *old_setting);
127asmlinkage long sys_timer_delete(timer_t timer_id);
128asmlinkage long sys_clock_settime(clockid_t which_clock,
129 const struct timespec __user *tp);
130asmlinkage long sys_clock_gettime(clockid_t which_clock,
131 struct timespec __user *tp);
132asmlinkage long sys_clock_getres(clockid_t which_clock,
133 struct timespec __user *tp);
134asmlinkage long sys_clock_nanosleep(clockid_t which_clock, int flags,
135 const struct timespec __user *rqtp,
136 struct timespec __user *rmtp);
137
138asmlinkage long sys_nice(int increment);
139asmlinkage long sys_sched_setscheduler(pid_t pid, int policy,
140 struct sched_param __user *param);
141asmlinkage long sys_sched_setparam(pid_t pid,
142 struct sched_param __user *param);
143asmlinkage long sys_sched_getscheduler(pid_t pid);
144asmlinkage long sys_sched_getparam(pid_t pid,
145 struct sched_param __user *param);
146asmlinkage long sys_sched_setaffinity(pid_t pid, unsigned int len,
147 unsigned long __user *user_mask_ptr);
148asmlinkage long sys_sched_getaffinity(pid_t pid, unsigned int len,
149 unsigned long __user *user_mask_ptr);
150asmlinkage long sys_sched_yield(void);
151asmlinkage long sys_sched_get_priority_max(int policy);
152asmlinkage long sys_sched_get_priority_min(int policy);
153asmlinkage long sys_sched_rr_get_interval(pid_t pid,
154 struct timespec __user *interval);
155asmlinkage long sys_setpriority(int which, int who, int niceval);
156asmlinkage long sys_getpriority(int which, int who);
157
158asmlinkage long sys_shutdown(int, int);
159asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd,
160 void __user *arg);
161asmlinkage long sys_restart_syscall(void);
162asmlinkage long sys_kexec_load(void *entry, unsigned long nr_segments,
163 struct kexec_segment *segments, unsigned long flags);
164
165asmlinkage long sys_exit(int error_code);
166asmlinkage void sys_exit_group(int error_code);
167asmlinkage long sys_wait4(pid_t pid, int __user *stat_addr,
168 int options, struct rusage __user *ru);
169asmlinkage long sys_waitid(int which, pid_t pid,
170 struct siginfo __user *infop,
171 int options, struct rusage __user *ru);
172asmlinkage long sys_waitpid(pid_t pid, int __user *stat_addr, int options);
173asmlinkage long sys_set_tid_address(int __user *tidptr);
174asmlinkage long sys_futex(u32 __user *uaddr, int op, int val,
175 struct timespec __user *utime, u32 __user *uaddr2,
176 int val3);
177
178asmlinkage long sys_init_module(void __user *umod, unsigned long len,
179 const char __user *uargs);
180asmlinkage long sys_delete_module(const char __user *name_user,
181 unsigned int flags);
182
183asmlinkage long sys_rt_sigprocmask(int how, sigset_t __user *set,
184 sigset_t __user *oset, size_t sigsetsize);
185asmlinkage long sys_rt_sigpending(sigset_t __user *set, size_t sigsetsize);
186asmlinkage long sys_rt_sigtimedwait(const sigset_t __user *uthese,
187 siginfo_t __user *uinfo,
188 const struct timespec __user *uts,
189 size_t sigsetsize);
190asmlinkage long sys_kill(int pid, int sig);
191asmlinkage long sys_tgkill(int tgid, int pid, int sig);
192asmlinkage long sys_tkill(int pid, int sig);
193asmlinkage long sys_rt_sigqueueinfo(int pid, int sig, siginfo_t __user *uinfo);
194asmlinkage long sys_sgetmask(void);
195asmlinkage long sys_ssetmask(int newmask);
196asmlinkage unsigned long sys_signal(int sig, __sighandler_t handler);
197asmlinkage long sys_pause(void);
198
199asmlinkage long sys_sync(void);
200asmlinkage long sys_fsync(unsigned int fd);
201asmlinkage long sys_fdatasync(unsigned int fd);
202asmlinkage long sys_bdflush(int func, long data);
203asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
204 char __user *type, unsigned long flags,
205 void __user *data);
206asmlinkage long sys_umount(char __user *name, int flags);
207asmlinkage long sys_oldumount(char __user *name);
208asmlinkage long sys_truncate(const char __user *path,
209 unsigned long length);
210asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
211asmlinkage long sys_stat(char __user *filename,
212 struct __old_kernel_stat __user *statbuf);
213asmlinkage long sys_statfs(const char __user * path,
214 struct statfs __user *buf);
215asmlinkage long sys_statfs64(const char __user *path, size_t sz,
216 struct statfs64 __user *buf);
217asmlinkage long sys_fstatfs(unsigned int fd, struct statfs __user *buf);
218asmlinkage long sys_fstatfs64(unsigned int fd, size_t sz,
219 struct statfs64 __user *buf);
220asmlinkage long sys_lstat(char __user *filename,
221 struct __old_kernel_stat __user *statbuf);
222asmlinkage long sys_fstat(unsigned int fd,
223 struct __old_kernel_stat __user *statbuf);
224asmlinkage long sys_newstat(char __user *filename,
225 struct stat __user *statbuf);
226asmlinkage long sys_newlstat(char __user *filename,
227 struct stat __user *statbuf);
228asmlinkage long sys_newfstat(unsigned int fd, struct stat __user *statbuf);
229asmlinkage long sys_ustat(unsigned dev, struct ustat __user *ubuf);
230#if BITS_PER_LONG == 32
231asmlinkage long sys_stat64(char __user *filename,
232 struct stat64 __user *statbuf);
233asmlinkage long sys_fstat64(unsigned long fd, struct stat64 __user *statbuf);
234asmlinkage long sys_lstat64(char __user *filename,
235 struct stat64 __user *statbuf);
236asmlinkage long sys_truncate64(const char __user *path, loff_t length);
237asmlinkage long sys_ftruncate64(unsigned int fd, loff_t length);
238#endif
239
240asmlinkage long sys_setxattr(char __user *path, char __user *name,
241 void __user *value, size_t size, int flags);
242asmlinkage long sys_lsetxattr(char __user *path, char __user *name,
243 void __user *value, size_t size, int flags);
244asmlinkage long sys_fsetxattr(int fd, char __user *name, void __user *value,
245 size_t size, int flags);
246asmlinkage ssize_t sys_getxattr(char __user *path, char __user *name,
247 void __user *value, size_t size);
248asmlinkage ssize_t sys_lgetxattr(char __user *path, char __user *name,
249 void __user *value, size_t size);
250asmlinkage ssize_t sys_fgetxattr(int fd, char __user *name,
251 void __user *value, size_t size);
252asmlinkage ssize_t sys_listxattr(char __user *path, char __user *list,
253 size_t size);
254asmlinkage ssize_t sys_llistxattr(char __user *path, char __user *list,
255 size_t size);
256asmlinkage ssize_t sys_flistxattr(int fd, char __user *list, size_t size);
257asmlinkage long sys_removexattr(char __user *path, char __user *name);
258asmlinkage long sys_lremovexattr(char __user *path, char __user *name);
259asmlinkage long sys_fremovexattr(int fd, char __user *name);
260
261asmlinkage unsigned long sys_brk(unsigned long brk);
262asmlinkage long sys_mprotect(unsigned long start, size_t len,
263 unsigned long prot);
264asmlinkage unsigned long sys_mremap(unsigned long addr,
265 unsigned long old_len, unsigned long new_len,
266 unsigned long flags, unsigned long new_addr);
267asmlinkage long sys_remap_file_pages(unsigned long start, unsigned long size,
268 unsigned long prot, unsigned long pgoff,
269 unsigned long flags);
270asmlinkage long sys_msync(unsigned long start, size_t len, int flags);
271asmlinkage long sys_fadvise64(int fd, loff_t offset, size_t len, int advice);
272asmlinkage long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice);
273asmlinkage long sys_munmap(unsigned long addr, size_t len);
274asmlinkage long sys_mlock(unsigned long start, size_t len);
275asmlinkage long sys_munlock(unsigned long start, size_t len);
276asmlinkage long sys_mlockall(int flags);
277asmlinkage long sys_munlockall(void);
278asmlinkage long sys_madvise(unsigned long start, size_t len, int behavior);
279asmlinkage long sys_mincore(unsigned long start, size_t len,
280 unsigned char __user * vec);
281
282asmlinkage long sys_pivot_root(const char __user *new_root,
283 const char __user *put_old);
284asmlinkage long sys_chroot(const char __user *filename);
285asmlinkage long sys_mknod(const char __user *filename, int mode,
286 unsigned dev);
287asmlinkage long sys_link(const char __user *oldname,
288 const char __user *newname);
289asmlinkage long sys_symlink(const char __user *old, const char __user *new);
290asmlinkage long sys_unlink(const char __user *pathname);
291asmlinkage long sys_rename(const char __user *oldname,
292 const char __user *newname);
293asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
294asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
295
296asmlinkage long sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg);
297#if BITS_PER_LONG == 32
298asmlinkage long sys_fcntl64(unsigned int fd,
299 unsigned int cmd, unsigned long arg);
300#endif
301asmlinkage long sys_dup(unsigned int fildes);
302asmlinkage long sys_dup2(unsigned int oldfd, unsigned int newfd);
303asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int on);
304asmlinkage long sys_ioctl(unsigned int fd, unsigned int cmd,
305 unsigned long arg);
306asmlinkage long sys_flock(unsigned int fd, unsigned int cmd);
307asmlinkage long sys_io_setup(unsigned nr_reqs, aio_context_t __user *ctx);
308asmlinkage long sys_io_destroy(aio_context_t ctx);
309asmlinkage long sys_io_getevents(aio_context_t ctx_id,
310 long min_nr,
311 long nr,
312 struct io_event __user *events,
313 struct timespec __user *timeout);
314asmlinkage long sys_io_submit(aio_context_t, long,
315 struct iocb __user * __user *);
316asmlinkage long sys_io_cancel(aio_context_t ctx_id, struct iocb __user *iocb,
317 struct io_event __user *result);
318asmlinkage ssize_t sys_sendfile(int out_fd, int in_fd,
319 off_t __user *offset, size_t count);
320asmlinkage ssize_t sys_sendfile64(int out_fd, int in_fd,
321 loff_t __user *offset, size_t count);
322asmlinkage long sys_readlink(const char __user *path,
323 char __user *buf, int bufsiz);
324asmlinkage long sys_creat(const char __user *pathname, int mode);
325asmlinkage long sys_open(const char __user *filename,
326 int flags, int mode);
327asmlinkage long sys_close(unsigned int fd);
328asmlinkage long sys_access(const char __user *filename, int mode);
329asmlinkage long sys_vhangup(void);
330asmlinkage long sys_chown(const char __user *filename,
331 uid_t user, gid_t group);
332asmlinkage long sys_lchown(const char __user *filename,
333 uid_t user, gid_t group);
334asmlinkage long sys_fchown(unsigned int fd, uid_t user, gid_t group);
335#ifdef CONFIG_UID16
336asmlinkage long sys_chown16(const char __user *filename,
337 old_uid_t user, old_gid_t group);
338asmlinkage long sys_lchown16(const char __user *filename,
339 old_uid_t user, old_gid_t group);
340asmlinkage long sys_fchown16(unsigned int fd, old_uid_t user, old_gid_t group);
341asmlinkage long sys_setregid16(old_gid_t rgid, old_gid_t egid);
342asmlinkage long sys_setgid16(old_gid_t gid);
343asmlinkage long sys_setreuid16(old_uid_t ruid, old_uid_t euid);
344asmlinkage long sys_setuid16(old_uid_t uid);
345asmlinkage long sys_setresuid16(old_uid_t ruid, old_uid_t euid, old_uid_t suid);
346asmlinkage long sys_getresuid16(old_uid_t __user *ruid,
347 old_uid_t __user *euid, old_uid_t __user *suid);
348asmlinkage long sys_setresgid16(old_gid_t rgid, old_gid_t egid, old_gid_t sgid);
349asmlinkage long sys_getresgid16(old_gid_t __user *rgid,
350 old_gid_t __user *egid, old_gid_t __user *sgid);
351asmlinkage long sys_setfsuid16(old_uid_t uid);
352asmlinkage long sys_setfsgid16(old_gid_t gid);
353asmlinkage long sys_getgroups16(int gidsetsize, old_gid_t __user *grouplist);
354asmlinkage long sys_setgroups16(int gidsetsize, old_gid_t __user *grouplist);
355asmlinkage long sys_getuid16(void);
356asmlinkage long sys_geteuid16(void);
357asmlinkage long sys_getgid16(void);
358asmlinkage long sys_getegid16(void);
359#endif
360
361asmlinkage long sys_utime(char __user *filename,
362 struct utimbuf __user *times);
363asmlinkage long sys_utimes(char __user *filename,
364 struct timeval __user *utimes);
365asmlinkage off_t sys_lseek(unsigned int fd, off_t offset,
366 unsigned int origin);
367asmlinkage long sys_llseek(unsigned int fd, unsigned long offset_high,
368 unsigned long offset_low, loff_t __user *result,
369 unsigned int origin);
370asmlinkage ssize_t sys_read(unsigned int fd, char __user *buf,
371 size_t count);
372asmlinkage ssize_t sys_readahead(int fd, loff_t offset, size_t count);
373asmlinkage ssize_t sys_readv(unsigned long fd,
374 const struct iovec __user *vec,
375 unsigned long vlen);
376asmlinkage ssize_t sys_write(unsigned int fd, const char __user *buf,
377 size_t count);
378asmlinkage ssize_t sys_writev(unsigned long fd,
379 const struct iovec __user *vec,
380 unsigned long vlen);
381asmlinkage ssize_t sys_pread64(unsigned int fd, char __user *buf,
382 size_t count, loff_t pos);
383asmlinkage ssize_t sys_pwrite64(unsigned int fd, const char __user *buf,
384 size_t count, loff_t pos);
385asmlinkage long sys_getcwd(char __user *buf, unsigned long size);
386asmlinkage long sys_mkdir(const char __user *pathname, int mode);
387asmlinkage long sys_chdir(const char __user *filename);
388asmlinkage long sys_fchdir(unsigned int fd);
389asmlinkage long sys_rmdir(const char __user *pathname);
390asmlinkage long sys_lookup_dcookie(u64 cookie64, char __user *buf, size_t len);
391asmlinkage long sys_quotactl(unsigned int cmd, const char __user *special,
392 qid_t id, void __user *addr);
393asmlinkage long sys_getdents(unsigned int fd,
394 struct linux_dirent __user *dirent,
395 unsigned int count);
396asmlinkage long sys_getdents64(unsigned int fd,
397 struct linux_dirent64 __user *dirent,
398 unsigned int count);
399
400asmlinkage long sys_setsockopt(int fd, int level, int optname,
401 char __user *optval, int optlen);
402asmlinkage long sys_getsockopt(int fd, int level, int optname,
403 char __user *optval, int __user *optlen);
404asmlinkage long sys_bind(int, struct sockaddr __user *, int);
405asmlinkage long sys_connect(int, struct sockaddr __user *, int);
406asmlinkage long sys_accept(int, struct sockaddr __user *, int __user *);
407asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
408asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
409asmlinkage long sys_send(int, void __user *, size_t, unsigned);
410asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
411 struct sockaddr __user *, int);
412asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
413asmlinkage long sys_recv(int, void __user *, size_t, unsigned);
414asmlinkage long sys_recvfrom(int, void __user *, size_t, unsigned,
415 struct sockaddr __user *, int __user *);
416asmlinkage long sys_recvmsg(int fd, struct msghdr __user *msg, unsigned flags);
417asmlinkage long sys_socket(int, int, int);
418asmlinkage long sys_socketpair(int, int, int, int __user *);
419asmlinkage long sys_socketcall(int call, unsigned long __user *args);
420asmlinkage long sys_listen(int, int);
421asmlinkage long sys_poll(struct pollfd __user *ufds, unsigned int nfds,
422 long timeout);
423asmlinkage long sys_select(int n, fd_set __user *inp, fd_set __user *outp,
424 fd_set __user *exp, struct timeval __user *tvp);
425asmlinkage long sys_epoll_create(int size);
426asmlinkage long sys_epoll_ctl(int epfd, int op, int fd,
427 struct epoll_event __user *event);
428asmlinkage long sys_epoll_wait(int epfd, struct epoll_event __user *events,
429 int maxevents, int timeout);
430asmlinkage long sys_gethostname(char __user *name, int len);
431asmlinkage long sys_sethostname(char __user *name, int len);
432asmlinkage long sys_setdomainname(char __user *name, int len);
433asmlinkage long sys_newuname(struct new_utsname __user *name);
434
435asmlinkage long sys_getrlimit(unsigned int resource,
436 struct rlimit __user *rlim);
437#if defined(COMPAT_RLIM_OLD_INFINITY) || !(defined(CONFIG_IA64) || defined(CONFIG_V850))
438asmlinkage long sys_old_getrlimit(unsigned int resource, struct rlimit __user *rlim);
439#endif
440asmlinkage long sys_setrlimit(unsigned int resource,
441 struct rlimit __user *rlim);
442asmlinkage long sys_getrusage(int who, struct rusage __user *ru);
443asmlinkage long sys_umask(int mask);
444
445asmlinkage long sys_msgget(key_t key, int msgflg);
446asmlinkage long sys_msgsnd(int msqid, struct msgbuf __user *msgp,
447 size_t msgsz, int msgflg);
448asmlinkage long sys_msgrcv(int msqid, struct msgbuf __user *msgp,
449 size_t msgsz, long msgtyp, int msgflg);
450asmlinkage long sys_msgctl(int msqid, int cmd, struct msqid_ds __user *buf);
451
452asmlinkage long sys_semget(key_t key, int nsems, int semflg);
453asmlinkage long sys_semop(int semid, struct sembuf __user *sops,
454 unsigned nsops);
455asmlinkage long sys_semctl(int semid, int semnum, int cmd, union semun arg);
456asmlinkage long sys_semtimedop(int semid, struct sembuf __user *sops,
457 unsigned nsops,
458 const struct timespec __user *timeout);
459asmlinkage long sys_shmat(int shmid, char __user *shmaddr,
460 int shmflg, unsigned long __user *addr);
461asmlinkage long sys_shmget(key_t key, size_t size, int flag);
462asmlinkage long sys_shmdt(char __user *shmaddr);
463asmlinkage long sys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf);
464
465asmlinkage long sys_mq_open(const char __user *name, int oflag, mode_t mode, struct mq_attr __user *attr);
466asmlinkage long sys_mq_unlink(const char __user *name);
467asmlinkage long sys_mq_timedsend(mqd_t mqdes, const char __user *msg_ptr, size_t msg_len, unsigned int msg_prio, const struct timespec __user *abs_timeout);
468asmlinkage ssize_t sys_mq_timedreceive(mqd_t mqdes, char __user *msg_ptr, size_t msg_len, unsigned int __user *msg_prio, const struct timespec __user *abs_timeout);
469asmlinkage long sys_mq_notify(mqd_t mqdes, const struct sigevent __user *notification);
470asmlinkage long sys_mq_getsetattr(mqd_t mqdes, const struct mq_attr __user *mqstat, struct mq_attr __user *omqstat);
471
472asmlinkage long sys_pciconfig_iobase(long which, unsigned long bus, unsigned long devfn);
473asmlinkage long sys_pciconfig_read(unsigned long bus, unsigned long dfn,
474 unsigned long off, unsigned long len,
475 void __user *buf);
476asmlinkage long sys_pciconfig_write(unsigned long bus, unsigned long dfn,
477 unsigned long off, unsigned long len,
478 void __user *buf);
479
480asmlinkage long sys_prctl(int option, unsigned long arg2, unsigned long arg3,
481 unsigned long arg4, unsigned long arg5);
482asmlinkage long sys_swapon(const char __user *specialfile, int swap_flags);
483asmlinkage long sys_swapoff(const char __user *specialfile);
484asmlinkage long sys_sysctl(struct __sysctl_args __user *args);
485asmlinkage long sys_sysinfo(struct sysinfo __user *info);
486asmlinkage long sys_sysfs(int option,
487 unsigned long arg1, unsigned long arg2);
488asmlinkage long sys_nfsservctl(int cmd,
489 struct nfsctl_arg __user *arg,
490 void __user *res);
491asmlinkage long sys_syslog(int type, char __user *buf, int len);
492asmlinkage long sys_uselib(const char __user *library);
493asmlinkage long sys_ni_syscall(void);
494
495asmlinkage long sys_add_key(const char __user *_type,
496 const char __user *_description,
497 const void __user *_payload,
498 size_t plen,
499 key_serial_t destringid);
500
501asmlinkage long sys_request_key(const char __user *_type,
502 const char __user *_description,
503 const char __user *_callout_info,
504 key_serial_t destringid);
505
506asmlinkage long sys_keyctl(int cmd, unsigned long arg2, unsigned long arg3,
507 unsigned long arg4, unsigned long arg5);
508
509#endif
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
new file mode 100644
index 000000000000..358d52b0c445
--- /dev/null
+++ b/include/linux/sysctl.h
@@ -0,0 +1,898 @@
1/*
2 * sysctl.h: General linux system control interface
3 *
4 * Begun 24 March 1995, Stephen Tweedie
5 *
6 ****************************************************************
7 ****************************************************************
8 **
9 ** The values in this file are exported to user space via
10 ** the sysctl() binary interface. However this interface
11 ** is unstable and deprecated and will be removed in the future.
12 ** For a stable interface use /proc/sys.
13 **
14 ****************************************************************
15 ****************************************************************
16 */
17
18#ifndef _LINUX_SYSCTL_H
19#define _LINUX_SYSCTL_H
20
21#include <linux/kernel.h>
22#include <linux/types.h>
23#include <linux/list.h>
24#include <linux/compiler.h>
25
26struct file;
27
28#define CTL_MAXNAME 10 /* how many path components do we allow in a
29 call to sysctl? In other words, what is
30 the largest acceptable value for the nlen
31 member of a struct __sysctl_args to have? */
32
33struct __sysctl_args {
34 int __user *name;
35 int nlen;
36 void __user *oldval;
37 size_t __user *oldlenp;
38 void __user *newval;
39 size_t newlen;
40 unsigned long __unused[4];
41};
42
43/* Define sysctl names first */
44
45/* Top-level names: */
46
47/* For internal pattern-matching use only: */
48#ifdef __KERNEL__
49#define CTL_ANY -1 /* Matches any name */
50#define CTL_NONE 0
51#endif
52
53enum
54{
55 CTL_KERN=1, /* General kernel info and control */
56 CTL_VM=2, /* VM management */
57 CTL_NET=3, /* Networking */
58 CTL_PROC=4, /* Process info */
59 CTL_FS=5, /* Filesystems */
60 CTL_DEBUG=6, /* Debugging */
61 CTL_DEV=7, /* Devices */
62 CTL_BUS=8, /* Busses */
63 CTL_ABI=9, /* Binary emulation */
64 CTL_CPU=10 /* CPU stuff (speed scaling, etc) */
65};
66
67/* CTL_BUS names: */
68enum
69{
70 CTL_BUS_ISA=1 /* ISA */
71};
72
73/* CTL_KERN names: */
74enum
75{
76 KERN_OSTYPE=1, /* string: system version */
77 KERN_OSRELEASE=2, /* string: system release */
78 KERN_OSREV=3, /* int: system revision */
79 KERN_VERSION=4, /* string: compile time info */
80 KERN_SECUREMASK=5, /* struct: maximum rights mask */
81 KERN_PROF=6, /* table: profiling information */
82 KERN_NODENAME=7,
83 KERN_DOMAINNAME=8,
84
85 KERN_CAP_BSET=14, /* int: capability bounding set */
86 KERN_PANIC=15, /* int: panic timeout */
87 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
88
89 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
90 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
91 KERN_PRINTK=23, /* struct: control printk logging parameters */
92 KERN_NAMETRANS=24, /* Name translation */
93 KERN_PPC_HTABRECLAIM=25, /* turn htab reclaimation on/off on PPC */
94 KERN_PPC_ZEROPAGED=26, /* turn idle page zeroing on/off on PPC */
95 KERN_PPC_POWERSAVE_NAP=27, /* use nap mode for power saving */
96 KERN_MODPROBE=28,
97 KERN_SG_BIG_BUFF=29,
98 KERN_ACCT=30, /* BSD process accounting parameters */
99 KERN_PPC_L2CR=31, /* l2cr register on PPC */
100
101 KERN_RTSIGNR=32, /* Number of rt sigs queued */
102 KERN_RTSIGMAX=33, /* Max queuable */
103
104 KERN_SHMMAX=34, /* long: Maximum shared memory segment */
105 KERN_MSGMAX=35, /* int: Maximum size of a messege */
106 KERN_MSGMNB=36, /* int: Maximum message queue size */
107 KERN_MSGPOOL=37, /* int: Maximum system message pool size */
108 KERN_SYSRQ=38, /* int: Sysreq enable */
109 KERN_MAX_THREADS=39, /* int: Maximum nr of threads in the system */
110 KERN_RANDOM=40, /* Random driver */
111 KERN_SHMALL=41, /* int: Maximum size of shared memory */
112 KERN_MSGMNI=42, /* int: msg queue identifiers */
113 KERN_SEM=43, /* struct: sysv semaphore limits */
114 KERN_SPARC_STOP_A=44, /* int: Sparc Stop-A enable */
115 KERN_SHMMNI=45, /* int: shm array identifiers */
116 KERN_OVERFLOWUID=46, /* int: overflow UID */
117 KERN_OVERFLOWGID=47, /* int: overflow GID */
118 KERN_SHMPATH=48, /* string: path to shm fs */
119 KERN_HOTPLUG=49, /* string: path to hotplug policy agent */
120 KERN_IEEE_EMULATION_WARNINGS=50, /* int: unimplemented ieee instructions */
121 KERN_S390_USER_DEBUG_LOGGING=51, /* int: dumps of user faults */
122 KERN_CORE_USES_PID=52, /* int: use core or core.%pid */
123 KERN_TAINTED=53, /* int: various kernel tainted flags */
124 KERN_CADPID=54, /* int: PID of the process to notify on CAD */
125 KERN_PIDMAX=55, /* int: PID # limit */
126 KERN_CORE_PATTERN=56, /* string: pattern for core-file names */
127 KERN_PANIC_ON_OOPS=57, /* int: whether we will panic on an oops */
128 KERN_HPPA_PWRSW=58, /* int: hppa soft-power enable */
129 KERN_HPPA_UNALIGNED=59, /* int: hppa unaligned-trap enable */
130 KERN_PRINTK_RATELIMIT=60, /* int: tune printk ratelimiting */
131 KERN_PRINTK_RATELIMIT_BURST=61, /* int: tune printk ratelimiting */
132 KERN_PTY=62, /* dir: pty driver */
133 KERN_NGROUPS_MAX=63, /* int: NGROUPS_MAX */
134 KERN_SPARC_SCONS_PWROFF=64, /* int: serial console power-off halt */
135 KERN_HZ_TIMER=65, /* int: hz timer on or off */
136 KERN_UNKNOWN_NMI_PANIC=66, /* int: unknown nmi panic flag */
137 KERN_BOOTLOADER_TYPE=67, /* int: boot loader type */
138 KERN_RANDOMIZE=68, /* int: randomize virtual address space */
139};
140
141
142/* CTL_VM names: */
143enum
144{
145 VM_UNUSED1=1, /* was: struct: Set vm swapping control */
146 VM_UNUSED2=2, /* was; int: Linear or sqrt() swapout for hogs */
147 VM_UNUSED3=3, /* was: struct: Set free page thresholds */
148 VM_UNUSED4=4, /* Spare */
149 VM_OVERCOMMIT_MEMORY=5, /* Turn off the virtual memory safety limit */
150 VM_UNUSED5=6, /* was: struct: Set buffer memory thresholds */
151 VM_UNUSED7=7, /* was: struct: Set cache memory thresholds */
152 VM_UNUSED8=8, /* was: struct: Control kswapd behaviour */
153 VM_UNUSED9=9, /* was: struct: Set page table cache parameters */
154 VM_PAGE_CLUSTER=10, /* int: set number of pages to swap together */
155 VM_DIRTY_BACKGROUND=11, /* dirty_background_ratio */
156 VM_DIRTY_RATIO=12, /* dirty_ratio */
157 VM_DIRTY_WB_CS=13, /* dirty_writeback_centisecs */
158 VM_DIRTY_EXPIRE_CS=14, /* dirty_expire_centisecs */
159 VM_NR_PDFLUSH_THREADS=15, /* nr_pdflush_threads */
160 VM_OVERCOMMIT_RATIO=16, /* percent of RAM to allow overcommit in */
161 VM_PAGEBUF=17, /* struct: Control pagebuf parameters */
162 VM_HUGETLB_PAGES=18, /* int: Number of available Huge Pages */
163 VM_SWAPPINESS=19, /* Tendency to steal mapped memory */
164 VM_LOWMEM_RESERVE_RATIO=20,/* reservation ratio for lower memory zones */
165 VM_MIN_FREE_KBYTES=21, /* Minimum free kilobytes to maintain */
166 VM_MAX_MAP_COUNT=22, /* int: Maximum number of mmaps/address-space */
167 VM_LAPTOP_MODE=23, /* vm laptop mode */
168 VM_BLOCK_DUMP=24, /* block dump mode */
169 VM_HUGETLB_GROUP=25, /* permitted hugetlb group */
170 VM_VFS_CACHE_PRESSURE=26, /* dcache/icache reclaim pressure */
171 VM_LEGACY_VA_LAYOUT=27, /* legacy/compatibility virtual address space layout */
172 VM_SWAP_TOKEN_TIMEOUT=28, /* default time for token time out */
173};
174
175
176/* CTL_NET names: */
177enum
178{
179 NET_CORE=1,
180 NET_ETHER=2,
181 NET_802=3,
182 NET_UNIX=4,
183 NET_IPV4=5,
184 NET_IPX=6,
185 NET_ATALK=7,
186 NET_NETROM=8,
187 NET_AX25=9,
188 NET_BRIDGE=10,
189 NET_ROSE=11,
190 NET_IPV6=12,
191 NET_X25=13,
192 NET_TR=14,
193 NET_DECNET=15,
194 NET_ECONET=16,
195 NET_SCTP=17,
196};
197
198/* /proc/sys/kernel/random */
199enum
200{
201 RANDOM_POOLSIZE=1,
202 RANDOM_ENTROPY_COUNT=2,
203 RANDOM_READ_THRESH=3,
204 RANDOM_WRITE_THRESH=4,
205 RANDOM_BOOT_ID=5,
206 RANDOM_UUID=6
207};
208
209/* /proc/sys/kernel/pty */
210enum
211{
212 PTY_MAX=1,
213 PTY_NR=2
214};
215
216/* /proc/sys/bus/isa */
217enum
218{
219 BUS_ISA_MEM_BASE=1,
220 BUS_ISA_PORT_BASE=2,
221 BUS_ISA_PORT_SHIFT=3
222};
223
224/* /proc/sys/net/core */
225enum
226{
227 NET_CORE_WMEM_MAX=1,
228 NET_CORE_RMEM_MAX=2,
229 NET_CORE_WMEM_DEFAULT=3,
230 NET_CORE_RMEM_DEFAULT=4,
231/* was NET_CORE_DESTROY_DELAY */
232 NET_CORE_MAX_BACKLOG=6,
233 NET_CORE_FASTROUTE=7,
234 NET_CORE_MSG_COST=8,
235 NET_CORE_MSG_BURST=9,
236 NET_CORE_OPTMEM_MAX=10,
237 NET_CORE_HOT_LIST_LENGTH=11,
238 NET_CORE_DIVERT_VERSION=12,
239 NET_CORE_NO_CONG_THRESH=13,
240 NET_CORE_NO_CONG=14,
241 NET_CORE_LO_CONG=15,
242 NET_CORE_MOD_CONG=16,
243 NET_CORE_DEV_WEIGHT=17,
244 NET_CORE_SOMAXCONN=18,
245};
246
247/* /proc/sys/net/ethernet */
248
249/* /proc/sys/net/802 */
250
251/* /proc/sys/net/unix */
252
253enum
254{
255 NET_UNIX_DESTROY_DELAY=1,
256 NET_UNIX_DELETE_DELAY=2,
257 NET_UNIX_MAX_DGRAM_QLEN=3,
258};
259
260/* /proc/sys/net/ipv4 */
261enum
262{
263 /* v2.0 compatibile variables */
264 NET_IPV4_FORWARD=8,
265 NET_IPV4_DYNADDR=9,
266
267 NET_IPV4_CONF=16,
268 NET_IPV4_NEIGH=17,
269 NET_IPV4_ROUTE=18,
270 NET_IPV4_FIB_HASH=19,
271 NET_IPV4_NETFILTER=20,
272
273 NET_IPV4_TCP_TIMESTAMPS=33,
274 NET_IPV4_TCP_WINDOW_SCALING=34,
275 NET_IPV4_TCP_SACK=35,
276 NET_IPV4_TCP_RETRANS_COLLAPSE=36,
277 NET_IPV4_DEFAULT_TTL=37,
278 NET_IPV4_AUTOCONFIG=38,
279 NET_IPV4_NO_PMTU_DISC=39,
280 NET_IPV4_TCP_SYN_RETRIES=40,
281 NET_IPV4_IPFRAG_HIGH_THRESH=41,
282 NET_IPV4_IPFRAG_LOW_THRESH=42,
283 NET_IPV4_IPFRAG_TIME=43,
284 NET_IPV4_TCP_MAX_KA_PROBES=44,
285 NET_IPV4_TCP_KEEPALIVE_TIME=45,
286 NET_IPV4_TCP_KEEPALIVE_PROBES=46,
287 NET_IPV4_TCP_RETRIES1=47,
288 NET_IPV4_TCP_RETRIES2=48,
289 NET_IPV4_TCP_FIN_TIMEOUT=49,
290 NET_IPV4_IP_MASQ_DEBUG=50,
291 NET_TCP_SYNCOOKIES=51,
292 NET_TCP_STDURG=52,
293 NET_TCP_RFC1337=53,
294 NET_TCP_SYN_TAILDROP=54,
295 NET_TCP_MAX_SYN_BACKLOG=55,
296 NET_IPV4_LOCAL_PORT_RANGE=56,
297 NET_IPV4_ICMP_ECHO_IGNORE_ALL=57,
298 NET_IPV4_ICMP_ECHO_IGNORE_BROADCASTS=58,
299 NET_IPV4_ICMP_SOURCEQUENCH_RATE=59,
300 NET_IPV4_ICMP_DESTUNREACH_RATE=60,
301 NET_IPV4_ICMP_TIMEEXCEED_RATE=61,
302 NET_IPV4_ICMP_PARAMPROB_RATE=62,
303 NET_IPV4_ICMP_ECHOREPLY_RATE=63,
304 NET_IPV4_ICMP_IGNORE_BOGUS_ERROR_RESPONSES=64,
305 NET_IPV4_IGMP_MAX_MEMBERSHIPS=65,
306 NET_TCP_TW_RECYCLE=66,
307 NET_IPV4_ALWAYS_DEFRAG=67,
308 NET_IPV4_TCP_KEEPALIVE_INTVL=68,
309 NET_IPV4_INET_PEER_THRESHOLD=69,
310 NET_IPV4_INET_PEER_MINTTL=70,
311 NET_IPV4_INET_PEER_MAXTTL=71,
312 NET_IPV4_INET_PEER_GC_MINTIME=72,
313 NET_IPV4_INET_PEER_GC_MAXTIME=73,
314 NET_TCP_ORPHAN_RETRIES=74,
315 NET_TCP_ABORT_ON_OVERFLOW=75,
316 NET_TCP_SYNACK_RETRIES=76,
317 NET_TCP_MAX_ORPHANS=77,
318 NET_TCP_MAX_TW_BUCKETS=78,
319 NET_TCP_FACK=79,
320 NET_TCP_REORDERING=80,
321 NET_TCP_ECN=81,
322 NET_TCP_DSACK=82,
323 NET_TCP_MEM=83,
324 NET_TCP_WMEM=84,
325 NET_TCP_RMEM=85,
326 NET_TCP_APP_WIN=86,
327 NET_TCP_ADV_WIN_SCALE=87,
328 NET_IPV4_NONLOCAL_BIND=88,
329 NET_IPV4_ICMP_RATELIMIT=89,
330 NET_IPV4_ICMP_RATEMASK=90,
331 NET_TCP_TW_REUSE=91,
332 NET_TCP_FRTO=92,
333 NET_TCP_LOW_LATENCY=93,
334 NET_IPV4_IPFRAG_SECRET_INTERVAL=94,
335 NET_TCP_WESTWOOD=95,
336 NET_IPV4_IGMP_MAX_MSF=96,
337 NET_TCP_NO_METRICS_SAVE=97,
338 NET_TCP_VEGAS=98,
339 NET_TCP_VEGAS_ALPHA=99,
340 NET_TCP_VEGAS_BETA=100,
341 NET_TCP_VEGAS_GAMMA=101,
342 NET_TCP_BIC=102,
343 NET_TCP_BIC_FAST_CONVERGENCE=103,
344 NET_TCP_BIC_LOW_WINDOW=104,
345 NET_TCP_DEFAULT_WIN_SCALE=105,
346 NET_TCP_MODERATE_RCVBUF=106,
347 NET_TCP_TSO_WIN_DIVISOR=107,
348 NET_TCP_BIC_BETA=108,
349};
350
351enum {
352 NET_IPV4_ROUTE_FLUSH=1,
353 NET_IPV4_ROUTE_MIN_DELAY=2,
354 NET_IPV4_ROUTE_MAX_DELAY=3,
355 NET_IPV4_ROUTE_GC_THRESH=4,
356 NET_IPV4_ROUTE_MAX_SIZE=5,
357 NET_IPV4_ROUTE_GC_MIN_INTERVAL=6,
358 NET_IPV4_ROUTE_GC_TIMEOUT=7,
359 NET_IPV4_ROUTE_GC_INTERVAL=8,
360 NET_IPV4_ROUTE_REDIRECT_LOAD=9,
361 NET_IPV4_ROUTE_REDIRECT_NUMBER=10,
362 NET_IPV4_ROUTE_REDIRECT_SILENCE=11,
363 NET_IPV4_ROUTE_ERROR_COST=12,
364 NET_IPV4_ROUTE_ERROR_BURST=13,
365 NET_IPV4_ROUTE_GC_ELASTICITY=14,
366 NET_IPV4_ROUTE_MTU_EXPIRES=15,
367 NET_IPV4_ROUTE_MIN_PMTU=16,
368 NET_IPV4_ROUTE_MIN_ADVMSS=17,
369 NET_IPV4_ROUTE_SECRET_INTERVAL=18,
370 NET_IPV4_ROUTE_GC_MIN_INTERVAL_MS=19,
371};
372
373enum
374{
375 NET_PROTO_CONF_ALL=-2,
376 NET_PROTO_CONF_DEFAULT=-3
377
378 /* And device ifindices ... */
379};
380
381enum
382{
383 NET_IPV4_CONF_FORWARDING=1,
384 NET_IPV4_CONF_MC_FORWARDING=2,
385 NET_IPV4_CONF_PROXY_ARP=3,
386 NET_IPV4_CONF_ACCEPT_REDIRECTS=4,
387 NET_IPV4_CONF_SECURE_REDIRECTS=5,
388 NET_IPV4_CONF_SEND_REDIRECTS=6,
389 NET_IPV4_CONF_SHARED_MEDIA=7,
390 NET_IPV4_CONF_RP_FILTER=8,
391 NET_IPV4_CONF_ACCEPT_SOURCE_ROUTE=9,
392 NET_IPV4_CONF_BOOTP_RELAY=10,
393 NET_IPV4_CONF_LOG_MARTIANS=11,
394 NET_IPV4_CONF_TAG=12,
395 NET_IPV4_CONF_ARPFILTER=13,
396 NET_IPV4_CONF_MEDIUM_ID=14,
397 NET_IPV4_CONF_NOXFRM=15,
398 NET_IPV4_CONF_NOPOLICY=16,
399 NET_IPV4_CONF_FORCE_IGMP_VERSION=17,
400 NET_IPV4_CONF_ARP_ANNOUNCE=18,
401 NET_IPV4_CONF_ARP_IGNORE=19,
402 __NET_IPV4_CONF_MAX
403};
404
405/* /proc/sys/net/ipv4/netfilter */
406enum
407{
408 NET_IPV4_NF_CONNTRACK_MAX=1,
409 NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_SYN_SENT=2,
410 NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_SYN_RECV=3,
411 NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_ESTABLISHED=4,
412 NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_FIN_WAIT=5,
413 NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_CLOSE_WAIT=6,
414 NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_LAST_ACK=7,
415 NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_TIME_WAIT=8,
416 NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_CLOSE=9,
417 NET_IPV4_NF_CONNTRACK_UDP_TIMEOUT=10,
418 NET_IPV4_NF_CONNTRACK_UDP_TIMEOUT_STREAM=11,
419 NET_IPV4_NF_CONNTRACK_ICMP_TIMEOUT=12,
420 NET_IPV4_NF_CONNTRACK_GENERIC_TIMEOUT=13,
421 NET_IPV4_NF_CONNTRACK_BUCKETS=14,
422 NET_IPV4_NF_CONNTRACK_LOG_INVALID=15,
423 NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_MAX_RETRANS=16,
424 NET_IPV4_NF_CONNTRACK_TCP_LOOSE=17,
425 NET_IPV4_NF_CONNTRACK_TCP_BE_LIBERAL=18,
426 NET_IPV4_NF_CONNTRACK_TCP_MAX_RETRANS=19,
427 NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_CLOSED=20,
428 NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_COOKIE_WAIT=21,
429 NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_COOKIE_ECHOED=22,
430 NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_ESTABLISHED=23,
431 NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_SENT=24,
432 NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_RECD=25,
433 NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_ACK_SENT=26,
434 NET_IPV4_NF_CONNTRACK_COUNT=27,
435};
436
437/* /proc/sys/net/ipv6 */
438enum {
439 NET_IPV6_CONF=16,
440 NET_IPV6_NEIGH=17,
441 NET_IPV6_ROUTE=18,
442 NET_IPV6_ICMP=19,
443 NET_IPV6_BINDV6ONLY=20,
444 NET_IPV6_IP6FRAG_HIGH_THRESH=21,
445 NET_IPV6_IP6FRAG_LOW_THRESH=22,
446 NET_IPV6_IP6FRAG_TIME=23,
447 NET_IPV6_IP6FRAG_SECRET_INTERVAL=24,
448 NET_IPV6_MLD_MAX_MSF=25,
449};
450
451enum {
452 NET_IPV6_ROUTE_FLUSH=1,
453 NET_IPV6_ROUTE_GC_THRESH=2,
454 NET_IPV6_ROUTE_MAX_SIZE=3,
455 NET_IPV6_ROUTE_GC_MIN_INTERVAL=4,
456 NET_IPV6_ROUTE_GC_TIMEOUT=5,
457 NET_IPV6_ROUTE_GC_INTERVAL=6,
458 NET_IPV6_ROUTE_GC_ELASTICITY=7,
459 NET_IPV6_ROUTE_MTU_EXPIRES=8,
460 NET_IPV6_ROUTE_MIN_ADVMSS=9,
461 NET_IPV6_ROUTE_GC_MIN_INTERVAL_MS=10
462};
463
464enum {
465 NET_IPV6_FORWARDING=1,
466 NET_IPV6_HOP_LIMIT=2,
467 NET_IPV6_MTU=3,
468 NET_IPV6_ACCEPT_RA=4,
469 NET_IPV6_ACCEPT_REDIRECTS=5,
470 NET_IPV6_AUTOCONF=6,
471 NET_IPV6_DAD_TRANSMITS=7,
472 NET_IPV6_RTR_SOLICITS=8,
473 NET_IPV6_RTR_SOLICIT_INTERVAL=9,
474 NET_IPV6_RTR_SOLICIT_DELAY=10,
475 NET_IPV6_USE_TEMPADDR=11,
476 NET_IPV6_TEMP_VALID_LFT=12,
477 NET_IPV6_TEMP_PREFERED_LFT=13,
478 NET_IPV6_REGEN_MAX_RETRY=14,
479 NET_IPV6_MAX_DESYNC_FACTOR=15,
480 NET_IPV6_MAX_ADDRESSES=16,
481 NET_IPV6_FORCE_MLD_VERSION=17,
482 __NET_IPV6_MAX
483};
484
485/* /proc/sys/net/ipv6/icmp */
486enum {
487 NET_IPV6_ICMP_RATELIMIT=1
488};
489
490/* /proc/sys/net/<protocol>/neigh/<dev> */
491enum {
492 NET_NEIGH_MCAST_SOLICIT=1,
493 NET_NEIGH_UCAST_SOLICIT=2,
494 NET_NEIGH_APP_SOLICIT=3,
495 NET_NEIGH_RETRANS_TIME=4,
496 NET_NEIGH_REACHABLE_TIME=5,
497 NET_NEIGH_DELAY_PROBE_TIME=6,
498 NET_NEIGH_GC_STALE_TIME=7,
499 NET_NEIGH_UNRES_QLEN=8,
500 NET_NEIGH_PROXY_QLEN=9,
501 NET_NEIGH_ANYCAST_DELAY=10,
502 NET_NEIGH_PROXY_DELAY=11,
503 NET_NEIGH_LOCKTIME=12,
504 NET_NEIGH_GC_INTERVAL=13,
505 NET_NEIGH_GC_THRESH1=14,
506 NET_NEIGH_GC_THRESH2=15,
507 NET_NEIGH_GC_THRESH3=16,
508 NET_NEIGH_RETRANS_TIME_MS=17,
509 NET_NEIGH_REACHABLE_TIME_MS=18,
510 __NET_NEIGH_MAX
511};
512
513/* /proc/sys/net/ipx */
514enum {
515 NET_IPX_PPROP_BROADCASTING=1,
516 NET_IPX_FORWARDING=2
517};
518
519
520/* /proc/sys/net/appletalk */
521enum {
522 NET_ATALK_AARP_EXPIRY_TIME=1,
523 NET_ATALK_AARP_TICK_TIME=2,
524 NET_ATALK_AARP_RETRANSMIT_LIMIT=3,
525 NET_ATALK_AARP_RESOLVE_TIME=4
526};
527
528
529/* /proc/sys/net/netrom */
530enum {
531 NET_NETROM_DEFAULT_PATH_QUALITY=1,
532 NET_NETROM_OBSOLESCENCE_COUNT_INITIALISER=2,
533 NET_NETROM_NETWORK_TTL_INITIALISER=3,
534 NET_NETROM_TRANSPORT_TIMEOUT=4,
535 NET_NETROM_TRANSPORT_MAXIMUM_TRIES=5,
536 NET_NETROM_TRANSPORT_ACKNOWLEDGE_DELAY=6,
537 NET_NETROM_TRANSPORT_BUSY_DELAY=7,
538 NET_NETROM_TRANSPORT_REQUESTED_WINDOW_SIZE=8,
539 NET_NETROM_TRANSPORT_NO_ACTIVITY_TIMEOUT=9,
540 NET_NETROM_ROUTING_CONTROL=10,
541 NET_NETROM_LINK_FAILS_COUNT=11
542};
543
544/* /proc/sys/net/ax25 */
545enum {
546 NET_AX25_IP_DEFAULT_MODE=1,
547 NET_AX25_DEFAULT_MODE=2,
548 NET_AX25_BACKOFF_TYPE=3,
549 NET_AX25_CONNECT_MODE=4,
550 NET_AX25_STANDARD_WINDOW=5,
551 NET_AX25_EXTENDED_WINDOW=6,
552 NET_AX25_T1_TIMEOUT=7,
553 NET_AX25_T2_TIMEOUT=8,
554 NET_AX25_T3_TIMEOUT=9,
555 NET_AX25_IDLE_TIMEOUT=10,
556 NET_AX25_N2=11,
557 NET_AX25_PACLEN=12,
558 NET_AX25_PROTOCOL=13,
559 NET_AX25_DAMA_SLAVE_TIMEOUT=14
560};
561
562/* /proc/sys/net/rose */
563enum {
564 NET_ROSE_RESTART_REQUEST_TIMEOUT=1,
565 NET_ROSE_CALL_REQUEST_TIMEOUT=2,
566 NET_ROSE_RESET_REQUEST_TIMEOUT=3,
567 NET_ROSE_CLEAR_REQUEST_TIMEOUT=4,
568 NET_ROSE_ACK_HOLD_BACK_TIMEOUT=5,
569 NET_ROSE_ROUTING_CONTROL=6,
570 NET_ROSE_LINK_FAIL_TIMEOUT=7,
571 NET_ROSE_MAX_VCS=8,
572 NET_ROSE_WINDOW_SIZE=9,
573 NET_ROSE_NO_ACTIVITY_TIMEOUT=10
574};
575
576/* /proc/sys/net/x25 */
577enum {
578 NET_X25_RESTART_REQUEST_TIMEOUT=1,
579 NET_X25_CALL_REQUEST_TIMEOUT=2,
580 NET_X25_RESET_REQUEST_TIMEOUT=3,
581 NET_X25_CLEAR_REQUEST_TIMEOUT=4,
582 NET_X25_ACK_HOLD_BACK_TIMEOUT=5
583};
584
585/* /proc/sys/net/token-ring */
586enum
587{
588 NET_TR_RIF_TIMEOUT=1
589};
590
591/* /proc/sys/net/decnet/ */
592enum {
593 NET_DECNET_NODE_TYPE = 1,
594 NET_DECNET_NODE_ADDRESS = 2,
595 NET_DECNET_NODE_NAME = 3,
596 NET_DECNET_DEFAULT_DEVICE = 4,
597 NET_DECNET_TIME_WAIT = 5,
598 NET_DECNET_DN_COUNT = 6,
599 NET_DECNET_DI_COUNT = 7,
600 NET_DECNET_DR_COUNT = 8,
601 NET_DECNET_DST_GC_INTERVAL = 9,
602 NET_DECNET_CONF = 10,
603 NET_DECNET_NO_FC_MAX_CWND = 11,
604 NET_DECNET_DEBUG_LEVEL = 255
605};
606
607/* /proc/sys/net/decnet/conf/<dev> */
608enum {
609 NET_DECNET_CONF_LOOPBACK = -2,
610 NET_DECNET_CONF_DDCMP = -3,
611 NET_DECNET_CONF_PPP = -4,
612 NET_DECNET_CONF_X25 = -5,
613 NET_DECNET_CONF_GRE = -6,
614 NET_DECNET_CONF_ETHER = -7
615
616 /* ... and ifindex of devices */
617};
618
619/* /proc/sys/net/decnet/conf/<dev>/ */
620enum {
621 NET_DECNET_CONF_DEV_PRIORITY = 1,
622 NET_DECNET_CONF_DEV_T1 = 2,
623 NET_DECNET_CONF_DEV_T2 = 3,
624 NET_DECNET_CONF_DEV_T3 = 4,
625 NET_DECNET_CONF_DEV_FORWARDING = 5,
626 NET_DECNET_CONF_DEV_BLKSIZE = 6,
627 NET_DECNET_CONF_DEV_STATE = 7
628};
629
630/* /proc/sys/net/sctp */
631enum {
632 NET_SCTP_RTO_INITIAL = 1,
633 NET_SCTP_RTO_MIN = 2,
634 NET_SCTP_RTO_MAX = 3,
635 NET_SCTP_RTO_ALPHA = 4,
636 NET_SCTP_RTO_BETA = 5,
637 NET_SCTP_VALID_COOKIE_LIFE = 6,
638 NET_SCTP_ASSOCIATION_MAX_RETRANS = 7,
639 NET_SCTP_PATH_MAX_RETRANS = 8,
640 NET_SCTP_MAX_INIT_RETRANSMITS = 9,
641 NET_SCTP_HB_INTERVAL = 10,
642 NET_SCTP_PRESERVE_ENABLE = 11,
643 NET_SCTP_MAX_BURST = 12,
644 NET_SCTP_ADDIP_ENABLE = 13,
645 NET_SCTP_PRSCTP_ENABLE = 14,
646};
647
648/* /proc/sys/net/bridge */
649enum {
650 NET_BRIDGE_NF_CALL_ARPTABLES = 1,
651 NET_BRIDGE_NF_CALL_IPTABLES = 2,
652 NET_BRIDGE_NF_CALL_IP6TABLES = 3,
653 NET_BRIDGE_NF_FILTER_VLAN_TAGGED = 4,
654};
655
656/* CTL_PROC names: */
657
658/* CTL_FS names: */
659enum
660{
661 FS_NRINODE=1, /* int:current number of allocated inodes */
662 FS_STATINODE=2,
663 FS_MAXINODE=3, /* int:maximum number of inodes that can be allocated */
664 FS_NRDQUOT=4, /* int:current number of allocated dquots */
665 FS_MAXDQUOT=5, /* int:maximum number of dquots that can be allocated */
666 FS_NRFILE=6, /* int:current number of allocated filedescriptors */
667 FS_MAXFILE=7, /* int:maximum number of filedescriptors that can be allocated */
668 FS_DENTRY=8,
669 FS_NRSUPER=9, /* int:current number of allocated super_blocks */
670 FS_MAXSUPER=10, /* int:maximum number of super_blocks that can be allocated */
671 FS_OVERFLOWUID=11, /* int: overflow UID */
672 FS_OVERFLOWGID=12, /* int: overflow GID */
673 FS_LEASES=13, /* int: leases enabled */
674 FS_DIR_NOTIFY=14, /* int: directory notification enabled */
675 FS_LEASE_TIME=15, /* int: maximum time to wait for a lease break */
676 FS_DQSTATS=16, /* disc quota usage statistics and control */
677 FS_XFS=17, /* struct: control xfs parameters */
678 FS_AIO_NR=18, /* current system-wide number of aio requests */
679 FS_AIO_MAX_NR=19, /* system-wide maximum number of aio requests */
680};
681
682/* /proc/sys/fs/quota/ */
683enum {
684 FS_DQ_LOOKUPS = 1,
685 FS_DQ_DROPS = 2,
686 FS_DQ_READS = 3,
687 FS_DQ_WRITES = 4,
688 FS_DQ_CACHE_HITS = 5,
689 FS_DQ_ALLOCATED = 6,
690 FS_DQ_FREE = 7,
691 FS_DQ_SYNCS = 8,
692 FS_DQ_WARNINGS = 9,
693};
694
695/* CTL_DEBUG names: */
696
697/* CTL_DEV names: */
698enum {
699 DEV_CDROM=1,
700 DEV_HWMON=2,
701 DEV_PARPORT=3,
702 DEV_RAID=4,
703 DEV_MAC_HID=5,
704 DEV_SCSI=6,
705};
706
707/* /proc/sys/dev/cdrom */
708enum {
709 DEV_CDROM_INFO=1,
710 DEV_CDROM_AUTOCLOSE=2,
711 DEV_CDROM_AUTOEJECT=3,
712 DEV_CDROM_DEBUG=4,
713 DEV_CDROM_LOCK=5,
714 DEV_CDROM_CHECK_MEDIA=6
715};
716
717/* /proc/sys/dev/parport */
718enum {
719 DEV_PARPORT_DEFAULT=-3
720};
721
722/* /proc/sys/dev/raid */
723enum {
724 DEV_RAID_SPEED_LIMIT_MIN=1,
725 DEV_RAID_SPEED_LIMIT_MAX=2
726};
727
728/* /proc/sys/dev/parport/default */
729enum {
730 DEV_PARPORT_DEFAULT_TIMESLICE=1,
731 DEV_PARPORT_DEFAULT_SPINTIME=2
732};
733
734/* /proc/sys/dev/parport/parport n */
735enum {
736 DEV_PARPORT_SPINTIME=1,
737 DEV_PARPORT_BASE_ADDR=2,
738 DEV_PARPORT_IRQ=3,
739 DEV_PARPORT_DMA=4,
740 DEV_PARPORT_MODES=5,
741 DEV_PARPORT_DEVICES=6,
742 DEV_PARPORT_AUTOPROBE=16
743};
744
745/* /proc/sys/dev/parport/parport n/devices/ */
746enum {
747 DEV_PARPORT_DEVICES_ACTIVE=-3,
748};
749
750/* /proc/sys/dev/parport/parport n/devices/device n */
751enum {
752 DEV_PARPORT_DEVICE_TIMESLICE=1,
753};
754
755/* /proc/sys/dev/mac_hid */
756enum {
757 DEV_MAC_HID_KEYBOARD_SENDS_LINUX_KEYCODES=1,
758 DEV_MAC_HID_KEYBOARD_LOCK_KEYCODES=2,
759 DEV_MAC_HID_MOUSE_BUTTON_EMULATION=3,
760 DEV_MAC_HID_MOUSE_BUTTON2_KEYCODE=4,
761 DEV_MAC_HID_MOUSE_BUTTON3_KEYCODE=5,
762 DEV_MAC_HID_ADB_MOUSE_SENDS_KEYCODES=6
763};
764
765/* /proc/sys/dev/scsi */
766enum {
767 DEV_SCSI_LOGGING_LEVEL=1,
768};
769
770/* /proc/sys/abi */
771enum
772{
773 ABI_DEFHANDLER_COFF=1, /* default handler for coff binaries */
774 ABI_DEFHANDLER_ELF=2, /* default handler for ELF binaries */
775 ABI_DEFHANDLER_LCALL7=3,/* default handler for procs using lcall7 */
776 ABI_DEFHANDLER_LIBCSO=4,/* default handler for an libc.so ELF interp */
777 ABI_TRACE=5, /* tracing flags */
778 ABI_FAKE_UTSNAME=6, /* fake target utsname information */
779};
780
781#ifdef __KERNEL__
782
783extern void sysctl_init(void);
784
785typedef struct ctl_table ctl_table;
786
787typedef int ctl_handler (ctl_table *table, int __user *name, int nlen,
788 void __user *oldval, size_t __user *oldlenp,
789 void __user *newval, size_t newlen,
790 void **context);
791
792typedef int proc_handler (ctl_table *ctl, int write, struct file * filp,
793 void __user *buffer, size_t *lenp, loff_t *ppos);
794
795extern int proc_dostring(ctl_table *, int, struct file *,
796 void __user *, size_t *, loff_t *);
797extern int proc_dointvec(ctl_table *, int, struct file *,
798 void __user *, size_t *, loff_t *);
799extern int proc_dointvec_bset(ctl_table *, int, struct file *,
800 void __user *, size_t *, loff_t *);
801extern int proc_dointvec_minmax(ctl_table *, int, struct file *,
802 void __user *, size_t *, loff_t *);
803extern int proc_dointvec_jiffies(ctl_table *, int, struct file *,
804 void __user *, size_t *, loff_t *);
805extern int proc_dointvec_userhz_jiffies(ctl_table *, int, struct file *,
806 void __user *, size_t *, loff_t *);
807extern int proc_dointvec_ms_jiffies(ctl_table *, int, struct file *,
808 void __user *, size_t *, loff_t *);
809extern int proc_doulongvec_minmax(ctl_table *, int, struct file *,
810 void __user *, size_t *, loff_t *);
811extern int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int,
812 struct file *, void __user *, size_t *, loff_t *);
813
814extern int do_sysctl (int __user *name, int nlen,
815 void __user *oldval, size_t __user *oldlenp,
816 void __user *newval, size_t newlen);
817
818extern int do_sysctl_strategy (ctl_table *table,
819 int __user *name, int nlen,
820 void __user *oldval, size_t __user *oldlenp,
821 void __user *newval, size_t newlen, void ** context);
822
823extern ctl_handler sysctl_string;
824extern ctl_handler sysctl_intvec;
825extern ctl_handler sysctl_jiffies;
826extern ctl_handler sysctl_ms_jiffies;
827
828
829/*
830 * Register a set of sysctl names by calling register_sysctl_table
831 * with an initialised array of ctl_table's. An entry with zero
832 * ctl_name terminates the table. table->de will be set up by the
833 * registration and need not be initialised in advance.
834 *
835 * sysctl names can be mirrored automatically under /proc/sys. The
836 * procname supplied controls /proc naming.
837 *
838 * The table's mode will be honoured both for sys_sysctl(2) and
839 * proc-fs access.
840 *
841 * Leaf nodes in the sysctl tree will be represented by a single file
842 * under /proc; non-leaf nodes will be represented by directories. A
843 * null procname disables /proc mirroring at this node.
844 *
845 * sysctl(2) can automatically manage read and write requests through
846 * the sysctl table. The data and maxlen fields of the ctl_table
847 * struct enable minimal validation of the values being written to be
848 * performed, and the mode field allows minimal authentication.
849 *
850 * More sophisticated management can be enabled by the provision of a
851 * strategy routine with the table entry. This will be called before
852 * any automatic read or write of the data is performed.
853 *
854 * The strategy routine may return:
855 * <0: Error occurred (error is passed to user process)
856 * 0: OK - proceed with automatic read or write.
857 * >0: OK - read or write has been done by the strategy routine, so
858 * return immediately.
859 *
860 * There must be a proc_handler routine for any terminal nodes
861 * mirrored under /proc/sys (non-terminals are handled by a built-in
862 * directory handler). Several default handlers are available to
863 * cover common cases.
864 */
865
866/* A sysctl table is an array of struct ctl_table: */
867struct ctl_table
868{
869 int ctl_name; /* Binary ID */
870 const char *procname; /* Text ID for /proc/sys, or zero */
871 void *data;
872 int maxlen;
873 mode_t mode;
874 ctl_table *child;
875 proc_handler *proc_handler; /* Callback for text formatting */
876 ctl_handler *strategy; /* Callback function for all r/w */
877 struct proc_dir_entry *de; /* /proc control block */
878 void *extra1;
879 void *extra2;
880};
881
882/* struct ctl_table_header is used to maintain dynamic lists of
883 ctl_table trees. */
884struct ctl_table_header
885{
886 ctl_table *ctl_table;
887 struct list_head ctl_entry;
888};
889
890struct ctl_table_header * register_sysctl_table(ctl_table * table,
891 int insert_at_head);
892void unregister_sysctl_table(struct ctl_table_header * table);
893
894#else /* __KERNEL__ */
895
896#endif /* __KERNEL__ */
897
898#endif /* _LINUX_SYSCTL_H */
diff --git a/include/linux/sysdev.h b/include/linux/sysdev.h
new file mode 100644
index 000000000000..635db1df656f
--- /dev/null
+++ b/include/linux/sysdev.h
@@ -0,0 +1,94 @@
1/**
2 * System devices follow a slightly different driver model.
3 * They don't need to do dynammic driver binding, can't be probed,
4 * and don't reside on any type of peripheral bus.
5 * So, we represent and treat them a little differently.
6 *
7 * We still have a notion of a driver for a system device, because we still
8 * want to perform basic operations on these devices.
9 *
10 * We also support auxillary drivers binding to devices of a certain class.
11 *
12 * This allows configurable drivers to register themselves for devices of
13 * a certain type. And, it allows class definitions to reside in generic
14 * code while arch-specific code can register specific drivers.
15 *
16 * Auxillary drivers registered with a NULL cls are registered as drivers
17 * for all system devices, and get notification calls for each device.
18 */
19
20
21#ifndef _SYSDEV_H_
22#define _SYSDEV_H_
23
24#include <linux/kobject.h>
25
26
27struct sys_device;
28
29struct sysdev_class {
30 struct list_head drivers;
31
32 /* Default operations for these types of devices */
33 int (*shutdown)(struct sys_device *);
34 int (*suspend)(struct sys_device *, u32 state);
35 int (*resume)(struct sys_device *);
36 struct kset kset;
37};
38
39
40extern int sysdev_class_register(struct sysdev_class *);
41extern void sysdev_class_unregister(struct sysdev_class *);
42
43
44/**
45 * Auxillary system device drivers.
46 */
47
48struct sysdev_driver {
49 struct list_head entry;
50 int (*add)(struct sys_device *);
51 int (*remove)(struct sys_device *);
52 int (*shutdown)(struct sys_device *);
53 int (*suspend)(struct sys_device *, u32 state);
54 int (*resume)(struct sys_device *);
55};
56
57
58extern int sysdev_driver_register(struct sysdev_class *, struct sysdev_driver *);
59extern void sysdev_driver_unregister(struct sysdev_class *, struct sysdev_driver *);
60
61
62/**
63 * sys_devices can be simplified a lot from regular devices, because they're
64 * simply not as versatile.
65 */
66
67struct sys_device {
68 u32 id;
69 struct sysdev_class * cls;
70 struct kobject kobj;
71};
72
73extern int sysdev_register(struct sys_device *);
74extern void sysdev_unregister(struct sys_device *);
75
76
77struct sysdev_attribute {
78 struct attribute attr;
79 ssize_t (*show)(struct sys_device *, char *);
80 ssize_t (*store)(struct sys_device *, const char *, size_t);
81};
82
83
84#define SYSDEV_ATTR(_name,_mode,_show,_store) \
85struct sysdev_attribute attr_##_name = { \
86 .attr = {.name = __stringify(_name), .mode = _mode }, \
87 .show = _show, \
88 .store = _store, \
89};
90
91extern int sysdev_create_file(struct sys_device *, struct sysdev_attribute *);
92extern void sysdev_remove_file(struct sys_device *, struct sysdev_attribute *);
93
94#endif /* _SYSDEV_H_ */
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
new file mode 100644
index 000000000000..6f502ff7902a
--- /dev/null
+++ b/include/linux/sysfs.h
@@ -0,0 +1,182 @@
1/*
2 * sysfs.h - definitions for the device driver filesystem
3 *
4 * Copyright (c) 2001,2002 Patrick Mochel
5 * Copyright (c) 2004 Silicon Graphics, Inc.
6 *
7 * Please see Documentation/filesystems/sysfs.txt for more information.
8 */
9
10#ifndef _SYSFS_H_
11#define _SYSFS_H_
12
13#include <asm/atomic.h>
14
15struct kobject;
16struct module;
17
18struct attribute {
19 char * name;
20 struct module * owner;
21 mode_t mode;
22};
23
24struct attribute_group {
25 char * name;
26 struct attribute ** attrs;
27};
28
29
30
31/**
32 * Use these macros to make defining attributes easier. See include/linux/device.h
33 * for examples..
34 */
35
36#define __ATTR(_name,_mode,_show,_store) { \
37 .attr = {.name = __stringify(_name), .mode = _mode, .owner = THIS_MODULE }, \
38 .show = _show, \
39 .store = _store, \
40}
41
42#define __ATTR_RO(_name) { \
43 .attr = { .name = __stringify(_name), .mode = 0444, .owner = THIS_MODULE }, \
44 .show = _name##_show, \
45}
46
47#define __ATTR_NULL { .attr = { .name = NULL } }
48
49#define attr_name(_attr) (_attr).attr.name
50
51struct vm_area_struct;
52
53struct bin_attribute {
54 struct attribute attr;
55 size_t size;
56 void *private;
57 ssize_t (*read)(struct kobject *, char *, loff_t, size_t);
58 ssize_t (*write)(struct kobject *, char *, loff_t, size_t);
59 int (*mmap)(struct kobject *, struct bin_attribute *attr,
60 struct vm_area_struct *vma);
61};
62
63struct sysfs_ops {
64 ssize_t (*show)(struct kobject *, struct attribute *,char *);
65 ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t);
66};
67
68struct sysfs_dirent {
69 atomic_t s_count;
70 struct list_head s_sibling;
71 struct list_head s_children;
72 void * s_element;
73 int s_type;
74 umode_t s_mode;
75 struct dentry * s_dentry;
76};
77
78#define SYSFS_ROOT 0x0001
79#define SYSFS_DIR 0x0002
80#define SYSFS_KOBJ_ATTR 0x0004
81#define SYSFS_KOBJ_BIN_ATTR 0x0008
82#define SYSFS_KOBJ_LINK 0x0020
83#define SYSFS_NOT_PINNED (SYSFS_KOBJ_ATTR | SYSFS_KOBJ_BIN_ATTR | SYSFS_KOBJ_LINK)
84
85#ifdef CONFIG_SYSFS
86
87extern int
88sysfs_create_dir(struct kobject *);
89
90extern void
91sysfs_remove_dir(struct kobject *);
92
93extern int
94sysfs_rename_dir(struct kobject *, const char *new_name);
95
96extern int
97sysfs_create_file(struct kobject *, const struct attribute *);
98
99extern int
100sysfs_update_file(struct kobject *, const struct attribute *);
101
102extern void
103sysfs_remove_file(struct kobject *, const struct attribute *);
104
105extern int
106sysfs_create_link(struct kobject * kobj, struct kobject * target, char * name);
107
108extern void
109sysfs_remove_link(struct kobject *, char * name);
110
111int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr);
112int sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr);
113
114int sysfs_create_group(struct kobject *, const struct attribute_group *);
115void sysfs_remove_group(struct kobject *, const struct attribute_group *);
116
117#else /* CONFIG_SYSFS */
118
119static inline int sysfs_create_dir(struct kobject * k)
120{
121 return 0;
122}
123
124static inline void sysfs_remove_dir(struct kobject * k)
125{
126 ;
127}
128
129static inline int sysfs_rename_dir(struct kobject * k, const char *new_name)
130{
131 return 0;
132}
133
134static inline int sysfs_create_file(struct kobject * k, const struct attribute * a)
135{
136 return 0;
137}
138
139static inline int sysfs_update_file(struct kobject * k, const struct attribute * a)
140{
141 return 0;
142}
143
144static inline void sysfs_remove_file(struct kobject * k, const struct attribute * a)
145{
146 ;
147}
148
149static inline int sysfs_create_link(struct kobject * k, struct kobject * t, char * n)
150{
151 return 0;
152}
153
154static inline void sysfs_remove_link(struct kobject * k, char * name)
155{
156 ;
157}
158
159
160static inline int sysfs_create_bin_file(struct kobject * k, struct bin_attribute * a)
161{
162 return 0;
163}
164
165static inline int sysfs_remove_bin_file(struct kobject * k, struct bin_attribute * a)
166{
167 return 0;
168}
169
170static inline int sysfs_create_group(struct kobject * k, const struct attribute_group *g)
171{
172 return 0;
173}
174
175static inline void sysfs_remove_group(struct kobject * k, const struct attribute_group * g)
176{
177 ;
178}
179
180#endif /* CONFIG_SYSFS */
181
182#endif /* _SYSFS_H_ */
diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
new file mode 100644
index 000000000000..ea819b89c235
--- /dev/null
+++ b/include/linux/sysrq.h
@@ -0,0 +1,60 @@
1/* -*- linux-c -*-
2 *
3 * $Id: sysrq.h,v 1.3 1997/07/17 11:54:33 mj Exp $
4 *
5 * Linux Magic System Request Key Hacks
6 *
7 * (c) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
8 *
9 * (c) 2000 Crutcher Dunnavant <crutcher+kernel@datastacks.com>
10 * overhauled to use key registration
11 * based upon discusions in irc://irc.openprojects.net/#kernelnewbies
12 */
13
14#include <linux/config.h>
15
16struct pt_regs;
17struct tty_struct;
18
19/* Possible values of bitmask for enabling sysrq functions */
20/* 0x0001 is reserved for enable everything */
21#define SYSRQ_ENABLE_LOG 0x0002
22#define SYSRQ_ENABLE_KEYBOARD 0x0004
23#define SYSRQ_ENABLE_DUMP 0x0008
24#define SYSRQ_ENABLE_SYNC 0x0010
25#define SYSRQ_ENABLE_REMOUNT 0x0020
26#define SYSRQ_ENABLE_SIGNAL 0x0040
27#define SYSRQ_ENABLE_BOOT 0x0080
28#define SYSRQ_ENABLE_RTNICE 0x0100
29
30struct sysrq_key_op {
31 void (*handler)(int, struct pt_regs *, struct tty_struct *);
32 char *help_msg;
33 char *action_msg;
34 int enable_mask;
35};
36
37#ifdef CONFIG_MAGIC_SYSRQ
38
39/* Generic SysRq interface -- you may call it from any device driver, supplying
40 * ASCII code of the key, pointer to registers and kbd/tty structs (if they
41 * are available -- else NULL's).
42 */
43
44void handle_sysrq(int, struct pt_regs *, struct tty_struct *);
45void __handle_sysrq(int, struct pt_regs *, struct tty_struct *, int check_mask);
46int register_sysrq_key(int, struct sysrq_key_op *);
47int unregister_sysrq_key(int, struct sysrq_key_op *);
48struct sysrq_key_op *__sysrq_get_key_op(int key);
49
50#else
51
52static inline int __reterr(void)
53{
54 return -EINVAL;
55}
56
57#define register_sysrq_key(ig,nore) __reterr()
58#define unregister_sysrq_key(ig,nore) __reterr()
59
60#endif
diff --git a/include/linux/sysv_fs.h b/include/linux/sysv_fs.h
new file mode 100644
index 000000000000..e0248631e461
--- /dev/null
+++ b/include/linux/sysv_fs.h
@@ -0,0 +1,206 @@
1#ifndef _LINUX_SYSV_FS_H
2#define _LINUX_SYSV_FS_H
3
4#if defined(__GNUC__)
5# define __packed2__ __attribute__((packed, aligned(2)))
6#else
7>> I want to scream! <<
8#endif
9
10
11#ifndef __KERNEL__
12typedef u16 __fs16;
13typedef u32 __fs16;
14#endif
15
16/* inode numbers are 16 bit */
17typedef __fs16 sysv_ino_t;
18
19/* Block numbers are 24 bit, sometimes stored in 32 bit.
20 On Coherent FS, they are always stored in PDP-11 manner: the least
21 significant 16 bits come last. */
22typedef __fs32 sysv_zone_t;
23
24/* 0 is non-existent */
25#define SYSV_BADBL_INO 1 /* inode of bad blocks file */
26#define SYSV_ROOT_INO 2 /* inode of root directory */
27
28
29/* Xenix super-block data on disk */
30#define XENIX_NICINOD 100 /* number of inode cache entries */
31#define XENIX_NICFREE 100 /* number of free block list chunk entries */
32struct xenix_super_block {
33 __fs16 s_isize; /* index of first data zone */
34 __fs32 s_fsize __packed2__; /* total number of zones of this fs */
35 /* the start of the free block list: */
36 __fs16 s_nfree; /* number of free blocks in s_free, <= XENIX_NICFREE */
37 sysv_zone_t s_free[XENIX_NICFREE]; /* first free block list chunk */
38 /* the cache of free inodes: */
39 __fs16 s_ninode; /* number of free inodes in s_inode, <= XENIX_NICINOD */
40 sysv_ino_t s_inode[XENIX_NICINOD]; /* some free inodes */
41 /* locks, not used by Linux: */
42 char s_flock; /* lock during free block list manipulation */
43 char s_ilock; /* lock during inode cache manipulation */
44 char s_fmod; /* super-block modified flag */
45 char s_ronly; /* flag whether fs is mounted read-only */
46 __fs32 s_time __packed2__; /* time of last super block update */
47 __fs32 s_tfree __packed2__; /* total number of free zones */
48 __fs16 s_tinode; /* total number of free inodes */
49 __fs16 s_dinfo[4]; /* device information ?? */
50 char s_fname[6]; /* file system volume name */
51 char s_fpack[6]; /* file system pack name */
52 char s_clean; /* set to 0x46 when filesystem is properly unmounted */
53 char s_fill[371];
54 s32 s_magic; /* version of file system */
55 __fs32 s_type; /* type of file system: 1 for 512 byte blocks
56 2 for 1024 byte blocks
57 3 for 2048 byte blocks */
58
59};
60
61/*
62 * SystemV FS comes in two variants:
63 * sysv2: System V Release 2 (e.g. Microport), structure elements aligned(2).
64 * sysv4: System V Release 4 (e.g. Consensys), structure elements aligned(4).
65 */
66#define SYSV_NICINOD 100 /* number of inode cache entries */
67#define SYSV_NICFREE 50 /* number of free block list chunk entries */
68
69/* SystemV4 super-block data on disk */
70struct sysv4_super_block {
71 __fs16 s_isize; /* index of first data zone */
72 u16 s_pad0;
73 __fs32 s_fsize; /* total number of zones of this fs */
74 /* the start of the free block list: */
75 __fs16 s_nfree; /* number of free blocks in s_free, <= SYSV_NICFREE */
76 u16 s_pad1;
77 sysv_zone_t s_free[SYSV_NICFREE]; /* first free block list chunk */
78 /* the cache of free inodes: */
79 __fs16 s_ninode; /* number of free inodes in s_inode, <= SYSV_NICINOD */
80 u16 s_pad2;
81 sysv_ino_t s_inode[SYSV_NICINOD]; /* some free inodes */
82 /* locks, not used by Linux: */
83 char s_flock; /* lock during free block list manipulation */
84 char s_ilock; /* lock during inode cache manipulation */
85 char s_fmod; /* super-block modified flag */
86 char s_ronly; /* flag whether fs is mounted read-only */
87 __fs32 s_time; /* time of last super block update */
88 __fs16 s_dinfo[4]; /* device information ?? */
89 __fs32 s_tfree; /* total number of free zones */
90 __fs16 s_tinode; /* total number of free inodes */
91 u16 s_pad3;
92 char s_fname[6]; /* file system volume name */
93 char s_fpack[6]; /* file system pack name */
94 s32 s_fill[12];
95 __fs32 s_state; /* file system state: 0x7c269d38-s_time means clean */
96 s32 s_magic; /* version of file system */
97 __fs32 s_type; /* type of file system: 1 for 512 byte blocks
98 2 for 1024 byte blocks */
99};
100
101/* SystemV2 super-block data on disk */
102struct sysv2_super_block {
103 __fs16 s_isize; /* index of first data zone */
104 __fs32 s_fsize __packed2__; /* total number of zones of this fs */
105 /* the start of the free block list: */
106 __fs16 s_nfree; /* number of free blocks in s_free, <= SYSV_NICFREE */
107 sysv_zone_t s_free[SYSV_NICFREE]; /* first free block list chunk */
108 /* the cache of free inodes: */
109 __fs16 s_ninode; /* number of free inodes in s_inode, <= SYSV_NICINOD */
110 sysv_ino_t s_inode[SYSV_NICINOD]; /* some free inodes */
111 /* locks, not used by Linux: */
112 char s_flock; /* lock during free block list manipulation */
113 char s_ilock; /* lock during inode cache manipulation */
114 char s_fmod; /* super-block modified flag */
115 char s_ronly; /* flag whether fs is mounted read-only */
116 __fs32 s_time __packed2__; /* time of last super block update */
117 __fs16 s_dinfo[4]; /* device information ?? */
118 __fs32 s_tfree __packed2__; /* total number of free zones */
119 __fs16 s_tinode; /* total number of free inodes */
120 char s_fname[6]; /* file system volume name */
121 char s_fpack[6]; /* file system pack name */
122 s32 s_fill[14];
123 __fs32 s_state; /* file system state: 0xcb096f43 means clean */
124 s32 s_magic; /* version of file system */
125 __fs32 s_type; /* type of file system: 1 for 512 byte blocks
126 2 for 1024 byte blocks */
127};
128
129/* V7 super-block data on disk */
130#define V7_NICINOD 100 /* number of inode cache entries */
131#define V7_NICFREE 50 /* number of free block list chunk entries */
132struct v7_super_block {
133 __fs16 s_isize; /* index of first data zone */
134 __fs32 s_fsize __packed2__; /* total number of zones of this fs */
135 /* the start of the free block list: */
136 __fs16 s_nfree; /* number of free blocks in s_free, <= V7_NICFREE */
137 sysv_zone_t s_free[V7_NICFREE]; /* first free block list chunk */
138 /* the cache of free inodes: */
139 __fs16 s_ninode; /* number of free inodes in s_inode, <= V7_NICINOD */
140 sysv_ino_t s_inode[V7_NICINOD]; /* some free inodes */
141 /* locks, not used by Linux or V7: */
142 char s_flock; /* lock during free block list manipulation */
143 char s_ilock; /* lock during inode cache manipulation */
144 char s_fmod; /* super-block modified flag */
145 char s_ronly; /* flag whether fs is mounted read-only */
146 __fs32 s_time __packed2__; /* time of last super block update */
147 /* the following fields are not maintained by V7: */
148 __fs32 s_tfree __packed2__; /* total number of free zones */
149 __fs16 s_tinode; /* total number of free inodes */
150 __fs16 s_m; /* interleave factor */
151 __fs16 s_n; /* interleave factor */
152 char s_fname[6]; /* file system name */
153 char s_fpack[6]; /* file system pack name */
154};
155
156/* Coherent super-block data on disk */
157#define COH_NICINOD 100 /* number of inode cache entries */
158#define COH_NICFREE 64 /* number of free block list chunk entries */
159struct coh_super_block {
160 __fs16 s_isize; /* index of first data zone */
161 __fs32 s_fsize __packed2__; /* total number of zones of this fs */
162 /* the start of the free block list: */
163 __fs16 s_nfree; /* number of free blocks in s_free, <= COH_NICFREE */
164 sysv_zone_t s_free[COH_NICFREE] __packed2__; /* first free block list chunk */
165 /* the cache of free inodes: */
166 __fs16 s_ninode; /* number of free inodes in s_inode, <= COH_NICINOD */
167 sysv_ino_t s_inode[COH_NICINOD]; /* some free inodes */
168 /* locks, not used by Linux: */
169 char s_flock; /* lock during free block list manipulation */
170 char s_ilock; /* lock during inode cache manipulation */
171 char s_fmod; /* super-block modified flag */
172 char s_ronly; /* flag whether fs is mounted read-only */
173 __fs32 s_time __packed2__; /* time of last super block update */
174 __fs32 s_tfree __packed2__; /* total number of free zones */
175 __fs16 s_tinode; /* total number of free inodes */
176 __fs16 s_interleave_m; /* interleave factor */
177 __fs16 s_interleave_n;
178 char s_fname[6]; /* file system volume name */
179 char s_fpack[6]; /* file system pack name */
180 __fs32 s_unique; /* zero, not used */
181};
182
183/* SystemV/Coherent inode data on disk */
184struct sysv_inode {
185 __fs16 i_mode;
186 __fs16 i_nlink;
187 __fs16 i_uid;
188 __fs16 i_gid;
189 __fs32 i_size;
190 u8 i_data[3*(10+1+1+1)];
191 u8 i_gen;
192 __fs32 i_atime; /* time of last access */
193 __fs32 i_mtime; /* time of last modification */
194 __fs32 i_ctime; /* time of creation */
195};
196
197/* SystemV/Coherent directory entry on disk */
198#define SYSV_NAMELEN 14 /* max size of name in struct sysv_dir_entry */
199struct sysv_dir_entry {
200 sysv_ino_t inode;
201 char name[SYSV_NAMELEN]; /* up to 14 characters, the rest are zeroes */
202};
203
204#define SYSV_DIRSIZE sizeof(struct sysv_dir_entry) /* size of every directory entry */
205
206#endif /* _LINUX_SYSV_FS_H */
diff --git a/include/linux/tc_act/tc_gact.h b/include/linux/tc_act/tc_gact.h
new file mode 100644
index 000000000000..23a03eb630db
--- /dev/null
+++ b/include/linux/tc_act/tc_gact.h
@@ -0,0 +1,34 @@
1#ifndef __LINUX_TC_GACT_H
2#define __LINUX_TC_GACT_H
3
4#include <linux/pkt_cls.h>
5
6#define TCA_ACT_GACT 5
7struct tc_gact
8{
9 tc_gen;
10
11};
12
13struct tc_gact_p
14{
15#define PGACT_NONE 0
16#define PGACT_NETRAND 1
17#define PGACT_DETERM 2
18#define MAX_RAND (PGACT_DETERM + 1 )
19 __u16 ptype;
20 __u16 pval;
21 int paction;
22};
23
24enum
25{
26 TCA_GACT_UNSPEC,
27 TCA_GACT_TM,
28 TCA_GACT_PARMS,
29 TCA_GACT_PROB,
30 __TCA_GACT_MAX
31};
32#define TCA_GACT_MAX (__TCA_GACT_MAX - 1)
33
34#endif
diff --git a/include/linux/tc_act/tc_ipt.h b/include/linux/tc_act/tc_ipt.h
new file mode 100644
index 000000000000..4b6f7b6c7a79
--- /dev/null
+++ b/include/linux/tc_act/tc_ipt.h
@@ -0,0 +1,21 @@
1#ifndef __LINUX_TC_IPT_H
2#define __LINUX_TC_IPT_H
3
4#include <linux/pkt_cls.h>
5
6#define TCA_ACT_IPT 6
7
8enum
9{
10 TCA_IPT_UNSPEC,
11 TCA_IPT_TABLE,
12 TCA_IPT_HOOK,
13 TCA_IPT_INDEX,
14 TCA_IPT_CNT,
15 TCA_IPT_TM,
16 TCA_IPT_TARG,
17 __TCA_IPT_MAX
18};
19#define TCA_IPT_MAX (__TCA_IPT_MAX - 1)
20
21#endif
diff --git a/include/linux/tc_act/tc_mirred.h b/include/linux/tc_act/tc_mirred.h
new file mode 100644
index 000000000000..71d63409d568
--- /dev/null
+++ b/include/linux/tc_act/tc_mirred.h
@@ -0,0 +1,28 @@
1#ifndef __LINUX_TC_MIR_H
2#define __LINUX_TC_MIR_H
3
4#include <linux/pkt_cls.h>
5
6#define TCA_ACT_MIRRED 8
7#define TCA_EGRESS_REDIR 1 /* packet redirect to EGRESS*/
8#define TCA_EGRESS_MIRROR 2 /* mirror packet to EGRESS */
9#define TCA_INGRESS_REDIR 3 /* packet redirect to INGRESS*/
10#define TCA_INGRESS_MIRROR 4 /* mirror packet to INGRESS */
11
12struct tc_mirred
13{
14 tc_gen;
15 int eaction; /* one of IN/EGRESS_MIRROR/REDIR */
16 __u32 ifindex; /* ifindex of egress port */
17};
18
19enum
20{
21 TCA_MIRRED_UNSPEC,
22 TCA_MIRRED_TM,
23 TCA_MIRRED_PARMS,
24 __TCA_MIRRED_MAX
25};
26#define TCA_MIRRED_MAX (__TCA_MIRRED_MAX - 1)
27
28#endif
diff --git a/include/linux/tc_act/tc_pedit.h b/include/linux/tc_act/tc_pedit.h
new file mode 100644
index 000000000000..83e56e32e8e0
--- /dev/null
+++ b/include/linux/tc_act/tc_pedit.h
@@ -0,0 +1,36 @@
1#ifndef __LINUX_TC_PED_H
2#define __LINUX_TC_PED_H
3
4#include <linux/pkt_cls.h>
5
6#define TCA_ACT_PEDIT 7
7
8enum
9{
10 TCA_PEDIT_UNSPEC,
11 TCA_PEDIT_TM,
12 TCA_PEDIT_PARMS,
13 __TCA_PEDIT_MAX
14};
15#define TCA_PEDIT_MAX (__TCA_PEDIT_MAX - 1)
16
17struct tc_pedit_key
18{
19 __u32 mask; /* AND */
20 __u32 val; /*XOR */
21 __u32 off; /*offset */
22 __u32 at;
23 __u32 offmask;
24 __u32 shift;
25};
26
27struct tc_pedit_sel
28{
29 tc_gen;
30 unsigned char nkeys;
31 unsigned char flags;
32 struct tc_pedit_key keys[0];
33};
34#define tc_pedit tc_pedit_sel
35
36#endif
diff --git a/include/linux/tc_ematch/tc_em_cmp.h b/include/linux/tc_ematch/tc_em_cmp.h
new file mode 100644
index 000000000000..c7f4d43618fd
--- /dev/null
+++ b/include/linux/tc_ematch/tc_em_cmp.h
@@ -0,0 +1,26 @@
1#ifndef __LINUX_TC_EM_CMP_H
2#define __LINUX_TC_EM_CMP_H
3
4#include <linux/pkt_cls.h>
5
6struct tcf_em_cmp
7{
8 __u32 val;
9 __u32 mask;
10 __u16 off;
11 __u8 align:4;
12 __u8 flags:4;
13 __u8 layer:4;
14 __u8 opnd:4;
15};
16
17enum
18{
19 TCF_EM_ALIGN_U8 = 1,
20 TCF_EM_ALIGN_U16 = 2,
21 TCF_EM_ALIGN_U32 = 4
22};
23
24#define TCF_EM_CMP_TRANS 1
25
26#endif
diff --git a/include/linux/tc_ematch/tc_em_meta.h b/include/linux/tc_ematch/tc_em_meta.h
new file mode 100644
index 000000000000..aa6b48bb4dcd
--- /dev/null
+++ b/include/linux/tc_ematch/tc_em_meta.h
@@ -0,0 +1,69 @@
1#ifndef __LINUX_TC_EM_META_H
2#define __LINUX_TC_EM_META_H
3
4#include <linux/pkt_cls.h>
5
6enum
7{
8 TCA_EM_META_UNSPEC,
9 TCA_EM_META_HDR,
10 TCA_EM_META_LVALUE,
11 TCA_EM_META_RVALUE,
12 __TCA_EM_META_MAX
13};
14#define TCA_EM_META_MAX (__TCA_EM_META_MAX - 1)
15
16struct tcf_meta_val
17{
18 __u16 kind;
19 __u8 shift;
20 __u8 op;
21};
22
23#define TCF_META_TYPE_MASK (0xf << 12)
24#define TCF_META_TYPE(kind) (((kind) & TCF_META_TYPE_MASK) >> 12)
25#define TCF_META_ID_MASK 0x7ff
26#define TCF_META_ID(kind) ((kind) & TCF_META_ID_MASK)
27
28enum
29{
30 TCF_META_TYPE_VAR,
31 TCF_META_TYPE_INT,
32 __TCF_META_TYPE_MAX
33};
34#define TCF_META_TYPE_MAX (__TCF_META_TYPE_MAX - 1)
35
36enum
37{
38 TCF_META_ID_VALUE,
39 TCF_META_ID_RANDOM,
40 TCF_META_ID_LOADAVG_0,
41 TCF_META_ID_LOADAVG_1,
42 TCF_META_ID_LOADAVG_2,
43 TCF_META_ID_DEV,
44 TCF_META_ID_INDEV,
45 TCF_META_ID_REALDEV,
46 TCF_META_ID_PRIORITY,
47 TCF_META_ID_PROTOCOL,
48 TCF_META_ID_SECURITY,
49 TCF_META_ID_PKTTYPE,
50 TCF_META_ID_PKTLEN,
51 TCF_META_ID_DATALEN,
52 TCF_META_ID_MACLEN,
53 TCF_META_ID_NFMARK,
54 TCF_META_ID_TCINDEX,
55 TCF_META_ID_TCVERDICT,
56 TCF_META_ID_TCCLASSID,
57 TCF_META_ID_RTCLASSID,
58 TCF_META_ID_RTIIF,
59 __TCF_META_ID_MAX
60};
61#define TCF_META_ID_MAX (__TCF_META_ID_MAX - 1)
62
63struct tcf_meta_hdr
64{
65 struct tcf_meta_val left;
66 struct tcf_meta_val right;
67};
68
69#endif
diff --git a/include/linux/tc_ematch/tc_em_nbyte.h b/include/linux/tc_ematch/tc_em_nbyte.h
new file mode 100644
index 000000000000..f19d1f58ec9d
--- /dev/null
+++ b/include/linux/tc_ematch/tc_em_nbyte.h
@@ -0,0 +1,13 @@
1#ifndef __LINUX_TC_EM_NBYTE_H
2#define __LINUX_TC_EM_NBYTE_H
3
4#include <linux/pkt_cls.h>
5
6struct tcf_em_nbyte
7{
8 __u16 off;
9 __u16 len:12;
10 __u8 layer:4;
11};
12
13#endif
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
new file mode 100644
index 000000000000..14a55e3e3a50
--- /dev/null
+++ b/include/linux/tcp.h
@@ -0,0 +1,448 @@
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Definitions for the TCP protocol.
7 *
8 * Version: @(#)tcp.h 1.0.2 04/28/93
9 *
10 * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version
15 * 2 of the License, or (at your option) any later version.
16 */
17#ifndef _LINUX_TCP_H
18#define _LINUX_TCP_H
19
20#include <linux/types.h>
21#include <asm/byteorder.h>
22
23struct tcphdr {
24 __u16 source;
25 __u16 dest;
26 __u32 seq;
27 __u32 ack_seq;
28#if defined(__LITTLE_ENDIAN_BITFIELD)
29 __u16 res1:4,
30 doff:4,
31 fin:1,
32 syn:1,
33 rst:1,
34 psh:1,
35 ack:1,
36 urg:1,
37 ece:1,
38 cwr:1;
39#elif defined(__BIG_ENDIAN_BITFIELD)
40 __u16 doff:4,
41 res1:4,
42 cwr:1,
43 ece:1,
44 urg:1,
45 ack:1,
46 psh:1,
47 rst:1,
48 syn:1,
49 fin:1;
50#else
51#error "Adjust your <asm/byteorder.h> defines"
52#endif
53 __u16 window;
54 __u16 check;
55 __u16 urg_ptr;
56};
57
58
59enum {
60 TCP_ESTABLISHED = 1,
61 TCP_SYN_SENT,
62 TCP_SYN_RECV,
63 TCP_FIN_WAIT1,
64 TCP_FIN_WAIT2,
65 TCP_TIME_WAIT,
66 TCP_CLOSE,
67 TCP_CLOSE_WAIT,
68 TCP_LAST_ACK,
69 TCP_LISTEN,
70 TCP_CLOSING, /* now a valid state */
71
72 TCP_MAX_STATES /* Leave at the end! */
73};
74
75#define TCP_STATE_MASK 0xF
76#define TCP_ACTION_FIN (1 << 7)
77
78enum {
79 TCPF_ESTABLISHED = (1 << 1),
80 TCPF_SYN_SENT = (1 << 2),
81 TCPF_SYN_RECV = (1 << 3),
82 TCPF_FIN_WAIT1 = (1 << 4),
83 TCPF_FIN_WAIT2 = (1 << 5),
84 TCPF_TIME_WAIT = (1 << 6),
85 TCPF_CLOSE = (1 << 7),
86 TCPF_CLOSE_WAIT = (1 << 8),
87 TCPF_LAST_ACK = (1 << 9),
88 TCPF_LISTEN = (1 << 10),
89 TCPF_CLOSING = (1 << 11)
90};
91
92/*
93 * The union cast uses a gcc extension to avoid aliasing problems
94 * (union is compatible to any of its members)
95 * This means this part of the code is -fstrict-aliasing safe now.
96 */
97union tcp_word_hdr {
98 struct tcphdr hdr;
99 __u32 words[5];
100};
101
102#define tcp_flag_word(tp) ( ((union tcp_word_hdr *)(tp))->words [3])
103
104enum {
105 TCP_FLAG_CWR = __constant_htonl(0x00800000),
106 TCP_FLAG_ECE = __constant_htonl(0x00400000),
107 TCP_FLAG_URG = __constant_htonl(0x00200000),
108 TCP_FLAG_ACK = __constant_htonl(0x00100000),
109 TCP_FLAG_PSH = __constant_htonl(0x00080000),
110 TCP_FLAG_RST = __constant_htonl(0x00040000),
111 TCP_FLAG_SYN = __constant_htonl(0x00020000),
112 TCP_FLAG_FIN = __constant_htonl(0x00010000),
113 TCP_RESERVED_BITS = __constant_htonl(0x0F000000),
114 TCP_DATA_OFFSET = __constant_htonl(0xF0000000)
115};
116
117/* TCP socket options */
118#define TCP_NODELAY 1 /* Turn off Nagle's algorithm. */
119#define TCP_MAXSEG 2 /* Limit MSS */
120#define TCP_CORK 3 /* Never send partially complete segments */
121#define TCP_KEEPIDLE 4 /* Start keeplives after this period */
122#define TCP_KEEPINTVL 5 /* Interval between keepalives */
123#define TCP_KEEPCNT 6 /* Number of keepalives before death */
124#define TCP_SYNCNT 7 /* Number of SYN retransmits */
125#define TCP_LINGER2 8 /* Life time of orphaned FIN-WAIT-2 state */
126#define TCP_DEFER_ACCEPT 9 /* Wake up listener only when data arrive */
127#define TCP_WINDOW_CLAMP 10 /* Bound advertised window */
128#define TCP_INFO 11 /* Information about this connection. */
129#define TCP_QUICKACK 12 /* Block/reenable quick acks */
130
131#define TCPI_OPT_TIMESTAMPS 1
132#define TCPI_OPT_SACK 2
133#define TCPI_OPT_WSCALE 4
134#define TCPI_OPT_ECN 8
135
136enum tcp_ca_state
137{
138 TCP_CA_Open = 0,
139#define TCPF_CA_Open (1<<TCP_CA_Open)
140 TCP_CA_Disorder = 1,
141#define TCPF_CA_Disorder (1<<TCP_CA_Disorder)
142 TCP_CA_CWR = 2,
143#define TCPF_CA_CWR (1<<TCP_CA_CWR)
144 TCP_CA_Recovery = 3,
145#define TCPF_CA_Recovery (1<<TCP_CA_Recovery)
146 TCP_CA_Loss = 4
147#define TCPF_CA_Loss (1<<TCP_CA_Loss)
148};
149
150struct tcp_info
151{
152 __u8 tcpi_state;
153 __u8 tcpi_ca_state;
154 __u8 tcpi_retransmits;
155 __u8 tcpi_probes;
156 __u8 tcpi_backoff;
157 __u8 tcpi_options;
158 __u8 tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4;
159
160 __u32 tcpi_rto;
161 __u32 tcpi_ato;
162 __u32 tcpi_snd_mss;
163 __u32 tcpi_rcv_mss;
164
165 __u32 tcpi_unacked;
166 __u32 tcpi_sacked;
167 __u32 tcpi_lost;
168 __u32 tcpi_retrans;
169 __u32 tcpi_fackets;
170
171 /* Times. */
172 __u32 tcpi_last_data_sent;
173 __u32 tcpi_last_ack_sent; /* Not remembered, sorry. */
174 __u32 tcpi_last_data_recv;
175 __u32 tcpi_last_ack_recv;
176
177 /* Metrics. */
178 __u32 tcpi_pmtu;
179 __u32 tcpi_rcv_ssthresh;
180 __u32 tcpi_rtt;
181 __u32 tcpi_rttvar;
182 __u32 tcpi_snd_ssthresh;
183 __u32 tcpi_snd_cwnd;
184 __u32 tcpi_advmss;
185 __u32 tcpi_reordering;
186
187 __u32 tcpi_rcv_rtt;
188 __u32 tcpi_rcv_space;
189
190 __u32 tcpi_total_retrans;
191};
192
193#ifdef __KERNEL__
194
195#include <linux/config.h>
196#include <linux/skbuff.h>
197#include <linux/ip.h>
198#include <net/sock.h>
199
200/* This defines a selective acknowledgement block. */
201struct tcp_sack_block {
202 __u32 start_seq;
203 __u32 end_seq;
204};
205
206enum tcp_congestion_algo {
207 TCP_RENO=0,
208 TCP_VEGAS,
209 TCP_WESTWOOD,
210 TCP_BIC,
211};
212
213struct tcp_options_received {
214/* PAWS/RTTM data */
215 long ts_recent_stamp;/* Time we stored ts_recent (for aging) */
216 __u32 ts_recent; /* Time stamp to echo next */
217 __u32 rcv_tsval; /* Time stamp value */
218 __u32 rcv_tsecr; /* Time stamp echo reply */
219 __u16 saw_tstamp : 1, /* Saw TIMESTAMP on last packet */
220 tstamp_ok : 1, /* TIMESTAMP seen on SYN packet */
221 dsack : 1, /* D-SACK is scheduled */
222 wscale_ok : 1, /* Wscale seen on SYN packet */
223 sack_ok : 4, /* SACK seen on SYN packet */
224 snd_wscale : 4, /* Window scaling received from sender */
225 rcv_wscale : 4; /* Window scaling to send to receiver */
226/* SACKs data */
227 __u8 eff_sacks; /* Size of SACK array to send with next packet */
228 __u8 num_sacks; /* Number of SACK blocks */
229 __u16 user_mss; /* mss requested by user in ioctl */
230 __u16 mss_clamp; /* Maximal mss, negotiated at connection setup */
231};
232
233struct tcp_sock {
234 /* inet_sock has to be the first member of tcp_sock */
235 struct inet_sock inet;
236 int tcp_header_len; /* Bytes of tcp header to send */
237
238/*
239 * Header prediction flags
240 * 0x5?10 << 16 + snd_wnd in net byte order
241 */
242 __u32 pred_flags;
243
244/*
245 * RFC793 variables by their proper names. This means you can
246 * read the code and the spec side by side (and laugh ...)
247 * See RFC793 and RFC1122. The RFC writes these in capitals.
248 */
249 __u32 rcv_nxt; /* What we want to receive next */
250 __u32 snd_nxt; /* Next sequence we send */
251
252 __u32 snd_una; /* First byte we want an ack for */
253 __u32 snd_sml; /* Last byte of the most recently transmitted small packet */
254 __u32 rcv_tstamp; /* timestamp of last received ACK (for keepalives) */
255 __u32 lsndtime; /* timestamp of last sent data packet (for restart window) */
256 struct tcp_bind_bucket *bind_hash;
257 /* Delayed ACK control data */
258 struct {
259 __u8 pending; /* ACK is pending */
260 __u8 quick; /* Scheduled number of quick acks */
261 __u8 pingpong; /* The session is interactive */
262 __u8 blocked; /* Delayed ACK was blocked by socket lock*/
263 __u32 ato; /* Predicted tick of soft clock */
264 unsigned long timeout; /* Currently scheduled timeout */
265 __u32 lrcvtime; /* timestamp of last received data packet*/
266 __u16 last_seg_size; /* Size of last incoming segment */
267 __u16 rcv_mss; /* MSS used for delayed ACK decisions */
268 } ack;
269
270 /* Data for direct copy to user */
271 struct {
272 struct sk_buff_head prequeue;
273 struct task_struct *task;
274 struct iovec *iov;
275 int memory;
276 int len;
277 } ucopy;
278
279 __u32 snd_wl1; /* Sequence for window update */
280 __u32 snd_wnd; /* The window we expect to receive */
281 __u32 max_window; /* Maximal window ever seen from peer */
282 __u32 pmtu_cookie; /* Last pmtu seen by socket */
283 __u32 mss_cache; /* Cached effective mss, not including SACKS */
284 __u16 mss_cache_std; /* Like mss_cache, but without TSO */
285 __u16 ext_header_len; /* Network protocol overhead (IP/IPv6 options) */
286 __u8 ca_state; /* State of fast-retransmit machine */
287 __u8 retransmits; /* Number of unrecovered RTO timeouts. */
288
289 __u16 advmss; /* Advertised MSS */
290 __u32 window_clamp; /* Maximal window to advertise */
291 __u32 rcv_ssthresh; /* Current window clamp */
292
293 __u32 frto_highmark; /* snd_nxt when RTO occurred */
294 __u8 reordering; /* Packet reordering metric. */
295 __u8 frto_counter; /* Number of new acks after RTO */
296
297 __u8 adv_cong; /* Using Vegas, Westwood, or BIC */
298 __u8 defer_accept; /* User waits for some data after accept() */
299
300/* RTT measurement */
301 __u32 srtt; /* smoothed round trip time << 3 */
302 __u32 mdev; /* medium deviation */
303 __u32 mdev_max; /* maximal mdev for the last rtt period */
304 __u32 rttvar; /* smoothed mdev_max */
305 __u32 rtt_seq; /* sequence number to update rttvar */
306 __u32 rto; /* retransmit timeout */
307
308 __u32 packets_out; /* Packets which are "in flight" */
309 __u32 left_out; /* Packets which leaved network */
310 __u32 retrans_out; /* Retransmitted packets out */
311 __u8 backoff; /* backoff */
312/*
313 * Options received (usually on last packet, some only on SYN packets).
314 */
315 __u8 nonagle; /* Disable Nagle algorithm? */
316 __u8 keepalive_probes; /* num of allowed keep alive probes */
317
318 __u8 probes_out; /* unanswered 0 window probes */
319 struct tcp_options_received rx_opt;
320
321/*
322 * Slow start and congestion control (see also Nagle, and Karn & Partridge)
323 */
324 __u32 snd_ssthresh; /* Slow start size threshold */
325 __u32 snd_cwnd; /* Sending congestion window */
326 __u16 snd_cwnd_cnt; /* Linear increase counter */
327 __u16 snd_cwnd_clamp; /* Do not allow snd_cwnd to grow above this */
328 __u32 snd_cwnd_used;
329 __u32 snd_cwnd_stamp;
330
331 /* Two commonly used timers in both sender and receiver paths. */
332 unsigned long timeout;
333 struct timer_list retransmit_timer; /* Resend (no ack) */
334 struct timer_list delack_timer; /* Ack delay */
335
336 struct sk_buff_head out_of_order_queue; /* Out of order segments go here */
337
338 struct tcp_func *af_specific; /* Operations which are AF_INET{4,6} specific */
339
340 __u32 rcv_wnd; /* Current receiver window */
341 __u32 rcv_wup; /* rcv_nxt on last window update sent */
342 __u32 write_seq; /* Tail(+1) of data held in tcp send buffer */
343 __u32 pushed_seq; /* Last pushed seq, required to talk to windows */
344 __u32 copied_seq; /* Head of yet unread data */
345
346/* SACKs data */
347 struct tcp_sack_block duplicate_sack[1]; /* D-SACK block */
348 struct tcp_sack_block selective_acks[4]; /* The SACKS themselves*/
349
350 __u8 syn_retries; /* num of allowed syn retries */
351 __u8 ecn_flags; /* ECN status bits. */
352 __u16 prior_ssthresh; /* ssthresh saved at recovery start */
353 __u32 lost_out; /* Lost packets */
354 __u32 sacked_out; /* SACK'd packets */
355 __u32 fackets_out; /* FACK'd packets */
356 __u32 high_seq; /* snd_nxt at onset of congestion */
357
358 __u32 retrans_stamp; /* Timestamp of the last retransmit,
359 * also used in SYN-SENT to remember stamp of
360 * the first SYN. */
361 __u32 undo_marker; /* tracking retrans started here. */
362 int undo_retrans; /* number of undoable retransmissions. */
363 __u32 urg_seq; /* Seq of received urgent pointer */
364 __u16 urg_data; /* Saved octet of OOB data and control flags */
365 __u8 pending; /* Scheduled timer event */
366 __u8 urg_mode; /* In urgent mode */
367 __u32 snd_up; /* Urgent pointer */
368
369 __u32 total_retrans; /* Total retransmits for entire connection */
370
371 /* The syn_wait_lock is necessary only to avoid proc interface having
372 * to grab the main lock sock while browsing the listening hash
373 * (otherwise it's deadlock prone).
374 * This lock is acquired in read mode only from listening_get_next()
375 * and it's acquired in write mode _only_ from code that is actively
376 * changing the syn_wait_queue. All readers that are holding
377 * the master sock lock don't need to grab this lock in read mode
378 * too as the syn_wait_queue writes are always protected from
379 * the main sock lock.
380 */
381 rwlock_t syn_wait_lock;
382 struct tcp_listen_opt *listen_opt;
383
384 /* FIFO of established children */
385 struct open_request *accept_queue;
386 struct open_request *accept_queue_tail;
387
388 unsigned int keepalive_time; /* time before keep alive takes place */
389 unsigned int keepalive_intvl; /* time interval between keep alive probes */
390 int linger2;
391
392 unsigned long last_synq_overflow;
393
394/* Receiver side RTT estimation */
395 struct {
396 __u32 rtt;
397 __u32 seq;
398 __u32 time;
399 } rcv_rtt_est;
400
401/* Receiver queue space */
402 struct {
403 int space;
404 __u32 seq;
405 __u32 time;
406 } rcvq_space;
407
408/* TCP Westwood structure */
409 struct {
410 __u32 bw_ns_est; /* first bandwidth estimation..not too smoothed 8) */
411 __u32 bw_est; /* bandwidth estimate */
412 __u32 rtt_win_sx; /* here starts a new evaluation... */
413 __u32 bk;
414 __u32 snd_una; /* used for evaluating the number of acked bytes */
415 __u32 cumul_ack;
416 __u32 accounted;
417 __u32 rtt;
418 __u32 rtt_min; /* minimum observed RTT */
419 } westwood;
420
421/* Vegas variables */
422 struct {
423 __u32 beg_snd_nxt; /* right edge during last RTT */
424 __u32 beg_snd_una; /* left edge during last RTT */
425 __u32 beg_snd_cwnd; /* saves the size of the cwnd */
426 __u8 doing_vegas_now;/* if true, do vegas for this RTT */
427 __u16 cntRTT; /* # of RTTs measured within last RTT */
428 __u32 minRTT; /* min of RTTs measured within last RTT (in usec) */
429 __u32 baseRTT; /* the min of all Vegas RTT measurements seen (in usec) */
430 } vegas;
431
432 /* BI TCP Parameters */
433 struct {
434 __u32 cnt; /* increase cwnd by 1 after this number of ACKs */
435 __u32 last_max_cwnd; /* last maximium snd_cwnd */
436 __u32 last_cwnd; /* the last snd_cwnd */
437 __u32 last_stamp; /* time when updated last_cwnd */
438 } bictcp;
439};
440
441static inline struct tcp_sock *tcp_sk(const struct sock *sk)
442{
443 return (struct tcp_sock *)sk;
444}
445
446#endif
447
448#endif /* _LINUX_TCP_H */
diff --git a/include/linux/tcp_diag.h b/include/linux/tcp_diag.h
new file mode 100644
index 000000000000..ceee962e1d15
--- /dev/null
+++ b/include/linux/tcp_diag.h
@@ -0,0 +1,127 @@
1#ifndef _TCP_DIAG_H_
2#define _TCP_DIAG_H_ 1
3
4/* Just some random number */
5#define TCPDIAG_GETSOCK 18
6
7/* Socket identity */
8struct tcpdiag_sockid
9{
10 __u16 tcpdiag_sport;
11 __u16 tcpdiag_dport;
12 __u32 tcpdiag_src[4];
13 __u32 tcpdiag_dst[4];
14 __u32 tcpdiag_if;
15 __u32 tcpdiag_cookie[2];
16#define TCPDIAG_NOCOOKIE (~0U)
17};
18
19/* Request structure */
20
21struct tcpdiagreq
22{
23 __u8 tcpdiag_family; /* Family of addresses. */
24 __u8 tcpdiag_src_len;
25 __u8 tcpdiag_dst_len;
26 __u8 tcpdiag_ext; /* Query extended information */
27
28 struct tcpdiag_sockid id;
29
30 __u32 tcpdiag_states; /* States to dump */
31 __u32 tcpdiag_dbs; /* Tables to dump (NI) */
32};
33
34enum
35{
36 TCPDIAG_REQ_NONE,
37 TCPDIAG_REQ_BYTECODE,
38};
39
40#define TCPDIAG_REQ_MAX TCPDIAG_REQ_BYTECODE
41
42/* Bytecode is sequence of 4 byte commands followed by variable arguments.
43 * All the commands identified by "code" are conditional jumps forward:
44 * to offset cc+"yes" or to offset cc+"no". "yes" is supposed to be
45 * length of the command and its arguments.
46 */
47
48struct tcpdiag_bc_op
49{
50 unsigned char code;
51 unsigned char yes;
52 unsigned short no;
53};
54
55enum
56{
57 TCPDIAG_BC_NOP,
58 TCPDIAG_BC_JMP,
59 TCPDIAG_BC_S_GE,
60 TCPDIAG_BC_S_LE,
61 TCPDIAG_BC_D_GE,
62 TCPDIAG_BC_D_LE,
63 TCPDIAG_BC_AUTO,
64 TCPDIAG_BC_S_COND,
65 TCPDIAG_BC_D_COND,
66};
67
68struct tcpdiag_hostcond
69{
70 __u8 family;
71 __u8 prefix_len;
72 int port;
73 __u32 addr[0];
74};
75
76/* Base info structure. It contains socket identity (addrs/ports/cookie)
77 * and, alas, the information shown by netstat. */
78struct tcpdiagmsg
79{
80 __u8 tcpdiag_family;
81 __u8 tcpdiag_state;
82 __u8 tcpdiag_timer;
83 __u8 tcpdiag_retrans;
84
85 struct tcpdiag_sockid id;
86
87 __u32 tcpdiag_expires;
88 __u32 tcpdiag_rqueue;
89 __u32 tcpdiag_wqueue;
90 __u32 tcpdiag_uid;
91 __u32 tcpdiag_inode;
92};
93
94/* Extensions */
95
96enum
97{
98 TCPDIAG_NONE,
99 TCPDIAG_MEMINFO,
100 TCPDIAG_INFO,
101 TCPDIAG_VEGASINFO,
102};
103
104#define TCPDIAG_MAX TCPDIAG_VEGASINFO
105
106
107/* TCPDIAG_MEM */
108
109struct tcpdiag_meminfo
110{
111 __u32 tcpdiag_rmem;
112 __u32 tcpdiag_wmem;
113 __u32 tcpdiag_fmem;
114 __u32 tcpdiag_tmem;
115};
116
117/* TCPDIAG_VEGASINFO */
118
119struct tcpvegas_info {
120 __u32 tcpv_enabled;
121 __u32 tcpv_rttcnt;
122 __u32 tcpv_rtt;
123 __u32 tcpv_minrtt;
124};
125
126
127#endif /* _TCP_DIAG_H_ */
diff --git a/include/linux/telephony.h b/include/linux/telephony.h
new file mode 100644
index 000000000000..0d0cf2a1e7bc
--- /dev/null
+++ b/include/linux/telephony.h
@@ -0,0 +1,266 @@
1/******************************************************************************
2 *
3 * telephony.h
4 *
5 * Basic Linux Telephony Interface
6 *
7 * (c) Copyright 1999-2001 Quicknet Technologies, Inc.
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
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 *
14 * Authors: Ed Okerson, <eokerson@quicknet.net>
15 * Greg Herlein, <gherlein@quicknet.net>
16 *
17 * Contributors: Alan Cox, <alan@redhat.com>
18 * David W. Erhart, <derhart@quicknet.net>
19 *
20 * IN NO EVENT SHALL QUICKNET TECHNOLOGIES, INC. BE LIABLE TO ANY PARTY FOR
21 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
22 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF QUICKNET
23 * TECHNOLOGIES, INC. HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *
25 * QUICKNET TECHNOLOGIES, INC. SPECIFICALLY DISCLAIMS ANY WARRANTIES,
26 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
27 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
28 * ON AN "AS IS" BASIS, AND QUICKNET TECHNOLOGIES, INC. HAS NO OBLIGATION
29 * TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
30 *
31 * Version: $Revision: 4.2 $
32 *
33 * $Id: telephony.h,v 4.2 2001/08/06 07:09:43 craigs Exp $
34 *
35 *****************************************************************************/
36
37#ifndef TELEPHONY_H
38#define TELEPHONY_H
39
40#define TELEPHONY_VERSION 3013
41
42#define PHONE_VENDOR_IXJ 1
43#define PHONE_VENDOR_QUICKNET PHONE_VENDOR_IXJ
44#define PHONE_VENDOR_VOICETRONIX 2
45#define PHONE_VENDOR_ACULAB 3
46#define PHONE_VENDOR_DIGI 4
47#define PHONE_VENDOR_FRANKLIN 5
48
49/******************************************************************************
50 * Vendor Summary Information Area
51 *
52 * Quicknet Technologies, Inc. - makes low density analog telephony cards
53 * with audio compression, POTS and PSTN interfaces (www.quicknet.net)
54 *
55 * (other vendors following this API shuld add a short description of
56 * the telephony products they support under Linux)
57 *
58 *****************************************************************************/
59#define QTI_PHONEJACK 100
60#define QTI_LINEJACK 300
61#define QTI_PHONEJACK_LITE 400
62#define QTI_PHONEJACK_PCI 500
63#define QTI_PHONECARD 600
64
65/******************************************************************************
66*
67* The capabilities ioctls can inform you of the capabilities of each phone
68* device installed in your system. The PHONECTL_CAPABILITIES ioctl
69* returns an integer value indicating the number of capabilities the
70* device has. The PHONECTL_CAPABILITIES_LIST will fill an array of
71* capability structs with all of its capabilities. The
72* PHONECTL_CAPABILITIES_CHECK takes a single capability struct and returns
73* a TRUE if the device has that capability, otherwise it returns false.
74*
75******************************************************************************/
76typedef enum {
77 vendor = 0,
78 device,
79 port,
80 codec,
81 dsp
82} phone_cap;
83
84struct phone_capability {
85 char desc[80];
86 phone_cap captype;
87 int cap;
88 int handle;
89};
90
91typedef enum {
92 pots = 0,
93 pstn,
94 handset,
95 speaker
96} phone_ports;
97
98#define PHONE_CAPABILITIES _IO ('q', 0x80)
99#define PHONE_CAPABILITIES_LIST _IOR ('q', 0x81, struct phone_capability *)
100#define PHONE_CAPABILITIES_CHECK _IOW ('q', 0x82, struct phone_capability *)
101
102typedef struct {
103 char month[3];
104 char day[3];
105 char hour[3];
106 char min[3];
107 int numlen;
108 char number[11];
109 int namelen;
110 char name[80];
111} PHONE_CID;
112
113#define PHONE_RING _IO ('q', 0x83)
114#define PHONE_HOOKSTATE _IO ('q', 0x84)
115#define PHONE_MAXRINGS _IOW ('q', 0x85, char)
116#define PHONE_RING_CADENCE _IOW ('q', 0x86, short)
117#define OLD_PHONE_RING_START _IO ('q', 0x87)
118#define PHONE_RING_START _IOW ('q', 0x87, PHONE_CID *)
119#define PHONE_RING_STOP _IO ('q', 0x88)
120
121#define USA_RING_CADENCE 0xC0C0
122
123#define PHONE_REC_CODEC _IOW ('q', 0x89, int)
124#define PHONE_REC_START _IO ('q', 0x8A)
125#define PHONE_REC_STOP _IO ('q', 0x8B)
126#define PHONE_REC_DEPTH _IOW ('q', 0x8C, int)
127#define PHONE_FRAME _IOW ('q', 0x8D, int)
128#define PHONE_REC_VOLUME _IOW ('q', 0x8E, int)
129#define PHONE_REC_VOLUME_LINEAR _IOW ('q', 0xDB, int)
130#define PHONE_REC_LEVEL _IO ('q', 0x8F)
131
132#define PHONE_PLAY_CODEC _IOW ('q', 0x90, int)
133#define PHONE_PLAY_START _IO ('q', 0x91)
134#define PHONE_PLAY_STOP _IO ('q', 0x92)
135#define PHONE_PLAY_DEPTH _IOW ('q', 0x93, int)
136#define PHONE_PLAY_VOLUME _IOW ('q', 0x94, int)
137#define PHONE_PLAY_VOLUME_LINEAR _IOW ('q', 0xDC, int)
138#define PHONE_PLAY_LEVEL _IO ('q', 0x95)
139#define PHONE_DTMF_READY _IOR ('q', 0x96, int)
140#define PHONE_GET_DTMF _IOR ('q', 0x97, int)
141#define PHONE_GET_DTMF_ASCII _IOR ('q', 0x98, int)
142#define PHONE_DTMF_OOB _IOW ('q', 0x99, int)
143#define PHONE_EXCEPTION _IOR ('q', 0x9A, int)
144#define PHONE_PLAY_TONE _IOW ('q', 0x9B, char)
145#define PHONE_SET_TONE_ON_TIME _IOW ('q', 0x9C, int)
146#define PHONE_SET_TONE_OFF_TIME _IOW ('q', 0x9D, int)
147#define PHONE_GET_TONE_ON_TIME _IO ('q', 0x9E)
148#define PHONE_GET_TONE_OFF_TIME _IO ('q', 0x9F)
149#define PHONE_GET_TONE_STATE _IO ('q', 0xA0)
150#define PHONE_BUSY _IO ('q', 0xA1)
151#define PHONE_RINGBACK _IO ('q', 0xA2)
152#define PHONE_DIALTONE _IO ('q', 0xA3)
153#define PHONE_CPT_STOP _IO ('q', 0xA4)
154
155#define PHONE_PSTN_SET_STATE _IOW ('q', 0xA4, int)
156#define PHONE_PSTN_GET_STATE _IO ('q', 0xA5)
157
158#define PSTN_ON_HOOK 0
159#define PSTN_RINGING 1
160#define PSTN_OFF_HOOK 2
161#define PSTN_PULSE_DIAL 3
162
163/******************************************************************************
164*
165* The wink duration is tunable with this ioctl. The default wink duration
166* is 320ms. You do not need to use this ioctl if you do not require a
167* different wink duration.
168*
169******************************************************************************/
170#define PHONE_WINK_DURATION _IOW ('q', 0xA6, int)
171#define PHONE_WINK _IOW ('q', 0xAA, int)
172
173/******************************************************************************
174*
175* Codec Definitions
176*
177******************************************************************************/
178typedef enum {
179 G723_63 = 1,
180 G723_53 = 2,
181 TS85 = 3,
182 TS48 = 4,
183 TS41 = 5,
184 G728 = 6,
185 G729 = 7,
186 ULAW = 8,
187 ALAW = 9,
188 LINEAR16 = 10,
189 LINEAR8 = 11,
190 WSS = 12,
191 G729B = 13
192} phone_codec;
193
194struct phone_codec_data
195{
196 phone_codec type;
197 unsigned short buf_min, buf_opt, buf_max;
198};
199
200#define PHONE_QUERY_CODEC _IOWR ('q', 0xA7, struct phone_codec_data *)
201#define PHONE_PSTN_LINETEST _IO ('q', 0xA8)
202
203/******************************************************************************
204*
205* This controls the VAD/CNG functionality of G.723.1. The driver will
206* always pass full size frames, any unused bytes will be padded with zeros,
207* and frames passed to the driver should also be padded with zeros. The
208* frame type is encoded in the least significant two bits of the first
209* WORD of the frame as follows:
210*
211* bits 1-0 Frame Type Data Rate Significant Words
212* 00 0 G.723.1 6.3 12
213* 01 1 G.723.1 5.3 10
214* 10 2 VAD/CNG 2
215* 11 3 Repeat last CNG 2 bits
216*
217******************************************************************************/
218#define PHONE_VAD _IOW ('q', 0xA9, int)
219
220
221/******************************************************************************
222*
223* The exception structure allows us to multiplex multiple events onto the
224* select() exception set. If any of these flags are set select() will
225* return with a positive indication on the exception set. The dtmf_ready
226* bit indicates if there is data waiting in the DTMF buffer. The
227* hookstate bit is set if there is a change in hookstate status, it does not
228* indicate the current state of the hookswitch. The pstn_ring bit
229* indicates that the DAA on a LineJACK card has detected ring voltage on
230* the PSTN port. The caller_id bit indicates that caller_id data has been
231* received and is available. The pstn_wink bit indicates that the DAA on
232* the LineJACK has received a wink from the telco switch. The f0, f1, f2
233* and f3 bits indicate that the filter has been triggered by detecting the
234* frequency programmed into that filter.
235*
236* The remaining bits should be set to zero. They will become defined over time
237* for other interface cards and their needs.
238*
239******************************************************************************/
240struct phone_except
241{
242 unsigned int dtmf_ready:1;
243 unsigned int hookstate:1;
244 unsigned int pstn_ring:1;
245 unsigned int caller_id:1;
246 unsigned int pstn_wink:1;
247 unsigned int f0:1;
248 unsigned int f1:1;
249 unsigned int f2:1;
250 unsigned int f3:1;
251 unsigned int flash:1;
252 unsigned int fc0:1;
253 unsigned int fc1:1;
254 unsigned int fc2:1;
255 unsigned int fc3:1;
256 unsigned int reserved:18;
257};
258
259union telephony_exception {
260 struct phone_except bits;
261 unsigned int bytes;
262};
263
264
265#endif /* TELEPHONY_H */
266
diff --git a/include/linux/termios.h b/include/linux/termios.h
new file mode 100644
index 000000000000..478662889f48
--- /dev/null
+++ b/include/linux/termios.h
@@ -0,0 +1,7 @@
1#ifndef _LINUX_TERMIOS_H
2#define _LINUX_TERMIOS_H
3
4#include <linux/types.h>
5#include <asm/termios.h>
6
7#endif
diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
new file mode 100644
index 000000000000..d252f45a0f9b
--- /dev/null
+++ b/include/linux/thread_info.h
@@ -0,0 +1,92 @@
1/* thread_info.h: common low-level thread information accessors
2 *
3 * Copyright (C) 2002 David Howells (dhowells@redhat.com)
4 * - Incorporating suggestions made by Linus Torvalds
5 */
6
7#ifndef _LINUX_THREAD_INFO_H
8#define _LINUX_THREAD_INFO_H
9
10/*
11 * System call restart block.
12 */
13struct restart_block {
14 long (*fn)(struct restart_block *);
15 unsigned long arg0, arg1, arg2, arg3;
16};
17
18extern long do_no_restart_syscall(struct restart_block *parm);
19
20#include <linux/bitops.h>
21#include <asm/thread_info.h>
22
23#ifdef __KERNEL__
24
25/*
26 * flag set/clear/test wrappers
27 * - pass TIF_xxxx constants to these functions
28 */
29
30static inline void set_thread_flag(int flag)
31{
32 set_bit(flag,&current_thread_info()->flags);
33}
34
35static inline void clear_thread_flag(int flag)
36{
37 clear_bit(flag,&current_thread_info()->flags);
38}
39
40static inline int test_and_set_thread_flag(int flag)
41{
42 return test_and_set_bit(flag,&current_thread_info()->flags);
43}
44
45static inline int test_and_clear_thread_flag(int flag)
46{
47 return test_and_clear_bit(flag,&current_thread_info()->flags);
48}
49
50static inline int test_thread_flag(int flag)
51{
52 return test_bit(flag,&current_thread_info()->flags);
53}
54
55static inline void set_ti_thread_flag(struct thread_info *ti, int flag)
56{
57 set_bit(flag,&ti->flags);
58}
59
60static inline void clear_ti_thread_flag(struct thread_info *ti, int flag)
61{
62 clear_bit(flag,&ti->flags);
63}
64
65static inline int test_and_set_ti_thread_flag(struct thread_info *ti, int flag)
66{
67 return test_and_set_bit(flag,&ti->flags);
68}
69
70static inline int test_and_clear_ti_thread_flag(struct thread_info *ti, int flag)
71{
72 return test_and_clear_bit(flag,&ti->flags);
73}
74
75static inline int test_ti_thread_flag(struct thread_info *ti, int flag)
76{
77 return test_bit(flag,&ti->flags);
78}
79
80static inline void set_need_resched(void)
81{
82 set_thread_flag(TIF_NEED_RESCHED);
83}
84
85static inline void clear_need_resched(void)
86{
87 clear_thread_flag(TIF_NEED_RESCHED);
88}
89
90#endif
91
92#endif /* _LINUX_THREAD_INFO_H */
diff --git a/include/linux/threads.h b/include/linux/threads.h
new file mode 100644
index 000000000000..b59738ac6197
--- /dev/null
+++ b/include/linux/threads.h
@@ -0,0 +1,36 @@
1#ifndef _LINUX_THREADS_H
2#define _LINUX_THREADS_H
3
4#include <linux/config.h>
5
6/*
7 * The default limit for the nr of threads is now in
8 * /proc/sys/kernel/threads-max.
9 */
10
11/*
12 * Maximum supported processors that can run under SMP. This value is
13 * set via configure setting. The maximum is equal to the size of the
14 * bitmasks used on that platform, i.e. 32 or 64. Setting this smaller
15 * saves quite a bit of memory.
16 */
17#ifdef CONFIG_SMP
18#define NR_CPUS CONFIG_NR_CPUS
19#else
20#define NR_CPUS 1
21#endif
22
23#define MIN_THREADS_LEFT_FOR_ROOT 4
24
25/*
26 * This controls the default maximum pid allocated to a process
27 */
28#define PID_MAX_DEFAULT (CONFIG_BASE_SMALL ? 0x1000 : 0x8000)
29
30/*
31 * A maximum of 4 million PIDs should be enough for a while:
32 */
33#define PID_MAX_LIMIT (CONFIG_BASE_SMALL ? PAGE_SIZE * 8 : \
34 (sizeof(long) > 4 ? 4 * 1024 * 1024 : PID_MAX_DEFAULT))
35
36#endif
diff --git a/include/linux/ticable.h b/include/linux/ticable.h
new file mode 100644
index 000000000000..8c2212086dcd
--- /dev/null
+++ b/include/linux/ticable.h
@@ -0,0 +1,44 @@
1/* Hey EMACS -*- linux-c -*-
2 *
3 * tipar/tiser/tiusb - low level driver for handling link cables
4 * designed for Texas Instruments graphing calculators.
5 *
6 * Copyright (C) 2000-2002, Romain Lievin <roms@lpg.ticalc.org>
7 *
8 * Redistribution of this file is permitted under the terms of the GNU
9 * Public License (GPL)
10 */
11
12#ifndef _TICABLE_H
13#define _TICABLE_H 1
14
15/* Internal default constants for the kernel module */
16#define TIMAXTIME 15 /* 1.5 seconds */
17#define IO_DELAY 10 /* 10 micro-seconds */
18
19/* Major & minor number for character devices */
20#define TIPAR_MAJOR 115 /* 0 to 7 */
21#define TIPAR_MINOR 0
22
23#define TISER_MAJOR 115 /* 8 to 15 */
24#define TISER_MINOR 8
25
26#define TIUSB_MAJOR 115 /* 16 to 31 */
27#define TIUSB_MINOR 16
28
29/*
30 * Request values for the 'ioctl' function.
31 */
32#define IOCTL_TIPAR_DELAY _IOW('p', 0xa8, int) /* set delay */
33#define IOCTL_TIPAR_TIMEOUT _IOW('p', 0xa9, int) /* set timeout */
34
35#define IOCTL_TISER_DELAY _IOW('p', 0xa0, int) /* set delay */
36#define IOCTL_TISER_TIMEOUT _IOW('p', 0xa1, int) /* set timeout */
37
38#define IOCTL_TIUSB_TIMEOUT _IOW('N', 0x20, int) /* set timeout */
39#define IOCTL_TIUSB_RESET_DEVICE _IOW('N', 0x21, int) /* reset device */
40#define IOCTL_TIUSB_RESET_PIPES _IOW('N', 0x22, int) /* reset both pipes*/
41#define IOCTL_TIUSB_GET_MAXPS _IOR('N', 0x23, int) /* max packet size */
42#define IOCTL_TIUSB_GET_DEVID _IOR('N', 0x24, int) /* get device type */
43
44#endif /* TICABLE_H */
diff --git a/include/linux/time.h b/include/linux/time.h
new file mode 100644
index 000000000000..5634497ff5df
--- /dev/null
+++ b/include/linux/time.h
@@ -0,0 +1,181 @@
1#ifndef _LINUX_TIME_H
2#define _LINUX_TIME_H
3
4#include <linux/types.h>
5
6#ifdef __KERNEL__
7#include <linux/seqlock.h>
8#endif
9
10#ifndef _STRUCT_TIMESPEC
11#define _STRUCT_TIMESPEC
12struct timespec {
13 time_t tv_sec; /* seconds */
14 long tv_nsec; /* nanoseconds */
15};
16#endif /* _STRUCT_TIMESPEC */
17
18struct timeval {
19 time_t tv_sec; /* seconds */
20 suseconds_t tv_usec; /* microseconds */
21};
22
23struct timezone {
24 int tz_minuteswest; /* minutes west of Greenwich */
25 int tz_dsttime; /* type of dst correction */
26};
27
28#ifdef __KERNEL__
29
30/* Parameters used to convert the timespec values */
31#ifndef USEC_PER_SEC
32#define USEC_PER_SEC (1000000L)
33#endif
34
35#ifndef NSEC_PER_SEC
36#define NSEC_PER_SEC (1000000000L)
37#endif
38
39#ifndef NSEC_PER_USEC
40#define NSEC_PER_USEC (1000L)
41#endif
42
43static __inline__ int timespec_equal(struct timespec *a, struct timespec *b)
44{
45 return (a->tv_sec == b->tv_sec) && (a->tv_nsec == b->tv_nsec);
46}
47
48/* Converts Gregorian date to seconds since 1970-01-01 00:00:00.
49 * Assumes input in normal date format, i.e. 1980-12-31 23:59:59
50 * => year=1980, mon=12, day=31, hour=23, min=59, sec=59.
51 *
52 * [For the Julian calendar (which was used in Russia before 1917,
53 * Britain & colonies before 1752, anywhere else before 1582,
54 * and is still in use by some communities) leave out the
55 * -year/100+year/400 terms, and add 10.]
56 *
57 * This algorithm was first published by Gauss (I think).
58 *
59 * WARNING: this function will overflow on 2106-02-07 06:28:16 on
60 * machines were long is 32-bit! (However, as time_t is signed, we
61 * will already get problems at other places on 2038-01-19 03:14:08)
62 */
63static inline unsigned long
64mktime (unsigned int year, unsigned int mon,
65 unsigned int day, unsigned int hour,
66 unsigned int min, unsigned int sec)
67{
68 if (0 >= (int) (mon -= 2)) { /* 1..12 -> 11,12,1..10 */
69 mon += 12; /* Puts Feb last since it has leap day */
70 year -= 1;
71 }
72
73 return (((
74 (unsigned long) (year/4 - year/100 + year/400 + 367*mon/12 + day) +
75 year*365 - 719499
76 )*24 + hour /* now have hours */
77 )*60 + min /* now have minutes */
78 )*60 + sec; /* finally seconds */
79}
80
81extern struct timespec xtime;
82extern struct timespec wall_to_monotonic;
83extern seqlock_t xtime_lock;
84
85static inline unsigned long get_seconds(void)
86{
87 return xtime.tv_sec;
88}
89
90struct timespec current_kernel_time(void);
91
92#define CURRENT_TIME (current_kernel_time())
93#define CURRENT_TIME_SEC ((struct timespec) { xtime.tv_sec, 0 })
94
95extern void do_gettimeofday(struct timeval *tv);
96extern int do_settimeofday(struct timespec *tv);
97extern int do_sys_settimeofday(struct timespec *tv, struct timezone *tz);
98extern void clock_was_set(void); // call when ever the clock is set
99extern int do_posix_clock_monotonic_gettime(struct timespec *tp);
100extern long do_nanosleep(struct timespec *t);
101extern long do_utimes(char __user * filename, struct timeval * times);
102struct itimerval;
103extern int do_setitimer(int which, struct itimerval *value, struct itimerval *ovalue);
104extern int do_getitimer(int which, struct itimerval *value);
105extern void getnstimeofday (struct timespec *tv);
106
107extern struct timespec timespec_trunc(struct timespec t, unsigned gran);
108
109static inline void
110set_normalized_timespec (struct timespec *ts, time_t sec, long nsec)
111{
112 while (nsec > NSEC_PER_SEC) {
113 nsec -= NSEC_PER_SEC;
114 ++sec;
115 }
116 while (nsec < 0) {
117 nsec += NSEC_PER_SEC;
118 --sec;
119 }
120 ts->tv_sec = sec;
121 ts->tv_nsec = nsec;
122}
123
124#endif /* __KERNEL__ */
125
126#define NFDBITS __NFDBITS
127
128#define FD_SETSIZE __FD_SETSIZE
129#define FD_SET(fd,fdsetp) __FD_SET(fd,fdsetp)
130#define FD_CLR(fd,fdsetp) __FD_CLR(fd,fdsetp)
131#define FD_ISSET(fd,fdsetp) __FD_ISSET(fd,fdsetp)
132#define FD_ZERO(fdsetp) __FD_ZERO(fdsetp)
133
134/*
135 * Names of the interval timers, and structure
136 * defining a timer setting.
137 */
138#define ITIMER_REAL 0
139#define ITIMER_VIRTUAL 1
140#define ITIMER_PROF 2
141
142struct itimerspec {
143 struct timespec it_interval; /* timer period */
144 struct timespec it_value; /* timer expiration */
145};
146
147struct itimerval {
148 struct timeval it_interval; /* timer interval */
149 struct timeval it_value; /* current value */
150};
151
152
153/*
154 * The IDs of the various system clocks (for POSIX.1b interval timers).
155 */
156#define CLOCK_REALTIME 0
157#define CLOCK_MONOTONIC 1
158#define CLOCK_PROCESS_CPUTIME_ID 2
159#define CLOCK_THREAD_CPUTIME_ID 3
160#define CLOCK_REALTIME_HR 4
161#define CLOCK_MONOTONIC_HR 5
162
163/*
164 * The IDs of various hardware clocks
165 */
166
167
168#define CLOCK_SGI_CYCLE 10
169#define MAX_CLOCKS 16
170#define CLOCKS_MASK (CLOCK_REALTIME | CLOCK_MONOTONIC | \
171 CLOCK_REALTIME_HR | CLOCK_MONOTONIC_HR)
172#define CLOCKS_MONO (CLOCK_MONOTONIC & CLOCK_MONOTONIC_HR)
173
174/*
175 * The various flags for setting POSIX.1b interval timers.
176 */
177
178#define TIMER_ABSTIME 0x01
179
180
181#endif
diff --git a/include/linux/timer.h b/include/linux/timer.h
new file mode 100644
index 000000000000..90db1cc62ddd
--- /dev/null
+++ b/include/linux/timer.h
@@ -0,0 +1,102 @@
1#ifndef _LINUX_TIMER_H
2#define _LINUX_TIMER_H
3
4#include <linux/config.h>
5#include <linux/list.h>
6#include <linux/spinlock.h>
7#include <linux/stddef.h>
8
9struct tvec_t_base_s;
10
11struct timer_list {
12 struct list_head entry;
13 unsigned long expires;
14
15 spinlock_t lock;
16 unsigned long magic;
17
18 void (*function)(unsigned long);
19 unsigned long data;
20
21 struct tvec_t_base_s *base;
22};
23
24#define TIMER_MAGIC 0x4b87ad6e
25
26#define TIMER_INITIALIZER(_function, _expires, _data) { \
27 .function = (_function), \
28 .expires = (_expires), \
29 .data = (_data), \
30 .base = NULL, \
31 .magic = TIMER_MAGIC, \
32 .lock = SPIN_LOCK_UNLOCKED, \
33 }
34
35/***
36 * init_timer - initialize a timer.
37 * @timer: the timer to be initialized
38 *
39 * init_timer() must be done to a timer prior calling *any* of the
40 * other timer functions.
41 */
42static inline void init_timer(struct timer_list * timer)
43{
44 timer->base = NULL;
45 timer->magic = TIMER_MAGIC;
46 spin_lock_init(&timer->lock);
47}
48
49/***
50 * timer_pending - is a timer pending?
51 * @timer: the timer in question
52 *
53 * timer_pending will tell whether a given timer is currently pending,
54 * or not. Callers must ensure serialization wrt. other operations done
55 * to this timer, eg. interrupt contexts, or other CPUs on SMP.
56 *
57 * return value: 1 if the timer is pending, 0 if not.
58 */
59static inline int timer_pending(const struct timer_list * timer)
60{
61 return timer->base != NULL;
62}
63
64extern void add_timer_on(struct timer_list *timer, int cpu);
65extern int del_timer(struct timer_list * timer);
66extern int __mod_timer(struct timer_list *timer, unsigned long expires);
67extern int mod_timer(struct timer_list *timer, unsigned long expires);
68
69extern unsigned long next_timer_interrupt(void);
70
71/***
72 * add_timer - start a timer
73 * @timer: the timer to be added
74 *
75 * The kernel will do a ->function(->data) callback from the
76 * timer interrupt at the ->expired point in the future. The
77 * current time is 'jiffies'.
78 *
79 * The timer's ->expired, ->function (and if the handler uses it, ->data)
80 * fields must be set prior calling this function.
81 *
82 * Timers with an ->expired field in the past will be executed in the next
83 * timer tick.
84 */
85static inline void add_timer(struct timer_list * timer)
86{
87 __mod_timer(timer, timer->expires);
88}
89
90#ifdef CONFIG_SMP
91 extern int del_timer_sync(struct timer_list *timer);
92 extern int del_singleshot_timer_sync(struct timer_list *timer);
93#else
94# define del_timer_sync(t) del_timer(t)
95# define del_singleshot_timer_sync(t) del_timer(t)
96#endif
97
98extern void init_timers(void);
99extern void run_local_timers(void);
100extern void it_real_fn(unsigned long);
101
102#endif
diff --git a/include/linux/times.h b/include/linux/times.h
new file mode 100644
index 000000000000..e2d3020742a6
--- /dev/null
+++ b/include/linux/times.h
@@ -0,0 +1,13 @@
1#ifndef _LINUX_TIMES_H
2#define _LINUX_TIMES_H
3
4#include <linux/types.h>
5
6struct tms {
7 clock_t tms_utime;
8 clock_t tms_stime;
9 clock_t tms_cutime;
10 clock_t tms_cstime;
11};
12
13#endif
diff --git a/include/linux/timex.h b/include/linux/timex.h
new file mode 100644
index 000000000000..74fdd07d3792
--- /dev/null
+++ b/include/linux/timex.h
@@ -0,0 +1,320 @@
1/*****************************************************************************
2 * *
3 * Copyright (c) David L. Mills 1993 *
4 * *
5 * Permission to use, copy, modify, and distribute this software and its *
6 * documentation for any purpose and without fee is hereby granted, provided *
7 * that the above copyright notice appears in all copies and that both the *
8 * copyright notice and this permission notice appear in supporting *
9 * documentation, and that the name University of Delaware not be used in *
10 * advertising or publicity pertaining to distribution of the software *
11 * without specific, written prior permission. The University of Delaware *
12 * makes no representations about the suitability this software for any *
13 * purpose. It is provided "as is" without express or implied warranty. *
14 * *
15 *****************************************************************************/
16
17/*
18 * Modification history timex.h
19 *
20 * 29 Dec 97 Russell King
21 * Moved CLOCK_TICK_RATE, CLOCK_TICK_FACTOR and FINETUNE to asm/timex.h
22 * for ARM machines
23 *
24 * 9 Jan 97 Adrian Sun
25 * Shifted LATCH define to allow access to alpha machines.
26 *
27 * 26 Sep 94 David L. Mills
28 * Added defines for hybrid phase/frequency-lock loop.
29 *
30 * 19 Mar 94 David L. Mills
31 * Moved defines from kernel routines to header file and added new
32 * defines for PPS phase-lock loop.
33 *
34 * 20 Feb 94 David L. Mills
35 * Revised status codes and structures for external clock and PPS
36 * signal discipline.
37 *
38 * 28 Nov 93 David L. Mills
39 * Adjusted parameters to improve stability and increase poll
40 * interval.
41 *
42 * 17 Sep 93 David L. Mills
43 * Created file $NTP/include/sys/timex.h
44 * 07 Oct 93 Torsten Duwe
45 * Derived linux/timex.h
46 * 1995-08-13 Torsten Duwe
47 * kernel PLL updated to 1994-12-13 specs (rfc-1589)
48 * 1997-08-30 Ulrich Windl
49 * Added new constant NTP_PHASE_LIMIT
50 * 2004-08-12 Christoph Lameter
51 * Reworked time interpolation logic
52 */
53#ifndef _LINUX_TIMEX_H
54#define _LINUX_TIMEX_H
55
56#include <linux/config.h>
57#include <linux/compiler.h>
58#include <linux/time.h>
59
60#include <asm/param.h>
61#include <asm/timex.h>
62
63/*
64 * SHIFT_KG and SHIFT_KF establish the damping of the PLL and are chosen
65 * for a slightly underdamped convergence characteristic. SHIFT_KH
66 * establishes the damping of the FLL and is chosen by wisdom and black
67 * art.
68 *
69 * MAXTC establishes the maximum time constant of the PLL. With the
70 * SHIFT_KG and SHIFT_KF values given and a time constant range from
71 * zero to MAXTC, the PLL will converge in 15 minutes to 16 hours,
72 * respectively.
73 */
74#define SHIFT_KG 6 /* phase factor (shift) */
75#define SHIFT_KF 16 /* PLL frequency factor (shift) */
76#define SHIFT_KH 2 /* FLL frequency factor (shift) */
77#define MAXTC 6 /* maximum time constant (shift) */
78
79/*
80 * The SHIFT_SCALE define establishes the decimal point of the time_phase
81 * variable which serves as an extension to the low-order bits of the
82 * system clock variable. The SHIFT_UPDATE define establishes the decimal
83 * point of the time_offset variable which represents the current offset
84 * with respect to standard time. The FINENSEC define represents 1 nsec in
85 * scaled units.
86 *
87 * SHIFT_USEC defines the scaling (shift) of the time_freq and
88 * time_tolerance variables, which represent the current frequency
89 * offset and maximum frequency tolerance.
90 *
91 * FINENSEC is 1 ns in SHIFT_UPDATE units of the time_phase variable.
92 */
93#define SHIFT_SCALE 22 /* phase scale (shift) */
94#define SHIFT_UPDATE (SHIFT_KG + MAXTC) /* time offset scale (shift) */
95#define SHIFT_USEC 16 /* frequency offset scale (shift) */
96#define FINENSEC (1L << (SHIFT_SCALE - 10)) /* ~1 ns in phase units */
97
98#define MAXPHASE 512000L /* max phase error (us) */
99#define MAXFREQ (512L << SHIFT_USEC) /* max frequency error (ppm) */
100#define MAXTIME (200L << PPS_AVG) /* max PPS error (jitter) (200 us) */
101#define MINSEC 16L /* min interval between updates (s) */
102#define MAXSEC 1200L /* max interval between updates (s) */
103#define NTP_PHASE_LIMIT (MAXPHASE << 5) /* beyond max. dispersion */
104
105/*
106 * The following defines are used only if a pulse-per-second (PPS)
107 * signal is available and connected via a modem control lead, such as
108 * produced by the optional ppsclock feature incorporated in the Sun
109 * asynch driver. They establish the design parameters of the frequency-
110 * lock loop used to discipline the CPU clock oscillator to the PPS
111 * signal.
112 *
113 * PPS_AVG is the averaging factor for the frequency loop, as well as
114 * the time and frequency dispersion.
115 *
116 * PPS_SHIFT and PPS_SHIFTMAX specify the minimum and maximum
117 * calibration intervals, respectively, in seconds as a power of two.
118 *
119 * PPS_VALID is the maximum interval before the PPS signal is considered
120 * invalid and protocol updates used directly instead.
121 *
122 * MAXGLITCH is the maximum interval before a time offset of more than
123 * MAXTIME is believed.
124 */
125#define PPS_AVG 2 /* pps averaging constant (shift) */
126#define PPS_SHIFT 2 /* min interval duration (s) (shift) */
127#define PPS_SHIFTMAX 8 /* max interval duration (s) (shift) */
128#define PPS_VALID 120 /* pps signal watchdog max (s) */
129#define MAXGLITCH 30 /* pps signal glitch max (s) */
130
131/*
132 * syscall interface - used (mainly by NTP daemon)
133 * to discipline kernel clock oscillator
134 */
135struct timex {
136 unsigned int modes; /* mode selector */
137 long offset; /* time offset (usec) */
138 long freq; /* frequency offset (scaled ppm) */
139 long maxerror; /* maximum error (usec) */
140 long esterror; /* estimated error (usec) */
141 int status; /* clock command/status */
142 long constant; /* pll time constant */
143 long precision; /* clock precision (usec) (read only) */
144 long tolerance; /* clock frequency tolerance (ppm)
145 * (read only)
146 */
147 struct timeval time; /* (read only) */
148 long tick; /* (modified) usecs between clock ticks */
149
150 long ppsfreq; /* pps frequency (scaled ppm) (ro) */
151 long jitter; /* pps jitter (us) (ro) */
152 int shift; /* interval duration (s) (shift) (ro) */
153 long stabil; /* pps stability (scaled ppm) (ro) */
154 long jitcnt; /* jitter limit exceeded (ro) */
155 long calcnt; /* calibration intervals (ro) */
156 long errcnt; /* calibration errors (ro) */
157 long stbcnt; /* stability limit exceeded (ro) */
158
159 int :32; int :32; int :32; int :32;
160 int :32; int :32; int :32; int :32;
161 int :32; int :32; int :32; int :32;
162};
163
164/*
165 * Mode codes (timex.mode)
166 */
167#define ADJ_OFFSET 0x0001 /* time offset */
168#define ADJ_FREQUENCY 0x0002 /* frequency offset */
169#define ADJ_MAXERROR 0x0004 /* maximum time error */
170#define ADJ_ESTERROR 0x0008 /* estimated time error */
171#define ADJ_STATUS 0x0010 /* clock status */
172#define ADJ_TIMECONST 0x0020 /* pll time constant */
173#define ADJ_TICK 0x4000 /* tick value */
174#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */
175
176/* xntp 3.4 compatibility names */
177#define MOD_OFFSET ADJ_OFFSET
178#define MOD_FREQUENCY ADJ_FREQUENCY
179#define MOD_MAXERROR ADJ_MAXERROR
180#define MOD_ESTERROR ADJ_ESTERROR
181#define MOD_STATUS ADJ_STATUS
182#define MOD_TIMECONST ADJ_TIMECONST
183#define MOD_CLKB ADJ_TICK
184#define MOD_CLKA ADJ_OFFSET_SINGLESHOT /* 0x8000 in original */
185
186
187/*
188 * Status codes (timex.status)
189 */
190#define STA_PLL 0x0001 /* enable PLL updates (rw) */
191#define STA_PPSFREQ 0x0002 /* enable PPS freq discipline (rw) */
192#define STA_PPSTIME 0x0004 /* enable PPS time discipline (rw) */
193#define STA_FLL 0x0008 /* select frequency-lock mode (rw) */
194
195#define STA_INS 0x0010 /* insert leap (rw) */
196#define STA_DEL 0x0020 /* delete leap (rw) */
197#define STA_UNSYNC 0x0040 /* clock unsynchronized (rw) */
198#define STA_FREQHOLD 0x0080 /* hold frequency (rw) */
199
200#define STA_PPSSIGNAL 0x0100 /* PPS signal present (ro) */
201#define STA_PPSJITTER 0x0200 /* PPS signal jitter exceeded (ro) */
202#define STA_PPSWANDER 0x0400 /* PPS signal wander exceeded (ro) */
203#define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */
204
205#define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */
206
207#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \
208 STA_PPSERROR | STA_CLOCKERR) /* read-only bits */
209
210/*
211 * Clock states (time_state)
212 */
213#define TIME_OK 0 /* clock synchronized, no leap second */
214#define TIME_INS 1 /* insert leap second */
215#define TIME_DEL 2 /* delete leap second */
216#define TIME_OOP 3 /* leap second in progress */
217#define TIME_WAIT 4 /* leap second has occurred */
218#define TIME_ERROR 5 /* clock not synchronized */
219#define TIME_BAD TIME_ERROR /* bw compat */
220
221#ifdef __KERNEL__
222/*
223 * kernel variables
224 * Note: maximum error = NTP synch distance = dispersion + delay / 2;
225 * estimated error = NTP dispersion.
226 */
227extern unsigned long tick_usec; /* USER_HZ period (usec) */
228extern unsigned long tick_nsec; /* ACTHZ period (nsec) */
229extern int tickadj; /* amount of adjustment per tick */
230
231/*
232 * phase-lock loop variables
233 */
234extern int time_state; /* clock status */
235extern int time_status; /* clock synchronization status bits */
236extern long time_offset; /* time adjustment (us) */
237extern long time_constant; /* pll time constant */
238extern long time_tolerance; /* frequency tolerance (ppm) */
239extern long time_precision; /* clock precision (us) */
240extern long time_maxerror; /* maximum error */
241extern long time_esterror; /* estimated error */
242
243extern long time_freq; /* frequency offset (scaled ppm) */
244extern long time_reftime; /* time at last adjustment (s) */
245
246extern long time_adjust; /* The amount of adjtime left */
247extern long time_next_adjust; /* Value for time_adjust at next tick */
248
249/* interface variables pps->timer interrupt */
250extern long pps_offset; /* pps time offset (us) */
251extern long pps_jitter; /* time dispersion (jitter) (us) */
252extern long pps_freq; /* frequency offset (scaled ppm) */
253extern long pps_stabil; /* frequency dispersion (scaled ppm) */
254extern long pps_valid; /* pps signal watchdog counter */
255
256/* interface variables pps->adjtimex */
257extern int pps_shift; /* interval duration (s) (shift) */
258extern long pps_jitcnt; /* jitter limit exceeded */
259extern long pps_calcnt; /* calibration intervals */
260extern long pps_errcnt; /* calibration errors */
261extern long pps_stbcnt; /* stability limit exceeded */
262
263#ifdef CONFIG_TIME_INTERPOLATION
264
265#define TIME_SOURCE_CPU 0
266#define TIME_SOURCE_MMIO64 1
267#define TIME_SOURCE_MMIO32 2
268#define TIME_SOURCE_FUNCTION 3
269
270/* For proper operations time_interpolator clocks must run slightly slower
271 * than the standard clock since the interpolator may only correct by having
272 * time jump forward during a tick. A slower clock is usually a side effect
273 * of the integer divide of the nanoseconds in a second by the frequency.
274 * The accuracy of the division can be increased by specifying a shift.
275 * However, this may cause the clock not to be slow enough.
276 * The interpolator will self-tune the clock by slowing down if no
277 * resets occur or speeding up if the time jumps per analysis cycle
278 * become too high.
279 *
280 * Setting jitter compensates for a fluctuating timesource by comparing
281 * to the last value read from the timesource to insure that an earlier value
282 * is not returned by a later call. The price to pay
283 * for the compensation is that the timer routines are not as scalable anymore.
284 */
285
286struct time_interpolator {
287 u16 source; /* time source flags */
288 u8 shift; /* increases accuracy of multiply by shifting. */
289 /* Note that bits may be lost if shift is set too high */
290 u8 jitter; /* if set compensate for fluctuations */
291 u32 nsec_per_cyc; /* set by register_time_interpolator() */
292 void *addr; /* address of counter or function */
293 u64 mask; /* mask the valid bits of the counter */
294 unsigned long offset; /* nsec offset at last update of interpolator */
295 u64 last_counter; /* counter value in units of the counter at last update */
296 u64 last_cycle; /* Last timer value if TIME_SOURCE_JITTER is set */
297 u64 frequency; /* frequency in counts/second */
298 long drift; /* drift in parts-per-million (or -1) */
299 unsigned long skips; /* skips forward */
300 unsigned long ns_skipped; /* nanoseconds skipped */
301 struct time_interpolator *next;
302};
303
304extern void register_time_interpolator(struct time_interpolator *);
305extern void unregister_time_interpolator(struct time_interpolator *);
306extern void time_interpolator_reset(void);
307extern unsigned long time_interpolator_get_offset(void);
308
309#else /* !CONFIG_TIME_INTERPOLATION */
310
311static inline void
312time_interpolator_reset(void)
313{
314}
315
316#endif /* !CONFIG_TIME_INTERPOLATION */
317
318#endif /* KERNEL */
319
320#endif /* LINUX_TIMEX_H */
diff --git a/include/linux/tiocl.h b/include/linux/tiocl.h
new file mode 100644
index 000000000000..2c9e847f6ed1
--- /dev/null
+++ b/include/linux/tiocl.h
@@ -0,0 +1,38 @@
1#ifndef _LINUX_TIOCL_H
2#define _LINUX_TIOCL_H
3
4#define TIOCL_SETSEL 2 /* set a selection */
5#define TIOCL_SELCHAR 0 /* select characters */
6#define TIOCL_SELWORD 1 /* select whole words */
7#define TIOCL_SELLINE 2 /* select whole lines */
8#define TIOCL_SELPOINTER 3 /* show the pointer */
9#define TIOCL_SELCLEAR 4 /* clear visibility of selection */
10#define TIOCL_SELMOUSEREPORT 16 /* report beginning of selection */
11#define TIOCL_SELBUTTONMASK 15 /* button mask for report */
12/* selection extent */
13struct tiocl_selection {
14 unsigned short xs; /* X start */
15 unsigned short ys; /* Y start */
16 unsigned short xe; /* X end */
17 unsigned short ye; /* Y end */
18 unsigned short sel_mode; /* selection mode */
19};
20
21#define TIOCL_PASTESEL 3 /* paste previous selection */
22#define TIOCL_UNBLANKSCREEN 4 /* unblank screen */
23
24#define TIOCL_SELLOADLUT 5
25 /* set characters to be considered alphabetic when selecting */
26 /* u32[8] bit array, 4 bytes-aligned with type */
27
28/* these two don't return a value: they write it back in the type */
29#define TIOCL_GETSHIFTSTATE 6 /* write shift state */
30#define TIOCL_GETMOUSEREPORTING 7 /* write whether mouse event are reported */
31#define TIOCL_SETVESABLANK 10 /* set vesa blanking mode */
32#define TIOCL_SETKMSGREDIRECT 11 /* restrict kernel messages to a vt */
33#define TIOCL_GETFGCONSOLE 12 /* get foreground vt */
34#define TIOCL_SCROLLCONSOLE 13 /* scroll console */
35#define TIOCL_BLANKSCREEN 14 /* keep screen blank even if a key is pressed */
36#define TIOCL_BLANKEDSCREEN 15 /* return which vt was blanked */
37
38#endif /* _LINUX_TIOCL_H */
diff --git a/include/linux/topology.h b/include/linux/topology.h
new file mode 100644
index 000000000000..d70e8972c67f
--- /dev/null
+++ b/include/linux/topology.h
@@ -0,0 +1,136 @@
1/*
2 * include/linux/topology.h
3 *
4 * Written by: Matthew Dobson, IBM Corporation
5 *
6 * Copyright (C) 2002, IBM Corp.
7 *
8 * All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
18 * NON INFRINGEMENT. See the GNU General Public License for more
19 * details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 *
25 * Send feedback to <colpatch@us.ibm.com>
26 */
27#ifndef _LINUX_TOPOLOGY_H
28#define _LINUX_TOPOLOGY_H
29
30#include <linux/cpumask.h>
31#include <linux/bitops.h>
32#include <linux/mmzone.h>
33#include <linux/smp.h>
34#include <asm/topology.h>
35
36#ifndef node_has_online_mem
37#define node_has_online_mem(nid) (1)
38#endif
39
40#ifndef nr_cpus_node
41#define nr_cpus_node(node) \
42 ({ \
43 cpumask_t __tmp__; \
44 __tmp__ = node_to_cpumask(node); \
45 cpus_weight(__tmp__); \
46 })
47#endif
48
49#define for_each_node_with_cpus(node) \
50 for_each_online_node(node) \
51 if (nr_cpus_node(node))
52
53#ifndef node_distance
54/* Conform to ACPI 2.0 SLIT distance definitions */
55#define LOCAL_DISTANCE 10
56#define REMOTE_DISTANCE 20
57#define node_distance(from,to) ((from) == (to) ? LOCAL_DISTANCE : REMOTE_DISTANCE)
58#endif
59#ifndef PENALTY_FOR_NODE_WITH_CPUS
60#define PENALTY_FOR_NODE_WITH_CPUS (1)
61#endif
62
63/*
64 * Below are the 3 major initializers used in building sched_domains:
65 * SD_SIBLING_INIT, for SMT domains
66 * SD_CPU_INIT, for SMP domains
67 * SD_NODE_INIT, for NUMA domains
68 *
69 * Any architecture that cares to do any tuning to these values should do so
70 * by defining their own arch-specific initializer in include/asm/topology.h.
71 * A definition there will automagically override these default initializers
72 * and allow arch-specific performance tuning of sched_domains.
73 */
74#ifdef CONFIG_SCHED_SMT
75/* MCD - Do we really need this? It is always on if CONFIG_SCHED_SMT is,
76 * so can't we drop this in favor of CONFIG_SCHED_SMT?
77 */
78#define ARCH_HAS_SCHED_WAKE_IDLE
79/* Common values for SMT siblings */
80#ifndef SD_SIBLING_INIT
81#define SD_SIBLING_INIT (struct sched_domain) { \
82 .span = CPU_MASK_NONE, \
83 .parent = NULL, \
84 .groups = NULL, \
85 .min_interval = 1, \
86 .max_interval = 2, \
87 .busy_factor = 8, \
88 .imbalance_pct = 110, \
89 .cache_hot_time = 0, \
90 .cache_nice_tries = 0, \
91 .per_cpu_gain = 25, \
92 .flags = SD_LOAD_BALANCE \
93 | SD_BALANCE_NEWIDLE \
94 | SD_BALANCE_EXEC \
95 | SD_WAKE_AFFINE \
96 | SD_WAKE_IDLE \
97 | SD_SHARE_CPUPOWER, \
98 .last_balance = jiffies, \
99 .balance_interval = 1, \
100 .nr_balance_failed = 0, \
101}
102#endif
103#endif /* CONFIG_SCHED_SMT */
104
105/* Common values for CPUs */
106#ifndef SD_CPU_INIT
107#define SD_CPU_INIT (struct sched_domain) { \
108 .span = CPU_MASK_NONE, \
109 .parent = NULL, \
110 .groups = NULL, \
111 .min_interval = 1, \
112 .max_interval = 4, \
113 .busy_factor = 64, \
114 .imbalance_pct = 125, \
115 .cache_hot_time = (5*1000000/2), \
116 .cache_nice_tries = 1, \
117 .per_cpu_gain = 100, \
118 .flags = SD_LOAD_BALANCE \
119 | SD_BALANCE_NEWIDLE \
120 | SD_BALANCE_EXEC \
121 | SD_WAKE_AFFINE \
122 | SD_WAKE_IDLE \
123 | SD_WAKE_BALANCE, \
124 .last_balance = jiffies, \
125 .balance_interval = 1, \
126 .nr_balance_failed = 0, \
127}
128#endif
129
130#ifdef CONFIG_NUMA
131#ifndef SD_NODE_INIT
132#error Please define an appropriate SD_NODE_INIT in include/asm/topology.h!!!
133#endif
134#endif /* CONFIG_NUMA */
135
136#endif /* _LINUX_TOPOLOGY_H */
diff --git a/include/linux/toshiba.h b/include/linux/toshiba.h
new file mode 100644
index 000000000000..916e5e3a699b
--- /dev/null
+++ b/include/linux/toshiba.h
@@ -0,0 +1,36 @@
1/* toshiba.h -- Linux driver for accessing the SMM on Toshiba laptops
2 *
3 * Copyright (c) 1996-2000 Jonathan A. Buzzard (jonathan@buzzard.org.uk)
4 *
5 * Thanks to Juergen Heinzl <juergen@monocerus.demon.co.uk> for the pointers
6 * on making sure the structure is aligned and packed.
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 */
19
20#ifndef _LINUX_TOSHIBA_H
21#define _LINUX_TOSHIBA_H
22
23#define TOSH_PROC "/proc/toshiba"
24#define TOSH_DEVICE "/dev/toshiba"
25#define TOSH_SMM _IOWR('t', 0x90, int) /* broken: meant 24 bytes */
26
27typedef struct {
28 unsigned int eax;
29 unsigned int ebx __attribute__ ((packed));
30 unsigned int ecx __attribute__ ((packed));
31 unsigned int edx __attribute__ ((packed));
32 unsigned int esi __attribute__ ((packed));
33 unsigned int edi __attribute__ ((packed));
34} SMMRegisters;
35
36#endif
diff --git a/include/linux/transport_class.h b/include/linux/transport_class.h
new file mode 100644
index 000000000000..87d98d1faefb
--- /dev/null
+++ b/include/linux/transport_class.h
@@ -0,0 +1,95 @@
1/*
2 * transport_class.h - a generic container for all transport classes
3 *
4 * Copyright (c) 2005 - James Bottomley <James.Bottomley@steeleye.com>
5 *
6 * This file is licensed under GPLv2
7 */
8
9#ifndef _TRANSPORT_CLASS_H_
10#define _TRANSPORT_CLASS_H_
11
12#include <linux/device.h>
13#include <linux/attribute_container.h>
14
15struct transport_class {
16 struct class class;
17 int (*setup)(struct device *);
18 int (*configure)(struct device *);
19 int (*remove)(struct device *);
20};
21
22#define DECLARE_TRANSPORT_CLASS(cls, nm, su, rm, cfg) \
23struct transport_class cls = { \
24 .class = { \
25 .name = nm, \
26 }, \
27 .setup = su, \
28 .remove = rm, \
29 .configure = cfg, \
30}
31
32
33struct anon_transport_class {
34 struct transport_class tclass;
35 struct attribute_container container;
36};
37
38#define DECLARE_ANON_TRANSPORT_CLASS(cls, mtch, cfg) \
39struct anon_transport_class cls = { \
40 .tclass = { \
41 .configure = cfg, \
42 }, \
43 . container = { \
44 .match = mtch, \
45 }, \
46}
47
48#define class_to_transport_class(x) \
49 container_of(x, struct transport_class, class)
50
51struct transport_container {
52 struct attribute_container ac;
53 struct attribute_group *statistics;
54};
55
56#define attribute_container_to_transport_container(x) \
57 container_of(x, struct transport_container, ac)
58
59void transport_remove_device(struct device *);
60void transport_add_device(struct device *);
61void transport_setup_device(struct device *);
62void transport_configure_device(struct device *);
63void transport_destroy_device(struct device *);
64
65static inline void
66transport_register_device(struct device *dev)
67{
68 transport_setup_device(dev);
69 transport_add_device(dev);
70}
71
72static inline void
73transport_unregister_device(struct device *dev)
74{
75 transport_remove_device(dev);
76 transport_destroy_device(dev);
77}
78
79static inline int transport_container_register(struct transport_container *tc)
80{
81 return attribute_container_register(&tc->ac);
82}
83
84static inline int transport_container_unregister(struct transport_container *tc)
85{
86 return attribute_container_unregister(&tc->ac);
87}
88
89int transport_class_register(struct transport_class *);
90int anon_transport_class_register(struct anon_transport_class *);
91void transport_class_unregister(struct transport_class *);
92void anon_transport_class_unregister(struct anon_transport_class *);
93
94
95#endif
diff --git a/include/linux/trdevice.h b/include/linux/trdevice.h
new file mode 100644
index 000000000000..aaa1f337edcb
--- /dev/null
+++ b/include/linux/trdevice.h
@@ -0,0 +1,37 @@
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. NET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Definitions for the Token-ring handlers.
7 *
8 * Version: @(#)eth.h 1.0.4 05/13/93
9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu>
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 *
13 * Relocated to include/linux where it belongs by Alan Cox
14 * <gw4pts@gw4pts.ampr.org>
15 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version
19 * 2 of the License, or (at your option) any later version.
20 *
21 * WARNING: This move may well be temporary. This file will get merged with others RSN.
22 *
23 */
24#ifndef _LINUX_TRDEVICE_H
25#define _LINUX_TRDEVICE_H
26
27
28#include <linux/if_tr.h>
29
30#ifdef __KERNEL__
31extern unsigned short tr_type_trans(struct sk_buff *skb, struct net_device *dev);
32extern void tr_source_route(struct sk_buff *skb, struct trh_hdr *trh, struct net_device *dev);
33extern struct net_device *alloc_trdev(int sizeof_priv);
34
35#endif
36
37#endif /* _LINUX_TRDEVICE_H */
diff --git a/include/linux/tty.h b/include/linux/tty.h
new file mode 100644
index 000000000000..1b76106272d3
--- /dev/null
+++ b/include/linux/tty.h
@@ -0,0 +1,412 @@
1#ifndef _LINUX_TTY_H
2#define _LINUX_TTY_H
3
4/*
5 * 'tty.h' defines some structures used by tty_io.c and some defines.
6 */
7
8/*
9 * These constants are also useful for user-level apps (e.g., VC
10 * resizing).
11 */
12#define MIN_NR_CONSOLES 1 /* must be at least 1 */
13#define MAX_NR_CONSOLES 63 /* serial lines start at 64 */
14#define MAX_NR_USER_CONSOLES 63 /* must be root to allocate above this */
15 /* Note: the ioctl VT_GETSTATE does not work for
16 consoles 16 and higher (since it returns a short) */
17
18#ifdef __KERNEL__
19#include <linux/config.h>
20#include <linux/fs.h>
21#include <linux/major.h>
22#include <linux/termios.h>
23#include <linux/workqueue.h>
24#include <linux/tty_driver.h>
25#include <linux/tty_ldisc.h>
26
27#include <asm/system.h>
28
29
30/*
31 * (Note: the *_driver.minor_start values 1, 64, 128, 192 are
32 * hardcoded at present.)
33 */
34#define NR_PTYS CONFIG_LEGACY_PTY_COUNT /* Number of legacy ptys */
35#define NR_UNIX98_PTY_DEFAULT 4096 /* Default maximum for Unix98 ptys */
36#define NR_UNIX98_PTY_MAX (1 << MINORBITS) /* Absolute limit */
37#define NR_LDISCS 16
38
39/*
40 * These are set up by the setup-routine at boot-time:
41 */
42
43struct screen_info {
44 u8 orig_x; /* 0x00 */
45 u8 orig_y; /* 0x01 */
46 u16 dontuse1; /* 0x02 -- EXT_MEM_K sits here */
47 u16 orig_video_page; /* 0x04 */
48 u8 orig_video_mode; /* 0x06 */
49 u8 orig_video_cols; /* 0x07 */
50 u16 unused2; /* 0x08 */
51 u16 orig_video_ega_bx; /* 0x0a */
52 u16 unused3; /* 0x0c */
53 u8 orig_video_lines; /* 0x0e */
54 u8 orig_video_isVGA; /* 0x0f */
55 u16 orig_video_points; /* 0x10 */
56
57 /* VESA graphic mode -- linear frame buffer */
58 u16 lfb_width; /* 0x12 */
59 u16 lfb_height; /* 0x14 */
60 u16 lfb_depth; /* 0x16 */
61 u32 lfb_base; /* 0x18 */
62 u32 lfb_size; /* 0x1c */
63 u16 dontuse2, dontuse3; /* 0x20 -- CL_MAGIC and CL_OFFSET here */
64 u16 lfb_linelength; /* 0x24 */
65 u8 red_size; /* 0x26 */
66 u8 red_pos; /* 0x27 */
67 u8 green_size; /* 0x28 */
68 u8 green_pos; /* 0x29 */
69 u8 blue_size; /* 0x2a */
70 u8 blue_pos; /* 0x2b */
71 u8 rsvd_size; /* 0x2c */
72 u8 rsvd_pos; /* 0x2d */
73 u16 vesapm_seg; /* 0x2e */
74 u16 vesapm_off; /* 0x30 */
75 u16 pages; /* 0x32 */
76 u16 vesa_attributes; /* 0x34 */
77 /* 0x36 -- 0x3f reserved for future expansion */
78};
79
80extern struct screen_info screen_info;
81
82#define ORIG_X (screen_info.orig_x)
83#define ORIG_Y (screen_info.orig_y)
84#define ORIG_VIDEO_MODE (screen_info.orig_video_mode)
85#define ORIG_VIDEO_COLS (screen_info.orig_video_cols)
86#define ORIG_VIDEO_EGA_BX (screen_info.orig_video_ega_bx)
87#define ORIG_VIDEO_LINES (screen_info.orig_video_lines)
88#define ORIG_VIDEO_ISVGA (screen_info.orig_video_isVGA)
89#define ORIG_VIDEO_POINTS (screen_info.orig_video_points)
90
91#define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
92#define VIDEO_TYPE_CGA 0x11 /* CGA Display */
93#define VIDEO_TYPE_EGAM 0x20 /* EGA/VGA in Monochrome Mode */
94#define VIDEO_TYPE_EGAC 0x21 /* EGA in Color Mode */
95#define VIDEO_TYPE_VGAC 0x22 /* VGA+ in Color Mode */
96#define VIDEO_TYPE_VLFB 0x23 /* VESA VGA in graphic mode */
97
98#define VIDEO_TYPE_PICA_S3 0x30 /* ACER PICA-61 local S3 video */
99#define VIDEO_TYPE_MIPS_G364 0x31 /* MIPS Magnum 4000 G364 video */
100#define VIDEO_TYPE_SGI 0x33 /* Various SGI graphics hardware */
101
102#define VIDEO_TYPE_TGAC 0x40 /* DEC TGA */
103
104#define VIDEO_TYPE_SUN 0x50 /* Sun frame buffer. */
105#define VIDEO_TYPE_SUNPCI 0x51 /* Sun PCI based frame buffer. */
106
107#define VIDEO_TYPE_PMAC 0x60 /* PowerMacintosh frame buffer. */
108
109/*
110 * This character is the same as _POSIX_VDISABLE: it cannot be used as
111 * a c_cc[] character, but indicates that a particular special character
112 * isn't in use (eg VINTR has no character etc)
113 */
114#define __DISABLED_CHAR '\0'
115
116/*
117 * This is the flip buffer used for the tty driver. The buffer is
118 * located in the tty structure, and is used as a high speed interface
119 * between the tty driver and the tty line discipline.
120 */
121#define TTY_FLIPBUF_SIZE 512
122
123struct tty_flip_buffer {
124 struct work_struct work;
125 struct semaphore pty_sem;
126 char *char_buf_ptr;
127 unsigned char *flag_buf_ptr;
128 int count;
129 int buf_num;
130 unsigned char char_buf[2*TTY_FLIPBUF_SIZE];
131 char flag_buf[2*TTY_FLIPBUF_SIZE];
132 unsigned char slop[4]; /* N.B. bug overwrites buffer by 1 */
133};
134/*
135 * The pty uses char_buf and flag_buf as a contiguous buffer
136 */
137#define PTY_BUF_SIZE 4*TTY_FLIPBUF_SIZE
138
139/*
140 * When a break, frame error, or parity error happens, these codes are
141 * stuffed into the flags buffer.
142 */
143#define TTY_NORMAL 0
144#define TTY_BREAK 1
145#define TTY_FRAME 2
146#define TTY_PARITY 3
147#define TTY_OVERRUN 4
148
149#define INTR_CHAR(tty) ((tty)->termios->c_cc[VINTR])
150#define QUIT_CHAR(tty) ((tty)->termios->c_cc[VQUIT])
151#define ERASE_CHAR(tty) ((tty)->termios->c_cc[VERASE])
152#define KILL_CHAR(tty) ((tty)->termios->c_cc[VKILL])
153#define EOF_CHAR(tty) ((tty)->termios->c_cc[VEOF])
154#define TIME_CHAR(tty) ((tty)->termios->c_cc[VTIME])
155#define MIN_CHAR(tty) ((tty)->termios->c_cc[VMIN])
156#define SWTC_CHAR(tty) ((tty)->termios->c_cc[VSWTC])
157#define START_CHAR(tty) ((tty)->termios->c_cc[VSTART])
158#define STOP_CHAR(tty) ((tty)->termios->c_cc[VSTOP])
159#define SUSP_CHAR(tty) ((tty)->termios->c_cc[VSUSP])
160#define EOL_CHAR(tty) ((tty)->termios->c_cc[VEOL])
161#define REPRINT_CHAR(tty) ((tty)->termios->c_cc[VREPRINT])
162#define DISCARD_CHAR(tty) ((tty)->termios->c_cc[VDISCARD])
163#define WERASE_CHAR(tty) ((tty)->termios->c_cc[VWERASE])
164#define LNEXT_CHAR(tty) ((tty)->termios->c_cc[VLNEXT])
165#define EOL2_CHAR(tty) ((tty)->termios->c_cc[VEOL2])
166
167#define _I_FLAG(tty,f) ((tty)->termios->c_iflag & (f))
168#define _O_FLAG(tty,f) ((tty)->termios->c_oflag & (f))
169#define _C_FLAG(tty,f) ((tty)->termios->c_cflag & (f))
170#define _L_FLAG(tty,f) ((tty)->termios->c_lflag & (f))
171
172#define I_IGNBRK(tty) _I_FLAG((tty),IGNBRK)
173#define I_BRKINT(tty) _I_FLAG((tty),BRKINT)
174#define I_IGNPAR(tty) _I_FLAG((tty),IGNPAR)
175#define I_PARMRK(tty) _I_FLAG((tty),PARMRK)
176#define I_INPCK(tty) _I_FLAG((tty),INPCK)
177#define I_ISTRIP(tty) _I_FLAG((tty),ISTRIP)
178#define I_INLCR(tty) _I_FLAG((tty),INLCR)
179#define I_IGNCR(tty) _I_FLAG((tty),IGNCR)
180#define I_ICRNL(tty) _I_FLAG((tty),ICRNL)
181#define I_IUCLC(tty) _I_FLAG((tty),IUCLC)
182#define I_IXON(tty) _I_FLAG((tty),IXON)
183#define I_IXANY(tty) _I_FLAG((tty),IXANY)
184#define I_IXOFF(tty) _I_FLAG((tty),IXOFF)
185#define I_IMAXBEL(tty) _I_FLAG((tty),IMAXBEL)
186#define I_IUTF8(tty) _I_FLAG((tty),IUTF8)
187
188#define O_OPOST(tty) _O_FLAG((tty),OPOST)
189#define O_OLCUC(tty) _O_FLAG((tty),OLCUC)
190#define O_ONLCR(tty) _O_FLAG((tty),ONLCR)
191#define O_OCRNL(tty) _O_FLAG((tty),OCRNL)
192#define O_ONOCR(tty) _O_FLAG((tty),ONOCR)
193#define O_ONLRET(tty) _O_FLAG((tty),ONLRET)
194#define O_OFILL(tty) _O_FLAG((tty),OFILL)
195#define O_OFDEL(tty) _O_FLAG((tty),OFDEL)
196#define O_NLDLY(tty) _O_FLAG((tty),NLDLY)
197#define O_CRDLY(tty) _O_FLAG((tty),CRDLY)
198#define O_TABDLY(tty) _O_FLAG((tty),TABDLY)
199#define O_BSDLY(tty) _O_FLAG((tty),BSDLY)
200#define O_VTDLY(tty) _O_FLAG((tty),VTDLY)
201#define O_FFDLY(tty) _O_FLAG((tty),FFDLY)
202
203#define C_BAUD(tty) _C_FLAG((tty),CBAUD)
204#define C_CSIZE(tty) _C_FLAG((tty),CSIZE)
205#define C_CSTOPB(tty) _C_FLAG((tty),CSTOPB)
206#define C_CREAD(tty) _C_FLAG((tty),CREAD)
207#define C_PARENB(tty) _C_FLAG((tty),PARENB)
208#define C_PARODD(tty) _C_FLAG((tty),PARODD)
209#define C_HUPCL(tty) _C_FLAG((tty),HUPCL)
210#define C_CLOCAL(tty) _C_FLAG((tty),CLOCAL)
211#define C_CIBAUD(tty) _C_FLAG((tty),CIBAUD)
212#define C_CRTSCTS(tty) _C_FLAG((tty),CRTSCTS)
213
214#define L_ISIG(tty) _L_FLAG((tty),ISIG)
215#define L_ICANON(tty) _L_FLAG((tty),ICANON)
216#define L_XCASE(tty) _L_FLAG((tty),XCASE)
217#define L_ECHO(tty) _L_FLAG((tty),ECHO)
218#define L_ECHOE(tty) _L_FLAG((tty),ECHOE)
219#define L_ECHOK(tty) _L_FLAG((tty),ECHOK)
220#define L_ECHONL(tty) _L_FLAG((tty),ECHONL)
221#define L_NOFLSH(tty) _L_FLAG((tty),NOFLSH)
222#define L_TOSTOP(tty) _L_FLAG((tty),TOSTOP)
223#define L_ECHOCTL(tty) _L_FLAG((tty),ECHOCTL)
224#define L_ECHOPRT(tty) _L_FLAG((tty),ECHOPRT)
225#define L_ECHOKE(tty) _L_FLAG((tty),ECHOKE)
226#define L_FLUSHO(tty) _L_FLAG((tty),FLUSHO)
227#define L_PENDIN(tty) _L_FLAG((tty),PENDIN)
228#define L_IEXTEN(tty) _L_FLAG((tty),IEXTEN)
229
230struct device;
231/*
232 * Where all of the state associated with a tty is kept while the tty
233 * is open. Since the termios state should be kept even if the tty
234 * has been closed --- for things like the baud rate, etc --- it is
235 * not stored here, but rather a pointer to the real state is stored
236 * here. Possible the winsize structure should have the same
237 * treatment, but (1) the default 80x24 is usually right and (2) it's
238 * most often used by a windowing system, which will set the correct
239 * size each time the window is created or resized anyway.
240 * - TYT, 9/14/92
241 */
242struct tty_struct {
243 int magic;
244 struct tty_driver *driver;
245 int index;
246 struct tty_ldisc ldisc;
247 struct semaphore termios_sem;
248 struct termios *termios, *termios_locked;
249 char name[64];
250 int pgrp;
251 int session;
252 unsigned long flags;
253 int count;
254 struct winsize winsize;
255 unsigned char stopped:1, hw_stopped:1, flow_stopped:1, packet:1;
256 unsigned char low_latency:1, warned:1;
257 unsigned char ctrl_status;
258
259 struct tty_struct *link;
260 struct fasync_struct *fasync;
261 struct tty_flip_buffer flip;
262 int max_flip_cnt;
263 int alt_speed; /* For magic substitution of 38400 bps */
264 wait_queue_head_t write_wait;
265 wait_queue_head_t read_wait;
266 struct work_struct hangup_work;
267 void *disc_data;
268 void *driver_data;
269 struct list_head tty_files;
270
271#define N_TTY_BUF_SIZE 4096
272
273 /*
274 * The following is data for the N_TTY line discipline. For
275 * historical reasons, this is included in the tty structure.
276 */
277 unsigned int column;
278 unsigned char lnext:1, erasing:1, raw:1, real_raw:1, icanon:1;
279 unsigned char closing:1;
280 unsigned short minimum_to_wake;
281 unsigned long overrun_time;
282 int num_overrun;
283 unsigned long process_char_map[256/(8*sizeof(unsigned long))];
284 char *read_buf;
285 int read_head;
286 int read_tail;
287 int read_cnt;
288 unsigned long read_flags[N_TTY_BUF_SIZE/(8*sizeof(unsigned long))];
289 int canon_data;
290 unsigned long canon_head;
291 unsigned int canon_column;
292 struct semaphore atomic_read;
293 struct semaphore atomic_write;
294 unsigned char *write_buf;
295 int write_cnt;
296 spinlock_t read_lock;
297 /* If the tty has a pending do_SAK, queue it here - akpm */
298 struct work_struct SAK_work;
299};
300
301/* tty magic number */
302#define TTY_MAGIC 0x5401
303
304/*
305 * These bits are used in the flags field of the tty structure.
306 *
307 * So that interrupts won't be able to mess up the queues,
308 * copy_to_cooked must be atomic with respect to itself, as must
309 * tty->write. Thus, you must use the inline functions set_bit() and
310 * clear_bit() to make things atomic.
311 */
312#define TTY_THROTTLED 0 /* Call unthrottle() at threshold min */
313#define TTY_IO_ERROR 1 /* Canse an I/O error (may be no ldisc too) */
314#define TTY_OTHER_CLOSED 2 /* Other side (if any) has closed */
315#define TTY_EXCLUSIVE 3 /* Exclusive open mode */
316#define TTY_DEBUG 4 /* Debugging */
317#define TTY_DO_WRITE_WAKEUP 5 /* Call write_wakeup after queuing new */
318#define TTY_PUSH 6 /* n_tty private */
319#define TTY_CLOSING 7 /* ->close() in progress */
320#define TTY_DONT_FLIP 8 /* Defer buffer flip */
321#define TTY_LDISC 9 /* Line discipline attached */
322#define TTY_HW_COOK_OUT 14 /* Hardware can do output cooking */
323#define TTY_HW_COOK_IN 15 /* Hardware can do input cooking */
324#define TTY_PTY_LOCK 16 /* pty private */
325#define TTY_NO_WRITE_SPLIT 17 /* Preserve write boundaries to driver */
326#define TTY_HUPPED 18 /* Post driver->hangup() */
327
328#define TTY_WRITE_FLUSH(tty) tty_write_flush((tty))
329
330extern void tty_write_flush(struct tty_struct *);
331
332extern struct termios tty_std_termios;
333extern int fg_console, last_console, want_console;
334
335extern int kmsg_redirect;
336
337extern void console_init(void);
338extern int vcs_init(void);
339
340extern int tty_paranoia_check(struct tty_struct *tty, struct inode *inode,
341 const char *routine);
342extern char *tty_name(struct tty_struct *tty, char *buf);
343extern void tty_wait_until_sent(struct tty_struct * tty, long timeout);
344extern int tty_check_change(struct tty_struct * tty);
345extern void stop_tty(struct tty_struct * tty);
346extern void start_tty(struct tty_struct * tty);
347extern int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc);
348extern int tty_register_driver(struct tty_driver *driver);
349extern int tty_unregister_driver(struct tty_driver *driver);
350extern void tty_register_device(struct tty_driver *driver, unsigned index, struct device *dev);
351extern void tty_unregister_device(struct tty_driver *driver, unsigned index);
352extern int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp,
353 int buflen);
354extern void tty_write_message(struct tty_struct *tty, char *msg);
355
356extern int is_orphaned_pgrp(int pgrp);
357extern int is_ignored(int sig);
358extern int tty_signal(int sig, struct tty_struct *tty);
359extern void tty_hangup(struct tty_struct * tty);
360extern void tty_vhangup(struct tty_struct * tty);
361extern void tty_unhangup(struct file *filp);
362extern int tty_hung_up_p(struct file * filp);
363extern void do_SAK(struct tty_struct *tty);
364extern void disassociate_ctty(int priv);
365extern void tty_flip_buffer_push(struct tty_struct *tty);
366extern int tty_get_baud_rate(struct tty_struct *tty);
367extern int tty_termios_baud_rate(struct termios *termios);
368
369extern struct tty_ldisc *tty_ldisc_ref(struct tty_struct *);
370extern void tty_ldisc_deref(struct tty_ldisc *);
371extern struct tty_ldisc *tty_ldisc_ref_wait(struct tty_struct *);
372
373extern struct tty_ldisc *tty_ldisc_get(int);
374extern void tty_ldisc_put(int);
375
376extern void tty_wakeup(struct tty_struct *tty);
377extern void tty_ldisc_flush(struct tty_struct *tty);
378
379struct semaphore;
380extern struct semaphore tty_sem;
381
382/* n_tty.c */
383extern struct tty_ldisc tty_ldisc_N_TTY;
384
385/* tty_ioctl.c */
386extern int n_tty_ioctl(struct tty_struct * tty, struct file * file,
387 unsigned int cmd, unsigned long arg);
388
389/* serial.c */
390
391extern void serial_console_init(void);
392
393/* pcxx.c */
394
395extern int pcxe_open(struct tty_struct *tty, struct file *filp);
396
397/* printk.c */
398
399extern void console_print(const char *);
400
401/* vt.c */
402
403extern int vt_ioctl(struct tty_struct *tty, struct file * file,
404 unsigned int cmd, unsigned long arg);
405
406static inline dev_t tty_devnum(struct tty_struct *tty)
407{
408 return MKDEV(tty->driver->major, tty->driver->minor_start) + tty->index;
409}
410
411#endif /* __KERNEL__ */
412#endif
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
new file mode 100644
index 000000000000..b368b296d035
--- /dev/null
+++ b/include/linux/tty_driver.h
@@ -0,0 +1,279 @@
1#ifndef _LINUX_TTY_DRIVER_H
2#define _LINUX_TTY_DRIVER_H
3
4/*
5 * This structure defines the interface between the low-level tty
6 * driver and the tty routines. The following routines can be
7 * defined; unless noted otherwise, they are optional, and can be
8 * filled in with a null pointer.
9 *
10 * int (*open)(struct tty_struct * tty, struct file * filp);
11 *
12 * This routine is called when a particular tty device is opened.
13 * This routine is mandatory; if this routine is not filled in,
14 * the attempted open will fail with ENODEV.
15 *
16 * void (*close)(struct tty_struct * tty, struct file * filp);
17 *
18 * This routine is called when a particular tty device is closed.
19 *
20 * int (*write)(struct tty_struct * tty,
21 * const unsigned char *buf, int count);
22 *
23 * This routine is called by the kernel to write a series of
24 * characters to the tty device. The characters may come from
25 * user space or kernel space. This routine will return the
26 * number of characters actually accepted for writing. This
27 * routine is mandatory.
28 *
29 * void (*put_char)(struct tty_struct *tty, unsigned char ch);
30 *
31 * This routine is called by the kernel to write a single
32 * character to the tty device. If the kernel uses this routine,
33 * it must call the flush_chars() routine (if defined) when it is
34 * done stuffing characters into the driver. If there is no room
35 * in the queue, the character is ignored.
36 *
37 * void (*flush_chars)(struct tty_struct *tty);
38 *
39 * This routine is called by the kernel after it has written a
40 * series of characters to the tty device using put_char().
41 *
42 * int (*write_room)(struct tty_struct *tty);
43 *
44 * This routine returns the numbers of characters the tty driver
45 * will accept for queuing to be written. This number is subject
46 * to change as output buffers get emptied, or if the output flow
47 * control is acted.
48 *
49 * int (*ioctl)(struct tty_struct *tty, struct file * file,
50 * unsigned int cmd, unsigned long arg);
51 *
52 * This routine allows the tty driver to implement
53 * device-specific ioctl's. If the ioctl number passed in cmd
54 * is not recognized by the driver, it should return ENOIOCTLCMD.
55 *
56 * void (*set_termios)(struct tty_struct *tty, struct termios * old);
57 *
58 * This routine allows the tty driver to be notified when
59 * device's termios settings have changed. Note that a
60 * well-designed tty driver should be prepared to accept the case
61 * where old == NULL, and try to do something rational.
62 *
63 * void (*set_ldisc)(struct tty_struct *tty);
64 *
65 * This routine allows the tty driver to be notified when the
66 * device's termios settings have changed.
67 *
68 * void (*throttle)(struct tty_struct * tty);
69 *
70 * This routine notifies the tty driver that input buffers for
71 * the line discipline are close to full, and it should somehow
72 * signal that no more characters should be sent to the tty.
73 *
74 * void (*unthrottle)(struct tty_struct * tty);
75 *
76 * This routine notifies the tty drivers that it should signals
77 * that characters can now be sent to the tty without fear of
78 * overrunning the input buffers of the line disciplines.
79 *
80 * void (*stop)(struct tty_struct *tty);
81 *
82 * This routine notifies the tty driver that it should stop
83 * outputting characters to the tty device.
84 *
85 * void (*start)(struct tty_struct *tty);
86 *
87 * This routine notifies the tty driver that it resume sending
88 * characters to the tty device.
89 *
90 * void (*hangup)(struct tty_struct *tty);
91 *
92 * This routine notifies the tty driver that it should hangup the
93 * tty device.
94 *
95 * void (*break_ctl)(struct tty_stuct *tty, int state);
96 *
97 * This optional routine requests the tty driver to turn on or
98 * off BREAK status on the RS-232 port. If state is -1,
99 * then the BREAK status should be turned on; if state is 0, then
100 * BREAK should be turned off.
101 *
102 * If this routine is implemented, the high-level tty driver will
103 * handle the following ioctls: TCSBRK, TCSBRKP, TIOCSBRK,
104 * TIOCCBRK. Otherwise, these ioctls will be passed down to the
105 * driver to handle.
106 *
107 * void (*wait_until_sent)(struct tty_struct *tty, int timeout);
108 *
109 * This routine waits until the device has written out all of the
110 * characters in its transmitter FIFO.
111 *
112 * void (*send_xchar)(struct tty_struct *tty, char ch);
113 *
114 * This routine is used to send a high-priority XON/XOFF
115 * character to the device.
116 */
117
118#include <linux/fs.h>
119#include <linux/list.h>
120#include <linux/cdev.h>
121
122struct tty_struct;
123
124struct tty_operations {
125 int (*open)(struct tty_struct * tty, struct file * filp);
126 void (*close)(struct tty_struct * tty, struct file * filp);
127 int (*write)(struct tty_struct * tty,
128 const unsigned char *buf, int count);
129 void (*put_char)(struct tty_struct *tty, unsigned char ch);
130 void (*flush_chars)(struct tty_struct *tty);
131 int (*write_room)(struct tty_struct *tty);
132 int (*chars_in_buffer)(struct tty_struct *tty);
133 int (*ioctl)(struct tty_struct *tty, struct file * file,
134 unsigned int cmd, unsigned long arg);
135 void (*set_termios)(struct tty_struct *tty, struct termios * old);
136 void (*throttle)(struct tty_struct * tty);
137 void (*unthrottle)(struct tty_struct * tty);
138 void (*stop)(struct tty_struct *tty);
139 void (*start)(struct tty_struct *tty);
140 void (*hangup)(struct tty_struct *tty);
141 void (*break_ctl)(struct tty_struct *tty, int state);
142 void (*flush_buffer)(struct tty_struct *tty);
143 void (*set_ldisc)(struct tty_struct *tty);
144 void (*wait_until_sent)(struct tty_struct *tty, int timeout);
145 void (*send_xchar)(struct tty_struct *tty, char ch);
146 int (*read_proc)(char *page, char **start, off_t off,
147 int count, int *eof, void *data);
148 int (*write_proc)(struct file *file, const char __user *buffer,
149 unsigned long count, void *data);
150 int (*tiocmget)(struct tty_struct *tty, struct file *file);
151 int (*tiocmset)(struct tty_struct *tty, struct file *file,
152 unsigned int set, unsigned int clear);
153};
154
155struct tty_driver {
156 int magic; /* magic number for this structure */
157 struct cdev cdev;
158 struct module *owner;
159 const char *driver_name;
160 const char *devfs_name;
161 const char *name;
162 int name_base; /* offset of printed name */
163 int major; /* major device number */
164 int minor_start; /* start of minor device number */
165 int minor_num; /* number of *possible* devices */
166 int num; /* number of devices allocated */
167 short type; /* type of tty driver */
168 short subtype; /* subtype of tty driver */
169 struct termios init_termios; /* Initial termios */
170 int flags; /* tty driver flags */
171 int refcount; /* for loadable tty drivers */
172 struct proc_dir_entry *proc_entry; /* /proc fs entry */
173 struct tty_driver *other; /* only used for the PTY driver */
174
175 /*
176 * Pointer to the tty data structures
177 */
178 struct tty_struct **ttys;
179 struct termios **termios;
180 struct termios **termios_locked;
181 void *driver_state; /* only used for the PTY driver */
182
183 /*
184 * Interface routines from the upper tty layer to the tty
185 * driver. Will be replaced with struct tty_operations.
186 */
187 int (*open)(struct tty_struct * tty, struct file * filp);
188 void (*close)(struct tty_struct * tty, struct file * filp);
189 int (*write)(struct tty_struct * tty,
190 const unsigned char *buf, int count);
191 void (*put_char)(struct tty_struct *tty, unsigned char ch);
192 void (*flush_chars)(struct tty_struct *tty);
193 int (*write_room)(struct tty_struct *tty);
194 int (*chars_in_buffer)(struct tty_struct *tty);
195 int (*ioctl)(struct tty_struct *tty, struct file * file,
196 unsigned int cmd, unsigned long arg);
197 void (*set_termios)(struct tty_struct *tty, struct termios * old);
198 void (*throttle)(struct tty_struct * tty);
199 void (*unthrottle)(struct tty_struct * tty);
200 void (*stop)(struct tty_struct *tty);
201 void (*start)(struct tty_struct *tty);
202 void (*hangup)(struct tty_struct *tty);
203 void (*break_ctl)(struct tty_struct *tty, int state);
204 void (*flush_buffer)(struct tty_struct *tty);
205 void (*set_ldisc)(struct tty_struct *tty);
206 void (*wait_until_sent)(struct tty_struct *tty, int timeout);
207 void (*send_xchar)(struct tty_struct *tty, char ch);
208 int (*read_proc)(char *page, char **start, off_t off,
209 int count, int *eof, void *data);
210 int (*write_proc)(struct file *file, const char __user *buffer,
211 unsigned long count, void *data);
212 int (*tiocmget)(struct tty_struct *tty, struct file *file);
213 int (*tiocmset)(struct tty_struct *tty, struct file *file,
214 unsigned int set, unsigned int clear);
215
216 struct list_head tty_drivers;
217};
218
219extern struct list_head tty_drivers;
220
221struct tty_driver *alloc_tty_driver(int lines);
222void put_tty_driver(struct tty_driver *driver);
223void tty_set_operations(struct tty_driver *driver, struct tty_operations *op);
224
225/* tty driver magic number */
226#define TTY_DRIVER_MAGIC 0x5402
227
228/*
229 * tty driver flags
230 *
231 * TTY_DRIVER_RESET_TERMIOS --- requests the tty layer to reset the
232 * termios setting when the last process has closed the device.
233 * Used for PTY's, in particular.
234 *
235 * TTY_DRIVER_REAL_RAW --- if set, indicates that the driver will
236 * guarantee never not to set any special character handling
237 * flags if ((IGNBRK || (!BRKINT && !PARMRK)) && (IGNPAR ||
238 * !INPCK)). That is, if there is no reason for the driver to
239 * send notifications of parity and break characters up to the
240 * line driver, it won't do so. This allows the line driver to
241 * optimize for this case if this flag is set. (Note that there
242 * is also a promise, if the above case is true, not to signal
243 * overruns, either.)
244 *
245 * TTY_DRIVER_NO_DEVFS --- if set, do not create devfs entries. This
246 * is only used by tty_register_driver().
247 *
248 * TTY_DRIVER_DEVPTS_MEM -- don't use the standard arrays, instead
249 * use dynamic memory keyed through the devpts filesystem. This
250 * is only applicable to the pty driver.
251 */
252#define TTY_DRIVER_INSTALLED 0x0001
253#define TTY_DRIVER_RESET_TERMIOS 0x0002
254#define TTY_DRIVER_REAL_RAW 0x0004
255#define TTY_DRIVER_NO_DEVFS 0x0008
256#define TTY_DRIVER_DEVPTS_MEM 0x0010
257
258/* tty driver types */
259#define TTY_DRIVER_TYPE_SYSTEM 0x0001
260#define TTY_DRIVER_TYPE_CONSOLE 0x0002
261#define TTY_DRIVER_TYPE_SERIAL 0x0003
262#define TTY_DRIVER_TYPE_PTY 0x0004
263#define TTY_DRIVER_TYPE_SCC 0x0005 /* scc driver */
264#define TTY_DRIVER_TYPE_SYSCONS 0x0006
265
266/* system subtypes (magic, used by tty_io.c) */
267#define SYSTEM_TYPE_TTY 0x0001
268#define SYSTEM_TYPE_CONSOLE 0x0002
269#define SYSTEM_TYPE_SYSCONS 0x0003
270#define SYSTEM_TYPE_SYSPTMX 0x0004
271
272/* pty subtypes (magic, used by tty_io.c) */
273#define PTY_TYPE_MASTER 0x0001
274#define PTY_TYPE_SLAVE 0x0002
275
276/* serial subtype definitions */
277#define SERIAL_TYPE_NORMAL 1
278
279#endif /* #ifdef _LINUX_TTY_DRIVER_H */
diff --git a/include/linux/tty_flip.h b/include/linux/tty_flip.h
new file mode 100644
index 000000000000..abe9bfcf226c
--- /dev/null
+++ b/include/linux/tty_flip.h
@@ -0,0 +1,35 @@
1#ifndef _LINUX_TTY_FLIP_H
2#define _LINUX_TTY_FLIP_H
3
4#ifdef INCLUDE_INLINE_FUNCS
5#define _INLINE_ extern
6#else
7#define _INLINE_ static __inline__
8#endif
9
10_INLINE_ void tty_insert_flip_char(struct tty_struct *tty,
11 unsigned char ch, char flag)
12{
13 if (tty->flip.count < TTY_FLIPBUF_SIZE) {
14 tty->flip.count++;
15 *tty->flip.flag_buf_ptr++ = flag;
16 *tty->flip.char_buf_ptr++ = ch;
17 }
18}
19
20_INLINE_ void tty_schedule_flip(struct tty_struct *tty)
21{
22 schedule_delayed_work(&tty->flip.work, 1);
23}
24
25#undef _INLINE_
26
27
28#endif /* _LINUX_TTY_FLIP_H */
29
30
31
32
33
34
35
diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
new file mode 100644
index 000000000000..6066afde5ce4
--- /dev/null
+++ b/include/linux/tty_ldisc.h
@@ -0,0 +1,154 @@
1#ifndef _LINUX_TTY_LDISC_H
2#define _LINUX_TTY_LDISC_H
3
4/*
5 * This structure defines the interface between the tty line discipline
6 * implementation and the tty routines. The following routines can be
7 * defined; unless noted otherwise, they are optional, and can be
8 * filled in with a null pointer.
9 *
10 * int (*open)(struct tty_struct *);
11 *
12 * This function is called when the line discipline is associated
13 * with the tty. The line discipline can use this as an
14 * opportunity to initialize any state needed by the ldisc routines.
15 *
16 * void (*close)(struct tty_struct *);
17 *
18 * This function is called when the line discipline is being
19 * shutdown, either because the tty is being closed or because
20 * the tty is being changed to use a new line discipline
21 *
22 * void (*flush_buffer)(struct tty_struct *tty);
23 *
24 * This function instructs the line discipline to clear its
25 * buffers of any input characters it may have queued to be
26 * delivered to the user mode process.
27 *
28 * ssize_t (*chars_in_buffer)(struct tty_struct *tty);
29 *
30 * This function returns the number of input characters the line
31 * discipline may have queued up to be delivered to the user mode
32 * process.
33 *
34 * ssize_t (*read)(struct tty_struct * tty, struct file * file,
35 * unsigned char * buf, size_t nr);
36 *
37 * This function is called when the user requests to read from
38 * the tty. The line discipline will return whatever characters
39 * it has buffered up for the user. If this function is not
40 * defined, the user will receive an EIO error.
41 *
42 * ssize_t (*write)(struct tty_struct * tty, struct file * file,
43 * const unsigned char * buf, size_t nr);
44 *
45 * This function is called when the user requests to write to the
46 * tty. The line discipline will deliver the characters to the
47 * low-level tty device for transmission, optionally performing
48 * some processing on the characters first. If this function is
49 * not defined, the user will receive an EIO error.
50 *
51 * int (*ioctl)(struct tty_struct * tty, struct file * file,
52 * unsigned int cmd, unsigned long arg);
53 *
54 * This function is called when the user requests an ioctl which
55 * is not handled by the tty layer or the low-level tty driver.
56 * It is intended for ioctls which affect line discpline
57 * operation. Note that the search order for ioctls is (1) tty
58 * layer, (2) tty low-level driver, (3) line discpline. So a
59 * low-level driver can "grab" an ioctl request before the line
60 * discpline has a chance to see it.
61 *
62 * void (*set_termios)(struct tty_struct *tty, struct termios * old);
63 *
64 * This function notifies the line discpline that a change has
65 * been made to the termios structure.
66 *
67 * int (*poll)(struct tty_struct * tty, struct file * file,
68 * poll_table *wait);
69 *
70 * This function is called when a user attempts to select/poll on a
71 * tty device. It is solely the responsibility of the line
72 * discipline to handle poll requests.
73 *
74 * void (*receive_buf)(struct tty_struct *, const unsigned char *cp,
75 * char *fp, int count);
76 *
77 * This function is called by the low-level tty driver to send
78 * characters received by the hardware to the line discpline for
79 * processing. <cp> is a pointer to the buffer of input
80 * character received by the device. <fp> is a pointer to a
81 * pointer of flag bytes which indicate whether a character was
82 * received with a parity error, etc.
83 *
84 * int (*receive_room)(struct tty_struct *);
85 *
86 * This function is called by the low-level tty driver to
87 * determine how many characters the line discpline can accept.
88 * The low-level driver must not send more characters than was
89 * indicated by receive_room, or the line discpline may drop
90 * those characters.
91 *
92 * void (*write_wakeup)(struct tty_struct *);
93 *
94 * This function is called by the low-level tty driver to signal
95 * that line discpline should try to send more characters to the
96 * low-level driver for transmission. If the line discpline does
97 * not have any more data to send, it can just return.
98 *
99 * int (*hangup)(struct tty_struct *)
100 *
101 * Called on a hangup. Tells the discipline that it should
102 * cease I/O to the tty driver. Can sleep. The driver should
103 * seek to perform this action quickly but should wait until
104 * any pending driver I/O is completed.
105 */
106
107#include <linux/fs.h>
108#include <linux/wait.h>
109
110struct tty_ldisc {
111 int magic;
112 char *name;
113 int num;
114 int flags;
115
116 /*
117 * The following routines are called from above.
118 */
119 int (*open)(struct tty_struct *);
120 void (*close)(struct tty_struct *);
121 void (*flush_buffer)(struct tty_struct *tty);
122 ssize_t (*chars_in_buffer)(struct tty_struct *tty);
123 ssize_t (*read)(struct tty_struct * tty, struct file * file,
124 unsigned char __user * buf, size_t nr);
125 ssize_t (*write)(struct tty_struct * tty, struct file * file,
126 const unsigned char * buf, size_t nr);
127 int (*ioctl)(struct tty_struct * tty, struct file * file,
128 unsigned int cmd, unsigned long arg);
129 void (*set_termios)(struct tty_struct *tty, struct termios * old);
130 unsigned int (*poll)(struct tty_struct *, struct file *,
131 struct poll_table_struct *);
132 int (*hangup)(struct tty_struct *tty);
133
134 /*
135 * The following routines are called from below.
136 */
137 void (*receive_buf)(struct tty_struct *, const unsigned char *cp,
138 char *fp, int count);
139 int (*receive_room)(struct tty_struct *);
140 void (*write_wakeup)(struct tty_struct *);
141
142 struct module *owner;
143
144 int refcount;
145};
146
147#define TTY_LDISC_MAGIC 0x5403
148
149#define LDISC_FLAG_DEFINED 0x00000001
150
151#define MODULE_ALIAS_LDISC(ldisc) \
152 MODULE_ALIAS("tty-ldisc-" __stringify(ldisc))
153
154#endif /* _LINUX_TTY_LDISC_H */
diff --git a/include/linux/types.h b/include/linux/types.h
new file mode 100644
index 000000000000..dcb13f865df9
--- /dev/null
+++ b/include/linux/types.h
@@ -0,0 +1,172 @@
1#ifndef _LINUX_TYPES_H
2#define _LINUX_TYPES_H
3
4#ifdef __KERNEL__
5#include <linux/config.h>
6
7#define BITS_TO_LONGS(bits) \
8 (((bits)+BITS_PER_LONG-1)/BITS_PER_LONG)
9#define DECLARE_BITMAP(name,bits) \
10 unsigned long name[BITS_TO_LONGS(bits)]
11#endif
12
13#include <linux/posix_types.h>
14#include <asm/types.h>
15
16#ifndef __KERNEL_STRICT_NAMES
17
18typedef __u32 __kernel_dev_t;
19
20typedef __kernel_fd_set fd_set;
21typedef __kernel_dev_t dev_t;
22typedef __kernel_ino_t ino_t;
23typedef __kernel_mode_t mode_t;
24typedef __kernel_nlink_t nlink_t;
25typedef __kernel_off_t off_t;
26typedef __kernel_pid_t pid_t;
27typedef __kernel_daddr_t daddr_t;
28typedef __kernel_key_t key_t;
29typedef __kernel_suseconds_t suseconds_t;
30typedef __kernel_timer_t timer_t;
31typedef __kernel_clockid_t clockid_t;
32typedef __kernel_mqd_t mqd_t;
33
34#ifdef __KERNEL__
35typedef __kernel_uid32_t uid_t;
36typedef __kernel_gid32_t gid_t;
37typedef __kernel_uid16_t uid16_t;
38typedef __kernel_gid16_t gid16_t;
39
40#ifdef CONFIG_UID16
41/* This is defined by include/asm-{arch}/posix_types.h */
42typedef __kernel_old_uid_t old_uid_t;
43typedef __kernel_old_gid_t old_gid_t;
44#endif /* CONFIG_UID16 */
45
46/* libc5 includes this file to define uid_t, thus uid_t can never change
47 * when it is included by non-kernel code
48 */
49#else
50typedef __kernel_uid_t uid_t;
51typedef __kernel_gid_t gid_t;
52#endif /* __KERNEL__ */
53
54#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
55typedef __kernel_loff_t loff_t;
56#endif
57
58/*
59 * The following typedefs are also protected by individual ifdefs for
60 * historical reasons:
61 */
62#ifndef _SIZE_T
63#define _SIZE_T
64typedef __kernel_size_t size_t;
65#endif
66
67#ifndef _SSIZE_T
68#define _SSIZE_T
69typedef __kernel_ssize_t ssize_t;
70#endif
71
72#ifndef _PTRDIFF_T
73#define _PTRDIFF_T
74typedef __kernel_ptrdiff_t ptrdiff_t;
75#endif
76
77#ifndef _TIME_T
78#define _TIME_T
79typedef __kernel_time_t time_t;
80#endif
81
82#ifndef _CLOCK_T
83#define _CLOCK_T
84typedef __kernel_clock_t clock_t;
85#endif
86
87#ifndef _CADDR_T
88#define _CADDR_T
89typedef __kernel_caddr_t caddr_t;
90#endif
91
92/* bsd */
93typedef unsigned char u_char;
94typedef unsigned short u_short;
95typedef unsigned int u_int;
96typedef unsigned long u_long;
97
98/* sysv */
99typedef unsigned char unchar;
100typedef unsigned short ushort;
101typedef unsigned int uint;
102typedef unsigned long ulong;
103
104#ifndef __BIT_TYPES_DEFINED__
105#define __BIT_TYPES_DEFINED__
106
107typedef __u8 u_int8_t;
108typedef __s8 int8_t;
109typedef __u16 u_int16_t;
110typedef __s16 int16_t;
111typedef __u32 u_int32_t;
112typedef __s32 int32_t;
113
114#endif /* !(__BIT_TYPES_DEFINED__) */
115
116typedef __u8 uint8_t;
117typedef __u16 uint16_t;
118typedef __u32 uint32_t;
119
120#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
121typedef __u64 uint64_t;
122typedef __u64 u_int64_t;
123typedef __s64 int64_t;
124#endif
125
126/*
127 * The type used for indexing onto a disc or disc partition.
128 * If required, asm/types.h can override it and define
129 * HAVE_SECTOR_T
130 */
131#ifndef HAVE_SECTOR_T
132typedef unsigned long sector_t;
133#endif
134
135/*
136 * The type of an index into the pagecache. Use a #define so asm/types.h
137 * can override it.
138 */
139#ifndef pgoff_t
140#define pgoff_t unsigned long
141#endif
142
143#endif /* __KERNEL_STRICT_NAMES */
144
145/*
146 * Below are truly Linux-specific types that should never collide with
147 * any application/library that wants linux/types.h.
148 */
149
150#ifdef __CHECKER__
151#define __bitwise __attribute__((bitwise))
152#else
153#define __bitwise
154#endif
155
156typedef __u16 __bitwise __le16;
157typedef __u16 __bitwise __be16;
158typedef __u32 __bitwise __le32;
159typedef __u32 __bitwise __be32;
160#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
161typedef __u64 __bitwise __le64;
162typedef __u64 __bitwise __be64;
163#endif
164
165struct ustat {
166 __kernel_daddr_t f_tfree;
167 __kernel_ino_t f_tinode;
168 char f_fname[6];
169 char f_fpack[6];
170};
171
172#endif /* _LINUX_TYPES_H */
diff --git a/include/linux/udf_fs.h b/include/linux/udf_fs.h
new file mode 100644
index 000000000000..46e2bb945353
--- /dev/null
+++ b/include/linux/udf_fs.h
@@ -0,0 +1,59 @@
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 * CONTACTS
17 * E-mail regarding any portion of the Linux UDF file system should be
18 * directed to the development team mailing list (run by majordomo):
19 * linux_udf@hpesjro.fc.hp.com
20 *
21 * COPYRIGHT
22 * This file is distributed under the terms of the GNU General Public
23 * License (GPL). Copies of the GPL can be obtained from:
24 * ftp://prep.ai.mit.edu/pub/gnu/GPL
25 * Each contributing author retains all rights to their own work.
26 *
27 * (C) 1999-2004 Ben Fennema
28 * (C) 1999-2000 Stelias Computing Inc
29 *
30 * HISTORY
31 *
32 */
33
34#ifndef _UDF_FS_H
35#define _UDF_FS_H 1
36
37#define UDF_PREALLOCATE
38#define UDF_DEFAULT_PREALLOC_BLOCKS 8
39
40#define UDFFS_DATE "2004/29/09"
41#define UDFFS_VERSION "0.9.8.1"
42
43#undef UDFFS_DEBUG
44
45#ifdef UDFFS_DEBUG
46#define udf_debug(f, a...) \
47 { \
48 printk (KERN_DEBUG "UDF-fs DEBUG %s:%d:%s: ", \
49 __FILE__, __LINE__, __FUNCTION__); \
50 printk (f, ##a); \
51 }
52#else
53#define udf_debug(f, a...) /**/
54#endif
55
56#define udf_info(f, a...) \
57 printk (KERN_INFO "UDF-fs INFO " f, ##a);
58
59#endif /* _UDF_FS_H */
diff --git a/include/linux/udf_fs_i.h b/include/linux/udf_fs_i.h
new file mode 100644
index 000000000000..62b15a4214e6
--- /dev/null
+++ b/include/linux/udf_fs_i.h
@@ -0,0 +1,78 @@
1/*
2 * udf_fs_i.h
3 *
4 * This file is intended for the Linux kernel/module.
5 *
6 * CONTACTS
7 * E-mail regarding any portion of the Linux UDF file system should be
8 * directed to the development team mailing list (run by majordomo):
9 * linux_udf@hpesjro.fc.hp.com
10 *
11 * COPYRIGHT
12 * This file is distributed under the terms of the GNU General Public
13 * License (GPL). Copies of the GPL can be obtained from:
14 * ftp://prep.ai.mit.edu/pub/gnu/GPL
15 * Each contributing author retains all rights to their own work.
16 */
17
18#ifndef _UDF_FS_I_H
19#define _UDF_FS_I_H 1
20
21#ifdef __KERNEL__
22
23#ifndef _ECMA_167_H
24typedef struct
25{
26 __u32 logicalBlockNum;
27 __u16 partitionReferenceNum;
28} __attribute__ ((packed)) lb_addr;
29
30typedef struct
31{
32 __u32 extLength;
33 __u32 extPosition;
34} __attribute__ ((packed)) short_ad;
35
36typedef struct
37{
38 __u32 extLength;
39 lb_addr extLocation;
40 __u8 impUse[6];
41} __attribute__ ((packed)) long_ad;
42#endif
43
44struct udf_inode_info
45{
46 struct timespec i_crtime;
47 /* Physical address of inode */
48 kernel_lb_addr i_location;
49 __u64 i_unique;
50 __u32 i_lenEAttr;
51 __u32 i_lenAlloc;
52 __u64 i_lenExtents;
53 __u32 i_next_alloc_block;
54 __u32 i_next_alloc_goal;
55 unsigned i_alloc_type : 3;
56 unsigned i_efe : 1;
57 unsigned i_use : 1;
58 unsigned i_strat4096 : 1;
59 unsigned reserved : 26;
60 union
61 {
62 short_ad *i_sad;
63 long_ad *i_lad;
64 __u8 *i_data;
65 } i_ext;
66 struct inode vfs_inode;
67};
68
69#endif
70
71/* exported IOCTLs, we have 'l', 0x40-0x7f */
72
73#define UDF_GETEASIZE _IOR('l', 0x40, int)
74#define UDF_GETEABLOCK _IOR('l', 0x41, void *)
75#define UDF_GETVOLIDENT _IOR('l', 0x42, void *)
76#define UDF_RELOCATE_BLOCKS _IOWR('l', 0x43, long)
77
78#endif /* _UDF_FS_I_H */
diff --git a/include/linux/udf_fs_sb.h b/include/linux/udf_fs_sb.h
new file mode 100644
index 000000000000..1966a6dbb4b6
--- /dev/null
+++ b/include/linux/udf_fs_sb.h
@@ -0,0 +1,122 @@
1/*
2 * udf_fs_sb.h
3 *
4 * This include file is for the Linux kernel/module.
5 *
6 * CONTACTS
7 * E-mail regarding any portion of the Linux UDF file system should be
8 * directed to the development team mailing list (run by majordomo):
9 * linux_udf@hpesjro.fc.hp.com
10 *
11 * COPYRIGHT
12 * This file is distributed under the terms of the GNU General Public
13 * License (GPL). Copies of the GPL can be obtained from:
14 * ftp://prep.ai.mit.edu/pub/gnu/GPL
15 * Each contributing author retains all rights to their own work.
16 */
17
18#ifndef _UDF_FS_SB_H
19#define _UDF_FS_SB_H 1
20
21#include <asm/semaphore.h>
22
23#pragma pack(1)
24
25#define UDF_MAX_BLOCK_LOADED 8
26
27#define UDF_TYPE1_MAP15 0x1511U
28#define UDF_VIRTUAL_MAP15 0x1512U
29#define UDF_VIRTUAL_MAP20 0x2012U
30#define UDF_SPARABLE_MAP15 0x1522U
31
32struct udf_sparing_data
33{
34 __u16 s_packet_len;
35 struct buffer_head *s_spar_map[4];
36};
37
38struct udf_virtual_data
39{
40 __u32 s_num_entries;
41 __u16 s_start_offset;
42};
43
44struct udf_bitmap
45{
46 __u32 s_extLength;
47 __u32 s_extPosition;
48 __u16 s_nr_groups;
49 struct buffer_head **s_block_bitmap;
50};
51
52struct udf_part_map
53{
54 union
55 {
56 struct udf_bitmap *s_bitmap;
57 struct inode *s_table;
58 } s_uspace;
59 union
60 {
61 struct udf_bitmap *s_bitmap;
62 struct inode *s_table;
63 } s_fspace;
64 __u32 s_partition_root;
65 __u32 s_partition_len;
66 __u16 s_partition_type;
67 __u16 s_partition_num;
68 union
69 {
70 struct udf_sparing_data s_sparing;
71 struct udf_virtual_data s_virtual;
72 } s_type_specific;
73 __u32 (*s_partition_func)(struct super_block *, __u32, __u16, __u32);
74 __u16 s_volumeseqnum;
75 __u16 s_partition_flags;
76};
77
78#pragma pack()
79
80struct udf_sb_info
81{
82 struct udf_part_map *s_partmaps;
83 __u8 s_volident[32];
84
85 /* Overall info */
86 __u16 s_partitions;
87 __u16 s_partition;
88
89 /* Sector headers */
90 __s32 s_session;
91 __u32 s_anchor[4];
92 __u32 s_lastblock;
93
94 struct buffer_head *s_lvidbh;
95
96 /* Default permissions */
97 mode_t s_umask;
98 gid_t s_gid;
99 uid_t s_uid;
100
101 /* Root Info */
102 struct timespec s_recordtime;
103
104 /* Fileset Info */
105 __u16 s_serialnum;
106
107 /* highest UDF revision we have recorded to this media */
108 __u16 s_udfrev;
109
110 /* Miscellaneous flags */
111 __u32 s_flags;
112
113 /* Encoding info */
114 struct nls_table *s_nls_map;
115
116 /* VAT inode */
117 struct inode *s_vat;
118
119 struct semaphore s_alloc_sem;
120};
121
122#endif /* _UDF_FS_SB_H */
diff --git a/include/linux/udp.h b/include/linux/udp.h
new file mode 100644
index 000000000000..b60e0b4a25c4
--- /dev/null
+++ b/include/linux/udp.h
@@ -0,0 +1,63 @@
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Definitions for the UDP protocol.
7 *
8 * Version: @(#)udp.h 1.0.2 04/28/93
9 *
10 * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version
15 * 2 of the License, or (at your option) any later version.
16 */
17#ifndef _LINUX_UDP_H
18#define _LINUX_UDP_H
19
20#include <linux/types.h>
21
22struct udphdr {
23 __u16 source;
24 __u16 dest;
25 __u16 len;
26 __u16 check;
27};
28
29/* UDP socket options */
30#define UDP_CORK 1 /* Never send partially complete segments */
31#define UDP_ENCAP 100 /* Set the socket to accept encapsulated packets */
32
33/* UDP encapsulation types */
34#define UDP_ENCAP_ESPINUDP_NON_IKE 1 /* draft-ietf-ipsec-nat-t-ike-00/01 */
35#define UDP_ENCAP_ESPINUDP 2 /* draft-ietf-ipsec-udp-encaps-06 */
36
37#ifdef __KERNEL__
38
39#include <linux/config.h>
40#include <net/sock.h>
41#include <linux/ip.h>
42
43struct udp_sock {
44 /* inet_sock has to be the first member */
45 struct inet_sock inet;
46 int pending; /* Any pending frames ? */
47 unsigned int corkflag; /* Cork is required */
48 __u16 encap_type; /* Is this an Encapsulation socket? */
49 /*
50 * Following member retains the infomation to create a UDP header
51 * when the socket is uncorked.
52 */
53 __u16 len; /* total length of pending frames */
54};
55
56static inline struct udp_sock *udp_sk(const struct sock *sk)
57{
58 return (struct udp_sock *)sk;
59}
60
61#endif
62
63#endif /* _LINUX_UDP_H */
diff --git a/include/linux/ufs_fs.h b/include/linux/ufs_fs.h
new file mode 100644
index 000000000000..7a6babeca256
--- /dev/null
+++ b/include/linux/ufs_fs.h
@@ -0,0 +1,943 @@
1/*
2 * linux/include/linux/ufs_fs.h
3 *
4 * Copyright (C) 1996
5 * Adrian Rodriguez (adrian@franklins-tower.rutgers.edu)
6 * Laboratory for Computer Science Research Computing Facility
7 * Rutgers, The State University of New Jersey
8 *
9 * Clean swab support by Fare <fare@tunes.org>
10 * just hope no one is using NNUUXXI on __?64 structure elements
11 * 64-bit clean thanks to Maciej W. Rozycki <macro@ds2.pg.gda.pl>
12 *
13 * 4.4BSD (FreeBSD) support added on February 1st 1998 by
14 * Niels Kristian Bech Jensen <nkbj@image.dk> partially based
15 * on code by Martin von Loewis <martin@mira.isdn.cs.tu-berlin.de>.
16 *
17 * NeXTstep support added on February 5th 1998 by
18 * Niels Kristian Bech Jensen <nkbj@image.dk>.
19 *
20 * Write support by Daniel Pirkl <daniel.pirkl@email.cz>
21 *
22 * HP/UX hfs filesystem support added by
23 * Martin K. Petersen <mkp@mkp.net>, August 1999
24 *
25 * UFS2 (of FreeBSD 5.x) support added by
26 * Niraj Kumar <niraj17@iitbombay.org> , Jan 2004
27 *
28 */
29
30#ifndef __LINUX_UFS_FS_H
31#define __LINUX_UFS_FS_H
32
33#include <linux/types.h>
34#include <linux/kernel.h>
35#include <linux/time.h>
36#include <linux/stat.h>
37#include <linux/fs.h>
38
39#ifndef __KERNEL__
40typedef __u64 __fs64;
41typedef __u32 __fs32;
42typedef __u16 __fs16;
43#else
44typedef __u64 __bitwise __fs64;
45typedef __u32 __bitwise __fs32;
46typedef __u16 __bitwise __fs16;
47#endif
48
49#include <linux/ufs_fs_i.h>
50#include <linux/ufs_fs_sb.h>
51
52#define UFS_BBLOCK 0
53#define UFS_BBSIZE 8192
54#define UFS_SBLOCK 8192
55#define UFS_SBSIZE 8192
56
57#define UFS_SECTOR_SIZE 512
58#define UFS_SECTOR_BITS 9
59#define UFS_MAGIC 0x00011954
60#define UFS2_MAGIC 0x19540119
61#define UFS_CIGAM 0x54190100 /* byteswapped MAGIC */
62
63/* Copied from FreeBSD */
64/*
65 * Each disk drive contains some number of filesystems.
66 * A filesystem consists of a number of cylinder groups.
67 * Each cylinder group has inodes and data.
68 *
69 * A filesystem is described by its super-block, which in turn
70 * describes the cylinder groups. The super-block is critical
71 * data and is replicated in each cylinder group to protect against
72 * catastrophic loss. This is done at `newfs' time and the critical
73 * super-block data does not change, so the copies need not be
74 * referenced further unless disaster strikes.
75 *
76 * For filesystem fs, the offsets of the various blocks of interest
77 * are given in the super block as:
78 * [fs->fs_sblkno] Super-block
79 * [fs->fs_cblkno] Cylinder group block
80 * [fs->fs_iblkno] Inode blocks
81 * [fs->fs_dblkno] Data blocks
82 * The beginning of cylinder group cg in fs, is given by
83 * the ``cgbase(fs, cg)'' macro.
84 *
85 * Depending on the architecture and the media, the superblock may
86 * reside in any one of four places. For tiny media where every block
87 * counts, it is placed at the very front of the partition. Historically,
88 * UFS1 placed it 8K from the front to leave room for the disk label and
89 * a small bootstrap. For UFS2 it got moved to 64K from the front to leave
90 * room for the disk label and a bigger bootstrap, and for really piggy
91 * systems we check at 256K from the front if the first three fail. In
92 * all cases the size of the superblock will be SBLOCKSIZE. All values are
93 * given in byte-offset form, so they do not imply a sector size. The
94 * SBLOCKSEARCH specifies the order in which the locations should be searched.
95 */
96#define SBLOCK_FLOPPY 0
97#define SBLOCK_UFS1 8192
98#define SBLOCK_UFS2 65536
99#define SBLOCK_PIGGY 262144
100#define SBLOCKSIZE 8192
101#define SBLOCKSEARCH \
102 { SBLOCK_UFS2, SBLOCK_UFS1, SBLOCK_FLOPPY, SBLOCK_PIGGY, -1 }
103
104
105/* HP specific MAGIC values */
106
107#define UFS_MAGIC_LFN 0x00095014 /* fs supports filenames > 14 chars */
108#define UFS_CIGAM_LFN 0x14500900 /* srahc 41 < semanelif stroppus sf */
109
110#define UFS_MAGIC_SEC 0x00612195 /* B1 security fs */
111#define UFS_CIGAM_SEC 0x95216100
112
113#define UFS_MAGIC_FEA 0x00195612 /* fs_featurebits supported */
114#define UFS_CIGAM_FEA 0x12561900
115
116#define UFS_MAGIC_4GB 0x05231994 /* fs > 4 GB && fs_featurebits */
117#define UFS_CIGAM_4GB 0x94192305
118
119/* Seems somebody at HP goofed here. B1 and lfs are both 0x2 !?! */
120#define UFS_FSF_LFN 0x00000001 /* long file names */
121#define UFS_FSF_B1 0x00000002 /* B1 security */
122#define UFS_FSF_LFS 0x00000002 /* large files */
123#define UFS_FSF_LUID 0x00000004 /* large UIDs */
124
125/* End of HP stuff */
126
127
128#define UFS_BSIZE 8192
129#define UFS_MINBSIZE 4096
130#define UFS_FSIZE 1024
131#define UFS_MAXFRAG (UFS_BSIZE / UFS_FSIZE)
132
133#define UFS_NDADDR 12
134#define UFS_NINDIR 3
135
136#define UFS_IND_BLOCK (UFS_NDADDR + 0)
137#define UFS_DIND_BLOCK (UFS_NDADDR + 1)
138#define UFS_TIND_BLOCK (UFS_NDADDR + 2)
139
140#define UFS_NDIR_FRAGMENT (UFS_NDADDR << uspi->s_fpbshift)
141#define UFS_IND_FRAGMENT (UFS_IND_BLOCK << uspi->s_fpbshift)
142#define UFS_DIND_FRAGMENT (UFS_DIND_BLOCK << uspi->s_fpbshift)
143#define UFS_TIND_FRAGMENT (UFS_TIND_BLOCK << uspi->s_fpbshift)
144
145#define UFS_ROOTINO 2
146#define UFS_FIRST_INO (UFS_ROOTINO + 1)
147
148#define UFS_USEEFT ((__u16)65535)
149
150#define UFS_FSOK 0x7c269d38
151#define UFS_FSACTIVE ((char)0x00)
152#define UFS_FSCLEAN ((char)0x01)
153#define UFS_FSSTABLE ((char)0x02)
154#define UFS_FSOSF1 ((char)0x03) /* is this correct for DEC OSF/1? */
155#define UFS_FSBAD ((char)0xff)
156
157/* From here to next blank line, s_flags for ufs_sb_info */
158/* directory entry encoding */
159#define UFS_DE_MASK 0x00000010 /* mask for the following */
160#define UFS_DE_OLD 0x00000000
161#define UFS_DE_44BSD 0x00000010
162/* uid encoding */
163#define UFS_UID_MASK 0x00000060 /* mask for the following */
164#define UFS_UID_OLD 0x00000000
165#define UFS_UID_44BSD 0x00000020
166#define UFS_UID_EFT 0x00000040
167/* superblock state encoding */
168#define UFS_ST_MASK 0x00000700 /* mask for the following */
169#define UFS_ST_OLD 0x00000000
170#define UFS_ST_44BSD 0x00000100
171#define UFS_ST_SUN 0x00000200
172#define UFS_ST_SUNx86 0x00000400
173/*cylinder group encoding */
174#define UFS_CG_MASK 0x00003000 /* mask for the following */
175#define UFS_CG_OLD 0x00000000
176#define UFS_CG_44BSD 0x00002000
177#define UFS_CG_SUN 0x00001000
178/* filesystem type encoding */
179#define UFS_TYPE_MASK 0x00010000 /* mask for the following */
180#define UFS_TYPE_UFS1 0x00000000
181#define UFS_TYPE_UFS2 0x00010000
182
183
184/* fs_inodefmt options */
185#define UFS_42INODEFMT -1
186#define UFS_44INODEFMT 2
187
188/* mount options */
189#define UFS_MOUNT_ONERROR 0x0000000F
190#define UFS_MOUNT_ONERROR_PANIC 0x00000001
191#define UFS_MOUNT_ONERROR_LOCK 0x00000002
192#define UFS_MOUNT_ONERROR_UMOUNT 0x00000004
193#define UFS_MOUNT_ONERROR_REPAIR 0x00000008
194
195#define UFS_MOUNT_UFSTYPE 0x0000FFF0
196#define UFS_MOUNT_UFSTYPE_OLD 0x00000010
197#define UFS_MOUNT_UFSTYPE_44BSD 0x00000020
198#define UFS_MOUNT_UFSTYPE_SUN 0x00000040
199#define UFS_MOUNT_UFSTYPE_NEXTSTEP 0x00000080
200#define UFS_MOUNT_UFSTYPE_NEXTSTEP_CD 0x00000100
201#define UFS_MOUNT_UFSTYPE_OPENSTEP 0x00000200
202#define UFS_MOUNT_UFSTYPE_SUNx86 0x00000400
203#define UFS_MOUNT_UFSTYPE_HP 0x00000800
204#define UFS_MOUNT_UFSTYPE_UFS2 0x00001000
205
206#define ufs_clear_opt(o,opt) o &= ~UFS_MOUNT_##opt
207#define ufs_set_opt(o,opt) o |= UFS_MOUNT_##opt
208#define ufs_test_opt(o,opt) ((o) & UFS_MOUNT_##opt)
209
210/*
211 * MINFREE gives the minimum acceptable percentage of file system
212 * blocks which may be free. If the freelist drops below this level
213 * only the superuser may continue to allocate blocks. This may
214 * be set to 0 if no reserve of free blocks is deemed necessary,
215 * however throughput drops by fifty percent if the file system
216 * is run at between 95% and 100% full; thus the minimum default
217 * value of fs_minfree is 5%. However, to get good clustering
218 * performance, 10% is a better choice. hence we use 10% as our
219 * default value. With 10% free space, fragmentation is not a
220 * problem, so we choose to optimize for time.
221 */
222#define UFS_MINFREE 5
223#define UFS_DEFAULTOPT UFS_OPTTIME
224
225/*
226 * Turn file system block numbers into disk block addresses.
227 * This maps file system blocks to device size blocks.
228 */
229#define ufs_fsbtodb(uspi, b) ((b) << (uspi)->s_fsbtodb)
230#define ufs_dbtofsb(uspi, b) ((b) >> (uspi)->s_fsbtodb)
231
232/*
233 * Cylinder group macros to locate things in cylinder groups.
234 * They calc file system addresses of cylinder group data structures.
235 */
236#define ufs_cgbase(c) (uspi->s_fpg * (c))
237#define ufs_cgstart(c) ((uspi)->fs_magic == UFS2_MAGIC ? ufs_cgbase(c) : \
238 (ufs_cgbase(c) + uspi->s_cgoffset * ((c) & ~uspi->s_cgmask)))
239#define ufs_cgsblock(c) (ufs_cgstart(c) + uspi->s_sblkno) /* super blk */
240#define ufs_cgcmin(c) (ufs_cgstart(c) + uspi->s_cblkno) /* cg block */
241#define ufs_cgimin(c) (ufs_cgstart(c) + uspi->s_iblkno) /* inode blk */
242#define ufs_cgdmin(c) (ufs_cgstart(c) + uspi->s_dblkno) /* 1st data */
243
244/*
245 * Macros for handling inode numbers:
246 * inode number to file system block offset.
247 * inode number to cylinder group number.
248 * inode number to file system block address.
249 */
250#define ufs_inotocg(x) ((x) / uspi->s_ipg)
251#define ufs_inotocgoff(x) ((x) % uspi->s_ipg)
252#define ufs_inotofsba(x) (ufs_cgimin(ufs_inotocg(x)) + ufs_inotocgoff(x) / uspi->s_inopf)
253#define ufs_inotofsbo(x) ((x) % uspi->s_inopf)
254
255/*
256 * Give cylinder group number for a file system block.
257 * Give cylinder group block number for a file system block.
258 */
259#define ufs_dtog(d) ((d) / uspi->s_fpg)
260#define ufs_dtogd(d) ((d) % uspi->s_fpg)
261
262/*
263 * Compute the cylinder and rotational position of a cyl block addr.
264 */
265#define ufs_cbtocylno(bno) \
266 ((bno) * uspi->s_nspf / uspi->s_spc)
267#define ufs_cbtorpos(bno) \
268 ((((bno) * uspi->s_nspf % uspi->s_spc / uspi->s_nsect \
269 * uspi->s_trackskew + (bno) * uspi->s_nspf % uspi->s_spc \
270 % uspi->s_nsect * uspi->s_interleave) % uspi->s_nsect \
271 * uspi->s_nrpos) / uspi->s_npsect)
272
273/*
274 * The following macros optimize certain frequently calculated
275 * quantities by using shifts and masks in place of divisions
276 * modulos and multiplications.
277 */
278#define ufs_blkoff(loc) ((loc) & uspi->s_qbmask)
279#define ufs_fragoff(loc) ((loc) & uspi->s_qfmask)
280#define ufs_lblktosize(blk) ((blk) << uspi->s_bshift)
281#define ufs_lblkno(loc) ((loc) >> uspi->s_bshift)
282#define ufs_numfrags(loc) ((loc) >> uspi->s_fshift)
283#define ufs_blkroundup(size) (((size) + uspi->s_qbmask) & uspi->s_bmask)
284#define ufs_fragroundup(size) (((size) + uspi->s_qfmask) & uspi->s_fmask)
285#define ufs_fragstoblks(frags) ((frags) >> uspi->s_fpbshift)
286#define ufs_blkstofrags(blks) ((blks) << uspi->s_fpbshift)
287#define ufs_fragnum(fsb) ((fsb) & uspi->s_fpbmask)
288#define ufs_blknum(fsb) ((fsb) & ~uspi->s_fpbmask)
289
290#define UFS_MAXNAMLEN 255
291#define UFS_MAXMNTLEN 512
292#define UFS2_MAXMNTLEN 468
293#define UFS2_MAXVOLLEN 32
294/* #define UFS_MAXCSBUFS 31 */
295#define UFS_LINK_MAX 32000
296/*
297#define UFS2_NOCSPTRS ((128 / sizeof(void *)) - 4)
298*/
299#define UFS2_NOCSPTRS 28
300
301/*
302 * UFS_DIR_PAD defines the directory entries boundaries
303 * (must be a multiple of 4)
304 */
305#define UFS_DIR_PAD 4
306#define UFS_DIR_ROUND (UFS_DIR_PAD - 1)
307#define UFS_DIR_REC_LEN(name_len) (((name_len) + 1 + 8 + UFS_DIR_ROUND) & ~UFS_DIR_ROUND)
308
309struct ufs_timeval {
310 __fs32 tv_sec;
311 __fs32 tv_usec;
312};
313
314struct ufs_dir_entry {
315 __fs32 d_ino; /* inode number of this entry */
316 __fs16 d_reclen; /* length of this entry */
317 union {
318 __fs16 d_namlen; /* actual length of d_name */
319 struct {
320 __u8 d_type; /* file type */
321 __u8 d_namlen; /* length of string in d_name */
322 } d_44;
323 } d_u;
324 __u8 d_name[UFS_MAXNAMLEN + 1]; /* file name */
325};
326
327struct ufs_csum {
328 __fs32 cs_ndir; /* number of directories */
329 __fs32 cs_nbfree; /* number of free blocks */
330 __fs32 cs_nifree; /* number of free inodes */
331 __fs32 cs_nffree; /* number of free frags */
332};
333struct ufs2_csum_total {
334 __fs64 cs_ndir; /* number of directories */
335 __fs64 cs_nbfree; /* number of free blocks */
336 __fs64 cs_nifree; /* number of free inodes */
337 __fs64 cs_nffree; /* number of free frags */
338 __fs64 cs_numclusters; /* number of free clusters */
339 __fs64 cs_spare[3]; /* future expansion */
340};
341
342/*
343 * This is the actual superblock, as it is laid out on the disk.
344 */
345struct ufs_super_block {
346 __fs32 fs_link; /* UNUSED */
347 __fs32 fs_rlink; /* UNUSED */
348 __fs32 fs_sblkno; /* addr of super-block in filesys */
349 __fs32 fs_cblkno; /* offset of cyl-block in filesys */
350 __fs32 fs_iblkno; /* offset of inode-blocks in filesys */
351 __fs32 fs_dblkno; /* offset of first data after cg */
352 __fs32 fs_cgoffset; /* cylinder group offset in cylinder */
353 __fs32 fs_cgmask; /* used to calc mod fs_ntrak */
354 __fs32 fs_time; /* last time written -- time_t */
355 __fs32 fs_size; /* number of blocks in fs */
356 __fs32 fs_dsize; /* number of data blocks in fs */
357 __fs32 fs_ncg; /* number of cylinder groups */
358 __fs32 fs_bsize; /* size of basic blocks in fs */
359 __fs32 fs_fsize; /* size of frag blocks in fs */
360 __fs32 fs_frag; /* number of frags in a block in fs */
361/* these are configuration parameters */
362 __fs32 fs_minfree; /* minimum percentage of free blocks */
363 __fs32 fs_rotdelay; /* num of ms for optimal next block */
364 __fs32 fs_rps; /* disk revolutions per second */
365/* these fields can be computed from the others */
366 __fs32 fs_bmask; /* ``blkoff'' calc of blk offsets */
367 __fs32 fs_fmask; /* ``fragoff'' calc of frag offsets */
368 __fs32 fs_bshift; /* ``lblkno'' calc of logical blkno */
369 __fs32 fs_fshift; /* ``numfrags'' calc number of frags */
370/* these are configuration parameters */
371 __fs32 fs_maxcontig; /* max number of contiguous blks */
372 __fs32 fs_maxbpg; /* max number of blks per cyl group */
373/* these fields can be computed from the others */
374 __fs32 fs_fragshift; /* block to frag shift */
375 __fs32 fs_fsbtodb; /* fsbtodb and dbtofsb shift constant */
376 __fs32 fs_sbsize; /* actual size of super block */
377 __fs32 fs_csmask; /* csum block offset */
378 __fs32 fs_csshift; /* csum block number */
379 __fs32 fs_nindir; /* value of NINDIR */
380 __fs32 fs_inopb; /* value of INOPB */
381 __fs32 fs_nspf; /* value of NSPF */
382/* yet another configuration parameter */
383 __fs32 fs_optim; /* optimization preference, see below */
384/* these fields are derived from the hardware */
385 union {
386 struct {
387 __fs32 fs_npsect; /* # sectors/track including spares */
388 } fs_sun;
389 struct {
390 __fs32 fs_state; /* file system state time stamp */
391 } fs_sunx86;
392 } fs_u1;
393 __fs32 fs_interleave; /* hardware sector interleave */
394 __fs32 fs_trackskew; /* sector 0 skew, per track */
395/* a unique id for this filesystem (currently unused and unmaintained) */
396/* In 4.3 Tahoe this space is used by fs_headswitch and fs_trkseek */
397/* Neither of those fields is used in the Tahoe code right now but */
398/* there could be problems if they are. */
399 __fs32 fs_id[2]; /* file system id */
400/* sizes determined by number of cylinder groups and their sizes */
401 __fs32 fs_csaddr; /* blk addr of cyl grp summary area */
402 __fs32 fs_cssize; /* size of cyl grp summary area */
403 __fs32 fs_cgsize; /* cylinder group size */
404/* these fields are derived from the hardware */
405 __fs32 fs_ntrak; /* tracks per cylinder */
406 __fs32 fs_nsect; /* sectors per track */
407 __fs32 fs_spc; /* sectors per cylinder */
408/* this comes from the disk driver partitioning */
409 __fs32 fs_ncyl; /* cylinders in file system */
410/* these fields can be computed from the others */
411 __fs32 fs_cpg; /* cylinders per group */
412 __fs32 fs_ipg; /* inodes per cylinder group */
413 __fs32 fs_fpg; /* blocks per group * fs_frag */
414/* this data must be re-computed after crashes */
415 struct ufs_csum fs_cstotal; /* cylinder summary information */
416/* these fields are cleared at mount time */
417 __s8 fs_fmod; /* super block modified flag */
418 __s8 fs_clean; /* file system is clean flag */
419 __s8 fs_ronly; /* mounted read-only flag */
420 __s8 fs_flags; /* currently unused flag */
421 union {
422 struct {
423 __s8 fs_fsmnt[UFS_MAXMNTLEN];/* name mounted on */
424 __fs32 fs_cgrotor; /* last cg searched */
425 __fs32 fs_csp[UFS_MAXCSBUFS];/*list of fs_cs info buffers */
426 __fs32 fs_maxcluster;
427 __fs32 fs_cpc; /* cyl per cycle in postbl */
428 __fs16 fs_opostbl[16][8]; /* old rotation block list head */
429 } fs_u1;
430 struct {
431 __s8 fs_fsmnt[UFS2_MAXMNTLEN]; /* name mounted on */
432 __u8 fs_volname[UFS2_MAXVOLLEN]; /* volume name */
433 __fs64 fs_swuid; /* system-wide uid */
434 __fs32 fs_pad; /* due to alignment of fs_swuid */
435 __fs32 fs_cgrotor; /* last cg searched */
436 __fs32 fs_ocsp[UFS2_NOCSPTRS]; /*list of fs_cs info buffers */
437 __fs32 fs_contigdirs;/*# of contiguously allocated dirs */
438 __fs32 fs_csp; /* cg summary info buffer for fs_cs */
439 __fs32 fs_maxcluster;
440 __fs32 fs_active;/* used by snapshots to track fs */
441 __fs32 fs_old_cpc; /* cyl per cycle in postbl */
442 __fs32 fs_maxbsize;/*maximum blocking factor permitted */
443 __fs64 fs_sparecon64[17];/*old rotation block list head */
444 __fs64 fs_sblockloc; /* byte offset of standard superblock */
445 struct ufs2_csum_total fs_cstotal;/*cylinder summary information*/
446 struct ufs_timeval fs_time; /* last time written */
447 __fs64 fs_size; /* number of blocks in fs */
448 __fs64 fs_dsize; /* number of data blocks in fs */
449 __fs64 fs_csaddr; /* blk addr of cyl grp summary area */
450 __fs64 fs_pendingblocks;/* blocks in process of being freed */
451 __fs32 fs_pendinginodes;/*inodes in process of being freed */
452 } fs_u2;
453 } fs_u11;
454 union {
455 struct {
456 __fs32 fs_sparecon[53];/* reserved for future constants */
457 __fs32 fs_reclaim;
458 __fs32 fs_sparecon2[1];
459 __fs32 fs_state; /* file system state time stamp */
460 __fs32 fs_qbmask[2]; /* ~usb_bmask */
461 __fs32 fs_qfmask[2]; /* ~usb_fmask */
462 } fs_sun;
463 struct {
464 __fs32 fs_sparecon[53];/* reserved for future constants */
465 __fs32 fs_reclaim;
466 __fs32 fs_sparecon2[1];
467 __fs32 fs_npsect; /* # sectors/track including spares */
468 __fs32 fs_qbmask[2]; /* ~usb_bmask */
469 __fs32 fs_qfmask[2]; /* ~usb_fmask */
470 } fs_sunx86;
471 struct {
472 __fs32 fs_sparecon[50];/* reserved for future constants */
473 __fs32 fs_contigsumsize;/* size of cluster summary array */
474 __fs32 fs_maxsymlinklen;/* max length of an internal symlink */
475 __fs32 fs_inodefmt; /* format of on-disk inodes */
476 __fs32 fs_maxfilesize[2]; /* max representable file size */
477 __fs32 fs_qbmask[2]; /* ~usb_bmask */
478 __fs32 fs_qfmask[2]; /* ~usb_fmask */
479 __fs32 fs_state; /* file system state time stamp */
480 } fs_44;
481 } fs_u2;
482 __fs32 fs_postblformat; /* format of positional layout tables */
483 __fs32 fs_nrpos; /* number of rotational positions */
484 __fs32 fs_postbloff; /* (__s16) rotation block list head */
485 __fs32 fs_rotbloff; /* (__u8) blocks for each rotation */
486 __fs32 fs_magic; /* magic number */
487 __u8 fs_space[1]; /* list of blocks for each rotation */
488};
489
490/*
491 * Preference for optimization.
492 */
493#define UFS_OPTTIME 0 /* minimize allocation time */
494#define UFS_OPTSPACE 1 /* minimize disk fragmentation */
495
496/*
497 * Rotational layout table format types
498 */
499#define UFS_42POSTBLFMT -1 /* 4.2BSD rotational table format */
500#define UFS_DYNAMICPOSTBLFMT 1 /* dynamic rotational table format */
501
502/*
503 * Convert cylinder group to base address of its global summary info.
504 */
505#define fs_cs(indx) \
506 s_csp[(indx) >> uspi->s_csshift][(indx) & ~uspi->s_csmask]
507
508/*
509 * Cylinder group block for a file system.
510 *
511 * Writable fields in the cylinder group are protected by the associated
512 * super block lock fs->fs_lock.
513 */
514#define CG_MAGIC 0x090255
515#define ufs_cg_chkmagic(sb, ucg) \
516 (fs32_to_cpu((sb), (ucg)->cg_magic) == CG_MAGIC)
517
518/*
519 * size of this structure is 172 B
520 */
521struct ufs_cylinder_group {
522 __fs32 cg_link; /* linked list of cyl groups */
523 __fs32 cg_magic; /* magic number */
524 __fs32 cg_time; /* time last written */
525 __fs32 cg_cgx; /* we are the cgx'th cylinder group */
526 __fs16 cg_ncyl; /* number of cyl's this cg */
527 __fs16 cg_niblk; /* number of inode blocks this cg */
528 __fs32 cg_ndblk; /* number of data blocks this cg */
529 struct ufs_csum cg_cs; /* cylinder summary information */
530 __fs32 cg_rotor; /* position of last used block */
531 __fs32 cg_frotor; /* position of last used frag */
532 __fs32 cg_irotor; /* position of last used inode */
533 __fs32 cg_frsum[UFS_MAXFRAG]; /* counts of available frags */
534 __fs32 cg_btotoff; /* (__u32) block totals per cylinder */
535 __fs32 cg_boff; /* (short) free block positions */
536 __fs32 cg_iusedoff; /* (char) used inode map */
537 __fs32 cg_freeoff; /* (u_char) free block map */
538 __fs32 cg_nextfreeoff; /* (u_char) next available space */
539 union {
540 struct {
541 __fs32 cg_clustersumoff; /* (u_int32) counts of avail clusters */
542 __fs32 cg_clusteroff; /* (u_int8) free cluster map */
543 __fs32 cg_nclusterblks; /* number of clusters this cg */
544 __fs32 cg_sparecon[13]; /* reserved for future use */
545 } cg_44;
546 struct {
547 __fs32 cg_clustersumoff;/* (u_int32) counts of avail clusters */
548 __fs32 cg_clusteroff; /* (u_int8) free cluster map */
549 __fs32 cg_nclusterblks;/* number of clusters this cg */
550 __fs32 cg_niblk; /* number of inode blocks this cg */
551 __fs32 cg_initediblk; /* last initialized inode */
552 __fs32 cg_sparecon32[3];/* reserved for future use */
553 __fs64 cg_time; /* time last written */
554 __fs64 cg_sparecon[3]; /* reserved for future use */
555 } cg_u2;
556 __fs32 cg_sparecon[16]; /* reserved for future use */
557 } cg_u;
558 __u8 cg_space[1]; /* space for cylinder group maps */
559/* actually longer */
560};
561
562/*
563 * structure of an on-disk inode
564 */
565struct ufs_inode {
566 __fs16 ui_mode; /* 0x0 */
567 __fs16 ui_nlink; /* 0x2 */
568 union {
569 struct {
570 __fs16 ui_suid; /* 0x4 */
571 __fs16 ui_sgid; /* 0x6 */
572 } oldids;
573 __fs32 ui_inumber; /* 0x4 lsf: inode number */
574 __fs32 ui_author; /* 0x4 GNU HURD: author */
575 } ui_u1;
576 __fs64 ui_size; /* 0x8 */
577 struct ufs_timeval ui_atime; /* 0x10 access */
578 struct ufs_timeval ui_mtime; /* 0x18 modification */
579 struct ufs_timeval ui_ctime; /* 0x20 creation */
580 union {
581 struct {
582 __fs32 ui_db[UFS_NDADDR];/* 0x28 data blocks */
583 __fs32 ui_ib[UFS_NINDIR];/* 0x58 indirect blocks */
584 } ui_addr;
585 __u8 ui_symlink[4*(UFS_NDADDR+UFS_NINDIR)];/* 0x28 fast symlink */
586 } ui_u2;
587 __fs32 ui_flags; /* 0x64 immutable, append-only... */
588 __fs32 ui_blocks; /* 0x68 blocks in use */
589 __fs32 ui_gen; /* 0x6c like ext2 i_version, for NFS support */
590 union {
591 struct {
592 __fs32 ui_shadow; /* 0x70 shadow inode with security data */
593 __fs32 ui_uid; /* 0x74 long EFT version of uid */
594 __fs32 ui_gid; /* 0x78 long EFT version of gid */
595 __fs32 ui_oeftflag; /* 0x7c reserved */
596 } ui_sun;
597 struct {
598 __fs32 ui_uid; /* 0x70 File owner */
599 __fs32 ui_gid; /* 0x74 File group */
600 __fs32 ui_spare[2]; /* 0x78 reserved */
601 } ui_44;
602 struct {
603 __fs32 ui_uid; /* 0x70 */
604 __fs32 ui_gid; /* 0x74 */
605 __fs16 ui_modeh; /* 0x78 mode high bits */
606 __fs16 ui_spare; /* 0x7A unused */
607 __fs32 ui_trans; /* 0x7c filesystem translator */
608 } ui_hurd;
609 } ui_u3;
610};
611
612#define UFS_NXADDR 2 /* External addresses in inode. */
613struct ufs2_inode {
614 __fs16 ui_mode; /* 0: IFMT, permissions; see below. */
615 __fs16 ui_nlink; /* 2: File link count. */
616 __fs32 ui_uid; /* 4: File owner. */
617 __fs32 ui_gid; /* 8: File group. */
618 __fs32 ui_blksize; /* 12: Inode blocksize. */
619 __fs64 ui_size; /* 16: File byte count. */
620 __fs64 ui_blocks; /* 24: Bytes actually held. */
621 struct ufs_timeval ui_atime; /* 32: Last access time. */
622 struct ufs_timeval ui_mtime; /* 40: Last modified time. */
623 struct ufs_timeval ui_ctime; /* 48: Last inode change time. */
624 struct ufs_timeval ui_birthtime; /* 56: Inode creation time. */
625 __fs32 ui_mtimensec; /* 64: Last modified time. */
626 __fs32 ui_atimensec; /* 68: Last access time. */
627 __fs32 ui_ctimensec; /* 72: Last inode change time. */
628 __fs32 ui_birthnsec; /* 76: Inode creation time. */
629 __fs32 ui_gen; /* 80: Generation number. */
630 __fs32 ui_kernflags; /* 84: Kernel flags. */
631 __fs32 ui_flags; /* 88: Status flags (chflags). */
632 __fs32 ui_extsize; /* 92: External attributes block. */
633 __fs64 ui_extb[UFS_NXADDR];/* 96: External attributes block. */
634 union {
635 struct {
636 __fs64 ui_db[UFS_NDADDR]; /* 112: Direct disk blocks. */
637 __fs64 ui_ib[UFS_NINDIR];/* 208: Indirect disk blocks.*/
638 } ui_addr;
639 __u8 ui_symlink[2*4*(UFS_NDADDR+UFS_NINDIR)];/* 0x28 fast symlink */
640 } ui_u2;
641 __fs64 ui_spare[3]; /* 232: Reserved; currently unused */
642};
643
644
645/* FreeBSD has these in sys/stat.h */
646/* ui_flags that can be set by a file owner */
647#define UFS_UF_SETTABLE 0x0000ffff
648#define UFS_UF_NODUMP 0x00000001 /* do not dump */
649#define UFS_UF_IMMUTABLE 0x00000002 /* immutable (can't "change") */
650#define UFS_UF_APPEND 0x00000004 /* append-only */
651#define UFS_UF_OPAQUE 0x00000008 /* directory is opaque (unionfs) */
652#define UFS_UF_NOUNLINK 0x00000010 /* can't be removed or renamed */
653/* ui_flags that only root can set */
654#define UFS_SF_SETTABLE 0xffff0000
655#define UFS_SF_ARCHIVED 0x00010000 /* archived */
656#define UFS_SF_IMMUTABLE 0x00020000 /* immutable (can't "change") */
657#define UFS_SF_APPEND 0x00040000 /* append-only */
658#define UFS_SF_NOUNLINK 0x00100000 /* can't be removed or renamed */
659
660/*
661 * This structure is used for reading disk structures larger
662 * than the size of fragment.
663 */
664struct ufs_buffer_head {
665 __u64 fragment; /* first fragment */
666 __u64 count; /* number of fragments */
667 struct buffer_head * bh[UFS_MAXFRAG]; /* buffers */
668};
669
670struct ufs_cg_private_info {
671 struct ufs_cylinder_group ucg;
672 __u32 c_cgx; /* number of cylidner group */
673 __u16 c_ncyl; /* number of cyl's this cg */
674 __u16 c_niblk; /* number of inode blocks this cg */
675 __u32 c_ndblk; /* number of data blocks this cg */
676 __u32 c_rotor; /* position of last used block */
677 __u32 c_frotor; /* position of last used frag */
678 __u32 c_irotor; /* position of last used inode */
679 __u32 c_btotoff; /* (__u32) block totals per cylinder */
680 __u32 c_boff; /* (short) free block positions */
681 __u32 c_iusedoff; /* (char) used inode map */
682 __u32 c_freeoff; /* (u_char) free block map */
683 __u32 c_nextfreeoff; /* (u_char) next available space */
684 __u32 c_clustersumoff;/* (u_int32) counts of avail clusters */
685 __u32 c_clusteroff; /* (u_int8) free cluster map */
686 __u32 c_nclusterblks; /* number of clusters this cg */
687};
688
689struct ufs_sb_private_info {
690 struct ufs_buffer_head s_ubh; /* buffer containing super block */
691 __u32 s_sblkno; /* offset of super-blocks in filesys */
692 __u32 s_cblkno; /* offset of cg-block in filesys */
693 __u32 s_iblkno; /* offset of inode-blocks in filesys */
694 __u32 s_dblkno; /* offset of first data after cg */
695 __u32 s_cgoffset; /* cylinder group offset in cylinder */
696 __u32 s_cgmask; /* used to calc mod fs_ntrak */
697 __u32 s_size; /* number of blocks (fragments) in fs */
698 __u32 s_dsize; /* number of data blocks in fs */
699 __u64 s_u2_size; /* ufs2: number of blocks (fragments) in fs */
700 __u64 s_u2_dsize; /*ufs2: number of data blocks in fs */
701 __u32 s_ncg; /* number of cylinder groups */
702 __u32 s_bsize; /* size of basic blocks */
703 __u32 s_fsize; /* size of fragments */
704 __u32 s_fpb; /* fragments per block */
705 __u32 s_minfree; /* minimum percentage of free blocks */
706 __u32 s_bmask; /* `blkoff'' calc of blk offsets */
707 __u32 s_fmask; /* s_fsize mask */
708 __u32 s_bshift; /* `lblkno'' calc of logical blkno */
709 __u32 s_fshift; /* s_fsize shift */
710 __u32 s_fpbshift; /* fragments per block shift */
711 __u32 s_fsbtodb; /* fsbtodb and dbtofsb shift constant */
712 __u32 s_sbsize; /* actual size of super block */
713 __u32 s_csmask; /* csum block offset */
714 __u32 s_csshift; /* csum block number */
715 __u32 s_nindir; /* value of NINDIR */
716 __u32 s_inopb; /* value of INOPB */
717 __u32 s_nspf; /* value of NSPF */
718 __u32 s_npsect; /* # sectors/track including spares */
719 __u32 s_interleave; /* hardware sector interleave */
720 __u32 s_trackskew; /* sector 0 skew, per track */
721 __u32 s_csaddr; /* blk addr of cyl grp summary area */
722 __u32 s_cssize; /* size of cyl grp summary area */
723 __u32 s_cgsize; /* cylinder group size */
724 __u32 s_ntrak; /* tracks per cylinder */
725 __u32 s_nsect; /* sectors per track */
726 __u32 s_spc; /* sectors per cylinder */
727 __u32 s_ipg; /* inodes per cylinder group */
728 __u32 s_fpg; /* fragments per group */
729 __u32 s_cpc; /* cyl per cycle in postbl */
730 __s32 s_contigsumsize;/* size of cluster summary array, 44bsd */
731 __s64 s_qbmask; /* ~usb_bmask */
732 __s64 s_qfmask; /* ~usb_fmask */
733 __s32 s_postblformat; /* format of positional layout tables */
734 __s32 s_nrpos; /* number of rotational positions */
735 __s32 s_postbloff; /* (__s16) rotation block list head */
736 __s32 s_rotbloff; /* (__u8) blocks for each rotation */
737
738 __u32 s_fpbmask; /* fragments per block mask */
739 __u32 s_apb; /* address per block */
740 __u32 s_2apb; /* address per block^2 */
741 __u32 s_3apb; /* address per block^3 */
742 __u32 s_apbmask; /* address per block mask */
743 __u32 s_apbshift; /* address per block shift */
744 __u32 s_2apbshift; /* address per block shift * 2 */
745 __u32 s_3apbshift; /* address per block shift * 3 */
746 __u32 s_nspfshift; /* number of sector per fragment shift */
747 __u32 s_nspb; /* number of sector per block */
748 __u32 s_inopf; /* inodes per fragment */
749 __u32 s_sbbase; /* offset of NeXTstep superblock */
750 __u32 s_bpf; /* bits per fragment */
751 __u32 s_bpfshift; /* bits per fragment shift*/
752 __u32 s_bpfmask; /* bits per fragment mask */
753
754 __u32 s_maxsymlinklen;/* upper limit on fast symlinks' size */
755 __s32 fs_magic; /* filesystem magic */
756};
757
758/*
759 * Sizes of this structures are:
760 * ufs_super_block_first 512
761 * ufs_super_block_second 512
762 * ufs_super_block_third 356
763 */
764struct ufs_super_block_first {
765 __fs32 fs_link;
766 __fs32 fs_rlink;
767 __fs32 fs_sblkno;
768 __fs32 fs_cblkno;
769 __fs32 fs_iblkno;
770 __fs32 fs_dblkno;
771 __fs32 fs_cgoffset;
772 __fs32 fs_cgmask;
773 __fs32 fs_time;
774 __fs32 fs_size;
775 __fs32 fs_dsize;
776 __fs32 fs_ncg;
777 __fs32 fs_bsize;
778 __fs32 fs_fsize;
779 __fs32 fs_frag;
780 __fs32 fs_minfree;
781 __fs32 fs_rotdelay;
782 __fs32 fs_rps;
783 __fs32 fs_bmask;
784 __fs32 fs_fmask;
785 __fs32 fs_bshift;
786 __fs32 fs_fshift;
787 __fs32 fs_maxcontig;
788 __fs32 fs_maxbpg;
789 __fs32 fs_fragshift;
790 __fs32 fs_fsbtodb;
791 __fs32 fs_sbsize;
792 __fs32 fs_csmask;
793 __fs32 fs_csshift;
794 __fs32 fs_nindir;
795 __fs32 fs_inopb;
796 __fs32 fs_nspf;
797 __fs32 fs_optim;
798 union {
799 struct {
800 __fs32 fs_npsect;
801 } fs_sun;
802 struct {
803 __fs32 fs_state;
804 } fs_sunx86;
805 } fs_u1;
806 __fs32 fs_interleave;
807 __fs32 fs_trackskew;
808 __fs32 fs_id[2];
809 __fs32 fs_csaddr;
810 __fs32 fs_cssize;
811 __fs32 fs_cgsize;
812 __fs32 fs_ntrak;
813 __fs32 fs_nsect;
814 __fs32 fs_spc;
815 __fs32 fs_ncyl;
816 __fs32 fs_cpg;
817 __fs32 fs_ipg;
818 __fs32 fs_fpg;
819 struct ufs_csum fs_cstotal;
820 __s8 fs_fmod;
821 __s8 fs_clean;
822 __s8 fs_ronly;
823 __s8 fs_flags;
824 __s8 fs_fsmnt[UFS_MAXMNTLEN - 212];
825
826};
827
828struct ufs_super_block_second {
829 __s8 fs_fsmnt[212];
830 __fs32 fs_cgrotor;
831 __fs32 fs_csp[UFS_MAXCSBUFS];
832 __fs32 fs_maxcluster;
833 __fs32 fs_cpc;
834 __fs16 fs_opostbl[82];
835};
836
837struct ufs_super_block_third {
838 __fs16 fs_opostbl[46];
839 union {
840 struct {
841 __fs32 fs_sparecon[53];/* reserved for future constants */
842 __fs32 fs_reclaim;
843 __fs32 fs_sparecon2[1];
844 __fs32 fs_state; /* file system state time stamp */
845 __fs32 fs_qbmask[2]; /* ~usb_bmask */
846 __fs32 fs_qfmask[2]; /* ~usb_fmask */
847 } fs_sun;
848 struct {
849 __fs32 fs_sparecon[53];/* reserved for future constants */
850 __fs32 fs_reclaim;
851 __fs32 fs_sparecon2[1];
852 __fs32 fs_npsect; /* # sectors/track including spares */
853 __fs32 fs_qbmask[2]; /* ~usb_bmask */
854 __fs32 fs_qfmask[2]; /* ~usb_fmask */
855 } fs_sunx86;
856 struct {
857 __fs32 fs_sparecon[50];/* reserved for future constants */
858 __fs32 fs_contigsumsize;/* size of cluster summary array */
859 __fs32 fs_maxsymlinklen;/* max length of an internal symlink */
860 __fs32 fs_inodefmt; /* format of on-disk inodes */
861 __fs32 fs_maxfilesize[2]; /* max representable file size */
862 __fs32 fs_qbmask[2]; /* ~usb_bmask */
863 __fs32 fs_qfmask[2]; /* ~usb_fmask */
864 __fs32 fs_state; /* file system state time stamp */
865 } fs_44;
866 } fs_u2;
867 __fs32 fs_postblformat;
868 __fs32 fs_nrpos;
869 __fs32 fs_postbloff;
870 __fs32 fs_rotbloff;
871 __fs32 fs_magic;
872 __u8 fs_space[1];
873};
874
875#ifdef __KERNEL__
876
877/* balloc.c */
878extern void ufs_free_fragments (struct inode *, unsigned, unsigned);
879extern void ufs_free_blocks (struct inode *, unsigned, unsigned);
880extern unsigned ufs_new_fragments (struct inode *, __fs32 *, unsigned, unsigned, unsigned, int *);
881
882/* cylinder.c */
883extern struct ufs_cg_private_info * ufs_load_cylinder (struct super_block *, unsigned);
884extern void ufs_put_cylinder (struct super_block *, unsigned);
885
886/* dir.c */
887extern struct inode_operations ufs_dir_inode_operations;
888extern int ufs_add_link (struct dentry *, struct inode *);
889extern ino_t ufs_inode_by_name(struct inode *, struct dentry *);
890extern int ufs_make_empty(struct inode *, struct inode *);
891extern struct ufs_dir_entry * ufs_find_entry (struct dentry *, struct buffer_head **);
892extern int ufs_delete_entry (struct inode *, struct ufs_dir_entry *, struct buffer_head *);
893extern int ufs_empty_dir (struct inode *);
894extern struct ufs_dir_entry * ufs_dotdot (struct inode *, struct buffer_head **);
895extern void ufs_set_link(struct inode *, struct ufs_dir_entry *, struct buffer_head *, struct inode *);
896
897/* file.c */
898extern struct inode_operations ufs_file_inode_operations;
899extern struct file_operations ufs_file_operations;
900
901extern struct address_space_operations ufs_aops;
902
903/* ialloc.c */
904extern void ufs_free_inode (struct inode *inode);
905extern struct inode * ufs_new_inode (struct inode *, int);
906
907/* inode.c */
908extern u64 ufs_frag_map (struct inode *, sector_t);
909extern void ufs_read_inode (struct inode *);
910extern void ufs_put_inode (struct inode *);
911extern int ufs_write_inode (struct inode *, int);
912extern int ufs_sync_inode (struct inode *);
913extern void ufs_delete_inode (struct inode *);
914extern struct buffer_head * ufs_getfrag (struct inode *, unsigned, int, int *);
915extern struct buffer_head * ufs_bread (struct inode *, unsigned, int, int *);
916
917/* namei.c */
918extern struct file_operations ufs_dir_operations;
919
920/* super.c */
921extern void ufs_warning (struct super_block *, const char *, const char *, ...) __attribute__ ((format (printf, 3, 4)));
922extern void ufs_error (struct super_block *, const char *, const char *, ...) __attribute__ ((format (printf, 3, 4)));
923extern void ufs_panic (struct super_block *, const char *, const char *, ...) __attribute__ ((format (printf, 3, 4)));
924
925/* symlink.c */
926extern struct inode_operations ufs_fast_symlink_inode_operations;
927
928/* truncate.c */
929extern void ufs_truncate (struct inode *);
930
931static inline struct ufs_sb_info *UFS_SB(struct super_block *sb)
932{
933 return sb->s_fs_info;
934}
935
936static inline struct ufs_inode_info *UFS_I(struct inode *inode)
937{
938 return container_of(inode, struct ufs_inode_info, vfs_inode);
939}
940
941#endif /* __KERNEL__ */
942
943#endif /* __LINUX_UFS_FS_H */
diff --git a/include/linux/ufs_fs_i.h b/include/linux/ufs_fs_i.h
new file mode 100644
index 000000000000..21665a953978
--- /dev/null
+++ b/include/linux/ufs_fs_i.h
@@ -0,0 +1,33 @@
1/*
2 * linux/include/linux/ufs_fs_i.h
3 *
4 * Copyright (C) 1996
5 * Adrian Rodriguez (adrian@franklins-tower.rutgers.edu)
6 * Laboratory for Computer Science Research Computing Facility
7 * Rutgers, The State University of New Jersey
8 *
9 * NeXTstep support added on February 5th 1998 by
10 * Niels Kristian Bech Jensen <nkbj@image.dk>.
11 */
12
13#ifndef _LINUX_UFS_FS_I_H
14#define _LINUX_UFS_FS_I_H
15
16struct ufs_inode_info {
17 union {
18 __fs32 i_data[15];
19 __u8 i_symlink[4*15];
20 __fs64 u2_i_data[15];
21 } i_u1;
22 __u32 i_flags;
23 __u32 i_gen;
24 __u32 i_shadow;
25 __u32 i_unused1;
26 __u32 i_unused2;
27 __u32 i_oeftflag;
28 __u16 i_osync;
29 __u32 i_lastfrag;
30 struct inode vfs_inode;
31};
32
33#endif /* _LINUX_UFS_FS_I_H */
diff --git a/include/linux/ufs_fs_sb.h b/include/linux/ufs_fs_sb.h
new file mode 100644
index 000000000000..c1be4c226486
--- /dev/null
+++ b/include/linux/ufs_fs_sb.h
@@ -0,0 +1,38 @@
1/*
2 * linux/include/linux/ufs_fs_sb.h
3 *
4 * Copyright (C) 1996
5 * Adrian Rodriguez (adrian@franklins-tower.rutgers.edu)
6 * Laboratory for Computer Science Research Computing Facility
7 * Rutgers, The State University of New Jersey
8 *
9 * $Id: ufs_fs_sb.h,v 1.8 1998/05/06 12:04:40 jj Exp $
10 *
11 * Write support by Daniel Pirkl <daniel.pirkl@email.cz>
12 */
13
14#ifndef __LINUX_UFS_FS_SB_H
15#define __LINUX_UFS_FS_SB_H
16
17
18#define UFS_MAX_GROUP_LOADED 8
19#define UFS_CGNO_EMPTY ((unsigned)-1)
20
21struct ufs_sb_private_info;
22struct ufs_cg_private_info;
23struct ufs_csum;
24#define UFS_MAXCSBUFS 31
25
26struct ufs_sb_info {
27 struct ufs_sb_private_info * s_uspi;
28 struct ufs_csum * s_csp[UFS_MAXCSBUFS];
29 unsigned s_bytesex;
30 unsigned s_flags;
31 struct buffer_head ** s_ucg;
32 struct ufs_cg_private_info * s_ucpi[UFS_MAX_GROUP_LOADED];
33 unsigned s_cgno[UFS_MAX_GROUP_LOADED];
34 unsigned short s_cg_loaded;
35 unsigned s_mount_opt;
36};
37
38#endif
diff --git a/include/linux/uinput.h b/include/linux/uinput.h
new file mode 100644
index 000000000000..4c2c82336d10
--- /dev/null
+++ b/include/linux/uinput.h
@@ -0,0 +1,167 @@
1#ifndef __UINPUT_H_
2#define __UINPUT_H_
3/*
4 * User level driver support for input subsystem
5 *
6 * Heavily based on evdev.c by Vojtech Pavlik
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 * Author: Aristeu Sergio Rozanski Filho <aris@cathedrallabs.org>
23 *
24 * Changes/Revisions:
25 * 0.2 16/10/2004 (Micah Dowty <micah@navi.cx>)
26 * - added force feedback support
27 * - added UI_SET_PHYS
28 * 0.1 20/06/2002
29 * - first public version
30 */
31#ifdef __KERNEL__
32#define UINPUT_MINOR 223
33#define UINPUT_NAME "uinput"
34#define UINPUT_BUFFER_SIZE 16
35#define UINPUT_NUM_REQUESTS 16
36
37/* state flags => bit index for {set|clear|test}_bit ops */
38#define UIST_CREATED 0
39
40struct uinput_request {
41 int id;
42 int code; /* UI_FF_UPLOAD, UI_FF_ERASE */
43
44 int retval;
45 wait_queue_head_t waitq;
46 int completed;
47
48 union {
49 int effect_id;
50 struct ff_effect* effect;
51 } u;
52};
53
54struct uinput_device {
55 struct input_dev *dev;
56 unsigned long state;
57 wait_queue_head_t waitq;
58 unsigned char ready,
59 head,
60 tail;
61 struct input_event buff[UINPUT_BUFFER_SIZE];
62
63 struct uinput_request *requests[UINPUT_NUM_REQUESTS];
64 wait_queue_head_t requests_waitq;
65 struct semaphore requests_sem;
66};
67#endif /* __KERNEL__ */
68
69struct uinput_ff_upload {
70 int request_id;
71 int retval;
72 struct ff_effect effect;
73};
74
75struct uinput_ff_erase {
76 int request_id;
77 int retval;
78 int effect_id;
79};
80
81/* ioctl */
82#define UINPUT_IOCTL_BASE 'U'
83#define UI_DEV_CREATE _IO(UINPUT_IOCTL_BASE, 1)
84#define UI_DEV_DESTROY _IO(UINPUT_IOCTL_BASE, 2)
85
86#define UI_SET_EVBIT _IOW(UINPUT_IOCTL_BASE, 100, int)
87#define UI_SET_KEYBIT _IOW(UINPUT_IOCTL_BASE, 101, int)
88#define UI_SET_RELBIT _IOW(UINPUT_IOCTL_BASE, 102, int)
89#define UI_SET_ABSBIT _IOW(UINPUT_IOCTL_BASE, 103, int)
90#define UI_SET_MSCBIT _IOW(UINPUT_IOCTL_BASE, 104, int)
91#define UI_SET_LEDBIT _IOW(UINPUT_IOCTL_BASE, 105, int)
92#define UI_SET_SNDBIT _IOW(UINPUT_IOCTL_BASE, 106, int)
93#define UI_SET_FFBIT _IOW(UINPUT_IOCTL_BASE, 107, int)
94#define UI_SET_PHYS _IOW(UINPUT_IOCTL_BASE, 108, char*)
95
96#define UI_BEGIN_FF_UPLOAD _IOWR(UINPUT_IOCTL_BASE, 200, struct uinput_ff_upload)
97#define UI_END_FF_UPLOAD _IOW(UINPUT_IOCTL_BASE, 201, struct uinput_ff_upload)
98#define UI_BEGIN_FF_ERASE _IOWR(UINPUT_IOCTL_BASE, 202, struct uinput_ff_erase)
99#define UI_END_FF_ERASE _IOW(UINPUT_IOCTL_BASE, 203, struct uinput_ff_erase)
100
101/* To write a force-feedback-capable driver, the upload_effect
102 * and erase_effect callbacks in input_dev must be implemented.
103 * The uinput driver will generate a fake input event when one of
104 * these callbacks are invoked. The userspace code then uses
105 * ioctls to retrieve additional parameters and send the return code.
106 * The callback blocks until this return code is sent.
107 *
108 * The described callback mechanism is only used if EV_FF is set.
109 * Otherwise, default implementations of upload_effect and erase_effect
110 * are used.
111 *
112 * To implement upload_effect():
113 * 1. Wait for an event with type==EV_UINPUT and code==UI_FF_UPLOAD.
114 * A request ID will be given in 'value'.
115 * 2. Allocate a uinput_ff_upload struct, fill in request_id with
116 * the 'value' from the EV_UINPUT event.
117 * 3. Issue a UI_BEGIN_FF_UPLOAD ioctl, giving it the
118 * uinput_ff_upload struct. It will be filled in with the
119 * ff_effect passed to upload_effect().
120 * 4. Perform the effect upload, and place the modified ff_effect
121 * and a return code back into the uinput_ff_upload struct.
122 * 5. Issue a UI_END_FF_UPLOAD ioctl, also giving it the
123 * uinput_ff_upload_effect struct. This will complete execution
124 * of our upload_effect() handler.
125 *
126 * To implement erase_effect():
127 * 1. Wait for an event with type==EV_UINPUT and code==UI_FF_ERASE.
128 * A request ID will be given in 'value'.
129 * 2. Allocate a uinput_ff_erase struct, fill in request_id with
130 * the 'value' from the EV_UINPUT event.
131 * 3. Issue a UI_BEGIN_FF_ERASE ioctl, giving it the
132 * uinput_ff_erase struct. It will be filled in with the
133 * effect ID passed to erase_effect().
134 * 4. Perform the effect erasure, and place a return code back
135 * into the uinput_ff_erase struct.
136 * and a return code back into the uinput_ff_erase struct.
137 * 5. Issue a UI_END_FF_ERASE ioctl, also giving it the
138 * uinput_ff_erase_effect struct. This will complete execution
139 * of our erase_effect() handler.
140 */
141
142/* This is the new event type, used only by uinput.
143 * 'code' is UI_FF_UPLOAD or UI_FF_ERASE, and 'value'
144 * is the unique request ID. This number was picked
145 * arbitrarily, above EV_MAX (since the input system
146 * never sees it) but in the range of a 16-bit int.
147 */
148#define EV_UINPUT 0x0101
149#define UI_FF_UPLOAD 1
150#define UI_FF_ERASE 2
151
152#ifndef NBITS
153#define NBITS(x) ((((x)-1)/(sizeof(long)*8))+1)
154#endif /* NBITS */
155
156#define UINPUT_MAX_NAME_SIZE 80
157struct uinput_user_dev {
158 char name[UINPUT_MAX_NAME_SIZE];
159 struct input_id id;
160 int ff_effects_max;
161 int absmax[ABS_MAX + 1];
162 int absmin[ABS_MAX + 1];
163 int absfuzz[ABS_MAX + 1];
164 int absflat[ABS_MAX + 1];
165};
166#endif /* __UINPUT_H_ */
167
diff --git a/include/linux/uio.h b/include/linux/uio.h
new file mode 100644
index 000000000000..9af8bbcd8963
--- /dev/null
+++ b/include/linux/uio.h
@@ -0,0 +1,66 @@
1#ifndef __LINUX_UIO_H
2#define __LINUX_UIO_H
3
4#include <linux/compiler.h>
5#include <linux/types.h>
6
7/*
8 * Berkeley style UIO structures - Alan Cox 1994.
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
17/* A word of warning: Our uio structure will clash with the C library one (which is now obsolete). Remove the C
18 library one from sys/uio.h if you have a very old library set */
19
20struct iovec
21{
22 void __user *iov_base; /* BSD uses caddr_t (1003.1g requires void *) */
23 __kernel_size_t iov_len; /* Must be size_t (1003.1g) */
24};
25
26#ifdef __KERNEL__
27
28struct kvec {
29 void *iov_base; /* and that should *never* hold a userland pointer */
30 size_t iov_len;
31};
32
33#endif
34
35/*
36 * UIO_MAXIOV shall be at least 16 1003.1g (5.4.1.1)
37 */
38
39#define UIO_FASTIOV 8
40#define UIO_MAXIOV 1024
41#if 0
42#define UIO_MAXIOV 16 /* Maximum iovec's in one operation
43 16 matches BSD */
44 /* Beg pardon: BSD has 1024 --ANK */
45#endif
46
47/*
48 * Total number of bytes covered by an iovec.
49 *
50 * NOTE that it is not safe to use this function until all the iovec's
51 * segment lengths have been validated. Because the individual lengths can
52 * overflow a size_t when added together.
53 */
54static inline size_t iov_length(const struct iovec *iov, unsigned long nr_segs)
55{
56 unsigned long seg;
57 size_t ret = 0;
58
59 for (seg = 0; seg < nr_segs; seg++)
60 ret += iov[seg].iov_len;
61 return ret;
62}
63
64unsigned long iov_shorten(struct iovec *iov, unsigned long nr_segs, size_t to);
65
66#endif
diff --git a/include/linux/ultrasound.h b/include/linux/ultrasound.h
new file mode 100644
index 000000000000..6b7703e75cec
--- /dev/null
+++ b/include/linux/ultrasound.h
@@ -0,0 +1,103 @@
1#ifndef _ULTRASOUND_H_
2#define _ULTRASOUND_H_
3/*
4 * ultrasound.h - Macros for programming the Gravis Ultrasound
5 * These macros are extremely device dependent
6 * and not portable.
7 */
8/*
9 * Copyright (C) by Hannu Savolainen 1993-1997
10 *
11 * OSS/Free for Linux is distributed under the GNU GENERAL PUBLIC LICENSE (GPL)
12 * Version 2 (June 1991). See the "COPYING" file distributed with this software
13 * for more info.
14 */
15
16
17/*
18 * Private events for Gravis Ultrasound (GUS)
19 *
20 * Format:
21 * byte 0 - SEQ_PRIVATE (0xfe)
22 * byte 1 - Synthesizer device number (0-N)
23 * byte 2 - Command (see below)
24 * byte 3 - Voice number (0-31)
25 * bytes 4 and 5 - parameter P1 (unsigned short)
26 * bytes 6 and 7 - parameter P2 (unsigned short)
27 *
28 * Commands:
29 * Each command affects one voice defined in byte 3.
30 * Unused parameters (P1 and/or P2 *MUST* be initialized to zero).
31 * _GUS_NUMVOICES - Sets max. number of concurrent voices (P1=14-31, default 16)
32 * _GUS_VOICESAMPLE- ************ OBSOLETE *************
33 * _GUS_VOICEON - Starts voice (P1=voice mode)
34 * _GUS_VOICEOFF - Stops voice (no parameters)
35 * _GUS_VOICEFADE - Stops the voice smoothly.
36 * _GUS_VOICEMODE - Alters the voice mode, don't start or stop voice (P1=voice mode)
37 * _GUS_VOICEBALA - Sets voice balence (P1, 0=left, 7=middle and 15=right, default 7)
38 * _GUS_VOICEFREQ - Sets voice (sample) playback frequency (P1=Hz)
39 * _GUS_VOICEVOL - Sets voice volume (P1=volume, 0xfff=max, 0xeff=half, 0x000=off)
40 * _GUS_VOICEVOL2 - Sets voice volume (P1=volume, 0xfff=max, 0xeff=half, 0x000=off)
41 * (Like GUS_VOICEVOL but doesn't change the hw
42 * volume. It just updates volume in the voice table).
43 *
44 * _GUS_RAMPRANGE - Sets limits for volume ramping (P1=low volume, P2=high volume)
45 * _GUS_RAMPRATE - Sets the speed for volume ramping (P1=scale, P2=rate)
46 * _GUS_RAMPMODE - Sets the volume ramping mode (P1=ramping mode)
47 * _GUS_RAMPON - Starts volume ramping (no parameters)
48 * _GUS_RAMPOFF - Stops volume ramping (no parameters)
49 * _GUS_VOLUME_SCALE - Changes the volume calculation constants
50 * for all voices.
51 */
52
53#define _GUS_NUMVOICES 0x00
54#define _GUS_VOICESAMPLE 0x01 /* OBSOLETE */
55#define _GUS_VOICEON 0x02
56#define _GUS_VOICEOFF 0x03
57#define _GUS_VOICEMODE 0x04
58#define _GUS_VOICEBALA 0x05
59#define _GUS_VOICEFREQ 0x06
60#define _GUS_VOICEVOL 0x07
61#define _GUS_RAMPRANGE 0x08
62#define _GUS_RAMPRATE 0x09
63#define _GUS_RAMPMODE 0x0a
64#define _GUS_RAMPON 0x0b
65#define _GUS_RAMPOFF 0x0c
66#define _GUS_VOICEFADE 0x0d
67#define _GUS_VOLUME_SCALE 0x0e
68#define _GUS_VOICEVOL2 0x0f
69#define _GUS_VOICE_POS 0x10
70
71/*
72 * GUS API macros
73 */
74
75#define _GUS_CMD(chn, voice, cmd, p1, p2) \
76 {_SEQ_NEEDBUF(8); _seqbuf[_seqbufptr] = SEQ_PRIVATE;\
77 _seqbuf[_seqbufptr+1] = (chn); _seqbuf[_seqbufptr+2] = cmd;\
78 _seqbuf[_seqbufptr+3] = voice;\
79 *(unsigned short*)&_seqbuf[_seqbufptr+4] = p1;\
80 *(unsigned short*)&_seqbuf[_seqbufptr+6] = p2;\
81 _SEQ_ADVBUF(8);}
82
83#define GUS_NUMVOICES(chn, p1) _GUS_CMD(chn, 0, _GUS_NUMVOICES, (p1), 0)
84#define GUS_VOICESAMPLE(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_VOICESAMPLE, (p1), 0) /* OBSOLETE */
85#define GUS_VOICEON(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_VOICEON, (p1), 0)
86#define GUS_VOICEOFF(chn, voice) _GUS_CMD(chn, voice, _GUS_VOICEOFF, 0, 0)
87#define GUS_VOICEFADE(chn, voice) _GUS_CMD(chn, voice, _GUS_VOICEFADE, 0, 0)
88#define GUS_VOICEMODE(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_VOICEMODE, (p1), 0)
89#define GUS_VOICEBALA(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_VOICEBALA, (p1), 0)
90#define GUS_VOICEFREQ(chn, voice, p) _GUS_CMD(chn, voice, _GUS_VOICEFREQ, \
91 (p) & 0xffff, ((p) >> 16) & 0xffff)
92#define GUS_VOICEVOL(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_VOICEVOL, (p1), 0)
93#define GUS_VOICEVOL2(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_VOICEVOL2, (p1), 0)
94#define GUS_RAMPRANGE(chn, voice, low, high) _GUS_CMD(chn, voice, _GUS_RAMPRANGE, (low), (high))
95#define GUS_RAMPRATE(chn, voice, p1, p2) _GUS_CMD(chn, voice, _GUS_RAMPRATE, (p1), (p2))
96#define GUS_RAMPMODE(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_RAMPMODE, (p1), 0)
97#define GUS_RAMPON(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_RAMPON, (p1), 0)
98#define GUS_RAMPOFF(chn, voice) _GUS_CMD(chn, voice, _GUS_RAMPOFF, 0, 0)
99#define GUS_VOLUME_SCALE(chn, voice, p1, p2) _GUS_CMD(chn, voice, _GUS_VOLUME_SCALE, (p1), (p2))
100#define GUS_VOICE_POS(chn, voice, p) _GUS_CMD(chn, voice, _GUS_VOICE_POS, \
101 (p) & 0xffff, ((p) >> 16) & 0xffff)
102
103#endif
diff --git a/include/linux/umem.h b/include/linux/umem.h
new file mode 100644
index 000000000000..f36ebfc32bf6
--- /dev/null
+++ b/include/linux/umem.h
@@ -0,0 +1,138 @@
1
2/*
3 * This file contains defines for the
4 * Micro Memory MM5415
5 * family PCI Memory Module with Battery Backup.
6 *
7 * Copyright Micro Memory INC 2001. All rights reserved.
8 * Release under the terms of the GNU GENERAL PUBLIC LICENSE version 2.
9 * See the file COPYING.
10 */
11
12#ifndef _DRIVERS_BLOCK_MM_H
13#define _DRIVERS_BLOCK_MM_H
14
15
16#define IRQ_TIMEOUT (1 * HZ)
17
18/* CSR register definition */
19#define MEMCTRLSTATUS_MAGIC 0x00
20#define MM_MAGIC_VALUE (unsigned char)0x59
21
22#define MEMCTRLSTATUS_BATTERY 0x04
23#define BATTERY_1_DISABLED 0x01
24#define BATTERY_1_FAILURE 0x02
25#define BATTERY_2_DISABLED 0x04
26#define BATTERY_2_FAILURE 0x08
27
28#define MEMCTRLSTATUS_MEMORY 0x07
29#define MEM_128_MB 0xfe
30#define MEM_256_MB 0xfc
31#define MEM_512_MB 0xf8
32#define MEM_1_GB 0xf0
33#define MEM_2_GB 0xe0
34
35#define MEMCTRLCMD_LEDCTRL 0x08
36#define LED_REMOVE 2
37#define LED_FAULT 4
38#define LED_POWER 6
39#define LED_FLIP 255
40#define LED_OFF 0x00
41#define LED_ON 0x01
42#define LED_FLASH_3_5 0x02
43#define LED_FLASH_7_0 0x03
44#define LED_POWER_ON 0x00
45#define LED_POWER_OFF 0x01
46#define USER_BIT1 0x01
47#define USER_BIT2 0x02
48
49#define MEMORY_INITIALIZED USER_BIT1
50
51#define MEMCTRLCMD_ERRCTRL 0x0C
52#define EDC_NONE_DEFAULT 0x00
53#define EDC_NONE 0x01
54#define EDC_STORE_READ 0x02
55#define EDC_STORE_CORRECT 0x03
56
57#define MEMCTRLCMD_ERRCNT 0x0D
58#define MEMCTRLCMD_ERRSTATUS 0x0E
59
60#define ERROR_DATA_LOG 0x20
61#define ERROR_ADDR_LOG 0x28
62#define ERROR_COUNT 0x3D
63#define ERROR_SYNDROME 0x3E
64#define ERROR_CHECK 0x3F
65
66#define DMA_PCI_ADDR 0x40
67#define DMA_LOCAL_ADDR 0x48
68#define DMA_TRANSFER_SIZE 0x50
69#define DMA_DESCRIPTOR_ADDR 0x58
70#define DMA_SEMAPHORE_ADDR 0x60
71#define DMA_STATUS_CTRL 0x68
72#define DMASCR_GO 0x00001
73#define DMASCR_TRANSFER_READ 0x00002
74#define DMASCR_CHAIN_EN 0x00004
75#define DMASCR_SEM_EN 0x00010
76#define DMASCR_DMA_COMP_EN 0x00020
77#define DMASCR_CHAIN_COMP_EN 0x00040
78#define DMASCR_ERR_INT_EN 0x00080
79#define DMASCR_PARITY_INT_EN 0x00100
80#define DMASCR_ANY_ERR 0x00800
81#define DMASCR_MBE_ERR 0x01000
82#define DMASCR_PARITY_ERR_REP 0x02000
83#define DMASCR_PARITY_ERR_DET 0x04000
84#define DMASCR_SYSTEM_ERR_SIG 0x08000
85#define DMASCR_TARGET_ABT 0x10000
86#define DMASCR_MASTER_ABT 0x20000
87#define DMASCR_DMA_COMPLETE 0x40000
88#define DMASCR_CHAIN_COMPLETE 0x80000
89
90/*
913.SOME PCs HAVE HOST BRIDGES WHICH APPARENTLY DO NOT CORRECTLY HANDLE
92READ-LINE (0xE) OR READ-MULTIPLE (0xC) PCI COMMAND CODES DURING DMA
93TRANSFERS. IN OTHER SYSTEMS THESE COMMAND CODES WILL CAUSE THE HOST BRIDGE
94TO ALLOW LONGER BURSTS DURING DMA READ OPERATIONS. THE UPPER FOUR BITS
95(31..28) OF THE DMA CSR HAVE BEEN MADE PROGRAMMABLE, SO THAT EITHER A 0x6,
96AN 0xE OR A 0xC CAN BE WRITTEN TO THEM TO SET THE COMMAND CODE USED DURING
97DMA READ OPERATIONS.
98*/
99#define DMASCR_READ 0x60000000
100#define DMASCR_READLINE 0xE0000000
101#define DMASCR_READMULTI 0xC0000000
102
103
104#define DMASCR_ERROR_MASK (DMASCR_MASTER_ABT | DMASCR_TARGET_ABT | DMASCR_SYSTEM_ERR_SIG | DMASCR_PARITY_ERR_DET | DMASCR_MBE_ERR | DMASCR_ANY_ERR)
105#define DMASCR_HARD_ERROR (DMASCR_MASTER_ABT | DMASCR_TARGET_ABT | DMASCR_SYSTEM_ERR_SIG | DMASCR_PARITY_ERR_DET | DMASCR_MBE_ERR)
106
107#define WINDOWMAP_WINNUM 0x7B
108
109#define DMA_READ_FROM_HOST 0
110#define DMA_WRITE_TO_HOST 1
111
112struct mm_dma_desc {
113 __le64 pci_addr;
114 __le64 local_addr;
115 __le32 transfer_size;
116 u32 zero1;
117 __le64 next_desc_addr;
118 __le64 sem_addr;
119 __le32 control_bits;
120 u32 zero2;
121
122 dma_addr_t data_dma_handle;
123
124 /* Copy of the bits */
125 __le64 sem_control_bits;
126} __attribute__((aligned(8)));
127
128#define PCI_VENDOR_ID_MICRO_MEMORY 0x1332
129#define PCI_DEVICE_ID_MICRO_MEMORY_5415CN 0x5415
130#define PCI_DEVICE_ID_MICRO_MEMORY_5425CN 0x5425
131#define PCI_DEVICE_ID_MICRO_MEMORY_6155 0x6155
132
133/* bits for card->flags */
134#define UM_FLAG_DMA_IN_REGS 1
135#define UM_FLAG_NO_BYTE_STATUS 2
136#define UM_FLAG_NO_BATTREG 4
137#define UM_FLAG_NO_BATT 8
138#endif
diff --git a/include/linux/un.h b/include/linux/un.h
new file mode 100644
index 000000000000..45561c564b8e
--- /dev/null
+++ b/include/linux/un.h
@@ -0,0 +1,11 @@
1#ifndef _LINUX_UN_H
2#define _LINUX_UN_H
3
4#define UNIX_PATH_MAX 108
5
6struct sockaddr_un {
7 sa_family_t sun_family; /* AF_UNIX */
8 char sun_path[UNIX_PATH_MAX]; /* pathname */
9};
10
11#endif /* _LINUX_UN_H */
diff --git a/include/linux/unistd.h b/include/linux/unistd.h
new file mode 100644
index 000000000000..10ed9834b822
--- /dev/null
+++ b/include/linux/unistd.h
@@ -0,0 +1,11 @@
1#ifndef _LINUX_UNISTD_H_
2#define _LINUX_UNISTD_H_
3
4extern int errno;
5
6/*
7 * Include machine specific syscallX macros
8 */
9#include <asm/unistd.h>
10
11#endif /* _LINUX_UNISTD_H_ */
diff --git a/include/linux/usb.h b/include/linux/usb.h
new file mode 100644
index 000000000000..c96728435935
--- /dev/null
+++ b/include/linux/usb.h
@@ -0,0 +1,1157 @@
1#ifndef __LINUX_USB_H
2#define __LINUX_USB_H
3
4#include <linux/mod_devicetable.h>
5#include <linux/usb_ch9.h>
6
7#define USB_MAJOR 180
8
9
10#ifdef __KERNEL__
11
12#include <linux/config.h>
13#include <linux/errno.h> /* for -ENODEV */
14#include <linux/delay.h> /* for mdelay() */
15#include <linux/interrupt.h> /* for in_interrupt() */
16#include <linux/list.h> /* for struct list_head */
17#include <linux/kref.h> /* for struct kref */
18#include <linux/device.h> /* for struct device */
19#include <linux/fs.h> /* for struct file_operations */
20#include <linux/completion.h> /* for struct completion */
21#include <linux/sched.h> /* for current && schedule_timeout */
22
23struct usb_device;
24struct usb_driver;
25
26/*-------------------------------------------------------------------------*/
27
28/*
29 * Host-side wrappers for standard USB descriptors ... these are parsed
30 * from the data provided by devices. Parsing turns them from a flat
31 * sequence of descriptors into a hierarchy:
32 *
33 * - devices have one (usually) or more configs;
34 * - configs have one (often) or more interfaces;
35 * - interfaces have one (usually) or more settings;
36 * - each interface setting has zero or (usually) more endpoints.
37 *
38 * And there might be other descriptors mixed in with those.
39 *
40 * Devices may also have class-specific or vendor-specific descriptors.
41 */
42
43/**
44 * struct usb_host_endpoint - host-side endpoint descriptor and queue
45 * @desc: descriptor for this endpoint, wMaxPacketSize in native byteorder
46 * @urb_list: urbs queued to this endpoint; maintained by usbcore
47 * @hcpriv: for use by HCD; typically holds hardware dma queue head (QH)
48 * with one or more transfer descriptors (TDs) per urb
49 * @extra: descriptors following this endpoint in the configuration
50 * @extralen: how many bytes of "extra" are valid
51 *
52 * USB requests are always queued to a given endpoint, identified by a
53 * descriptor within an active interface in a given USB configuration.
54 */
55struct usb_host_endpoint {
56 struct usb_endpoint_descriptor desc;
57 struct list_head urb_list;
58 void *hcpriv;
59
60 unsigned char *extra; /* Extra descriptors */
61 int extralen;
62};
63
64/* host-side wrapper for one interface setting's parsed descriptors */
65struct usb_host_interface {
66 struct usb_interface_descriptor desc;
67
68 /* array of desc.bNumEndpoint endpoints associated with this
69 * interface setting. these will be in no particular order.
70 */
71 struct usb_host_endpoint *endpoint;
72
73 char *string; /* iInterface string, if present */
74 unsigned char *extra; /* Extra descriptors */
75 int extralen;
76};
77
78enum usb_interface_condition {
79 USB_INTERFACE_UNBOUND = 0,
80 USB_INTERFACE_BINDING,
81 USB_INTERFACE_BOUND,
82 USB_INTERFACE_UNBINDING,
83};
84
85/**
86 * struct usb_interface - what usb device drivers talk to
87 * @altsetting: array of interface structures, one for each alternate
88 * setting that may be selected. Each one includes a set of
89 * endpoint configurations. They will be in no particular order.
90 * @num_altsetting: number of altsettings defined.
91 * @cur_altsetting: the current altsetting.
92 * @driver: the USB driver that is bound to this interface.
93 * @minor: the minor number assigned to this interface, if this
94 * interface is bound to a driver that uses the USB major number.
95 * If this interface does not use the USB major, this field should
96 * be unused. The driver should set this value in the probe()
97 * function of the driver, after it has been assigned a minor
98 * number from the USB core by calling usb_register_dev().
99 * @condition: binding state of the interface: not bound, binding
100 * (in probe()), bound to a driver, or unbinding (in disconnect())
101 * @dev: driver model's view of this device
102 * @class_dev: driver model's class view of this device.
103 *
104 * USB device drivers attach to interfaces on a physical device. Each
105 * interface encapsulates a single high level function, such as feeding
106 * an audio stream to a speaker or reporting a change in a volume control.
107 * Many USB devices only have one interface. The protocol used to talk to
108 * an interface's endpoints can be defined in a usb "class" specification,
109 * or by a product's vendor. The (default) control endpoint is part of
110 * every interface, but is never listed among the interface's descriptors.
111 *
112 * The driver that is bound to the interface can use standard driver model
113 * calls such as dev_get_drvdata() on the dev member of this structure.
114 *
115 * Each interface may have alternate settings. The initial configuration
116 * of a device sets altsetting 0, but the device driver can change
117 * that setting using usb_set_interface(). Alternate settings are often
118 * used to control the the use of periodic endpoints, such as by having
119 * different endpoints use different amounts of reserved USB bandwidth.
120 * All standards-conformant USB devices that use isochronous endpoints
121 * will use them in non-default settings.
122 *
123 * The USB specification says that alternate setting numbers must run from
124 * 0 to one less than the total number of alternate settings. But some
125 * devices manage to mess this up, and the structures aren't necessarily
126 * stored in numerical order anyhow. Use usb_altnum_to_altsetting() to
127 * look up an alternate setting in the altsetting array based on its number.
128 */
129struct usb_interface {
130 /* array of alternate settings for this interface,
131 * stored in no particular order */
132 struct usb_host_interface *altsetting;
133
134 struct usb_host_interface *cur_altsetting; /* the currently
135 * active alternate setting */
136 unsigned num_altsetting; /* number of alternate settings */
137
138 int minor; /* minor number this interface is bound to */
139 enum usb_interface_condition condition; /* state of binding */
140 struct device dev; /* interface specific device info */
141 struct class_device *class_dev;
142};
143#define to_usb_interface(d) container_of(d, struct usb_interface, dev)
144#define interface_to_usbdev(intf) \
145 container_of(intf->dev.parent, struct usb_device, dev)
146
147static inline void *usb_get_intfdata (struct usb_interface *intf)
148{
149 return dev_get_drvdata (&intf->dev);
150}
151
152static inline void usb_set_intfdata (struct usb_interface *intf, void *data)
153{
154 dev_set_drvdata(&intf->dev, data);
155}
156
157struct usb_interface *usb_get_intf(struct usb_interface *intf);
158void usb_put_intf(struct usb_interface *intf);
159
160/* this maximum is arbitrary */
161#define USB_MAXINTERFACES 32
162
163/**
164 * struct usb_interface_cache - long-term representation of a device interface
165 * @num_altsetting: number of altsettings defined.
166 * @ref: reference counter.
167 * @altsetting: variable-length array of interface structures, one for
168 * each alternate setting that may be selected. Each one includes a
169 * set of endpoint configurations. They will be in no particular order.
170 *
171 * These structures persist for the lifetime of a usb_device, unlike
172 * struct usb_interface (which persists only as long as its configuration
173 * is installed). The altsetting arrays can be accessed through these
174 * structures at any time, permitting comparison of configurations and
175 * providing support for the /proc/bus/usb/devices pseudo-file.
176 */
177struct usb_interface_cache {
178 unsigned num_altsetting; /* number of alternate settings */
179 struct kref ref; /* reference counter */
180
181 /* variable-length array of alternate settings for this interface,
182 * stored in no particular order */
183 struct usb_host_interface altsetting[0];
184};
185#define ref_to_usb_interface_cache(r) \
186 container_of(r, struct usb_interface_cache, ref)
187#define altsetting_to_usb_interface_cache(a) \
188 container_of(a, struct usb_interface_cache, altsetting[0])
189
190/**
191 * struct usb_host_config - representation of a device's configuration
192 * @desc: the device's configuration descriptor.
193 * @string: pointer to the cached version of the iConfiguration string, if
194 * present for this configuration.
195 * @interface: array of pointers to usb_interface structures, one for each
196 * interface in the configuration. The number of interfaces is stored
197 * in desc.bNumInterfaces. These pointers are valid only while the
198 * the configuration is active.
199 * @intf_cache: array of pointers to usb_interface_cache structures, one
200 * for each interface in the configuration. These structures exist
201 * for the entire life of the device.
202 * @extra: pointer to buffer containing all extra descriptors associated
203 * with this configuration (those preceding the first interface
204 * descriptor).
205 * @extralen: length of the extra descriptors buffer.
206 *
207 * USB devices may have multiple configurations, but only one can be active
208 * at any time. Each encapsulates a different operational environment;
209 * for example, a dual-speed device would have separate configurations for
210 * full-speed and high-speed operation. The number of configurations
211 * available is stored in the device descriptor as bNumConfigurations.
212 *
213 * A configuration can contain multiple interfaces. Each corresponds to
214 * a different function of the USB device, and all are available whenever
215 * the configuration is active. The USB standard says that interfaces
216 * are supposed to be numbered from 0 to desc.bNumInterfaces-1, but a lot
217 * of devices get this wrong. In addition, the interface array is not
218 * guaranteed to be sorted in numerical order. Use usb_ifnum_to_if() to
219 * look up an interface entry based on its number.
220 *
221 * Device drivers should not attempt to activate configurations. The choice
222 * of which configuration to install is a policy decision based on such
223 * considerations as available power, functionality provided, and the user's
224 * desires (expressed through hotplug scripts). However, drivers can call
225 * usb_reset_configuration() to reinitialize the current configuration and
226 * all its interfaces.
227 */
228struct usb_host_config {
229 struct usb_config_descriptor desc;
230
231 char *string;
232 /* the interfaces associated with this configuration,
233 * stored in no particular order */
234 struct usb_interface *interface[USB_MAXINTERFACES];
235
236 /* Interface information available even when this is not the
237 * active configuration */
238 struct usb_interface_cache *intf_cache[USB_MAXINTERFACES];
239
240 unsigned char *extra; /* Extra descriptors */
241 int extralen;
242};
243
244int __usb_get_extra_descriptor(char *buffer, unsigned size,
245 unsigned char type, void **ptr);
246#define usb_get_extra_descriptor(ifpoint,type,ptr)\
247 __usb_get_extra_descriptor((ifpoint)->extra,(ifpoint)->extralen,\
248 type,(void**)ptr)
249
250/* -------------------------------------------------------------------------- */
251
252struct usb_operations;
253
254/* USB device number allocation bitmap */
255struct usb_devmap {
256 unsigned long devicemap[128 / (8*sizeof(unsigned long))];
257};
258
259/*
260 * Allocated per bus (tree of devices) we have:
261 */
262struct usb_bus {
263 struct device *controller; /* host/master side hardware */
264 int busnum; /* Bus number (in order of reg) */
265 char *bus_name; /* stable id (PCI slot_name etc) */
266 u8 otg_port; /* 0, or number of OTG/HNP port */
267 unsigned is_b_host:1; /* true during some HNP roleswitches */
268 unsigned b_hnp_enable:1; /* OTG: did A-Host enable HNP? */
269
270 int devnum_next; /* Next open device number in round-robin allocation */
271
272 struct usb_devmap devmap; /* device address allocation map */
273 struct usb_operations *op; /* Operations (specific to the HC) */
274 struct usb_device *root_hub; /* Root hub */
275 struct list_head bus_list; /* list of busses */
276 void *hcpriv; /* Host Controller private data */
277
278 int bandwidth_allocated; /* on this bus: how much of the time
279 * reserved for periodic (intr/iso)
280 * requests is used, on average?
281 * Units: microseconds/frame.
282 * Limits: Full/low speed reserve 90%,
283 * while high speed reserves 80%.
284 */
285 int bandwidth_int_reqs; /* number of Interrupt requests */
286 int bandwidth_isoc_reqs; /* number of Isoc. requests */
287
288 struct dentry *usbfs_dentry; /* usbfs dentry entry for the bus */
289
290 struct class_device class_dev; /* class device for this bus */
291 void (*release)(struct usb_bus *bus); /* function to destroy this bus's memory */
292#if defined(CONFIG_USB_MON) || defined(CONFIG_USB_MON_MODULE)
293 struct mon_bus *mon_bus; /* non-null when associated */
294 int monitored; /* non-zero when monitored */
295#endif
296};
297#define to_usb_bus(d) container_of(d, struct usb_bus, class_dev)
298
299
300/* -------------------------------------------------------------------------- */
301
302/* This is arbitrary.
303 * From USB 2.0 spec Table 11-13, offset 7, a hub can
304 * have up to 255 ports. The most yet reported is 10.
305 */
306#define USB_MAXCHILDREN (16)
307
308struct usb_tt;
309
310/*
311 * struct usb_device - kernel's representation of a USB device
312 *
313 * FIXME: Write the kerneldoc!
314 *
315 * Usbcore drivers should not set usbdev->state directly. Instead use
316 * usb_set_device_state().
317 */
318struct usb_device {
319 int devnum; /* Address on USB bus */
320 char devpath [16]; /* Use in messages: /port/port/... */
321 enum usb_device_state state; /* configured, not attached, etc */
322 enum usb_device_speed speed; /* high/full/low (or error) */
323
324 struct usb_tt *tt; /* low/full speed dev, highspeed hub */
325 int ttport; /* device port on that tt hub */
326
327 struct semaphore serialize;
328
329 unsigned int toggle[2]; /* one bit for each endpoint ([0] = IN, [1] = OUT) */
330
331 struct usb_device *parent; /* our hub, unless we're the root */
332 struct usb_bus *bus; /* Bus we're part of */
333 struct usb_host_endpoint ep0;
334
335 struct device dev; /* Generic device interface */
336
337 struct usb_device_descriptor descriptor;/* Descriptor */
338 struct usb_host_config *config; /* All of the configs */
339
340 struct usb_host_config *actconfig;/* the active configuration */
341 struct usb_host_endpoint *ep_in[16];
342 struct usb_host_endpoint *ep_out[16];
343
344 char **rawdescriptors; /* Raw descriptors for each config */
345
346 int have_langid; /* whether string_langid is valid yet */
347 int string_langid; /* language ID for strings */
348
349 char *product;
350 char *manufacturer;
351 char *serial; /* static strings from the device */
352 struct list_head filelist;
353 struct dentry *usbfs_dentry; /* usbfs dentry entry for the device */
354
355 /*
356 * Child devices - these can be either new devices
357 * (if this is a hub device), or different instances
358 * of this same device.
359 *
360 * Each instance needs its own set of data structures.
361 */
362
363 int maxchild; /* Number of ports if hub */
364 struct usb_device *children[USB_MAXCHILDREN];
365};
366#define to_usb_device(d) container_of(d, struct usb_device, dev)
367
368extern struct usb_device *usb_get_dev(struct usb_device *dev);
369extern void usb_put_dev(struct usb_device *dev);
370
371extern void usb_lock_device(struct usb_device *udev);
372extern int usb_trylock_device(struct usb_device *udev);
373extern int usb_lock_device_for_reset(struct usb_device *udev,
374 struct usb_interface *iface);
375extern void usb_unlock_device(struct usb_device *udev);
376
377/* USB port reset for device reinitialization */
378extern int usb_reset_device(struct usb_device *dev);
379
380extern struct usb_device *usb_find_device(u16 vendor_id, u16 product_id);
381
382/*-------------------------------------------------------------------------*/
383
384/* for drivers using iso endpoints */
385extern int usb_get_current_frame_number (struct usb_device *usb_dev);
386
387/* used these for multi-interface device registration */
388extern int usb_driver_claim_interface(struct usb_driver *driver,
389 struct usb_interface *iface, void* priv);
390
391/**
392 * usb_interface_claimed - returns true iff an interface is claimed
393 * @iface: the interface being checked
394 *
395 * Returns true (nonzero) iff the interface is claimed, else false (zero).
396 * Callers must own the driver model's usb bus readlock. So driver
397 * probe() entries don't need extra locking, but other call contexts
398 * may need to explicitly claim that lock.
399 *
400 */
401static inline int usb_interface_claimed(struct usb_interface *iface) {
402 return (iface->dev.driver != NULL);
403}
404
405extern void usb_driver_release_interface(struct usb_driver *driver,
406 struct usb_interface *iface);
407const struct usb_device_id *usb_match_id(struct usb_interface *interface,
408 const struct usb_device_id *id);
409
410extern struct usb_interface *usb_find_interface(struct usb_driver *drv,
411 int minor);
412extern struct usb_interface *usb_ifnum_to_if(struct usb_device *dev,
413 unsigned ifnum);
414extern struct usb_host_interface *usb_altnum_to_altsetting(
415 struct usb_interface *intf, unsigned int altnum);
416
417
418/**
419 * usb_make_path - returns stable device path in the usb tree
420 * @dev: the device whose path is being constructed
421 * @buf: where to put the string
422 * @size: how big is "buf"?
423 *
424 * Returns length of the string (> 0) or negative if size was too small.
425 *
426 * This identifier is intended to be "stable", reflecting physical paths in
427 * hardware such as physical bus addresses for host controllers or ports on
428 * USB hubs. That makes it stay the same until systems are physically
429 * reconfigured, by re-cabling a tree of USB devices or by moving USB host
430 * controllers. Adding and removing devices, including virtual root hubs
431 * in host controller driver modules, does not change these path identifers;
432 * neither does rebooting or re-enumerating. These are more useful identifiers
433 * than changeable ("unstable") ones like bus numbers or device addresses.
434 *
435 * With a partial exception for devices connected to USB 2.0 root hubs, these
436 * identifiers are also predictable. So long as the device tree isn't changed,
437 * plugging any USB device into a given hub port always gives it the same path.
438 * Because of the use of "companion" controllers, devices connected to ports on
439 * USB 2.0 root hubs (EHCI host controllers) will get one path ID if they are
440 * high speed, and a different one if they are full or low speed.
441 */
442static inline int usb_make_path (struct usb_device *dev, char *buf, size_t size)
443{
444 int actual;
445 actual = snprintf (buf, size, "usb-%s-%s", dev->bus->bus_name, dev->devpath);
446 return (actual >= (int)size) ? -1 : actual;
447}
448
449/*-------------------------------------------------------------------------*/
450
451#define USB_DEVICE_ID_MATCH_DEVICE (USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT)
452#define USB_DEVICE_ID_MATCH_DEV_RANGE (USB_DEVICE_ID_MATCH_DEV_LO | USB_DEVICE_ID_MATCH_DEV_HI)
453#define USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION (USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_DEV_RANGE)
454#define USB_DEVICE_ID_MATCH_DEV_INFO \
455 (USB_DEVICE_ID_MATCH_DEV_CLASS | USB_DEVICE_ID_MATCH_DEV_SUBCLASS | USB_DEVICE_ID_MATCH_DEV_PROTOCOL)
456#define USB_DEVICE_ID_MATCH_INT_INFO \
457 (USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS | USB_DEVICE_ID_MATCH_INT_PROTOCOL)
458
459/**
460 * USB_DEVICE - macro used to describe a specific usb device
461 * @vend: the 16 bit USB Vendor ID
462 * @prod: the 16 bit USB Product ID
463 *
464 * This macro is used to create a struct usb_device_id that matches a
465 * specific device.
466 */
467#define USB_DEVICE(vend,prod) \
468 .match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = (vend), .idProduct = (prod)
469/**
470 * USB_DEVICE_VER - macro used to describe a specific usb device with a version range
471 * @vend: the 16 bit USB Vendor ID
472 * @prod: the 16 bit USB Product ID
473 * @lo: the bcdDevice_lo value
474 * @hi: the bcdDevice_hi value
475 *
476 * This macro is used to create a struct usb_device_id that matches a
477 * specific device, with a version range.
478 */
479#define USB_DEVICE_VER(vend,prod,lo,hi) \
480 .match_flags = USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION, .idVendor = (vend), .idProduct = (prod), .bcdDevice_lo = (lo), .bcdDevice_hi = (hi)
481
482/**
483 * USB_DEVICE_INFO - macro used to describe a class of usb devices
484 * @cl: bDeviceClass value
485 * @sc: bDeviceSubClass value
486 * @pr: bDeviceProtocol value
487 *
488 * This macro is used to create a struct usb_device_id that matches a
489 * specific class of devices.
490 */
491#define USB_DEVICE_INFO(cl,sc,pr) \
492 .match_flags = USB_DEVICE_ID_MATCH_DEV_INFO, .bDeviceClass = (cl), .bDeviceSubClass = (sc), .bDeviceProtocol = (pr)
493
494/**
495 * USB_INTERFACE_INFO - macro used to describe a class of usb interfaces
496 * @cl: bInterfaceClass value
497 * @sc: bInterfaceSubClass value
498 * @pr: bInterfaceProtocol value
499 *
500 * This macro is used to create a struct usb_device_id that matches a
501 * specific class of interfaces.
502 */
503#define USB_INTERFACE_INFO(cl,sc,pr) \
504 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO, .bInterfaceClass = (cl), .bInterfaceSubClass = (sc), .bInterfaceProtocol = (pr)
505
506/* -------------------------------------------------------------------------- */
507
508/**
509 * struct usb_driver - identifies USB driver to usbcore
510 * @owner: Pointer to the module owner of this driver; initialize
511 * it using THIS_MODULE.
512 * @name: The driver name should be unique among USB drivers,
513 * and should normally be the same as the module name.
514 * @probe: Called to see if the driver is willing to manage a particular
515 * interface on a device. If it is, probe returns zero and uses
516 * dev_set_drvdata() to associate driver-specific data with the
517 * interface. It may also use usb_set_interface() to specify the
518 * appropriate altsetting. If unwilling to manage the interface,
519 * return a negative errno value.
520 * @disconnect: Called when the interface is no longer accessible, usually
521 * because its device has been (or is being) disconnected or the
522 * driver module is being unloaded.
523 * @ioctl: Used for drivers that want to talk to userspace through
524 * the "usbfs" filesystem. This lets devices provide ways to
525 * expose information to user space regardless of where they
526 * do (or don't) show up otherwise in the filesystem.
527 * @suspend: Called when the device is going to be suspended by the system.
528 * @resume: Called when the device is being resumed by the system.
529 * @id_table: USB drivers use ID table to support hotplugging.
530 * Export this with MODULE_DEVICE_TABLE(usb,...). This must be set
531 * or your driver's probe function will never get called.
532 * @driver: the driver model core driver structure.
533 *
534 * USB drivers must provide a name, probe() and disconnect() methods,
535 * and an id_table. Other driver fields are optional.
536 *
537 * The id_table is used in hotplugging. It holds a set of descriptors,
538 * and specialized data may be associated with each entry. That table
539 * is used by both user and kernel mode hotplugging support.
540 *
541 * The probe() and disconnect() methods are called in a context where
542 * they can sleep, but they should avoid abusing the privilege. Most
543 * work to connect to a device should be done when the device is opened,
544 * and undone at the last close. The disconnect code needs to address
545 * concurrency issues with respect to open() and close() methods, as
546 * well as forcing all pending I/O requests to complete (by unlinking
547 * them as necessary, and blocking until the unlinks complete).
548 */
549struct usb_driver {
550 struct module *owner;
551
552 const char *name;
553
554 int (*probe) (struct usb_interface *intf,
555 const struct usb_device_id *id);
556
557 void (*disconnect) (struct usb_interface *intf);
558
559 int (*ioctl) (struct usb_interface *intf, unsigned int code, void *buf);
560
561 int (*suspend) (struct usb_interface *intf, u32 state);
562 int (*resume) (struct usb_interface *intf);
563
564 const struct usb_device_id *id_table;
565
566 struct device_driver driver;
567};
568#define to_usb_driver(d) container_of(d, struct usb_driver, driver)
569
570extern struct bus_type usb_bus_type;
571
572/**
573 * struct usb_class_driver - identifies a USB driver that wants to use the USB major number
574 * @name: devfs name for this driver. Will also be used by the driver
575 * class code to create a usb class device.
576 * @fops: pointer to the struct file_operations of this driver.
577 * @mode: the mode for the devfs file to be created for this driver.
578 * @minor_base: the start of the minor range for this driver.
579 *
580 * This structure is used for the usb_register_dev() and
581 * usb_unregister_dev() functions, to consolidate a number of the
582 * parameters used for them.
583 */
584struct usb_class_driver {
585 char *name;
586 struct file_operations *fops;
587 mode_t mode;
588 int minor_base;
589};
590
591/*
592 * use these in module_init()/module_exit()
593 * and don't forget MODULE_DEVICE_TABLE(usb, ...)
594 */
595extern int usb_register(struct usb_driver *);
596extern void usb_deregister(struct usb_driver *);
597
598extern int usb_register_dev(struct usb_interface *intf,
599 struct usb_class_driver *class_driver);
600extern void usb_deregister_dev(struct usb_interface *intf,
601 struct usb_class_driver *class_driver);
602
603extern int usb_disabled(void);
604
605/* -------------------------------------------------------------------------- */
606
607/*
608 * URB support, for asynchronous request completions
609 */
610
611/*
612 * urb->transfer_flags:
613 */
614#define URB_SHORT_NOT_OK 0x0001 /* report short reads as errors */
615#define URB_ISO_ASAP 0x0002 /* iso-only, urb->start_frame ignored */
616#define URB_NO_TRANSFER_DMA_MAP 0x0004 /* urb->transfer_dma valid on submit */
617#define URB_NO_SETUP_DMA_MAP 0x0008 /* urb->setup_dma valid on submit */
618#define URB_ASYNC_UNLINK 0x0010 /* usb_unlink_urb() returns asap */
619#define URB_NO_FSBR 0x0020 /* UHCI-specific */
620#define URB_ZERO_PACKET 0x0040 /* Finish bulk OUTs with short packet */
621#define URB_NO_INTERRUPT 0x0080 /* HINT: no non-error interrupt needed */
622
623struct usb_iso_packet_descriptor {
624 unsigned int offset;
625 unsigned int length; /* expected length */
626 unsigned int actual_length;
627 unsigned int status;
628};
629
630struct urb;
631struct pt_regs;
632
633typedef void (*usb_complete_t)(struct urb *, struct pt_regs *);
634
635/**
636 * struct urb - USB Request Block
637 * @urb_list: For use by current owner of the URB.
638 * @pipe: Holds endpoint number, direction, type, and more.
639 * Create these values with the eight macros available;
640 * usb_{snd,rcv}TYPEpipe(dev,endpoint), where the TYPE is "ctrl"
641 * (control), "bulk", "int" (interrupt), or "iso" (isochronous).
642 * For example usb_sndbulkpipe() or usb_rcvintpipe(). Endpoint
643 * numbers range from zero to fifteen. Note that "in" endpoint two
644 * is a different endpoint (and pipe) from "out" endpoint two.
645 * The current configuration controls the existence, type, and
646 * maximum packet size of any given endpoint.
647 * @dev: Identifies the USB device to perform the request.
648 * @status: This is read in non-iso completion functions to get the
649 * status of the particular request. ISO requests only use it
650 * to tell whether the URB was unlinked; detailed status for
651 * each frame is in the fields of the iso_frame-desc.
652 * @transfer_flags: A variety of flags may be used to affect how URB
653 * submission, unlinking, or operation are handled. Different
654 * kinds of URB can use different flags.
655 * @transfer_buffer: This identifies the buffer to (or from) which
656 * the I/O request will be performed (unless URB_NO_TRANSFER_DMA_MAP
657 * is set). This buffer must be suitable for DMA; allocate it with
658 * kmalloc() or equivalent. For transfers to "in" endpoints, contents
659 * of this buffer will be modified. This buffer is used for the data
660 * stage of control transfers.
661 * @transfer_dma: When transfer_flags includes URB_NO_TRANSFER_DMA_MAP,
662 * the device driver is saying that it provided this DMA address,
663 * which the host controller driver should use in preference to the
664 * transfer_buffer.
665 * @transfer_buffer_length: How big is transfer_buffer. The transfer may
666 * be broken up into chunks according to the current maximum packet
667 * size for the endpoint, which is a function of the configuration
668 * and is encoded in the pipe. When the length is zero, neither
669 * transfer_buffer nor transfer_dma is used.
670 * @actual_length: This is read in non-iso completion functions, and
671 * it tells how many bytes (out of transfer_buffer_length) were
672 * transferred. It will normally be the same as requested, unless
673 * either an error was reported or a short read was performed.
674 * The URB_SHORT_NOT_OK transfer flag may be used to make such
675 * short reads be reported as errors.
676 * @setup_packet: Only used for control transfers, this points to eight bytes
677 * of setup data. Control transfers always start by sending this data
678 * to the device. Then transfer_buffer is read or written, if needed.
679 * @setup_dma: For control transfers with URB_NO_SETUP_DMA_MAP set, the
680 * device driver has provided this DMA address for the setup packet.
681 * The host controller driver should use this in preference to
682 * setup_packet.
683 * @start_frame: Returns the initial frame for isochronous transfers.
684 * @number_of_packets: Lists the number of ISO transfer buffers.
685 * @interval: Specifies the polling interval for interrupt or isochronous
686 * transfers. The units are frames (milliseconds) for for full and low
687 * speed devices, and microframes (1/8 millisecond) for highspeed ones.
688 * @error_count: Returns the number of ISO transfers that reported errors.
689 * @context: For use in completion functions. This normally points to
690 * request-specific driver context.
691 * @complete: Completion handler. This URB is passed as the parameter to the
692 * completion function. The completion function may then do what
693 * it likes with the URB, including resubmitting or freeing it.
694 * @iso_frame_desc: Used to provide arrays of ISO transfer buffers and to
695 * collect the transfer status for each buffer.
696 *
697 * This structure identifies USB transfer requests. URBs must be allocated by
698 * calling usb_alloc_urb() and freed with a call to usb_free_urb().
699 * Initialization may be done using various usb_fill_*_urb() functions. URBs
700 * are submitted using usb_submit_urb(), and pending requests may be canceled
701 * using usb_unlink_urb() or usb_kill_urb().
702 *
703 * Data Transfer Buffers:
704 *
705 * Normally drivers provide I/O buffers allocated with kmalloc() or otherwise
706 * taken from the general page pool. That is provided by transfer_buffer
707 * (control requests also use setup_packet), and host controller drivers
708 * perform a dma mapping (and unmapping) for each buffer transferred. Those
709 * mapping operations can be expensive on some platforms (perhaps using a dma
710 * bounce buffer or talking to an IOMMU),
711 * although they're cheap on commodity x86 and ppc hardware.
712 *
713 * Alternatively, drivers may pass the URB_NO_xxx_DMA_MAP transfer flags,
714 * which tell the host controller driver that no such mapping is needed since
715 * the device driver is DMA-aware. For example, a device driver might
716 * allocate a DMA buffer with usb_buffer_alloc() or call usb_buffer_map().
717 * When these transfer flags are provided, host controller drivers will
718 * attempt to use the dma addresses found in the transfer_dma and/or
719 * setup_dma fields rather than determining a dma address themselves. (Note
720 * that transfer_buffer and setup_packet must still be set because not all
721 * host controllers use DMA, nor do virtual root hubs).
722 *
723 * Initialization:
724 *
725 * All URBs submitted must initialize the dev, pipe, transfer_flags (may be
726 * zero), and complete fields.
727 * The URB_ASYNC_UNLINK transfer flag affects later invocations of
728 * the usb_unlink_urb() routine. Note: Failure to set URB_ASYNC_UNLINK
729 * with usb_unlink_urb() is deprecated. For synchronous unlinks use
730 * usb_kill_urb() instead.
731 *
732 * All URBs must also initialize
733 * transfer_buffer and transfer_buffer_length. They may provide the
734 * URB_SHORT_NOT_OK transfer flag, indicating that short reads are
735 * to be treated as errors; that flag is invalid for write requests.
736 *
737 * Bulk URBs may
738 * use the URB_ZERO_PACKET transfer flag, indicating that bulk OUT transfers
739 * should always terminate with a short packet, even if it means adding an
740 * extra zero length packet.
741 *
742 * Control URBs must provide a setup_packet. The setup_packet and
743 * transfer_buffer may each be mapped for DMA or not, independently of
744 * the other. The transfer_flags bits URB_NO_TRANSFER_DMA_MAP and
745 * URB_NO_SETUP_DMA_MAP indicate which buffers have already been mapped.
746 * URB_NO_SETUP_DMA_MAP is ignored for non-control URBs.
747 *
748 * Interrupt URBs must provide an interval, saying how often (in milliseconds
749 * or, for highspeed devices, 125 microsecond units)
750 * to poll for transfers. After the URB has been submitted, the interval
751 * field reflects how the transfer was actually scheduled.
752 * The polling interval may be more frequent than requested.
753 * For example, some controllers have a maximum interval of 32 milliseconds,
754 * while others support intervals of up to 1024 milliseconds.
755 * Isochronous URBs also have transfer intervals. (Note that for isochronous
756 * endpoints, as well as high speed interrupt endpoints, the encoding of
757 * the transfer interval in the endpoint descriptor is logarithmic.
758 * Device drivers must convert that value to linear units themselves.)
759 *
760 * Isochronous URBs normally use the URB_ISO_ASAP transfer flag, telling
761 * the host controller to schedule the transfer as soon as bandwidth
762 * utilization allows, and then set start_frame to reflect the actual frame
763 * selected during submission. Otherwise drivers must specify the start_frame
764 * and handle the case where the transfer can't begin then. However, drivers
765 * won't know how bandwidth is currently allocated, and while they can
766 * find the current frame using usb_get_current_frame_number () they can't
767 * know the range for that frame number. (Ranges for frame counter values
768 * are HC-specific, and can go from 256 to 65536 frames from "now".)
769 *
770 * Isochronous URBs have a different data transfer model, in part because
771 * the quality of service is only "best effort". Callers provide specially
772 * allocated URBs, with number_of_packets worth of iso_frame_desc structures
773 * at the end. Each such packet is an individual ISO transfer. Isochronous
774 * URBs are normally queued, submitted by drivers to arrange that
775 * transfers are at least double buffered, and then explicitly resubmitted
776 * in completion handlers, so
777 * that data (such as audio or video) streams at as constant a rate as the
778 * host controller scheduler can support.
779 *
780 * Completion Callbacks:
781 *
782 * The completion callback is made in_interrupt(), and one of the first
783 * things that a completion handler should do is check the status field.
784 * The status field is provided for all URBs. It is used to report
785 * unlinked URBs, and status for all non-ISO transfers. It should not
786 * be examined before the URB is returned to the completion handler.
787 *
788 * The context field is normally used to link URBs back to the relevant
789 * driver or request state.
790 *
791 * When the completion callback is invoked for non-isochronous URBs, the
792 * actual_length field tells how many bytes were transferred. This field
793 * is updated even when the URB terminated with an error or was unlinked.
794 *
795 * ISO transfer status is reported in the status and actual_length fields
796 * of the iso_frame_desc array, and the number of errors is reported in
797 * error_count. Completion callbacks for ISO transfers will normally
798 * (re)submit URBs to ensure a constant transfer rate.
799 */
800struct urb
801{
802 /* private, usb core and host controller only fields in the urb */
803 struct kref kref; /* reference count of the URB */
804 spinlock_t lock; /* lock for the URB */
805 void *hcpriv; /* private data for host controller */
806 struct list_head urb_list; /* list pointer to all active urbs */
807 int bandwidth; /* bandwidth for INT/ISO request */
808 atomic_t use_count; /* concurrent submissions counter */
809 u8 reject; /* submissions will fail */
810
811 /* public, documented fields in the urb that can be used by drivers */
812 struct usb_device *dev; /* (in) pointer to associated device */
813 unsigned int pipe; /* (in) pipe information */
814 int status; /* (return) non-ISO status */
815 unsigned int transfer_flags; /* (in) URB_SHORT_NOT_OK | ...*/
816 void *transfer_buffer; /* (in) associated data buffer */
817 dma_addr_t transfer_dma; /* (in) dma addr for transfer_buffer */
818 int transfer_buffer_length; /* (in) data buffer length */
819 int actual_length; /* (return) actual transfer length */
820 unsigned char *setup_packet; /* (in) setup packet (control only) */
821 dma_addr_t setup_dma; /* (in) dma addr for setup_packet */
822 int start_frame; /* (modify) start frame (ISO) */
823 int number_of_packets; /* (in) number of ISO packets */
824 int interval; /* (modify) transfer interval (INT/ISO) */
825 int error_count; /* (return) number of ISO errors */
826 void *context; /* (in) context for completion */
827 usb_complete_t complete; /* (in) completion routine */
828 struct usb_iso_packet_descriptor iso_frame_desc[0]; /* (in) ISO ONLY */
829};
830
831/* -------------------------------------------------------------------------- */
832
833/**
834 * usb_fill_control_urb - initializes a control urb
835 * @urb: pointer to the urb to initialize.
836 * @dev: pointer to the struct usb_device for this urb.
837 * @pipe: the endpoint pipe
838 * @setup_packet: pointer to the setup_packet buffer
839 * @transfer_buffer: pointer to the transfer buffer
840 * @buffer_length: length of the transfer buffer
841 * @complete: pointer to the usb_complete_t function
842 * @context: what to set the urb context to.
843 *
844 * Initializes a control urb with the proper information needed to submit
845 * it to a device.
846 */
847static inline void usb_fill_control_urb (struct urb *urb,
848 struct usb_device *dev,
849 unsigned int pipe,
850 unsigned char *setup_packet,
851 void *transfer_buffer,
852 int buffer_length,
853 usb_complete_t complete,
854 void *context)
855{
856 spin_lock_init(&urb->lock);
857 urb->dev = dev;
858 urb->pipe = pipe;
859 urb->setup_packet = setup_packet;
860 urb->transfer_buffer = transfer_buffer;
861 urb->transfer_buffer_length = buffer_length;
862 urb->complete = complete;
863 urb->context = context;
864}
865
866/**
867 * usb_fill_bulk_urb - macro to help initialize a bulk urb
868 * @urb: pointer to the urb to initialize.
869 * @dev: pointer to the struct usb_device for this urb.
870 * @pipe: the endpoint pipe
871 * @transfer_buffer: pointer to the transfer buffer
872 * @buffer_length: length of the transfer buffer
873 * @complete: pointer to the usb_complete_t function
874 * @context: what to set the urb context to.
875 *
876 * Initializes a bulk urb with the proper information needed to submit it
877 * to a device.
878 */
879static inline void usb_fill_bulk_urb (struct urb *urb,
880 struct usb_device *dev,
881 unsigned int pipe,
882 void *transfer_buffer,
883 int buffer_length,
884 usb_complete_t complete,
885 void *context)
886{
887 spin_lock_init(&urb->lock);
888 urb->dev = dev;
889 urb->pipe = pipe;
890 urb->transfer_buffer = transfer_buffer;
891 urb->transfer_buffer_length = buffer_length;
892 urb->complete = complete;
893 urb->context = context;
894}
895
896/**
897 * usb_fill_int_urb - macro to help initialize a interrupt urb
898 * @urb: pointer to the urb to initialize.
899 * @dev: pointer to the struct usb_device for this urb.
900 * @pipe: the endpoint pipe
901 * @transfer_buffer: pointer to the transfer buffer
902 * @buffer_length: length of the transfer buffer
903 * @complete: pointer to the usb_complete_t function
904 * @context: what to set the urb context to.
905 * @interval: what to set the urb interval to, encoded like
906 * the endpoint descriptor's bInterval value.
907 *
908 * Initializes a interrupt urb with the proper information needed to submit
909 * it to a device.
910 * Note that high speed interrupt endpoints use a logarithmic encoding of
911 * the endpoint interval, and express polling intervals in microframes
912 * (eight per millisecond) rather than in frames (one per millisecond).
913 */
914static inline void usb_fill_int_urb (struct urb *urb,
915 struct usb_device *dev,
916 unsigned int pipe,
917 void *transfer_buffer,
918 int buffer_length,
919 usb_complete_t complete,
920 void *context,
921 int interval)
922{
923 spin_lock_init(&urb->lock);
924 urb->dev = dev;
925 urb->pipe = pipe;
926 urb->transfer_buffer = transfer_buffer;
927 urb->transfer_buffer_length = buffer_length;
928 urb->complete = complete;
929 urb->context = context;
930 if (dev->speed == USB_SPEED_HIGH)
931 urb->interval = 1 << (interval - 1);
932 else
933 urb->interval = interval;
934 urb->start_frame = -1;
935}
936
937extern void usb_init_urb(struct urb *urb);
938extern struct urb *usb_alloc_urb(int iso_packets, int mem_flags);
939extern void usb_free_urb(struct urb *urb);
940#define usb_put_urb usb_free_urb
941extern struct urb *usb_get_urb(struct urb *urb);
942extern int usb_submit_urb(struct urb *urb, int mem_flags);
943extern int usb_unlink_urb(struct urb *urb);
944extern void usb_kill_urb(struct urb *urb);
945
946#define HAVE_USB_BUFFERS
947void *usb_buffer_alloc (struct usb_device *dev, size_t size,
948 int mem_flags, dma_addr_t *dma);
949void usb_buffer_free (struct usb_device *dev, size_t size,
950 void *addr, dma_addr_t dma);
951
952#if 0
953struct urb *usb_buffer_map (struct urb *urb);
954void usb_buffer_dmasync (struct urb *urb);
955void usb_buffer_unmap (struct urb *urb);
956#endif
957
958struct scatterlist;
959int usb_buffer_map_sg (struct usb_device *dev, unsigned pipe,
960 struct scatterlist *sg, int nents);
961#if 0
962void usb_buffer_dmasync_sg (struct usb_device *dev, unsigned pipe,
963 struct scatterlist *sg, int n_hw_ents);
964#endif
965void usb_buffer_unmap_sg (struct usb_device *dev, unsigned pipe,
966 struct scatterlist *sg, int n_hw_ents);
967
968/*-------------------------------------------------------------------*
969 * SYNCHRONOUS CALL SUPPORT *
970 *-------------------------------------------------------------------*/
971
972extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
973 __u8 request, __u8 requesttype, __u16 value, __u16 index,
974 void *data, __u16 size, int timeout);
975extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
976 void *data, int len, int *actual_length,
977 int timeout);
978
979/* selective suspend/resume */
980extern int usb_suspend_device(struct usb_device *dev, u32 state);
981extern int usb_resume_device(struct usb_device *dev);
982
983
984/* wrappers around usb_control_msg() for the most common standard requests */
985extern int usb_get_descriptor(struct usb_device *dev, unsigned char desctype,
986 unsigned char descindex, void *buf, int size);
987extern int usb_get_status(struct usb_device *dev,
988 int type, int target, void *data);
989extern int usb_get_string(struct usb_device *dev,
990 unsigned short langid, unsigned char index, void *buf, int size);
991extern int usb_string(struct usb_device *dev, int index,
992 char *buf, size_t size);
993
994/* wrappers that also update important state inside usbcore */
995extern int usb_clear_halt(struct usb_device *dev, int pipe);
996extern int usb_reset_configuration(struct usb_device *dev);
997extern int usb_set_interface(struct usb_device *dev, int ifnum, int alternate);
998
999/*
1000 * timeouts, in milliseconds, used for sending/receiving control messages
1001 * they typically complete within a few frames (msec) after they're issued
1002 * USB identifies 5 second timeouts, maybe more in a few cases, and a few
1003 * slow devices (like some MGE Ellipse UPSes) actually push that limit.
1004 */
1005#define USB_CTRL_GET_TIMEOUT 5000
1006#define USB_CTRL_SET_TIMEOUT 5000
1007
1008
1009/**
1010 * struct usb_sg_request - support for scatter/gather I/O
1011 * @status: zero indicates success, else negative errno
1012 * @bytes: counts bytes transferred.
1013 *
1014 * These requests are initialized using usb_sg_init(), and then are used
1015 * as request handles passed to usb_sg_wait() or usb_sg_cancel(). Most
1016 * members of the request object aren't for driver access.
1017 *
1018 * The status and bytecount values are valid only after usb_sg_wait()
1019 * returns. If the status is zero, then the bytecount matches the total
1020 * from the request.
1021 *
1022 * After an error completion, drivers may need to clear a halt condition
1023 * on the endpoint.
1024 */
1025struct usb_sg_request {
1026 int status;
1027 size_t bytes;
1028
1029 /*
1030 * members below are private to usbcore,
1031 * and are not provided for driver access!
1032 */
1033 spinlock_t lock;
1034
1035 struct usb_device *dev;
1036 int pipe;
1037 struct scatterlist *sg;
1038 int nents;
1039
1040 int entries;
1041 struct urb **urbs;
1042
1043 int count;
1044 struct completion complete;
1045};
1046
1047int usb_sg_init (
1048 struct usb_sg_request *io,
1049 struct usb_device *dev,
1050 unsigned pipe,
1051 unsigned period,
1052 struct scatterlist *sg,
1053 int nents,
1054 size_t length,
1055 int mem_flags
1056);
1057void usb_sg_cancel (struct usb_sg_request *io);
1058void usb_sg_wait (struct usb_sg_request *io);
1059
1060
1061/* -------------------------------------------------------------------------- */
1062
1063/*
1064 * For various legacy reasons, Linux has a small cookie that's paired with
1065 * a struct usb_device to identify an endpoint queue. Queue characteristics
1066 * are defined by the endpoint's descriptor. This cookie is called a "pipe",
1067 * an unsigned int encoded as:
1068 *
1069 * - direction: bit 7 (0 = Host-to-Device [Out],
1070 * 1 = Device-to-Host [In] ...
1071 * like endpoint bEndpointAddress)
1072 * - device address: bits 8-14 ... bit positions known to uhci-hcd
1073 * - endpoint: bits 15-18 ... bit positions known to uhci-hcd
1074 * - pipe type: bits 30-31 (00 = isochronous, 01 = interrupt,
1075 * 10 = control, 11 = bulk)
1076 *
1077 * Given the device address and endpoint descriptor, pipes are redundant.
1078 */
1079
1080/* NOTE: these are not the standard USB_ENDPOINT_XFER_* values!! */
1081/* (yet ... they're the values used by usbfs) */
1082#define PIPE_ISOCHRONOUS 0
1083#define PIPE_INTERRUPT 1
1084#define PIPE_CONTROL 2
1085#define PIPE_BULK 3
1086
1087#define usb_pipein(pipe) ((pipe) & USB_DIR_IN)
1088#define usb_pipeout(pipe) (!usb_pipein(pipe))
1089
1090#define usb_pipedevice(pipe) (((pipe) >> 8) & 0x7f)
1091#define usb_pipeendpoint(pipe) (((pipe) >> 15) & 0xf)
1092
1093#define usb_pipetype(pipe) (((pipe) >> 30) & 3)
1094#define usb_pipeisoc(pipe) (usb_pipetype((pipe)) == PIPE_ISOCHRONOUS)
1095#define usb_pipeint(pipe) (usb_pipetype((pipe)) == PIPE_INTERRUPT)
1096#define usb_pipecontrol(pipe) (usb_pipetype((pipe)) == PIPE_CONTROL)
1097#define usb_pipebulk(pipe) (usb_pipetype((pipe)) == PIPE_BULK)
1098
1099/* The D0/D1 toggle bits ... USE WITH CAUTION (they're almost hcd-internal) */
1100#define usb_gettoggle(dev, ep, out) (((dev)->toggle[out] >> (ep)) & 1)
1101#define usb_dotoggle(dev, ep, out) ((dev)->toggle[out] ^= (1 << (ep)))
1102#define usb_settoggle(dev, ep, out, bit) ((dev)->toggle[out] = ((dev)->toggle[out] & ~(1 << (ep))) | ((bit) << (ep)))
1103
1104
1105static inline unsigned int __create_pipe(struct usb_device *dev, unsigned int endpoint)
1106{
1107 return (dev->devnum << 8) | (endpoint << 15);
1108}
1109
1110/* Create various pipes... */
1111#define usb_sndctrlpipe(dev,endpoint) ((PIPE_CONTROL << 30) | __create_pipe(dev,endpoint))
1112#define usb_rcvctrlpipe(dev,endpoint) ((PIPE_CONTROL << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN)
1113#define usb_sndisocpipe(dev,endpoint) ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev,endpoint))
1114#define usb_rcvisocpipe(dev,endpoint) ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN)
1115#define usb_sndbulkpipe(dev,endpoint) ((PIPE_BULK << 30) | __create_pipe(dev,endpoint))
1116#define usb_rcvbulkpipe(dev,endpoint) ((PIPE_BULK << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN)
1117#define usb_sndintpipe(dev,endpoint) ((PIPE_INTERRUPT << 30) | __create_pipe(dev,endpoint))
1118#define usb_rcvintpipe(dev,endpoint) ((PIPE_INTERRUPT << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN)
1119
1120/*-------------------------------------------------------------------------*/
1121
1122static inline __u16
1123usb_maxpacket(struct usb_device *udev, int pipe, int is_out)
1124{
1125 struct usb_host_endpoint *ep;
1126 unsigned epnum = usb_pipeendpoint(pipe);
1127
1128 if (is_out) {
1129 WARN_ON(usb_pipein(pipe));
1130 ep = udev->ep_out[epnum];
1131 } else {
1132 WARN_ON(usb_pipeout(pipe));
1133 ep = udev->ep_in[epnum];
1134 }
1135 if (!ep)
1136 return 0;
1137
1138 /* NOTE: only 0x07ff bits are for packet size... */
1139 return le16_to_cpu(ep->desc.wMaxPacketSize);
1140}
1141
1142/* -------------------------------------------------------------------------- */
1143
1144#ifdef DEBUG
1145#define dbg(format, arg...) printk(KERN_DEBUG "%s: " format "\n" , __FILE__ , ## arg)
1146#else
1147#define dbg(format, arg...) do {} while (0)
1148#endif
1149
1150#define err(format, arg...) printk(KERN_ERR "%s: " format "\n" , __FILE__ , ## arg)
1151#define info(format, arg...) printk(KERN_INFO "%s: " format "\n" , __FILE__ , ## arg)
1152#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n" , __FILE__ , ## arg)
1153
1154
1155#endif /* __KERNEL__ */
1156
1157#endif
diff --git a/include/linux/usb_cdc.h b/include/linux/usb_cdc.h
new file mode 100644
index 000000000000..1b68c122279a
--- /dev/null
+++ b/include/linux/usb_cdc.h
@@ -0,0 +1,192 @@
1/*
2 * USB Communications Device Class (CDC) definitions
3 *
4 * CDC says how to talk to lots of different types of network adapters,
5 * notably ethernet adapters and various modems. It's used mostly with
6 * firmware based USB peripherals.
7 */
8
9#define USB_CDC_SUBCLASS_ACM 0x02
10#define USB_CDC_SUBCLASS_ETHERNET 0x06
11#define USB_CDC_SUBCLASS_WHCM 0x08
12#define USB_CDC_SUBCLASS_DMM 0x09
13#define USB_CDC_SUBCLASS_MDLM 0x0a
14#define USB_CDC_SUBCLASS_OBEX 0x0b
15
16#define USB_CDC_PROTO_NONE 0
17
18#define USB_CDC_ACM_PROTO_AT_V25TER 1
19#define USB_CDC_ACM_PROTO_AT_PCCA101 2
20#define USB_CDC_ACM_PROTO_AT_PCCA101_WAKE 3
21#define USB_CDC_ACM_PROTO_AT_GSM 4
22#define USB_CDC_ACM_PROTO_AT_3G 5
23#define USB_CDC_ACM_PROTO_AT_CDMA 6
24#define USB_CDC_ACM_PROTO_VENDOR 0xff
25
26/*-------------------------------------------------------------------------*/
27
28/*
29 * Class-Specific descriptors ... there are a couple dozen of them
30 */
31
32#define USB_CDC_HEADER_TYPE 0x00 /* header_desc */
33#define USB_CDC_CALL_MANAGEMENT_TYPE 0x01 /* call_mgmt_descriptor */
34#define USB_CDC_ACM_TYPE 0x02 /* acm_descriptor */
35#define USB_CDC_UNION_TYPE 0x06 /* union_desc */
36#define USB_CDC_COUNTRY_TYPE 0x07
37#define USB_CDC_ETHERNET_TYPE 0x0f /* ether_desc */
38#define USB_CDC_WHCM_TYPE 0x11
39#define USB_CDC_MDLM_TYPE 0x12 /* mdlm_desc */
40#define USB_CDC_MDLM_DETAIL_TYPE 0x13 /* mdlm_detail_desc */
41#define USB_CDC_DMM_TYPE 0x14
42#define USB_CDC_OBEX_TYPE 0x15
43
44/* "Header Functional Descriptor" from CDC spec 5.2.3.1 */
45struct usb_cdc_header_desc {
46 __u8 bLength;
47 __u8 bDescriptorType;
48 __u8 bDescriptorSubType;
49
50 __le16 bcdCDC;
51} __attribute__ ((packed));
52
53/* "Call Management Descriptor" from CDC spec 5.2.3.2 */
54struct usb_cdc_call_mgmt_descriptor {
55 __u8 bLength;
56 __u8 bDescriptorType;
57 __u8 bDescriptorSubType;
58
59 __u8 bmCapabilities;
60#define USB_CDC_CALL_MGMT_CAP_CALL_MGMT 0x01
61#define USB_CDC_CALL_MGMT_CAP_DATA_INTF 0x02
62
63 __u8 bDataInterface;
64} __attribute__ ((packed));
65
66/* "Abstract Control Management Descriptor" from CDC spec 5.2.3.3 */
67struct usb_cdc_acm_descriptor {
68 __u8 bLength;
69 __u8 bDescriptorType;
70 __u8 bDescriptorSubType;
71
72 __u8 bmCapabilities;
73} __attribute__ ((packed));
74
75/* "Union Functional Descriptor" from CDC spec 5.2.3.8 */
76struct usb_cdc_union_desc {
77 __u8 bLength;
78 __u8 bDescriptorType;
79 __u8 bDescriptorSubType;
80
81 __u8 bMasterInterface0;
82 __u8 bSlaveInterface0;
83 /* ... and there could be other slave interfaces */
84} __attribute__ ((packed));
85
86/* "Ethernet Networking Functional Descriptor" from CDC spec 5.2.3.16 */
87struct usb_cdc_ether_desc {
88 __u8 bLength;
89 __u8 bDescriptorType;
90 __u8 bDescriptorSubType;
91
92 __u8 iMACAddress;
93 __le32 bmEthernetStatistics;
94 __le16 wMaxSegmentSize;
95 __le16 wNumberMCFilters;
96 __u8 bNumberPowerFilters;
97} __attribute__ ((packed));
98
99/* "MDLM Functional Descriptor" from CDC WMC spec 6.7.2.3 */
100struct usb_cdc_mdlm_desc {
101 __u8 bLength;
102 __u8 bDescriptorType;
103 __u8 bDescriptorSubType;
104
105 __le16 bcdVersion;
106 __u8 bGUID[16];
107} __attribute__ ((packed));
108
109/* "MDLM Detail Functional Descriptor" from CDC WMC spec 6.7.2.4 */
110struct usb_cdc_mdlm_detail_desc {
111 __u8 bLength;
112 __u8 bDescriptorType;
113 __u8 bDescriptorSubType;
114
115 /* type is associated with mdlm_desc.bGUID */
116 __u8 bGuidDescriptorType;
117 __u8 bDetailData[];
118} __attribute__ ((packed));
119
120/*-------------------------------------------------------------------------*/
121
122/*
123 * Class-Specific Control Requests (6.2)
124 *
125 * section 3.6.2.1 table 4 has the ACM profile, for modems.
126 * section 3.8.2 table 10 has the ethernet profile.
127 *
128 * Microsoft's RNDIS stack for Ethernet is a vendor-specific CDC ACM variant,
129 * heavily dependent on the encapsulated (proprietary) command mechanism.
130 */
131
132#define USB_CDC_SEND_ENCAPSULATED_COMMAND 0x00
133#define USB_CDC_GET_ENCAPSULATED_RESPONSE 0x01
134#define USB_CDC_REQ_SET_LINE_CODING 0x20
135#define USB_CDC_REQ_GET_LINE_CODING 0x21
136#define USB_CDC_REQ_SET_CONTROL_LINE_STATE 0x22
137#define USB_CDC_REQ_SEND_BREAK 0x23
138#define USB_CDC_SET_ETHERNET_MULTICAST_FILTERS 0x40
139#define USB_CDC_SET_ETHERNET_PM_PATTERN_FILTER 0x41
140#define USB_CDC_GET_ETHERNET_PM_PATTERN_FILTER 0x42
141#define USB_CDC_SET_ETHERNET_PACKET_FILTER 0x43
142#define USB_CDC_GET_ETHERNET_STATISTIC 0x44
143
144/* Line Coding Structure from CDC spec 6.2.13 */
145struct usb_cdc_line_coding {
146 __le32 dwDTERate;
147 __u8 bCharFormat;
148#define USB_CDC_1_STOP_BITS 0
149#define USB_CDC_1_5_STOP_BITS 1
150#define USB_CDC_2_STOP_BITS 2
151
152 __u8 bParityType;
153#define USB_CDC_NO_PARITY 0
154#define USB_CDC_ODD_PARITY 1
155#define USB_CDC_EVEN_PARITY 2
156#define USB_CDC_MARK_PARITY 3
157#define USB_CDC_SPACE_PARITY 4
158
159 __u8 bDataBits;
160} __attribute__ ((packed));
161
162/* table 62; bits in multicast filter */
163#define USB_CDC_PACKET_TYPE_PROMISCUOUS (1 << 0)
164#define USB_CDC_PACKET_TYPE_ALL_MULTICAST (1 << 1) /* no filter */
165#define USB_CDC_PACKET_TYPE_DIRECTED (1 << 2)
166#define USB_CDC_PACKET_TYPE_BROADCAST (1 << 3)
167#define USB_CDC_PACKET_TYPE_MULTICAST (1 << 4) /* filtered */
168
169
170/*-------------------------------------------------------------------------*/
171
172/*
173 * Class-Specific Notifications (6.3) sent by interrupt transfers
174 *
175 * section 3.8.2 table 11 of the CDC spec lists Ethernet notifications
176 * section 3.6.2.1 table 5 specifies ACM notifications, accepted by RNDIS
177 * RNDIS also defines its own bit-incompatible notifications
178 */
179
180#define USB_CDC_NOTIFY_NETWORK_CONNECTION 0x00
181#define USB_CDC_NOTIFY_RESPONSE_AVAILABLE 0x01
182#define USB_CDC_NOTIFY_SERIAL_STATE 0x20
183#define USB_CDC_NOTIFY_SPEED_CHANGE 0x2a
184
185struct usb_cdc_notification {
186 __u8 bmRequestType;
187 __u8 bNotificationType;
188 __le16 wValue;
189 __le16 wIndex;
190 __le16 wLength;
191} __attribute__ ((packed));
192
diff --git a/include/linux/usb_ch9.h b/include/linux/usb_ch9.h
new file mode 100644
index 000000000000..f5fe94e09a03
--- /dev/null
+++ b/include/linux/usb_ch9.h
@@ -0,0 +1,384 @@
1/*
2 * This file holds USB constants and structures that are needed for USB
3 * device APIs. These are used by the USB device model, which is defined
4 * in chapter 9 of the USB 2.0 specification. Linux has several APIs in C
5 * that need these:
6 *
7 * - the master/host side Linux-USB kernel driver API;
8 * - the "usbfs" user space API; and
9 * - (eventually) a Linux "gadget" slave/device side driver API.
10 *
11 * USB 2.0 adds an additional "On The Go" (OTG) mode, which lets systems
12 * act either as a USB master/host or as a USB slave/device. That means
13 * the master and slave side APIs will benefit from working well together.
14 */
15
16#ifndef __LINUX_USB_CH9_H
17#define __LINUX_USB_CH9_H
18
19#include <asm/types.h> /* __u8 etc */
20
21/*-------------------------------------------------------------------------*/
22
23/* CONTROL REQUEST SUPPORT */
24
25/*
26 * USB directions
27 *
28 * This bit flag is used in endpoint descriptors' bEndpointAddress field.
29 * It's also one of three fields in control requests bRequestType.
30 */
31#define USB_DIR_OUT 0 /* to device */
32#define USB_DIR_IN 0x80 /* to host */
33
34/*
35 * USB types, the second of three bRequestType fields
36 */
37#define USB_TYPE_MASK (0x03 << 5)
38#define USB_TYPE_STANDARD (0x00 << 5)
39#define USB_TYPE_CLASS (0x01 << 5)
40#define USB_TYPE_VENDOR (0x02 << 5)
41#define USB_TYPE_RESERVED (0x03 << 5)
42
43/*
44 * USB recipients, the third of three bRequestType fields
45 */
46#define USB_RECIP_MASK 0x1f
47#define USB_RECIP_DEVICE 0x00
48#define USB_RECIP_INTERFACE 0x01
49#define USB_RECIP_ENDPOINT 0x02
50#define USB_RECIP_OTHER 0x03
51
52/*
53 * Standard requests, for the bRequest field of a SETUP packet.
54 *
55 * These are qualified by the bRequestType field, so that for example
56 * TYPE_CLASS or TYPE_VENDOR specific feature flags could be retrieved
57 * by a GET_STATUS request.
58 */
59#define USB_REQ_GET_STATUS 0x00
60#define USB_REQ_CLEAR_FEATURE 0x01
61#define USB_REQ_SET_FEATURE 0x03
62#define USB_REQ_SET_ADDRESS 0x05
63#define USB_REQ_GET_DESCRIPTOR 0x06
64#define USB_REQ_SET_DESCRIPTOR 0x07
65#define USB_REQ_GET_CONFIGURATION 0x08
66#define USB_REQ_SET_CONFIGURATION 0x09
67#define USB_REQ_GET_INTERFACE 0x0A
68#define USB_REQ_SET_INTERFACE 0x0B
69#define USB_REQ_SYNCH_FRAME 0x0C
70
71/*
72 * USB feature flags are written using USB_REQ_{CLEAR,SET}_FEATURE, and
73 * are read as a bit array returned by USB_REQ_GET_STATUS. (So there
74 * are at most sixteen features of each type.)
75 */
76#define USB_DEVICE_SELF_POWERED 0 /* (read only) */
77#define USB_DEVICE_REMOTE_WAKEUP 1 /* dev may initiate wakeup */
78#define USB_DEVICE_TEST_MODE 2 /* (high speed only) */
79#define USB_DEVICE_B_HNP_ENABLE 3 /* dev may initiate HNP */
80#define USB_DEVICE_A_HNP_SUPPORT 4 /* RH port supports HNP */
81#define USB_DEVICE_A_ALT_HNP_SUPPORT 5 /* other RH port does */
82#define USB_DEVICE_DEBUG_MODE 6 /* (special devices only) */
83
84#define USB_ENDPOINT_HALT 0 /* IN/OUT will STALL */
85
86
87/**
88 * struct usb_ctrlrequest - SETUP data for a USB device control request
89 * @bRequestType: matches the USB bmRequestType field
90 * @bRequest: matches the USB bRequest field
91 * @wValue: matches the USB wValue field (le16 byte order)
92 * @wIndex: matches the USB wIndex field (le16 byte order)
93 * @wLength: matches the USB wLength field (le16 byte order)
94 *
95 * This structure is used to send control requests to a USB device. It matches
96 * the different fields of the USB 2.0 Spec section 9.3, table 9-2. See the
97 * USB spec for a fuller description of the different fields, and what they are
98 * used for.
99 *
100 * Note that the driver for any interface can issue control requests.
101 * For most devices, interfaces don't coordinate with each other, so
102 * such requests may be made at any time.
103 */
104struct usb_ctrlrequest {
105 __u8 bRequestType;
106 __u8 bRequest;
107 __le16 wValue;
108 __le16 wIndex;
109 __le16 wLength;
110} __attribute__ ((packed));
111
112/*-------------------------------------------------------------------------*/
113
114/*
115 * STANDARD DESCRIPTORS ... as returned by GET_DESCRIPTOR, or
116 * (rarely) accepted by SET_DESCRIPTOR.
117 *
118 * Note that all multi-byte values here are encoded in little endian
119 * byte order "on the wire". But when exposed through Linux-USB APIs,
120 * they've been converted to cpu byte order.
121 */
122
123/*
124 * Descriptor types ... USB 2.0 spec table 9.5
125 */
126#define USB_DT_DEVICE 0x01
127#define USB_DT_CONFIG 0x02
128#define USB_DT_STRING 0x03
129#define USB_DT_INTERFACE 0x04
130#define USB_DT_ENDPOINT 0x05
131#define USB_DT_DEVICE_QUALIFIER 0x06
132#define USB_DT_OTHER_SPEED_CONFIG 0x07
133#define USB_DT_INTERFACE_POWER 0x08
134/* these are from a minor usb 2.0 revision (ECN) */
135#define USB_DT_OTG 0x09
136#define USB_DT_DEBUG 0x0a
137#define USB_DT_INTERFACE_ASSOCIATION 0x0b
138
139/* conventional codes for class-specific descriptors */
140#define USB_DT_CS_DEVICE 0x21
141#define USB_DT_CS_CONFIG 0x22
142#define USB_DT_CS_STRING 0x23
143#define USB_DT_CS_INTERFACE 0x24
144#define USB_DT_CS_ENDPOINT 0x25
145
146/* All standard descriptors have these 2 fields at the beginning */
147struct usb_descriptor_header {
148 __u8 bLength;
149 __u8 bDescriptorType;
150} __attribute__ ((packed));
151
152
153/*-------------------------------------------------------------------------*/
154
155/* USB_DT_DEVICE: Device descriptor */
156struct usb_device_descriptor {
157 __u8 bLength;
158 __u8 bDescriptorType;
159
160 __le16 bcdUSB;
161 __u8 bDeviceClass;
162 __u8 bDeviceSubClass;
163 __u8 bDeviceProtocol;
164 __u8 bMaxPacketSize0;
165 __le16 idVendor;
166 __le16 idProduct;
167 __le16 bcdDevice;
168 __u8 iManufacturer;
169 __u8 iProduct;
170 __u8 iSerialNumber;
171 __u8 bNumConfigurations;
172} __attribute__ ((packed));
173
174#define USB_DT_DEVICE_SIZE 18
175
176
177/*
178 * Device and/or Interface Class codes
179 * as found in bDeviceClass or bInterfaceClass
180 * and defined by www.usb.org documents
181 */
182#define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */
183#define USB_CLASS_AUDIO 1
184#define USB_CLASS_COMM 2
185#define USB_CLASS_HID 3
186#define USB_CLASS_PHYSICAL 5
187#define USB_CLASS_STILL_IMAGE 6
188#define USB_CLASS_PRINTER 7
189#define USB_CLASS_MASS_STORAGE 8
190#define USB_CLASS_HUB 9
191#define USB_CLASS_CDC_DATA 0x0a
192#define USB_CLASS_CSCID 0x0b /* chip+ smart card */
193#define USB_CLASS_CONTENT_SEC 0x0d /* content security */
194#define USB_CLASS_VIDEO 0x0e
195#define USB_CLASS_APP_SPEC 0xfe
196#define USB_CLASS_VENDOR_SPEC 0xff
197
198/*-------------------------------------------------------------------------*/
199
200/* USB_DT_CONFIG: Configuration descriptor information.
201 *
202 * USB_DT_OTHER_SPEED_CONFIG is the same descriptor, except that the
203 * descriptor type is different. Highspeed-capable devices can look
204 * different depending on what speed they're currently running. Only
205 * devices with a USB_DT_DEVICE_QUALIFIER have any OTHER_SPEED_CONFIG
206 * descriptors.
207 */
208struct usb_config_descriptor {
209 __u8 bLength;
210 __u8 bDescriptorType;
211
212 __le16 wTotalLength;
213 __u8 bNumInterfaces;
214 __u8 bConfigurationValue;
215 __u8 iConfiguration;
216 __u8 bmAttributes;
217 __u8 bMaxPower;
218} __attribute__ ((packed));
219
220#define USB_DT_CONFIG_SIZE 9
221
222/* from config descriptor bmAttributes */
223#define USB_CONFIG_ATT_ONE (1 << 7) /* must be set */
224#define USB_CONFIG_ATT_SELFPOWER (1 << 6) /* self powered */
225#define USB_CONFIG_ATT_WAKEUP (1 << 5) /* can wakeup */
226
227/*-------------------------------------------------------------------------*/
228
229/* USB_DT_STRING: String descriptor */
230struct usb_string_descriptor {
231 __u8 bLength;
232 __u8 bDescriptorType;
233
234 __le16 wData[1]; /* UTF-16LE encoded */
235} __attribute__ ((packed));
236
237/* note that "string" zero is special, it holds language codes that
238 * the device supports, not Unicode characters.
239 */
240
241/*-------------------------------------------------------------------------*/
242
243/* USB_DT_INTERFACE: Interface descriptor */
244struct usb_interface_descriptor {
245 __u8 bLength;
246 __u8 bDescriptorType;
247
248 __u8 bInterfaceNumber;
249 __u8 bAlternateSetting;
250 __u8 bNumEndpoints;
251 __u8 bInterfaceClass;
252 __u8 bInterfaceSubClass;
253 __u8 bInterfaceProtocol;
254 __u8 iInterface;
255} __attribute__ ((packed));
256
257#define USB_DT_INTERFACE_SIZE 9
258
259/*-------------------------------------------------------------------------*/
260
261/* USB_DT_ENDPOINT: Endpoint descriptor */
262struct usb_endpoint_descriptor {
263 __u8 bLength;
264 __u8 bDescriptorType;
265
266 __u8 bEndpointAddress;
267 __u8 bmAttributes;
268 __le16 wMaxPacketSize;
269 __u8 bInterval;
270
271 // NOTE: these two are _only_ in audio endpoints.
272 // use USB_DT_ENDPOINT*_SIZE in bLength, not sizeof.
273 __u8 bRefresh;
274 __u8 bSynchAddress;
275} __attribute__ ((packed));
276
277#define USB_DT_ENDPOINT_SIZE 7
278#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */
279
280
281/*
282 * Endpoints
283 */
284#define USB_ENDPOINT_NUMBER_MASK 0x0f /* in bEndpointAddress */
285#define USB_ENDPOINT_DIR_MASK 0x80
286
287#define USB_ENDPOINT_XFERTYPE_MASK 0x03 /* in bmAttributes */
288#define USB_ENDPOINT_XFER_CONTROL 0
289#define USB_ENDPOINT_XFER_ISOC 1
290#define USB_ENDPOINT_XFER_BULK 2
291#define USB_ENDPOINT_XFER_INT 3
292
293
294/*-------------------------------------------------------------------------*/
295
296/* USB_DT_DEVICE_QUALIFIER: Device Qualifier descriptor */
297struct usb_qualifier_descriptor {
298 __u8 bLength;
299 __u8 bDescriptorType;
300
301 __le16 bcdUSB;
302 __u8 bDeviceClass;
303 __u8 bDeviceSubClass;
304 __u8 bDeviceProtocol;
305 __u8 bMaxPacketSize0;
306 __u8 bNumConfigurations;
307 __u8 bRESERVED;
308} __attribute__ ((packed));
309
310
311/*-------------------------------------------------------------------------*/
312
313/* USB_DT_OTG (from OTG 1.0a supplement) */
314struct usb_otg_descriptor {
315 __u8 bLength;
316 __u8 bDescriptorType;
317
318 __u8 bmAttributes; /* support for HNP, SRP, etc */
319} __attribute__ ((packed));
320
321/* from usb_otg_descriptor.bmAttributes */
322#define USB_OTG_SRP (1 << 0)
323#define USB_OTG_HNP (1 << 1) /* swap host/device roles */
324
325/*-------------------------------------------------------------------------*/
326
327/* USB_DT_DEBUG: for special highspeed devices, replacing serial console */
328struct usb_debug_descriptor {
329 __u8 bLength;
330 __u8 bDescriptorType;
331
332 /* bulk endpoints with 8 byte maxpacket */
333 __u8 bDebugInEndpoint;
334 __u8 bDebugOutEndpoint;
335};
336
337/*-------------------------------------------------------------------------*/
338
339/* USB_DT_INTERFACE_ASSOCIATION: groups interfaces */
340struct usb_interface_assoc_descriptor {
341 __u8 bLength;
342 __u8 bDescriptorType;
343
344 __u8 bFirstInterface;
345 __u8 bInterfaceCount;
346 __u8 bFunctionClass;
347 __u8 bFunctionSubClass;
348 __u8 bFunctionProtocol;
349 __u8 iFunction;
350} __attribute__ ((packed));
351
352
353/*-------------------------------------------------------------------------*/
354
355/* USB 2.0 defines three speeds, here's how Linux identifies them */
356
357enum usb_device_speed {
358 USB_SPEED_UNKNOWN = 0, /* enumerating */
359 USB_SPEED_LOW, USB_SPEED_FULL, /* usb 1.1 */
360 USB_SPEED_HIGH /* usb 2.0 */
361};
362
363enum usb_device_state {
364 /* NOTATTACHED isn't in the USB spec, and this state acts
365 * the same as ATTACHED ... but it's clearer this way.
366 */
367 USB_STATE_NOTATTACHED = 0,
368
369 /* the chapter 9 device states */
370 USB_STATE_ATTACHED,
371 USB_STATE_POWERED,
372 USB_STATE_DEFAULT, /* limited function */
373 USB_STATE_ADDRESS,
374 USB_STATE_CONFIGURED, /* most functions */
375
376 USB_STATE_SUSPENDED
377
378 /* NOTE: there are actually four different SUSPENDED
379 * states, returning to POWERED, DEFAULT, ADDRESS, or
380 * CONFIGURED respectively when SOF tokens flow again.
381 */
382};
383
384#endif /* __LINUX_USB_CH9_H */
diff --git a/include/linux/usb_gadget.h b/include/linux/usb_gadget.h
new file mode 100644
index 000000000000..9bba9997947b
--- /dev/null
+++ b/include/linux/usb_gadget.h
@@ -0,0 +1,878 @@
1/*
2 * <linux/usb_gadget.h>
3 *
4 * We call the USB code inside a Linux-based peripheral device a "gadget"
5 * driver, except for the hardware-specific bus glue. One USB host can
6 * master many USB gadgets, but the gadgets are only slaved to one host.
7 *
8 *
9 * (C) Copyright 2002-2004 by David Brownell
10 * All Rights Reserved.
11 *
12 * This software is licensed under the GNU GPL version 2.
13 */
14
15#ifndef __LINUX_USB_GADGET_H
16#define __LINUX_USB_GADGET_H
17
18#ifdef __KERNEL__
19
20struct usb_ep;
21
22/**
23 * struct usb_request - describes one i/o request
24 * @buf: Buffer used for data. Always provide this; some controllers
25 * only use PIO, or don't use DMA for some endpoints.
26 * @dma: DMA address corresponding to 'buf'. If you don't set this
27 * field, and the usb controller needs one, it is responsible
28 * for mapping and unmapping the buffer.
29 * @length: Length of that data
30 * @no_interrupt: If true, hints that no completion irq is needed.
31 * Helpful sometimes with deep request queues that are handled
32 * directly by DMA controllers.
33 * @zero: If true, when writing data, makes the last packet be "short"
34 * by adding a zero length packet as needed;
35 * @short_not_ok: When reading data, makes short packets be
36 * treated as errors (queue stops advancing till cleanup).
37 * @complete: Function called when request completes, so this request and
38 * its buffer may be re-used.
39 * Reads terminate with a short packet, or when the buffer fills,
40 * whichever comes first. When writes terminate, some data bytes
41 * will usually still be in flight (often in a hardware fifo).
42 * Errors (for reads or writes) stop the queue from advancing
43 * until the completion function returns, so that any transfers
44 * invalidated by the error may first be dequeued.
45 * @context: For use by the completion callback
46 * @list: For use by the gadget driver.
47 * @status: Reports completion code, zero or a negative errno.
48 * Normally, faults block the transfer queue from advancing until
49 * the completion callback returns.
50 * Code "-ESHUTDOWN" indicates completion caused by device disconnect,
51 * or when the driver disabled the endpoint.
52 * @actual: Reports bytes transferred to/from the buffer. For reads (OUT
53 * transfers) this may be less than the requested length. If the
54 * short_not_ok flag is set, short reads are treated as errors
55 * even when status otherwise indicates successful completion.
56 * Note that for writes (IN transfers) some data bytes may still
57 * reside in a device-side FIFO when the request is reported as
58 * complete.
59 *
60 * These are allocated/freed through the endpoint they're used with. The
61 * hardware's driver can add extra per-request data to the memory it returns,
62 * which often avoids separate memory allocations (potential failures),
63 * later when the request is queued.
64 *
65 * Request flags affect request handling, such as whether a zero length
66 * packet is written (the "zero" flag), whether a short read should be
67 * treated as an error (blocking request queue advance, the "short_not_ok"
68 * flag), or hinting that an interrupt is not required (the "no_interrupt"
69 * flag, for use with deep request queues).
70 *
71 * Bulk endpoints can use any size buffers, and can also be used for interrupt
72 * transfers. interrupt-only endpoints can be much less functional.
73 */
74 // NOTE this is analagous to 'struct urb' on the host side,
75 // except that it's thinner and promotes more pre-allocation.
76
77struct usb_request {
78 void *buf;
79 unsigned length;
80 dma_addr_t dma;
81
82 unsigned no_interrupt:1;
83 unsigned zero:1;
84 unsigned short_not_ok:1;
85
86 void (*complete)(struct usb_ep *ep,
87 struct usb_request *req);
88 void *context;
89 struct list_head list;
90
91 int status;
92 unsigned actual;
93};
94
95/*-------------------------------------------------------------------------*/
96
97/* endpoint-specific parts of the api to the usb controller hardware.
98 * unlike the urb model, (de)multiplexing layers are not required.
99 * (so this api could slash overhead if used on the host side...)
100 *
101 * note that device side usb controllers commonly differ in how many
102 * endpoints they support, as well as their capabilities.
103 */
104struct usb_ep_ops {
105 int (*enable) (struct usb_ep *ep,
106 const struct usb_endpoint_descriptor *desc);
107 int (*disable) (struct usb_ep *ep);
108
109 struct usb_request *(*alloc_request) (struct usb_ep *ep,
110 int gfp_flags);
111 void (*free_request) (struct usb_ep *ep, struct usb_request *req);
112
113 void *(*alloc_buffer) (struct usb_ep *ep, unsigned bytes,
114 dma_addr_t *dma, int gfp_flags);
115 void (*free_buffer) (struct usb_ep *ep, void *buf, dma_addr_t dma,
116 unsigned bytes);
117 // NOTE: on 2.6, drivers may also use dma_map() and
118 // dma_sync_single_*() to directly manage dma overhead.
119
120 int (*queue) (struct usb_ep *ep, struct usb_request *req,
121 int gfp_flags);
122 int (*dequeue) (struct usb_ep *ep, struct usb_request *req);
123
124 int (*set_halt) (struct usb_ep *ep, int value);
125 int (*fifo_status) (struct usb_ep *ep);
126 void (*fifo_flush) (struct usb_ep *ep);
127};
128
129/**
130 * struct usb_ep - device side representation of USB endpoint
131 * @name:identifier for the endpoint, such as "ep-a" or "ep9in-bulk"
132 * @ops: Function pointers used to access hardware-specific operations.
133 * @ep_list:the gadget's ep_list holds all of its endpoints
134 * @maxpacket:The maximum packet size used on this endpoint. The initial
135 * value can sometimes be reduced (hardware allowing), according to
136 * the endpoint descriptor used to configure the endpoint.
137 * @driver_data:for use by the gadget driver. all other fields are
138 * read-only to gadget drivers.
139 *
140 * the bus controller driver lists all the general purpose endpoints in
141 * gadget->ep_list. the control endpoint (gadget->ep0) is not in that list,
142 * and is accessed only in response to a driver setup() callback.
143 */
144struct usb_ep {
145 void *driver_data;
146
147 const char *name;
148 const struct usb_ep_ops *ops;
149 struct list_head ep_list;
150 unsigned maxpacket:16;
151};
152
153/*-------------------------------------------------------------------------*/
154
155/**
156 * usb_ep_enable - configure endpoint, making it usable
157 * @ep:the endpoint being configured. may not be the endpoint named "ep0".
158 * drivers discover endpoints through the ep_list of a usb_gadget.
159 * @desc:descriptor for desired behavior. caller guarantees this pointer
160 * remains valid until the endpoint is disabled; the data byte order
161 * is little-endian (usb-standard).
162 *
163 * when configurations are set, or when interface settings change, the driver
164 * will enable or disable the relevant endpoints. while it is enabled, an
165 * endpoint may be used for i/o until the driver receives a disconnect() from
166 * the host or until the endpoint is disabled.
167 *
168 * the ep0 implementation (which calls this routine) must ensure that the
169 * hardware capabilities of each endpoint match the descriptor provided
170 * for it. for example, an endpoint named "ep2in-bulk" would be usable
171 * for interrupt transfers as well as bulk, but it likely couldn't be used
172 * for iso transfers or for endpoint 14. some endpoints are fully
173 * configurable, with more generic names like "ep-a". (remember that for
174 * USB, "in" means "towards the USB master".)
175 *
176 * returns zero, or a negative error code.
177 */
178static inline int
179usb_ep_enable (struct usb_ep *ep, const struct usb_endpoint_descriptor *desc)
180{
181 return ep->ops->enable (ep, desc);
182}
183
184/**
185 * usb_ep_disable - endpoint is no longer usable
186 * @ep:the endpoint being unconfigured. may not be the endpoint named "ep0".
187 *
188 * no other task may be using this endpoint when this is called.
189 * any pending and uncompleted requests will complete with status
190 * indicating disconnect (-ESHUTDOWN) before this call returns.
191 * gadget drivers must call usb_ep_enable() again before queueing
192 * requests to the endpoint.
193 *
194 * returns zero, or a negative error code.
195 */
196static inline int
197usb_ep_disable (struct usb_ep *ep)
198{
199 return ep->ops->disable (ep);
200}
201
202/**
203 * usb_ep_alloc_request - allocate a request object to use with this endpoint
204 * @ep:the endpoint to be used with with the request
205 * @gfp_flags:GFP_* flags to use
206 *
207 * Request objects must be allocated with this call, since they normally
208 * need controller-specific setup and may even need endpoint-specific
209 * resources such as allocation of DMA descriptors.
210 * Requests may be submitted with usb_ep_queue(), and receive a single
211 * completion callback. Free requests with usb_ep_free_request(), when
212 * they are no longer needed.
213 *
214 * Returns the request, or null if one could not be allocated.
215 */
216static inline struct usb_request *
217usb_ep_alloc_request (struct usb_ep *ep, int gfp_flags)
218{
219 return ep->ops->alloc_request (ep, gfp_flags);
220}
221
222/**
223 * usb_ep_free_request - frees a request object
224 * @ep:the endpoint associated with the request
225 * @req:the request being freed
226 *
227 * Reverses the effect of usb_ep_alloc_request().
228 * Caller guarantees the request is not queued, and that it will
229 * no longer be requeued (or otherwise used).
230 */
231static inline void
232usb_ep_free_request (struct usb_ep *ep, struct usb_request *req)
233{
234 ep->ops->free_request (ep, req);
235}
236
237/**
238 * usb_ep_alloc_buffer - allocate an I/O buffer
239 * @ep:the endpoint associated with the buffer
240 * @len:length of the desired buffer
241 * @dma:pointer to the buffer's DMA address; must be valid
242 * @gfp_flags:GFP_* flags to use
243 *
244 * Returns a new buffer, or null if one could not be allocated.
245 * The buffer is suitably aligned for dma, if that endpoint uses DMA,
246 * and the caller won't have to care about dma-inconsistency
247 * or any hidden "bounce buffer" mechanism. No additional per-request
248 * DMA mapping will be required for such buffers.
249 * Free it later with usb_ep_free_buffer().
250 *
251 * You don't need to use this call to allocate I/O buffers unless you
252 * want to make sure drivers don't incur costs for such "bounce buffer"
253 * copies or per-request DMA mappings.
254 */
255static inline void *
256usb_ep_alloc_buffer (struct usb_ep *ep, unsigned len, dma_addr_t *dma,
257 int gfp_flags)
258{
259 return ep->ops->alloc_buffer (ep, len, dma, gfp_flags);
260}
261
262/**
263 * usb_ep_free_buffer - frees an i/o buffer
264 * @ep:the endpoint associated with the buffer
265 * @buf:CPU view address of the buffer
266 * @dma:the buffer's DMA address
267 * @len:length of the buffer
268 *
269 * reverses the effect of usb_ep_alloc_buffer().
270 * caller guarantees the buffer will no longer be accessed
271 */
272static inline void
273usb_ep_free_buffer (struct usb_ep *ep, void *buf, dma_addr_t dma, unsigned len)
274{
275 ep->ops->free_buffer (ep, buf, dma, len);
276}
277
278/**
279 * usb_ep_queue - queues (submits) an I/O request to an endpoint.
280 * @ep:the endpoint associated with the request
281 * @req:the request being submitted
282 * @gfp_flags: GFP_* flags to use in case the lower level driver couldn't
283 * pre-allocate all necessary memory with the request.
284 *
285 * This tells the device controller to perform the specified request through
286 * that endpoint (reading or writing a buffer). When the request completes,
287 * including being canceled by usb_ep_dequeue(), the request's completion
288 * routine is called to return the request to the driver. Any endpoint
289 * (except control endpoints like ep0) may have more than one transfer
290 * request queued; they complete in FIFO order. Once a gadget driver
291 * submits a request, that request may not be examined or modified until it
292 * is given back to that driver through the completion callback.
293 *
294 * Each request is turned into one or more packets. The controller driver
295 * never merges adjacent requests into the same packet. OUT transfers
296 * will sometimes use data that's already buffered in the hardware.
297 * Drivers can rely on the fact that the first byte of the request's buffer
298 * always corresponds to the first byte of some USB packet, for both
299 * IN and OUT transfers.
300 *
301 * Bulk endpoints can queue any amount of data; the transfer is packetized
302 * automatically. The last packet will be short if the request doesn't fill it
303 * out completely. Zero length packets (ZLPs) should be avoided in portable
304 * protocols since not all usb hardware can successfully handle zero length
305 * packets. (ZLPs may be explicitly written, and may be implicitly written if
306 * the request 'zero' flag is set.) Bulk endpoints may also be used
307 * for interrupt transfers; but the reverse is not true, and some endpoints
308 * won't support every interrupt transfer. (Such as 768 byte packets.)
309 *
310 * Interrupt-only endpoints are less functional than bulk endpoints, for
311 * example by not supporting queueing or not handling buffers that are
312 * larger than the endpoint's maxpacket size. They may also treat data
313 * toggle differently.
314 *
315 * Control endpoints ... after getting a setup() callback, the driver queues
316 * one response (even if it would be zero length). That enables the
317 * status ack, after transfering data as specified in the response. Setup
318 * functions may return negative error codes to generate protocol stalls.
319 * (Note that some USB device controllers disallow protocol stall responses
320 * in some cases.) When control responses are deferred (the response is
321 * written after the setup callback returns), then usb_ep_set_halt() may be
322 * used on ep0 to trigger protocol stalls.
323 *
324 * For periodic endpoints, like interrupt or isochronous ones, the usb host
325 * arranges to poll once per interval, and the gadget driver usually will
326 * have queued some data to transfer at that time.
327 *
328 * Returns zero, or a negative error code. Endpoints that are not enabled
329 * report errors; errors will also be
330 * reported when the usb peripheral is disconnected.
331 */
332static inline int
333usb_ep_queue (struct usb_ep *ep, struct usb_request *req, int gfp_flags)
334{
335 return ep->ops->queue (ep, req, gfp_flags);
336}
337
338/**
339 * usb_ep_dequeue - dequeues (cancels, unlinks) an I/O request from an endpoint
340 * @ep:the endpoint associated with the request
341 * @req:the request being canceled
342 *
343 * if the request is still active on the endpoint, it is dequeued and its
344 * completion routine is called (with status -ECONNRESET); else a negative
345 * error code is returned.
346 *
347 * note that some hardware can't clear out write fifos (to unlink the request
348 * at the head of the queue) except as part of disconnecting from usb. such
349 * restrictions prevent drivers from supporting configuration changes,
350 * even to configuration zero (a "chapter 9" requirement).
351 */
352static inline int usb_ep_dequeue (struct usb_ep *ep, struct usb_request *req)
353{
354 return ep->ops->dequeue (ep, req);
355}
356
357/**
358 * usb_ep_set_halt - sets the endpoint halt feature.
359 * @ep: the non-isochronous endpoint being stalled
360 *
361 * Use this to stall an endpoint, perhaps as an error report.
362 * Except for control endpoints,
363 * the endpoint stays halted (will not stream any data) until the host
364 * clears this feature; drivers may need to empty the endpoint's request
365 * queue first, to make sure no inappropriate transfers happen.
366 *
367 * Note that while an endpoint CLEAR_FEATURE will be invisible to the
368 * gadget driver, a SET_INTERFACE will not be. To reset endpoints for the
369 * current altsetting, see usb_ep_clear_halt(). When switching altsettings,
370 * it's simplest to use usb_ep_enable() or usb_ep_disable() for the endpoints.
371 *
372 * Returns zero, or a negative error code. On success, this call sets
373 * underlying hardware state that blocks data transfers.
374 * Attempts to halt IN endpoints will fail (returning -EAGAIN) if any
375 * transfer requests are still queued, or if the controller hardware
376 * (usually a FIFO) still holds bytes that the host hasn't collected.
377 */
378static inline int
379usb_ep_set_halt (struct usb_ep *ep)
380{
381 return ep->ops->set_halt (ep, 1);
382}
383
384/**
385 * usb_ep_clear_halt - clears endpoint halt, and resets toggle
386 * @ep:the bulk or interrupt endpoint being reset
387 *
388 * Use this when responding to the standard usb "set interface" request,
389 * for endpoints that aren't reconfigured, after clearing any other state
390 * in the endpoint's i/o queue.
391 *
392 * Returns zero, or a negative error code. On success, this call clears
393 * the underlying hardware state reflecting endpoint halt and data toggle.
394 * Note that some hardware can't support this request (like pxa2xx_udc),
395 * and accordingly can't correctly implement interface altsettings.
396 */
397static inline int
398usb_ep_clear_halt (struct usb_ep *ep)
399{
400 return ep->ops->set_halt (ep, 0);
401}
402
403/**
404 * usb_ep_fifo_status - returns number of bytes in fifo, or error
405 * @ep: the endpoint whose fifo status is being checked.
406 *
407 * FIFO endpoints may have "unclaimed data" in them in certain cases,
408 * such as after aborted transfers. Hosts may not have collected all
409 * the IN data written by the gadget driver (and reported by a request
410 * completion). The gadget driver may not have collected all the data
411 * written OUT to it by the host. Drivers that need precise handling for
412 * fault reporting or recovery may need to use this call.
413 *
414 * This returns the number of such bytes in the fifo, or a negative
415 * errno if the endpoint doesn't use a FIFO or doesn't support such
416 * precise handling.
417 */
418static inline int
419usb_ep_fifo_status (struct usb_ep *ep)
420{
421 if (ep->ops->fifo_status)
422 return ep->ops->fifo_status (ep);
423 else
424 return -EOPNOTSUPP;
425}
426
427/**
428 * usb_ep_fifo_flush - flushes contents of a fifo
429 * @ep: the endpoint whose fifo is being flushed.
430 *
431 * This call may be used to flush the "unclaimed data" that may exist in
432 * an endpoint fifo after abnormal transaction terminations. The call
433 * must never be used except when endpoint is not being used for any
434 * protocol translation.
435 */
436static inline void
437usb_ep_fifo_flush (struct usb_ep *ep)
438{
439 if (ep->ops->fifo_flush)
440 ep->ops->fifo_flush (ep);
441}
442
443
444/*-------------------------------------------------------------------------*/
445
446struct usb_gadget;
447
448/* the rest of the api to the controller hardware: device operations,
449 * which don't involve endpoints (or i/o).
450 */
451struct usb_gadget_ops {
452 int (*get_frame)(struct usb_gadget *);
453 int (*wakeup)(struct usb_gadget *);
454 int (*set_selfpowered) (struct usb_gadget *, int is_selfpowered);
455 int (*vbus_session) (struct usb_gadget *, int is_active);
456 int (*vbus_draw) (struct usb_gadget *, unsigned mA);
457 int (*pullup) (struct usb_gadget *, int is_on);
458 int (*ioctl)(struct usb_gadget *,
459 unsigned code, unsigned long param);
460};
461
462/**
463 * struct usb_gadget - represents a usb slave device
464 * @ops: Function pointers used to access hardware-specific operations.
465 * @ep0: Endpoint zero, used when reading or writing responses to
466 * driver setup() requests
467 * @ep_list: List of other endpoints supported by the device.
468 * @speed: Speed of current connection to USB host.
469 * @is_dualspeed: True if the controller supports both high and full speed
470 * operation. If it does, the gadget driver must also support both.
471 * @is_otg: True if the USB device port uses a Mini-AB jack, so that the
472 * gadget driver must provide a USB OTG descriptor.
473 * @is_a_peripheral: False unless is_otg, the "A" end of a USB cable
474 * is in the Mini-AB jack, and HNP has been used to switch roles
475 * so that the "A" device currently acts as A-Peripheral, not A-Host.
476 * @a_hnp_support: OTG device feature flag, indicating that the A-Host
477 * supports HNP at this port.
478 * @a_alt_hnp_support: OTG device feature flag, indicating that the A-Host
479 * only supports HNP on a different root port.
480 * @b_hnp_enable: OTG device feature flag, indicating that the A-Host
481 * enabled HNP support.
482 * @name: Identifies the controller hardware type. Used in diagnostics
483 * and sometimes configuration.
484 * @dev: Driver model state for this abstract device.
485 *
486 * Gadgets have a mostly-portable "gadget driver" implementing device
487 * functions, handling all usb configurations and interfaces. Gadget
488 * drivers talk to hardware-specific code indirectly, through ops vectors.
489 * That insulates the gadget driver from hardware details, and packages
490 * the hardware endpoints through generic i/o queues. The "usb_gadget"
491 * and "usb_ep" interfaces provide that insulation from the hardware.
492 *
493 * Except for the driver data, all fields in this structure are
494 * read-only to the gadget driver. That driver data is part of the
495 * "driver model" infrastructure in 2.6 (and later) kernels, and for
496 * earlier systems is grouped in a similar structure that's not known
497 * to the rest of the kernel.
498 *
499 * Values of the three OTG device feature flags are updated before the
500 * setup() call corresponding to USB_REQ_SET_CONFIGURATION, and before
501 * driver suspend() calls. They are valid only when is_otg, and when the
502 * device is acting as a B-Peripheral (so is_a_peripheral is false).
503 */
504struct usb_gadget {
505 /* readonly to gadget driver */
506 const struct usb_gadget_ops *ops;
507 struct usb_ep *ep0;
508 struct list_head ep_list; /* of usb_ep */
509 enum usb_device_speed speed;
510 unsigned is_dualspeed:1;
511 unsigned is_otg:1;
512 unsigned is_a_peripheral:1;
513 unsigned b_hnp_enable:1;
514 unsigned a_hnp_support:1;
515 unsigned a_alt_hnp_support:1;
516 const char *name;
517 struct device dev;
518};
519
520static inline void set_gadget_data (struct usb_gadget *gadget, void *data)
521 { dev_set_drvdata (&gadget->dev, data); }
522static inline void *get_gadget_data (struct usb_gadget *gadget)
523 { return dev_get_drvdata (&gadget->dev); }
524
525/* iterates the non-control endpoints; 'tmp' is a struct usb_ep pointer */
526#define gadget_for_each_ep(tmp,gadget) \
527 list_for_each_entry(tmp, &(gadget)->ep_list, ep_list)
528
529
530/**
531 * usb_gadget_frame_number - returns the current frame number
532 * @gadget: controller that reports the frame number
533 *
534 * Returns the usb frame number, normally eleven bits from a SOF packet,
535 * or negative errno if this device doesn't support this capability.
536 */
537static inline int usb_gadget_frame_number (struct usb_gadget *gadget)
538{
539 return gadget->ops->get_frame (gadget);
540}
541
542/**
543 * usb_gadget_wakeup - tries to wake up the host connected to this gadget
544 * @gadget: controller used to wake up the host
545 *
546 * Returns zero on success, else negative error code if the hardware
547 * doesn't support such attempts, or its support has not been enabled
548 * by the usb host. Drivers must return device descriptors that report
549 * their ability to support this, or hosts won't enable it.
550 *
551 * This may also try to use SRP to wake the host and start enumeration,
552 * even if OTG isn't otherwise in use. OTG devices may also start
553 * remote wakeup even when hosts don't explicitly enable it.
554 */
555static inline int usb_gadget_wakeup (struct usb_gadget *gadget)
556{
557 if (!gadget->ops->wakeup)
558 return -EOPNOTSUPP;
559 return gadget->ops->wakeup (gadget);
560}
561
562/**
563 * usb_gadget_set_selfpowered - sets the device selfpowered feature.
564 * @gadget:the device being declared as self-powered
565 *
566 * this affects the device status reported by the hardware driver
567 * to reflect that it now has a local power supply.
568 *
569 * returns zero on success, else negative errno.
570 */
571static inline int
572usb_gadget_set_selfpowered (struct usb_gadget *gadget)
573{
574 if (!gadget->ops->set_selfpowered)
575 return -EOPNOTSUPP;
576 return gadget->ops->set_selfpowered (gadget, 1);
577}
578
579/**
580 * usb_gadget_clear_selfpowered - clear the device selfpowered feature.
581 * @gadget:the device being declared as bus-powered
582 *
583 * this affects the device status reported by the hardware driver.
584 * some hardware may not support bus-powered operation, in which
585 * case this feature's value can never change.
586 *
587 * returns zero on success, else negative errno.
588 */
589static inline int
590usb_gadget_clear_selfpowered (struct usb_gadget *gadget)
591{
592 if (!gadget->ops->set_selfpowered)
593 return -EOPNOTSUPP;
594 return gadget->ops->set_selfpowered (gadget, 0);
595}
596
597/**
598 * usb_gadget_vbus_connect - Notify controller that VBUS is powered
599 * @gadget:The device which now has VBUS power.
600 *
601 * This call is used by a driver for an external transceiver (or GPIO)
602 * that detects a VBUS power session starting. Common responses include
603 * resuming the controller, activating the D+ (or D-) pullup to let the
604 * host detect that a USB device is attached, and starting to draw power
605 * (8mA or possibly more, especially after SET_CONFIGURATION).
606 *
607 * Returns zero on success, else negative errno.
608 */
609static inline int
610usb_gadget_vbus_connect(struct usb_gadget *gadget)
611{
612 if (!gadget->ops->vbus_session)
613 return -EOPNOTSUPP;
614 return gadget->ops->vbus_session (gadget, 1);
615}
616
617/**
618 * usb_gadget_vbus_draw - constrain controller's VBUS power usage
619 * @gadget:The device whose VBUS usage is being described
620 * @mA:How much current to draw, in milliAmperes. This should be twice
621 * the value listed in the configuration descriptor bMaxPower field.
622 *
623 * This call is used by gadget drivers during SET_CONFIGURATION calls,
624 * reporting how much power the device may consume. For example, this
625 * could affect how quickly batteries are recharged.
626 *
627 * Returns zero on success, else negative errno.
628 */
629static inline int
630usb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA)
631{
632 if (!gadget->ops->vbus_draw)
633 return -EOPNOTSUPP;
634 return gadget->ops->vbus_draw (gadget, mA);
635}
636
637/**
638 * usb_gadget_vbus_disconnect - notify controller about VBUS session end
639 * @gadget:the device whose VBUS supply is being described
640 *
641 * This call is used by a driver for an external transceiver (or GPIO)
642 * that detects a VBUS power session ending. Common responses include
643 * reversing everything done in usb_gadget_vbus_connect().
644 *
645 * Returns zero on success, else negative errno.
646 */
647static inline int
648usb_gadget_vbus_disconnect(struct usb_gadget *gadget)
649{
650 if (!gadget->ops->vbus_session)
651 return -EOPNOTSUPP;
652 return gadget->ops->vbus_session (gadget, 0);
653}
654
655/**
656 * usb_gadget_connect - software-controlled connect to USB host
657 * @gadget:the peripheral being connected
658 *
659 * Enables the D+ (or potentially D-) pullup. The host will start
660 * enumerating this gadget when the pullup is active and a VBUS session
661 * is active (the link is powered). This pullup is always enabled unless
662 * usb_gadget_disconnect() has been used to disable it.
663 *
664 * Returns zero on success, else negative errno.
665 */
666static inline int
667usb_gadget_connect (struct usb_gadget *gadget)
668{
669 if (!gadget->ops->pullup)
670 return -EOPNOTSUPP;
671 return gadget->ops->pullup (gadget, 1);
672}
673
674/**
675 * usb_gadget_disconnect - software-controlled disconnect from USB host
676 * @gadget:the peripheral being disconnected
677 *
678 * Disables the D+ (or potentially D-) pullup, which the host may see
679 * as a disconnect (when a VBUS session is active). Not all systems
680 * support software pullup controls.
681 *
682 * This routine may be used during the gadget driver bind() call to prevent
683 * the peripheral from ever being visible to the USB host, unless later
684 * usb_gadget_connect() is called. For example, user mode components may
685 * need to be activated before the system can talk to hosts.
686 *
687 * Returns zero on success, else negative errno.
688 */
689static inline int
690usb_gadget_disconnect (struct usb_gadget *gadget)
691{
692 if (!gadget->ops->pullup)
693 return -EOPNOTSUPP;
694 return gadget->ops->pullup (gadget, 0);
695}
696
697
698
699/*-------------------------------------------------------------------------*/
700
701/**
702 * struct usb_gadget_driver - driver for usb 'slave' devices
703 * @function: String describing the gadget's function
704 * @speed: Highest speed the driver handles.
705 * @bind: Invoked when the driver is bound to a gadget, usually
706 * after registering the driver.
707 * At that point, ep0 is fully initialized, and ep_list holds
708 * the currently-available endpoints.
709 * Called in a context that permits sleeping.
710 * @setup: Invoked for ep0 control requests that aren't handled by
711 * the hardware level driver. Most calls must be handled by
712 * the gadget driver, including descriptor and configuration
713 * management. The 16 bit members of the setup data are in
714 * cpu order. Called in_interrupt; this may not sleep. Driver
715 * queues a response to ep0, or returns negative to stall.
716 * @disconnect: Invoked after all transfers have been stopped,
717 * when the host is disconnected. May be called in_interrupt; this
718 * may not sleep. Some devices can't detect disconnect, so this might
719 * not be called except as part of controller shutdown.
720 * @unbind: Invoked when the driver is unbound from a gadget,
721 * usually from rmmod (after a disconnect is reported).
722 * Called in a context that permits sleeping.
723 * @suspend: Invoked on USB suspend. May be called in_interrupt.
724 * @resume: Invoked on USB resume. May be called in_interrupt.
725 * @driver: Driver model state for this driver.
726 *
727 * Devices are disabled till a gadget driver successfully bind()s, which
728 * means the driver will handle setup() requests needed to enumerate (and
729 * meet "chapter 9" requirements) then do some useful work.
730 *
731 * If gadget->is_otg is true, the gadget driver must provide an OTG
732 * descriptor during enumeration, or else fail the bind() call. In such
733 * cases, no USB traffic may flow until both bind() returns without
734 * having called usb_gadget_disconnect(), and the USB host stack has
735 * initialized.
736 *
737 * Drivers use hardware-specific knowledge to configure the usb hardware.
738 * endpoint addressing is only one of several hardware characteristics that
739 * are in descriptors the ep0 implementation returns from setup() calls.
740 *
741 * Except for ep0 implementation, most driver code shouldn't need change to
742 * run on top of different usb controllers. It'll use endpoints set up by
743 * that ep0 implementation.
744 *
745 * The usb controller driver handles a few standard usb requests. Those
746 * include set_address, and feature flags for devices, interfaces, and
747 * endpoints (the get_status, set_feature, and clear_feature requests).
748 *
749 * Accordingly, the driver's setup() callback must always implement all
750 * get_descriptor requests, returning at least a device descriptor and
751 * a configuration descriptor. Drivers must make sure the endpoint
752 * descriptors match any hardware constraints. Some hardware also constrains
753 * other descriptors. (The pxa250 allows only configurations 1, 2, or 3).
754 *
755 * The driver's setup() callback must also implement set_configuration,
756 * and should also implement set_interface, get_configuration, and
757 * get_interface. Setting a configuration (or interface) is where
758 * endpoints should be activated or (config 0) shut down.
759 *
760 * (Note that only the default control endpoint is supported. Neither
761 * hosts nor devices generally support control traffic except to ep0.)
762 *
763 * Most devices will ignore USB suspend/resume operations, and so will
764 * not provide those callbacks. However, some may need to change modes
765 * when the host is not longer directing those activities. For example,
766 * local controls (buttons, dials, etc) may need to be re-enabled since
767 * the (remote) host can't do that any longer; or an error state might
768 * be cleared, to make the device behave identically whether or not
769 * power is maintained.
770 */
771struct usb_gadget_driver {
772 char *function;
773 enum usb_device_speed speed;
774 int (*bind)(struct usb_gadget *);
775 void (*unbind)(struct usb_gadget *);
776 int (*setup)(struct usb_gadget *,
777 const struct usb_ctrlrequest *);
778 void (*disconnect)(struct usb_gadget *);
779 void (*suspend)(struct usb_gadget *);
780 void (*resume)(struct usb_gadget *);
781
782 // FIXME support safe rmmod
783 struct device_driver driver;
784};
785
786
787
788/*-------------------------------------------------------------------------*/
789
790/* driver modules register and unregister, as usual.
791 * these calls must be made in a context that can sleep.
792 *
793 * these will usually be implemented directly by the hardware-dependent
794 * usb bus interface driver, which will only support a single driver.
795 */
796
797/**
798 * usb_gadget_register_driver - register a gadget driver
799 * @driver:the driver being registered
800 *
801 * Call this in your gadget driver's module initialization function,
802 * to tell the underlying usb controller driver about your driver.
803 * The driver's bind() function will be called to bind it to a
804 * gadget. This function must be called in a context that can sleep.
805 */
806int usb_gadget_register_driver (struct usb_gadget_driver *driver);
807
808/**
809 * usb_gadget_unregister_driver - unregister a gadget driver
810 * @driver:the driver being unregistered
811 *
812 * Call this in your gadget driver's module cleanup function,
813 * to tell the underlying usb controller that your driver is
814 * going away. If the controller is connected to a USB host,
815 * it will first disconnect(). The driver is also requested
816 * to unbind() and clean up any device state, before this procedure
817 * finally returns.
818 * This function must be called in a context that can sleep.
819 */
820int usb_gadget_unregister_driver (struct usb_gadget_driver *driver);
821
822/*-------------------------------------------------------------------------*/
823
824/* utility to simplify dealing with string descriptors */
825
826/**
827 * struct usb_string - wraps a C string and its USB id
828 * @id:the (nonzero) ID for this string
829 * @s:the string, in UTF-8 encoding
830 *
831 * If you're using usb_gadget_get_string(), use this to wrap a string
832 * together with its ID.
833 */
834struct usb_string {
835 u8 id;
836 const char *s;
837};
838
839/**
840 * struct usb_gadget_strings - a set of USB strings in a given language
841 * @language:identifies the strings' language (0x0409 for en-us)
842 * @strings:array of strings with their ids
843 *
844 * If you're using usb_gadget_get_string(), use this to wrap all the
845 * strings for a given language.
846 */
847struct usb_gadget_strings {
848 u16 language; /* 0x0409 for en-us */
849 struct usb_string *strings;
850};
851
852/* put descriptor for string with that id into buf (buflen >= 256) */
853int usb_gadget_get_string (struct usb_gadget_strings *table, int id, u8 *buf);
854
855/*-------------------------------------------------------------------------*/
856
857/* utility to simplify managing config descriptors */
858
859/* write vector of descriptors into buffer */
860int usb_descriptor_fillbuf(void *, unsigned,
861 const struct usb_descriptor_header **);
862
863/* build config descriptor from single descriptor vector */
864int usb_gadget_config_buf(const struct usb_config_descriptor *config,
865 void *buf, unsigned buflen, const struct usb_descriptor_header **desc);
866
867/*-------------------------------------------------------------------------*/
868
869/* utility wrapping a simple endpoint selection policy */
870
871extern struct usb_ep *usb_ep_autoconfig (struct usb_gadget *,
872 struct usb_endpoint_descriptor *) __init;
873
874extern void usb_ep_autoconfig_reset (struct usb_gadget *) __init;
875
876#endif /* __KERNEL__ */
877
878#endif /* __LINUX_USB_GADGET_H */
diff --git a/include/linux/usb_gadgetfs.h b/include/linux/usb_gadgetfs.h
new file mode 100644
index 000000000000..b53d6ae8e55e
--- /dev/null
+++ b/include/linux/usb_gadgetfs.h
@@ -0,0 +1,75 @@
1
2#include <asm/types.h>
3#include <asm/ioctl.h>
4
5#include <linux/usb_ch9.h>
6
7/*
8 * Filesystem based user-mode API to USB Gadget controller hardware
9 *
10 * Almost everything can be done with only read and write operations,
11 * on endpoint files found in one directory. They are configured by
12 * writing descriptors, and then may be used for normal stream style
13 * i/o requests. When ep0 is configured, the device can enumerate;
14 * when it's closed, the device disconnects from usb.
15 *
16 * Configuration and device descriptors get written to /dev/gadget/$CHIP,
17 * which may then be used to read usb_gadgetfs_event structs. The driver
18 * may activate endpoints as it handles SET_CONFIGURATION setup events,
19 * or earlier; writing endpoint descriptors to /dev/gadget/$ENDPOINT
20 * then performing data transfers by reading or writing.
21 */
22
23/*
24 * Events are delivered on the ep0 file descriptor, if the user mode driver
25 * reads from this file descriptor after writing the descriptors. Don't
26 * stop polling this descriptor, if you write that kind of driver.
27 */
28
29enum usb_gadgetfs_event_type {
30 GADGETFS_NOP = 0,
31
32 GADGETFS_CONNECT,
33 GADGETFS_DISCONNECT,
34 GADGETFS_SETUP,
35 GADGETFS_SUSPEND,
36 // and likely more !
37};
38
39struct usb_gadgetfs_event {
40 enum usb_gadgetfs_event_type type;
41 union {
42 // NOP, DISCONNECT, SUSPEND: nothing
43 // ... some hardware can't report disconnection
44
45 // CONNECT: just the speed
46 enum usb_device_speed speed;
47
48 // SETUP: packet; DATA phase i/o precedes next event
49 // (setup.bmRequestType & USB_DIR_IN) flags direction
50 // ... includes SET_CONFIGURATION, SET_INTERFACE
51 struct usb_ctrlrequest setup;
52 } u;
53};
54
55
56/* endpoint ioctls */
57
58/* IN transfers may be reported to the gadget driver as complete
59 * when the fifo is loaded, before the host reads the data;
60 * OUT transfers may be reported to the host's "client" driver as
61 * complete when they're sitting in the FIFO unread.
62 * THIS returns how many bytes are "unclaimed" in the endpoint fifo
63 * (needed for precise fault handling, when the hardware allows it)
64 */
65#define GADGETFS_FIFO_STATUS _IO('g',1)
66
67/* discards any unclaimed data in the fifo. */
68#define GADGETFS_FIFO_FLUSH _IO('g',2)
69
70/* resets endpoint halt+toggle; used to implement set_interface.
71 * some hardware (like pxa2xx) can't support this.
72 */
73#define GADGETFS_CLEAR_HALT _IO('g',3)
74
75
diff --git a/include/linux/usb_otg.h b/include/linux/usb_otg.h
new file mode 100644
index 000000000000..c6683146e9b0
--- /dev/null
+++ b/include/linux/usb_otg.h
@@ -0,0 +1,118 @@
1// include/linux/usb_otg.h
2
3/*
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
6 * continue to use just usb_device and usb_gadget.
7 */
8
9
10/* OTG defines lots of enumeration states before device reset */
11enum usb_otg_state {
12 OTG_STATE_UNDEFINED = 0,
13
14 /* single-role peripheral, and dual-role default-b */
15 OTG_STATE_B_IDLE,
16 OTG_STATE_B_SRP_INIT,
17 OTG_STATE_B_PERIPHERAL,
18
19 /* extra dual-role default-b states */
20 OTG_STATE_B_WAIT_ACON,
21 OTG_STATE_B_HOST,
22
23 /* dual-role default-a */
24 OTG_STATE_A_IDLE,
25 OTG_STATE_A_WAIT_VRISE,
26 OTG_STATE_A_WAIT_BCON,
27 OTG_STATE_A_HOST,
28 OTG_STATE_A_SUSPEND,
29 OTG_STATE_A_PERIPHERAL,
30 OTG_STATE_A_WAIT_VFALL,
31 OTG_STATE_A_VBUS_ERR,
32};
33
34/*
35 * the otg driver needs to interact with both device side and host side
36 * usb controllers. it decides which controller is active at a given
37 * moment, using the transceiver, ID signal, HNP and sometimes static
38 * configuration information (including "board isn't wired for otg").
39 */
40struct otg_transceiver {
41 struct device *dev;
42 const char *label;
43
44 u8 default_a;
45 enum usb_otg_state state;
46
47 struct usb_bus *host;
48 struct usb_gadget *gadget;
49
50 /* to pass extra port status to the root hub */
51 u16 port_status;
52 u16 port_change;
53
54 /* bind/unbind the host controller */
55 int (*set_host)(struct otg_transceiver *otg,
56 struct usb_bus *host);
57
58 /* bind/unbind the peripheral controller */
59 int (*set_peripheral)(struct otg_transceiver *otg,
60 struct usb_gadget *gadget);
61
62 /* effective for B devices, ignored for A-peripheral */
63 int (*set_power)(struct otg_transceiver *otg,
64 unsigned mA);
65
66 /* for B devices only: start session with A-Host */
67 int (*start_srp)(struct otg_transceiver *otg);
68
69 /* start or continue HNP role switch */
70 int (*start_hnp)(struct otg_transceiver *otg);
71
72};
73
74
75/* for board-specific init logic */
76extern int otg_set_transceiver(struct otg_transceiver *);
77
78
79/* for usb host and peripheral controller drivers */
80extern struct otg_transceiver *otg_get_transceiver(void);
81
82static inline int
83otg_start_hnp(struct otg_transceiver *otg)
84{
85 return otg->start_hnp(otg);
86}
87
88
89/* for HCDs */
90static inline int
91otg_set_host(struct otg_transceiver *otg, struct usb_bus *host)
92{
93 return otg->set_host(otg, host);
94}
95
96
97/* for usb peripheral controller drivers */
98static inline int
99otg_set_peripheral(struct otg_transceiver *otg, struct usb_gadget *periph)
100{
101 return otg->set_peripheral(otg, periph);
102}
103
104static inline int
105otg_set_power(struct otg_transceiver *otg, unsigned mA)
106{
107 return otg->set_power(otg, mA);
108}
109
110static inline int
111otg_start_srp(struct otg_transceiver *otg)
112{
113 return otg->start_srp(otg);
114}
115
116
117/* for OTG controller drivers (and maybe other stuff) */
118extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num);
diff --git a/include/linux/usb_sl811.h b/include/linux/usb_sl811.h
new file mode 100644
index 000000000000..4f2d012d7309
--- /dev/null
+++ b/include/linux/usb_sl811.h
@@ -0,0 +1,26 @@
1
2/*
3 * board initialization should put one of these into dev->platform_data
4 * and place the sl811hs onto platform_bus named "sl811-hcd".
5 */
6
7struct sl811_platform_data {
8 unsigned can_wakeup:1;
9
10 /* given port_power, msec/2 after power on till power good */
11 u8 potpg;
12
13 /* mA/2 power supplied on this port (max = default = 250) */
14 u8 power;
15
16 /* sl811 relies on an external source of VBUS current */
17 void (*port_power)(struct device *dev, int is_on);
18
19 /* pulse sl811 nRST (probably with a GPIO) */
20 void (*reset)(struct device *dev);
21
22 // some boards need something like these:
23 // int (*check_overcurrent)(struct device *dev);
24 // void (*clock_enable)(struct device *dev, int is_on);
25};
26
diff --git a/include/linux/usbdevice_fs.h b/include/linux/usbdevice_fs.h
new file mode 100644
index 000000000000..fb57c2217468
--- /dev/null
+++ b/include/linux/usbdevice_fs.h
@@ -0,0 +1,168 @@
1/*****************************************************************************/
2
3/*
4 * usbdevice_fs.h -- USB device file system.
5 *
6 * Copyright (C) 2000
7 * Thomas Sailer (sailer@ife.ee.ethz.ch)
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 * History:
24 * 0.1 04.01.2000 Created
25 *
26 * $Id: usbdevice_fs.h,v 1.1 2000/01/06 18:40:41 tom Exp $
27 */
28
29/*****************************************************************************/
30
31#ifndef _LINUX_USBDEVICE_FS_H
32#define _LINUX_USBDEVICE_FS_H
33
34#include <linux/types.h>
35#include <linux/compat.h>
36
37/* --------------------------------------------------------------------- */
38
39#define USBDEVICE_SUPER_MAGIC 0x9fa2
40
41/* usbdevfs ioctl codes */
42
43struct usbdevfs_ctrltransfer {
44 __u8 bRequestType;
45 __u8 bRequest;
46 __u16 wValue;
47 __u16 wIndex;
48 __u16 wLength;
49 __u32 timeout; /* in milliseconds */
50 void __user *data;
51};
52
53struct usbdevfs_bulktransfer {
54 unsigned int ep;
55 unsigned int len;
56 unsigned int timeout; /* in milliseconds */
57 void __user *data;
58};
59
60struct usbdevfs_setinterface {
61 unsigned int interface;
62 unsigned int altsetting;
63};
64
65struct usbdevfs_disconnectsignal {
66 unsigned int signr;
67 void __user *context;
68};
69
70#define USBDEVFS_MAXDRIVERNAME 255
71
72struct usbdevfs_getdriver {
73 unsigned int interface;
74 char driver[USBDEVFS_MAXDRIVERNAME + 1];
75};
76
77struct usbdevfs_connectinfo {
78 unsigned int devnum;
79 unsigned char slow;
80};
81
82#define USBDEVFS_URB_SHORT_NOT_OK 1
83#define USBDEVFS_URB_ISO_ASAP 2
84
85#define USBDEVFS_URB_TYPE_ISO 0
86#define USBDEVFS_URB_TYPE_INTERRUPT 1
87#define USBDEVFS_URB_TYPE_CONTROL 2
88#define USBDEVFS_URB_TYPE_BULK 3
89
90struct usbdevfs_iso_packet_desc {
91 unsigned int length;
92 unsigned int actual_length;
93 unsigned int status;
94};
95
96struct usbdevfs_urb {
97 unsigned char type;
98 unsigned char endpoint;
99 int status;
100 unsigned int flags;
101 void __user *buffer;
102 int buffer_length;
103 int actual_length;
104 int start_frame;
105 int number_of_packets;
106 int error_count;
107 unsigned int signr; /* signal to be sent on error, -1 if none should be sent */
108 void *usercontext;
109 struct usbdevfs_iso_packet_desc iso_frame_desc[0];
110};
111
112/* ioctls for talking directly to drivers */
113struct usbdevfs_ioctl {
114 int ifno; /* interface 0..N ; negative numbers reserved */
115 int ioctl_code; /* MUST encode size + direction of data so the
116 * macros in <asm/ioctl.h> give correct values */
117 void __user *data; /* param buffer (in, or out) */
118};
119
120/* You can do most things with hubs just through control messages,
121 * except find out what device connects to what port. */
122struct usbdevfs_hub_portinfo {
123 char nports; /* number of downstream ports in this hub */
124 char port [127]; /* e.g. port 3 connects to device 27 */
125};
126
127#ifdef CONFIG_COMPAT
128struct usbdevfs_urb32 {
129 unsigned char type;
130 unsigned char endpoint;
131 compat_int_t status;
132 compat_uint_t flags;
133 compat_caddr_t buffer;
134 compat_int_t buffer_length;
135 compat_int_t actual_length;
136 compat_int_t start_frame;
137 compat_int_t number_of_packets;
138 compat_int_t error_count;
139 compat_uint_t signr;
140 compat_caddr_t usercontext; /* unused */
141 struct usbdevfs_iso_packet_desc iso_frame_desc[0];
142};
143#endif
144
145#define USBDEVFS_CONTROL _IOWR('U', 0, struct usbdevfs_ctrltransfer)
146#define USBDEVFS_BULK _IOWR('U', 2, struct usbdevfs_bulktransfer)
147#define USBDEVFS_RESETEP _IOR('U', 3, unsigned int)
148#define USBDEVFS_SETINTERFACE _IOR('U', 4, struct usbdevfs_setinterface)
149#define USBDEVFS_SETCONFIGURATION _IOR('U', 5, unsigned int)
150#define USBDEVFS_GETDRIVER _IOW('U', 8, struct usbdevfs_getdriver)
151#define USBDEVFS_SUBMITURB _IOR('U', 10, struct usbdevfs_urb)
152#define USBDEVFS_SUBMITURB32 _IOR('U', 10, struct usbdevfs_urb32)
153#define USBDEVFS_DISCARDURB _IO('U', 11)
154#define USBDEVFS_REAPURB _IOW('U', 12, void *)
155#define USBDEVFS_REAPURB32 _IOW('U', 12, u32)
156#define USBDEVFS_REAPURBNDELAY _IOW('U', 13, void *)
157#define USBDEVFS_REAPURBNDELAY32 _IOW('U', 13, u32)
158#define USBDEVFS_DISCSIGNAL _IOR('U', 14, struct usbdevfs_disconnectsignal)
159#define USBDEVFS_CLAIMINTERFACE _IOR('U', 15, unsigned int)
160#define USBDEVFS_RELEASEINTERFACE _IOR('U', 16, unsigned int)
161#define USBDEVFS_CONNECTINFO _IOW('U', 17, struct usbdevfs_connectinfo)
162#define USBDEVFS_IOCTL _IOWR('U', 18, struct usbdevfs_ioctl)
163#define USBDEVFS_HUB_PORTINFO _IOR('U', 19, struct usbdevfs_hub_portinfo)
164#define USBDEVFS_RESET _IO('U', 20)
165#define USBDEVFS_CLEAR_HALT _IOR('U', 21, unsigned int)
166#define USBDEVFS_DISCONNECT _IO('U', 22)
167#define USBDEVFS_CONNECT _IO('U', 23)
168#endif /* _LINUX_USBDEVICE_FS_H */
diff --git a/include/linux/user.h b/include/linux/user.h
new file mode 100644
index 000000000000..68daf840f6c8
--- /dev/null
+++ b/include/linux/user.h
@@ -0,0 +1 @@
#include <asm/user.h>
diff --git a/include/linux/utime.h b/include/linux/utime.h
new file mode 100644
index 000000000000..c6bf27b7897e
--- /dev/null
+++ b/include/linux/utime.h
@@ -0,0 +1,9 @@
1#ifndef _LINUX_UTIME_H
2#define _LINUX_UTIME_H
3
4struct utimbuf {
5 time_t actime;
6 time_t modtime;
7};
8
9#endif
diff --git a/include/linux/uts.h b/include/linux/uts.h
new file mode 100644
index 000000000000..73eb1ed36ec4
--- /dev/null
+++ b/include/linux/uts.h
@@ -0,0 +1,19 @@
1#ifndef _LINUX_UTS_H
2#define _LINUX_UTS_H
3
4/*
5 * Defines for what uname() should return
6 */
7#ifndef UTS_SYSNAME
8#define UTS_SYSNAME "Linux"
9#endif
10
11#ifndef UTS_NODENAME
12#define UTS_NODENAME "(none)" /* set by sethostname() */
13#endif
14
15#ifndef UTS_DOMAINNAME
16#define UTS_DOMAINNAME "(none)" /* set by setdomainname() */
17#endif
18
19#endif
diff --git a/include/linux/utsname.h b/include/linux/utsname.h
new file mode 100644
index 000000000000..13e1da0c538d
--- /dev/null
+++ b/include/linux/utsname.h
@@ -0,0 +1,36 @@
1#ifndef _LINUX_UTSNAME_H
2#define _LINUX_UTSNAME_H
3
4#define __OLD_UTS_LEN 8
5
6struct oldold_utsname {
7 char sysname[9];
8 char nodename[9];
9 char release[9];
10 char version[9];
11 char machine[9];
12};
13
14#define __NEW_UTS_LEN 64
15
16struct old_utsname {
17 char sysname[65];
18 char nodename[65];
19 char release[65];
20 char version[65];
21 char machine[65];
22};
23
24struct new_utsname {
25 char sysname[65];
26 char nodename[65];
27 char release[65];
28 char version[65];
29 char machine[65];
30 char domainname[65];
31};
32
33extern struct new_utsname system_utsname;
34
35extern struct rw_semaphore uts_sem;
36#endif
diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
new file mode 100644
index 000000000000..fadc535e2925
--- /dev/null
+++ b/include/linux/vermagic.h
@@ -0,0 +1,23 @@
1#include <linux/version.h>
2#include <linux/module.h>
3
4/* Simply sanity version stamp for modules. */
5#ifdef CONFIG_SMP
6#define MODULE_VERMAGIC_SMP "SMP "
7#else
8#define MODULE_VERMAGIC_SMP ""
9#endif
10#ifdef CONFIG_PREEMPT
11#define MODULE_VERMAGIC_PREEMPT "preempt "
12#else
13#define MODULE_VERMAGIC_PREEMPT ""
14#endif
15#ifndef MODULE_ARCH_VERMAGIC
16#define MODULE_ARCH_VERMAGIC ""
17#endif
18
19#define VERMAGIC_STRING \
20 UTS_RELEASE " " \
21 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
22 MODULE_ARCH_VERMAGIC \
23 "gcc-" __stringify(__GNUC__) "." __stringify(__GNUC_MINOR__)
diff --git a/include/linux/vfs.h b/include/linux/vfs.h
new file mode 100644
index 000000000000..e701d0541405
--- /dev/null
+++ b/include/linux/vfs.h
@@ -0,0 +1,6 @@
1#ifndef _LINUX_VFS_H
2#define _LINUX_VFS_H
3
4#include <linux/statfs.h>
5
6#endif
diff --git a/include/linux/via.h b/include/linux/via.h
new file mode 100644
index 000000000000..86ae3bcdb2ba
--- /dev/null
+++ b/include/linux/via.h
@@ -0,0 +1,22 @@
1/* Miscellaneous definitions for VIA chipsets
2 Currently used only by drivers/parport/parport_pc.c */
3
4/* Values for SuperIO function select configuration register */
5#define VIA_FUNCTION_PARPORT_SPP 0x00
6#define VIA_FUNCTION_PARPORT_ECP 0x01
7#define VIA_FUNCTION_PARPORT_EPP 0x02
8#define VIA_FUNCTION_PARPORT_DISABLE 0x03
9#define VIA_FUNCTION_PROBE 0xFF /* Special magic value to be used in code, not to be written into chip */
10
11/* Bits for parallel port mode configuration register */
12#define VIA_PARPORT_ECPEPP 0X20
13#define VIA_PARPORT_BIDIR 0x80
14
15/* VIA configuration registers */
16#define VIA_CONFIG_INDEX 0x3F0
17#define VIA_CONFIG_DATA 0x3F1
18
19/* Mask for parallel port IRQ bits (in ISA PnP IRQ routing register 1) */
20#define VIA_IRQCONTROL_PARALLEL 0xF0
21/* Mask for parallel port DMA bits (in ISA PnP DMA routing register) */
22#define VIA_DMACONTROL_PARALLEL 0x0C
diff --git a/include/linux/video_decoder.h b/include/linux/video_decoder.h
new file mode 100644
index 000000000000..0e9e48b83e3b
--- /dev/null
+++ b/include/linux/video_decoder.h
@@ -0,0 +1,44 @@
1#ifndef _LINUX_VIDEO_DECODER_H
2#define _LINUX_VIDEO_DECODER_H
3
4struct video_decoder_capability { /* this name is too long */
5 __u32 flags;
6#define VIDEO_DECODER_PAL 1 /* can decode PAL signal */
7#define VIDEO_DECODER_NTSC 2 /* can decode NTSC */
8#define VIDEO_DECODER_SECAM 4 /* can decode SECAM */
9#define VIDEO_DECODER_AUTO 8 /* can autosense norm */
10#define VIDEO_DECODER_CCIR 16 /* CCIR-601 pixel rate (720 pixels per line) instead of square pixel rate */
11 int inputs; /* number of inputs */
12 int outputs; /* number of outputs */
13};
14
15/*
16DECODER_GET_STATUS returns the following flags. The only one you need is
17DECODER_STATUS_GOOD, the others are just nice things to know.
18*/
19#define DECODER_STATUS_GOOD 1 /* receiving acceptable input */
20#define DECODER_STATUS_COLOR 2 /* receiving color information */
21#define DECODER_STATUS_PAL 4 /* auto detected */
22#define DECODER_STATUS_NTSC 8 /* auto detected */
23#define DECODER_STATUS_SECAM 16 /* auto detected */
24
25struct video_decoder_init {
26 unsigned char len;
27 const unsigned char *data;
28};
29
30#define DECODER_GET_CAPABILITIES _IOR('d', 1, struct video_decoder_capability)
31#define DECODER_GET_STATUS _IOR('d', 2, int)
32#define DECODER_SET_NORM _IOW('d', 3, int)
33#define DECODER_SET_INPUT _IOW('d', 4, int) /* 0 <= input < #inputs */
34#define DECODER_SET_OUTPUT _IOW('d', 5, int) /* 0 <= output < #outputs */
35#define DECODER_ENABLE_OUTPUT _IOW('d', 6, int) /* boolean output enable control */
36#define DECODER_SET_PICTURE _IOW('d', 7, struct video_picture)
37#define DECODER_SET_GPIO _IOW('d', 8, int) /* switch general purpose pin */
38#define DECODER_INIT _IOW('d', 9, struct video_decoder_init) /* init internal registers at once */
39#define DECODER_SET_VBI_BYPASS _IOW('d', 10, int) /* switch vbi bypass */
40
41#define DECODER_DUMP _IO('d', 192) /* debug hook */
42
43
44#endif
diff --git a/include/linux/video_encoder.h b/include/linux/video_encoder.h
new file mode 100644
index 000000000000..4b0e6907a7b4
--- /dev/null
+++ b/include/linux/video_encoder.h
@@ -0,0 +1,21 @@
1#ifndef _LINUX_VIDEO_ENCODER_H
2#define _LINUX_VIDEO_ENCODER_H
3
4struct video_encoder_capability { /* this name is too long */
5 __u32 flags;
6#define VIDEO_ENCODER_PAL 1 /* can encode PAL signal */
7#define VIDEO_ENCODER_NTSC 2 /* can encode NTSC */
8#define VIDEO_ENCODER_SECAM 4 /* can encode SECAM */
9#define VIDEO_ENCODER_CCIR 16 /* CCIR-601 pixel rate (720 pixels per line) instead of square pixel rate */
10 int inputs; /* number of inputs */
11 int outputs; /* number of outputs */
12};
13
14#define ENCODER_GET_CAPABILITIES _IOR('e', 1, struct video_encoder_capability)
15#define ENCODER_SET_NORM _IOW('e', 2, int)
16#define ENCODER_SET_INPUT _IOW('e', 3, int) /* 0 <= input < #inputs */
17#define ENCODER_SET_OUTPUT _IOW('e', 4, int) /* 0 <= output < #outputs */
18#define ENCODER_ENABLE_OUTPUT _IOW('e', 5, int) /* boolean output enable control */
19
20
21#endif
diff --git a/include/linux/videodev.h b/include/linux/videodev.h
new file mode 100644
index 000000000000..9d6fbde3d29c
--- /dev/null
+++ b/include/linux/videodev.h
@@ -0,0 +1,443 @@
1#ifndef __LINUX_VIDEODEV_H
2#define __LINUX_VIDEODEV_H
3
4#include <linux/compiler.h>
5#include <linux/types.h>
6#include <linux/version.h>
7
8#define HAVE_V4L2 1
9#include <linux/videodev2.h>
10
11#ifdef __KERNEL__
12
13#include <linux/poll.h>
14#include <linux/mm.h>
15#include <linux/device.h>
16
17struct video_device
18{
19 /* device info */
20 struct device *dev;
21 char name[32];
22 int type; /* v4l1 */
23 int type2; /* v4l2 */
24 int hardware;
25 int minor;
26
27 /* device ops + callbacks */
28 struct file_operations *fops;
29 void (*release)(struct video_device *vfd);
30
31
32#if 1 /* to be removed in 2.7.x */
33 /* obsolete -- fops->owner is used instead */
34 struct module *owner;
35 /* dev->driver_data will be used instead some day.
36 * Use the video_{get|set}_drvdata() helper functions,
37 * so the switch over will be transparent for you.
38 * Or use {pci|usb}_{get|set}_drvdata() directly. */
39 void *priv;
40#endif
41
42 /* for videodev.c intenal usage -- please don't touch */
43 int users; /* video_exclusive_{open|close} ... */
44 struct semaphore lock; /* ... helper function uses these */
45 char devfs_name[64]; /* devfs */
46 struct class_device class_dev; /* sysfs */
47};
48
49#define VIDEO_MAJOR 81
50
51#define VFL_TYPE_GRABBER 0
52#define VFL_TYPE_VBI 1
53#define VFL_TYPE_RADIO 2
54#define VFL_TYPE_VTX 3
55
56extern int video_register_device(struct video_device *, int type, int nr);
57extern void video_unregister_device(struct video_device *);
58extern struct video_device* video_devdata(struct file*);
59
60#define to_video_device(cd) container_of(cd, struct video_device, class_dev)
61static inline void
62video_device_create_file(struct video_device *vfd,
63 struct class_device_attribute *attr)
64{
65 class_device_create_file(&vfd->class_dev, attr);
66}
67static inline void
68video_device_remove_file(struct video_device *vfd,
69 struct class_device_attribute *attr)
70{
71 class_device_remove_file(&vfd->class_dev, attr);
72}
73
74/* helper functions to alloc / release struct video_device, the
75 later can be used for video_device->release() */
76struct video_device *video_device_alloc(void);
77void video_device_release(struct video_device *vfd);
78
79/* helper functions to access driver private data. */
80static inline void *video_get_drvdata(struct video_device *dev)
81{
82 return dev->priv;
83}
84
85static inline void video_set_drvdata(struct video_device *dev, void *data)
86{
87 dev->priv = data;
88}
89
90extern int video_exclusive_open(struct inode *inode, struct file *file);
91extern int video_exclusive_release(struct inode *inode, struct file *file);
92extern int video_usercopy(struct inode *inode, struct file *file,
93 unsigned int cmd, unsigned long arg,
94 int (*func)(struct inode *inode, struct file *file,
95 unsigned int cmd, void *arg));
96#endif /* __KERNEL__ */
97
98#define VID_TYPE_CAPTURE 1 /* Can capture */
99#define VID_TYPE_TUNER 2 /* Can tune */
100#define VID_TYPE_TELETEXT 4 /* Does teletext */
101#define VID_TYPE_OVERLAY 8 /* Overlay onto frame buffer */
102#define VID_TYPE_CHROMAKEY 16 /* Overlay by chromakey */
103#define VID_TYPE_CLIPPING 32 /* Can clip */
104#define VID_TYPE_FRAMERAM 64 /* Uses the frame buffer memory */
105#define VID_TYPE_SCALES 128 /* Scalable */
106#define VID_TYPE_MONOCHROME 256 /* Monochrome only */
107#define VID_TYPE_SUBCAPTURE 512 /* Can capture subareas of the image */
108#define VID_TYPE_MPEG_DECODER 1024 /* Can decode MPEG streams */
109#define VID_TYPE_MPEG_ENCODER 2048 /* Can encode MPEG streams */
110#define VID_TYPE_MJPEG_DECODER 4096 /* Can decode MJPEG streams */
111#define VID_TYPE_MJPEG_ENCODER 8192 /* Can encode MJPEG streams */
112
113struct video_capability
114{
115 char name[32];
116 int type;
117 int channels; /* Num channels */
118 int audios; /* Num audio devices */
119 int maxwidth; /* Supported width */
120 int maxheight; /* And height */
121 int minwidth; /* Supported width */
122 int minheight; /* And height */
123};
124
125
126struct video_channel
127{
128 int channel;
129 char name[32];
130 int tuners;
131 __u32 flags;
132#define VIDEO_VC_TUNER 1 /* Channel has a tuner */
133#define VIDEO_VC_AUDIO 2 /* Channel has audio */
134 __u16 type;
135#define VIDEO_TYPE_TV 1
136#define VIDEO_TYPE_CAMERA 2
137 __u16 norm; /* Norm set by channel */
138};
139
140struct video_tuner
141{
142 int tuner;
143 char name[32];
144 unsigned long rangelow, rangehigh; /* Tuner range */
145 __u32 flags;
146#define VIDEO_TUNER_PAL 1
147#define VIDEO_TUNER_NTSC 2
148#define VIDEO_TUNER_SECAM 4
149#define VIDEO_TUNER_LOW 8 /* Uses KHz not MHz */
150#define VIDEO_TUNER_NORM 16 /* Tuner can set norm */
151#define VIDEO_TUNER_STEREO_ON 128 /* Tuner is seeing stereo */
152#define VIDEO_TUNER_RDS_ON 256 /* Tuner is seeing an RDS datastream */
153#define VIDEO_TUNER_MBS_ON 512 /* Tuner is seeing an MBS datastream */
154 __u16 mode; /* PAL/NTSC/SECAM/OTHER */
155#define VIDEO_MODE_PAL 0
156#define VIDEO_MODE_NTSC 1
157#define VIDEO_MODE_SECAM 2
158#define VIDEO_MODE_AUTO 3
159 __u16 signal; /* Signal strength 16bit scale */
160};
161
162struct video_picture
163{
164 __u16 brightness;
165 __u16 hue;
166 __u16 colour;
167 __u16 contrast;
168 __u16 whiteness; /* Black and white only */
169 __u16 depth; /* Capture depth */
170 __u16 palette; /* Palette in use */
171#define VIDEO_PALETTE_GREY 1 /* Linear greyscale */
172#define VIDEO_PALETTE_HI240 2 /* High 240 cube (BT848) */
173#define VIDEO_PALETTE_RGB565 3 /* 565 16 bit RGB */
174#define VIDEO_PALETTE_RGB24 4 /* 24bit RGB */
175#define VIDEO_PALETTE_RGB32 5 /* 32bit RGB */
176#define VIDEO_PALETTE_RGB555 6 /* 555 15bit RGB */
177#define VIDEO_PALETTE_YUV422 7 /* YUV422 capture */
178#define VIDEO_PALETTE_YUYV 8
179#define VIDEO_PALETTE_UYVY 9 /* The great thing about standards is ... */
180#define VIDEO_PALETTE_YUV420 10
181#define VIDEO_PALETTE_YUV411 11 /* YUV411 capture */
182#define VIDEO_PALETTE_RAW 12 /* RAW capture (BT848) */
183#define VIDEO_PALETTE_YUV422P 13 /* YUV 4:2:2 Planar */
184#define VIDEO_PALETTE_YUV411P 14 /* YUV 4:1:1 Planar */
185#define VIDEO_PALETTE_YUV420P 15 /* YUV 4:2:0 Planar */
186#define VIDEO_PALETTE_YUV410P 16 /* YUV 4:1:0 Planar */
187#define VIDEO_PALETTE_PLANAR 13 /* start of planar entries */
188#define VIDEO_PALETTE_COMPONENT 7 /* start of component entries */
189};
190
191struct video_audio
192{
193 int audio; /* Audio channel */
194 __u16 volume; /* If settable */
195 __u16 bass, treble;
196 __u32 flags;
197#define VIDEO_AUDIO_MUTE 1
198#define VIDEO_AUDIO_MUTABLE 2
199#define VIDEO_AUDIO_VOLUME 4
200#define VIDEO_AUDIO_BASS 8
201#define VIDEO_AUDIO_TREBLE 16
202#define VIDEO_AUDIO_BALANCE 32
203 char name[16];
204#define VIDEO_SOUND_MONO 1
205#define VIDEO_SOUND_STEREO 2
206#define VIDEO_SOUND_LANG1 4
207#define VIDEO_SOUND_LANG2 8
208 __u16 mode;
209 __u16 balance; /* Stereo balance */
210 __u16 step; /* Step actual volume uses */
211};
212
213struct video_clip
214{
215 __s32 x,y;
216 __s32 width, height;
217 struct video_clip *next; /* For user use/driver use only */
218};
219
220struct video_window
221{
222 __u32 x,y; /* Position of window */
223 __u32 width,height; /* Its size */
224 __u32 chromakey;
225 __u32 flags;
226 struct video_clip __user *clips; /* Set only */
227 int clipcount;
228#define VIDEO_WINDOW_INTERLACE 1
229#define VIDEO_WINDOW_CHROMAKEY 16 /* Overlay by chromakey */
230#define VIDEO_CLIP_BITMAP -1
231/* bitmap is 1024x625, a '1' bit represents a clipped pixel */
232#define VIDEO_CLIPMAP_SIZE (128 * 625)
233};
234
235struct video_capture
236{
237 __u32 x,y; /* Offsets into image */
238 __u32 width, height; /* Area to capture */
239 __u16 decimation; /* Decimation divider */
240 __u16 flags; /* Flags for capture */
241#define VIDEO_CAPTURE_ODD 0 /* Temporal */
242#define VIDEO_CAPTURE_EVEN 1
243};
244
245struct video_buffer
246{
247 void *base;
248 int height,width;
249 int depth;
250 int bytesperline;
251};
252
253struct video_mmap
254{
255 unsigned int frame; /* Frame (0 - n) for double buffer */
256 int height,width;
257 unsigned int format; /* should be VIDEO_PALETTE_* */
258};
259
260struct video_key
261{
262 __u8 key[8];
263 __u32 flags;
264};
265
266
267#define VIDEO_MAX_FRAME 32
268
269struct video_mbuf
270{
271 int size; /* Total memory to map */
272 int frames; /* Frames */
273 int offsets[VIDEO_MAX_FRAME];
274};
275
276
277#define VIDEO_NO_UNIT (-1)
278
279
280struct video_unit
281{
282 int video; /* Video minor */
283 int vbi; /* VBI minor */
284 int radio; /* Radio minor */
285 int audio; /* Audio minor */
286 int teletext; /* Teletext minor */
287};
288
289struct vbi_format {
290 __u32 sampling_rate; /* in Hz */
291 __u32 samples_per_line;
292 __u32 sample_format; /* VIDEO_PALETTE_RAW only (1 byte) */
293 __s32 start[2]; /* starting line for each frame */
294 __u32 count[2]; /* count of lines for each frame */
295 __u32 flags;
296#define VBI_UNSYNC 1 /* can distingues between top/bottom field */
297#define VBI_INTERLACED 2 /* lines are interlaced */
298};
299
300/* video_info is biased towards hardware mpeg encode/decode */
301/* but it could apply generically to any hardware compressor/decompressor */
302struct video_info
303{
304 __u32 frame_count; /* frames output since decode/encode began */
305 __u32 h_size; /* current unscaled horizontal size */
306 __u32 v_size; /* current unscaled veritcal size */
307 __u32 smpte_timecode; /* current SMPTE timecode (for current GOP) */
308 __u32 picture_type; /* current picture type */
309 __u32 temporal_reference; /* current temporal reference */
310 __u8 user_data[256]; /* user data last found in compressed stream */
311 /* user_data[0] contains user data flags, user_data[1] has count */
312};
313
314/* generic structure for setting playback modes */
315struct video_play_mode
316{
317 int mode;
318 int p1;
319 int p2;
320};
321
322/* for loading microcode / fpga programming */
323struct video_code
324{
325 char loadwhat[16]; /* name or tag of file being passed */
326 int datasize;
327 __u8 *data;
328};
329
330#define VIDIOCGCAP _IOR('v',1,struct video_capability) /* Get capabilities */
331#define VIDIOCGCHAN _IOWR('v',2,struct video_channel) /* Get channel info (sources) */
332#define VIDIOCSCHAN _IOW('v',3,struct video_channel) /* Set channel */
333#define VIDIOCGTUNER _IOWR('v',4,struct video_tuner) /* Get tuner abilities */
334#define VIDIOCSTUNER _IOW('v',5,struct video_tuner) /* Tune the tuner for the current channel */
335#define VIDIOCGPICT _IOR('v',6,struct video_picture) /* Get picture properties */
336#define VIDIOCSPICT _IOW('v',7,struct video_picture) /* Set picture properties */
337#define VIDIOCCAPTURE _IOW('v',8,int) /* Start, end capture */
338#define VIDIOCGWIN _IOR('v',9, struct video_window) /* Get the video overlay window */
339#define VIDIOCSWIN _IOW('v',10, struct video_window) /* Set the video overlay window - passes clip list for hardware smarts , chromakey etc */
340#define VIDIOCGFBUF _IOR('v',11, struct video_buffer) /* Get frame buffer */
341#define VIDIOCSFBUF _IOW('v',12, struct video_buffer) /* Set frame buffer - root only */
342#define VIDIOCKEY _IOR('v',13, struct video_key) /* Video key event - to dev 255 is to all - cuts capture on all DMA windows with this key (0xFFFFFFFF == all) */
343#define VIDIOCGFREQ _IOR('v',14, unsigned long) /* Set tuner */
344#define VIDIOCSFREQ _IOW('v',15, unsigned long) /* Set tuner */
345#define VIDIOCGAUDIO _IOR('v',16, struct video_audio) /* Get audio info */
346#define VIDIOCSAUDIO _IOW('v',17, struct video_audio) /* Audio source, mute etc */
347#define VIDIOCSYNC _IOW('v',18, int) /* Sync with mmap grabbing */
348#define VIDIOCMCAPTURE _IOW('v',19, struct video_mmap) /* Grab frames */
349#define VIDIOCGMBUF _IOR('v',20, struct video_mbuf) /* Memory map buffer info */
350#define VIDIOCGUNIT _IOR('v',21, struct video_unit) /* Get attached units */
351#define VIDIOCGCAPTURE _IOR('v',22, struct video_capture) /* Get subcapture */
352#define VIDIOCSCAPTURE _IOW('v',23, struct video_capture) /* Set subcapture */
353#define VIDIOCSPLAYMODE _IOW('v',24, struct video_play_mode) /* Set output video mode/feature */
354#define VIDIOCSWRITEMODE _IOW('v',25, int) /* Set write mode */
355#define VIDIOCGPLAYINFO _IOR('v',26, struct video_info) /* Get current playback info from hardware */
356#define VIDIOCSMICROCODE _IOW('v',27, struct video_code) /* Load microcode into hardware */
357#define VIDIOCGVBIFMT _IOR('v',28, struct vbi_format) /* Get VBI information */
358#define VIDIOCSVBIFMT _IOW('v',29, struct vbi_format) /* Set VBI information */
359
360
361#define BASE_VIDIOCPRIVATE 192 /* 192-255 are private */
362
363/* VIDIOCSWRITEMODE */
364#define VID_WRITE_MPEG_AUD 0
365#define VID_WRITE_MPEG_VID 1
366#define VID_WRITE_OSD 2
367#define VID_WRITE_TTX 3
368#define VID_WRITE_CC 4
369#define VID_WRITE_MJPEG 5
370
371/* VIDIOCSPLAYMODE */
372#define VID_PLAY_VID_OUT_MODE 0
373 /* p1: = VIDEO_MODE_PAL, VIDEO_MODE_NTSC, etc ... */
374#define VID_PLAY_GENLOCK 1
375 /* p1: 0 = OFF, 1 = ON */
376 /* p2: GENLOCK FINE DELAY value */
377#define VID_PLAY_NORMAL 2
378#define VID_PLAY_PAUSE 3
379#define VID_PLAY_SINGLE_FRAME 4
380#define VID_PLAY_FAST_FORWARD 5
381#define VID_PLAY_SLOW_MOTION 6
382#define VID_PLAY_IMMEDIATE_NORMAL 7
383#define VID_PLAY_SWITCH_CHANNELS 8
384#define VID_PLAY_FREEZE_FRAME 9
385#define VID_PLAY_STILL_MODE 10
386#define VID_PLAY_MASTER_MODE 11
387 /* p1: see below */
388#define VID_PLAY_MASTER_NONE 1
389#define VID_PLAY_MASTER_VIDEO 2
390#define VID_PLAY_MASTER_AUDIO 3
391#define VID_PLAY_ACTIVE_SCANLINES 12
392 /* p1 = first active; p2 = last active */
393#define VID_PLAY_RESET 13
394#define VID_PLAY_END_MARK 14
395
396
397
398#define VID_HARDWARE_BT848 1
399#define VID_HARDWARE_QCAM_BW 2
400#define VID_HARDWARE_PMS 3
401#define VID_HARDWARE_QCAM_C 4
402#define VID_HARDWARE_PSEUDO 5
403#define VID_HARDWARE_SAA5249 6
404#define VID_HARDWARE_AZTECH 7
405#define VID_HARDWARE_SF16MI 8
406#define VID_HARDWARE_RTRACK 9
407#define VID_HARDWARE_ZOLTRIX 10
408#define VID_HARDWARE_SAA7146 11
409#define VID_HARDWARE_VIDEUM 12 /* Reserved for Winnov videum */
410#define VID_HARDWARE_RTRACK2 13
411#define VID_HARDWARE_PERMEDIA2 14 /* Reserved for Permedia2 */
412#define VID_HARDWARE_RIVA128 15 /* Reserved for RIVA 128 */
413#define VID_HARDWARE_PLANB 16 /* PowerMac motherboard video-in */
414#define VID_HARDWARE_BROADWAY 17 /* Broadway project */
415#define VID_HARDWARE_GEMTEK 18
416#define VID_HARDWARE_TYPHOON 19
417#define VID_HARDWARE_VINO 20 /* SGI Indy Vino */
418#define VID_HARDWARE_CADET 21 /* Cadet radio */
419#define VID_HARDWARE_TRUST 22 /* Trust FM Radio */
420#define VID_HARDWARE_TERRATEC 23 /* TerraTec ActiveRadio */
421#define VID_HARDWARE_CPIA 24
422#define VID_HARDWARE_ZR36120 25 /* Zoran ZR36120/ZR36125 */
423#define VID_HARDWARE_ZR36067 26 /* Zoran ZR36067/36060 */
424#define VID_HARDWARE_OV511 27
425#define VID_HARDWARE_ZR356700 28 /* Zoran 36700 series */
426#define VID_HARDWARE_W9966 29
427#define VID_HARDWARE_SE401 30 /* SE401 USB webcams */
428#define VID_HARDWARE_PWC 31 /* Philips webcams */
429#define VID_HARDWARE_MEYE 32 /* Sony Vaio MotionEye cameras */
430#define VID_HARDWARE_CPIA2 33
431#define VID_HARDWARE_VICAM 34
432#define VID_HARDWARE_SF16FMR2 35
433#define VID_HARDWARE_W9968CF 36
434#define VID_HARDWARE_SAA7114H 37
435#define VID_HARDWARE_SN9C102 38
436#define VID_HARDWARE_ARV 39
437#endif /* __LINUX_VIDEODEV_H */
438
439/*
440 * Local variables:
441 * c-basic-offset: 8
442 * End:
443 */
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
new file mode 100644
index 000000000000..4e0edce53760
--- /dev/null
+++ b/include/linux/videodev2.h
@@ -0,0 +1,977 @@
1#ifndef __LINUX_VIDEODEV2_H
2#define __LINUX_VIDEODEV2_H
3/*
4 * Video for Linux Two
5 *
6 * Header file for v4l or V4L2 drivers and applications, for
7 * Linux kernels 2.2.x or 2.4.x.
8 *
9 * See http://bytesex.org/v4l/ for API specs and other
10 * v4l2 documentation.
11 *
12 * Author: Bill Dirks <bdirks@pacbell.net>
13 * Justin Schoeman
14 * et al.
15 */
16#ifdef __KERNEL__
17#include <linux/time.h> /* need struct timeval */
18#endif
19#include <linux/compiler.h> /* need __user */
20
21/*
22 * M I S C E L L A N E O U S
23 */
24
25/* Four-character-code (FOURCC) */
26#define v4l2_fourcc(a,b,c,d)\
27 (((__u32)(a)<<0)|((__u32)(b)<<8)|((__u32)(c)<<16)|((__u32)(d)<<24))
28
29/*
30 * E N U M S
31 */
32enum v4l2_field {
33 V4L2_FIELD_ANY = 0, /* driver can choose from none,
34 top, bottom, interlaced
35 depending on whatever it thinks
36 is approximate ... */
37 V4L2_FIELD_NONE = 1, /* this device has no fields ... */
38 V4L2_FIELD_TOP = 2, /* top field only */
39 V4L2_FIELD_BOTTOM = 3, /* bottom field only */
40 V4L2_FIELD_INTERLACED = 4, /* both fields interlaced */
41 V4L2_FIELD_SEQ_TB = 5, /* both fields sequential into one
42 buffer, top-bottom order */
43 V4L2_FIELD_SEQ_BT = 6, /* same as above + bottom-top order */
44 V4L2_FIELD_ALTERNATE = 7, /* both fields alternating into
45 separate buffers */
46};
47#define V4L2_FIELD_HAS_TOP(field) \
48 ((field) == V4L2_FIELD_TOP ||\
49 (field) == V4L2_FIELD_INTERLACED ||\
50 (field) == V4L2_FIELD_SEQ_TB ||\
51 (field) == V4L2_FIELD_SEQ_BT)
52#define V4L2_FIELD_HAS_BOTTOM(field) \
53 ((field) == V4L2_FIELD_BOTTOM ||\
54 (field) == V4L2_FIELD_INTERLACED ||\
55 (field) == V4L2_FIELD_SEQ_TB ||\
56 (field) == V4L2_FIELD_SEQ_BT)
57#define V4L2_FIELD_HAS_BOTH(field) \
58 ((field) == V4L2_FIELD_INTERLACED ||\
59 (field) == V4L2_FIELD_SEQ_TB ||\
60 (field) == V4L2_FIELD_SEQ_BT)
61
62enum v4l2_buf_type {
63 V4L2_BUF_TYPE_VIDEO_CAPTURE = 1,
64 V4L2_BUF_TYPE_VIDEO_OUTPUT = 2,
65 V4L2_BUF_TYPE_VIDEO_OVERLAY = 3,
66 V4L2_BUF_TYPE_VBI_CAPTURE = 4,
67 V4L2_BUF_TYPE_VBI_OUTPUT = 5,
68 V4L2_BUF_TYPE_PRIVATE = 0x80,
69};
70
71enum v4l2_ctrl_type {
72 V4L2_CTRL_TYPE_INTEGER = 1,
73 V4L2_CTRL_TYPE_BOOLEAN = 2,
74 V4L2_CTRL_TYPE_MENU = 3,
75 V4L2_CTRL_TYPE_BUTTON = 4,
76};
77
78enum v4l2_tuner_type {
79 V4L2_TUNER_RADIO = 1,
80 V4L2_TUNER_ANALOG_TV = 2,
81 V4L2_TUNER_DIGITAL_TV = 3,
82};
83
84enum v4l2_memory {
85 V4L2_MEMORY_MMAP = 1,
86 V4L2_MEMORY_USERPTR = 2,
87 V4L2_MEMORY_OVERLAY = 3,
88};
89
90/* see also http://vektor.theorem.ca/graphics/ycbcr/ */
91enum v4l2_colorspace {
92 /* ITU-R 601 -- broadcast NTSC/PAL */
93 V4L2_COLORSPACE_SMPTE170M = 1,
94
95 /* 1125-Line (US) HDTV */
96 V4L2_COLORSPACE_SMPTE240M = 2,
97
98 /* HD and modern captures. */
99 V4L2_COLORSPACE_REC709 = 3,
100
101 /* broken BT878 extents (601, luma range 16-253 instead of 16-235) */
102 V4L2_COLORSPACE_BT878 = 4,
103
104 /* These should be useful. Assume 601 extents. */
105 V4L2_COLORSPACE_470_SYSTEM_M = 5,
106 V4L2_COLORSPACE_470_SYSTEM_BG = 6,
107
108 /* I know there will be cameras that send this. So, this is
109 * unspecified chromaticities and full 0-255 on each of the
110 * Y'CbCr components
111 */
112 V4L2_COLORSPACE_JPEG = 7,
113
114 /* For RGB colourspaces, this is probably a good start. */
115 V4L2_COLORSPACE_SRGB = 8,
116};
117
118enum v4l2_priority {
119 V4L2_PRIORITY_UNSET = 0, /* not initialized */
120 V4L2_PRIORITY_BACKGROUND = 1,
121 V4L2_PRIORITY_INTERACTIVE = 2,
122 V4L2_PRIORITY_RECORD = 3,
123 V4L2_PRIORITY_DEFAULT = V4L2_PRIORITY_INTERACTIVE,
124};
125
126struct v4l2_rect {
127 __s32 left;
128 __s32 top;
129 __s32 width;
130 __s32 height;
131};
132
133struct v4l2_fract {
134 __u32 numerator;
135 __u32 denominator;
136};
137
138/*
139 * D R I V E R C A P A B I L I T I E S
140 */
141struct v4l2_capability
142{
143 __u8 driver[16]; /* i.e. "bttv" */
144 __u8 card[32]; /* i.e. "Hauppauge WinTV" */
145 __u8 bus_info[32]; /* "PCI:" + pci_name(pci_dev) */
146 __u32 version; /* should use KERNEL_VERSION() */
147 __u32 capabilities; /* Device capabilities */
148 __u32 reserved[4];
149};
150
151/* Values for 'capabilities' field */
152#define V4L2_CAP_VIDEO_CAPTURE 0x00000001 /* Is a video capture device */
153#define V4L2_CAP_VIDEO_OUTPUT 0x00000002 /* Is a video output device */
154#define V4L2_CAP_VIDEO_OVERLAY 0x00000004 /* Can do video overlay */
155#define V4L2_CAP_VBI_CAPTURE 0x00000010 /* Is a VBI capture device */
156#define V4L2_CAP_VBI_OUTPUT 0x00000020 /* Is a VBI output device */
157#define V4L2_CAP_RDS_CAPTURE 0x00000100 /* RDS data capture */
158
159#define V4L2_CAP_TUNER 0x00010000 /* has a tuner */
160#define V4L2_CAP_AUDIO 0x00020000 /* has audio support */
161#define V4L2_CAP_RADIO 0x00040000 /* is a radio device */
162
163#define V4L2_CAP_READWRITE 0x01000000 /* read/write systemcalls */
164#define V4L2_CAP_ASYNCIO 0x02000000 /* async I/O */
165#define V4L2_CAP_STREAMING 0x04000000 /* streaming I/O ioctls */
166
167/*
168 * V I D E O I M A G E F O R M A T
169 */
170
171struct v4l2_pix_format
172{
173 __u32 width;
174 __u32 height;
175 __u32 pixelformat;
176 enum v4l2_field field;
177 __u32 bytesperline; /* for padding, zero if unused */
178 __u32 sizeimage;
179 enum v4l2_colorspace colorspace;
180 __u32 priv; /* private data, depends on pixelformat */
181};
182
183/* Pixel format FOURCC depth Description */
184#define V4L2_PIX_FMT_RGB332 v4l2_fourcc('R','G','B','1') /* 8 RGB-3-3-2 */
185#define V4L2_PIX_FMT_RGB555 v4l2_fourcc('R','G','B','O') /* 16 RGB-5-5-5 */
186#define V4L2_PIX_FMT_RGB565 v4l2_fourcc('R','G','B','P') /* 16 RGB-5-6-5 */
187#define V4L2_PIX_FMT_RGB555X v4l2_fourcc('R','G','B','Q') /* 16 RGB-5-5-5 BE */
188#define V4L2_PIX_FMT_RGB565X v4l2_fourcc('R','G','B','R') /* 16 RGB-5-6-5 BE */
189#define V4L2_PIX_FMT_BGR24 v4l2_fourcc('B','G','R','3') /* 24 BGR-8-8-8 */
190#define V4L2_PIX_FMT_RGB24 v4l2_fourcc('R','G','B','3') /* 24 RGB-8-8-8 */
191#define V4L2_PIX_FMT_BGR32 v4l2_fourcc('B','G','R','4') /* 32 BGR-8-8-8-8 */
192#define V4L2_PIX_FMT_RGB32 v4l2_fourcc('R','G','B','4') /* 32 RGB-8-8-8-8 */
193#define V4L2_PIX_FMT_GREY v4l2_fourcc('G','R','E','Y') /* 8 Greyscale */
194#define V4L2_PIX_FMT_YVU410 v4l2_fourcc('Y','V','U','9') /* 9 YVU 4:1:0 */
195#define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y','V','1','2') /* 12 YVU 4:2:0 */
196#define V4L2_PIX_FMT_YUYV v4l2_fourcc('Y','U','Y','V') /* 16 YUV 4:2:2 */
197#define V4L2_PIX_FMT_UYVY v4l2_fourcc('U','Y','V','Y') /* 16 YUV 4:2:2 */
198#define V4L2_PIX_FMT_YUV422P v4l2_fourcc('4','2','2','P') /* 16 YVU422 planar */
199#define V4L2_PIX_FMT_YUV411P v4l2_fourcc('4','1','1','P') /* 16 YVU411 planar */
200#define V4L2_PIX_FMT_Y41P v4l2_fourcc('Y','4','1','P') /* 12 YUV 4:1:1 */
201
202/* two planes -- one Y, one Cr + Cb interleaved */
203#define V4L2_PIX_FMT_NV12 v4l2_fourcc('N','V','1','2') /* 12 Y/CbCr 4:2:0 */
204#define V4L2_PIX_FMT_NV21 v4l2_fourcc('N','V','2','1') /* 12 Y/CrCb 4:2:0 */
205
206/* The following formats are not defined in the V4L2 specification */
207#define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y','U','V','9') /* 9 YUV 4:1:0 */
208#define V4L2_PIX_FMT_YUV420 v4l2_fourcc('Y','U','1','2') /* 12 YUV 4:2:0 */
209#define V4L2_PIX_FMT_YYUV v4l2_fourcc('Y','Y','U','V') /* 16 YUV 4:2:2 */
210#define V4L2_PIX_FMT_HI240 v4l2_fourcc('H','I','2','4') /* 8 8-bit color */
211
212/* see http://www.siliconimaging.com/RGB%20Bayer.htm */
213#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B','A','8','1') /* 8 BGBG.. GRGR.. */
214
215/* compressed formats */
216#define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M','J','P','G') /* Motion-JPEG */
217#define V4L2_PIX_FMT_JPEG v4l2_fourcc('J','P','E','G') /* JFIF JPEG */
218#define V4L2_PIX_FMT_DV v4l2_fourcc('d','v','s','d') /* 1394 */
219#define V4L2_PIX_FMT_MPEG v4l2_fourcc('M','P','E','G') /* MPEG */
220
221/* Vendor-specific formats */
222#define V4L2_PIX_FMT_WNVA v4l2_fourcc('W','N','V','A') /* Winnov hw compress */
223#define V4L2_PIX_FMT_SN9C10X v4l2_fourcc('S','9','1','0') /* SN9C10x compression */
224
225/*
226 * F O R M A T E N U M E R A T I O N
227 */
228struct v4l2_fmtdesc
229{
230 __u32 index; /* Format number */
231 enum v4l2_buf_type type; /* buffer type */
232 __u32 flags;
233 __u8 description[32]; /* Description string */
234 __u32 pixelformat; /* Format fourcc */
235 __u32 reserved[4];
236};
237
238#define V4L2_FMT_FLAG_COMPRESSED 0x0001
239
240
241/*
242 * T I M E C O D E
243 */
244struct v4l2_timecode
245{
246 __u32 type;
247 __u32 flags;
248 __u8 frames;
249 __u8 seconds;
250 __u8 minutes;
251 __u8 hours;
252 __u8 userbits[4];
253};
254
255/* Type */
256#define V4L2_TC_TYPE_24FPS 1
257#define V4L2_TC_TYPE_25FPS 2
258#define V4L2_TC_TYPE_30FPS 3
259#define V4L2_TC_TYPE_50FPS 4
260#define V4L2_TC_TYPE_60FPS 5
261
262/* Flags */
263#define V4L2_TC_FLAG_DROPFRAME 0x0001 /* "drop-frame" mode */
264#define V4L2_TC_FLAG_COLORFRAME 0x0002
265#define V4L2_TC_USERBITS_field 0x000C
266#define V4L2_TC_USERBITS_USERDEFINED 0x0000
267#define V4L2_TC_USERBITS_8BITCHARS 0x0008
268/* The above is based on SMPTE timecodes */
269
270
271#if 1
272/*
273 * M P E G C O M P R E S S I O N P A R A M E T E R S
274 *
275 * ### WARNING: this is still work-in-progress right now, most likely
276 * ### there will be some incompatible changes.
277 *
278 */
279
280
281enum v4l2_bitrate_mode {
282 V4L2_BITRATE_NONE = 0, /* not specified */
283 V4L2_BITRATE_CBR, /* constant bitrate */
284 V4L2_BITRATE_VBR, /* variable bitrate */
285};
286struct v4l2_bitrate {
287 /* rates are specified in kbit/sec */
288 enum v4l2_bitrate_mode mode;
289 __u32 min;
290 __u32 target; /* use this one for CBR */
291 __u32 max;
292};
293
294enum v4l2_mpeg_streamtype {
295 V4L2_MPEG_SS_1, /* MPEG-1 system stream */
296 V4L2_MPEG_PS_2, /* MPEG-2 program stream */
297 V4L2_MPEG_TS_2, /* MPEG-2 transport stream */
298 V4L2_MPEG_PS_DVD, /* MPEG-2 program stream with DVD header fixups */
299};
300enum v4l2_mpeg_audiotype {
301 V4L2_MPEG_AU_2_I, /* MPEG-2 layer 1 */
302 V4L2_MPEG_AU_2_II, /* MPEG-2 layer 2 */
303 V4L2_MPEG_AU_2_III, /* MPEG-2 layer 3 */
304 V4L2_MPEG_AC3, /* AC3 */
305 V4L2_MPEG_LPCM, /* LPCM */
306};
307enum v4l2_mpeg_videotype {
308 V4L2_MPEG_VI_1, /* MPEG-1 */
309 V4L2_MPEG_VI_2, /* MPEG-2 */
310};
311enum v4l2_mpeg_aspectratio {
312 V4L2_MPEG_ASPECT_SQUARE = 1, /* square pixel */
313 V4L2_MPEG_ASPECT_4_3 = 2, /* 4 : 3 */
314 V4L2_MPEG_ASPECT_16_9 = 3, /* 16 : 9 */
315 V4L2_MPEG_ASPECT_1_221 = 4, /* 1 : 2,21 */
316};
317
318struct v4l2_mpeg_compression {
319 /* general */
320 enum v4l2_mpeg_streamtype st_type;
321 struct v4l2_bitrate st_bitrate;
322
323 /* transport streams */
324 __u16 ts_pid_pmt;
325 __u16 ts_pid_audio;
326 __u16 ts_pid_video;
327 __u16 ts_pid_pcr;
328
329 /* program stream */
330 __u16 ps_size;
331 __u16 reserved_1; /* align */
332
333 /* audio */
334 enum v4l2_mpeg_audiotype au_type;
335 struct v4l2_bitrate au_bitrate;
336 __u32 au_sample_rate;
337 __u8 au_pesid;
338 __u8 reserved_2[3]; /* align */
339
340 /* video */
341 enum v4l2_mpeg_videotype vi_type;
342 enum v4l2_mpeg_aspectratio vi_aspect_ratio;
343 struct v4l2_bitrate vi_bitrate;
344 __u32 vi_frame_rate;
345 __u16 vi_frames_per_gop;
346 __u16 vi_bframes_count;
347 __u8 vi_pesid;
348 __u8 reserved_3[3]; /* align */
349
350 /* misc flags */
351 __u32 closed_gops:1;
352 __u32 pulldown:1;
353 __u32 reserved_4:30; /* align */
354
355 /* I don't expect the above being perfect yet ;) */
356 __u32 reserved_5[8];
357};
358#endif
359
360struct v4l2_jpegcompression
361{
362 int quality;
363
364 int APPn; /* Number of APP segment to be written,
365 * must be 0..15 */
366 int APP_len; /* Length of data in JPEG APPn segment */
367 char APP_data[60]; /* Data in the JPEG APPn segment. */
368
369 int COM_len; /* Length of data in JPEG COM segment */
370 char COM_data[60]; /* Data in JPEG COM segment */
371
372 __u32 jpeg_markers; /* Which markers should go into the JPEG
373 * output. Unless you exactly know what
374 * you do, leave them untouched.
375 * Inluding less markers will make the
376 * resulting code smaller, but there will
377 * be fewer aplications which can read it.
378 * The presence of the APP and COM marker
379 * is influenced by APP_len and COM_len
380 * ONLY, not by this property! */
381
382#define V4L2_JPEG_MARKER_DHT (1<<3) /* Define Huffman Tables */
383#define V4L2_JPEG_MARKER_DQT (1<<4) /* Define Quantization Tables */
384#define V4L2_JPEG_MARKER_DRI (1<<5) /* Define Restart Interval */
385#define V4L2_JPEG_MARKER_COM (1<<6) /* Comment segment */
386#define V4L2_JPEG_MARKER_APP (1<<7) /* App segment, driver will
387 * allways use APP0 */
388};
389
390
391/*
392 * M E M O R Y - M A P P I N G B U F F E R S
393 */
394struct v4l2_requestbuffers
395{
396 __u32 count;
397 enum v4l2_buf_type type;
398 enum v4l2_memory memory;
399 __u32 reserved[2];
400};
401
402struct v4l2_buffer
403{
404 __u32 index;
405 enum v4l2_buf_type type;
406 __u32 bytesused;
407 __u32 flags;
408 enum v4l2_field field;
409 struct timeval timestamp;
410 struct v4l2_timecode timecode;
411 __u32 sequence;
412
413 /* memory location */
414 enum v4l2_memory memory;
415 union {
416 __u32 offset;
417 unsigned long userptr;
418 } m;
419 __u32 length;
420 __u32 input;
421 __u32 reserved;
422};
423
424/* Flags for 'flags' field */
425#define V4L2_BUF_FLAG_MAPPED 0x0001 /* Buffer is mapped (flag) */
426#define V4L2_BUF_FLAG_QUEUED 0x0002 /* Buffer is queued for processing */
427#define V4L2_BUF_FLAG_DONE 0x0004 /* Buffer is ready */
428#define V4L2_BUF_FLAG_KEYFRAME 0x0008 /* Image is a keyframe (I-frame) */
429#define V4L2_BUF_FLAG_PFRAME 0x0010 /* Image is a P-frame */
430#define V4L2_BUF_FLAG_BFRAME 0x0020 /* Image is a B-frame */
431#define V4L2_BUF_FLAG_TIMECODE 0x0100 /* timecode field is valid */
432#define V4L2_BUF_FLAG_INPUT 0x0200 /* input field is valid */
433
434/*
435 * O V E R L A Y P R E V I E W
436 */
437struct v4l2_framebuffer
438{
439 __u32 capability;
440 __u32 flags;
441/* FIXME: in theory we should pass something like PCI device + memory
442 * region + offset instead of some physical address */
443 void* base;
444 struct v4l2_pix_format fmt;
445};
446/* Flags for the 'capability' field. Read only */
447#define V4L2_FBUF_CAP_EXTERNOVERLAY 0x0001
448#define V4L2_FBUF_CAP_CHROMAKEY 0x0002
449#define V4L2_FBUF_CAP_LIST_CLIPPING 0x0004
450#define V4L2_FBUF_CAP_BITMAP_CLIPPING 0x0008
451/* Flags for the 'flags' field. */
452#define V4L2_FBUF_FLAG_PRIMARY 0x0001
453#define V4L2_FBUF_FLAG_OVERLAY 0x0002
454#define V4L2_FBUF_FLAG_CHROMAKEY 0x0004
455
456struct v4l2_clip
457{
458 struct v4l2_rect c;
459 struct v4l2_clip *next;
460};
461
462struct v4l2_window
463{
464 struct v4l2_rect w;
465 enum v4l2_field field;
466 __u32 chromakey;
467 struct v4l2_clip __user *clips;
468 __u32 clipcount;
469 void __user *bitmap;
470};
471
472
473/*
474 * C A P T U R E P A R A M E T E R S
475 */
476struct v4l2_captureparm
477{
478 __u32 capability; /* Supported modes */
479 __u32 capturemode; /* Current mode */
480 struct v4l2_fract timeperframe; /* Time per frame in .1us units */
481 __u32 extendedmode; /* Driver-specific extensions */
482 __u32 readbuffers; /* # of buffers for read */
483 __u32 reserved[4];
484};
485/* Flags for 'capability' and 'capturemode' fields */
486#define V4L2_MODE_HIGHQUALITY 0x0001 /* High quality imaging mode */
487#define V4L2_CAP_TIMEPERFRAME 0x1000 /* timeperframe field is supported */
488
489struct v4l2_outputparm
490{
491 __u32 capability; /* Supported modes */
492 __u32 outputmode; /* Current mode */
493 struct v4l2_fract timeperframe; /* Time per frame in seconds */
494 __u32 extendedmode; /* Driver-specific extensions */
495 __u32 writebuffers; /* # of buffers for write */
496 __u32 reserved[4];
497};
498
499/*
500 * I N P U T I M A G E C R O P P I N G
501 */
502
503struct v4l2_cropcap {
504 enum v4l2_buf_type type;
505 struct v4l2_rect bounds;
506 struct v4l2_rect defrect;
507 struct v4l2_fract pixelaspect;
508};
509
510struct v4l2_crop {
511 enum v4l2_buf_type type;
512 struct v4l2_rect c;
513};
514
515/*
516 * A N A L O G V I D E O S T A N D A R D
517 */
518
519typedef __u64 v4l2_std_id;
520
521/* one bit for each */
522#define V4L2_STD_PAL_B ((v4l2_std_id)0x00000001)
523#define V4L2_STD_PAL_B1 ((v4l2_std_id)0x00000002)
524#define V4L2_STD_PAL_G ((v4l2_std_id)0x00000004)
525#define V4L2_STD_PAL_H ((v4l2_std_id)0x00000008)
526#define V4L2_STD_PAL_I ((v4l2_std_id)0x00000010)
527#define V4L2_STD_PAL_D ((v4l2_std_id)0x00000020)
528#define V4L2_STD_PAL_D1 ((v4l2_std_id)0x00000040)
529#define V4L2_STD_PAL_K ((v4l2_std_id)0x00000080)
530
531#define V4L2_STD_PAL_M ((v4l2_std_id)0x00000100)
532#define V4L2_STD_PAL_N ((v4l2_std_id)0x00000200)
533#define V4L2_STD_PAL_Nc ((v4l2_std_id)0x00000400)
534#define V4L2_STD_PAL_60 ((v4l2_std_id)0x00000800)
535
536#define V4L2_STD_NTSC_M ((v4l2_std_id)0x00001000)
537#define V4L2_STD_NTSC_M_JP ((v4l2_std_id)0x00002000)
538
539#define V4L2_STD_SECAM_B ((v4l2_std_id)0x00010000)
540#define V4L2_STD_SECAM_D ((v4l2_std_id)0x00020000)
541#define V4L2_STD_SECAM_G ((v4l2_std_id)0x00040000)
542#define V4L2_STD_SECAM_H ((v4l2_std_id)0x00080000)
543#define V4L2_STD_SECAM_K ((v4l2_std_id)0x00100000)
544#define V4L2_STD_SECAM_K1 ((v4l2_std_id)0x00200000)
545#define V4L2_STD_SECAM_L ((v4l2_std_id)0x00400000)
546
547/* ATSC/HDTV */
548#define V4L2_STD_ATSC_8_VSB ((v4l2_std_id)0x01000000)
549#define V4L2_STD_ATSC_16_VSB ((v4l2_std_id)0x02000000)
550
551/* some common needed stuff */
552#define V4L2_STD_PAL_BG (V4L2_STD_PAL_B |\
553 V4L2_STD_PAL_B1 |\
554 V4L2_STD_PAL_G)
555#define V4L2_STD_PAL_DK (V4L2_STD_PAL_D |\
556 V4L2_STD_PAL_D1 |\
557 V4L2_STD_PAL_K)
558#define V4L2_STD_PAL (V4L2_STD_PAL_BG |\
559 V4L2_STD_PAL_DK |\
560 V4L2_STD_PAL_H |\
561 V4L2_STD_PAL_I)
562#define V4L2_STD_NTSC (V4L2_STD_NTSC_M |\
563 V4L2_STD_NTSC_M_JP)
564#define V4L2_STD_SECAM_DK (V4L2_STD_SECAM_D |\
565 V4L2_STD_SECAM_K |\
566 V4L2_STD_SECAM_K1)
567#define V4L2_STD_SECAM (V4L2_STD_SECAM_B |\
568 V4L2_STD_SECAM_G |\
569 V4L2_STD_SECAM_H |\
570 V4L2_STD_SECAM_DK |\
571 V4L2_STD_SECAM_L)
572
573#define V4L2_STD_525_60 (V4L2_STD_PAL_M |\
574 V4L2_STD_PAL_60 |\
575 V4L2_STD_NTSC)
576#define V4L2_STD_625_50 (V4L2_STD_PAL |\
577 V4L2_STD_PAL_N |\
578 V4L2_STD_PAL_Nc |\
579 V4L2_STD_SECAM)
580#define V4L2_STD_ATSC (V4L2_STD_ATSC_8_VSB |\
581 V4L2_STD_ATSC_16_VSB)
582
583#define V4L2_STD_UNKNOWN 0
584#define V4L2_STD_ALL (V4L2_STD_525_60 |\
585 V4L2_STD_625_50)
586
587struct v4l2_standard
588{
589 __u32 index;
590 v4l2_std_id id;
591 __u8 name[24];
592 struct v4l2_fract frameperiod; /* Frames, not fields */
593 __u32 framelines;
594 __u32 reserved[4];
595};
596
597
598/*
599 * V I D E O I N P U T S
600 */
601struct v4l2_input
602{
603 __u32 index; /* Which input */
604 __u8 name[32]; /* Label */
605 __u32 type; /* Type of input */
606 __u32 audioset; /* Associated audios (bitfield) */
607 __u32 tuner; /* Associated tuner */
608 v4l2_std_id std;
609 __u32 status;
610 __u32 reserved[4];
611};
612/* Values for the 'type' field */
613#define V4L2_INPUT_TYPE_TUNER 1
614#define V4L2_INPUT_TYPE_CAMERA 2
615
616/* field 'status' - general */
617#define V4L2_IN_ST_NO_POWER 0x00000001 /* Attached device is off */
618#define V4L2_IN_ST_NO_SIGNAL 0x00000002
619#define V4L2_IN_ST_NO_COLOR 0x00000004
620
621/* field 'status' - analog */
622#define V4L2_IN_ST_NO_H_LOCK 0x00000100 /* No horizontal sync lock */
623#define V4L2_IN_ST_COLOR_KILL 0x00000200 /* Color killer is active */
624
625/* field 'status' - digital */
626#define V4L2_IN_ST_NO_SYNC 0x00010000 /* No synchronization lock */
627#define V4L2_IN_ST_NO_EQU 0x00020000 /* No equalizer lock */
628#define V4L2_IN_ST_NO_CARRIER 0x00040000 /* Carrier recovery failed */
629
630/* field 'status' - VCR and set-top box */
631#define V4L2_IN_ST_MACROVISION 0x01000000 /* Macrovision detected */
632#define V4L2_IN_ST_NO_ACCESS 0x02000000 /* Conditional access denied */
633#define V4L2_IN_ST_VTR 0x04000000 /* VTR time constant */
634
635/*
636 * V I D E O O U T P U T S
637 */
638struct v4l2_output
639{
640 __u32 index; /* Which output */
641 __u8 name[32]; /* Label */
642 __u32 type; /* Type of output */
643 __u32 audioset; /* Associated audios (bitfield) */
644 __u32 modulator; /* Associated modulator */
645 v4l2_std_id std;
646 __u32 reserved[4];
647};
648/* Values for the 'type' field */
649#define V4L2_OUTPUT_TYPE_MODULATOR 1
650#define V4L2_OUTPUT_TYPE_ANALOG 2
651#define V4L2_OUTPUT_TYPE_ANALOGVGAOVERLAY 3
652
653/*
654 * C O N T R O L S
655 */
656struct v4l2_control
657{
658 __u32 id;
659 __s32 value;
660};
661
662/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */
663struct v4l2_queryctrl
664{
665 __u32 id;
666 enum v4l2_ctrl_type type;
667 __u8 name[32]; /* Whatever */
668 __s32 minimum; /* Note signedness */
669 __s32 maximum;
670 __s32 step;
671 __s32 default_value;
672 __u32 flags;
673 __u32 reserved[2];
674};
675
676/* Used in the VIDIOC_QUERYMENU ioctl for querying menu items */
677struct v4l2_querymenu
678{
679 __u32 id;
680 __u32 index;
681 __u8 name[32]; /* Whatever */
682 __u32 reserved;
683};
684
685/* Control flags */
686#define V4L2_CTRL_FLAG_DISABLED 0x0001
687#define V4L2_CTRL_FLAG_GRABBED 0x0002
688
689/* Control IDs defined by V4L2 */
690#define V4L2_CID_BASE 0x00980900
691/* IDs reserved for driver specific controls */
692#define V4L2_CID_PRIVATE_BASE 0x08000000
693
694#define V4L2_CID_BRIGHTNESS (V4L2_CID_BASE+0)
695#define V4L2_CID_CONTRAST (V4L2_CID_BASE+1)
696#define V4L2_CID_SATURATION (V4L2_CID_BASE+2)
697#define V4L2_CID_HUE (V4L2_CID_BASE+3)
698#define V4L2_CID_AUDIO_VOLUME (V4L2_CID_BASE+5)
699#define V4L2_CID_AUDIO_BALANCE (V4L2_CID_BASE+6)
700#define V4L2_CID_AUDIO_BASS (V4L2_CID_BASE+7)
701#define V4L2_CID_AUDIO_TREBLE (V4L2_CID_BASE+8)
702#define V4L2_CID_AUDIO_MUTE (V4L2_CID_BASE+9)
703#define V4L2_CID_AUDIO_LOUDNESS (V4L2_CID_BASE+10)
704#define V4L2_CID_BLACK_LEVEL (V4L2_CID_BASE+11)
705#define V4L2_CID_AUTO_WHITE_BALANCE (V4L2_CID_BASE+12)
706#define V4L2_CID_DO_WHITE_BALANCE (V4L2_CID_BASE+13)
707#define V4L2_CID_RED_BALANCE (V4L2_CID_BASE+14)
708#define V4L2_CID_BLUE_BALANCE (V4L2_CID_BASE+15)
709#define V4L2_CID_GAMMA (V4L2_CID_BASE+16)
710#define V4L2_CID_WHITENESS (V4L2_CID_GAMMA) /* ? Not sure */
711#define V4L2_CID_EXPOSURE (V4L2_CID_BASE+17)
712#define V4L2_CID_AUTOGAIN (V4L2_CID_BASE+18)
713#define V4L2_CID_GAIN (V4L2_CID_BASE+19)
714#define V4L2_CID_HFLIP (V4L2_CID_BASE+20)
715#define V4L2_CID_VFLIP (V4L2_CID_BASE+21)
716#define V4L2_CID_HCENTER (V4L2_CID_BASE+22)
717#define V4L2_CID_VCENTER (V4L2_CID_BASE+23)
718#define V4L2_CID_LASTP1 (V4L2_CID_BASE+24) /* last CID + 1 */
719
720/*
721 * T U N I N G
722 */
723struct v4l2_tuner
724{
725 __u32 index;
726 __u8 name[32];
727 enum v4l2_tuner_type type;
728 __u32 capability;
729 __u32 rangelow;
730 __u32 rangehigh;
731 __u32 rxsubchans;
732 __u32 audmode;
733 __s32 signal;
734 __s32 afc;
735 __u32 reserved[4];
736};
737
738struct v4l2_modulator
739{
740 __u32 index;
741 __u8 name[32];
742 __u32 capability;
743 __u32 rangelow;
744 __u32 rangehigh;
745 __u32 txsubchans;
746 __u32 reserved[4];
747};
748
749/* Flags for the 'capability' field */
750#define V4L2_TUNER_CAP_LOW 0x0001
751#define V4L2_TUNER_CAP_NORM 0x0002
752#define V4L2_TUNER_CAP_STEREO 0x0010
753#define V4L2_TUNER_CAP_LANG2 0x0020
754#define V4L2_TUNER_CAP_SAP 0x0020
755#define V4L2_TUNER_CAP_LANG1 0x0040
756
757/* Flags for the 'rxsubchans' field */
758#define V4L2_TUNER_SUB_MONO 0x0001
759#define V4L2_TUNER_SUB_STEREO 0x0002
760#define V4L2_TUNER_SUB_LANG2 0x0004
761#define V4L2_TUNER_SUB_SAP 0x0004
762#define V4L2_TUNER_SUB_LANG1 0x0008
763
764/* Values for the 'audmode' field */
765#define V4L2_TUNER_MODE_MONO 0x0000
766#define V4L2_TUNER_MODE_STEREO 0x0001
767#define V4L2_TUNER_MODE_LANG2 0x0002
768#define V4L2_TUNER_MODE_SAP 0x0002
769#define V4L2_TUNER_MODE_LANG1 0x0003
770
771struct v4l2_frequency
772{
773 __u32 tuner;
774 enum v4l2_tuner_type type;
775 __u32 frequency;
776 __u32 reserved[8];
777};
778
779/*
780 * A U D I O
781 */
782struct v4l2_audio
783{
784 __u32 index;
785 __u8 name[32];
786 __u32 capability;
787 __u32 mode;
788 __u32 reserved[2];
789};
790/* Flags for the 'capability' field */
791#define V4L2_AUDCAP_STEREO 0x00001
792#define V4L2_AUDCAP_AVL 0x00002
793
794/* Flags for the 'mode' field */
795#define V4L2_AUDMODE_AVL 0x00001
796
797struct v4l2_audioout
798{
799 __u32 index;
800 __u8 name[32];
801 __u32 capability;
802 __u32 mode;
803 __u32 reserved[2];
804};
805
806/*
807 * D A T A S E R V I C E S ( V B I )
808 *
809 * Data services API by Michael Schimek
810 */
811
812struct v4l2_vbi_format
813{
814 __u32 sampling_rate; /* in 1 Hz */
815 __u32 offset;
816 __u32 samples_per_line;
817 __u32 sample_format; /* V4L2_PIX_FMT_* */
818 __s32 start[2];
819 __u32 count[2];
820 __u32 flags; /* V4L2_VBI_* */
821 __u32 reserved[2]; /* must be zero */
822};
823
824/* VBI flags */
825#define V4L2_VBI_UNSYNC (1<< 0)
826#define V4L2_VBI_INTERLACED (1<< 1)
827
828
829/*
830 * A G G R E G A T E S T R U C T U R E S
831 */
832
833/* Stream data format
834 */
835struct v4l2_format
836{
837 enum v4l2_buf_type type;
838 union
839 {
840 struct v4l2_pix_format pix; // V4L2_BUF_TYPE_VIDEO_CAPTURE
841 struct v4l2_window win; // V4L2_BUF_TYPE_VIDEO_OVERLAY
842 struct v4l2_vbi_format vbi; // V4L2_BUF_TYPE_VBI_CAPTURE
843 __u8 raw_data[200]; // user-defined
844 } fmt;
845};
846
847
848/* Stream type-dependent parameters
849 */
850struct v4l2_streamparm
851{
852 enum v4l2_buf_type type;
853 union
854 {
855 struct v4l2_captureparm capture;
856 struct v4l2_outputparm output;
857 __u8 raw_data[200]; /* user-defined */
858 } parm;
859};
860
861
862
863/*
864 * I O C T L C O D E S F O R V I D E O D E V I C E S
865 *
866 */
867#define VIDIOC_QUERYCAP _IOR ('V', 0, struct v4l2_capability)
868#define VIDIOC_RESERVED _IO ('V', 1)
869#define VIDIOC_ENUM_FMT _IOWR ('V', 2, struct v4l2_fmtdesc)
870#define VIDIOC_G_FMT _IOWR ('V', 4, struct v4l2_format)
871#define VIDIOC_S_FMT _IOWR ('V', 5, struct v4l2_format)
872#if 1 /* experimental */
873#define VIDIOC_G_MPEGCOMP _IOR ('V', 6, struct v4l2_mpeg_compression)
874#define VIDIOC_S_MPEGCOMP _IOW ('V', 7, struct v4l2_mpeg_compression)
875#endif
876#define VIDIOC_REQBUFS _IOWR ('V', 8, struct v4l2_requestbuffers)
877#define VIDIOC_QUERYBUF _IOWR ('V', 9, struct v4l2_buffer)
878#define VIDIOC_G_FBUF _IOR ('V', 10, struct v4l2_framebuffer)
879#define VIDIOC_S_FBUF _IOW ('V', 11, struct v4l2_framebuffer)
880#define VIDIOC_OVERLAY _IOW ('V', 14, int)
881#define VIDIOC_QBUF _IOWR ('V', 15, struct v4l2_buffer)
882#define VIDIOC_DQBUF _IOWR ('V', 17, struct v4l2_buffer)
883#define VIDIOC_STREAMON _IOW ('V', 18, int)
884#define VIDIOC_STREAMOFF _IOW ('V', 19, int)
885#define VIDIOC_G_PARM _IOWR ('V', 21, struct v4l2_streamparm)
886#define VIDIOC_S_PARM _IOWR ('V', 22, struct v4l2_streamparm)
887#define VIDIOC_G_STD _IOR ('V', 23, v4l2_std_id)
888#define VIDIOC_S_STD _IOW ('V', 24, v4l2_std_id)
889#define VIDIOC_ENUMSTD _IOWR ('V', 25, struct v4l2_standard)
890#define VIDIOC_ENUMINPUT _IOWR ('V', 26, struct v4l2_input)
891#define VIDIOC_G_CTRL _IOWR ('V', 27, struct v4l2_control)
892#define VIDIOC_S_CTRL _IOWR ('V', 28, struct v4l2_control)
893#define VIDIOC_G_TUNER _IOWR ('V', 29, struct v4l2_tuner)
894#define VIDIOC_S_TUNER _IOW ('V', 30, struct v4l2_tuner)
895#define VIDIOC_G_AUDIO _IOR ('V', 33, struct v4l2_audio)
896#define VIDIOC_S_AUDIO _IOW ('V', 34, struct v4l2_audio)
897#define VIDIOC_QUERYCTRL _IOWR ('V', 36, struct v4l2_queryctrl)
898#define VIDIOC_QUERYMENU _IOWR ('V', 37, struct v4l2_querymenu)
899#define VIDIOC_G_INPUT _IOR ('V', 38, int)
900#define VIDIOC_S_INPUT _IOWR ('V', 39, int)
901#define VIDIOC_G_OUTPUT _IOR ('V', 46, int)
902#define VIDIOC_S_OUTPUT _IOWR ('V', 47, int)
903#define VIDIOC_ENUMOUTPUT _IOWR ('V', 48, struct v4l2_output)
904#define VIDIOC_G_AUDOUT _IOR ('V', 49, struct v4l2_audioout)
905#define VIDIOC_S_AUDOUT _IOW ('V', 50, struct v4l2_audioout)
906#define VIDIOC_G_MODULATOR _IOWR ('V', 54, struct v4l2_modulator)
907#define VIDIOC_S_MODULATOR _IOW ('V', 55, struct v4l2_modulator)
908#define VIDIOC_G_FREQUENCY _IOWR ('V', 56, struct v4l2_frequency)
909#define VIDIOC_S_FREQUENCY _IOW ('V', 57, struct v4l2_frequency)
910#define VIDIOC_CROPCAP _IOWR ('V', 58, struct v4l2_cropcap)
911#define VIDIOC_G_CROP _IOWR ('V', 59, struct v4l2_crop)
912#define VIDIOC_S_CROP _IOW ('V', 60, struct v4l2_crop)
913#define VIDIOC_G_JPEGCOMP _IOR ('V', 61, struct v4l2_jpegcompression)
914#define VIDIOC_S_JPEGCOMP _IOW ('V', 62, struct v4l2_jpegcompression)
915#define VIDIOC_QUERYSTD _IOR ('V', 63, v4l2_std_id)
916#define VIDIOC_TRY_FMT _IOWR ('V', 64, struct v4l2_format)
917#define VIDIOC_ENUMAUDIO _IOWR ('V', 65, struct v4l2_audio)
918#define VIDIOC_ENUMAUDOUT _IOWR ('V', 66, struct v4l2_audioout)
919#define VIDIOC_G_PRIORITY _IOR ('V', 67, enum v4l2_priority)
920#define VIDIOC_S_PRIORITY _IOW ('V', 68, enum v4l2_priority)
921
922/* for compatibility, will go away some day */
923#define VIDIOC_OVERLAY_OLD _IOWR ('V', 14, int)
924#define VIDIOC_S_PARM_OLD _IOW ('V', 22, struct v4l2_streamparm)
925#define VIDIOC_S_CTRL_OLD _IOW ('V', 28, struct v4l2_control)
926#define VIDIOC_G_AUDIO_OLD _IOWR ('V', 33, struct v4l2_audio)
927#define VIDIOC_G_AUDOUT_OLD _IOWR ('V', 49, struct v4l2_audioout)
928#define VIDIOC_CROPCAP_OLD _IOR ('V', 58, struct v4l2_cropcap)
929
930#define BASE_VIDIOC_PRIVATE 192 /* 192-255 are private */
931
932
933#ifdef __KERNEL__
934/*
935 *
936 * V 4 L 2 D R I V E R H E L P E R A P I
937 *
938 * Some commonly needed functions for drivers (v4l2-common.o module)
939 */
940#include <linux/fs.h>
941
942/* Video standard functions */
943extern unsigned int v4l2_video_std_fps(struct v4l2_standard *vs);
944extern int v4l2_video_std_construct(struct v4l2_standard *vs,
945 int id, char *name);
946
947/* prority handling */
948struct v4l2_prio_state {
949 atomic_t prios[4];
950};
951int v4l2_prio_init(struct v4l2_prio_state *global);
952int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local,
953 enum v4l2_priority new);
954int v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local);
955int v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority *local);
956enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global);
957int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority *local);
958
959/* names for fancy debug output */
960extern char *v4l2_field_names[];
961extern char *v4l2_type_names[];
962extern char *v4l2_ioctl_names[];
963
964/* Compatibility layer interface -- v4l1-compat module */
965typedef int (*v4l2_kioctl)(struct inode *inode, struct file *file,
966 unsigned int cmd, void *arg);
967int v4l_compat_translate_ioctl(struct inode *inode, struct file *file,
968 int cmd, void *arg, v4l2_kioctl driver_ioctl);
969
970#endif /* __KERNEL__ */
971#endif /* __LINUX_VIDEODEV2_H */
972
973/*
974 * Local variables:
975 * c-basic-offset: 8
976 * End:
977 */
diff --git a/include/linux/videotext.h b/include/linux/videotext.h
new file mode 100644
index 000000000000..018f92047ff8
--- /dev/null
+++ b/include/linux/videotext.h
@@ -0,0 +1,125 @@
1#ifndef _VTX_H
2#define _VTX_H
3
4/*
5 * Teletext (=Videotext) hardware decoders using interface /dev/vtx
6 * Do not confuse with drivers using /dev/vbi which decode videotext by software
7 *
8 * Videotext IOCTLs changed in order to use _IO() macros defined in <linux/ioctl.h>,
9 * unused tuner IOCTLs cleaned up by
10 * Michael Geng <linux@MichaelGeng.de>
11 *
12 * Copyright (c) 1994-97 Martin Buck <martin-2.buck@student.uni-ulm.de>
13 * Read COPYING for more information
14 *
15 */
16
17
18/*
19 * Videotext ioctls
20 */
21#define VTXIOCGETINFO _IOR (0x81, 1, vtx_info_t)
22#define VTXIOCCLRPAGE _IOW (0x81, 2, vtx_pagereq_t)
23#define VTXIOCCLRFOUND _IOW (0x81, 3, vtx_pagereq_t)
24#define VTXIOCPAGEREQ _IOW (0x81, 4, vtx_pagereq_t)
25#define VTXIOCGETSTAT _IOW (0x81, 5, vtx_pagereq_t)
26#define VTXIOCGETPAGE _IOW (0x81, 6, vtx_pagereq_t)
27#define VTXIOCSTOPDAU _IOW (0x81, 7, vtx_pagereq_t)
28#define VTXIOCPUTPAGE _IO (0x81, 8)
29#define VTXIOCSETDISP _IO (0x81, 9)
30#define VTXIOCPUTSTAT _IO (0x81, 10)
31#define VTXIOCCLRCACHE _IO (0x81, 11)
32#define VTXIOCSETVIRT _IOW (0x81, 12, long)
33
34/* for compatibility, will go away some day */
35#define VTXIOCGETINFO_OLD 0x7101 /* get version of driver & capabilities of vtx-chipset */
36#define VTXIOCCLRPAGE_OLD 0x7102 /* clear page-buffer */
37#define VTXIOCCLRFOUND_OLD 0x7103 /* clear bits indicating that page was found */
38#define VTXIOCPAGEREQ_OLD 0x7104 /* search for page */
39#define VTXIOCGETSTAT_OLD 0x7105 /* get status of page-buffer */
40#define VTXIOCGETPAGE_OLD 0x7106 /* get contents of page-buffer */
41#define VTXIOCSTOPDAU_OLD 0x7107 /* stop data acquisition unit */
42#define VTXIOCPUTPAGE_OLD 0x7108 /* display page on TV-screen */
43#define VTXIOCSETDISP_OLD 0x7109 /* set TV-mode */
44#define VTXIOCPUTSTAT_OLD 0x710a /* set status of TV-output-buffer */
45#define VTXIOCCLRCACHE_OLD 0x710b /* clear cache on VTX-interface (if avail.) */
46#define VTXIOCSETVIRT_OLD 0x710c /* turn on virtual mode (this disables TV-display) */
47
48/*
49 * Definitions for VTXIOCGETINFO
50 */
51
52#define SAA5243 0
53#define SAA5246 1
54#define SAA5249 2
55#define SAA5248 3
56#define XSTV5346 4
57
58typedef struct {
59 int version_major, version_minor; /* version of driver; if version_major changes, driver */
60 /* is not backward compatible!!! CHECK THIS!!! */
61 int numpages; /* number of page-buffers of vtx-chipset */
62 int cct_type; /* type of vtx-chipset (SAA5243, SAA5246, SAA5248 or
63 * SAA5249) */
64}
65vtx_info_t;
66
67
68/*
69 * Definitions for VTXIOC{CLRPAGE,CLRFOUND,PAGEREQ,GETSTAT,GETPAGE,STOPDAU,PUTPAGE,SETDISP}
70 */
71
72#define MIN_UNIT (1<<0)
73#define MIN_TEN (1<<1)
74#define HR_UNIT (1<<2)
75#define HR_TEN (1<<3)
76#define PG_UNIT (1<<4)
77#define PG_TEN (1<<5)
78#define PG_HUND (1<<6)
79#define PGMASK_MAX (1<<7)
80#define PGMASK_PAGE (PG_HUND | PG_TEN | PG_UNIT)
81#define PGMASK_HOUR (HR_TEN | HR_UNIT)
82#define PGMASK_MINUTE (MIN_TEN | MIN_UNIT)
83
84typedef struct
85{
86 int page; /* number of requested page (hexadecimal) */
87 int hour; /* requested hour (hexadecimal) */
88 int minute; /* requested minute (hexadecimal) */
89 int pagemask; /* mask defining which values of the above are set */
90 int pgbuf; /* buffer where page will be stored */
91 int start; /* start of requested part of page */
92 int end; /* end of requested part of page */
93 void __user *buffer; /* pointer to beginning of destination buffer */
94}
95vtx_pagereq_t;
96
97
98/*
99 * Definitions for VTXIOC{GETSTAT,PUTSTAT}
100 */
101
102#define VTX_PAGESIZE (40 * 24)
103#define VTX_VIRTUALSIZE (40 * 49)
104
105typedef struct
106{
107 int pagenum; /* number of page (hexadecimal) */
108 int hour; /* hour (hexadecimal) */
109 int minute; /* minute (hexadecimal) */
110 int charset; /* national charset */
111 unsigned delete : 1; /* delete page (C4) */
112 unsigned headline : 1; /* insert headline (C5) */
113 unsigned subtitle : 1; /* insert subtitle (C6) */
114 unsigned supp_header : 1; /* suppress header (C7) */
115 unsigned update : 1; /* update page (C8) */
116 unsigned inter_seq : 1; /* interrupted sequence (C9) */
117 unsigned dis_disp : 1; /* disable/suppress display (C10) */
118 unsigned serial : 1; /* serial mode (C11) */
119 unsigned notfound : 1; /* /FOUND */
120 unsigned pblf : 1; /* PBLF */
121 unsigned hamming : 1; /* hamming-error occurred */
122}
123vtx_pageinfo_t;
124
125#endif /* _VTX_H */
diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
new file mode 100644
index 000000000000..3a358c895188
--- /dev/null
+++ b/include/linux/vmalloc.h
@@ -0,0 +1,54 @@
1#ifndef _LINUX_VMALLOC_H
2#define _LINUX_VMALLOC_H
3
4#include <linux/spinlock.h>
5#include <asm/page.h> /* pgprot_t */
6
7/* bits in vm_struct->flags */
8#define VM_IOREMAP 0x00000001 /* ioremap() and friends */
9#define VM_ALLOC 0x00000002 /* vmalloc() */
10#define VM_MAP 0x00000004 /* vmap()ed pages */
11/* bits [20..32] reserved for arch specific ioremap internals */
12
13struct vm_struct {
14 void *addr;
15 unsigned long size;
16 unsigned long flags;
17 struct page **pages;
18 unsigned int nr_pages;
19 unsigned long phys_addr;
20 struct vm_struct *next;
21};
22
23/*
24 * Highlevel APIs for driver use
25 */
26extern void *vmalloc(unsigned long size);
27extern void *vmalloc_exec(unsigned long size);
28extern void *vmalloc_32(unsigned long size);
29extern void *__vmalloc(unsigned long size, unsigned int __nocast gfp_mask, pgprot_t prot);
30extern void *__vmalloc_area(struct vm_struct *area, unsigned int __nocast gfp_mask, pgprot_t prot);
31extern void vfree(void *addr);
32
33extern void *vmap(struct page **pages, unsigned int count,
34 unsigned long flags, pgprot_t prot);
35extern void vunmap(void *addr);
36
37/*
38 * Lowlevel-APIs (not for driver use!)
39 */
40extern struct vm_struct *get_vm_area(unsigned long size, unsigned long flags);
41extern struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags,
42 unsigned long start, unsigned long end);
43extern struct vm_struct *remove_vm_area(void *addr);
44extern int map_vm_area(struct vm_struct *area, pgprot_t prot,
45 struct page ***pages);
46extern void unmap_vm_area(struct vm_struct *area);
47
48/*
49 * Internals. Dont't use..
50 */
51extern rwlock_t vmlist_lock;
52extern struct vm_struct *vmlist;
53
54#endif /* _LINUX_VMALLOC_H */
diff --git a/include/linux/vt.h b/include/linux/vt.h
new file mode 100644
index 000000000000..9f95b0bea5b3
--- /dev/null
+++ b/include/linux/vt.h
@@ -0,0 +1,54 @@
1#ifndef _LINUX_VT_H
2#define _LINUX_VT_H
3
4/* 0x56 is 'V', to avoid collision with termios and kd */
5
6#define VT_OPENQRY 0x5600 /* find available vt */
7
8struct vt_mode {
9 char mode; /* vt mode */
10 char waitv; /* if set, hang on writes if not active */
11 short relsig; /* signal to raise on release req */
12 short acqsig; /* signal to raise on acquisition */
13 short frsig; /* unused (set to 0) */
14};
15#define VT_GETMODE 0x5601 /* get mode of active vt */
16#define VT_SETMODE 0x5602 /* set mode of active vt */
17#define VT_AUTO 0x00 /* auto vt switching */
18#define VT_PROCESS 0x01 /* process controls switching */
19#define VT_ACKACQ 0x02 /* acknowledge switch */
20
21struct vt_stat {
22 unsigned short v_active; /* active vt */
23 unsigned short v_signal; /* signal to send */
24 unsigned short v_state; /* vt bitmask */
25};
26#define VT_GETSTATE 0x5603 /* get global vt state info */
27#define VT_SENDSIG 0x5604 /* signal to send to bitmask of vts */
28
29#define VT_RELDISP 0x5605 /* release display */
30
31#define VT_ACTIVATE 0x5606 /* make vt active */
32#define VT_WAITACTIVE 0x5607 /* wait for vt active */
33#define VT_DISALLOCATE 0x5608 /* free memory associated to vt */
34
35struct vt_sizes {
36 unsigned short v_rows; /* number of rows */
37 unsigned short v_cols; /* number of columns */
38 unsigned short v_scrollsize; /* number of lines of scrollback */
39};
40#define VT_RESIZE 0x5609 /* set kernel's idea of screensize */
41
42struct vt_consize {
43 unsigned short v_rows; /* number of rows */
44 unsigned short v_cols; /* number of columns */
45 unsigned short v_vlin; /* number of pixel rows on screen */
46 unsigned short v_clin; /* number of pixel rows per character */
47 unsigned short v_vcol; /* number of pixel columns on screen */
48 unsigned short v_ccol; /* number of pixel columns per character */
49};
50#define VT_RESIZEX 0x560A /* set kernel's idea of screensize + more */
51#define VT_LOCKSWITCH 0x560B /* disallow vt switching */
52#define VT_UNLOCKSWITCH 0x560C /* allow vt switching */
53
54#endif /* _LINUX_VT_H */
diff --git a/include/linux/vt_buffer.h b/include/linux/vt_buffer.h
new file mode 100644
index 000000000000..1f7ba3629053
--- /dev/null
+++ b/include/linux/vt_buffer.h
@@ -0,0 +1,64 @@
1/*
2 * include/linux/vt_buffer.h -- Access to VT screen buffer
3 *
4 * (c) 1998 Martin Mares <mj@ucw.cz>
5 *
6 * This is a set of macros and functions which are used in the
7 * console driver and related code to access the screen buffer.
8 * In most cases the console works with simple in-memory buffer,
9 * but when handling hardware text mode consoles, we store
10 * the foreground console directly in video memory.
11 */
12
13#ifndef _LINUX_VT_BUFFER_H_
14#define _LINUX_VT_BUFFER_H_
15
16#include <linux/config.h>
17
18#if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_MDA_CONSOLE)
19#include <asm/vga.h>
20#endif
21
22#ifndef VT_BUF_HAVE_RW
23#define scr_writew(val, addr) (*(addr) = (val))
24#define scr_readw(addr) (*(addr))
25#define scr_memcpyw(d, s, c) memcpy(d, s, c)
26#define scr_memmovew(d, s, c) memmove(d, s, c)
27#define VT_BUF_HAVE_MEMCPYW
28#define VT_BUF_HAVE_MEMMOVEW
29#endif
30
31#ifndef VT_BUF_HAVE_MEMSETW
32static inline void scr_memsetw(u16 *s, u16 c, unsigned int count)
33{
34 count /= 2;
35 while (count--)
36 scr_writew(c, s++);
37}
38#endif
39
40#ifndef VT_BUF_HAVE_MEMCPYW
41static inline void scr_memcpyw(u16 *d, const u16 *s, unsigned int count)
42{
43 count /= 2;
44 while (count--)
45 scr_writew(scr_readw(s++), d++);
46}
47#endif
48
49#ifndef VT_BUF_HAVE_MEMMOVEW
50static inline void scr_memmovew(u16 *d, const u16 *s, unsigned int count)
51{
52 if (d < s)
53 scr_memcpyw(d, s, count);
54 else {
55 count /= 2;
56 d += count;
57 s += count;
58 while (count--)
59 scr_writew(scr_readw(--s), --d);
60 }
61}
62#endif
63
64#endif
diff --git a/include/linux/vt_kern.h b/include/linux/vt_kern.h
new file mode 100644
index 000000000000..fab5aed8ca31
--- /dev/null
+++ b/include/linux/vt_kern.h
@@ -0,0 +1,86 @@
1#ifndef _VT_KERN_H
2#define _VT_KERN_H
3
4/*
5 * this really is an extension of the vc_cons structure in console.c, but
6 * with information needed by the vt package
7 */
8
9#include <linux/config.h>
10#include <linux/vt.h>
11#include <linux/kd.h>
12#include <linux/tty.h>
13#include <linux/console_struct.h>
14#include <linux/mm.h>
15
16/*
17 * Presently, a lot of graphics programs do not restore the contents of
18 * the higher font pages. Defining this flag will avoid use of them, but
19 * will lose support for PIO_FONTRESET. Note that many font operations are
20 * not likely to work with these programs anyway; they need to be
21 * fixed. The linux/Documentation directory includes a code snippet
22 * to save and restore the text font.
23 */
24#ifdef CONFIG_VGA_CONSOLE
25#define BROKEN_GRAPHICS_PROGRAMS 1
26#endif
27
28extern void kd_mksound(unsigned int hz, unsigned int ticks);
29extern int kbd_rate(struct kbd_repeat *rep);
30
31/* console.c */
32
33int vc_allocate(unsigned int console);
34int vc_cons_allocated(unsigned int console);
35int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines);
36void vc_disallocate(unsigned int console);
37void reset_palette(struct vc_data *vc);
38void do_blank_screen(int entering_gfx);
39void do_unblank_screen(int leaving_gfx);
40void unblank_screen(void);
41void poke_blanked_console(void);
42int con_font_op(struct vc_data *vc, struct console_font_op *op);
43int con_set_cmap(unsigned char __user *cmap);
44int con_get_cmap(unsigned char __user *cmap);
45void scrollback(struct vc_data *vc, int lines);
46void scrollfront(struct vc_data *vc, int lines);
47void update_region(struct vc_data *vc, unsigned long start, int count);
48void redraw_screen(struct vc_data *vc, int is_switch);
49#define update_screen(x) redraw_screen(x, 0)
50#define switch_screen(x) redraw_screen(x, 1)
51
52struct tty_struct;
53int tioclinux(struct tty_struct *tty, unsigned long arg);
54
55/* consolemap.c */
56
57struct unimapinit;
58struct unipair;
59
60int con_set_trans_old(unsigned char __user * table);
61int con_get_trans_old(unsigned char __user * table);
62int con_set_trans_new(unsigned short __user * table);
63int con_get_trans_new(unsigned short __user * table);
64int con_clear_unimap(struct vc_data *vc, struct unimapinit *ui);
65int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list);
66int con_get_unimap(struct vc_data *vc, ushort ct, ushort __user *uct, struct unipair __user *list);
67int con_set_default_unimap(struct vc_data *vc);
68void con_free_unimap(struct vc_data *vc);
69void con_protect_unimap(struct vc_data *vc, int rdonly);
70int con_copy_unimap(struct vc_data *dst_vc, struct vc_data *src_vc);
71
72/* vt.c */
73int vt_waitactive(int vt);
74void change_console(struct vc_data *new_vc);
75void reset_vc(struct vc_data *vc);
76
77/*
78 * vc_screen.c shares this temporary buffer with the console write code so that
79 * we can easily avoid touching user space while holding the console spinlock.
80 */
81
82#define CON_BUF_SIZE (CONFIG_BASE_SMALL ? 256 : PAGE_SIZE)
83extern char con_buf[CON_BUF_SIZE];
84extern struct semaphore con_buf_sem;
85
86#endif /* _VT_KERN_H */
diff --git a/include/linux/wait.h b/include/linux/wait.h
new file mode 100644
index 000000000000..17c874a8eb3f
--- /dev/null
+++ b/include/linux/wait.h
@@ -0,0 +1,460 @@
1#ifndef _LINUX_WAIT_H
2#define _LINUX_WAIT_H
3
4#define WNOHANG 0x00000001
5#define WUNTRACED 0x00000002
6#define WSTOPPED WUNTRACED
7#define WEXITED 0x00000004
8#define WCONTINUED 0x00000008
9#define WNOWAIT 0x01000000 /* Don't reap, just poll status. */
10
11#define __WNOTHREAD 0x20000000 /* Don't wait on children of other threads in this group */
12#define __WALL 0x40000000 /* Wait on all children, regardless of type */
13#define __WCLONE 0x80000000 /* Wait only on non-SIGCHLD children */
14
15/* First argument to waitid: */
16#define P_ALL 0
17#define P_PID 1
18#define P_PGID 2
19
20#ifdef __KERNEL__
21
22#include <linux/config.h>
23#include <linux/list.h>
24#include <linux/stddef.h>
25#include <linux/spinlock.h>
26#include <asm/system.h>
27#include <asm/current.h>
28
29typedef struct __wait_queue wait_queue_t;
30typedef int (*wait_queue_func_t)(wait_queue_t *wait, unsigned mode, int sync, void *key);
31int default_wake_function(wait_queue_t *wait, unsigned mode, int sync, void *key);
32
33struct __wait_queue {
34 unsigned int flags;
35#define WQ_FLAG_EXCLUSIVE 0x01
36 struct task_struct * task;
37 wait_queue_func_t func;
38 struct list_head task_list;
39};
40
41struct wait_bit_key {
42 void *flags;
43 int bit_nr;
44};
45
46struct wait_bit_queue {
47 struct wait_bit_key key;
48 wait_queue_t wait;
49};
50
51struct __wait_queue_head {
52 spinlock_t lock;
53 struct list_head task_list;
54};
55typedef struct __wait_queue_head wait_queue_head_t;
56
57
58/*
59 * Macros for declaration and initialisaton of the datatypes
60 */
61
62#define __WAITQUEUE_INITIALIZER(name, tsk) { \
63 .task = tsk, \
64 .func = default_wake_function, \
65 .task_list = { NULL, NULL } }
66
67#define DECLARE_WAITQUEUE(name, tsk) \
68 wait_queue_t name = __WAITQUEUE_INITIALIZER(name, tsk)
69
70#define __WAIT_QUEUE_HEAD_INITIALIZER(name) { \
71 .lock = SPIN_LOCK_UNLOCKED, \
72 .task_list = { &(name).task_list, &(name).task_list } }
73
74#define DECLARE_WAIT_QUEUE_HEAD(name) \
75 wait_queue_head_t name = __WAIT_QUEUE_HEAD_INITIALIZER(name)
76
77#define __WAIT_BIT_KEY_INITIALIZER(word, bit) \
78 { .flags = word, .bit_nr = bit, }
79
80static inline void init_waitqueue_head(wait_queue_head_t *q)
81{
82 spin_lock_init(&q->lock);
83 INIT_LIST_HEAD(&q->task_list);
84}
85
86static inline void init_waitqueue_entry(wait_queue_t *q, struct task_struct *p)
87{
88 q->flags = 0;
89 q->task = p;
90 q->func = default_wake_function;
91}
92
93static inline void init_waitqueue_func_entry(wait_queue_t *q,
94 wait_queue_func_t func)
95{
96 q->flags = 0;
97 q->task = NULL;
98 q->func = func;
99}
100
101static inline int waitqueue_active(wait_queue_head_t *q)
102{
103 return !list_empty(&q->task_list);
104}
105
106/*
107 * Used to distinguish between sync and async io wait context:
108 * sync i/o typically specifies a NULL wait queue entry or a wait
109 * queue entry bound to a task (current task) to wake up.
110 * aio specifies a wait queue entry with an async notification
111 * callback routine, not associated with any task.
112 */
113#define is_sync_wait(wait) (!(wait) || ((wait)->task))
114
115extern void FASTCALL(add_wait_queue(wait_queue_head_t *q, wait_queue_t * wait));
116extern void FASTCALL(add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t * wait));
117extern void FASTCALL(remove_wait_queue(wait_queue_head_t *q, wait_queue_t * wait));
118
119static inline void __add_wait_queue(wait_queue_head_t *head, wait_queue_t *new)
120{
121 list_add(&new->task_list, &head->task_list);
122}
123
124/*
125 * Used for wake-one threads:
126 */
127static inline void __add_wait_queue_tail(wait_queue_head_t *head,
128 wait_queue_t *new)
129{
130 list_add_tail(&new->task_list, &head->task_list);
131}
132
133static inline void __remove_wait_queue(wait_queue_head_t *head,
134 wait_queue_t *old)
135{
136 list_del(&old->task_list);
137}
138
139void FASTCALL(__wake_up(wait_queue_head_t *q, unsigned int mode, int nr, void *key));
140extern void FASTCALL(__wake_up_locked(wait_queue_head_t *q, unsigned int mode));
141extern void FASTCALL(__wake_up_sync(wait_queue_head_t *q, unsigned int mode, int nr));
142void FASTCALL(__wake_up_bit(wait_queue_head_t *, void *, int));
143int FASTCALL(__wait_on_bit(wait_queue_head_t *, struct wait_bit_queue *, int (*)(void *), unsigned));
144int FASTCALL(__wait_on_bit_lock(wait_queue_head_t *, struct wait_bit_queue *, int (*)(void *), unsigned));
145void FASTCALL(wake_up_bit(void *, int));
146int FASTCALL(out_of_line_wait_on_bit(void *, int, int (*)(void *), unsigned));
147int FASTCALL(out_of_line_wait_on_bit_lock(void *, int, int (*)(void *), unsigned));
148wait_queue_head_t *FASTCALL(bit_waitqueue(void *, int));
149
150#define wake_up(x) __wake_up(x, TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE, 1, NULL)
151#define wake_up_nr(x, nr) __wake_up(x, TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE, nr, NULL)
152#define wake_up_all(x) __wake_up(x, TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE, 0, NULL)
153#define wake_up_interruptible(x) __wake_up(x, TASK_INTERRUPTIBLE, 1, NULL)
154#define wake_up_interruptible_nr(x, nr) __wake_up(x, TASK_INTERRUPTIBLE, nr, NULL)
155#define wake_up_interruptible_all(x) __wake_up(x, TASK_INTERRUPTIBLE, 0, NULL)
156#define wake_up_locked(x) __wake_up_locked((x), TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE)
157#define wake_up_interruptible_sync(x) __wake_up_sync((x),TASK_INTERRUPTIBLE, 1)
158
159#define __wait_event(wq, condition) \
160do { \
161 DEFINE_WAIT(__wait); \
162 \
163 for (;;) { \
164 prepare_to_wait(&wq, &__wait, TASK_UNINTERRUPTIBLE); \
165 if (condition) \
166 break; \
167 schedule(); \
168 } \
169 finish_wait(&wq, &__wait); \
170} while (0)
171
172/**
173 * wait_event - sleep until a condition gets true
174 * @wq: the waitqueue to wait on
175 * @condition: a C expression for the event to wait for
176 *
177 * The process is put to sleep (TASK_UNINTERRUPTIBLE) until the
178 * @condition evaluates to true. The @condition is checked each time
179 * the waitqueue @wq is woken up.
180 *
181 * wake_up() has to be called after changing any variable that could
182 * change the result of the wait condition.
183 */
184#define wait_event(wq, condition) \
185do { \
186 if (condition) \
187 break; \
188 __wait_event(wq, condition); \
189} while (0)
190
191#define __wait_event_timeout(wq, condition, ret) \
192do { \
193 DEFINE_WAIT(__wait); \
194 \
195 for (;;) { \
196 prepare_to_wait(&wq, &__wait, TASK_UNINTERRUPTIBLE); \
197 if (condition) \
198 break; \
199 ret = schedule_timeout(ret); \
200 if (!ret) \
201 break; \
202 } \
203 finish_wait(&wq, &__wait); \
204} while (0)
205
206/**
207 * wait_event_timeout - sleep until a condition gets true or a timeout elapses
208 * @wq: the waitqueue to wait on
209 * @condition: a C expression for the event to wait for
210 * @timeout: timeout, in jiffies
211 *
212 * The process is put to sleep (TASK_UNINTERRUPTIBLE) until the
213 * @condition evaluates to true. The @condition is checked each time
214 * the waitqueue @wq is woken up.
215 *
216 * wake_up() has to be called after changing any variable that could
217 * change the result of the wait condition.
218 *
219 * The function returns 0 if the @timeout elapsed, and the remaining
220 * jiffies if the condition evaluated to true before the timeout elapsed.
221 */
222#define wait_event_timeout(wq, condition, timeout) \
223({ \
224 long __ret = timeout; \
225 if (!(condition)) \
226 __wait_event_timeout(wq, condition, __ret); \
227 __ret; \
228})
229
230#define __wait_event_interruptible(wq, condition, ret) \
231do { \
232 DEFINE_WAIT(__wait); \
233 \
234 for (;;) { \
235 prepare_to_wait(&wq, &__wait, TASK_INTERRUPTIBLE); \
236 if (condition) \
237 break; \
238 if (!signal_pending(current)) { \
239 schedule(); \
240 continue; \
241 } \
242 ret = -ERESTARTSYS; \
243 break; \
244 } \
245 finish_wait(&wq, &__wait); \
246} while (0)
247
248/**
249 * wait_event_interruptible - sleep until a condition gets true
250 * @wq: the waitqueue to wait on
251 * @condition: a C expression for the event to wait for
252 *
253 * The process is put to sleep (TASK_INTERRUPTIBLE) until the
254 * @condition evaluates to true or a signal is received.
255 * The @condition is checked each time the waitqueue @wq is woken up.
256 *
257 * wake_up() has to be called after changing any variable that could
258 * change the result of the wait condition.
259 *
260 * The function will return -ERESTARTSYS if it was interrupted by a
261 * signal and 0 if @condition evaluated to true.
262 */
263#define wait_event_interruptible(wq, condition) \
264({ \
265 int __ret = 0; \
266 if (!(condition)) \
267 __wait_event_interruptible(wq, condition, __ret); \
268 __ret; \
269})
270
271#define __wait_event_interruptible_timeout(wq, condition, ret) \
272do { \
273 DEFINE_WAIT(__wait); \
274 \
275 for (;;) { \
276 prepare_to_wait(&wq, &__wait, TASK_INTERRUPTIBLE); \
277 if (condition) \
278 break; \
279 if (!signal_pending(current)) { \
280 ret = schedule_timeout(ret); \
281 if (!ret) \
282 break; \
283 continue; \
284 } \
285 ret = -ERESTARTSYS; \
286 break; \
287 } \
288 finish_wait(&wq, &__wait); \
289} while (0)
290
291/**
292 * wait_event_interruptible_timeout - sleep until a condition gets true or a timeout elapses
293 * @wq: the waitqueue to wait on
294 * @condition: a C expression for the event to wait for
295 * @timeout: timeout, in jiffies
296 *
297 * The process is put to sleep (TASK_INTERRUPTIBLE) until the
298 * @condition evaluates to true or a signal is received.
299 * The @condition is checked each time the waitqueue @wq is woken up.
300 *
301 * wake_up() has to be called after changing any variable that could
302 * change the result of the wait condition.
303 *
304 * The function returns 0 if the @timeout elapsed, -ERESTARTSYS if it
305 * was interrupted by a signal, and the remaining jiffies otherwise
306 * if the condition evaluated to true before the timeout elapsed.
307 */
308#define wait_event_interruptible_timeout(wq, condition, timeout) \
309({ \
310 long __ret = timeout; \
311 if (!(condition)) \
312 __wait_event_interruptible_timeout(wq, condition, __ret); \
313 __ret; \
314})
315
316#define __wait_event_interruptible_exclusive(wq, condition, ret) \
317do { \
318 DEFINE_WAIT(__wait); \
319 \
320 for (;;) { \
321 prepare_to_wait_exclusive(&wq, &__wait, \
322 TASK_INTERRUPTIBLE); \
323 if (condition) \
324 break; \
325 if (!signal_pending(current)) { \
326 schedule(); \
327 continue; \
328 } \
329 ret = -ERESTARTSYS; \
330 break; \
331 } \
332 finish_wait(&wq, &__wait); \
333} while (0)
334
335#define wait_event_interruptible_exclusive(wq, condition) \
336({ \
337 int __ret = 0; \
338 if (!(condition)) \
339 __wait_event_interruptible_exclusive(wq, condition, __ret);\
340 __ret; \
341})
342
343/*
344 * Must be called with the spinlock in the wait_queue_head_t held.
345 */
346static inline void add_wait_queue_exclusive_locked(wait_queue_head_t *q,
347 wait_queue_t * wait)
348{
349 wait->flags |= WQ_FLAG_EXCLUSIVE;
350 __add_wait_queue_tail(q, wait);
351}
352
353/*
354 * Must be called with the spinlock in the wait_queue_head_t held.
355 */
356static inline void remove_wait_queue_locked(wait_queue_head_t *q,
357 wait_queue_t * wait)
358{
359 __remove_wait_queue(q, wait);
360}
361
362/*
363 * These are the old interfaces to sleep waiting for an event.
364 * They are racy. DO NOT use them, use the wait_event* interfaces above.
365 * We plan to remove these interfaces during 2.7.
366 */
367extern void FASTCALL(sleep_on(wait_queue_head_t *q));
368extern long FASTCALL(sleep_on_timeout(wait_queue_head_t *q,
369 signed long timeout));
370extern void FASTCALL(interruptible_sleep_on(wait_queue_head_t *q));
371extern long FASTCALL(interruptible_sleep_on_timeout(wait_queue_head_t *q,
372 signed long timeout));
373
374/*
375 * Waitqueues which are removed from the waitqueue_head at wakeup time
376 */
377void FASTCALL(prepare_to_wait(wait_queue_head_t *q,
378 wait_queue_t *wait, int state));
379void FASTCALL(prepare_to_wait_exclusive(wait_queue_head_t *q,
380 wait_queue_t *wait, int state));
381void FASTCALL(finish_wait(wait_queue_head_t *q, wait_queue_t *wait));
382int autoremove_wake_function(wait_queue_t *wait, unsigned mode, int sync, void *key);
383int wake_bit_function(wait_queue_t *wait, unsigned mode, int sync, void *key);
384
385#define DEFINE_WAIT(name) \
386 wait_queue_t name = { \
387 .task = current, \
388 .func = autoremove_wake_function, \
389 .task_list = { .next = &(name).task_list, \
390 .prev = &(name).task_list, \
391 }, \
392 }
393
394#define DEFINE_WAIT_BIT(name, word, bit) \
395 struct wait_bit_queue name = { \
396 .key = __WAIT_BIT_KEY_INITIALIZER(word, bit), \
397 .wait = { \
398 .task = current, \
399 .func = wake_bit_function, \
400 .task_list = \
401 LIST_HEAD_INIT((name).wait.task_list), \
402 }, \
403 }
404
405#define init_wait(wait) \
406 do { \
407 (wait)->task = current; \
408 (wait)->func = autoremove_wake_function; \
409 INIT_LIST_HEAD(&(wait)->task_list); \
410 } while (0)
411
412/**
413 * wait_on_bit - wait for a bit to be cleared
414 * @word: the word being waited on, a kernel virtual address
415 * @bit: the bit of the word being waited on
416 * @action: the function used to sleep, which may take special actions
417 * @mode: the task state to sleep in
418 *
419 * There is a standard hashed waitqueue table for generic use. This
420 * is the part of the hashtable's accessor API that waits on a bit.
421 * For instance, if one were to have waiters on a bitflag, one would
422 * call wait_on_bit() in threads waiting for the bit to clear.
423 * One uses wait_on_bit() where one is waiting for the bit to clear,
424 * but has no intention of setting it.
425 */
426static inline int wait_on_bit(void *word, int bit,
427 int (*action)(void *), unsigned mode)
428{
429 if (!test_bit(bit, word))
430 return 0;
431 return out_of_line_wait_on_bit(word, bit, action, mode);
432}
433
434/**
435 * wait_on_bit_lock - wait for a bit to be cleared, when wanting to set it
436 * @word: the word being waited on, a kernel virtual address
437 * @bit: the bit of the word being waited on
438 * @action: the function used to sleep, which may take special actions
439 * @mode: the task state to sleep in
440 *
441 * There is a standard hashed waitqueue table for generic use. This
442 * is the part of the hashtable's accessor API that waits on a bit
443 * when one intends to set it, for instance, trying to lock bitflags.
444 * For instance, if one were to have waiters trying to set bitflag
445 * and waiting for it to clear before setting it, one would call
446 * wait_on_bit() in threads waiting to be able to set the bit.
447 * One uses wait_on_bit_lock() where one is waiting for the bit to
448 * clear with the intention of setting it, and when done, clearing it.
449 */
450static inline int wait_on_bit_lock(void *word, int bit,
451 int (*action)(void *), unsigned mode)
452{
453 if (!test_and_set_bit(bit, word))
454 return 0;
455 return out_of_line_wait_on_bit_lock(word, bit, action, mode);
456}
457
458#endif /* __KERNEL__ */
459
460#endif
diff --git a/include/linux/wanpipe.h b/include/linux/wanpipe.h
new file mode 100644
index 000000000000..167d956c492b
--- /dev/null
+++ b/include/linux/wanpipe.h
@@ -0,0 +1,492 @@
1/*****************************************************************************
2* wanpipe.h WANPIPE(tm) Multiprotocol WAN Link Driver.
3* User-level API definitions.
4*
5* Author: Nenad Corbic <ncorbic@sangoma.com>
6* Gideon Hack
7*
8* Copyright: (c) 1995-2000 Sangoma Technologies Inc.
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* Nov 3, 2000 Nenad Corbic Added config_id to sdla_t structure.
16* Used to determine the protocol running.
17* Jul 13, 2000 Nenad Corbic Added SyncPPP Support
18* Feb 24, 2000 Nenad Corbic Added support for x25api driver
19* Oct 04, 1999 Nenad Corbic New CHDLC and FRAME RELAY code, SMP support
20* Jun 02, 1999 Gideon Hack Added 'update_call_count' for Cisco HDLC
21* support
22* Jun 26, 1998 David Fong Added 'ip_mode' in sdla_t.u.p for dynamic IP
23* routing mode configuration
24* Jun 12, 1998 David Fong Added Cisco HDLC union member in sdla_t
25* Dec 08, 1997 Jaspreet Singh Added 'authenticator' in union of 'sdla_t'
26* Nov 26, 1997 Jaspreet Singh Added 'load_sharing' structure. Also added
27* 'devs_struct','dev_to_devtint_next' to 'sdla_t'
28* Nov 24, 1997 Jaspreet Singh Added 'irq_dis_if_send_count',
29* 'irq_dis_poll_count' to 'sdla_t'.
30* Nov 06, 1997 Jaspreet Singh Added a define called 'INTR_TEST_MODE'
31* Oct 20, 1997 Jaspreet Singh Added 'buff_intr_mode_unbusy' and
32* 'dlci_intr_mode_unbusy' to 'sdla_t'
33* Oct 18, 1997 Jaspreet Singh Added structure to maintain global driver
34* statistics.
35* Jan 15, 1997 Gene Kozin Version 3.1.0
36* o added UDP management stuff
37* Jan 02, 1997 Gene Kozin Version 3.0.0
38*****************************************************************************/
39#ifndef _WANPIPE_H
40#define _WANPIPE_H
41
42#include <linux/wanrouter.h>
43
44/* Defines */
45
46#ifndef PACKED
47#define PACKED __attribute__((packed))
48#endif
49
50#define WANPIPE_MAGIC 0x414C4453L /* signature: 'SDLA' reversed */
51
52/* IOCTL numbers (up to 16) */
53#define WANPIPE_DUMP (ROUTER_USER+0) /* dump adapter's memory */
54#define WANPIPE_EXEC (ROUTER_USER+1) /* execute firmware command */
55
56#define TRACE_ALL 0x00
57#define TRACE_PROT 0x01
58#define TRACE_DATA 0x02
59
60/* values for request/reply byte */
61#define UDPMGMT_REQUEST 0x01
62#define UDPMGMT_REPLY 0x02
63#define UDP_OFFSET 12
64
65#define MAX_CMD_BUFF 10
66#define MAX_X25_LCN 255 /* Maximum number of x25 channels */
67#define MAX_LCN_NUM 4095 /* Maximum lcn number */
68#define MAX_FT1_RETRY 100
69
70#ifndef AF_WANPIPE
71 #define AF_WANPIPE 25
72 #ifndef PF_WANPIPE
73 #define PF_WANPIPE AF_WANPIPE
74 #endif
75#endif
76
77
78#define TX_TIMEOUT 5*HZ
79
80/* General Critical Flags */
81#define SEND_CRIT 0x00
82#define PERI_CRIT 0x01
83
84/* Chdlc and PPP polling critical flag */
85#define POLL_CRIT 0x03
86
87/* Frame Relay Tx IRQ send critical flag */
88#define SEND_TXIRQ_CRIT 0x02
89
90/* Frame Relay ARP critical flag */
91#define ARP_CRIT 0x03
92
93/* Bit maps for dynamic interface configuration
94 * DYN_OPT_ON : turns this option on/off
95 * DEV_DOWN : device was shutdown by the driver not
96 * by user
97 */
98#define DYN_OPT_ON 0x00
99#define DEV_DOWN 0x01
100
101/*
102 * Data structures for IOCTL calls.
103 */
104
105typedef struct sdla_dump /* WANPIPE_DUMP */
106{
107 unsigned long magic; /* for verification */
108 unsigned long offset; /* absolute adapter memory address */
109 unsigned long length; /* block length */
110 void* ptr; /* -> buffer */
111} sdla_dump_t;
112
113typedef struct sdla_exec /* WANPIPE_EXEC */
114{
115 unsigned long magic; /* for verification */
116 void* cmd; /* -> command structure */
117 void* data; /* -> data buffer */
118} sdla_exec_t;
119
120/* UDP management stuff */
121
122typedef struct wum_header
123{
124 unsigned char signature[8]; /* 00h: signature */
125 unsigned char type; /* 08h: request/reply */
126 unsigned char command; /* 09h: commnand */
127 unsigned char reserved[6]; /* 0Ah: reserved */
128} wum_header_t;
129
130/*************************************************************************
131 Data Structure for global statistics
132*************************************************************************/
133
134typedef struct global_stats
135{
136 unsigned long isr_entry;
137 unsigned long isr_already_critical;
138 unsigned long isr_rx;
139 unsigned long isr_tx;
140 unsigned long isr_intr_test;
141 unsigned long isr_spurious;
142 unsigned long isr_enable_tx_int;
143 unsigned long rx_intr_corrupt_rx_bfr;
144 unsigned long rx_intr_on_orphaned_DLCI;
145 unsigned long rx_intr_dev_not_started;
146 unsigned long tx_intr_dev_not_started;
147 unsigned long poll_entry;
148 unsigned long poll_already_critical;
149 unsigned long poll_processed;
150 unsigned long poll_tbusy_bad_status;
151 unsigned long poll_host_disable_irq;
152 unsigned long poll_host_enable_irq;
153
154} global_stats_t;
155
156
157typedef struct{
158 unsigned short udp_src_port PACKED;
159 unsigned short udp_dst_port PACKED;
160 unsigned short udp_length PACKED;
161 unsigned short udp_checksum PACKED;
162} udp_pkt_t;
163
164
165typedef struct {
166 unsigned char ver_inet_hdr_length PACKED;
167 unsigned char service_type PACKED;
168 unsigned short total_length PACKED;
169 unsigned short identifier PACKED;
170 unsigned short flags_frag_offset PACKED;
171 unsigned char ttl PACKED;
172 unsigned char protocol PACKED;
173 unsigned short hdr_checksum PACKED;
174 unsigned long ip_src_address PACKED;
175 unsigned long ip_dst_address PACKED;
176} ip_pkt_t;
177
178
179typedef struct {
180 unsigned char signature[8] PACKED;
181 unsigned char request_reply PACKED;
182 unsigned char id PACKED;
183 unsigned char reserved[6] PACKED;
184} wp_mgmt_t;
185
186/*************************************************************************
187 Data Structure for if_send statistics
188*************************************************************************/
189typedef struct if_send_stat{
190 unsigned long if_send_entry;
191 unsigned long if_send_skb_null;
192 unsigned long if_send_broadcast;
193 unsigned long if_send_multicast;
194 unsigned long if_send_critical_ISR;
195 unsigned long if_send_critical_non_ISR;
196 unsigned long if_send_tbusy;
197 unsigned long if_send_tbusy_timeout;
198 unsigned long if_send_PIPE_request;
199 unsigned long if_send_wan_disconnected;
200 unsigned long if_send_dlci_disconnected;
201 unsigned long if_send_no_bfrs;
202 unsigned long if_send_adptr_bfrs_full;
203 unsigned long if_send_bfr_passed_to_adptr;
204 unsigned long if_send_protocol_error;
205 unsigned long if_send_bfr_not_passed_to_adptr;
206 unsigned long if_send_tx_int_enabled;
207 unsigned long if_send_consec_send_fail;
208} if_send_stat_t;
209
210typedef struct rx_intr_stat{
211 unsigned long rx_intr_no_socket;
212 unsigned long rx_intr_dev_not_started;
213 unsigned long rx_intr_PIPE_request;
214 unsigned long rx_intr_bfr_not_passed_to_stack;
215 unsigned long rx_intr_bfr_passed_to_stack;
216} rx_intr_stat_t;
217
218typedef struct pipe_mgmt_stat{
219 unsigned long UDP_PIPE_mgmt_kmalloc_err;
220 unsigned long UDP_PIPE_mgmt_direction_err;
221 unsigned long UDP_PIPE_mgmt_adptr_type_err;
222 unsigned long UDP_PIPE_mgmt_adptr_cmnd_OK;
223 unsigned long UDP_PIPE_mgmt_adptr_cmnd_timeout;
224 unsigned long UDP_PIPE_mgmt_adptr_send_passed;
225 unsigned long UDP_PIPE_mgmt_adptr_send_failed;
226 unsigned long UDP_PIPE_mgmt_not_passed_to_stack;
227 unsigned long UDP_PIPE_mgmt_passed_to_stack;
228 unsigned long UDP_PIPE_mgmt_no_socket;
229 unsigned long UDP_PIPE_mgmt_passed_to_adptr;
230} pipe_mgmt_stat_t;
231
232
233typedef struct {
234 struct sk_buff *skb;
235} bh_data_t, cmd_data_t;
236
237#define MAX_LGTH_UDP_MGNT_PKT 2000
238
239
240/* This is used for interrupt testing */
241#define INTR_TEST_MODE 0x02
242
243#define WUM_SIGNATURE_L 0x50495046
244#define WUM_SIGNATURE_H 0x444E3845
245
246#define WUM_KILL 0x50
247#define WUM_EXEC 0x51
248
249#define WANPIPE 0x00
250#define API 0x01
251#define BRIDGE 0x02
252#define BRIDGE_NODE 0x03
253
254#ifdef __KERNEL__
255/****** Kernel Interface ****************************************************/
256
257#include <linux/sdladrv.h> /* SDLA support module API definitions */
258#include <linux/sdlasfm.h> /* SDLA firmware module definitions */
259#include <linux/workqueue.h>
260#include <linux/serial.h>
261#include <linux/serialP.h>
262#include <linux/serial_reg.h>
263#include <asm/serial.h>
264#include <linux/tty.h>
265#include <linux/tty_driver.h>
266#include <linux/tty_flip.h>
267
268
269#define is_digit(ch) (((ch)>=(unsigned)'0'&&(ch)<=(unsigned)'9')?1:0)
270#define is_alpha(ch) ((((ch)>=(unsigned)'a'&&(ch)<=(unsigned)'z')||\
271 ((ch)>=(unsigned)'A'&&(ch)<=(unsigned)'Z'))?1:0)
272#define is_hex_digit(ch) ((((ch)>=(unsigned)'0'&&(ch)<=(unsigned)'9')||\
273 ((ch)>=(unsigned)'a'&&(ch)<=(unsigned)'f')||\
274 ((ch)>=(unsigned)'A'&&(ch)<=(unsigned)'F'))?1:0)
275
276
277/****** Data Structures *****************************************************/
278
279/* Adapter Data Space.
280 * This structure is needed because we handle multiple cards, otherwise
281 * static data would do it.
282 */
283typedef struct sdla
284{
285 char devname[WAN_DRVNAME_SZ+1]; /* card name */
286 sdlahw_t hw; /* hardware configuration */
287 struct wan_device wandev; /* WAN device data space */
288
289 unsigned open_cnt; /* number of open interfaces */
290 unsigned long state_tick; /* link state timestamp */
291 unsigned intr_mode; /* Type of Interrupt Mode */
292 char in_isr; /* interrupt-in-service flag */
293 char buff_int_mode_unbusy; /* flag for carrying out dev_tint */
294 char dlci_int_mode_unbusy; /* flag for carrying out dev_tint */
295 long configured; /* flag for previous configurations */
296
297 unsigned short irq_dis_if_send_count; /* Disabling irqs in if_send*/
298 unsigned short irq_dis_poll_count; /* Disabling irqs in poll routine*/
299 unsigned short force_enable_irq;
300 char TracingEnabled; /* flag for enabling trace */
301 global_stats_t statistics; /* global statistics */
302 void* mbox; /* -> mailbox */
303 void* rxmb; /* -> receive mailbox */
304 void* flags; /* -> adapter status flags */
305 void (*isr)(struct sdla* card); /* interrupt service routine */
306 void (*poll)(struct sdla* card); /* polling routine */
307 int (*exec)(struct sdla* card, void* u_cmd, void* u_data);
308 /* Used by the listen() system call */
309 /* Wanpipe Socket Interface */
310 int (*func) (struct sk_buff *, struct sock *);
311 struct sock *sk;
312
313 /* Shutdown function */
314 void (*disable_comm) (struct sdla *card);
315
316 /* Secondary Port Device: Piggibacking */
317 struct sdla *next;
318
319 /* TTY driver variables */
320 unsigned char tty_opt;
321 struct tty_struct *tty;
322 unsigned int tty_minor;
323 unsigned int tty_open;
324 unsigned char *tty_buf;
325 unsigned char *tty_rx;
326 struct work_struct tty_work;
327
328 union
329 {
330 struct
331 { /****** X.25 specific data **********/
332 u32 lo_pvc;
333 u32 hi_pvc;
334 u32 lo_svc;
335 u32 hi_svc;
336 struct net_device *svc_to_dev_map[MAX_X25_LCN];
337 struct net_device *pvc_to_dev_map[MAX_X25_LCN];
338 struct net_device *tx_dev;
339 struct net_device *cmd_dev;
340 u32 no_dev;
341 volatile u8 *hdlc_buf_status;
342 u32 tx_interrupts_pending;
343 u16 timer_int_enabled;
344 struct net_device *poll_device;
345 atomic_t command_busy;
346
347 u16 udp_pkt_lgth;
348 u32 udp_type;
349 u8 udp_pkt_src;
350 u32 udp_lcn;
351 struct net_device *udp_dev;
352 s8 udp_pkt_data[MAX_LGTH_UDP_MGNT_PKT];
353
354 u8 LAPB_hdlc; /* Option to turn off X25 and run only LAPB */
355 u8 logging; /* Option to log call messages */
356 u8 oob_on_modem; /* Option to send modem status to the api */
357 u16 num_of_ch; /* Number of channels configured by the user */
358
359 struct work_struct x25_poll_work;
360 struct timer_list x25_timer;
361 } x;
362 struct
363 { /****** frame relay specific data ***/
364 void* rxmb_base; /* -> first Rx buffer */
365 void* rxmb_last; /* -> last Rx buffer */
366 unsigned rx_base; /* S508 receive buffer base */
367 unsigned rx_top; /* S508 receive buffer end */
368 unsigned short node_dlci[100];
369 unsigned short dlci_num;
370 struct net_device *dlci_to_dev_map[991 + 1];
371 unsigned tx_interrupts_pending;
372 unsigned short timer_int_enabled;
373 unsigned short udp_pkt_lgth;
374 int udp_type;
375 char udp_pkt_src;
376 unsigned udp_dlci;
377 char udp_pkt_data[MAX_LGTH_UDP_MGNT_PKT];
378 void* trc_el_base; /* first trace element */
379 void* trc_el_last; /* last trace element */
380 void *curr_trc_el; /* current trace element */
381 unsigned short trc_bfr_space; /* trace buffer space */
382 unsigned char update_comms_stats;
383 struct net_device *arp_dev;
384 spinlock_t if_send_lock;
385 } f;
386 struct /****** PPP-specific data ***********/
387 {
388 char if_name[WAN_IFNAME_SZ+1]; /* interface name */
389 void* txbuf; /* -> current Tx buffer */
390 void* txbuf_base; /* -> first Tx buffer */
391 void* txbuf_last; /* -> last Tx buffer */
392 void* rxbuf_base; /* -> first Rx buffer */
393 void* rxbuf_last; /* -> last Rx buffer */
394 unsigned rx_base; /* S508 receive buffer base */
395 unsigned rx_top; /* S508 receive buffer end */
396 char ip_mode; /* STATIC/HOST/PEER IP Mode */
397 char authenticator; /* Authenticator for PAP/CHAP */
398 unsigned char comm_enabled; /* Is comm enabled or not */
399 unsigned char peer_route; /* Process Peer Route */
400 unsigned long *txbuf_next; /* Next Tx buffer to use */
401 unsigned long *rxbuf_next; /* Next Rx buffer to use */
402 } p;
403 struct /* Cisco HDLC-specific data */
404 {
405 char if_name[WAN_IFNAME_SZ+1]; /* interface name */
406 unsigned char comm_port;/* Communication Port O or 1 */
407 unsigned char usedby; /* Used by WANPIPE or API */
408 void* rxmb; /* Receive mail box */
409 void* flags; /* flags */
410 void* tx_status; /* Tx status element */
411 void* rx_status; /* Rx status element */
412 void* txbuf; /* -> current Tx buffer */
413 void* txbuf_base; /* -> first Tx buffer */
414 void* txbuf_last; /* -> last Tx buffer */
415 void* rxbuf_base; /* -> first Rx buffer */
416 void* rxbuf_last; /* -> last Rx buffer */
417 unsigned rx_base; /* S508 receive buffer base */
418 unsigned rx_top; /* S508 receive buffer end */
419 unsigned char receive_only; /* high speed receivers */
420 unsigned short protocol_options;
421 unsigned short kpalv_tx; /* Tx kpalv timer */
422 unsigned short kpalv_rx; /* Rx kpalv timer */
423 unsigned short kpalv_err; /* Error tolerance */
424 unsigned short slarp_timer; /* SLARP req timer */
425 unsigned state; /* state of the link */
426 unsigned char api_status;
427 unsigned char update_call_count;
428 unsigned short api_options; /* for async config */
429 unsigned char async_mode;
430 unsigned short tx_bits_per_char;
431 unsigned short rx_bits_per_char;
432 unsigned short stop_bits;
433 unsigned short parity;
434 unsigned short break_timer;
435 unsigned short inter_char_timer;
436 unsigned short rx_complete_length;
437 unsigned short xon_char;
438 unsigned short xoff_char;
439 unsigned char comm_enabled; /* Is comm enabled or not */
440 unsigned char backup;
441 } c;
442 struct
443 {
444 void* tx_status; /* Tx status element */
445 void* rx_status; /* Rx status element */
446 void* trace_status; /* Trace status element */
447 void* txbuf; /* -> current Tx buffer */
448 void* txbuf_base; /* -> first Tx buffer */
449 void* txbuf_last; /* -> last Tx buffer */
450 void* rxbuf_base; /* -> first Rx buffer */
451 void* rxbuf_last; /* -> last Rx buffer */
452 void* tracebuf; /* -> current Trace buffer */
453 void* tracebuf_base; /* -> current Trace buffer */
454 void* tracebuf_last; /* -> current Trace buffer */
455 unsigned rx_base; /* receive buffer base */
456 unsigned rx_end; /* receive buffer end */
457 unsigned trace_base; /* trace buffer base */
458 unsigned trace_end; /* trace buffer end */
459
460 } h;
461 } u;
462} sdla_t;
463
464/****** Public Functions ****************************************************/
465
466void wanpipe_open (sdla_t* card); /* wpmain.c */
467void wanpipe_close (sdla_t* card); /* wpmain.c */
468void wanpipe_set_state (sdla_t* card, int state); /* wpmain.c */
469
470int wpx_init (sdla_t* card, wandev_conf_t* conf); /* wpx.c */
471int wpf_init (sdla_t* card, wandev_conf_t* conf); /* wpf.c */
472int wpp_init (sdla_t* card, wandev_conf_t* conf); /* wpp.c */
473int wpc_init (sdla_t* card, wandev_conf_t* conf); /* Cisco HDLC */
474int bsc_init (sdla_t* card, wandev_conf_t* conf); /* BSC streaming */
475int hdlc_init(sdla_t* card, wandev_conf_t* conf); /* HDLC support */
476int wpft1_init (sdla_t* card, wandev_conf_t* conf); /* FT1 Config support */
477int wsppp_init (sdla_t* card, wandev_conf_t* conf); /* Sync PPP on top of RAW CHDLC */
478
479extern sdla_t * wanpipe_find_card(char *);
480extern sdla_t * wanpipe_find_card_num (int);
481
482extern void wanpipe_queue_work (struct work_struct *);
483extern void wanpipe_mark_bh (void);
484extern void wakeup_sk_bh(struct net_device *dev);
485extern int change_dev_flags(struct net_device *dev, unsigned flags);
486extern unsigned long get_ip_address(struct net_device *dev, int option);
487extern void add_gateway(sdla_t *card, struct net_device *dev);
488
489
490#endif /* __KERNEL__ */
491#endif /* _WANPIPE_H */
492
diff --git a/include/linux/wanrouter.h b/include/linux/wanrouter.h
new file mode 100644
index 000000000000..3e89f0f15f49
--- /dev/null
+++ b/include/linux/wanrouter.h
@@ -0,0 +1,541 @@
1/*****************************************************************************
2* wanrouter.h Definitions for the WAN Multiprotocol Router Module.
3* This module provides API and common services for WAN Link
4* Drivers and is completely hardware-independent.
5*
6* Author: Nenad Corbic <ncorbic@sangoma.com>
7* Gideon Hack
8* Additions: Arnaldo Melo
9*
10* Copyright: (c) 1995-2000 Sangoma Technologies Inc.
11*
12* This program is free software; you can redistribute it and/or
13* modify it under the terms of the GNU General Public License
14* as published by the Free Software Foundation; either version
15* 2 of the License, or (at your option) any later version.
16* ============================================================================
17* Jul 21, 2000 Nenad Corbic Added WAN_FT1_READY State
18* Feb 24, 2000 Nenad Corbic Added support for socket based x25api
19* Jan 28, 2000 Nenad Corbic Added support for the ASYNC protocol.
20* Oct 04, 1999 Nenad Corbic Updated for 2.1.0 release
21* Jun 02, 1999 Gideon Hack Added support for the S514 adapter.
22* May 23, 1999 Arnaldo Melo Added local_addr to wanif_conf_t
23* WAN_DISCONNECTING state added
24* Jul 20, 1998 David Fong Added Inverse ARP options to 'wanif_conf_t'
25* Jun 12, 1998 David Fong Added Cisco HDLC support.
26* Dec 16, 1997 Jaspreet Singh Moved 'enable_IPX' and 'network_number' to
27* 'wanif_conf_t'
28* Dec 05, 1997 Jaspreet Singh Added 'pap', 'chap' to 'wanif_conf_t'
29* Added 'authenticator' to 'wan_ppp_conf_t'
30* Nov 06, 1997 Jaspreet Singh Changed Router Driver version to 1.1 from 1.0
31* Oct 20, 1997 Jaspreet Singh Added 'cir','bc','be' and 'mc' to 'wanif_conf_t'
32* Added 'enable_IPX' and 'network_number' to
33* 'wan_device_t'. Also added defines for
34* UDP PACKET TYPE, Interrupt test, critical values
35* for RACE conditions.
36* Oct 05, 1997 Jaspreet Singh Added 'dlci_num' and 'dlci[100]' to
37* 'wan_fr_conf_t' to configure a list of dlci(s)
38* for a NODE
39* Jul 07, 1997 Jaspreet Singh Added 'ttl' to 'wandev_conf_t' & 'wan_device_t'
40* May 29, 1997 Jaspreet Singh Added 'tx_int_enabled' to 'wan_device_t'
41* May 21, 1997 Jaspreet Singh Added 'udp_port' to 'wan_device_t'
42* Apr 25, 1997 Farhan Thawar Added 'udp_port' to 'wandev_conf_t'
43* Jan 16, 1997 Gene Kozin router_devlist made public
44* Jan 02, 1997 Gene Kozin Initial version (based on wanpipe.h).
45*****************************************************************************/
46
47#include <linux/spinlock.h> /* Support for SMP Locking */
48
49#ifndef _ROUTER_H
50#define _ROUTER_H
51
52#define ROUTER_NAME "wanrouter" /* in case we ever change it */
53#define ROUTER_VERSION 1 /* version number */
54#define ROUTER_RELEASE 1 /* release (minor version) number */
55#define ROUTER_IOCTL 'W' /* for IOCTL calls */
56#define ROUTER_MAGIC 0x524D4157L /* signature: 'WANR' reversed */
57
58/* IOCTL codes for /proc/router/<device> entries (up to 255) */
59enum router_ioctls
60{
61 ROUTER_SETUP = ROUTER_IOCTL<<8, /* configure device */
62 ROUTER_DOWN, /* shut down device */
63 ROUTER_STAT, /* get device status */
64 ROUTER_IFNEW, /* add interface */
65 ROUTER_IFDEL, /* delete interface */
66 ROUTER_IFSTAT, /* get interface status */
67 ROUTER_USER = (ROUTER_IOCTL<<8)+16, /* driver-specific calls */
68 ROUTER_USER_MAX = (ROUTER_IOCTL<<8)+31
69};
70
71/* identifiers for displaying proc file data for dual port adapters */
72#define PROC_DATA_PORT_0 0x8000 /* the data is for port 0 */
73#define PROC_DATA_PORT_1 0x8001 /* the data is for port 1 */
74
75/* NLPID for packet encapsulation (ISO/IEC TR 9577) */
76#define NLPID_IP 0xCC /* Internet Protocol Datagram */
77#define NLPID_SNAP 0x80 /* IEEE Subnetwork Access Protocol */
78#define NLPID_CLNP 0x81 /* ISO/IEC 8473 */
79#define NLPID_ESIS 0x82 /* ISO/IEC 9542 */
80#define NLPID_ISIS 0x83 /* ISO/IEC ISIS */
81#define NLPID_Q933 0x08 /* CCITT Q.933 */
82
83/* Miscellaneous */
84#define WAN_IFNAME_SZ 15 /* max length of the interface name */
85#define WAN_DRVNAME_SZ 15 /* max length of the link driver name */
86#define WAN_ADDRESS_SZ 31 /* max length of the WAN media address */
87#define USED_BY_FIELD 8 /* max length of the used by field */
88
89/* Defines for UDP PACKET TYPE */
90#define UDP_PTPIPE_TYPE 0x01
91#define UDP_FPIPE_TYPE 0x02
92#define UDP_CPIPE_TYPE 0x03
93#define UDP_DRVSTATS_TYPE 0x04
94#define UDP_INVALID_TYPE 0x05
95
96/* Command return code */
97#define CMD_OK 0 /* normal firmware return code */
98#define CMD_TIMEOUT 0xFF /* firmware command timed out */
99
100/* UDP Packet Management */
101#define UDP_PKT_FRM_STACK 0x00
102#define UDP_PKT_FRM_NETWORK 0x01
103
104/* Maximum interrupt test counter */
105#define MAX_INTR_TEST_COUNTER 100
106
107/* Critical Values for RACE conditions*/
108#define CRITICAL_IN_ISR 0xA1
109#define CRITICAL_INTR_HANDLED 0xB1
110
111/****** Data Types **********************************************************/
112
113/*----------------------------------------------------------------------------
114 * X.25-specific link-level configuration.
115 */
116typedef struct wan_x25_conf
117{
118 unsigned lo_pvc; /* lowest permanent circuit number */
119 unsigned hi_pvc; /* highest permanent circuit number */
120 unsigned lo_svc; /* lowest switched circuit number */
121 unsigned hi_svc; /* highest switched circuit number */
122 unsigned hdlc_window; /* HDLC window size (1..7) */
123 unsigned pkt_window; /* X.25 packet window size (1..7) */
124 unsigned t1; /* HDLC timer T1, sec (1..30) */
125 unsigned t2; /* HDLC timer T2, sec (0..29) */
126 unsigned t4; /* HDLC supervisory frame timer = T4 * T1 */
127 unsigned n2; /* HDLC retransmission limit (1..30) */
128 unsigned t10_t20; /* X.25 RESTART timeout, sec (1..255) */
129 unsigned t11_t21; /* X.25 CALL timeout, sec (1..255) */
130 unsigned t12_t22; /* X.25 RESET timeout, sec (1..255) */
131 unsigned t13_t23; /* X.25 CLEAR timeout, sec (1..255) */
132 unsigned t16_t26; /* X.25 INTERRUPT timeout, sec (1..255) */
133 unsigned t28; /* X.25 REGISTRATION timeout, sec (1..255) */
134 unsigned r10_r20; /* RESTART retransmission limit (0..250) */
135 unsigned r12_r22; /* RESET retransmission limit (0..250) */
136 unsigned r13_r23; /* CLEAR retransmission limit (0..250) */
137 unsigned ccitt_compat; /* compatibility mode: 1988/1984/1980 */
138 unsigned x25_conf_opt; /* User defined x25 config optoins */
139 unsigned char LAPB_hdlc_only; /* Run in HDLC only mode */
140 unsigned char logging; /* Control connection logging */
141 unsigned char oob_on_modem; /* Whether to send modem status to the user app */
142} wan_x25_conf_t;
143
144/*----------------------------------------------------------------------------
145 * Frame relay specific link-level configuration.
146 */
147typedef struct wan_fr_conf
148{
149 unsigned signalling; /* local in-channel signalling type */
150 unsigned t391; /* link integrity verification timer */
151 unsigned t392; /* polling verification timer */
152 unsigned n391; /* full status polling cycle counter */
153 unsigned n392; /* error threshold counter */
154 unsigned n393; /* monitored events counter */
155 unsigned dlci_num; /* number of DLCs (access node) */
156 unsigned dlci[100]; /* List of all DLCIs */
157} wan_fr_conf_t;
158
159/*----------------------------------------------------------------------------
160 * PPP-specific link-level configuration.
161 */
162typedef struct wan_ppp_conf
163{
164 unsigned restart_tmr; /* restart timer */
165 unsigned auth_rsrt_tmr; /* authentication timer */
166 unsigned auth_wait_tmr; /* authentication timer */
167 unsigned mdm_fail_tmr; /* modem failure timer */
168 unsigned dtr_drop_tmr; /* DTR drop timer */
169 unsigned connect_tmout; /* connection timeout */
170 unsigned conf_retry; /* max. retry */
171 unsigned term_retry; /* max. retry */
172 unsigned fail_retry; /* max. retry */
173 unsigned auth_retry; /* max. retry */
174 unsigned auth_options; /* authentication opt. */
175 unsigned ip_options; /* IP options */
176 char authenticator; /* AUTHENTICATOR or not */
177 char ip_mode; /* Static/Host/Peer */
178} wan_ppp_conf_t;
179
180/*----------------------------------------------------------------------------
181 * CHDLC-specific link-level configuration.
182 */
183typedef struct wan_chdlc_conf
184{
185 unsigned char ignore_dcd; /* Protocol options: */
186 unsigned char ignore_cts; /* Ignore these to determine */
187 unsigned char ignore_keepalive; /* link status (Yes or No) */
188 unsigned char hdlc_streaming; /* hdlc_streaming mode (Y/N) */
189 unsigned char receive_only; /* no transmit buffering (Y/N) */
190 unsigned keepalive_tx_tmr; /* transmit keepalive timer */
191 unsigned keepalive_rx_tmr; /* receive keepalive timer */
192 unsigned keepalive_err_margin; /* keepalive_error_tolerance */
193 unsigned slarp_timer; /* SLARP request timer */
194} wan_chdlc_conf_t;
195
196
197/*----------------------------------------------------------------------------
198 * WAN device configuration. Passed to ROUTER_SETUP IOCTL.
199 */
200typedef struct wandev_conf
201{
202 unsigned magic; /* magic number (for verification) */
203 unsigned config_id; /* configuration structure identifier */
204 /****** hardware configuration ******/
205 unsigned ioport; /* adapter I/O port base */
206 unsigned long maddr; /* dual-port memory address */
207 unsigned msize; /* dual-port memory size */
208 int irq; /* interrupt request level */
209 int dma; /* DMA request level */
210 char S514_CPU_no[1]; /* S514 PCI adapter CPU number ('A' or 'B') */
211 unsigned PCI_slot_no; /* S514 PCI adapter slot number */
212 char auto_pci_cfg; /* S515 PCI automatic slot detection */
213 char comm_port; /* Communication Port (PRI=0, SEC=1) */
214 unsigned bps; /* data transfer rate */
215 unsigned mtu; /* maximum transmit unit size */
216 unsigned udp_port; /* UDP port for management */
217 unsigned char ttl; /* Time To Live for UDP security */
218 unsigned char ft1; /* FT1 Configurator Option */
219 char interface; /* RS-232/V.35, etc. */
220 char clocking; /* external/internal */
221 char line_coding; /* NRZ/NRZI/FM0/FM1, etc. */
222 char station; /* DTE/DCE, primary/secondary, etc. */
223 char connection; /* permanent/switched/on-demand */
224 char read_mode; /* read mode: Polling or interrupt */
225 char receive_only; /* disable tx buffers */
226 char tty; /* Create a fake tty device */
227 unsigned tty_major; /* Major number for wanpipe tty device */
228 unsigned tty_minor; /* Minor number for wanpipe tty device */
229 unsigned tty_mode; /* TTY operation mode SYNC or ASYNC */
230 char backup; /* Backup Mode */
231 unsigned hw_opt[4]; /* other hardware options */
232 unsigned reserved[4];
233 /****** arbitrary data ***************/
234 unsigned data_size; /* data buffer size */
235 void* data; /* data buffer, e.g. firmware */
236 union /****** protocol-specific ************/
237 {
238 wan_x25_conf_t x25; /* X.25 configuration */
239 wan_ppp_conf_t ppp; /* PPP configuration */
240 wan_fr_conf_t fr; /* frame relay configuration */
241 wan_chdlc_conf_t chdlc; /* Cisco HDLC configuration */
242 } u;
243} wandev_conf_t;
244
245/* 'config_id' definitions */
246#define WANCONFIG_X25 101 /* X.25 link */
247#define WANCONFIG_FR 102 /* frame relay link */
248#define WANCONFIG_PPP 103 /* synchronous PPP link */
249#define WANCONFIG_CHDLC 104 /* Cisco HDLC Link */
250#define WANCONFIG_BSC 105 /* BiSync Streaming */
251#define WANCONFIG_HDLC 106 /* HDLC Support */
252#define WANCONFIG_MPPP 107 /* Multi Port PPP over RAW CHDLC */
253
254/*
255 * Configuration options defines.
256 */
257/* general options */
258#define WANOPT_OFF 0
259#define WANOPT_ON 1
260#define WANOPT_NO 0
261#define WANOPT_YES 1
262
263/* intercace options */
264#define WANOPT_RS232 0
265#define WANOPT_V35 1
266
267/* data encoding options */
268#define WANOPT_NRZ 0
269#define WANOPT_NRZI 1
270#define WANOPT_FM0 2
271#define WANOPT_FM1 3
272
273/* link type options */
274#define WANOPT_POINTTOPOINT 0 /* RTS always active */
275#define WANOPT_MULTIDROP 1 /* RTS is active when transmitting */
276
277/* clocking options */
278#define WANOPT_EXTERNAL 0
279#define WANOPT_INTERNAL 1
280
281/* station options */
282#define WANOPT_DTE 0
283#define WANOPT_DCE 1
284#define WANOPT_CPE 0
285#define WANOPT_NODE 1
286#define WANOPT_SECONDARY 0
287#define WANOPT_PRIMARY 1
288
289/* connection options */
290#define WANOPT_PERMANENT 0 /* DTR always active */
291#define WANOPT_SWITCHED 1 /* use DTR to setup link (dial-up) */
292#define WANOPT_ONDEMAND 2 /* activate DTR only before sending */
293
294/* frame relay in-channel signalling */
295#define WANOPT_FR_ANSI 1 /* ANSI T1.617 Annex D */
296#define WANOPT_FR_Q933 2 /* ITU Q.933A */
297#define WANOPT_FR_LMI 3 /* LMI */
298
299/* PPP IP Mode Options */
300#define WANOPT_PPP_STATIC 0
301#define WANOPT_PPP_HOST 1
302#define WANOPT_PPP_PEER 2
303
304/* ASY Mode Options */
305#define WANOPT_ONE 1
306#define WANOPT_TWO 2
307#define WANOPT_ONE_AND_HALF 3
308
309#define WANOPT_NONE 0
310#define WANOPT_ODD 1
311#define WANOPT_EVEN 2
312
313/* CHDLC Protocol Options */
314/* DF Commmented out for now.
315
316#define WANOPT_CHDLC_NO_DCD IGNORE_DCD_FOR_LINK_STAT
317#define WANOPT_CHDLC_NO_CTS IGNORE_CTS_FOR_LINK_STAT
318#define WANOPT_CHDLC_NO_KEEPALIVE IGNORE_KPALV_FOR_LINK_STAT
319*/
320
321/* Port options */
322#define WANOPT_PRI 0
323#define WANOPT_SEC 1
324/* read mode */
325#define WANOPT_INTR 0
326#define WANOPT_POLL 1
327
328
329#define WANOPT_TTY_SYNC 0
330#define WANOPT_TTY_ASYNC 1
331/*----------------------------------------------------------------------------
332 * WAN Link Status Info (for ROUTER_STAT IOCTL).
333 */
334typedef struct wandev_stat
335{
336 unsigned state; /* link state */
337 unsigned ndev; /* number of configured interfaces */
338
339 /* link/interface configuration */
340 unsigned connection; /* permanent/switched/on-demand */
341 unsigned media_type; /* Frame relay/PPP/X.25/SDLC, etc. */
342 unsigned mtu; /* max. transmit unit for this device */
343
344 /* physical level statistics */
345 unsigned modem_status; /* modem status */
346 unsigned rx_frames; /* received frames count */
347 unsigned rx_overruns; /* receiver overrun error count */
348 unsigned rx_crc_err; /* receive CRC error count */
349 unsigned rx_aborts; /* received aborted frames count */
350 unsigned rx_bad_length; /* unexpetedly long/short frames count */
351 unsigned rx_dropped; /* frames discarded at device level */
352 unsigned tx_frames; /* transmitted frames count */
353 unsigned tx_underruns; /* aborted transmissions (underruns) count */
354 unsigned tx_timeouts; /* transmission timeouts */
355 unsigned tx_rejects; /* other transmit errors */
356
357 /* media level statistics */
358 unsigned rx_bad_format; /* frames with invalid format */
359 unsigned rx_bad_addr; /* frames with invalid media address */
360 unsigned tx_retries; /* frames re-transmitted */
361 unsigned reserved[16]; /* reserved for future use */
362} wandev_stat_t;
363
364/* 'state' defines */
365enum wan_states
366{
367 WAN_UNCONFIGURED, /* link/channel is not configured */
368 WAN_DISCONNECTED, /* link/channel is disconnected */
369 WAN_CONNECTING, /* connection is in progress */
370 WAN_CONNECTED, /* link/channel is operational */
371 WAN_LIMIT, /* for verification only */
372 WAN_DUALPORT, /* for Dual Port cards */
373 WAN_DISCONNECTING,
374 WAN_FT1_READY /* FT1 Configurator Ready */
375};
376
377enum {
378 WAN_LOCAL_IP,
379 WAN_POINTOPOINT_IP,
380 WAN_NETMASK_IP,
381 WAN_BROADCAST_IP
382};
383
384/* 'modem_status' masks */
385#define WAN_MODEM_CTS 0x0001 /* CTS line active */
386#define WAN_MODEM_DCD 0x0002 /* DCD line active */
387#define WAN_MODEM_DTR 0x0010 /* DTR line active */
388#define WAN_MODEM_RTS 0x0020 /* RTS line active */
389
390/*----------------------------------------------------------------------------
391 * WAN interface (logical channel) configuration (for ROUTER_IFNEW IOCTL).
392 */
393typedef struct wanif_conf
394{
395 unsigned magic; /* magic number */
396 unsigned config_id; /* configuration identifier */
397 char name[WAN_IFNAME_SZ+1]; /* interface name, ASCIIZ */
398 char addr[WAN_ADDRESS_SZ+1]; /* media address, ASCIIZ */
399 char usedby[USED_BY_FIELD]; /* used by API or WANPIPE */
400 unsigned idle_timeout; /* sec, before disconnecting */
401 unsigned hold_timeout; /* sec, before re-connecting */
402 unsigned cir; /* Committed Information Rate fwd,bwd*/
403 unsigned bc; /* Committed Burst Size fwd, bwd */
404 unsigned be; /* Excess Burst Size fwd, bwd */
405 unsigned char enable_IPX; /* Enable or Disable IPX */
406 unsigned char inarp; /* Send Inverse ARP requests Y/N */
407 unsigned inarp_interval; /* sec, between InARP requests */
408 unsigned long network_number; /* Network Number for IPX */
409 char mc; /* Multicast on or off */
410 char local_addr[WAN_ADDRESS_SZ+1];/* local media address, ASCIIZ */
411 unsigned char port; /* board port */
412 unsigned char protocol; /* prococol used in this channel (TCPOX25 or X25) */
413 char pap; /* PAP enabled or disabled */
414 char chap; /* CHAP enabled or disabled */
415 unsigned char userid[511]; /* List of User Id */
416 unsigned char passwd[511]; /* List of passwords */
417 unsigned char sysname[31]; /* Name of the system */
418 unsigned char ignore_dcd; /* Protocol options: */
419 unsigned char ignore_cts; /* Ignore these to determine */
420 unsigned char ignore_keepalive; /* link status (Yes or No) */
421 unsigned char hdlc_streaming; /* Hdlc streaming mode (Y/N) */
422 unsigned keepalive_tx_tmr; /* transmit keepalive timer */
423 unsigned keepalive_rx_tmr; /* receive keepalive timer */
424 unsigned keepalive_err_margin; /* keepalive_error_tolerance */
425 unsigned slarp_timer; /* SLARP request timer */
426 unsigned char ttl; /* Time To Live for UDP security */
427 char interface; /* RS-232/V.35, etc. */
428 char clocking; /* external/internal */
429 unsigned bps; /* data transfer rate */
430 unsigned mtu; /* maximum transmit unit size */
431 unsigned char if_down; /* brind down interface when disconnected */
432 unsigned char gateway; /* Is this interface a gateway */
433 unsigned char true_if_encoding; /* Set the dev->type to true board protocol */
434
435 unsigned char asy_data_trans; /* async API options */
436 unsigned char rts_hs_for_receive; /* async Protocol options */
437 unsigned char xon_xoff_hs_for_receive;
438 unsigned char xon_xoff_hs_for_transmit;
439 unsigned char dcd_hs_for_transmit;
440 unsigned char cts_hs_for_transmit;
441 unsigned char async_mode;
442 unsigned tx_bits_per_char;
443 unsigned rx_bits_per_char;
444 unsigned stop_bits;
445 unsigned char parity;
446 unsigned break_timer;
447 unsigned inter_char_timer;
448 unsigned rx_complete_length;
449 unsigned xon_char;
450 unsigned xoff_char;
451 unsigned char receive_only; /* no transmit buffering (Y/N) */
452} wanif_conf_t;
453
454#ifdef __KERNEL__
455/****** Kernel Interface ****************************************************/
456
457#include <linux/fs.h> /* support for device drivers */
458#include <linux/proc_fs.h> /* proc filesystem pragmatics */
459#include <linux/netdevice.h> /* support for network drivers */
460/*----------------------------------------------------------------------------
461 * WAN device data space.
462 */
463struct wan_device {
464 unsigned magic; /* magic number */
465 char* name; /* -> WAN device name (ASCIIZ) */
466 void* private; /* -> driver private data */
467 unsigned config_id; /* Configuration ID */
468 /****** hardware configuration ******/
469 unsigned ioport; /* adapter I/O port base #1 */
470 char S514_cpu_no[1]; /* PCI CPU Number */
471 unsigned char S514_slot_no; /* PCI Slot Number */
472 unsigned long maddr; /* dual-port memory address */
473 unsigned msize; /* dual-port memory size */
474 int irq; /* interrupt request level */
475 int dma; /* DMA request level */
476 unsigned bps; /* data transfer rate */
477 unsigned mtu; /* max physical transmit unit size */
478 unsigned udp_port; /* UDP port for management */
479 unsigned char ttl; /* Time To Live for UDP security */
480 unsigned enable_tx_int; /* Transmit Interrupt enabled or not */
481 char interface; /* RS-232/V.35, etc. */
482 char clocking; /* external/internal */
483 char line_coding; /* NRZ/NRZI/FM0/FM1, etc. */
484 char station; /* DTE/DCE, primary/secondary, etc. */
485 char connection; /* permanent/switched/on-demand */
486 char signalling; /* Signalling RS232 or V35 */
487 char read_mode; /* read mode: Polling or interrupt */
488 char new_if_cnt; /* Number of interfaces per wanpipe */
489 char del_if_cnt; /* Number of times del_if() gets called */
490 unsigned char piggyback; /* Piggibacking a port */
491 unsigned hw_opt[4]; /* other hardware options */
492 /****** status and statistics *******/
493 char state; /* device state */
494 char api_status; /* device api status */
495 struct net_device_stats stats; /* interface statistics */
496 unsigned reserved[16]; /* reserved for future use */
497 unsigned long critical; /* critical section flag */
498 spinlock_t lock; /* Support for SMP Locking */
499
500 /****** device management methods ***/
501 int (*setup) (struct wan_device *wandev, wandev_conf_t *conf);
502 int (*shutdown) (struct wan_device *wandev);
503 int (*update) (struct wan_device *wandev);
504 int (*ioctl) (struct wan_device *wandev, unsigned cmd,
505 unsigned long arg);
506 int (*new_if)(struct wan_device *wandev, struct net_device *dev,
507 wanif_conf_t *conf);
508 int (*del_if)(struct wan_device *wandev, struct net_device *dev);
509 /****** maintained by the router ****/
510 struct wan_device* next; /* -> next device */
511 struct net_device* dev; /* list of network interfaces */
512 unsigned ndev; /* number of interfaces */
513 struct proc_dir_entry *dent; /* proc filesystem entry */
514};
515
516/* Public functions available for device drivers */
517extern int register_wan_device(struct wan_device *wandev);
518extern int unregister_wan_device(char *name);
519unsigned short wanrouter_type_trans(struct sk_buff *skb,
520 struct net_device *dev);
521int wanrouter_encapsulate(struct sk_buff *skb, struct net_device *dev,
522 unsigned short type);
523
524/* Proc interface functions. These must not be called by the drivers! */
525extern int wanrouter_proc_init(void);
526extern void wanrouter_proc_cleanup(void);
527extern int wanrouter_proc_add(struct wan_device *wandev);
528extern int wanrouter_proc_delete(struct wan_device *wandev);
529extern int wanrouter_ioctl( struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg);
530
531extern void lock_adapter_irq(spinlock_t *lock, unsigned long *smp_flags);
532extern void unlock_adapter_irq(spinlock_t *lock, unsigned long *smp_flags);
533
534
535
536/* Public Data */
537/* list of registered devices */
538extern struct wan_device *wanrouter_router_devlist;
539
540#endif /* __KERNEL__ */
541#endif /* _ROUTER_H */
diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h
new file mode 100644
index 000000000000..88ba0d29f8c8
--- /dev/null
+++ b/include/linux/watchdog.h
@@ -0,0 +1,50 @@
1/*
2 * Generic watchdog defines. Derived from..
3 *
4 * Berkshire PC Watchdog Defines
5 * by Ken Hollis <khollis@bitgate.com>
6 *
7 */
8
9#ifndef _LINUX_WATCHDOG_H
10#define _LINUX_WATCHDOG_H
11
12#include <linux/ioctl.h>
13#include <linux/types.h>
14
15#define WATCHDOG_IOCTL_BASE 'W'
16
17struct watchdog_info {
18 __u32 options; /* Options the card/driver supports */
19 __u32 firmware_version; /* Firmware version of the card */
20 __u8 identity[32]; /* Identity of the board */
21};
22
23#define WDIOC_GETSUPPORT _IOR(WATCHDOG_IOCTL_BASE, 0, struct watchdog_info)
24#define WDIOC_GETSTATUS _IOR(WATCHDOG_IOCTL_BASE, 1, int)
25#define WDIOC_GETBOOTSTATUS _IOR(WATCHDOG_IOCTL_BASE, 2, int)
26#define WDIOC_GETTEMP _IOR(WATCHDOG_IOCTL_BASE, 3, int)
27#define WDIOC_SETOPTIONS _IOR(WATCHDOG_IOCTL_BASE, 4, int)
28#define WDIOC_KEEPALIVE _IOR(WATCHDOG_IOCTL_BASE, 5, int)
29#define WDIOC_SETTIMEOUT _IOWR(WATCHDOG_IOCTL_BASE, 6, int)
30#define WDIOC_GETTIMEOUT _IOR(WATCHDOG_IOCTL_BASE, 7, int)
31
32#define WDIOF_UNKNOWN -1 /* Unknown flag error */
33#define WDIOS_UNKNOWN -1 /* Unknown status error */
34
35#define WDIOF_OVERHEAT 0x0001 /* Reset due to CPU overheat */
36#define WDIOF_FANFAULT 0x0002 /* Fan failed */
37#define WDIOF_EXTERN1 0x0004 /* External relay 1 */
38#define WDIOF_EXTERN2 0x0008 /* External relay 2 */
39#define WDIOF_POWERUNDER 0x0010 /* Power bad/power fault */
40#define WDIOF_CARDRESET 0x0020 /* Card previously reset the CPU */
41#define WDIOF_POWEROVER 0x0040 /* Power over voltage */
42#define WDIOF_SETTIMEOUT 0x0080 /* Set timeout (in seconds) */
43#define WDIOF_MAGICCLOSE 0x0100 /* Supports magic close char */
44#define WDIOF_KEEPALIVEPING 0x8000 /* Keep alive ping reply */
45
46#define WDIOS_DISABLECARD 0x0001 /* Turn off the watchdog timer */
47#define WDIOS_ENABLECARD 0x0002 /* Turn on the watchdog timer */
48#define WDIOS_TEMPPANIC 0x0004 /* Kernel panic on temperature trip */
49
50#endif /* ifndef _LINUX_WATCHDOG_H */
diff --git a/include/linux/wavefront.h b/include/linux/wavefront.h
new file mode 100644
index 000000000000..61bd0fd35240
--- /dev/null
+++ b/include/linux/wavefront.h
@@ -0,0 +1,675 @@
1#ifndef __wavefront_h__
2#define __wavefront_h__
3
4/* WaveFront header file.
5 *
6 * Copyright (C) by Paul Barton-Davis 1998
7 *
8 * This program is distributed under the GNU GENERAL PUBLIC LICENSE (GPL)
9 * Version 2 (June 1991). See the "COPYING" file distributed with this software
10 * for more info.
11 */
12
13#if (!defined(__GNUC__) && !defined(__GNUG__))
14
15 You will not be able to compile this file correctly without gcc, because
16 it is necessary to pack the "wavefront_alias" structure to a size
17 of 22 bytes, corresponding to 16-bit alignment (as would have been
18 the case on the original platform, MS-DOS). If this is not done,
19 then WavePatch-format files cannot be read/written correctly.
20 The method used to do this here ("__attribute__((packed)") is
21 completely compiler dependent.
22
23 All other wavefront_* types end up aligned to 32 bit values and
24 still have the same (correct) size.
25
26#else
27
28 /* However, note that as of G++ 2.7.3.2, g++ was unable to
29 correctly parse *type* __attribute__ tags. It will do the
30 right thing if we use the "packed" attribute on each struct
31 member, which has the same semantics anyway.
32 */
33
34#endif /* __GNUC__ */
35
36/***************************** WARNING ********************************
37 PLEASE DO NOT MODIFY THIS FILE IN ANY WAY THAT AFFECTS ITS ABILITY TO
38 BE USED WITH EITHER C *OR* C++.
39 **********************************************************************/
40
41#ifndef NUM_MIDIKEYS
42#define NUM_MIDIKEYS 128
43#endif /* NUM_MIDIKEYS */
44
45#ifndef NUM_MIDICHANNELS
46#define NUM_MIDICHANNELS 16
47#endif /* NUM_MIDICHANNELS */
48
49/* These are very useful/important. the original wavefront interface
50 was developed on a 16 bit system, where sizeof(int) = 2
51 bytes. Defining things like this makes the code much more portable, and
52 easier to understand without having to toggle back and forth
53 between a 16-bit view of the world and a 32-bit one.
54 */
55
56typedef short INT16;
57typedef unsigned short UINT16;
58typedef int INT32;
59typedef unsigned int UINT32;
60typedef char CHAR8;
61typedef unsigned char UCHAR8;
62
63/* Pseudo-commands not part of the WaveFront command set.
64 These are used for various driver controls and direct
65 hardware control.
66 */
67
68#define WFC_DEBUG_DRIVER 0
69#define WFC_FX_IOCTL 1
70#define WFC_PATCH_STATUS 2
71#define WFC_PROGRAM_STATUS 3
72#define WFC_SAMPLE_STATUS 4
73#define WFC_DISABLE_INTERRUPTS 5
74#define WFC_ENABLE_INTERRUPTS 6
75#define WFC_INTERRUPT_STATUS 7
76#define WFC_ROMSAMPLES_RDONLY 8
77#define WFC_IDENTIFY_SLOT_TYPE 9
78
79/* Wavefront synth commands
80 */
81
82#define WFC_DOWNLOAD_SAMPLE 0x80
83#define WFC_DOWNLOAD_BLOCK 0x81
84#define WFC_DOWNLOAD_MULTISAMPLE 0x82
85#define WFC_DOWNLOAD_SAMPLE_ALIAS 0x83
86#define WFC_DELETE_SAMPLE 0x84
87#define WFC_REPORT_FREE_MEMORY 0x85
88#define WFC_DOWNLOAD_PATCH 0x86
89#define WFC_DOWNLOAD_PROGRAM 0x87
90#define WFC_SET_SYNTHVOL 0x89
91#define WFC_SET_NVOICES 0x8B
92#define WFC_DOWNLOAD_DRUM 0x90
93#define WFC_GET_SYNTHVOL 0x92
94#define WFC_GET_NVOICES 0x94
95#define WFC_DISABLE_CHANNEL 0x9A
96#define WFC_ENABLE_CHANNEL 0x9B
97#define WFC_MISYNTH_OFF 0x9D
98#define WFC_MISYNTH_ON 0x9E
99#define WFC_FIRMWARE_VERSION 0x9F
100#define WFC_GET_NSAMPLES 0xA0
101#define WFC_DISABLE_DRUM_PROGRAM 0xA2
102#define WFC_UPLOAD_PATCH 0xA3
103#define WFC_UPLOAD_PROGRAM 0xA4
104#define WFC_SET_TUNING 0xA6
105#define WFC_GET_TUNING 0xA7
106#define WFC_VMIDI_ON 0xA8
107#define WFC_VMIDI_OFF 0xA9
108#define WFC_MIDI_STATUS 0xAA
109#define WFC_GET_CHANNEL_STATUS 0xAB
110#define WFC_DOWNLOAD_SAMPLE_HEADER 0xAC
111#define WFC_UPLOAD_SAMPLE_HEADER 0xAD
112#define WFC_UPLOAD_MULTISAMPLE 0xAE
113#define WFC_UPLOAD_SAMPLE_ALIAS 0xAF
114#define WFC_IDENTIFY_SAMPLE_TYPE 0xB0
115#define WFC_DOWNLOAD_EDRUM_PROGRAM 0xB1
116#define WFC_UPLOAD_EDRUM_PROGRAM 0xB2
117#define WFC_SET_EDRUM_CHANNEL 0xB3
118#define WFC_INSTOUT_LEVELS 0xB4
119#define WFC_PEAKOUT_LEVELS 0xB5
120#define WFC_REPORT_CHANNEL_PROGRAMS 0xB6
121#define WFC_HARDWARE_VERSION 0xCF
122#define WFC_UPLOAD_SAMPLE_PARAMS 0xD7
123#define WFC_DOWNLOAD_OS 0xF1
124#define WFC_NOOP 0xFF
125
126#define WF_MAX_SAMPLE 512
127#define WF_MAX_PATCH 256
128#define WF_MAX_PROGRAM 128
129
130#define WF_SECTION_MAX 44 /* longest OS section length */
131
132/* # of bytes we send to the board when sending it various kinds of
133 substantive data, such as samples, patches and programs.
134*/
135
136#define WF_PROGRAM_BYTES 32
137#define WF_PATCH_BYTES 132
138#define WF_SAMPLE_BYTES 27
139#define WF_SAMPLE_HDR_BYTES 25
140#define WF_ALIAS_BYTES 25
141#define WF_DRUM_BYTES 9
142#define WF_MSAMPLE_BYTES 259 /* (MIDI_KEYS * 2) + 3 */
143
144#define WF_ACK 0x80
145#define WF_DMA_ACK 0x81
146
147/* OR-values for MIDI status bits */
148
149#define WF_MIDI_VIRTUAL_ENABLED 0x1
150#define WF_MIDI_VIRTUAL_IS_EXTERNAL 0x2
151#define WF_MIDI_IN_TO_SYNTH_DISABLED 0x4
152
153/* slot indexes for struct address_info: makes code a little more mnemonic */
154
155#define WF_SYNTH_SLOT 0
156#define WF_INTERNAL_MIDI_SLOT 1
157#define WF_EXTERNAL_MIDI_SLOT 2
158
159/* Magic MIDI bytes used to switch I/O streams on the ICS2115 MPU401
160 emulation. Note these NEVER show up in output from the device and
161 should NEVER be used in input unless Virtual MIDI mode has been
162 disabled. If they do show up as input, the results are unpredictable.
163*/
164
165#define WF_EXTERNAL_SWITCH 0xFD
166#define WF_INTERNAL_SWITCH 0xF9
167
168/* Debugging flags */
169
170#define WF_DEBUG_CMD 0x1
171#define WF_DEBUG_DATA 0x2
172#define WF_DEBUG_LOAD_PATCH 0x4
173#define WF_DEBUG_IO 0x8
174
175/* WavePatch file format stuff */
176
177#define WF_WAVEPATCH_VERSION 120; /* Current version number (1.2) */
178#define WF_MAX_COMMENT 64 /* Comment length */
179#define WF_NUM_LAYERS 4
180#define WF_NAME_LENGTH 32
181#define WF_SOURCE_LENGTH 260
182
183#define BankFileID "Bank"
184#define DrumkitFileID "DrumKit"
185#define ProgramFileID "Program"
186
187struct wf_envelope
188{
189 UCHAR8 attack_time:7;
190 UCHAR8 Unused1:1;
191
192 UCHAR8 decay1_time:7;
193 UCHAR8 Unused2:1;
194
195 UCHAR8 decay2_time:7;
196 UCHAR8 Unused3:1;
197
198 UCHAR8 sustain_time:7;
199 UCHAR8 Unused4:1;
200
201 UCHAR8 release_time:7;
202 UCHAR8 Unused5:1;
203
204 UCHAR8 release2_time:7;
205 UCHAR8 Unused6:1;
206
207 CHAR8 attack_level;
208 CHAR8 decay1_level;
209 CHAR8 decay2_level;
210 CHAR8 sustain_level;
211 CHAR8 release_level;
212
213 UCHAR8 attack_velocity:7;
214 UCHAR8 Unused7:1;
215
216 UCHAR8 volume_velocity:7;
217 UCHAR8 Unused8:1;
218
219 UCHAR8 keyboard_scaling:7;
220 UCHAR8 Unused9:1;
221};
222typedef struct wf_envelope wavefront_envelope;
223
224struct wf_lfo
225{
226 UCHAR8 sample_number;
227
228 UCHAR8 frequency:7;
229 UCHAR8 Unused1:1;
230
231 UCHAR8 am_src:4;
232 UCHAR8 fm_src:4;
233
234 CHAR8 fm_amount;
235 CHAR8 am_amount;
236 CHAR8 start_level;
237 CHAR8 end_level;
238
239 UCHAR8 ramp_delay:7;
240 UCHAR8 wave_restart:1; /* for LFO2 only */
241
242 UCHAR8 ramp_time:7;
243 UCHAR8 Unused2:1;
244};
245typedef struct wf_lfo wavefront_lfo;
246
247struct wf_patch
248{
249 INT16 frequency_bias; /* ** THIS IS IN MOTOROLA FORMAT!! ** */
250
251 UCHAR8 amplitude_bias:7;
252 UCHAR8 Unused1:1;
253
254 UCHAR8 portamento:7;
255 UCHAR8 Unused2:1;
256
257 UCHAR8 sample_number;
258
259 UCHAR8 pitch_bend:4;
260 UCHAR8 sample_msb:1;
261 UCHAR8 Unused3:3;
262
263 UCHAR8 mono:1;
264 UCHAR8 retrigger:1;
265 UCHAR8 nohold:1;
266 UCHAR8 restart:1;
267 UCHAR8 filterconfig:2; /* SDK says "not used" */
268 UCHAR8 reuse:1;
269 UCHAR8 reset_lfo:1;
270
271 UCHAR8 fm_src2:4;
272 UCHAR8 fm_src1:4;
273
274 CHAR8 fm_amount1;
275 CHAR8 fm_amount2;
276
277 UCHAR8 am_src:4;
278 UCHAR8 Unused4:4;
279
280 CHAR8 am_amount;
281
282 UCHAR8 fc1_mode:4;
283 UCHAR8 fc2_mode:4;
284
285 CHAR8 fc1_mod_amount;
286 CHAR8 fc1_keyboard_scaling;
287 CHAR8 fc1_bias;
288 CHAR8 fc2_mod_amount;
289 CHAR8 fc2_keyboard_scaling;
290 CHAR8 fc2_bias;
291
292 UCHAR8 randomizer:7;
293 UCHAR8 Unused5:1;
294
295 struct wf_envelope envelope1;
296 struct wf_envelope envelope2;
297 struct wf_lfo lfo1;
298 struct wf_lfo lfo2;
299};
300typedef struct wf_patch wavefront_patch;
301
302struct wf_layer
303{
304 UCHAR8 patch_number;
305
306 UCHAR8 mix_level:7;
307 UCHAR8 mute:1;
308
309 UCHAR8 split_point:7;
310 UCHAR8 play_below:1;
311
312 UCHAR8 pan_mod_src:2;
313 UCHAR8 pan_or_mod:1;
314 UCHAR8 pan:4;
315 UCHAR8 split_type:1;
316};
317typedef struct wf_layer wavefront_layer;
318
319struct wf_program
320{
321 struct wf_layer layer[WF_NUM_LAYERS];
322};
323typedef struct wf_program wavefront_program;
324
325struct wf_sample_offset
326{
327 INT32 Fraction:4;
328 INT32 Integer:20;
329 INT32 Unused:8;
330};
331typedef struct wf_sample_offset wavefront_sample_offset;
332
333/* Sample slot types */
334
335#define WF_ST_SAMPLE 0
336#define WF_ST_MULTISAMPLE 1
337#define WF_ST_ALIAS 2
338#define WF_ST_EMPTY 3
339
340/* pseudo's */
341
342#define WF_ST_DRUM 4
343#define WF_ST_PROGRAM 5
344#define WF_ST_PATCH 6
345#define WF_ST_SAMPLEHDR 7
346
347#define WF_ST_MASK 0xf
348
349/* Flags for slot status. These occupy the upper bits of the same byte
350 as a sample type.
351*/
352
353#define WF_SLOT_USED 0x80 /* XXX don't rely on this being accurate */
354#define WF_SLOT_FILLED 0x40
355#define WF_SLOT_ROM 0x20
356
357#define WF_SLOT_MASK 0xf0
358
359/* channel constants */
360
361#define WF_CH_MONO 0
362#define WF_CH_LEFT 1
363#define WF_CH_RIGHT 2
364
365/* Sample formats */
366
367#define LINEAR_16BIT 0
368#define WHITE_NOISE 1
369#define LINEAR_8BIT 2
370#define MULAW_8BIT 3
371
372#define WF_SAMPLE_IS_8BIT(smpl) ((smpl)->SampleResolution&2)
373
374
375/*
376
377 Because most/all of the sample data we pass in via pointers has
378 never been copied (just mmap-ed into user space straight from the
379 disk), it would be nice to allow handling of multi-channel sample
380 data without forcing user-level extraction of the relevant bytes.
381
382 So, we need a way of specifying which channel to use (the WaveFront
383 only handles mono samples in a given slot), and the only way to do
384 this without using some struct other than wavefront_sample as the
385 interface is the awful hack of using the unused bits in a
386 wavefront_sample:
387
388 Val Meaning
389 --- -------
390 0 no channel selection (use channel 1, sample is MONO)
391 1 use first channel, and skip one
392 2 use second channel, and skip one
393 3 use third channel, and skip two
394 4 use fourth channel, skip three
395 5 use fifth channel, skip four
396 6 use six channel, skip five
397
398
399 This can handle up to 4 channels, and anyone downloading >4 channels
400 of sample data just to select one of them needs to find some tools
401 like sox ...
402
403 NOTE: values 0, 1 and 2 correspond to WF_CH_* above. This is
404 important.
405
406*/
407
408#define WF_SET_CHANNEL(samp,chn) \
409 (samp)->Unused1 = chn & 0x1; \
410 (samp)->Unused2 = chn & 0x2; \
411 (samp)->Unused3 = chn & 0x4
412
413#define WF_GET_CHANNEL(samp) \
414 (((samp)->Unused3 << 2)|((samp)->Unused2<<1)|(samp)->Unused1)
415
416typedef struct wf_sample {
417 struct wf_sample_offset sampleStartOffset;
418 struct wf_sample_offset loopStartOffset;
419 struct wf_sample_offset loopEndOffset;
420 struct wf_sample_offset sampleEndOffset;
421 INT16 FrequencyBias;
422 UCHAR8 SampleResolution:2; /* sample_format */
423 UCHAR8 Unused1:1;
424 UCHAR8 Loop:1;
425 UCHAR8 Bidirectional:1;
426 UCHAR8 Unused2:1;
427 UCHAR8 Reverse:1;
428 UCHAR8 Unused3:1;
429} wavefront_sample;
430
431typedef struct wf_multisample {
432 INT16 NumberOfSamples; /* log2 of the number of samples */
433 INT16 SampleNumber[NUM_MIDIKEYS];
434} wavefront_multisample;
435
436typedef struct wf_alias {
437 INT16 OriginalSample __attribute__ ((packed));
438
439 struct wf_sample_offset sampleStartOffset __attribute__ ((packed));
440 struct wf_sample_offset loopStartOffset __attribute__ ((packed));
441 struct wf_sample_offset sampleEndOffset __attribute__ ((packed));
442 struct wf_sample_offset loopEndOffset __attribute__ ((packed));
443
444 INT16 FrequencyBias __attribute__ ((packed));
445
446 UCHAR8 SampleResolution:2 __attribute__ ((packed));
447 UCHAR8 Unused1:1 __attribute__ ((packed));
448 UCHAR8 Loop:1 __attribute__ ((packed));
449 UCHAR8 Bidirectional:1 __attribute__ ((packed));
450 UCHAR8 Unused2:1 __attribute__ ((packed));
451 UCHAR8 Reverse:1 __attribute__ ((packed));
452 UCHAR8 Unused3:1 __attribute__ ((packed));
453
454 /* This structure is meant to be padded only to 16 bits on their
455 original. Of course, whoever wrote their documentation didn't
456 realize that sizeof(struct) can be >=
457 sum(sizeof(struct-fields)) and so thought that giving a C level
458 description of the structs used in WavePatch files was
459 sufficient. I suppose it was, as long as you remember the
460 standard 16->32 bit issues.
461 */
462
463 UCHAR8 sixteen_bit_padding __attribute__ ((packed));
464} wavefront_alias;
465
466typedef struct wf_drum {
467 UCHAR8 PatchNumber;
468 UCHAR8 MixLevel:7;
469 UCHAR8 Unmute:1;
470 UCHAR8 Group:4;
471 UCHAR8 Unused1:4;
472 UCHAR8 PanModSource:2;
473 UCHAR8 PanModulated:1;
474 UCHAR8 PanAmount:4;
475 UCHAR8 Unused2:1;
476} wavefront_drum;
477
478typedef struct wf_drumkit {
479 struct wf_drum drum[NUM_MIDIKEYS];
480} wavefront_drumkit;
481
482typedef struct wf_channel_programs {
483 UCHAR8 Program[NUM_MIDICHANNELS];
484} wavefront_channel_programs;
485
486/* How to get MIDI channel status from the data returned by
487 a WFC_GET_CHANNEL_STATUS command (a struct wf_channel_programs)
488*/
489
490#define WF_CHANNEL_STATUS(ch,wcp) (wcp)[(ch/7)] & (1<<((ch)%7))
491
492typedef union wf_any {
493 wavefront_sample s;
494 wavefront_multisample ms;
495 wavefront_alias a;
496 wavefront_program pr;
497 wavefront_patch p;
498 wavefront_drum d;
499} wavefront_any;
500
501/* Hannu Solvainen hoped that his "patch_info" struct in soundcard.h
502 might work for other wave-table based patch loading situations.
503 Alas, his fears were correct. The WaveFront doesn't even come with
504 just "patches", but several different kind of structures that
505 control the sound generation process.
506 */
507
508typedef struct wf_patch_info {
509
510 /* the first two fields are used by the OSS "patch loading" interface
511 only, and are unused by the current user-level library.
512 */
513
514 INT16 key; /* Use WAVEFRONT_PATCH here */
515 UINT16 devno; /* fill in when sending */
516 UCHAR8 subkey; /* WF_ST_{SAMPLE,ALIAS,etc.} */
517
518#define WAVEFRONT_FIND_FREE_SAMPLE_SLOT 999
519
520 UINT16 number; /* patch/sample/prog number */
521
522 UINT32 size; /* size of any data included in
523 one of the fields in `hdrptr', or
524 as `dataptr'.
525
526 NOTE: for actual samples, this is
527 the size of the *SELECTED CHANNEL*
528 even if more data is actually available.
529
530 So, a stereo sample (2 channels) of
531 6000 bytes total has `size' = 3000.
532
533 See the macros and comments for
534 WF_{GET,SET}_CHANNEL above.
535
536 */
537 wavefront_any __user *hdrptr; /* user-space ptr to hdr bytes */
538 UINT16 __user *dataptr; /* actual sample data */
539
540 wavefront_any hdr; /* kernel-space copy of hdr bytes */
541} wavefront_patch_info;
542
543/* The maximum number of bytes we will ever move to or from user space
544 in response to a WFC_* command. This obviously doesn't cover
545 actual sample data.
546*/
547
548#define WF_MAX_READ sizeof(wavefront_multisample)
549#define WF_MAX_WRITE sizeof(wavefront_multisample)
550
551/*
552 This allows us to execute any WF command except the download/upload
553 ones, which are handled differently due to copyin/copyout issues as
554 well as data-nybbling to/from the card.
555 */
556
557typedef struct wavefront_control {
558 int cmd; /* WFC_* */
559 char status; /* return status to user-space */
560 unsigned char rbuf[WF_MAX_READ]; /* bytes read from card */
561 unsigned char wbuf[WF_MAX_WRITE]; /* bytes written to card */
562} wavefront_control;
563
564#define WFCTL_WFCMD 0x1
565#define WFCTL_LOAD_SPP 0x2
566
567/* Modulator table */
568
569#define WF_MOD_LFO1 0
570#define WF_MOD_LFO2 1
571#define WF_MOD_ENV1 2
572#define WF_MOD_ENV2 3
573#define WF_MOD_KEYBOARD 4
574#define WF_MOD_LOGKEY 5
575#define WF_MOD_VELOCITY 6
576#define WF_MOD_LOGVEL 7
577#define WF_MOD_RANDOM 8
578#define WF_MOD_PRESSURE 9
579#define WF_MOD_MOD_WHEEL 10
580#define WF_MOD_1 WF_MOD_MOD_WHEEL
581#define WF_MOD_BREATH 11
582#define WF_MOD_2 WF_MOD_BREATH
583#define WF_MOD_FOOT 12
584#define WF_MOD_4 WF_MOD_FOOT
585#define WF_MOD_VOLUME 13
586#define WF_MOD_7 WF_MOD_VOLUME
587#define WF_MOD_PAN 14
588#define WF_MOD_10 WF_MOD_PAN
589#define WF_MOD_EXPR 15
590#define WF_MOD_11 WF_MOD_EXPR
591
592/* FX-related material */
593
594typedef struct wf_fx_info {
595 int request; /* see list below */
596 int data[4]; /* we don't need much */
597} wavefront_fx_info;
598
599/* support for each of these will be forthcoming once I or someone
600 else has figured out which of the addresses on page 6 and page 7 of
601 the YSS225 control each parameter. Incidentally, these come from
602 the Windows driver interface, but again, Turtle Beach didn't
603 document the API to use them.
604*/
605
606#define WFFX_SETOUTGAIN 0
607#define WFFX_SETSTEREOOUTGAIN 1
608#define WFFX_SETREVERBIN1GAIN 2
609#define WFFX_SETREVERBIN2GAIN 3
610#define WFFX_SETREVERBIN3GAIN 4
611#define WFFX_SETCHORUSINPORT 5
612#define WFFX_SETREVERBIN1PORT 6
613#define WFFX_SETREVERBIN2PORT 7
614#define WFFX_SETREVERBIN3PORT 8
615#define WFFX_SETEFFECTPORT 9
616#define WFFX_SETAUXPORT 10
617#define WFFX_SETREVERBTYPE 11
618#define WFFX_SETREVERBDELAY 12
619#define WFFX_SETCHORUSLFO 13
620#define WFFX_SETCHORUSPMD 14
621#define WFFX_SETCHORUSAMD 15
622#define WFFX_SETEFFECT 16
623#define WFFX_SETBASEALL 17
624#define WFFX_SETREVERBALL 18
625#define WFFX_SETCHORUSALL 20
626#define WFFX_SETREVERBDEF 22
627#define WFFX_SETCHORUSDEF 23
628#define WFFX_DELAYSETINGAIN 24
629#define WFFX_DELAYSETFBGAIN 25
630#define WFFX_DELAYSETFBLPF 26
631#define WFFX_DELAYSETGAIN 27
632#define WFFX_DELAYSETTIME 28
633#define WFFX_DELAYSETFBTIME 29
634#define WFFX_DELAYSETALL 30
635#define WFFX_DELAYSETDEF 32
636#define WFFX_SDELAYSETINGAIN 33
637#define WFFX_SDELAYSETFBGAIN 34
638#define WFFX_SDELAYSETFBLPF 35
639#define WFFX_SDELAYSETGAIN 36
640#define WFFX_SDELAYSETTIME 37
641#define WFFX_SDELAYSETFBTIME 38
642#define WFFX_SDELAYSETALL 39
643#define WFFX_SDELAYSETDEF 41
644#define WFFX_DEQSETINGAIN 42
645#define WFFX_DEQSETFILTER 43
646#define WFFX_DEQSETALL 44
647#define WFFX_DEQSETDEF 46
648#define WFFX_MUTE 47
649#define WFFX_FLANGESETBALANCE 48
650#define WFFX_FLANGESETDELAY 49
651#define WFFX_FLANGESETDWFFX_TH 50
652#define WFFX_FLANGESETFBGAIN 51
653#define WFFX_FLANGESETINGAIN 52
654#define WFFX_FLANGESETLFO 53
655#define WFFX_FLANGESETALL 54
656#define WFFX_FLANGESETDEF 56
657#define WFFX_PITCHSETSHIFT 57
658#define WFFX_PITCHSETBALANCE 58
659#define WFFX_PITCHSETALL 59
660#define WFFX_PITCHSETDEF 61
661#define WFFX_SRSSETINGAIN 62
662#define WFFX_SRSSETSPACE 63
663#define WFFX_SRSSETCENTER 64
664#define WFFX_SRSSETGAIN 65
665#define WFFX_SRSSETMODE 66
666#define WFFX_SRSSETDEF 68
667
668/* Allow direct user-space control over FX memory/coefficient data.
669 In theory this could be used to download the FX microprogram,
670 but it would be a little slower, and involve some weird code.
671 */
672
673#define WFFX_MEMSET 69
674
675#endif /* __wavefront_h__ */
diff --git a/include/linux/wireless.h b/include/linux/wireless.h
new file mode 100644
index 000000000000..2f51f2b6562e
--- /dev/null
+++ b/include/linux/wireless.h
@@ -0,0 +1,773 @@
1/*
2 * This file define a set of standard wireless extensions
3 *
4 * Version : 17 21.6.04
5 *
6 * Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com>
7 * Copyright (c) 1997-2004 Jean Tourrilhes, All Rights Reserved.
8 */
9
10#ifndef _LINUX_WIRELESS_H
11#define _LINUX_WIRELESS_H
12
13/************************** DOCUMENTATION **************************/
14/*
15 * Initial APIs (1996 -> onward) :
16 * -----------------------------
17 * Basically, the wireless extensions are for now a set of standard ioctl
18 * call + /proc/net/wireless
19 *
20 * The entry /proc/net/wireless give statistics and information on the
21 * driver.
22 * This is better than having each driver having its entry because
23 * its centralised and we may remove the driver module safely.
24 *
25 * Ioctl are used to configure the driver and issue commands. This is
26 * better than command line options of insmod because we may want to
27 * change dynamically (while the driver is running) some parameters.
28 *
29 * The ioctl mechanimsm are copied from standard devices ioctl.
30 * We have the list of command plus a structure descibing the
31 * data exchanged...
32 * Note that to add these ioctl, I was obliged to modify :
33 * # net/core/dev.c (two place + add include)
34 * # net/ipv4/af_inet.c (one place + add include)
35 *
36 * /proc/net/wireless is a copy of /proc/net/dev.
37 * We have a structure for data passed from the driver to /proc/net/wireless
38 * Too add this, I've modified :
39 * # net/core/dev.c (two other places)
40 * # include/linux/netdevice.h (one place)
41 * # include/linux/proc_fs.h (one place)
42 *
43 * New driver API (2002 -> onward) :
44 * -------------------------------
45 * This file is only concerned with the user space API and common definitions.
46 * The new driver API is defined and documented in :
47 * # include/net/iw_handler.h
48 *
49 * Note as well that /proc/net/wireless implementation has now moved in :
50 * # net/core/wireless.c
51 *
52 * Wireless Events (2002 -> onward) :
53 * --------------------------------
54 * Events are defined at the end of this file, and implemented in :
55 * # net/core/wireless.c
56 *
57 * Other comments :
58 * --------------
59 * Do not add here things that are redundant with other mechanisms
60 * (drivers init, ifconfig, /proc/net/dev, ...) and with are not
61 * wireless specific.
62 *
63 * These wireless extensions are not magic : each driver has to provide
64 * support for them...
65 *
66 * IMPORTANT NOTE : As everything in the kernel, this is very much a
67 * work in progress. Contact me if you have ideas of improvements...
68 */
69
70/***************************** INCLUDES *****************************/
71
72/* To minimise problems in user space, I might remove those headers
73 * at some point. Jean II */
74#include <linux/types.h> /* for "caddr_t" et al */
75#include <linux/socket.h> /* for "struct sockaddr" et al */
76#include <linux/if.h> /* for IFNAMSIZ and co... */
77
78/***************************** VERSION *****************************/
79/*
80 * This constant is used to know the availability of the wireless
81 * extensions and to know which version of wireless extensions it is
82 * (there is some stuff that will be added in the future...)
83 * I just plan to increment with each new version.
84 */
85#define WIRELESS_EXT 17
86
87/*
88 * Changes :
89 *
90 * V2 to V3
91 * --------
92 * Alan Cox start some incompatibles changes. I've integrated a bit more.
93 * - Encryption renamed to Encode to avoid US regulation problems
94 * - Frequency changed from float to struct to avoid problems on old 386
95 *
96 * V3 to V4
97 * --------
98 * - Add sensitivity
99 *
100 * V4 to V5
101 * --------
102 * - Missing encoding definitions in range
103 * - Access points stuff
104 *
105 * V5 to V6
106 * --------
107 * - 802.11 support (ESSID ioctls)
108 *
109 * V6 to V7
110 * --------
111 * - define IW_ESSID_MAX_SIZE and IW_MAX_AP
112 *
113 * V7 to V8
114 * --------
115 * - Changed my e-mail address
116 * - More 802.11 support (nickname, rate, rts, frag)
117 * - List index in frequencies
118 *
119 * V8 to V9
120 * --------
121 * - Support for 'mode of operation' (ad-hoc, managed...)
122 * - Support for unicast and multicast power saving
123 * - Change encoding to support larger tokens (>64 bits)
124 * - Updated iw_params (disable, flags) and use it for NWID
125 * - Extracted iw_point from iwreq for clarity
126 *
127 * V9 to V10
128 * ---------
129 * - Add PM capability to range structure
130 * - Add PM modifier : MAX/MIN/RELATIVE
131 * - Add encoding option : IW_ENCODE_NOKEY
132 * - Add TxPower ioctls (work like TxRate)
133 *
134 * V10 to V11
135 * ----------
136 * - Add WE version in range (help backward/forward compatibility)
137 * - Add retry ioctls (work like PM)
138 *
139 * V11 to V12
140 * ----------
141 * - Add SIOCSIWSTATS to get /proc/net/wireless programatically
142 * - Add DEV PRIVATE IOCTL to avoid collisions in SIOCDEVPRIVATE space
143 * - Add new statistics (frag, retry, beacon)
144 * - Add average quality (for user space calibration)
145 *
146 * V12 to V13
147 * ----------
148 * - Document creation of new driver API.
149 * - Extract union iwreq_data from struct iwreq (for new driver API).
150 * - Rename SIOCSIWNAME as SIOCSIWCOMMIT
151 *
152 * V13 to V14
153 * ----------
154 * - Wireless Events support : define struct iw_event
155 * - Define additional specific event numbers
156 * - Add "addr" and "param" fields in union iwreq_data
157 * - AP scanning stuff (SIOCSIWSCAN and friends)
158 *
159 * V14 to V15
160 * ----------
161 * - Add IW_PRIV_TYPE_ADDR for struct sockaddr private arg
162 * - Make struct iw_freq signed (both m & e), add explicit padding
163 * - Add IWEVCUSTOM for driver specific event/scanning token
164 * - Add IW_MAX_GET_SPY for driver returning a lot of addresses
165 * - Add IW_TXPOW_RANGE for range of Tx Powers
166 * - Add IWEVREGISTERED & IWEVEXPIRED events for Access Points
167 * - Add IW_MODE_MONITOR for passive monitor
168 *
169 * V15 to V16
170 * ----------
171 * - Increase the number of bitrates in iw_range to 32 (for 802.11g)
172 * - Increase the number of frequencies in iw_range to 32 (for 802.11b+a)
173 * - Reshuffle struct iw_range for increases, add filler
174 * - Increase IW_MAX_AP to 64 for driver returning a lot of addresses
175 * - Remove IW_MAX_GET_SPY because conflict with enhanced spy support
176 * - Add SIOCSIWTHRSPY/SIOCGIWTHRSPY and "struct iw_thrspy"
177 * - Add IW_ENCODE_TEMP and iw_range->encoding_login_index
178 *
179 * V16 to V17
180 * ----------
181 * - Add flags to frequency -> auto/fixed
182 * - Document (struct iw_quality *)->updated, add new flags (INVALID)
183 * - Wireless Event capability in struct iw_range
184 * - Add support for relative TxPower (yick !)
185 */
186
187/**************************** CONSTANTS ****************************/
188
189/* -------------------------- IOCTL LIST -------------------------- */
190
191/* Wireless Identification */
192#define SIOCSIWCOMMIT 0x8B00 /* Commit pending changes to driver */
193#define SIOCGIWNAME 0x8B01 /* get name == wireless protocol */
194/* SIOCGIWNAME is used to verify the presence of Wireless Extensions.
195 * Common values : "IEEE 802.11-DS", "IEEE 802.11-FH", "IEEE 802.11b"...
196 * Don't put the name of your driver there, it's useless. */
197
198/* Basic operations */
199#define SIOCSIWNWID 0x8B02 /* set network id (pre-802.11) */
200#define SIOCGIWNWID 0x8B03 /* get network id (the cell) */
201#define SIOCSIWFREQ 0x8B04 /* set channel/frequency (Hz) */
202#define SIOCGIWFREQ 0x8B05 /* get channel/frequency (Hz) */
203#define SIOCSIWMODE 0x8B06 /* set operation mode */
204#define SIOCGIWMODE 0x8B07 /* get operation mode */
205#define SIOCSIWSENS 0x8B08 /* set sensitivity (dBm) */
206#define SIOCGIWSENS 0x8B09 /* get sensitivity (dBm) */
207
208/* Informative stuff */
209#define SIOCSIWRANGE 0x8B0A /* Unused */
210#define SIOCGIWRANGE 0x8B0B /* Get range of parameters */
211#define SIOCSIWPRIV 0x8B0C /* Unused */
212#define SIOCGIWPRIV 0x8B0D /* get private ioctl interface info */
213#define SIOCSIWSTATS 0x8B0E /* Unused */
214#define SIOCGIWSTATS 0x8B0F /* Get /proc/net/wireless stats */
215/* SIOCGIWSTATS is strictly used between user space and the kernel, and
216 * is never passed to the driver (i.e. the driver will never see it). */
217
218/* Spy support (statistics per MAC address - used for Mobile IP support) */
219#define SIOCSIWSPY 0x8B10 /* set spy addresses */
220#define SIOCGIWSPY 0x8B11 /* get spy info (quality of link) */
221#define SIOCSIWTHRSPY 0x8B12 /* set spy threshold (spy event) */
222#define SIOCGIWTHRSPY 0x8B13 /* get spy threshold */
223
224/* Access Point manipulation */
225#define SIOCSIWAP 0x8B14 /* set access point MAC addresses */
226#define SIOCGIWAP 0x8B15 /* get access point MAC addresses */
227#define SIOCGIWAPLIST 0x8B17 /* Deprecated in favor of scanning */
228#define SIOCSIWSCAN 0x8B18 /* trigger scanning (list cells) */
229#define SIOCGIWSCAN 0x8B19 /* get scanning results */
230
231/* 802.11 specific support */
232#define SIOCSIWESSID 0x8B1A /* set ESSID (network name) */
233#define SIOCGIWESSID 0x8B1B /* get ESSID */
234#define SIOCSIWNICKN 0x8B1C /* set node name/nickname */
235#define SIOCGIWNICKN 0x8B1D /* get node name/nickname */
236/* As the ESSID and NICKN are strings up to 32 bytes long, it doesn't fit
237 * within the 'iwreq' structure, so we need to use the 'data' member to
238 * point to a string in user space, like it is done for RANGE... */
239
240/* Other parameters useful in 802.11 and some other devices */
241#define SIOCSIWRATE 0x8B20 /* set default bit rate (bps) */
242#define SIOCGIWRATE 0x8B21 /* get default bit rate (bps) */
243#define SIOCSIWRTS 0x8B22 /* set RTS/CTS threshold (bytes) */
244#define SIOCGIWRTS 0x8B23 /* get RTS/CTS threshold (bytes) */
245#define SIOCSIWFRAG 0x8B24 /* set fragmentation thr (bytes) */
246#define SIOCGIWFRAG 0x8B25 /* get fragmentation thr (bytes) */
247#define SIOCSIWTXPOW 0x8B26 /* set transmit power (dBm) */
248#define SIOCGIWTXPOW 0x8B27 /* get transmit power (dBm) */
249#define SIOCSIWRETRY 0x8B28 /* set retry limits and lifetime */
250#define SIOCGIWRETRY 0x8B29 /* get retry limits and lifetime */
251
252/* Encoding stuff (scrambling, hardware security, WEP...) */
253#define SIOCSIWENCODE 0x8B2A /* set encoding token & mode */
254#define SIOCGIWENCODE 0x8B2B /* get encoding token & mode */
255/* Power saving stuff (power management, unicast and multicast) */
256#define SIOCSIWPOWER 0x8B2C /* set Power Management settings */
257#define SIOCGIWPOWER 0x8B2D /* get Power Management settings */
258
259/* -------------------- DEV PRIVATE IOCTL LIST -------------------- */
260
261/* These 32 ioctl are wireless device private, for 16 commands.
262 * Each driver is free to use them for whatever purpose it chooses,
263 * however the driver *must* export the description of those ioctls
264 * with SIOCGIWPRIV and *must* use arguments as defined below.
265 * If you don't follow those rules, DaveM is going to hate you (reason :
266 * it make mixed 32/64bit operation impossible).
267 */
268#define SIOCIWFIRSTPRIV 0x8BE0
269#define SIOCIWLASTPRIV 0x8BFF
270/* Previously, we were using SIOCDEVPRIVATE, but we now have our
271 * separate range because of collisions with other tools such as
272 * 'mii-tool'.
273 * We now have 32 commands, so a bit more space ;-).
274 * Also, all 'odd' commands are only usable by root and don't return the
275 * content of ifr/iwr to user (but you are not obliged to use the set/get
276 * convention, just use every other two command). More details in iwpriv.c.
277 * And I repeat : you are not forced to use them with iwpriv, but you
278 * must be compliant with it.
279 */
280
281/* ------------------------- IOCTL STUFF ------------------------- */
282
283/* The first and the last (range) */
284#define SIOCIWFIRST 0x8B00
285#define SIOCIWLAST SIOCIWLASTPRIV /* 0x8BFF */
286
287/* Even : get (world access), odd : set (root access) */
288#define IW_IS_SET(cmd) (!((cmd) & 0x1))
289#define IW_IS_GET(cmd) ((cmd) & 0x1)
290
291/* ----------------------- WIRELESS EVENTS ----------------------- */
292/* Those are *NOT* ioctls, do not issue request on them !!! */
293/* Most events use the same identifier as ioctl requests */
294
295#define IWEVTXDROP 0x8C00 /* Packet dropped to excessive retry */
296#define IWEVQUAL 0x8C01 /* Quality part of statistics (scan) */
297#define IWEVCUSTOM 0x8C02 /* Driver specific ascii string */
298#define IWEVREGISTERED 0x8C03 /* Discovered a new node (AP mode) */
299#define IWEVEXPIRED 0x8C04 /* Expired a node (AP mode) */
300
301#define IWEVFIRST 0x8C00
302
303/* ------------------------- PRIVATE INFO ------------------------- */
304/*
305 * The following is used with SIOCGIWPRIV. It allow a driver to define
306 * the interface (name, type of data) for its private ioctl.
307 * Privates ioctl are SIOCIWFIRSTPRIV -> SIOCIWLASTPRIV
308 */
309
310#define IW_PRIV_TYPE_MASK 0x7000 /* Type of arguments */
311#define IW_PRIV_TYPE_NONE 0x0000
312#define IW_PRIV_TYPE_BYTE 0x1000 /* Char as number */
313#define IW_PRIV_TYPE_CHAR 0x2000 /* Char as character */
314#define IW_PRIV_TYPE_INT 0x4000 /* 32 bits int */
315#define IW_PRIV_TYPE_FLOAT 0x5000 /* struct iw_freq */
316#define IW_PRIV_TYPE_ADDR 0x6000 /* struct sockaddr */
317
318#define IW_PRIV_SIZE_FIXED 0x0800 /* Variable or fixed number of args */
319
320#define IW_PRIV_SIZE_MASK 0x07FF /* Max number of those args */
321
322/*
323 * Note : if the number of args is fixed and the size < 16 octets,
324 * instead of passing a pointer we will put args in the iwreq struct...
325 */
326
327/* ----------------------- OTHER CONSTANTS ----------------------- */
328
329/* Maximum frequencies in the range struct */
330#define IW_MAX_FREQUENCIES 32
331/* Note : if you have something like 80 frequencies,
332 * don't increase this constant and don't fill the frequency list.
333 * The user will be able to set by channel anyway... */
334
335/* Maximum bit rates in the range struct */
336#define IW_MAX_BITRATES 32
337
338/* Maximum tx powers in the range struct */
339#define IW_MAX_TXPOWER 8
340/* Note : if you more than 8 TXPowers, just set the max and min or
341 * a few of them in the struct iw_range. */
342
343/* Maximum of address that you may set with SPY */
344#define IW_MAX_SPY 8
345
346/* Maximum of address that you may get in the
347 list of access points in range */
348#define IW_MAX_AP 64
349
350/* Maximum size of the ESSID and NICKN strings */
351#define IW_ESSID_MAX_SIZE 32
352
353/* Modes of operation */
354#define IW_MODE_AUTO 0 /* Let the driver decides */
355#define IW_MODE_ADHOC 1 /* Single cell network */
356#define IW_MODE_INFRA 2 /* Multi cell network, roaming, ... */
357#define IW_MODE_MASTER 3 /* Synchronisation master or Access Point */
358#define IW_MODE_REPEAT 4 /* Wireless Repeater (forwarder) */
359#define IW_MODE_SECOND 5 /* Secondary master/repeater (backup) */
360#define IW_MODE_MONITOR 6 /* Passive monitor (listen only) */
361
362/* Statistics flags (bitmask in updated) */
363#define IW_QUAL_QUAL_UPDATED 0x1 /* Value was updated since last read */
364#define IW_QUAL_LEVEL_UPDATED 0x2
365#define IW_QUAL_NOISE_UPDATED 0x4
366#define IW_QUAL_QUAL_INVALID 0x10 /* Driver doesn't provide value */
367#define IW_QUAL_LEVEL_INVALID 0x20
368#define IW_QUAL_NOISE_INVALID 0x40
369
370/* Frequency flags */
371#define IW_FREQ_AUTO 0x00 /* Let the driver decides */
372#define IW_FREQ_FIXED 0x01 /* Force a specific value */
373
374/* Maximum number of size of encoding token available
375 * they are listed in the range structure */
376#define IW_MAX_ENCODING_SIZES 8
377
378/* Maximum size of the encoding token in bytes */
379#define IW_ENCODING_TOKEN_MAX 32 /* 256 bits (for now) */
380
381/* Flags for encoding (along with the token) */
382#define IW_ENCODE_INDEX 0x00FF /* Token index (if needed) */
383#define IW_ENCODE_FLAGS 0xFF00 /* Flags defined below */
384#define IW_ENCODE_MODE 0xF000 /* Modes defined below */
385#define IW_ENCODE_DISABLED 0x8000 /* Encoding disabled */
386#define IW_ENCODE_ENABLED 0x0000 /* Encoding enabled */
387#define IW_ENCODE_RESTRICTED 0x4000 /* Refuse non-encoded packets */
388#define IW_ENCODE_OPEN 0x2000 /* Accept non-encoded packets */
389#define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not present */
390#define IW_ENCODE_TEMP 0x0400 /* Temporary key */
391
392/* Power management flags available (along with the value, if any) */
393#define IW_POWER_ON 0x0000 /* No details... */
394#define IW_POWER_TYPE 0xF000 /* Type of parameter */
395#define IW_POWER_PERIOD 0x1000 /* Value is a period/duration of */
396#define IW_POWER_TIMEOUT 0x2000 /* Value is a timeout (to go asleep) */
397#define IW_POWER_MODE 0x0F00 /* Power Management mode */
398#define IW_POWER_UNICAST_R 0x0100 /* Receive only unicast messages */
399#define IW_POWER_MULTICAST_R 0x0200 /* Receive only multicast messages */
400#define IW_POWER_ALL_R 0x0300 /* Receive all messages though PM */
401#define IW_POWER_FORCE_S 0x0400 /* Force PM procedure for sending unicast */
402#define IW_POWER_REPEATER 0x0800 /* Repeat broadcast messages in PM period */
403#define IW_POWER_MODIFIER 0x000F /* Modify a parameter */
404#define IW_POWER_MIN 0x0001 /* Value is a minimum */
405#define IW_POWER_MAX 0x0002 /* Value is a maximum */
406#define IW_POWER_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
407
408/* Transmit Power flags available */
409#define IW_TXPOW_TYPE 0x00FF /* Type of value */
410#define IW_TXPOW_DBM 0x0000 /* Value is in dBm */
411#define IW_TXPOW_MWATT 0x0001 /* Value is in mW */
412#define IW_TXPOW_RELATIVE 0x0002 /* Value is in arbitrary units */
413#define IW_TXPOW_RANGE 0x1000 /* Range of value between min/max */
414
415/* Retry limits and lifetime flags available */
416#define IW_RETRY_ON 0x0000 /* No details... */
417#define IW_RETRY_TYPE 0xF000 /* Type of parameter */
418#define IW_RETRY_LIMIT 0x1000 /* Maximum number of retries*/
419#define IW_RETRY_LIFETIME 0x2000 /* Maximum duration of retries in us */
420#define IW_RETRY_MODIFIER 0x000F /* Modify a parameter */
421#define IW_RETRY_MIN 0x0001 /* Value is a minimum */
422#define IW_RETRY_MAX 0x0002 /* Value is a maximum */
423#define IW_RETRY_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
424
425/* Scanning request flags */
426#define IW_SCAN_DEFAULT 0x0000 /* Default scan of the driver */
427#define IW_SCAN_ALL_ESSID 0x0001 /* Scan all ESSIDs */
428#define IW_SCAN_THIS_ESSID 0x0002 /* Scan only this ESSID */
429#define IW_SCAN_ALL_FREQ 0x0004 /* Scan all Frequencies */
430#define IW_SCAN_THIS_FREQ 0x0008 /* Scan only this Frequency */
431#define IW_SCAN_ALL_MODE 0x0010 /* Scan all Modes */
432#define IW_SCAN_THIS_MODE 0x0020 /* Scan only this Mode */
433#define IW_SCAN_ALL_RATE 0x0040 /* Scan all Bit-Rates */
434#define IW_SCAN_THIS_RATE 0x0080 /* Scan only this Bit-Rate */
435/* Maximum size of returned data */
436#define IW_SCAN_MAX_DATA 4096 /* In bytes */
437
438/* Max number of char in custom event - use multiple of them if needed */
439#define IW_CUSTOM_MAX 256 /* In bytes */
440
441/* Event capability macros - in (struct iw_range *)->event_capa
442 * Because we have more than 32 possible events, we use an array of
443 * 32 bit bitmasks. Note : 32 bits = 0x20 = 2^5. */
444#define IW_EVENT_CAPA_BASE(cmd) ((cmd >= SIOCIWFIRSTPRIV) ? \
445 (cmd - SIOCIWFIRSTPRIV + 0x60) : \
446 (cmd - SIOCSIWCOMMIT))
447#define IW_EVENT_CAPA_INDEX(cmd) (IW_EVENT_CAPA_BASE(cmd) >> 5)
448#define IW_EVENT_CAPA_MASK(cmd) (1 << (IW_EVENT_CAPA_BASE(cmd) & 0x1F))
449/* Event capability constants - event autogenerated by the kernel
450 * This list is valid for most 802.11 devices, customise as needed... */
451#define IW_EVENT_CAPA_K_0 (IW_EVENT_CAPA_MASK(0x8B04) | \
452 IW_EVENT_CAPA_MASK(0x8B06) | \
453 IW_EVENT_CAPA_MASK(0x8B1A))
454#define IW_EVENT_CAPA_K_1 (IW_EVENT_CAPA_MASK(0x8B2A))
455/* "Easy" macro to set events in iw_range (less efficient) */
456#define IW_EVENT_CAPA_SET(event_capa, cmd) (event_capa[IW_EVENT_CAPA_INDEX(cmd)] |= IW_EVENT_CAPA_MASK(cmd))
457#define IW_EVENT_CAPA_SET_KERNEL(event_capa) {event_capa[0] |= IW_EVENT_CAPA_K_0; event_capa[1] |= IW_EVENT_CAPA_K_1; }
458
459
460/****************************** TYPES ******************************/
461
462/* --------------------------- SUBTYPES --------------------------- */
463/*
464 * Generic format for most parameters that fit in an int
465 */
466struct iw_param
467{
468 __s32 value; /* The value of the parameter itself */
469 __u8 fixed; /* Hardware should not use auto select */
470 __u8 disabled; /* Disable the feature */
471 __u16 flags; /* Various specifc flags (if any) */
472};
473
474/*
475 * For all data larger than 16 octets, we need to use a
476 * pointer to memory allocated in user space.
477 */
478struct iw_point
479{
480 void __user *pointer; /* Pointer to the data (in user space) */
481 __u16 length; /* number of fields or size in bytes */
482 __u16 flags; /* Optional params */
483};
484
485/*
486 * A frequency
487 * For numbers lower than 10^9, we encode the number in 'm' and
488 * set 'e' to 0
489 * For number greater than 10^9, we divide it by the lowest power
490 * of 10 to get 'm' lower than 10^9, with 'm'= f / (10^'e')...
491 * The power of 10 is in 'e', the result of the division is in 'm'.
492 */
493struct iw_freq
494{
495 __s32 m; /* Mantissa */
496 __s16 e; /* Exponent */
497 __u8 i; /* List index (when in range struct) */
498 __u8 flags; /* Flags (fixed/auto) */
499};
500
501/*
502 * Quality of the link
503 */
504struct iw_quality
505{
506 __u8 qual; /* link quality (%retries, SNR,
507 %missed beacons or better...) */
508 __u8 level; /* signal level (dBm) */
509 __u8 noise; /* noise level (dBm) */
510 __u8 updated; /* Flags to know if updated */
511};
512
513/*
514 * Packet discarded in the wireless adapter due to
515 * "wireless" specific problems...
516 * Note : the list of counter and statistics in net_device_stats
517 * is already pretty exhaustive, and you should use that first.
518 * This is only additional stats...
519 */
520struct iw_discarded
521{
522 __u32 nwid; /* Rx : Wrong nwid/essid */
523 __u32 code; /* Rx : Unable to code/decode (WEP) */
524 __u32 fragment; /* Rx : Can't perform MAC reassembly */
525 __u32 retries; /* Tx : Max MAC retries num reached */
526 __u32 misc; /* Others cases */
527};
528
529/*
530 * Packet/Time period missed in the wireless adapter due to
531 * "wireless" specific problems...
532 */
533struct iw_missed
534{
535 __u32 beacon; /* Missed beacons/superframe */
536};
537
538/*
539 * Quality range (for spy threshold)
540 */
541struct iw_thrspy
542{
543 struct sockaddr addr; /* Source address (hw/mac) */
544 struct iw_quality qual; /* Quality of the link */
545 struct iw_quality low; /* Low threshold */
546 struct iw_quality high; /* High threshold */
547};
548
549/* ------------------------ WIRELESS STATS ------------------------ */
550/*
551 * Wireless statistics (used for /proc/net/wireless)
552 */
553struct iw_statistics
554{
555 __u16 status; /* Status
556 * - device dependent for now */
557
558 struct iw_quality qual; /* Quality of the link
559 * (instant/mean/max) */
560 struct iw_discarded discard; /* Packet discarded counts */
561 struct iw_missed miss; /* Packet missed counts */
562};
563
564/* ------------------------ IOCTL REQUEST ------------------------ */
565/*
566 * This structure defines the payload of an ioctl, and is used
567 * below.
568 *
569 * Note that this structure should fit on the memory footprint
570 * of iwreq (which is the same as ifreq), which mean a max size of
571 * 16 octets = 128 bits. Warning, pointers might be 64 bits wide...
572 * You should check this when increasing the structures defined
573 * above in this file...
574 */
575union iwreq_data
576{
577 /* Config - generic */
578 char name[IFNAMSIZ];
579 /* Name : used to verify the presence of wireless extensions.
580 * Name of the protocol/provider... */
581
582 struct iw_point essid; /* Extended network name */
583 struct iw_param nwid; /* network id (or domain - the cell) */
584 struct iw_freq freq; /* frequency or channel :
585 * 0-1000 = channel
586 * > 1000 = frequency in Hz */
587
588 struct iw_param sens; /* signal level threshold */
589 struct iw_param bitrate; /* default bit rate */
590 struct iw_param txpower; /* default transmit power */
591 struct iw_param rts; /* RTS threshold threshold */
592 struct iw_param frag; /* Fragmentation threshold */
593 __u32 mode; /* Operation mode */
594 struct iw_param retry; /* Retry limits & lifetime */
595
596 struct iw_point encoding; /* Encoding stuff : tokens */
597 struct iw_param power; /* PM duration/timeout */
598 struct iw_quality qual; /* Quality part of statistics */
599
600 struct sockaddr ap_addr; /* Access point address */
601 struct sockaddr addr; /* Destination address (hw/mac) */
602
603 struct iw_param param; /* Other small parameters */
604 struct iw_point data; /* Other large parameters */
605};
606
607/*
608 * The structure to exchange data for ioctl.
609 * This structure is the same as 'struct ifreq', but (re)defined for
610 * convenience...
611 * Do I need to remind you about structure size (32 octets) ?
612 */
613struct iwreq
614{
615 union
616 {
617 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "eth0" */
618 } ifr_ifrn;
619
620 /* Data part (defined just above) */
621 union iwreq_data u;
622};
623
624/* -------------------------- IOCTL DATA -------------------------- */
625/*
626 * For those ioctl which want to exchange mode data that what could
627 * fit in the above structure...
628 */
629
630/*
631 * Range of parameters
632 */
633
634struct iw_range
635{
636 /* Informative stuff (to choose between different interface) */
637 __u32 throughput; /* To give an idea... */
638 /* In theory this value should be the maximum benchmarked
639 * TCP/IP throughput, because with most of these devices the
640 * bit rate is meaningless (overhead an co) to estimate how
641 * fast the connection will go and pick the fastest one.
642 * I suggest people to play with Netperf or any benchmark...
643 */
644
645 /* NWID (or domain id) */
646 __u32 min_nwid; /* Minimal NWID we are able to set */
647 __u32 max_nwid; /* Maximal NWID we are able to set */
648
649 /* Old Frequency (backward compat - moved lower ) */
650 __u16 old_num_channels;
651 __u8 old_num_frequency;
652
653 /* Wireless event capability bitmasks */
654 __u32 event_capa[6];
655
656 /* signal level threshold range */
657 __s32 sensitivity;
658
659 /* Quality of link & SNR stuff */
660 /* Quality range (link, level, noise)
661 * If the quality is absolute, it will be in the range [0 ; max_qual],
662 * if the quality is dBm, it will be in the range [max_qual ; 0].
663 * Don't forget that we use 8 bit arithmetics... */
664 struct iw_quality max_qual; /* Quality of the link */
665 /* This should contain the average/typical values of the quality
666 * indicator. This should be the threshold between a "good" and
667 * a "bad" link (example : monitor going from green to orange).
668 * Currently, user space apps like quality monitors don't have any
669 * way to calibrate the measurement. With this, they can split
670 * the range between 0 and max_qual in different quality level
671 * (using a geometric subdivision centered on the average).
672 * I expect that people doing the user space apps will feedback
673 * us on which value we need to put in each driver... */
674 struct iw_quality avg_qual; /* Quality of the link */
675
676 /* Rates */
677 __u8 num_bitrates; /* Number of entries in the list */
678 __s32 bitrate[IW_MAX_BITRATES]; /* list, in bps */
679
680 /* RTS threshold */
681 __s32 min_rts; /* Minimal RTS threshold */
682 __s32 max_rts; /* Maximal RTS threshold */
683
684 /* Frag threshold */
685 __s32 min_frag; /* Minimal frag threshold */
686 __s32 max_frag; /* Maximal frag threshold */
687
688 /* Power Management duration & timeout */
689 __s32 min_pmp; /* Minimal PM period */
690 __s32 max_pmp; /* Maximal PM period */
691 __s32 min_pmt; /* Minimal PM timeout */
692 __s32 max_pmt; /* Maximal PM timeout */
693 __u16 pmp_flags; /* How to decode max/min PM period */
694 __u16 pmt_flags; /* How to decode max/min PM timeout */
695 __u16 pm_capa; /* What PM options are supported */
696
697 /* Encoder stuff */
698 __u16 encoding_size[IW_MAX_ENCODING_SIZES]; /* Different token sizes */
699 __u8 num_encoding_sizes; /* Number of entry in the list */
700 __u8 max_encoding_tokens; /* Max number of tokens */
701 /* For drivers that need a "login/passwd" form */
702 __u8 encoding_login_index; /* token index for login token */
703
704 /* Transmit power */
705 __u16 txpower_capa; /* What options are supported */
706 __u8 num_txpower; /* Number of entries in the list */
707 __s32 txpower[IW_MAX_TXPOWER]; /* list, in bps */
708
709 /* Wireless Extension version info */
710 __u8 we_version_compiled; /* Must be WIRELESS_EXT */
711 __u8 we_version_source; /* Last update of source */
712
713 /* Retry limits and lifetime */
714 __u16 retry_capa; /* What retry options are supported */
715 __u16 retry_flags; /* How to decode max/min retry limit */
716 __u16 r_time_flags; /* How to decode max/min retry life */
717 __s32 min_retry; /* Minimal number of retries */
718 __s32 max_retry; /* Maximal number of retries */
719 __s32 min_r_time; /* Minimal retry lifetime */
720 __s32 max_r_time; /* Maximal retry lifetime */
721
722 /* Frequency */
723 __u16 num_channels; /* Number of channels [0; num - 1] */
724 __u8 num_frequency; /* Number of entry in the list */
725 struct iw_freq freq[IW_MAX_FREQUENCIES]; /* list */
726 /* Note : this frequency list doesn't need to fit channel numbers,
727 * because each entry contain its channel index */
728};
729
730/*
731 * Private ioctl interface information
732 */
733
734struct iw_priv_args
735{
736 __u32 cmd; /* Number of the ioctl to issue */
737 __u16 set_args; /* Type and number of args */
738 __u16 get_args; /* Type and number of args */
739 char name[IFNAMSIZ]; /* Name of the extension */
740};
741
742/* ----------------------- WIRELESS EVENTS ----------------------- */
743/*
744 * Wireless events are carried through the rtnetlink socket to user
745 * space. They are encapsulated in the IFLA_WIRELESS field of
746 * a RTM_NEWLINK message.
747 */
748
749/*
750 * A Wireless Event. Contains basically the same data as the ioctl...
751 */
752struct iw_event
753{
754 __u16 len; /* Real lenght of this stuff */
755 __u16 cmd; /* Wireless IOCTL */
756 union iwreq_data u; /* IOCTL fixed payload */
757};
758
759/* Size of the Event prefix (including padding and alignement junk) */
760#define IW_EV_LCP_LEN (sizeof(struct iw_event) - sizeof(union iwreq_data))
761/* Size of the various events */
762#define IW_EV_CHAR_LEN (IW_EV_LCP_LEN + IFNAMSIZ)
763#define IW_EV_UINT_LEN (IW_EV_LCP_LEN + sizeof(__u32))
764#define IW_EV_FREQ_LEN (IW_EV_LCP_LEN + sizeof(struct iw_freq))
765#define IW_EV_POINT_LEN (IW_EV_LCP_LEN + sizeof(struct iw_point))
766#define IW_EV_PARAM_LEN (IW_EV_LCP_LEN + sizeof(struct iw_param))
767#define IW_EV_ADDR_LEN (IW_EV_LCP_LEN + sizeof(struct sockaddr))
768#define IW_EV_QUAL_LEN (IW_EV_LCP_LEN + sizeof(struct iw_quality))
769
770/* Note : in the case of iw_point, the extra data will come at the
771 * end of the event */
772
773#endif /* _LINUX_WIRELESS_H */
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
new file mode 100644
index 000000000000..ff46f537ba9b
--- /dev/null
+++ b/include/linux/workqueue.h
@@ -0,0 +1,90 @@
1/*
2 * workqueue.h --- work queue handling for Linux.
3 */
4
5#ifndef _LINUX_WORKQUEUE_H
6#define _LINUX_WORKQUEUE_H
7
8#include <linux/timer.h>
9#include <linux/linkage.h>
10#include <linux/bitops.h>
11
12struct workqueue_struct;
13
14struct work_struct {
15 unsigned long pending;
16 struct list_head entry;
17 void (*func)(void *);
18 void *data;
19 void *wq_data;
20 struct timer_list timer;
21};
22
23#define __WORK_INITIALIZER(n, f, d) { \
24 .entry = { &(n).entry, &(n).entry }, \
25 .func = (f), \
26 .data = (d), \
27 .timer = TIMER_INITIALIZER(NULL, 0, 0), \
28 }
29
30#define DECLARE_WORK(n, f, d) \
31 struct work_struct n = __WORK_INITIALIZER(n, f, d)
32
33/*
34 * initialize a work-struct's func and data pointers:
35 */
36#define PREPARE_WORK(_work, _func, _data) \
37 do { \
38 (_work)->func = _func; \
39 (_work)->data = _data; \
40 } while (0)
41
42/*
43 * initialize all of a work-struct:
44 */
45#define INIT_WORK(_work, _func, _data) \
46 do { \
47 INIT_LIST_HEAD(&(_work)->entry); \
48 (_work)->pending = 0; \
49 PREPARE_WORK((_work), (_func), (_data)); \
50 init_timer(&(_work)->timer); \
51 } while (0)
52
53extern struct workqueue_struct *__create_workqueue(const char *name,
54 int singlethread);
55#define create_workqueue(name) __create_workqueue((name), 0)
56#define create_singlethread_workqueue(name) __create_workqueue((name), 1)
57
58extern void destroy_workqueue(struct workqueue_struct *wq);
59
60extern int FASTCALL(queue_work(struct workqueue_struct *wq, struct work_struct *work));
61extern int FASTCALL(queue_delayed_work(struct workqueue_struct *wq, struct work_struct *work, unsigned long delay));
62extern void FASTCALL(flush_workqueue(struct workqueue_struct *wq));
63
64extern int FASTCALL(schedule_work(struct work_struct *work));
65extern int FASTCALL(schedule_delayed_work(struct work_struct *work, unsigned long delay));
66
67extern int schedule_delayed_work_on(int cpu, struct work_struct *work, unsigned long delay);
68extern void flush_scheduled_work(void);
69extern int current_is_keventd(void);
70extern int keventd_up(void);
71
72extern void init_workqueues(void);
73void cancel_rearming_delayed_work(struct work_struct *work);
74
75/*
76 * Kill off a pending schedule_delayed_work(). Note that the work callback
77 * function may still be running on return from cancel_delayed_work(). Run
78 * flush_scheduled_work() to wait on it.
79 */
80static inline int cancel_delayed_work(struct work_struct *work)
81{
82 int ret;
83
84 ret = del_timer_sync(&work->timer);
85 if (ret)
86 clear_bit(0, &work->pending);
87 return ret;
88}
89
90#endif
diff --git a/include/linux/writeback.h b/include/linux/writeback.h
new file mode 100644
index 000000000000..1262cb43c3ab
--- /dev/null
+++ b/include/linux/writeback.h
@@ -0,0 +1,118 @@
1/*
2 * include/linux/writeback.h.
3 */
4#ifndef WRITEBACK_H
5#define WRITEBACK_H
6
7struct backing_dev_info;
8
9extern spinlock_t inode_lock;
10extern struct list_head inode_in_use;
11extern struct list_head inode_unused;
12
13/*
14 * Yes, writeback.h requires sched.h
15 * No, sched.h is not included from here.
16 */
17static inline int current_is_pdflush(void)
18{
19 return current->flags & PF_FLUSHER;
20}
21
22/*
23 * fs/fs-writeback.c
24 */
25enum writeback_sync_modes {
26 WB_SYNC_NONE, /* Don't wait on anything */
27 WB_SYNC_ALL, /* Wait on every mapping */
28 WB_SYNC_HOLD, /* Hold the inode on sb_dirty for sys_sync() */
29};
30
31/*
32 * A control structure which tells the writeback code what to do. These are
33 * always on the stack, and hence need no locking. They are always initialised
34 * in a manner such that unspecified fields are set to zero.
35 */
36struct writeback_control {
37 struct backing_dev_info *bdi; /* If !NULL, only write back this
38 queue */
39 enum writeback_sync_modes sync_mode;
40 unsigned long *older_than_this; /* If !NULL, only write back inodes
41 older than this */
42 long nr_to_write; /* Write this many pages, and decrement
43 this for each page written */
44 long pages_skipped; /* Pages which were not written */
45
46 /*
47 * For a_ops->writepages(): is start or end are non-zero then this is
48 * a hint that the filesystem need only write out the pages inside that
49 * byterange. The byte at `end' is included in the writeout request.
50 */
51 loff_t start;
52 loff_t end;
53
54 unsigned nonblocking:1; /* Don't get stuck on request queues */
55 unsigned encountered_congestion:1; /* An output: a queue is full */
56 unsigned for_kupdate:1; /* A kupdate writeback */
57 unsigned for_reclaim:1; /* Invoked from the page allocator */
58};
59
60/*
61 * ->writepage() return values (make these much larger than a pagesize, in
62 * case some fs is returning number-of-bytes-written from writepage)
63 */
64#define WRITEPAGE_ACTIVATE 0x80000 /* IO was not started: activate page */
65
66/*
67 * fs/fs-writeback.c
68 */
69void writeback_inodes(struct writeback_control *wbc);
70void wake_up_inode(struct inode *inode);
71int inode_wait(void *);
72void sync_inodes_sb(struct super_block *, int wait);
73void sync_inodes(int wait);
74
75/* writeback.h requires fs.h; it, too, is not included from here. */
76static inline void wait_on_inode(struct inode *inode)
77{
78 might_sleep();
79 wait_on_bit(&inode->i_state, __I_LOCK, inode_wait,
80 TASK_UNINTERRUPTIBLE);
81}
82
83/*
84 * mm/page-writeback.c
85 */
86int wakeup_bdflush(long nr_pages);
87void laptop_io_completion(void);
88void laptop_sync_completion(void);
89void throttle_vm_writeout(void);
90
91/* These are exported to sysctl. */
92extern int dirty_background_ratio;
93extern int vm_dirty_ratio;
94extern int dirty_writeback_centisecs;
95extern int dirty_expire_centisecs;
96extern int block_dump;
97extern int laptop_mode;
98
99struct ctl_table;
100struct file;
101int dirty_writeback_centisecs_handler(struct ctl_table *, int, struct file *,
102 void __user *, size_t *, loff_t *);
103
104void page_writeback_init(void);
105void balance_dirty_pages_ratelimited(struct address_space *mapping);
106int pdflush_operation(void (*fn)(unsigned long), unsigned long arg0);
107int do_writepages(struct address_space *mapping, struct writeback_control *wbc);
108int sync_page_range(struct inode *inode, struct address_space *mapping,
109 loff_t pos, size_t count);
110int sync_page_range_nolock(struct inode *inode, struct address_space
111 *mapping, loff_t pos, size_t count);
112
113/* pdflush.c */
114extern int nr_pdflush_threads; /* Global so it can be exported to sysctl
115 read-only. */
116
117
118#endif /* WRITEBACK_H */
diff --git a/include/linux/x25.h b/include/linux/x25.h
new file mode 100644
index 000000000000..7531cfed5885
--- /dev/null
+++ b/include/linux/x25.h
@@ -0,0 +1,112 @@
1/*
2 * These are the public elements of the Linux kernel X.25 implementation.
3 *
4 * History
5 * mar/20/00 Daniela Squassoni Disabling/enabling of facilities
6 * negotiation.
7 */
8
9#ifndef X25_KERNEL_H
10#define X25_KERNEL_H
11
12#define SIOCX25GSUBSCRIP (SIOCPROTOPRIVATE + 0)
13#define SIOCX25SSUBSCRIP (SIOCPROTOPRIVATE + 1)
14#define SIOCX25GFACILITIES (SIOCPROTOPRIVATE + 2)
15#define SIOCX25SFACILITIES (SIOCPROTOPRIVATE + 3)
16#define SIOCX25GCALLUSERDATA (SIOCPROTOPRIVATE + 4)
17#define SIOCX25SCALLUSERDATA (SIOCPROTOPRIVATE + 5)
18#define SIOCX25GCAUSEDIAG (SIOCPROTOPRIVATE + 6)
19
20/*
21 * Values for {get,set}sockopt.
22 */
23#define X25_QBITINCL 1
24
25/*
26 * X.25 Packet Size values.
27 */
28#define X25_PS16 4
29#define X25_PS32 5
30#define X25_PS64 6
31#define X25_PS128 7
32#define X25_PS256 8
33#define X25_PS512 9
34#define X25_PS1024 10
35#define X25_PS2048 11
36#define X25_PS4096 12
37
38/*
39 * An X.121 address, it is held as ASCII text, null terminated, up to 15
40 * digits and a null terminator.
41 */
42struct x25_address {
43 char x25_addr[16];
44};
45
46/*
47 * Linux X.25 Address structure, used for bind, and connect mostly.
48 */
49struct sockaddr_x25 {
50 sa_family_t sx25_family; /* Must be AF_X25 */
51 struct x25_address sx25_addr; /* X.121 Address */
52};
53
54/*
55 * DTE/DCE subscription options.
56 *
57 * As this is missing lots of options, user should expect major
58 * changes of this structure in 2.5.x which might break compatibilty.
59 * The somewhat ugly dimension 200-sizeof() is needed to maintain
60 * backward compatibility.
61 */
62struct x25_subscrip_struct {
63 char device[200-sizeof(unsigned long)];
64 unsigned long global_facil_mask; /* 0 to disable negotiation */
65 unsigned int extended;
66};
67
68/* values for above global_facil_mask */
69
70#define X25_MASK_REVERSE 0x01
71#define X25_MASK_THROUGHPUT 0x02
72#define X25_MASK_PACKET_SIZE 0x04
73#define X25_MASK_WINDOW_SIZE 0x08
74
75
76
77/*
78 * Routing table control structure.
79 */
80struct x25_route_struct {
81 struct x25_address address;
82 unsigned int sigdigits;
83 char device[200];
84};
85
86/*
87 * Facilities structure.
88 */
89struct x25_facilities {
90 unsigned int winsize_in, winsize_out;
91 unsigned int pacsize_in, pacsize_out;
92 unsigned int throughput;
93 unsigned int reverse;
94};
95
96/*
97 * Call User Data structure.
98 */
99struct x25_calluserdata {
100 unsigned int cudlength;
101 unsigned char cuddata[128];
102};
103
104/*
105 * Call clearing Cause and Diagnostic structure.
106 */
107struct x25_causediag {
108 unsigned char cause;
109 unsigned char diagnostic;
110};
111
112#endif
diff --git a/include/linux/xattr.h b/include/linux/xattr.h
new file mode 100644
index 000000000000..23f9c61d9546
--- /dev/null
+++ b/include/linux/xattr.h
@@ -0,0 +1,33 @@
1/*
2 File: linux/xattr.h
3
4 Extended attributes handling.
5
6 Copyright (C) 2001 by Andreas Gruenbacher <a.gruenbacher@computer.org>
7 Copyright (c) 2001-2002 Silicon Graphics, Inc. All Rights Reserved.
8 Copyright (c) 2004 Red Hat, Inc., James Morris <jmorris@redhat.com>
9*/
10#ifndef _LINUX_XATTR_H
11#define _LINUX_XATTR_H
12
13#define XATTR_CREATE 0x1 /* set value, fail if attr already exists */
14#define XATTR_REPLACE 0x2 /* set value, fail if attr does not exist */
15
16#define XATTR_SECURITY_PREFIX "security."
17
18struct xattr_handler {
19 char *prefix;
20 size_t (*list)(struct inode *inode, char *list, size_t list_size,
21 const char *name, size_t name_len);
22 int (*get)(struct inode *inode, const char *name, void *buffer,
23 size_t size);
24 int (*set)(struct inode *inode, const char *name, const void *buffer,
25 size_t size, int flags);
26};
27
28ssize_t generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size);
29ssize_t generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size);
30int generic_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags);
31int generic_removexattr(struct dentry *dentry, const char *name);
32
33#endif /* _LINUX_XATTR_H */
diff --git a/include/linux/xattr_acl.h b/include/linux/xattr_acl.h
new file mode 100644
index 000000000000..7a1f9b93a45f
--- /dev/null
+++ b/include/linux/xattr_acl.h
@@ -0,0 +1,50 @@
1/*
2 File: linux/xattr_acl.h
3
4 (extended attribute representation of access control lists)
5
6 (C) 2000 Andreas Gruenbacher, <a.gruenbacher@computer.org>
7*/
8
9#ifndef _LINUX_XATTR_ACL_H
10#define _LINUX_XATTR_ACL_H
11
12#include <linux/posix_acl.h>
13
14#define XATTR_NAME_ACL_ACCESS "system.posix_acl_access"
15#define XATTR_NAME_ACL_DEFAULT "system.posix_acl_default"
16
17#define XATTR_ACL_VERSION 0x0002
18
19typedef struct {
20 __u16 e_tag;
21 __u16 e_perm;
22 __u32 e_id;
23} xattr_acl_entry;
24
25typedef struct {
26 __u32 a_version;
27 xattr_acl_entry a_entries[0];
28} xattr_acl_header;
29
30static inline size_t xattr_acl_size(int count)
31{
32 return sizeof(xattr_acl_header) + count * sizeof(xattr_acl_entry);
33}
34
35static inline int xattr_acl_count(size_t size)
36{
37 if (size < sizeof(xattr_acl_header))
38 return -1;
39 size -= sizeof(xattr_acl_header);
40 if (size % sizeof(xattr_acl_entry))
41 return -1;
42 return size / sizeof(xattr_acl_entry);
43}
44
45struct posix_acl * posix_acl_from_xattr(const void *value, size_t size);
46int posix_acl_to_xattr(const struct posix_acl *acl, void *buffer, size_t size);
47
48
49
50#endif /* _LINUX_XATTR_ACL_H */
diff --git a/include/linux/xfrm.h b/include/linux/xfrm.h
new file mode 100644
index 000000000000..f0df02ae68a4
--- /dev/null
+++ b/include/linux/xfrm.h
@@ -0,0 +1,258 @@
1#ifndef _LINUX_XFRM_H
2#define _LINUX_XFRM_H
3
4#include <linux/types.h>
5
6/* All of the structures in this file may not change size as they are
7 * passed into the kernel from userspace via netlink sockets.
8 */
9
10/* Structure to encapsulate addresses. I do not want to use
11 * "standard" structure. My apologies.
12 */
13typedef union
14{
15 __u32 a4;
16 __u32 a6[4];
17} xfrm_address_t;
18
19/* Ident of a specific xfrm_state. It is used on input to lookup
20 * the state by (spi,daddr,ah/esp) or to store information about
21 * spi, protocol and tunnel address on output.
22 */
23struct xfrm_id
24{
25 xfrm_address_t daddr;
26 __u32 spi;
27 __u8 proto;
28};
29
30/* Selector, used as selector both on policy rules (SPD) and SAs. */
31
32struct xfrm_selector
33{
34 xfrm_address_t daddr;
35 xfrm_address_t saddr;
36 __u16 dport;
37 __u16 dport_mask;
38 __u16 sport;
39 __u16 sport_mask;
40 __u16 family;
41 __u8 prefixlen_d;
42 __u8 prefixlen_s;
43 __u8 proto;
44 int ifindex;
45 uid_t user;
46};
47
48#define XFRM_INF (~(__u64)0)
49
50struct xfrm_lifetime_cfg
51{
52 __u64 soft_byte_limit;
53 __u64 hard_byte_limit;
54 __u64 soft_packet_limit;
55 __u64 hard_packet_limit;
56 __u64 soft_add_expires_seconds;
57 __u64 hard_add_expires_seconds;
58 __u64 soft_use_expires_seconds;
59 __u64 hard_use_expires_seconds;
60};
61
62struct xfrm_lifetime_cur
63{
64 __u64 bytes;
65 __u64 packets;
66 __u64 add_time;
67 __u64 use_time;
68};
69
70struct xfrm_replay_state
71{
72 __u32 oseq;
73 __u32 seq;
74 __u32 bitmap;
75};
76
77struct xfrm_algo {
78 char alg_name[64];
79 int alg_key_len; /* in bits */
80 char alg_key[0];
81};
82
83struct xfrm_stats {
84 __u32 replay_window;
85 __u32 replay;
86 __u32 integrity_failed;
87};
88
89enum
90{
91 XFRM_POLICY_IN = 0,
92 XFRM_POLICY_OUT = 1,
93 XFRM_POLICY_FWD = 2,
94 XFRM_POLICY_MAX = 3
95};
96
97enum
98{
99 XFRM_SHARE_ANY, /* No limitations */
100 XFRM_SHARE_SESSION, /* For this session only */
101 XFRM_SHARE_USER, /* For this user only */
102 XFRM_SHARE_UNIQUE /* Use once */
103};
104
105/* Netlink configuration messages. */
106enum {
107 XFRM_MSG_BASE = 0x10,
108
109 XFRM_MSG_NEWSA = 0x10,
110#define XFRM_MSG_NEWSA XFRM_MSG_NEWSA
111 XFRM_MSG_DELSA,
112#define XFRM_MSG_DELSA XFRM_MSG_DELSA
113 XFRM_MSG_GETSA,
114#define XFRM_MSG_GETSA XFRM_MSG_GETSA
115
116 XFRM_MSG_NEWPOLICY,
117#define XFRM_MSG_NEWPOLICY XFRM_MSG_NEWPOLICY
118 XFRM_MSG_DELPOLICY,
119#define XFRM_MSG_DELPOLICY XFRM_MSG_DELPOLICY
120 XFRM_MSG_GETPOLICY,
121#define XFRM_MSG_GETPOLICY XFRM_MSG_GETPOLICY
122
123 XFRM_MSG_ALLOCSPI,
124#define XFRM_MSG_ALLOCSPI XFRM_MSG_ALLOCSPI
125 XFRM_MSG_ACQUIRE,
126#define XFRM_MSG_ACQUIRE XFRM_MSG_ACQUIRE
127 XFRM_MSG_EXPIRE,
128#define XFRM_MSG_EXPIRE XFRM_MSG_EXPIRE
129
130 XFRM_MSG_UPDPOLICY,
131#define XFRM_MSG_UPDPOLICY XFRM_MSG_UPDPOLICY
132 XFRM_MSG_UPDSA,
133#define XFRM_MSG_UPDSA XFRM_MSG_UPDSA
134
135 XFRM_MSG_POLEXPIRE,
136#define XFRM_MSG_POLEXPIRE XFRM_MSG_POLEXPIRE
137
138 XFRM_MSG_FLUSHSA,
139#define XFRM_MSG_FLUSHSA XFRM_MSG_FLUSHSA
140 XFRM_MSG_FLUSHPOLICY,
141#define XFRM_MSG_FLUSHPOLICY XFRM_MSG_FLUSHPOLICY
142
143 XFRM_MSG_MAX
144};
145
146struct xfrm_user_tmpl {
147 struct xfrm_id id;
148 __u16 family;
149 xfrm_address_t saddr;
150 __u32 reqid;
151 __u8 mode;
152 __u8 share;
153 __u8 optional;
154 __u32 aalgos;
155 __u32 ealgos;
156 __u32 calgos;
157};
158
159struct xfrm_encap_tmpl {
160 __u16 encap_type;
161 __u16 encap_sport;
162 __u16 encap_dport;
163 xfrm_address_t encap_oa;
164};
165
166/* Netlink message attributes. */
167enum xfrm_attr_type_t {
168 XFRMA_UNSPEC,
169 XFRMA_ALG_AUTH, /* struct xfrm_algo */
170 XFRMA_ALG_CRYPT, /* struct xfrm_algo */
171 XFRMA_ALG_COMP, /* struct xfrm_algo */
172 XFRMA_ENCAP, /* struct xfrm_algo + struct xfrm_encap_tmpl */
173 XFRMA_TMPL, /* 1 or more struct xfrm_user_tmpl */
174 __XFRMA_MAX
175
176#define XFRMA_MAX (__XFRMA_MAX - 1)
177};
178
179struct xfrm_usersa_info {
180 struct xfrm_selector sel;
181 struct xfrm_id id;
182 xfrm_address_t saddr;
183 struct xfrm_lifetime_cfg lft;
184 struct xfrm_lifetime_cur curlft;
185 struct xfrm_stats stats;
186 __u32 seq;
187 __u32 reqid;
188 __u16 family;
189 __u8 mode; /* 0=transport,1=tunnel */
190 __u8 replay_window;
191 __u8 flags;
192#define XFRM_STATE_NOECN 1
193#define XFRM_STATE_DECAP_DSCP 2
194};
195
196struct xfrm_usersa_id {
197 xfrm_address_t daddr;
198 __u32 spi;
199 __u16 family;
200 __u8 proto;
201};
202
203struct xfrm_userspi_info {
204 struct xfrm_usersa_info info;
205 __u32 min;
206 __u32 max;
207};
208
209struct xfrm_userpolicy_info {
210 struct xfrm_selector sel;
211 struct xfrm_lifetime_cfg lft;
212 struct xfrm_lifetime_cur curlft;
213 __u32 priority;
214 __u32 index;
215 __u8 dir;
216 __u8 action;
217#define XFRM_POLICY_ALLOW 0
218#define XFRM_POLICY_BLOCK 1
219 __u8 flags;
220#define XFRM_POLICY_LOCALOK 1 /* Allow user to override global policy */
221 __u8 share;
222};
223
224struct xfrm_userpolicy_id {
225 struct xfrm_selector sel;
226 __u32 index;
227 __u8 dir;
228};
229
230struct xfrm_user_acquire {
231 struct xfrm_id id;
232 xfrm_address_t saddr;
233 struct xfrm_selector sel;
234 struct xfrm_userpolicy_info policy;
235 __u32 aalgos;
236 __u32 ealgos;
237 __u32 calgos;
238 __u32 seq;
239};
240
241struct xfrm_user_expire {
242 struct xfrm_usersa_info state;
243 __u8 hard;
244};
245
246struct xfrm_user_polexpire {
247 struct xfrm_userpolicy_info pol;
248 __u8 hard;
249};
250
251struct xfrm_usersa_flush {
252 __u8 proto;
253};
254
255#define XFRMGRP_ACQUIRE 1
256#define XFRMGRP_EXPIRE 2
257
258#endif /* _LINUX_XFRM_H */
diff --git a/include/linux/yam.h b/include/linux/yam.h
new file mode 100644
index 000000000000..7fe28228b274
--- /dev/null
+++ b/include/linux/yam.h
@@ -0,0 +1,82 @@
1/*****************************************************************************/
2
3/*
4 * yam.h -- YAM radio modem driver.
5 *
6 * Copyright (C) 1998 Frederic Rible F1OAT (frible@teaser.fr)
7 * Adapted from baycom.c driver written by Thomas Sailer (sailer@ife.ee.ethz.ch)
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 * Please note that the GPL allows you to use the driver, NOT the radio.
24 * In order to use the radio, you need a license from the communications
25 * authority of your country.
26 *
27 *
28 */
29
30/*****************************************************************************/
31
32#define SIOCYAMRESERVED (0)
33#define SIOCYAMSCFG (1) /* Set configuration */
34#define SIOCYAMGCFG (2) /* Get configuration */
35#define SIOCYAMSMCS (3) /* Set mcs data */
36
37#define YAM_IOBASE (1 << 0)
38#define YAM_IRQ (1 << 1)
39#define YAM_BITRATE (1 << 2) /* Bit rate of radio port ->57600 */
40#define YAM_MODE (1 << 3) /* 0=simplex 1=duplex 2=duplex+tempo */
41#define YAM_HOLDDLY (1 << 4) /* duplex tempo (sec) */
42#define YAM_TXDELAY (1 << 5) /* Tx Delay (ms) */
43#define YAM_TXTAIL (1 << 6) /* Tx Tail (ms) */
44#define YAM_PERSIST (1 << 7) /* Persist (ms) */
45#define YAM_SLOTTIME (1 << 8) /* Slottime (ms) */
46#define YAM_BAUDRATE (1 << 9) /* Baud rate of rs232 port ->115200 */
47
48#define YAM_MAXBITRATE 57600
49#define YAM_MAXBAUDRATE 115200
50#define YAM_MAXMODE 2
51#define YAM_MAXHOLDDLY 99
52#define YAM_MAXTXDELAY 999
53#define YAM_MAXTXTAIL 999
54#define YAM_MAXPERSIST 255
55#define YAM_MAXSLOTTIME 999
56
57#define YAM_FPGA_SIZE 5302
58
59struct yamcfg {
60 unsigned int mask; /* Mask of commands */
61 unsigned int iobase; /* IO Base of COM port */
62 unsigned int irq; /* IRQ of COM port */
63 unsigned int bitrate; /* Bit rate of radio port */
64 unsigned int baudrate; /* Baud rate of the RS232 port */
65 unsigned int txdelay; /* TxDelay */
66 unsigned int txtail; /* TxTail */
67 unsigned int persist; /* Persistence */
68 unsigned int slottime; /* Slottime */
69 unsigned int mode; /* mode 0 (simp), 1(Dupl), 2(Dupl+delay) */
70 unsigned int holddly; /* PTT delay in FullDuplex 2 mode */
71};
72
73struct yamdrv_ioctl_cfg {
74 int cmd;
75 struct yamcfg cfg;
76};
77
78struct yamdrv_ioctl_mcs {
79 int cmd;
80 int bitrate;
81 unsigned char bits[YAM_FPGA_SIZE];
82};
diff --git a/include/linux/zconf.h b/include/linux/zconf.h
new file mode 100644
index 000000000000..f1cfd66b9554
--- /dev/null
+++ b/include/linux/zconf.h
@@ -0,0 +1,45 @@
1/* zconf.h -- configuration of the zlib compression library
2 * Copyright (C) 1995-1998 Jean-loup Gailly.
3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */
5
6/* @(#) $Id$ */
7
8#ifndef _ZCONF_H
9#define _ZCONF_H
10
11/* The memory requirements for deflate are (in bytes):
12 (1 << (windowBits+2)) + (1 << (memLevel+9))
13 that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
14 plus a few kilobytes for small objects. For example, if you want to reduce
15 the default memory requirements from 256K to 128K, compile with
16 make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
17 Of course this will generally degrade compression (there's no free lunch).
18
19 The memory requirements for inflate are (in bytes) 1 << windowBits
20 that is, 32K for windowBits=15 (default value) plus a few kilobytes
21 for small objects.
22*/
23
24/* Maximum value for memLevel in deflateInit2 */
25#ifndef MAX_MEM_LEVEL
26# define MAX_MEM_LEVEL 8
27#endif
28
29/* Maximum value for windowBits in deflateInit2 and inflateInit2.
30 * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
31 * created by gzip. (Files created by minigzip can still be extracted by
32 * gzip.)
33 */
34#ifndef MAX_WBITS
35# define MAX_WBITS 15 /* 32K LZ77 window */
36#endif
37
38 /* Type declarations */
39
40typedef unsigned char Byte; /* 8 bits */
41typedef unsigned int uInt; /* 16 bits or more */
42typedef unsigned long uLong; /* 32 bits or more */
43typedef void *voidp;
44
45#endif /* _ZCONF_H */
diff --git a/include/linux/zftape.h b/include/linux/zftape.h
new file mode 100644
index 000000000000..b057c65366c6
--- /dev/null
+++ b/include/linux/zftape.h
@@ -0,0 +1,87 @@
1#ifndef _ZFTAPE_H
2#define _ZFTAPE_H
3
4/*
5 * Copyright (C) 1996, 1997 Claus-Justus Heine.
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 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; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 *
22 * $Source: /homes/cvs/ftape-stacked/include/linux/zftape.h,v $
23 * $Revision: 1.12 $
24 * $Date: 1997/10/21 11:02:37 $
25 *
26 * Special ioctl and other global info for the zftape VFS
27 * interface for the QIC-40/80/3010/3020 floppy-tape driver for
28 * Linux.
29 */
30
31#define ZFTAPE_VERSION "zftape for " FTAPE_VERSION
32
33#include <linux/ftape.h>
34
35#define ZFTAPE_LABEL "Ftape - The Linux Floppy Tape Project!"
36
37/* Bits of the minor device number that control the operation mode */
38#define ZFT_Q80_MODE (1 << 3)
39#define ZFT_ZIP_MODE (1 << 4)
40#define ZFT_RAW_MODE (1 << 5)
41#define ZFT_MINOR_OP_MASK (ZFT_Q80_MODE | \
42 ZFT_ZIP_MODE | \
43 ZFT_RAW_MODE)
44#define ZFT_MINOR_MASK (FTAPE_SEL_MASK | \
45 ZFT_MINOR_OP_MASK | \
46 FTAPE_NO_REWIND)
47
48#ifdef ZFT_OBSOLETE
49struct mtblksz {
50 unsigned int mt_blksz;
51};
52#define MTIOC_ZFTAPE_GETBLKSZ _IOR('m', 104, struct mtblksz)
53#endif
54
55#ifdef __KERNEL__
56
57extern int zft_init(void);
58
59static inline __s64 zft_div_blksz(__s64 value, __u32 blk_sz)
60{
61 if (blk_sz == 1) {
62 return value;
63 } else {
64 return (__s64)(((__u32)(value >> 10) + (blk_sz >> 10) - 1)
65 / (blk_sz >> 10));
66 }
67}
68
69static inline __s64 zft_mul_blksz(__s64 value, __u32 blk_sz)
70{
71 if (blk_sz == 1) {
72 return value;
73 } else {
74 /* if blk_sz != 1, then it is a multiple of 1024. In
75 * this case, `value' will also fit into 32 bits.
76 *
77 * Actually, this limits the capacity to 42
78 * bits. This is (2^32)*1024, roughly a thousand
79 * times 2GB, or 3 Terabytes. Hopefully this is enough
80 */
81 return(__s64)(((__u32)(value)*(blk_sz>>10))<<10);
82 }
83}
84
85#endif
86
87#endif
diff --git a/include/linux/zlib.h b/include/linux/zlib.h
new file mode 100644
index 000000000000..850076ea14d3
--- /dev/null
+++ b/include/linux/zlib.h
@@ -0,0 +1,637 @@
1/* zlib.h -- interface of the 'zlib' general purpose compression library
2 version 1.1.3, July 9th, 1998
3
4 Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler
5
6 This software is provided 'as-is', without any express or implied
7 warranty. In no event will the authors be held liable for any damages
8 arising from the use of this software.
9
10 Permission is granted to anyone to use this software for any purpose,
11 including commercial applications, and to alter it and redistribute it
12 freely, subject to the following restrictions:
13
14 1. The origin of this software must not be misrepresented; you must not
15 claim that you wrote the original software. If you use this software
16 in a product, an acknowledgment in the product documentation would be
17 appreciated but is not required.
18 2. Altered source versions must be plainly marked as such, and must not be
19 misrepresented as being the original software.
20 3. This notice may not be removed or altered from any source distribution.
21
22 Jean-loup Gailly Mark Adler
23 jloup@gzip.org madler@alumni.caltech.edu
24
25
26 The data format used by the zlib library is described by RFCs (Request for
27 Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt
28 (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
29*/
30
31#ifndef _ZLIB_H
32#define _ZLIB_H
33
34#include <linux/zconf.h>
35
36#define ZLIB_VERSION "1.1.3"
37
38/*
39 The 'zlib' compression library provides in-memory compression and
40 decompression functions, including integrity checks of the uncompressed
41 data. This version of the library supports only one compression method
42 (deflation) but other algorithms will be added later and will have the same
43 stream interface.
44
45 Compression can be done in a single step if the buffers are large
46 enough (for example if an input file is mmap'ed), or can be done by
47 repeated calls of the compression function. In the latter case, the
48 application must provide more input and/or consume the output
49 (providing more output space) before each call.
50
51 The library also supports reading and writing files in gzip (.gz) format
52 with an interface similar to that of stdio.
53
54 The library does not install any signal handler. The decoder checks
55 the consistency of the compressed data, so the library should never
56 crash even in case of corrupted input.
57*/
58
59struct internal_state;
60
61typedef struct z_stream_s {
62 Byte *next_in; /* next input byte */
63 uInt avail_in; /* number of bytes available at next_in */
64 uLong total_in; /* total nb of input bytes read so far */
65
66 Byte *next_out; /* next output byte should be put there */
67 uInt avail_out; /* remaining free space at next_out */
68 uLong total_out; /* total nb of bytes output so far */
69
70 char *msg; /* last error message, NULL if no error */
71 struct internal_state *state; /* not visible by applications */
72
73 void *workspace; /* memory allocated for this stream */
74
75 int data_type; /* best guess about the data type: ascii or binary */
76 uLong adler; /* adler32 value of the uncompressed data */
77 uLong reserved; /* reserved for future use */
78} z_stream;
79
80typedef z_stream *z_streamp;
81
82/*
83 The application must update next_in and avail_in when avail_in has
84 dropped to zero. It must update next_out and avail_out when avail_out
85 has dropped to zero. The application must initialize zalloc, zfree and
86 opaque before calling the init function. All other fields are set by the
87 compression library and must not be updated by the application.
88
89 The opaque value provided by the application will be passed as the first
90 parameter for calls of zalloc and zfree. This can be useful for custom
91 memory management. The compression library attaches no meaning to the
92 opaque value.
93
94 zalloc must return NULL if there is not enough memory for the object.
95 If zlib is used in a multi-threaded application, zalloc and zfree must be
96 thread safe.
97
98 On 16-bit systems, the functions zalloc and zfree must be able to allocate
99 exactly 65536 bytes, but will not be required to allocate more than this
100 if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
101 pointers returned by zalloc for objects of exactly 65536 bytes *must*
102 have their offset normalized to zero. The default allocation function
103 provided by this library ensures this (see zutil.c). To reduce memory
104 requirements and avoid any allocation of 64K objects, at the expense of
105 compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
106
107 The fields total_in and total_out can be used for statistics or
108 progress reports. After compression, total_in holds the total size of
109 the uncompressed data and may be saved for use in the decompressor
110 (particularly if the decompressor wants to decompress everything in
111 a single step).
112*/
113
114 /* constants */
115
116#define Z_NO_FLUSH 0
117#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */
118#define Z_PACKET_FLUSH 2
119#define Z_SYNC_FLUSH 3
120#define Z_FULL_FLUSH 4
121#define Z_FINISH 5
122/* Allowed flush values; see deflate() below for details */
123
124#define Z_OK 0
125#define Z_STREAM_END 1
126#define Z_NEED_DICT 2
127#define Z_ERRNO (-1)
128#define Z_STREAM_ERROR (-2)
129#define Z_DATA_ERROR (-3)
130#define Z_MEM_ERROR (-4)
131#define Z_BUF_ERROR (-5)
132#define Z_VERSION_ERROR (-6)
133/* Return codes for the compression/decompression functions. Negative
134 * values are errors, positive values are used for special but normal events.
135 */
136
137#define Z_NO_COMPRESSION 0
138#define Z_BEST_SPEED 1
139#define Z_BEST_COMPRESSION 9
140#define Z_DEFAULT_COMPRESSION (-1)
141/* compression levels */
142
143#define Z_FILTERED 1
144#define Z_HUFFMAN_ONLY 2
145#define Z_DEFAULT_STRATEGY 0
146/* compression strategy; see deflateInit2() below for details */
147
148#define Z_BINARY 0
149#define Z_ASCII 1
150#define Z_UNKNOWN 2
151/* Possible values of the data_type field */
152
153#define Z_DEFLATED 8
154/* The deflate compression method (the only one supported in this version) */
155
156 /* basic functions */
157
158extern const char * zlib_zlibVersion (void);
159/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
160 If the first character differs, the library code actually used is
161 not compatible with the zlib.h header file used by the application.
162 This check is automatically made by deflateInit and inflateInit.
163 */
164
165extern int zlib_deflate_workspacesize (void);
166/*
167 Returns the number of bytes that needs to be allocated for a per-
168 stream workspace. A pointer to this number of bytes should be
169 returned in stream->workspace before calling zlib_deflateInit().
170*/
171
172/*
173extern int deflateInit (z_streamp strm, int level);
174
175 Initializes the internal stream state for compression. The fields
176 zalloc, zfree and opaque must be initialized before by the caller.
177 If zalloc and zfree are set to NULL, deflateInit updates them to
178 use default allocation functions.
179
180 The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
181 1 gives best speed, 9 gives best compression, 0 gives no compression at
182 all (the input data is simply copied a block at a time).
183 Z_DEFAULT_COMPRESSION requests a default compromise between speed and
184 compression (currently equivalent to level 6).
185
186 deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
187 enough memory, Z_STREAM_ERROR if level is not a valid compression level,
188 Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
189 with the version assumed by the caller (ZLIB_VERSION).
190 msg is set to null if there is no error message. deflateInit does not
191 perform any compression: this will be done by deflate().
192*/
193
194
195extern int zlib_deflate (z_streamp strm, int flush);
196/*
197 deflate compresses as much data as possible, and stops when the input
198 buffer becomes empty or the output buffer becomes full. It may introduce some
199 output latency (reading input without producing any output) except when
200 forced to flush.
201
202 The detailed semantics are as follows. deflate performs one or both of the
203 following actions:
204
205 - Compress more input starting at next_in and update next_in and avail_in
206 accordingly. If not all input can be processed (because there is not
207 enough room in the output buffer), next_in and avail_in are updated and
208 processing will resume at this point for the next call of deflate().
209
210 - Provide more output starting at next_out and update next_out and avail_out
211 accordingly. This action is forced if the parameter flush is non zero.
212 Forcing flush frequently degrades the compression ratio, so this parameter
213 should be set only when necessary (in interactive applications).
214 Some output may be provided even if flush is not set.
215
216 Before the call of deflate(), the application should ensure that at least
217 one of the actions is possible, by providing more input and/or consuming
218 more output, and updating avail_in or avail_out accordingly; avail_out
219 should never be zero before the call. The application can consume the
220 compressed output when it wants, for example when the output buffer is full
221 (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK
222 and with zero avail_out, it must be called again after making room in the
223 output buffer because there might be more output pending.
224
225 If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
226 flushed to the output buffer and the output is aligned on a byte boundary, so
227 that the decompressor can get all input data available so far. (In particular
228 avail_in is zero after the call if enough output space has been provided
229 before the call.) Flushing may degrade compression for some compression
230 algorithms and so it should be used only when necessary.
231
232 If flush is set to Z_FULL_FLUSH, all output is flushed as with
233 Z_SYNC_FLUSH, and the compression state is reset so that decompression can
234 restart from this point if previous compressed data has been damaged or if
235 random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
236 the compression.
237
238 If deflate returns with avail_out == 0, this function must be called again
239 with the same value of the flush parameter and more output space (updated
240 avail_out), until the flush is complete (deflate returns with non-zero
241 avail_out).
242
243 If the parameter flush is set to Z_FINISH, pending input is processed,
244 pending output is flushed and deflate returns with Z_STREAM_END if there
245 was enough output space; if deflate returns with Z_OK, this function must be
246 called again with Z_FINISH and more output space (updated avail_out) but no
247 more input data, until it returns with Z_STREAM_END or an error. After
248 deflate has returned Z_STREAM_END, the only possible operations on the
249 stream are deflateReset or deflateEnd.
250
251 Z_FINISH can be used immediately after deflateInit if all the compression
252 is to be done in a single step. In this case, avail_out must be at least
253 0.1% larger than avail_in plus 12 bytes. If deflate does not return
254 Z_STREAM_END, then it must be called again as described above.
255
256 deflate() sets strm->adler to the adler32 checksum of all input read
257 so far (that is, total_in bytes).
258
259 deflate() may update data_type if it can make a good guess about
260 the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered
261 binary. This field is only for information purposes and does not affect
262 the compression algorithm in any manner.
263
264 deflate() returns Z_OK if some progress has been made (more input
265 processed or more output produced), Z_STREAM_END if all input has been
266 consumed and all output has been produced (only when flush is set to
267 Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
268 if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible
269 (for example avail_in or avail_out was zero).
270*/
271
272
273extern int zlib_deflateEnd (z_streamp strm);
274/*
275 All dynamically allocated data structures for this stream are freed.
276 This function discards any unprocessed input and does not flush any
277 pending output.
278
279 deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
280 stream state was inconsistent, Z_DATA_ERROR if the stream was freed
281 prematurely (some input or output was discarded). In the error case,
282 msg may be set but then points to a static string (which must not be
283 deallocated).
284*/
285
286
287extern int zlib_inflate_workspacesize (void);
288/*
289 Returns the number of bytes that needs to be allocated for a per-
290 stream workspace. A pointer to this number of bytes should be
291 returned in stream->workspace before calling zlib_inflateInit().
292*/
293
294/*
295extern int zlib_inflateInit (z_streamp strm);
296
297 Initializes the internal stream state for decompression. The fields
298 next_in, avail_in, and workspace must be initialized before by
299 the caller. If next_in is not NULL and avail_in is large enough (the exact
300 value depends on the compression method), inflateInit determines the
301 compression method from the zlib header and allocates all data structures
302 accordingly; otherwise the allocation will be deferred to the first call of
303 inflate. If zalloc and zfree are set to NULL, inflateInit updates them to
304 use default allocation functions.
305
306 inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
307 memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
308 version assumed by the caller. msg is set to null if there is no error
309 message. inflateInit does not perform any decompression apart from reading
310 the zlib header if present: this will be done by inflate(). (So next_in and
311 avail_in may be modified, but next_out and avail_out are unchanged.)
312*/
313
314
315extern int zlib_inflate (z_streamp strm, int flush);
316/*
317 inflate decompresses as much data as possible, and stops when the input
318 buffer becomes empty or the output buffer becomes full. It may some
319 introduce some output latency (reading input without producing any output)
320 except when forced to flush.
321
322 The detailed semantics are as follows. inflate performs one or both of the
323 following actions:
324
325 - Decompress more input starting at next_in and update next_in and avail_in
326 accordingly. If not all input can be processed (because there is not
327 enough room in the output buffer), next_in is updated and processing
328 will resume at this point for the next call of inflate().
329
330 - Provide more output starting at next_out and update next_out and avail_out
331 accordingly. inflate() provides as much output as possible, until there
332 is no more input data or no more space in the output buffer (see below
333 about the flush parameter).
334
335 Before the call of inflate(), the application should ensure that at least
336 one of the actions is possible, by providing more input and/or consuming
337 more output, and updating the next_* and avail_* values accordingly.
338 The application can consume the uncompressed output when it wants, for
339 example when the output buffer is full (avail_out == 0), or after each
340 call of inflate(). If inflate returns Z_OK and with zero avail_out, it
341 must be called again after making room in the output buffer because there
342 might be more output pending.
343
344 If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much
345 output as possible to the output buffer. The flushing behavior of inflate is
346 not specified for values of the flush parameter other than Z_SYNC_FLUSH
347 and Z_FINISH, but the current implementation actually flushes as much output
348 as possible anyway.
349
350 inflate() should normally be called until it returns Z_STREAM_END or an
351 error. However if all decompression is to be performed in a single step
352 (a single call of inflate), the parameter flush should be set to
353 Z_FINISH. In this case all pending input is processed and all pending
354 output is flushed; avail_out must be large enough to hold all the
355 uncompressed data. (The size of the uncompressed data may have been saved
356 by the compressor for this purpose.) The next operation on this stream must
357 be inflateEnd to deallocate the decompression state. The use of Z_FINISH
358 is never required, but can be used to inform inflate that a faster routine
359 may be used for the single inflate() call.
360
361 If a preset dictionary is needed at this point (see inflateSetDictionary
362 below), inflate sets strm-adler to the adler32 checksum of the
363 dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise
364 it sets strm->adler to the adler32 checksum of all output produced
365 so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or
366 an error code as described below. At the end of the stream, inflate()
367 checks that its computed adler32 checksum is equal to that saved by the
368 compressor and returns Z_STREAM_END only if the checksum is correct.
369
370 inflate() returns Z_OK if some progress has been made (more input processed
371 or more output produced), Z_STREAM_END if the end of the compressed data has
372 been reached and all uncompressed output has been produced, Z_NEED_DICT if a
373 preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
374 corrupted (input stream not conforming to the zlib format or incorrect
375 adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent
376 (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not
377 enough memory, Z_BUF_ERROR if no progress is possible or if there was not
378 enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR
379 case, the application may then call inflateSync to look for a good
380 compression block.
381*/
382
383
384extern int zlib_inflateEnd (z_streamp strm);
385/*
386 All dynamically allocated data structures for this stream are freed.
387 This function discards any unprocessed input and does not flush any
388 pending output.
389
390 inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
391 was inconsistent. In the error case, msg may be set but then points to a
392 static string (which must not be deallocated).
393*/
394
395 /* Advanced functions */
396
397/*
398 The following functions are needed only in some special applications.
399*/
400
401/*
402extern int deflateInit2 (z_streamp strm,
403 int level,
404 int method,
405 int windowBits,
406 int memLevel,
407 int strategy);
408
409 This is another version of deflateInit with more compression options. The
410 fields next_in, zalloc, zfree and opaque must be initialized before by
411 the caller.
412
413 The method parameter is the compression method. It must be Z_DEFLATED in
414 this version of the library.
415
416 The windowBits parameter is the base two logarithm of the window size
417 (the size of the history buffer). It should be in the range 8..15 for this
418 version of the library. Larger values of this parameter result in better
419 compression at the expense of memory usage. The default value is 15 if
420 deflateInit is used instead.
421
422 The memLevel parameter specifies how much memory should be allocated
423 for the internal compression state. memLevel=1 uses minimum memory but
424 is slow and reduces compression ratio; memLevel=9 uses maximum memory
425 for optimal speed. The default value is 8. See zconf.h for total memory
426 usage as a function of windowBits and memLevel.
427
428 The strategy parameter is used to tune the compression algorithm. Use the
429 value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
430 filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no
431 string match). Filtered data consists mostly of small values with a
432 somewhat random distribution. In this case, the compression algorithm is
433 tuned to compress them better. The effect of Z_FILTERED is to force more
434 Huffman coding and less string matching; it is somewhat intermediate
435 between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects
436 the compression ratio but not the correctness of the compressed output even
437 if it is not set appropriately.
438
439 deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
440 memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid
441 method). msg is set to null if there is no error message. deflateInit2 does
442 not perform any compression: this will be done by deflate().
443*/
444
445extern int zlib_deflateSetDictionary (z_streamp strm,
446 const Byte *dictionary,
447 uInt dictLength);
448/*
449 Initializes the compression dictionary from the given byte sequence
450 without producing any compressed output. This function must be called
451 immediately after deflateInit, deflateInit2 or deflateReset, before any
452 call of deflate. The compressor and decompressor must use exactly the same
453 dictionary (see inflateSetDictionary).
454
455 The dictionary should consist of strings (byte sequences) that are likely
456 to be encountered later in the data to be compressed, with the most commonly
457 used strings preferably put towards the end of the dictionary. Using a
458 dictionary is most useful when the data to be compressed is short and can be
459 predicted with good accuracy; the data can then be compressed better than
460 with the default empty dictionary.
461
462 Depending on the size of the compression data structures selected by
463 deflateInit or deflateInit2, a part of the dictionary may in effect be
464 discarded, for example if the dictionary is larger than the window size in
465 deflate or deflate2. Thus the strings most likely to be useful should be
466 put at the end of the dictionary, not at the front.
467
468 Upon return of this function, strm->adler is set to the Adler32 value
469 of the dictionary; the decompressor may later use this value to determine
470 which dictionary has been used by the compressor. (The Adler32 value
471 applies to the whole dictionary even if only a subset of the dictionary is
472 actually used by the compressor.)
473
474 deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
475 parameter is invalid (such as NULL dictionary) or the stream state is
476 inconsistent (for example if deflate has already been called for this stream
477 or if the compression method is bsort). deflateSetDictionary does not
478 perform any compression: this will be done by deflate().
479*/
480
481extern int zlib_deflateCopy (z_streamp dest, z_streamp source);
482/*
483 Sets the destination stream as a complete copy of the source stream.
484
485 This function can be useful when several compression strategies will be
486 tried, for example when there are several ways of pre-processing the input
487 data with a filter. The streams that will be discarded should then be freed
488 by calling deflateEnd. Note that deflateCopy duplicates the internal
489 compression state which can be quite large, so this strategy is slow and
490 can consume lots of memory.
491
492 deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
493 enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
494 (such as zalloc being NULL). msg is left unchanged in both source and
495 destination.
496*/
497
498extern int zlib_deflateReset (z_streamp strm);
499/*
500 This function is equivalent to deflateEnd followed by deflateInit,
501 but does not free and reallocate all the internal compression state.
502 The stream will keep the same compression level and any other attributes
503 that may have been set by deflateInit2.
504
505 deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
506 stream state was inconsistent (such as zalloc or state being NULL).
507*/
508
509extern int zlib_deflateParams (z_streamp strm, int level, int strategy);
510/*
511 Dynamically update the compression level and compression strategy. The
512 interpretation of level and strategy is as in deflateInit2. This can be
513 used to switch between compression and straight copy of the input data, or
514 to switch to a different kind of input data requiring a different
515 strategy. If the compression level is changed, the input available so far
516 is compressed with the old level (and may be flushed); the new level will
517 take effect only at the next call of deflate().
518
519 Before the call of deflateParams, the stream state must be set as for
520 a call of deflate(), since the currently available input may have to
521 be compressed and flushed. In particular, strm->avail_out must be non-zero.
522
523 deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
524 stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR
525 if strm->avail_out was zero.
526*/
527
528/*
529extern int inflateInit2 (z_streamp strm, int windowBits);
530
531 This is another version of inflateInit with an extra parameter. The
532 fields next_in, avail_in, zalloc, zfree and opaque must be initialized
533 before by the caller.
534
535 The windowBits parameter is the base two logarithm of the maximum window
536 size (the size of the history buffer). It should be in the range 8..15 for
537 this version of the library. The default value is 15 if inflateInit is used
538 instead. If a compressed stream with a larger window size is given as
539 input, inflate() will return with the error code Z_DATA_ERROR instead of
540 trying to allocate a larger window.
541
542 inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
543 memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative
544 memLevel). msg is set to null if there is no error message. inflateInit2
545 does not perform any decompression apart from reading the zlib header if
546 present: this will be done by inflate(). (So next_in and avail_in may be
547 modified, but next_out and avail_out are unchanged.)
548*/
549
550extern int zlib_inflateSetDictionary (z_streamp strm,
551 const Byte *dictionary,
552 uInt dictLength);
553/*
554 Initializes the decompression dictionary from the given uncompressed byte
555 sequence. This function must be called immediately after a call of inflate
556 if this call returned Z_NEED_DICT. The dictionary chosen by the compressor
557 can be determined from the Adler32 value returned by this call of
558 inflate. The compressor and decompressor must use exactly the same
559 dictionary (see deflateSetDictionary).
560
561 inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
562 parameter is invalid (such as NULL dictionary) or the stream state is
563 inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
564 expected one (incorrect Adler32 value). inflateSetDictionary does not
565 perform any decompression: this will be done by subsequent calls of
566 inflate().
567*/
568
569extern int zlib_inflateSync (z_streamp strm);
570/*
571 Skips invalid compressed data until a full flush point (see above the
572 description of deflate with Z_FULL_FLUSH) can be found, or until all
573 available input is skipped. No output is provided.
574
575 inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
576 if no more input was provided, Z_DATA_ERROR if no flush point has been found,
577 or Z_STREAM_ERROR if the stream structure was inconsistent. In the success
578 case, the application may save the current current value of total_in which
579 indicates where valid compressed data was found. In the error case, the
580 application may repeatedly call inflateSync, providing more input each time,
581 until success or end of the input data.
582*/
583
584extern int zlib_inflateReset (z_streamp strm);
585/*
586 This function is equivalent to inflateEnd followed by inflateInit,
587 but does not free and reallocate all the internal decompression state.
588 The stream will keep attributes that may have been set by inflateInit2.
589
590 inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
591 stream state was inconsistent (such as zalloc or state being NULL).
592*/
593
594extern int zlib_inflateIncomp (z_stream *strm);
595/*
596 This function adds the data at next_in (avail_in bytes) to the output
597 history without performing any output. There must be no pending output,
598 and the decompressor must be expecting to see the start of a block.
599 Calling this function is equivalent to decompressing a stored block
600 containing the data at next_in (except that the data is not output).
601*/
602
603 /* various hacks, don't look :) */
604
605/* deflateInit and inflateInit are macros to allow checking the zlib version
606 * and the compiler's view of z_stream:
607 */
608extern int zlib_deflateInit_ (z_streamp strm, int level,
609 const char *version, int stream_size);
610extern int zlib_inflateInit_ (z_streamp strm,
611 const char *version, int stream_size);
612extern int zlib_deflateInit2_ (z_streamp strm, int level, int method,
613 int windowBits, int memLevel,
614 int strategy, const char *version,
615 int stream_size);
616extern int zlib_inflateInit2_ (z_streamp strm, int windowBits,
617 const char *version, int stream_size);
618#define zlib_deflateInit(strm, level) \
619 zlib_deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
620#define zlib_inflateInit(strm) \
621 zlib_inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream))
622#define zlib_deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
623 zlib_deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
624 (strategy), ZLIB_VERSION, sizeof(z_stream))
625#define zlib_inflateInit2(strm, windowBits) \
626 zlib_inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
627
628
629#if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL)
630 struct internal_state {int dummy;}; /* hack for buggy compilers */
631#endif
632
633extern const char * zlib_zError (int err);
634extern int zlib_inflateSyncPoint (z_streamp z);
635extern const uLong * zlib_get_crc_table (void);
636
637#endif /* _ZLIB_H */
diff --git a/include/linux/zorro.h b/include/linux/zorro.h
new file mode 100644
index 000000000000..ba5b72768bbe
--- /dev/null
+++ b/include/linux/zorro.h
@@ -0,0 +1,329 @@
1/*
2 * linux/zorro.h -- Amiga AutoConfig (Zorro) Bus Definitions
3 *
4 * Copyright (C) 1995--2003 Geert Uytterhoeven
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#ifndef _LINUX_ZORRO_H
12#define _LINUX_ZORRO_H
13
14#ifndef __ASSEMBLY__
15
16#include <linux/device.h>
17
18
19 /*
20 * Each Zorro board has a 32-bit ID of the form
21 *
22 * mmmmmmmmmmmmmmmmppppppppeeeeeeee
23 *
24 * with
25 *
26 * mmmmmmmmmmmmmmmm 16-bit Manufacturer ID (assigned by CBM (sigh))
27 * pppppppp 8-bit Product ID (assigned by manufacturer)
28 * eeeeeeee 8-bit Extended Product ID (currently only used
29 * for some GVP boards)
30 */
31
32
33#define ZORRO_MANUF(id) ((id) >> 16)
34#define ZORRO_PROD(id) (((id) >> 8) & 0xff)
35#define ZORRO_EPC(id) ((id) & 0xff)
36
37#define ZORRO_ID(manuf, prod, epc) \
38 ((ZORRO_MANUF_##manuf << 16) | ((prod) << 8) | (epc))
39
40typedef __u32 zorro_id;
41
42
43#define ZORRO_WILDCARD (0xffffffff) /* not official */
44
45/* Include the ID list */
46#include <linux/zorro_ids.h>
47
48
49 /*
50 * GVP identifies most of its products through the 'extended product code'
51 * (epc). The epc has to be ANDed with the GVP_PRODMASK before the
52 * identification.
53 */
54
55#define GVP_PRODMASK (0xf8)
56#define GVP_SCSICLKMASK (0x01)
57
58enum GVP_flags {
59 GVP_IO = 0x01,
60 GVP_ACCEL = 0x02,
61 GVP_SCSI = 0x04,
62 GVP_24BITDMA = 0x08,
63 GVP_25BITDMA = 0x10,
64 GVP_NOBANK = 0x20,
65 GVP_14MHZ = 0x40,
66};
67
68
69struct Node {
70 struct Node *ln_Succ; /* Pointer to next (successor) */
71 struct Node *ln_Pred; /* Pointer to previous (predecessor) */
72 __u8 ln_Type;
73 __s8 ln_Pri; /* Priority, for sorting */
74 __s8 *ln_Name; /* ID string, null terminated */
75} __attribute__ ((packed));
76
77struct ExpansionRom {
78 /* -First 16 bytes of the expansion ROM */
79 __u8 er_Type; /* Board type, size and flags */
80 __u8 er_Product; /* Product number, assigned by manufacturer */
81 __u8 er_Flags; /* Flags */
82 __u8 er_Reserved03; /* Must be zero ($ff inverted) */
83 __u16 er_Manufacturer; /* Unique ID, ASSIGNED BY COMMODORE-AMIGA! */
84 __u32 er_SerialNumber; /* Available for use by manufacturer */
85 __u16 er_InitDiagVec; /* Offset to optional "DiagArea" structure */
86 __u8 er_Reserved0c;
87 __u8 er_Reserved0d;
88 __u8 er_Reserved0e;
89 __u8 er_Reserved0f;
90} __attribute__ ((packed));
91
92/* er_Type board type bits */
93#define ERT_TYPEMASK 0xc0
94#define ERT_ZORROII 0xc0
95#define ERT_ZORROIII 0x80
96
97/* other bits defined in er_Type */
98#define ERTB_MEMLIST 5 /* Link RAM into free memory list */
99#define ERTF_MEMLIST (1<<5)
100
101struct ConfigDev {
102 struct Node cd_Node;
103 __u8 cd_Flags; /* (read/write) */
104 __u8 cd_Pad; /* reserved */
105 struct ExpansionRom cd_Rom; /* copy of board's expansion ROM */
106 void *cd_BoardAddr; /* where in memory the board was placed */
107 __u32 cd_BoardSize; /* size of board in bytes */
108 __u16 cd_SlotAddr; /* which slot number (PRIVATE) */
109 __u16 cd_SlotSize; /* number of slots (PRIVATE) */
110 void *cd_Driver; /* pointer to node of driver */
111 struct ConfigDev *cd_NextCD; /* linked list of drivers to config */
112 __u32 cd_Unused[4]; /* for whatever the driver wants */
113} __attribute__ ((packed));
114
115#else /* __ASSEMBLY__ */
116
117LN_Succ = 0
118LN_Pred = LN_Succ+4
119LN_Type = LN_Pred+4
120LN_Pri = LN_Type+1
121LN_Name = LN_Pri+1
122LN_sizeof = LN_Name+4
123
124ER_Type = 0
125ER_Product = ER_Type+1
126ER_Flags = ER_Product+1
127ER_Reserved03 = ER_Flags+1
128ER_Manufacturer = ER_Reserved03+1
129ER_SerialNumber = ER_Manufacturer+2
130ER_InitDiagVec = ER_SerialNumber+4
131ER_Reserved0c = ER_InitDiagVec+2
132ER_Reserved0d = ER_Reserved0c+1
133ER_Reserved0e = ER_Reserved0d+1
134ER_Reserved0f = ER_Reserved0e+1
135ER_sizeof = ER_Reserved0f+1
136
137CD_Node = 0
138CD_Flags = CD_Node+LN_sizeof
139CD_Pad = CD_Flags+1
140CD_Rom = CD_Pad+1
141CD_BoardAddr = CD_Rom+ER_sizeof
142CD_BoardSize = CD_BoardAddr+4
143CD_SlotAddr = CD_BoardSize+4
144CD_SlotSize = CD_SlotAddr+2
145CD_Driver = CD_SlotSize+2
146CD_NextCD = CD_Driver+4
147CD_Unused = CD_NextCD+4
148CD_sizeof = CD_Unused+(4*4)
149
150#endif /* __ASSEMBLY__ */
151
152#ifndef __ASSEMBLY__
153
154#define ZORRO_NUM_AUTO 16
155
156#ifdef __KERNEL__
157
158#include <linux/init.h>
159#include <linux/ioport.h>
160
161#include <asm/zorro.h>
162
163
164 /*
165 * Zorro devices
166 */
167
168struct zorro_dev {
169 struct ExpansionRom rom;
170 zorro_id id;
171 struct zorro_driver *driver; /* which driver has allocated this device */
172 struct device dev; /* Generic device interface */
173 u16 slotaddr;
174 u16 slotsize;
175 char name[64];
176 struct resource resource;
177};
178
179#define to_zorro_dev(n) container_of(n, struct zorro_dev, dev)
180
181
182 /*
183 * Zorro bus
184 */
185
186struct zorro_bus {
187 struct list_head devices; /* list of devices on this bus */
188 unsigned int num_resources; /* number of resources */
189 struct resource resources[4]; /* address space routed to this bus */
190 struct device dev;
191 char name[10];
192};
193
194extern struct zorro_bus zorro_bus; /* single Zorro bus */
195extern struct bus_type zorro_bus_type;
196
197
198 /*
199 * Zorro device IDs
200 */
201
202struct zorro_device_id {
203 zorro_id id; /* Device ID or ZORRO_WILDCARD */
204 unsigned long driver_data; /* Data private to the driver */
205};
206
207
208 /*
209 * Zorro device drivers
210 */
211
212struct zorro_driver {
213 struct list_head node;
214 char *name;
215 const struct zorro_device_id *id_table; /* NULL if wants all devices */
216 int (*probe)(struct zorro_dev *z, const struct zorro_device_id *id); /* New device inserted */
217 void (*remove)(struct zorro_dev *z); /* Device removed (NULL if not a hot-plug capable driver) */
218 struct device_driver driver;
219};
220
221#define to_zorro_driver(drv) container_of(drv, struct zorro_driver, driver)
222
223
224#define zorro_for_each_dev(dev) \
225 for (dev = &zorro_autocon[0]; dev < zorro_autocon+zorro_num_autocon; dev++)
226
227
228/* New-style probing */
229extern int zorro_register_driver(struct zorro_driver *);
230extern void zorro_unregister_driver(struct zorro_driver *);
231extern const struct zorro_device_id *zorro_match_device(const struct zorro_device_id *ids, const struct zorro_dev *z);
232static inline struct zorro_driver *zorro_dev_driver(const struct zorro_dev *z)
233{
234 return z->driver;
235}
236
237
238extern unsigned int zorro_num_autocon; /* # of autoconfig devices found */
239extern struct zorro_dev zorro_autocon[ZORRO_NUM_AUTO];
240
241
242 /*
243 * Zorro Functions
244 */
245
246extern struct zorro_dev *zorro_find_device(zorro_id id,
247 struct zorro_dev *from);
248
249#define zorro_resource_start(z) ((z)->resource.start)
250#define zorro_resource_end(z) ((z)->resource.end)
251#define zorro_resource_len(z) ((z)->resource.end-(z)->resource.start+1)
252#define zorro_resource_flags(z) ((z)->resource.flags)
253
254#define zorro_request_device(z, name) \
255 request_mem_region(zorro_resource_start(z), zorro_resource_len(z), name)
256#define zorro_release_device(z) \
257 release_mem_region(zorro_resource_start(z), zorro_resource_len(z))
258
259/* Similar to the helpers above, these manipulate per-zorro_dev
260 * driver-specific data. They are really just a wrapper around
261 * the generic device structure functions of these calls.
262 */
263static inline void *zorro_get_drvdata (struct zorro_dev *z)
264{
265 return dev_get_drvdata(&z->dev);
266}
267
268static inline void zorro_set_drvdata (struct zorro_dev *z, void *data)
269{
270 dev_set_drvdata(&z->dev, data);
271}
272
273
274/*
275 * A helper function which helps ensure correct zorro_driver
276 * setup and cleanup for commonly-encountered hotplug/modular cases
277 *
278 * This MUST stay in a header, as it checks for -DMODULE
279 */
280static inline int zorro_module_init(struct zorro_driver *drv)
281{
282 int rc = zorro_register_driver(drv);
283
284 if (rc > 0)
285 return 0;
286
287 /* iff CONFIG_HOTPLUG and built into kernel, we should
288 * leave the driver around for future hotplug events.
289 * For the module case, a hotplug daemon of some sort
290 * should load a module in response to an insert event. */
291#if defined(CONFIG_HOTPLUG) && !defined(MODULE)
292 if (rc == 0)
293 return 0;
294#else
295 if (rc == 0)
296 rc = -ENODEV;
297#endif
298
299 /* if we get here, we need to clean up Zorro driver instance
300 * and return some sort of error */
301 zorro_unregister_driver(drv);
302
303 return rc;
304}
305
306
307 /*
308 * Bitmask indicating portions of available Zorro II RAM that are unused
309 * by the system. Every bit represents a 64K chunk, for a maximum of 8MB
310 * (128 chunks, physical 0x00200000-0x009fffff).
311 *
312 * If you want to use (= allocate) portions of this RAM, you should clear
313 * the corresponding bits.
314 */
315
316extern DECLARE_BITMAP(zorro_unused_z2ram, 128);
317
318#define Z2RAM_START (0x00200000)
319#define Z2RAM_END (0x00a00000)
320#define Z2RAM_SIZE (0x00800000)
321#define Z2RAM_CHUNKSIZE (0x00010000)
322#define Z2RAM_CHUNKMASK (0x0000ffff)
323#define Z2RAM_CHUNKSHIFT (16)
324
325
326#endif /* !__ASSEMBLY__ */
327#endif /* __KERNEL__ */
328
329#endif /* _LINUX_ZORRO_H */
diff --git a/include/linux/zorro_ids.h b/include/linux/zorro_ids.h
new file mode 100644
index 000000000000..7e749088910d
--- /dev/null
+++ b/include/linux/zorro_ids.h
@@ -0,0 +1,552 @@
1/*
2 * Zorro board IDs
3 *
4 * Please keep sorted.
5 */
6
7
8#define ZORRO_MANUF_PACIFIC_PERIPHERALS 0x00D3
9#define ZORRO_PROD_PACIFIC_PERIPHERALS_SE_2000_A500 ZORRO_ID(PACIFIC_PERIPHERALS, 0x00, 0)
10#define ZORRO_PROD_PACIFIC_PERIPHERALS_SCSI ZORRO_ID(PACIFIC_PERIPHERALS, 0x0A, 0)
11
12#define ZORRO_MANUF_MACROSYSTEMS_USA_2 0x0100
13#define ZORRO_PROD_MACROSYSTEMS_WARP_ENGINE ZORRO_ID(MACROSYSTEMS_USA_2, 0x13, 0)
14
15#define ZORRO_MANUF_KUPKE_1 0x00DD
16#define ZORRO_PROD_KUPKE_GOLEM_RAM_BOX_2MB ZORRO_ID(KUPKE_1, 0x00, 0)
17
18#define ZORRO_MANUF_MEMPHIS 0x0100
19#define ZORRO_PROD_MEMPHIS_STORMBRINGER ZORRO_ID(MEMPHIS, 0x00, 0)
20
21#define ZORRO_MANUF_3_STATE 0x0200
22#define ZORRO_PROD_3_STATE_MEGAMIX_2000 ZORRO_ID(3_STATE, 0x02, 0)
23
24#define ZORRO_MANUF_COMMODORE_BRAUNSCHWEIG 0x0201
25#define ZORRO_PROD_CBM_A2088_A2286 ZORRO_ID(COMMODORE_BRAUNSCHWEIG, 0x01, 0)
26#define ZORRO_PROD_CBM_A2286 ZORRO_ID(COMMODORE_BRAUNSCHWEIG, 0x02, 0)
27#define ZORRO_PROD_CBM_A4091_1 ZORRO_ID(COMMODORE_BRAUNSCHWEIG, 0x54, 0)
28#define ZORRO_PROD_CBM_A2386SX_1 ZORRO_ID(COMMODORE_BRAUNSCHWEIG, 0x67, 0)
29
30#define ZORRO_MANUF_COMMODORE_WEST_CHESTER_1 0x0202
31#define ZORRO_PROD_CBM_A2090A ZORRO_ID(COMMODORE_WEST_CHESTER_1, 0x01, 0)
32#define ZORRO_PROD_CBM_A590_A2091_1 ZORRO_ID(COMMODORE_WEST_CHESTER_1, 0x02, 0)
33#define ZORRO_PROD_CBM_A590_A2091_2 ZORRO_ID(COMMODORE_WEST_CHESTER_1, 0x03, 0)
34#define ZORRO_PROD_CBM_A2090B ZORRO_ID(COMMODORE_WEST_CHESTER_1, 0x04, 0)
35#define ZORRO_PROD_CBM_A2060 ZORRO_ID(COMMODORE_WEST_CHESTER_1, 0x09, 0)
36#define ZORRO_PROD_CBM_A590_A2052_A2058_A2091 ZORRO_ID(COMMODORE_WEST_CHESTER_1, 0x0A, 0)
37#define ZORRO_PROD_CBM_A560_RAM ZORRO_ID(COMMODORE_WEST_CHESTER_1, 0x20, 0)
38#define ZORRO_PROD_CBM_A2232_PROTOTYPE ZORRO_ID(COMMODORE_WEST_CHESTER_1, 0x45, 0)
39#define ZORRO_PROD_CBM_A2232 ZORRO_ID(COMMODORE_WEST_CHESTER_1, 0x46, 0)
40#define ZORRO_PROD_CBM_A2620 ZORRO_ID(COMMODORE_WEST_CHESTER_1, 0x50, 0)
41#define ZORRO_PROD_CBM_A2630 ZORRO_ID(COMMODORE_WEST_CHESTER_1, 0x51, 0)
42#define ZORRO_PROD_CBM_A4091_2 ZORRO_ID(COMMODORE_WEST_CHESTER_1, 0x54, 0)
43#define ZORRO_PROD_CBM_A2065_1 ZORRO_ID(COMMODORE_WEST_CHESTER_1, 0x5A, 0)
44#define ZORRO_PROD_CBM_ROMULATOR ZORRO_ID(COMMODORE_WEST_CHESTER_1, 0x60, 0)
45#define ZORRO_PROD_CBM_A3000_TEST_FIXTURE ZORRO_ID(COMMODORE_WEST_CHESTER_1, 0x61, 0)
46#define ZORRO_PROD_CBM_A2386SX_2 ZORRO_ID(COMMODORE_WEST_CHESTER_1, 0x67, 0)
47#define ZORRO_PROD_CBM_A2065_2 ZORRO_ID(COMMODORE_WEST_CHESTER_1, 0x70, 0)
48
49#define ZORRO_MANUF_COMMODORE_WEST_CHESTER_2 0x0203
50#define ZORRO_PROD_CBM_A2090A_CM ZORRO_ID(COMMODORE_WEST_CHESTER_2, 0x03, 0)
51
52#define ZORRO_MANUF_PROGRESSIVE_PERIPHERALS_AND_SYSTEMS_2 0x02F4
53#define ZORRO_PROD_PPS_EXP8000 ZORRO_ID(PROGRESSIVE_PERIPHERALS_AND_SYSTEMS_2, 0x02, 0)
54
55#define ZORRO_MANUF_KOLFF_COMPUTER_SUPPLIES 0x02FF
56#define ZORRO_PROD_KCS_POWER_PC_BOARD ZORRO_ID(KOLFF_COMPUTER_SUPPLIES, 0x00, 0)
57
58#define ZORRO_MANUF_CARDCO_1 0x03EC
59#define ZORRO_PROD_CARDCO_KRONOS_2000_1 ZORRO_ID(CARDCO_1, 0x04, 0)
60#define ZORRO_PROD_CARDCO_A1000_1 ZORRO_ID(CARDCO_1, 0x0C, 0)
61#define ZORRO_PROD_CARDCO_ESCORT ZORRO_ID(CARDCO_1, 0x0E, 0)
62#define ZORRO_PROD_CARDCO_A2410 ZORRO_ID(CARDCO_1, 0xF5, 0)
63
64#define ZORRO_MANUF_A_SQUARED 0x03ED
65#define ZORRO_PROD_A_SQUARED_LIVE_2000 ZORRO_ID(A_SQUARED, 0x01, 0)
66
67#define ZORRO_MANUF_COMSPEC_COMMUNICATIONS 0x03EE
68#define ZORRO_PROD_COMSPEC_COMMUNICATIONS_AX2000 ZORRO_ID(COMSPEC_COMMUNICATIONS, 0x01, 0)
69
70#define ZORRO_MANUF_ANAKIN_RESEARCH 0x03F1
71#define ZORRO_PROD_ANAKIN_RESEARCH_EASYL ZORRO_ID(ANAKIN_RESEARCH, 0x01, 0)
72
73#define ZORRO_MANUF_MICROBOTICS 0x03F2
74#define ZORRO_PROD_MICROBOTICS_STARBOARD_II ZORRO_ID(MICROBOTICS, 0x00, 0)
75#define ZORRO_PROD_MICROBOTICS_STARDRIVE ZORRO_ID(MICROBOTICS, 0x02, 0)
76#define ZORRO_PROD_MICROBOTICS_8_UP_A ZORRO_ID(MICROBOTICS, 0x03, 0)
77#define ZORRO_PROD_MICROBOTICS_8_UP_Z ZORRO_ID(MICROBOTICS, 0x04, 0)
78#define ZORRO_PROD_MICROBOTICS_DELTA_RAM ZORRO_ID(MICROBOTICS, 0x20, 0)
79#define ZORRO_PROD_MICROBOTICS_8_STAR_RAM ZORRO_ID(MICROBOTICS, 0x40, 0)
80#define ZORRO_PROD_MICROBOTICS_8_STAR ZORRO_ID(MICROBOTICS, 0x41, 0)
81#define ZORRO_PROD_MICROBOTICS_VXL_RAM_32 ZORRO_ID(MICROBOTICS, 0x44, 0)
82#define ZORRO_PROD_MICROBOTICS_VXL_68030 ZORRO_ID(MICROBOTICS, 0x45, 0)
83#define ZORRO_PROD_MICROBOTICS_DELTA ZORRO_ID(MICROBOTICS, 0x60, 0)
84#define ZORRO_PROD_MICROBOTICS_MBX_1200_1200Z_RAM ZORRO_ID(MICROBOTICS, 0x81, 0)
85#define ZORRO_PROD_MICROBOTICS_HARDFRAME_2000_1 ZORRO_ID(MICROBOTICS, 0x96, 0)
86#define ZORRO_PROD_MICROBOTICS_HARDFRAME_2000_2 ZORRO_ID(MICROBOTICS, 0x9E, 0)
87#define ZORRO_PROD_MICROBOTICS_MBX_1200_1200Z ZORRO_ID(MICROBOTICS, 0xC1, 0)
88
89#define ZORRO_MANUF_ACCESS_ASSOCIATES_ALEGRA 0x03F4
90
91#define ZORRO_MANUF_EXPANSION_TECHNOLOGIES 0x03F6
92
93#define ZORRO_MANUF_ASDG 0x03FF
94#define ZORRO_PROD_ASDG_MEMORY_1 ZORRO_ID(ASDG, 0x01, 0)
95#define ZORRO_PROD_ASDG_MEMORY_2 ZORRO_ID(ASDG, 0x02, 0)
96#define ZORRO_PROD_ASDG_EB920_LAN_ROVER ZORRO_ID(ASDG, 0xFE, 0)
97#define ZORRO_PROD_ASDG_GPIB_DUALIEEE488_TWIN_X ZORRO_ID(ASDG, 0xFF, 0)
98
99#define ZORRO_MANUF_IMTRONICS_1 0x0404
100#define ZORRO_PROD_IMTRONICS_HURRICANE_2800_1 ZORRO_ID(IMTRONICS_1, 0x39, 0)
101#define ZORRO_PROD_IMTRONICS_HURRICANE_2800_2 ZORRO_ID(IMTRONICS_1, 0x57, 0)
102
103#define ZORRO_MANUF_CBM_UNIVERSITY_OF_LOWELL 0x0406
104#define ZORRO_PROD_CBM_A2410 ZORRO_ID(CBM_UNIVERSITY_OF_LOWELL, 0x00, 0)
105
106#define ZORRO_MANUF_AMERISTAR 0x041D
107#define ZORRO_PROD_AMERISTAR_A2065 ZORRO_ID(AMERISTAR, 0x01, 0)
108#define ZORRO_PROD_AMERISTAR_A560 ZORRO_ID(AMERISTAR, 0x09, 0)
109#define ZORRO_PROD_AMERISTAR_A4066 ZORRO_ID(AMERISTAR, 0x0A, 0)
110
111#define ZORRO_MANUF_SUPRA 0x0420
112#define ZORRO_PROD_SUPRA_SUPRADRIVE_4x4 ZORRO_ID(SUPRA, 0x01, 0)
113#define ZORRO_PROD_SUPRA_1000_RAM ZORRO_ID(SUPRA, 0x02, 0)
114#define ZORRO_PROD_SUPRA_2000_DMA ZORRO_ID(SUPRA, 0x03, 0)
115#define ZORRO_PROD_SUPRA_500 ZORRO_ID(SUPRA, 0x05, 0)
116#define ZORRO_PROD_SUPRA_500_SCSI ZORRO_ID(SUPRA, 0x08, 0)
117#define ZORRO_PROD_SUPRA_500XP_2000_RAM ZORRO_ID(SUPRA, 0x09, 0)
118#define ZORRO_PROD_SUPRA_500RX_2000_RAM ZORRO_ID(SUPRA, 0x0A, 0)
119#define ZORRO_PROD_SUPRA_2400ZI ZORRO_ID(SUPRA, 0x0B, 0)
120#define ZORRO_PROD_SUPRA_500XP_SUPRADRIVE_WORDSYNC ZORRO_ID(SUPRA, 0x0C, 0)
121#define ZORRO_PROD_SUPRA_SUPRADRIVE_WORDSYNC_II ZORRO_ID(SUPRA, 0x0D, 0)
122#define ZORRO_PROD_SUPRA_2400ZIPLUS ZORRO_ID(SUPRA, 0x10, 0)
123
124#define ZORRO_MANUF_COMPUTER_SYSTEMS_ASSOCIATES 0x0422
125#define ZORRO_PROD_CSA_MAGNUM ZORRO_ID(COMPUTER_SYSTEMS_ASSOCIATES, 0x11, 0)
126#define ZORRO_PROD_CSA_12_GAUGE ZORRO_ID(COMPUTER_SYSTEMS_ASSOCIATES, 0x15, 0)
127
128#define ZORRO_MANUF_MARC_MICHAEL_GROTH 0x0439
129
130#define ZORRO_MANUF_M_TECH 0x0502
131#define ZORRO_PROD_MTEC_AT500_1 ZORRO_ID(M_TECH, 0x03, 0)
132
133#define ZORRO_MANUF_GREAT_VALLEY_PRODUCTS_1 0x06E1
134#define ZORRO_PROD_GVP_IMPACT_SERIES_I ZORRO_ID(GREAT_VALLEY_PRODUCTS_1, 0x08, 0)
135
136#define ZORRO_MANUF_BYTEBOX 0x07DA
137#define ZORRO_PROD_BYTEBOX_A500 ZORRO_ID(BYTEBOX, 0x00, 0)
138
139#define ZORRO_MANUF_DKB_POWER_COMPUTING 0x07DC
140#define ZORRO_PROD_DKB_POWER_COMPUTING_SECUREKEY ZORRO_ID(DKB_POWER_COMPUTING, 0x09, 0)
141#define ZORRO_PROD_DKB_POWER_COMPUTING_DKM_3128 ZORRO_ID(DKB_POWER_COMPUTING, 0x0E, 0)
142#define ZORRO_PROD_DKB_POWER_COMPUTING_RAPID_FIRE ZORRO_ID(DKB_POWER_COMPUTING, 0x0F, 0)
143#define ZORRO_PROD_DKB_POWER_COMPUTING_DKM_1202 ZORRO_ID(DKB_POWER_COMPUTING, 0x10, 0)
144#define ZORRO_PROD_DKB_POWER_COMPUTING_COBRA_VIPER_II_68EC030 ZORRO_ID(DKB_POWER_COMPUTING, 0x12, 0)
145#define ZORRO_PROD_DKB_POWER_COMPUTING_WILDFIRE_060_1 ZORRO_ID(DKB_POWER_COMPUTING, 0x17, 0)
146#define ZORRO_PROD_DKB_POWER_COMPUTING_WILDFIRE_060_2 ZORRO_ID(DKB_POWER_COMPUTING, 0xFF, 0)
147
148#define ZORRO_MANUF_GREAT_VALLEY_PRODUCTS_2 0x07E1
149#define ZORRO_PROD_GVP_IMPACT_SERIES_I_4K ZORRO_ID(GREAT_VALLEY_PRODUCTS_2, 0x01, 0)
150#define ZORRO_PROD_GVP_IMPACT_SERIES_I_16K_2 ZORRO_ID(GREAT_VALLEY_PRODUCTS_2, 0x02, 0)
151#define ZORRO_PROD_GVP_IMPACT_SERIES_I_16K_3 ZORRO_ID(GREAT_VALLEY_PRODUCTS_2, 0x03, 0)
152#define ZORRO_PROD_GVP_IMPACT_3001_IDE_1 ZORRO_ID(GREAT_VALLEY_PRODUCTS_2, 0x08, 0)
153#define ZORRO_PROD_GVP_IMPACT_3001_RAM ZORRO_ID(GREAT_VALLEY_PRODUCTS_2, 0x09, 0)
154#define ZORRO_PROD_GVP_IMPACT_SERIES_II_RAM_1 ZORRO_ID(GREAT_VALLEY_PRODUCTS_2, 0x0A, 0)
155#define ZORRO_PROD_GVP_EPC_BASE ZORRO_ID(GREAT_VALLEY_PRODUCTS_2, 0x0B, 0)
156#define ZORRO_PROD_GVP_GFORCE_040_1 ZORRO_ID(GREAT_VALLEY_PRODUCTS_2, 0x0B, 0x20)
157#define ZORRO_PROD_GVP_GFORCE_040_SCSI_1 ZORRO_ID(GREAT_VALLEY_PRODUCTS_2, 0x0B, 0x30)
158#define ZORRO_PROD_GVP_A1291 ZORRO_ID(GREAT_VALLEY_PRODUCTS_2, 0x0B, 0x40)
159#define ZORRO_PROD_GVP_COMBO_030_R4 ZORRO_ID(GREAT_VALLEY_PRODUCTS_2, 0x0B, 0x60)
160#define ZORRO_PROD_GVP_COMBO_030_R4_SCSI ZORRO_ID(GREAT_VALLEY_PRODUCTS_2, 0x0B, 0x70)
161#define ZORRO_PROD_GVP_PHONEPAK ZORRO_ID(GREAT_VALLEY_PRODUCTS_2, 0x0B, 0x78)
162#define ZORRO_PROD_GVP_IO_EXTENDER ZORRO_ID(GREAT_VALLEY_PRODUCTS_2, 0x0B, 0x98)
163#define ZORRO_PROD_GVP_GFORCE_030 ZORRO_ID(GREAT_VALLEY_PRODUCTS_2, 0x0B, 0xa0)
164#define ZORRO_PROD_GVP_GFORCE_030_SCSI ZORRO_ID(GREAT_VALLEY_PRODUCTS_2, 0x0B, 0xb0)
165#define ZORRO_PROD_GVP_A530 ZORRO_ID(GREAT_VALLEY_PRODUCTS_2, 0x0B, 0xc0)
166#define ZORRO_PROD_GVP_A530_SCSI ZORRO_ID(GREAT_VALLEY_PRODUCTS_2, 0x0B, 0xd0)
167#define ZORRO_PROD_GVP_COMBO_030_R3 ZORRO_ID(GREAT_VALLEY_PRODUCTS_2, 0x0B, 0xe0)
168#define ZORRO_PROD_GVP_COMBO_030_R3_SCSI ZORRO_ID(GREAT_VALLEY_PRODUCTS_2, 0x0B, 0xf0)
169#define ZORRO_PROD_GVP_SERIES_II ZORRO_ID(GREAT_VALLEY_PRODUCTS_2, 0x0B, 0xf8)
170#define ZORRO_PROD_GVP_IMPACT_3001_IDE_2 ZORRO_ID(GREAT_VALLEY_PRODUCTS_2, 0x0D, 0)
171/*#define ZORRO_PROD_GVP_A2000_030 ZORRO_ID(GREAT_VALLEY_PRODUCTS_2, 0x0D, 0)*/
172/*#define ZORRO_PROD_GVP_GFORCE_040_SCSI_2 ZORRO_ID(GREAT_VALLEY_PRODUCTS_2, 0x0D, 0)*/
173#define ZORRO_PROD_GVP_GFORCE_040_060 ZORRO_ID(GREAT_VALLEY_PRODUCTS_2, 0x16, 0)
174#define ZORRO_PROD_GVP_IMPACT_VISION_24 ZORRO_ID(GREAT_VALLEY_PRODUCTS_2, 0x20, 0)
175#define ZORRO_PROD_GVP_GFORCE_040_2 ZORRO_ID(GREAT_VALLEY_PRODUCTS_2, 0xFF, 0)
176
177#define ZORRO_MANUF_CALIFORNIA_ACCESS_SYNERGY 0x07E5
178#define ZORRO_PROD_CALIFORNIA_ACCESS_SYNERGY_MALIBU ZORRO_ID(CALIFORNIA_ACCESS_SYNERGY, 0x01, 0)
179
180#define ZORRO_MANUF_XETEC 0x07E6
181#define ZORRO_PROD_XETEC_FASTCARD ZORRO_ID(XETEC, 0x01, 0)
182#define ZORRO_PROD_XETEC_FASTCARD_RAM ZORRO_ID(XETEC, 0x02, 0)
183#define ZORRO_PROD_XETEC_FASTCARD_PLUS ZORRO_ID(XETEC, 0x03, 0)
184
185#define ZORRO_MANUF_PROGRESSIVE_PERIPHERALS_AND_SYSTEMS 0x07EA
186#define ZORRO_PROD_PPS_MERCURY ZORRO_ID(PROGRESSIVE_PERIPHERALS_AND_SYSTEMS, 0x00, 0)
187#define ZORRO_PROD_PPS_A3000_68040 ZORRO_ID(PROGRESSIVE_PERIPHERALS_AND_SYSTEMS, 0x01, 0)
188#define ZORRO_PROD_PPS_A2000_68040 ZORRO_ID(PROGRESSIVE_PERIPHERALS_AND_SYSTEMS, 0x69, 0)
189#define ZORRO_PROD_PPS_ZEUS ZORRO_ID(PROGRESSIVE_PERIPHERALS_AND_SYSTEMS, 0x96, 0)
190#define ZORRO_PROD_PPS_A500_68040 ZORRO_ID(PROGRESSIVE_PERIPHERALS_AND_SYSTEMS, 0xBB, 0)
191
192#define ZORRO_MANUF_XEBEC 0x07EC
193
194#define ZORRO_MANUF_SPIRIT_TECHNOLOGY 0x07F2
195#define ZORRO_PROD_SPIRIT_TECHNOLOGY_INSIDER_IN1000 ZORRO_ID(SPIRIT_TECHNOLOGY, 0x01, 0)
196#define ZORRO_PROD_SPIRIT_TECHNOLOGY_INSIDER_IN500 ZORRO_ID(SPIRIT_TECHNOLOGY, 0x02, 0)
197#define ZORRO_PROD_SPIRIT_TECHNOLOGY_SIN500 ZORRO_ID(SPIRIT_TECHNOLOGY, 0x03, 0)
198#define ZORRO_PROD_SPIRIT_TECHNOLOGY_HDA_506 ZORRO_ID(SPIRIT_TECHNOLOGY, 0x04, 0)
199#define ZORRO_PROD_SPIRIT_TECHNOLOGY_AX_S ZORRO_ID(SPIRIT_TECHNOLOGY, 0x05, 0)
200#define ZORRO_PROD_SPIRIT_TECHNOLOGY_OCTABYTE ZORRO_ID(SPIRIT_TECHNOLOGY, 0x06, 0)
201#define ZORRO_PROD_SPIRIT_TECHNOLOGY_INMATE ZORRO_ID(SPIRIT_TECHNOLOGY, 0x08, 0)
202
203#define ZORRO_MANUF_SPIRIT_TECHNOLOGY_2 0x07F3
204
205#define ZORRO_MANUF_BSC_ALFADATA_1 0x07FE
206#define ZORRO_PROD_BSC_ALF_3_1 ZORRO_ID(BSC_ALFADATA_1, 0x03, 0)
207
208#define ZORRO_MANUF_BSC_ALFADATA_2 0x0801
209#define ZORRO_PROD_BSC_ALF_2_1 ZORRO_ID(BSC_ALFADATA_2, 0x01, 0)
210#define ZORRO_PROD_BSC_ALF_2_2 ZORRO_ID(BSC_ALFADATA_2, 0x02, 0)
211#define ZORRO_PROD_BSC_ALF_3_2 ZORRO_ID(BSC_ALFADATA_2, 0x03, 0)
212
213#define ZORRO_MANUF_CARDCO_2 0x0802
214#define ZORRO_PROD_CARDCO_KRONOS_2000_2 ZORRO_ID(CARDCO_2, 0x04, 0)
215#define ZORRO_PROD_CARDCO_A1000_2 ZORRO_ID(CARDCO_2, 0x0C, 0)
216
217#define ZORRO_MANUF_JOCHHEIM 0x0804
218#define ZORRO_PROD_JOCHHEIM_RAM ZORRO_ID(JOCHHEIM, 0x01, 0)
219
220#define ZORRO_MANUF_CHECKPOINT_TECHNOLOGIES 0x0807
221#define ZORRO_PROD_CHECKPOINT_TECHNOLOGIES_SERIAL_SOLUTION ZORRO_ID(CHECKPOINT_TECHNOLOGIES, 0x00, 0)
222
223#define ZORRO_MANUF_EDOTRONIK 0x0810
224#define ZORRO_PROD_EDOTRONIK_IEEE_488 ZORRO_ID(EDOTRONIK, 0x01, 0)
225#define ZORRO_PROD_EDOTRONIK_8032 ZORRO_ID(EDOTRONIK, 0x02, 0)
226#define ZORRO_PROD_EDOTRONIK_MULTISERIAL ZORRO_ID(EDOTRONIK, 0x03, 0)
227#define ZORRO_PROD_EDOTRONIK_VIDEODIGITIZER ZORRO_ID(EDOTRONIK, 0x04, 0)
228#define ZORRO_PROD_EDOTRONIK_PARALLEL_IO ZORRO_ID(EDOTRONIK, 0x05, 0)
229#define ZORRO_PROD_EDOTRONIK_PIC_PROTOYPING ZORRO_ID(EDOTRONIK, 0x06, 0)
230#define ZORRO_PROD_EDOTRONIK_ADC ZORRO_ID(EDOTRONIK, 0x07, 0)
231#define ZORRO_PROD_EDOTRONIK_VME ZORRO_ID(EDOTRONIK, 0x08, 0)
232#define ZORRO_PROD_EDOTRONIK_DSP96000 ZORRO_ID(EDOTRONIK, 0x09, 0)
233
234#define ZORRO_MANUF_NES_INC 0x0813
235#define ZORRO_PROD_NES_INC_RAM ZORRO_ID(NES_INC, 0x00, 0)
236
237#define ZORRO_MANUF_ICD 0x0817
238#define ZORRO_PROD_ICD_ADVANTAGE_2000_SCSI ZORRO_ID(ICD, 0x01, 0)
239#define ZORRO_PROD_ICD_ADVANTAGE_IDE ZORRO_ID(ICD, 0x03, 0)
240#define ZORRO_PROD_ICD_ADVANTAGE_2080_RAM ZORRO_ID(ICD, 0x04, 0)
241
242#define ZORRO_MANUF_KUPKE_2 0x0819
243#define ZORRO_PROD_KUPKE_OMTI ZORRO_ID(KUPKE_2, 0x01, 0)
244#define ZORRO_PROD_KUPKE_SCSI_II ZORRO_ID(KUPKE_2, 0x02, 0)
245#define ZORRO_PROD_KUPKE_GOLEM_BOX ZORRO_ID(KUPKE_2, 0x03, 0)
246#define ZORRO_PROD_KUPKE_030_882 ZORRO_ID(KUPKE_2, 0x04, 0)
247#define ZORRO_PROD_KUPKE_SCSI_AT ZORRO_ID(KUPKE_2, 0x05, 0)
248
249#define ZORRO_MANUF_GREAT_VALLEY_PRODUCTS_3 0x081D
250#define ZORRO_PROD_GVP_A2000_RAM8 ZORRO_ID(GREAT_VALLEY_PRODUCTS_3, 0x09, 0)
251#define ZORRO_PROD_GVP_IMPACT_SERIES_II_RAM_2 ZORRO_ID(GREAT_VALLEY_PRODUCTS_3, 0x0A, 0)
252
253#define ZORRO_MANUF_INTERWORKS_NETWORK 0x081E
254
255#define ZORRO_MANUF_HARDITAL_SYNTHESIS 0x0820
256#define ZORRO_PROD_HARDITAL_SYNTHESIS_TQM_68030_68882 ZORRO_ID(HARDITAL_SYNTHESIS, 0x14, 0)
257
258#define ZORRO_MANUF_APPLIED_ENGINEERING 0x0828
259#define ZORRO_PROD_APPLIED_ENGINEERING_DL2000 ZORRO_ID(APPLIED_ENGINEERING, 0x10, 0)
260#define ZORRO_PROD_APPLIED_ENGINEERING_RAM_WORKS ZORRO_ID(APPLIED_ENGINEERING, 0xE0, 0)
261
262#define ZORRO_MANUF_BSC_ALFADATA_3 0x082C
263#define ZORRO_PROD_BSC_OKTAGON_2008 ZORRO_ID(BSC_ALFADATA_3, 0x05, 0)
264#define ZORRO_PROD_BSC_TANDEM_AT_2008_508 ZORRO_ID(BSC_ALFADATA_3, 0x06, 0)
265#define ZORRO_PROD_BSC_ALFA_RAM_1200 ZORRO_ID(BSC_ALFADATA_3, 0x07, 0)
266#define ZORRO_PROD_BSC_OKTAGON_2008_RAM ZORRO_ID(BSC_ALFADATA_3, 0x08, 0)
267#define ZORRO_PROD_BSC_MULTIFACE_I ZORRO_ID(BSC_ALFADATA_3, 0x10, 0)
268#define ZORRO_PROD_BSC_MULTIFACE_II ZORRO_ID(BSC_ALFADATA_3, 0x11, 0)
269#define ZORRO_PROD_BSC_MULTIFACE_III ZORRO_ID(BSC_ALFADATA_3, 0x12, 0)
270#define ZORRO_PROD_BSC_FRAMEMASTER_II ZORRO_ID(BSC_ALFADATA_3, 0x20, 0)
271#define ZORRO_PROD_BSC_GRAFFITI_RAM ZORRO_ID(BSC_ALFADATA_3, 0x21, 0)
272#define ZORRO_PROD_BSC_GRAFFITI_REG ZORRO_ID(BSC_ALFADATA_3, 0x22, 0)
273#define ZORRO_PROD_BSC_ISDN_MASTERCARD ZORRO_ID(BSC_ALFADATA_3, 0x40, 0)
274#define ZORRO_PROD_BSC_ISDN_MASTERCARD_II ZORRO_ID(BSC_ALFADATA_3, 0x41, 0)
275
276#define ZORRO_MANUF_PHOENIX 0x0835
277#define ZORRO_PROD_PHOENIX_ST506 ZORRO_ID(PHOENIX, 0x21, 0)
278#define ZORRO_PROD_PHOENIX_SCSI ZORRO_ID(PHOENIX, 0x22, 0)
279#define ZORRO_PROD_PHOENIX_RAM ZORRO_ID(PHOENIX, 0xBE, 0)
280
281#define ZORRO_MANUF_ADVANCED_STORAGE_SYSTEMS 0x0836
282#define ZORRO_PROD_ADVANCED_STORAGE_SYSTEMS_NEXUS ZORRO_ID(ADVANCED_STORAGE_SYSTEMS, 0x01, 0)
283#define ZORRO_PROD_ADVANCED_STORAGE_SYSTEMS_NEXUS_RAM ZORRO_ID(ADVANCED_STORAGE_SYSTEMS, 0x08, 0)
284
285#define ZORRO_MANUF_IMPULSE 0x0838
286#define ZORRO_PROD_IMPULSE_FIRECRACKER_24 ZORRO_ID(IMPULSE, 0x00, 0)
287
288#define ZORRO_MANUF_IVS 0x0840
289#define ZORRO_PROD_IVS_GRANDSLAM_PIC_2 ZORRO_ID(IVS, 0x02, 0)
290#define ZORRO_PROD_IVS_GRANDSLAM_PIC_1 ZORRO_ID(IVS, 0x04, 0)
291#define ZORRO_PROD_IVS_OVERDRIVE ZORRO_ID(IVS, 0x10, 0)
292#define ZORRO_PROD_IVS_TRUMPCARD_CLASSIC ZORRO_ID(IVS, 0x30, 0)
293#define ZORRO_PROD_IVS_TRUMPCARD_PRO_GRANDSLAM ZORRO_ID(IVS, 0x34, 0)
294#define ZORRO_PROD_IVS_META_4 ZORRO_ID(IVS, 0x40, 0)
295#define ZORRO_PROD_IVS_WAVETOOLS ZORRO_ID(IVS, 0xBF, 0)
296#define ZORRO_PROD_IVS_VECTOR_1 ZORRO_ID(IVS, 0xF3, 0)
297#define ZORRO_PROD_IVS_VECTOR_2 ZORRO_ID(IVS, 0xF4, 0)
298
299#define ZORRO_MANUF_VECTOR_1 0x0841
300#define ZORRO_PROD_VECTOR_CONNECTION_1 ZORRO_ID(VECTOR_1, 0xE3, 0)
301
302#define ZORRO_MANUF_XPERT_PRODEV 0x0845
303#define ZORRO_PROD_XPERT_PRODEV_VISIONA_RAM ZORRO_ID(XPERT_PRODEV, 0x01, 0)
304#define ZORRO_PROD_XPERT_PRODEV_VISIONA_REG ZORRO_ID(XPERT_PRODEV, 0x02, 0)
305#define ZORRO_PROD_XPERT_PRODEV_MERLIN_RAM ZORRO_ID(XPERT_PRODEV, 0x03, 0)
306#define ZORRO_PROD_XPERT_PRODEV_MERLIN_REG_1 ZORRO_ID(XPERT_PRODEV, 0x04, 0)
307#define ZORRO_PROD_XPERT_PRODEV_MERLIN_REG_2 ZORRO_ID(XPERT_PRODEV, 0xC9, 0)
308
309#define ZORRO_MANUF_HYDRA_SYSTEMS 0x0849
310#define ZORRO_PROD_HYDRA_SYSTEMS_AMIGANET ZORRO_ID(HYDRA_SYSTEMS, 0x01, 0)
311
312#define ZORRO_MANUF_SUNRIZE_INDUSTRIES 0x084F
313#define ZORRO_PROD_SUNRIZE_INDUSTRIES_AD1012 ZORRO_ID(SUNRIZE_INDUSTRIES, 0x01, 0)
314#define ZORRO_PROD_SUNRIZE_INDUSTRIES_AD516 ZORRO_ID(SUNRIZE_INDUSTRIES, 0x02, 0)
315#define ZORRO_PROD_SUNRIZE_INDUSTRIES_DD512 ZORRO_ID(SUNRIZE_INDUSTRIES, 0x03, 0)
316
317#define ZORRO_MANUF_TRICERATOPS 0x0850
318#define ZORRO_PROD_TRICERATOPS_MULTI_IO ZORRO_ID(TRICERATOPS, 0x01, 0)
319
320#define ZORRO_MANUF_APPLIED_MAGIC 0x0851
321#define ZORRO_PROD_APPLIED_MAGIC_DMI_RESOLVER ZORRO_ID(APPLIED_MAGIC, 0x01, 0)
322#define ZORRO_PROD_APPLIED_MAGIC_DIGITAL_BROADCASTER ZORRO_ID(APPLIED_MAGIC, 0x06, 0)
323
324#define ZORRO_MANUF_GFX_BASE 0x085E
325#define ZORRO_PROD_GFX_BASE_GDA_1_VRAM ZORRO_ID(GFX_BASE, 0x00, 0)
326#define ZORRO_PROD_GFX_BASE_GDA_1 ZORRO_ID(GFX_BASE, 0x01, 0)
327
328#define ZORRO_MANUF_ROCTEC 0x0860
329#define ZORRO_PROD_ROCTEC_RH_800C ZORRO_ID(ROCTEC, 0x01, 0)
330#define ZORRO_PROD_ROCTEC_RH_800C_RAM ZORRO_ID(ROCTEC, 0x01, 0)
331
332#define ZORRO_MANUF_KATO 0x0861
333#define ZORRO_PROD_KATO_MELODY ZORRO_ID(KATO, 0x80, 0)
334/* ID clash!! */
335#define ZORRO_MANUF_HELFRICH_1 0x0861
336#define ZORRO_PROD_HELFRICH_RAINBOW_II ZORRO_ID(HELFRICH_1, 0x20, 0)
337#define ZORRO_PROD_HELFRICH_RAINBOW_III ZORRO_ID(HELFRICH_1, 0x21, 0)
338
339#define ZORRO_MANUF_ATLANTIS 0x0862
340
341#define ZORRO_MANUF_PROTAR 0x0864
342
343#define ZORRO_MANUF_ACS 0x0865
344
345#define ZORRO_MANUF_SOFTWARE_RESULTS_ENTERPRISES 0x0866
346#define ZORRO_PROD_SOFTWARE_RESULTS_ENTERPRISES_GOLDEN_GATE_2_BUS_PLUS ZORRO_ID(SOFTWARE_RESULTS_ENTERPRISES, 0x01, 0)
347
348#define ZORRO_MANUF_MASOBOSHI 0x086D
349#define ZORRO_PROD_MASOBOSHI_MASTER_CARD_SC201 ZORRO_ID(MASOBOSHI, 0x03, 0)
350#define ZORRO_PROD_MASOBOSHI_MASTER_CARD_MC702 ZORRO_ID(MASOBOSHI, 0x04, 0)
351#define ZORRO_PROD_MASOBOSHI_MVD_819 ZORRO_ID(MASOBOSHI, 0x07, 0)
352
353#define ZORRO_MANUF_MAINHATTAN_DATA 0x086F
354#define ZORRO_PROD_MAINHATTAN_DATA_IDE ZORRO_ID(MAINHATTAN_DATA, 0x01, 0)
355
356#define ZORRO_MANUF_VILLAGE_TRONIC 0x0877
357#define ZORRO_PROD_VILLAGE_TRONIC_DOMINO_RAM ZORRO_ID(VILLAGE_TRONIC, 0x01, 0)
358#define ZORRO_PROD_VILLAGE_TRONIC_DOMINO_REG ZORRO_ID(VILLAGE_TRONIC, 0x02, 0)
359#define ZORRO_PROD_VILLAGE_TRONIC_DOMINO_16M_PROTOTYPE ZORRO_ID(VILLAGE_TRONIC, 0x03, 0)
360#define ZORRO_PROD_VILLAGE_TRONIC_PICASSO_II_II_PLUS_RAM ZORRO_ID(VILLAGE_TRONIC, 0x0B, 0)
361#define ZORRO_PROD_VILLAGE_TRONIC_PICASSO_II_II_PLUS_REG ZORRO_ID(VILLAGE_TRONIC, 0x0C, 0)
362#define ZORRO_PROD_VILLAGE_TRONIC_PICASSO_II_II_PLUS_SEGMENTED_MODE ZORRO_ID(VILLAGE_TRONIC, 0x0D, 0)
363#define ZORRO_PROD_VILLAGE_TRONIC_PICASSO_IV_Z2_MEM1 ZORRO_ID(VILLAGE_TRONIC, 0x15, 0)
364#define ZORRO_PROD_VILLAGE_TRONIC_PICASSO_IV_Z2_MEM2 ZORRO_ID(VILLAGE_TRONIC, 0x16, 0)
365#define ZORRO_PROD_VILLAGE_TRONIC_PICASSO_IV_Z2_REG ZORRO_ID(VILLAGE_TRONIC, 0x17, 0)
366#define ZORRO_PROD_VILLAGE_TRONIC_PICASSO_IV_Z3 ZORRO_ID(VILLAGE_TRONIC, 0x18, 0)
367#define ZORRO_PROD_VILLAGE_TRONIC_ARIADNE ZORRO_ID(VILLAGE_TRONIC, 0xC9, 0)
368#define ZORRO_PROD_VILLAGE_TRONIC_ARIADNE2 ZORRO_ID(VILLAGE_TRONIC, 0xCA, 0)
369
370#define ZORRO_MANUF_UTILITIES_UNLIMITED 0x087B
371#define ZORRO_PROD_UTILITIES_UNLIMITED_EMPLANT_DELUXE ZORRO_ID(UTILITIES_UNLIMITED, 0x15, 0)
372#define ZORRO_PROD_UTILITIES_UNLIMITED_EMPLANT_DELUXE2 ZORRO_ID(UTILITIES_UNLIMITED, 0x20, 0)
373
374#define ZORRO_MANUF_AMITRIX 0x0880
375#define ZORRO_PROD_AMITRIX_MULTI_IO ZORRO_ID(AMITRIX, 0x01, 0)
376#define ZORRO_PROD_AMITRIX_CD_RAM ZORRO_ID(AMITRIX, 0x02, 0)
377
378#define ZORRO_MANUF_ARMAX 0x0885
379#define ZORRO_PROD_ARMAX_OMNIBUS ZORRO_ID(ARMAX, 0x00, 0)
380
381#define ZORRO_MANUF_ZEUS 0x088D
382#define ZORRO_PROD_ZEUS_SPIDER ZORRO_ID(ZEUS, 0x04, 0)
383
384#define ZORRO_MANUF_NEWTEK 0x088F
385#define ZORRO_PROD_NEWTEK_VIDEOTOASTER ZORRO_ID(NEWTEK, 0x00, 0)
386
387#define ZORRO_MANUF_M_TECH_GERMANY 0x0890
388#define ZORRO_PROD_MTEC_AT500_2 ZORRO_ID(M_TECH_GERMANY, 0x01, 0)
389#define ZORRO_PROD_MTEC_68030 ZORRO_ID(M_TECH_GERMANY, 0x03, 0)
390#define ZORRO_PROD_MTEC_68020I ZORRO_ID(M_TECH_GERMANY, 0x06, 0)
391#define ZORRO_PROD_MTEC_A1200_T68030_RTC ZORRO_ID(M_TECH_GERMANY, 0x20, 0)
392#define ZORRO_PROD_MTEC_VIPER_MK_V_E_MATRIX_530 ZORRO_ID(M_TECH_GERMANY, 0x21, 0)
393#define ZORRO_PROD_MTEC_8_MB_RAM ZORRO_ID(M_TECH_GERMANY, 0x22, 0)
394#define ZORRO_PROD_MTEC_VIPER_MK_V_E_MATRIX_530_SCSI_IDE ZORRO_ID(M_TECH_GERMANY, 0x24, 0)
395
396#define ZORRO_MANUF_GREAT_VALLEY_PRODUCTS_4 0x0891
397#define ZORRO_PROD_GVP_EGS_28_24_SPECTRUM_RAM ZORRO_ID(GREAT_VALLEY_PRODUCTS_4, 0x01, 0)
398#define ZORRO_PROD_GVP_EGS_28_24_SPECTRUM_REG ZORRO_ID(GREAT_VALLEY_PRODUCTS_4, 0x02, 0)
399
400#define ZORRO_MANUF_APOLLO_1 0x0892
401#define ZORRO_PROD_APOLLO_A1200 ZORRO_ID(APOLLO_1, 0x01, 0)
402
403#define ZORRO_MANUF_HELFRICH_2 0x0893
404#define ZORRO_PROD_HELFRICH_PICCOLO_RAM ZORRO_ID(HELFRICH_2, 0x05, 0)
405#define ZORRO_PROD_HELFRICH_PICCOLO_REG ZORRO_ID(HELFRICH_2, 0x06, 0)
406#define ZORRO_PROD_HELFRICH_PEGGY_PLUS_MPEG ZORRO_ID(HELFRICH_2, 0x07, 0)
407#define ZORRO_PROD_HELFRICH_VIDEOCRUNCHER ZORRO_ID(HELFRICH_2, 0x08, 0)
408#define ZORRO_PROD_HELFRICH_SD64_RAM ZORRO_ID(HELFRICH_2, 0x0A, 0)
409#define ZORRO_PROD_HELFRICH_SD64_REG ZORRO_ID(HELFRICH_2, 0x0B, 0)
410
411#define ZORRO_MANUF_MACROSYSTEMS_USA 0x089B
412#define ZORRO_PROD_MACROSYSTEMS_WARP_ENGINE_40xx ZORRO_ID(MACROSYSTEMS_USA, 0x13, 0)
413
414#define ZORRO_MANUF_ELBOX_COMPUTER 0x089E
415#define ZORRO_PROD_ELBOX_COMPUTER_1200_4 ZORRO_ID(ELBOX_COMPUTER, 0x06, 0)
416
417#define ZORRO_MANUF_HARMS_PROFESSIONAL 0x0A00
418#define ZORRO_PROD_HARMS_PROFESSIONAL_030_PLUS ZORRO_ID(HARMS_PROFESSIONAL, 0x10, 0)
419#define ZORRO_PROD_HARMS_PROFESSIONAL_3500 ZORRO_ID(HARMS_PROFESSIONAL, 0xD0, 0)
420
421#define ZORRO_MANUF_MICRONIK 0x0A50
422#define ZORRO_PROD_MICRONIK_RCA_120 ZORRO_ID(MICRONIK, 0x0A, 0)
423
424#define ZORRO_MANUF_MICRONIK2 0x0F0F
425#define ZORRO_PROD_MICRONIK2_Z3I ZORRO_ID(MICRONIK2, 0x01, 0)
426
427#define ZORRO_MANUF_MEGAMICRO 0x1000
428#define ZORRO_PROD_MEGAMICRO_SCRAM_500 ZORRO_ID(MEGAMICRO, 0x03, 0)
429#define ZORRO_PROD_MEGAMICRO_SCRAM_500_RAM ZORRO_ID(MEGAMICRO, 0x04, 0)
430
431#define ZORRO_MANUF_IMTRONICS_2 0x1028
432#define ZORRO_PROD_IMTRONICS_HURRICANE_2800_3 ZORRO_ID(IMTRONICS_2, 0x39, 0)
433#define ZORRO_PROD_IMTRONICS_HURRICANE_2800_4 ZORRO_ID(IMTRONICS_2, 0x57, 0)
434
435/* unofficial ID */
436#define ZORRO_MANUF_INDIVIDUAL_COMPUTERS 0x1212
437#define ZORRO_PROD_INDIVIDUAL_COMPUTERS_BUDDHA ZORRO_ID(INDIVIDUAL_COMPUTERS, 0x00, 0)
438#define ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF ZORRO_ID(INDIVIDUAL_COMPUTERS, 0x17, 0)
439#define ZORRO_PROD_INDIVIDUAL_COMPUTERS_CATWEASEL ZORRO_ID(INDIVIDUAL_COMPUTERS, 0x2A, 0)
440
441#define ZORRO_MANUF_KUPKE_3 0x1248
442#define ZORRO_PROD_KUPKE_GOLEM_HD_3000 ZORRO_ID(KUPKE_3, 0x01, 0)
443
444#define ZORRO_MANUF_ITH 0x1388
445#define ZORRO_PROD_ITH_ISDN_MASTER_II ZORRO_ID(ITH, 0x01, 0)
446
447#define ZORRO_MANUF_VMC 0x1389
448#define ZORRO_PROD_VMC_ISDN_BLASTER_Z2 ZORRO_ID(VMC, 0x01, 0)
449#define ZORRO_PROD_VMC_HYPERCOM_4 ZORRO_ID(VMC, 0x02, 0)
450
451#define ZORRO_MANUF_INFORMATION 0x157C
452#define ZORRO_PROD_INFORMATION_ISDN_ENGINE_I ZORRO_ID(INFORMATION, 0x64, 0)
453
454#define ZORRO_MANUF_VORTEX 0x2017
455#define ZORRO_PROD_VORTEX_GOLDEN_GATE_80386SX ZORRO_ID(VORTEX, 0x07, 0)
456#define ZORRO_PROD_VORTEX_GOLDEN_GATE_RAM ZORRO_ID(VORTEX, 0x08, 0)
457#define ZORRO_PROD_VORTEX_GOLDEN_GATE_80486 ZORRO_ID(VORTEX, 0x09, 0)
458
459#define ZORRO_MANUF_EXPANSION_SYSTEMS 0x2062
460#define ZORRO_PROD_EXPANSION_SYSTEMS_DATAFLYER_4000SX ZORRO_ID(EXPANSION_SYSTEMS, 0x01, 0)
461#define ZORRO_PROD_EXPANSION_SYSTEMS_DATAFLYER_4000SX_RAM ZORRO_ID(EXPANSION_SYSTEMS, 0x02, 0)
462
463#define ZORRO_MANUF_READYSOFT 0x2100
464#define ZORRO_PROD_READYSOFT_AMAX_II_IV ZORRO_ID(READYSOFT, 0x01, 0)
465
466#define ZORRO_MANUF_PHASE5 0x2140
467#define ZORRO_PROD_PHASE5_BLIZZARD_RAM ZORRO_ID(PHASE5, 0x01, 0)
468#define ZORRO_PROD_PHASE5_BLIZZARD ZORRO_ID(PHASE5, 0x02, 0)
469#define ZORRO_PROD_PHASE5_BLIZZARD_1220_IV ZORRO_ID(PHASE5, 0x06, 0)
470#define ZORRO_PROD_PHASE5_FASTLANE_Z3_RAM ZORRO_ID(PHASE5, 0x0A, 0)
471#define ZORRO_PROD_PHASE5_BLIZZARD_1230_II_FASTLANE_Z3_CYBERSCSI_CYBERSTORM060 ZORRO_ID(PHASE5, 0x0B, 0)
472#define ZORRO_PROD_PHASE5_BLIZZARD_1220_CYBERSTORM ZORRO_ID(PHASE5, 0x0C, 0)
473#define ZORRO_PROD_PHASE5_BLIZZARD_1230 ZORRO_ID(PHASE5, 0x0D, 0)
474#define ZORRO_PROD_PHASE5_BLIZZARD_1230_IV_1260 ZORRO_ID(PHASE5, 0x11, 0)
475#define ZORRO_PROD_PHASE5_BLIZZARD_2060 ZORRO_ID(PHASE5, 0x18, 0)
476#define ZORRO_PROD_PHASE5_CYBERSTORM_MK_II ZORRO_ID(PHASE5, 0x19, 0)
477#define ZORRO_PROD_PHASE5_CYBERVISION64 ZORRO_ID(PHASE5, 0x22, 0)
478#define ZORRO_PROD_PHASE5_CYBERVISION64_3D_PROTOTYPE ZORRO_ID(PHASE5, 0x32, 0)
479#define ZORRO_PROD_PHASE5_CYBERVISION64_3D ZORRO_ID(PHASE5, 0x43, 0)
480#define ZORRO_PROD_PHASE5_CYBERSTORM_MK_III ZORRO_ID(PHASE5, 0x64, 0)
481#define ZORRO_PROD_PHASE5_BLIZZARD_603E_PLUS ZORRO_ID(PHASE5, 0x6e, 0)
482
483#define ZORRO_MANUF_DPS 0x2169
484#define ZORRO_PROD_DPS_PERSONAL_ANIMATION_RECORDER ZORRO_ID(DPS, 0x01, 0)
485
486#define ZORRO_MANUF_APOLLO_2 0x2200
487#define ZORRO_PROD_APOLLO_A620_68020_1 ZORRO_ID(APOLLO_2, 0x00, 0)
488#define ZORRO_PROD_APOLLO_A620_68020_2 ZORRO_ID(APOLLO_2, 0x01, 0)
489
490#define ZORRO_MANUF_APOLLO_3 0x2222
491#define ZORRO_PROD_APOLLO_AT_APOLLO ZORRO_ID(APOLLO_3, 0x22, 0)
492#define ZORRO_PROD_APOLLO_1230_1240_1260_2030_4040_4060 ZORRO_ID(APOLLO_3, 0x23, 0)
493
494#define ZORRO_MANUF_PETSOFF_LP 0x38A5
495#define ZORRO_PROD_PETSOFF_LP_DELFINA ZORRO_ID(PETSOFF_LP, 0x00, 0)
496#define ZORRO_PROD_PETSOFF_LP_DELFINA_LITE ZORRO_ID(PETSOFF_LP, 0x01, 0)
497
498#define ZORRO_MANUF_UWE_GERLACH 0x3FF7
499#define ZORRO_PROD_UWE_GERLACH_RAM_ROM ZORRO_ID(UWE_GERLACH, 0xd4, 0)
500
501#define ZORRO_MANUF_ACT 0x4231
502#define ZORRO_PROD_ACT_PRELUDE ZORRO_ID(ACT, 0x01, 0)
503
504#define ZORRO_MANUF_MACROSYSTEMS_GERMANY 0x4754
505#define ZORRO_PROD_MACROSYSTEMS_MAESTRO ZORRO_ID(MACROSYSTEMS_GERMANY, 0x03, 0)
506#define ZORRO_PROD_MACROSYSTEMS_VLAB ZORRO_ID(MACROSYSTEMS_GERMANY, 0x04, 0)
507#define ZORRO_PROD_MACROSYSTEMS_MAESTRO_PRO ZORRO_ID(MACROSYSTEMS_GERMANY, 0x05, 0)
508#define ZORRO_PROD_MACROSYSTEMS_RETINA ZORRO_ID(MACROSYSTEMS_GERMANY, 0x06, 0)
509#define ZORRO_PROD_MACROSYSTEMS_MULTI_EVOLUTION ZORRO_ID(MACROSYSTEMS_GERMANY, 0x08, 0)
510#define ZORRO_PROD_MACROSYSTEMS_TOCCATA ZORRO_ID(MACROSYSTEMS_GERMANY, 0x0C, 0)
511#define ZORRO_PROD_MACROSYSTEMS_RETINA_Z3 ZORRO_ID(MACROSYSTEMS_GERMANY, 0x10, 0)
512#define ZORRO_PROD_MACROSYSTEMS_VLAB_MOTION ZORRO_ID(MACROSYSTEMS_GERMANY, 0x12, 0)
513#define ZORRO_PROD_MACROSYSTEMS_ALTAIS ZORRO_ID(MACROSYSTEMS_GERMANY, 0x13, 0)
514#define ZORRO_PROD_MACROSYSTEMS_FALCON_040 ZORRO_ID(MACROSYSTEMS_GERMANY, 0xFD, 0)
515
516#define ZORRO_MANUF_COMBITEC 0x6766
517
518#define ZORRO_MANUF_SKI_PERIPHERALS 0x8000
519#define ZORRO_PROD_SKI_PERIPHERALS_MAST_FIREBALL ZORRO_ID(SKI_PERIPHERALS, 0x08, 0)
520#define ZORRO_PROD_SKI_PERIPHERALS_SCSI_DUAL_SERIAL ZORRO_ID(SKI_PERIPHERALS, 0x80, 0)
521
522#define ZORRO_MANUF_REIS_WARE_2 0xA9AD
523#define ZORRO_PROD_REIS_WARE_SCAN_KING ZORRO_ID(REIS_WARE_2, 0x11, 0)
524
525#define ZORRO_MANUF_CAMERON 0xAA01
526#define ZORRO_PROD_CAMERON_PERSONAL_A4 ZORRO_ID(CAMERON, 0x10, 0)
527
528#define ZORRO_MANUF_REIS_WARE 0xAA11
529#define ZORRO_PROD_REIS_WARE_HANDYSCANNER ZORRO_ID(REIS_WARE, 0x11, 0)
530
531#define ZORRO_MANUF_PHOENIX_2 0xB5A8
532#define ZORRO_PROD_PHOENIX_ST506_2 ZORRO_ID(PHOENIX_2, 0x21, 0)
533#define ZORRO_PROD_PHOENIX_SCSI_2 ZORRO_ID(PHOENIX_2, 0x22, 0)
534#define ZORRO_PROD_PHOENIX_RAM_2 ZORRO_ID(PHOENIX_2, 0xBE, 0)
535
536#define ZORRO_MANUF_COMBITEC_2 0xC008
537#define ZORRO_PROD_COMBITEC_HD ZORRO_ID(COMBITEC_2, 0x2A, 0)
538#define ZORRO_PROD_COMBITEC_SRAM ZORRO_ID(COMBITEC_2, 0x2B, 0)
539
540
541 /*
542 * Test and illegal Manufacturer IDs.
543 */
544
545#define ZORRO_MANUF_HACKER 0x07DB
546#define ZORRO_PROD_GENERAL_PROTOTYPE ZORRO_ID(HACKER, 0x00, 0)
547#define ZORRO_PROD_HACKER_SCSI ZORRO_ID(HACKER, 0x01, 0)
548#define ZORRO_PROD_RESOURCE_MANAGEMENT_FORCE_QUICKNET_QN2000 ZORRO_ID(HACKER, 0x02, 0)
549#define ZORRO_PROD_VECTOR_CONNECTION_2 ZORRO_ID(HACKER, 0xE0, 0)
550#define ZORRO_PROD_VECTOR_CONNECTION_3 ZORRO_ID(HACKER, 0xE1, 0)
551#define ZORRO_PROD_VECTOR_CONNECTION_4 ZORRO_ID(HACKER, 0xE2, 0)
552#define ZORRO_PROD_VECTOR_CONNECTION_5 ZORRO_ID(HACKER, 0xE3, 0)
diff --git a/include/linux/zutil.h b/include/linux/zutil.h
new file mode 100644
index 000000000000..fdfd5ed41ec4
--- /dev/null
+++ b/include/linux/zutil.h
@@ -0,0 +1,119 @@
1/* zutil.h -- internal interface and configuration of the compression library
2 * Copyright (C) 1995-1998 Jean-loup Gailly.
3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */
5
6/* WARNING: this file should *not* be used by applications. It is
7 part of the implementation of the compression library and is
8 subject to change. Applications should only use zlib.h.
9 */
10
11/* @(#) $Id: zutil.h,v 1.1 2000/01/01 03:32:23 davem Exp $ */
12
13#ifndef _Z_UTIL_H
14#define _Z_UTIL_H
15
16#include <linux/zlib.h>
17#include <linux/string.h>
18#include <linux/errno.h>
19#include <linux/kernel.h>
20
21typedef unsigned char uch;
22typedef unsigned short ush;
23typedef unsigned long ulg;
24
25 /* common constants */
26
27#ifndef DEF_WBITS
28# define DEF_WBITS MAX_WBITS
29#endif
30/* default windowBits for decompression. MAX_WBITS is for compression only */
31
32#if MAX_MEM_LEVEL >= 8
33# define DEF_MEM_LEVEL 8
34#else
35# define DEF_MEM_LEVEL MAX_MEM_LEVEL
36#endif
37/* default memLevel */
38
39#define STORED_BLOCK 0
40#define STATIC_TREES 1
41#define DYN_TREES 2
42/* The three kinds of block type */
43
44#define MIN_MATCH 3
45#define MAX_MATCH 258
46/* The minimum and maximum match lengths */
47
48#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
49
50 /* target dependencies */
51
52 /* Common defaults */
53
54#ifndef OS_CODE
55# define OS_CODE 0x03 /* assume Unix */
56#endif
57
58 /* functions */
59
60typedef uLong (*check_func) (uLong check, const Byte *buf,
61 uInt len);
62
63
64 /* checksum functions */
65
66#define BASE 65521L /* largest prime smaller than 65536 */
67#define NMAX 5552
68/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
69
70#define DO1(buf,i) {s1 += buf[i]; s2 += s1;}
71#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
72#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
73#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
74#define DO16(buf) DO8(buf,0); DO8(buf,8);
75
76/* ========================================================================= */
77/*
78 Update a running Adler-32 checksum with the bytes buf[0..len-1] and
79 return the updated checksum. If buf is NULL, this function returns
80 the required initial value for the checksum.
81 An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
82 much faster. Usage example:
83
84 uLong adler = adler32(0L, NULL, 0);
85
86 while (read_buffer(buffer, length) != EOF) {
87 adler = adler32(adler, buffer, length);
88 }
89 if (adler != original_adler) error();
90*/
91static inline uLong zlib_adler32(uLong adler,
92 const Byte *buf,
93 uInt len)
94{
95 unsigned long s1 = adler & 0xffff;
96 unsigned long s2 = (adler >> 16) & 0xffff;
97 int k;
98
99 if (buf == NULL) return 1L;
100
101 while (len > 0) {
102 k = len < NMAX ? len : NMAX;
103 len -= k;
104 while (k >= 16) {
105 DO16(buf);
106 buf += 16;
107 k -= 16;
108 }
109 if (k != 0) do {
110 s1 += *buf++;
111 s2 += s1;
112 } while (--k);
113 s1 %= BASE;
114 s2 %= BASE;
115 }
116 return (s2 << 16) | s1;
117}
118
119#endif /* _Z_UTIL_H */